diff --git a/README.md b/README.md new file mode 100644 index 0000000..c545155 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Kiesraad Rust PDF generation + +A Proof of Concept application that generates a PDF given a `model` consisting of a Typst template and some JSON `input`. + +## Usage + +### Development + +Typst template development can be done in several ways. Via the `typst-cli`, The [online Typst editor](https://typst.app/), or via this Rust program by running: + +```console +$ cargo watch -x run +``` + +To develop Typst in your editor of choice, there is a [Typst language server](https://github.com/nvarner/typst-lsp) available and a [Tree-sitter grammar](https://github.com/uben0/tree-sitter-typst). + +### Packaging + +This Proof of Concept tries to make installation as easy as possible by embedding all assets in the binary. When running or building in release mode (`cargo build --release`), all Typst files and fonts are embedded into the binary and used from memory when running the application. diff --git a/src/main.rs b/src/main.rs index f5196eb..1885c1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,9 @@ mod world; #[derive(Parser)] struct Cli { + /// The model to render, in kebab-case (example: model-p-22-1) model: String, + /// The path to the JSON input data input: PathBuf, } diff --git a/templates/model-o-7.typ b/templates/model-o-7.typ index ce99e79..8e488a0 100644 --- a/templates/model-o-7.typ +++ b/templates/model-o-7.typ @@ -13,7 +13,6 @@ [De verkiezing van de leden van de *#input.leden_van*] ) - #grid( columns: (100pt, auto), gutter: 5pt, @@ -76,7 +75,7 @@ Het aantal kiesgerechtigden woonachtig in de van deze kieskring deel uitmakende inset: 5pt, [*#letter*], [#votes] - ) + ) } #align( @@ -108,10 +107,10 @@ Het aantal kiesgerechtigden woonachtig in de van deze kieskring deel uitmakende fill: (_, y) => if calc.odd(y) { rgb("EAF2F5") }, table.header( table.cell(colspan: 3, grid( - columns: (auto, auto), - gutter: 12pt, - [*Lijstnaam*], [#lijst.naam], - [*Lijstnummer*], [#lijst.lijstnummer], + columns: (auto, auto), + gutter: 12pt, + [*Lijstnaam*], [#lijst.naam], + [*Lijstnummer*], [#lijst.lijstnummer], )), [*Nummer op de lijst*], [*Naam kandidaat*], [*Aantal stemmen*], ),