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

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*.zip *.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

@ -11,3 +11,5 @@ each { |folder|
rm -f $zip rm -f $zip
7z a $zip * 7z a $zip *
} }
typst compile main.typ

View file

@ -1,10 +1,13 @@
#import "@preview/prequery:0.2.0": prequery
#let template(doc) = [ #let template(doc) = context {
#set page(height: auto) if target() != "html" {
#show link: underline set page(height: auto)
#set quote(block: true) }
#doc show link: underline
] set quote(block: true)
doc
}
#let embedClass(name: str, label: none) = { #let embedClass(name: str, label: none) = {
show figure: set block(width: 100%) show figure: set block(width: 100%)
@ -15,3 +18,17 @@
#label #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 { pkgs.mkShell rec {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
jdk jdk
typst
]; ];
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
jre jre
]; ];
TYPST_FEATURES = "html";
} }