diff options
author | Sudipto Mallick <smlckz@termux-alpine> | 2024-01-12 10:13:01 +0000 |
---|---|---|
committer | Sudipto Mallick <smlckz@termux-alpine> | 2024-01-12 10:13:01 +0000 |
commit | ac7aba2bacaaf74a91e218ee537fe3bf267b8e4d (patch) | |
tree | ffa6a98fa31b9031b918d448a6cb7744ad66122d /java/prelude.typ | |
parent | 87554cf575a4a92f00908a7cccfe6c92db2ef3ef (diff) | |
download | zadania-ac7aba2bacaaf74a91e218ee537fe3bf267b8e4d.tar.gz |
Initial implementation of complete assignment
This is the initial implementation of the generation of complete document of the assignments. java/buildall: Generates a Typst document from the list of assignments in `alist.txt` (needs to updated to work with `state.sql` in future). java/prelude.typ: Contains the prelude code responsible for generating the table of contents, using the facilities provided by Typst. java/template.typ: Updated so that it can be used with `prelude.typ` for generating the table of contents. .gitignore: To ignore `all.typ`, which is a build artifact.
Diffstat (limited to 'java/prelude.typ')
-rw-r--r-- | java/prelude.typ | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/java/prelude.typ b/java/prelude.typ new file mode 100644 index 0000000..027bfef --- /dev/null +++ b/java/prelude.typ @@ -0,0 +1,38 @@ +#import "@preview/tablex:0.0.7": tablex, cellx +#import "/template.typ": * + +#apply(page-numbering: "(i)" , [ + #align(center, [== Contents]) + #let heading-format(content) = cellx(align: center + horizon, content) + #let col-aligns = (right, auto, center + horizon, center + horizon, auto) + #let preprocess-alist(l, lpno) = { + let i = 0 + let e = l.len() - 1 + let nl = () + while i < e { + let it = l.at(i) + i = i + 1 + let nit = l.at(i) + it.at(2) = [ #it.at(2) - #{nit.at(2) - 1} ] + it.push([]) + nl.push(it) + } + l.at(e).at(2) = [ #{l.at(e).at(2)} - #lpno ] + l.at(e).push([]) + nl.push(l.at(e)) + nl + } + #list-of-assignments((l, lpno) => + tablex( + columns: (3em, 1fr, 4em, 8em, 10em), + stroke: 1pt + gray, + map-cols: (i, cells) => (cells.first(), ..cells.slice(1).map(cell => (..cell, align: col-aligns.at(i)))), + heading-format[*Sl.* \ *No.*], heading-format[*Description*], heading-format[*Page No.*], heading-format[*Date*], heading-format[*Teacher’s* \ *Signature*], + ..preprocess-alist(l, lpno).flatten(), + )) +]) + +#colbreak() + +#counter(page).update(0) + |