summary refs log tree commit diff stats
path: root/java/template.typ
diff options
context:
space:
mode:
authorSudipto Mallick <smlckz@termux-alpine>2024-01-12 10:13:01 +0000
committerSudipto Mallick <smlckz@termux-alpine>2024-01-12 10:13:01 +0000
commitac7aba2bacaaf74a91e218ee537fe3bf267b8e4d (patch)
treeffa6a98fa31b9031b918d448a6cb7744ad66122d /java/template.typ
parent87554cf575a4a92f00908a7cccfe6c92db2ef3ef (diff)
downloadzadania-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/template.typ')
-rw-r--r--java/template.typ17
1 files changed, 13 insertions, 4 deletions
diff --git a/java/template.typ b/java/template.typ
index 47a97a1..57e2e48 100644
--- a/java/template.typ
+++ b/java/template.typ
@@ -31,13 +31,13 @@
 }
 
 /* Draws page border around the provided content, taking an optional function to be called at the footer. */
-#let apply-page-borders(body, ..font-options, footer-special-func: none) = {
+#let apply-page-borders(body, ..font-options, footer-special-func: none, page-numbering: none) = {
   let page-margin = (left: 0.75in, right: 0.25in, top: 0.25in, bottom: 0.25in)
   let margin = (left: 0.65in, right: 0.15in, top: 1.5em, bottom: 1.5em)
   let page-border-thickness = 1.25pt
   set page(
     margin: (..page-margin, bottom: margin.bottom + 2em),
-    numbering: "1",
+    numbering: if page-numbering != none { page-numbering } else { "1" },
     background: align(top + start, pad(..margin, rect(width: 100%, height: 100%, stroke: page-border-thickness + gray, radius: 5pt))),
     footer: locate(loc => {
       align(center, move(dy: -margin.bottom + 1em, text(..font-options, size: 9pt, counter(page).display(loc.page-numbering()))))
@@ -50,7 +50,7 @@
   body
 }
 
-#let apply(body) = {
+#let apply(body, page-numbering: none) = {
   let body-font-settings = (font: "Nunito Sans 10pt", size: 12pt, stretch: 75%)
 //  let body-font-settings = (font: "Hanken Grotesk", size: 12pt, stretch: 75%)
   set text(..body-font-settings)
@@ -74,7 +74,7 @@
   show raw.where(block: true): it => align(left, it)
   set list(marker: ([$square.filled.tiny$], [--]))
   set par(leading: 0.5em)
-  apply-page-borders(body, ..body-font-settings, footer-special-func: signature-footer)
+  apply-page-borders(body, ..body-font-settings, footer-special-func: signature-footer, page-numbering: page-numbering)
 }
 
 #let scos(name) = {
@@ -86,9 +86,18 @@
   include ofname
 }
 
+#let alist = state("assignment-list", ())
+
+#let list-of-assignments(cb) = locate(loc => {
+  let l = alist.final(loc)
+  let lpno = counter(page).final(loc).first()
+  cb(l, lpno)
+})
+
 #let assignment(number, description) = align(center, [
 = #text(weight: 600, [Assignment #number])
 == #text(weight: 500, [Program statement:]) #text(weight: 400, description)
+#locate(loc => alist.update(lst => (..lst, (number, description, counter(page).at(loc).first(), []))))
 ])
 
 #let skind(kind) = [