diff --git a/.gitignore b/.gitignore index ba4df6d..705f3a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.zip -*.pdf \ No newline at end of file +*.pdf +result* \ No newline at end of file diff --git a/DEVELOP.md b/DEVELOP.md new file mode 100644 index 0000000..261dc59 --- /dev/null +++ b/DEVELOP.md @@ -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 ''`. For more info see https://typst.app/universe/package/prequery. \ No newline at end of file diff --git a/build.nu b/build.nu index d83268d..f046120 100644 --- a/build.nu +++ b/build.nu @@ -10,4 +10,6 @@ each { |folder| let zip = ("../" + $folder + ".zip") rm -f $zip 7z a $zip * -} \ No newline at end of file +} + +typst compile main.typ \ No newline at end of file diff --git a/common/common.typ b/common/common.typ index eae5ece..fd97dad 100644 --- a/common/common.typ +++ b/common/common.typ @@ -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 ] -} \ No newline at end of file +} + +#let runCommand(cmd: str, ..args) = prequery( + (data: cmd, path: args.pos().at(0)), + , + () => { + let output = read(..args) + raw(block: true, output) + }, + fallback: [ + ``` + ... + ``` + ] +) \ No newline at end of file diff --git a/main.typ b/main.typ new file mode 100644 index 0000000..5a107ac --- /dev/null +++ b/main.typ @@ -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 + } +} diff --git a/shell.nix b/shell.nix index 7631554..946a87b 100644 --- a/shell.nix +++ b/shell.nix @@ -4,8 +4,11 @@ pkgs.mkShell rec { buildInputs = with pkgs; [ jdk + typst ]; nativeBuildInputs = with pkgs; [ jre ]; + + TYPST_FEATURES = "html"; }