Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Added some comments and a README
Browse files Browse the repository at this point in the history
  • Loading branch information
cikzh committed Mar 27, 2024
1 parent a68a928 commit 6e1736d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
11 changes: 5 additions & 6 deletions templates/model-o-7.typ
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
[De verkiezing van de leden van de *#input.leden_van*]
)


#grid(
columns: (100pt, auto),
gutter: 5pt,
Expand Down Expand Up @@ -76,7 +75,7 @@ Het aantal kiesgerechtigden woonachtig in de van deze kieskring deel uitmakende
inset: 5pt,
[*#letter*],
[#votes]
)
)
}

#align(
Expand Down Expand Up @@ -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*],
),
Expand Down

0 comments on commit 6e1736d

Please sign in to comment.