experiment with formatting

This commit is contained in:
Daniel Bulant 2025-10-07 17:15:22 +02:00
parent a475669d50
commit 94711b2ec7
No known key found for this signature in database
6 changed files with 60 additions and 9 deletions

3
.gitignore vendored
View file

@ -1,2 +1,3 @@
*.zip
*.pdf
*.pdf
result*

5
DEVELOP.md Normal file
View file

@ -0,0 +1,5 @@
When a command runner is desired in the function, query functionality can be used.
In `common/common.typ`, there's a `runCommand` function.
This can be queried using `typst query --input prequery-fallback=true --field value doc.typ '<cmd>'`. For more info see https://typst.app/universe/package/prequery.

View file

@ -10,4 +10,6 @@ each { |folder|
let zip = ("../" + $folder + ".zip")
rm -f $zip
7z a $zip *
}
}
typst compile main.typ

View file

@ -1,10 +1,13 @@
#import "@preview/prequery:0.2.0": prequery
#let template(doc) = [
#set page(height: auto)
#show link: underline
#set quote(block: true)
#doc
]
#let template(doc) = context {
if target() != "html" {
set page(height: auto)
}
show link: underline
set quote(block: true)
doc
}
#let embedClass(name: str, label: none) = {
show figure: set block(width: 100%)
@ -14,4 +17,18 @@
#figure(caption: name, kind: "Class", supplement: [Class], raw(read("../" + name + ".java"), lang:"java", block: true))
#label
]
}
}
#let runCommand(cmd: str, ..args) = prequery(
(data: cmd, path: args.pos().at(0)),
<cmd>,
() => {
let output = read(..args)
raw(block: true, output)
},
fallback: [
```
...
```
]
)

23
main.typ Normal file
View file

@ -0,0 +1,23 @@
#set document(
title: "Introduction to Programming - Exercise solutions",
author: "Daniel Bulant"
)
= Introduction to Programming
Collection of solutions to programming exercises as part of Introduction to Programming (EN), taught by Magnus Madsen.
#outline()
#outline(
title: [Classes],
target: figure.where(kind: "Class")
)
#{
let count = 5;
for week in range(1, count + 1) {
let a = "./week" + str(week) + "/doc.typ"
include a
}
}

View file

@ -4,8 +4,11 @@
pkgs.mkShell rec {
buildInputs = with pkgs; [
jdk
typst
];
nativeBuildInputs = with pkgs; [
jre
];
TYPST_FEATURES = "html";
}