diff options
| author | hachem <im@hachem.wtf> | 2026-09-18 18:29:59 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-18 18:29:59 +0200 |
| commit | 8075871a5b364d41f59a8153bb632cd9c893f895 (patch) | |
| tree | 04343c6574d15d8b9ae8ceb555070b764e46b266 | |
| parent | 5ecd3773b5a6f40b2c83687180d6f674959f46a3 (diff) | |
chore: docs
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | README.md | 67 | ||||
| -rw-r--r-- | mktypst.1 | 122 | ||||
| -rw-r--r-- | mktypst.c | 4 |
4 files changed, 195 insertions, 2 deletions
@@ -31,6 +31,7 @@ endif PREFIX ?= /usr/local bindir := $(DESTDIR)$(PREFIX)/bin +mandir := $(DESTDIR)$(PREFIX)/share/man/man1 ifeq ($(shell uname),Darwin) DATADIR := $(HOME)/Library/Application Support @@ -50,6 +51,8 @@ install-bin: $(MAKE) DEBUG=0 SANITIZE=0 clean $(BIN) install -d $(bindir) install -m 755 $(BIN) $(bindir)/$(BIN) + install -d $(mandir) + install -m 644 $(BIN).1 $(mandir)/$(BIN).1 install-pkg: mkdir -p "$(pkgdir)" @@ -58,6 +61,7 @@ install-pkg: uninstall: rm -f $(bindir)/$(BIN) + rm -f $(mandir)/$(BIN).1 rm -rf "$(DATADIR)/typst/packages/local/$(PKG)/$(VERSION)" samples: @@ -2,6 +2,73 @@ Just a couple of dumb Typst templates so I stop rewriting the same document setup every fucking time. +```sh +$ mktypst rapport +$ typst watch rapport.typ +``` + +## Templates +`paper` is a two-column academic article; `letter` is a French formal letter. Both are French by default (`lang: "fr"`), so you get guillemets, the spacing before `; : ! ?`, `Résumé`, `Tableau`, all of it — pass `lang: "en"` for English. + +You apply one with a `#show` rule at the top of the document and start writing: + +```typ +#import "@local/hachem:0.1.0": paper + +#show: paper.with( + title: "Les Origines de YHWH", + date: "mars 2026", + authors: ((name: "Hachem H.", location: [Paris, France]),), + abstract: [Un paragraphe.], +) + += Introduction +Du texte. +``` + +The `letter` works the same way. There are full examples in `samples/`, and `make samples` compiles them. + +## Usage + +```text +$ mktypst --help +mktypst 0.1.0 - dumb typst document generator + +generates a typst document that imports and applies an mktypst +template, so you can start writing instead of pasting a preamble. + +usage: mktypst [-t template] [-T title] [-a author] [-d date] [-f] <name> + mktypst [-v | -h] + +options: + -t, --template NAME template to apply (default paper) + -T, --title TITLE document title (default: the name) + -a, --author NAME author name (default: git config user.name) + -d, --date DATE document date (default: current month) + -f, --force overwrite an existing file + --stdout write to stdout instead of a .typ file + -v, --version print version and bail + -h, --help print this and bail + +by hachem <im@hachem.wtf> +``` + +```sh +$ mktypst rapport # paper, the default +$ mktypst -t letter -T "candidature" x # a letter instead +$ mktypst --stdout note # print it, don't write a file +``` + +## Install + +```sh +$ git clone https://git.hachem.wtf/mktypst && cd mktypst +$ sudo make install # mktypst -> /usr/local/bin, templates -> @local/hachem +$ make install PREFIX=~/.local # or without sudo +``` + +You need a C compiler for the binary, and Typst (plus the EB Garamond font) to build documents. The templates install into Typst's local package dir, so any file can `#import "@local/hachem:0.1.0"`. In the Typst app, link that folder as the namespace `local` and it works there too. + ## License `mktypst` is licensed under the MIT License. See [LICENSE](LICENSE) for more. diff --git a/mktypst.1 b/mktypst.1 new file mode 100644 index 0000000..66b9722 --- /dev/null +++ b/mktypst.1 @@ -0,0 +1,122 @@ +.TH MKTYPST 1 "2026-09-18" "mktypst 0.1.0" "User Commands" +.SH NAME +mktypst \- dumb typst document generator +.SH SYNOPSIS +.B mktypst +.RI [ options ] +.I name +.br +.B mktypst +.BR \-v | \-h +.SH DESCRIPTION +.B mktypst +writes a Typst document that already imports and applies one of the +.B @local/hachem +templates, so you can start writing instead of pasting the same preamble every +time. +.PP +It creates +.IR name .typ +(the +.B .typ +extension is added if you leave it off) and refuses to overwrite an existing +file unless +.B \-\-force +is given. With +.B \-\-stdout +the document is written to standard output instead. +.SH OPTIONS +.TP +.BR \-t ", " \-\-template " " \fIname\fR +Template to apply: +.B paper +or +.BR letter . +Default +.BR paper . +.TP +.BR \-T ", " \-\-title " " \fItitle\fR +Document title. Defaults to +.I name +with any +.B .typ +trimmed. +.TP +.BR \-a ", " \-\-author " " \fIname\fR +Author name. Defaults to +.BR "git config user.name" , +falling back to +.BR $USER . +.TP +.BR \-d ", " \-\-date " " \fIdate\fR +Document date. Defaults to the current month and year, localized through +.BR LC_TIME . +.TP +.BR \-f ", " \-\-force +Overwrite an existing file. +.TP +.B \-\-stdout +Write to standard output instead of a +.B .typ +file. +.TP +.BR \-v ", " \-\-version +Print version and exit. +.TP +.BR \-h ", " \-\-help +Print a usage summary and exit. +.SH TEMPLATES +.TP +.B paper +A two-column academic article. +.TP +.B letter +A French formal letter. +.PP +Both are French by default; pass +.B "lang: \(dqen\(dq" +to the template for English. +.SH ENVIRONMENT +.TP +.B LC_TIME +Sets the locale used for the default date, so the month name matches your +system's language. +.SH EXAMPLES +.TP +.B mktypst rapport +A paper, with the title, author and date filled in. +.TP +.B mktypst \-t letter \-T candidature lettre +A letter. +.TP +.B mktypst \-\-stdout note +Print the document instead of writing a file. +.PP +The generated file applies the chosen template with a +.B #show +rule; a paper reads: +.PP +.RS 4 +.EX +#import "@local/hachem:0.1.0": paper + +#show: paper.with( + title: "Les Origines de YHWH", + date: "mars 2026", + authors: ((name: "Hachem H.", location: [Paris, France]),), +) + += Introduction +.EE +.RE +.SH "EXIT STATUS" +.TP +.B 0 +The document was generated. +.TP +.B 1 +A usage error, or the file could not be written. +.SH "SEE ALSO" +.BR typst (1) +.SH AUTHOR +hachem <im@hachem.wtf> @@ -4,7 +4,7 @@ * generates a typst document that imports and applies an mktypst template, * so you can start writing instead of pasting the same preamble every time. * - * Author: hachem <contact@hachem.cc> + * Author: hachem <im@hachem.wtf> * Version: 0.1.0 */ @@ -77,7 +77,7 @@ static void print_usage(FILE* stream) " -v, --version print version and bail\n" " -h, --help print this and bail\n" "\n" - "by hachem <contact@hachem.cc>\n", + "by hachem <im@hachem.wtf>\n", mktypst_program, mktypst_version, mktypst_tagline, mktypst_program, mktypst_program); } |
