This commit is contained in:
2026-01-30 09:45:24 -10:00
parent fd0ec5aabc
commit 97747c6b5c
3 changed files with 167 additions and 74 deletions
+11 -11
View File
@@ -85,7 +85,7 @@ Using `~()` - the unquote concept from Clojure's syntax-quote:
#t"The value is ~(expr)."
;; Hiccup expression returns content
#t"Click ~([:link {:dest url} label]) to continue."
#t"Click ~([:link {:src url} label]) to continue."
;; Conditional
#t"Status: ~(if done? 'Complete' 'Pending')"
@@ -128,7 +128,7 @@ Same mental model as macro unquote:
[:block {:inset "1em"}
[:strong name] [:linebreak]
[:emph affiliation] [:linebreak]
[:link {:dest (str "mailto:" email)} email]])
[:link {:src (str "mailto:" email)} email]])
(defn results-table [data]
[:table {:columns 2 :align ["left" "right"]}
@@ -171,8 +171,8 @@ Same mental model as macro unquote:
"
;; Back to hiccup for the technical diagram
[:figure {:caption "System architecture overview."}
[:image {:width "80%"} "architecture.png"]]
[:figure {:caption "System architecture overview." :label :fig/arch}
[:image {:src "architecture.png" :width "80%"}]]
#t"
Our method works by first processing the input through
@@ -198,7 +198,7 @@ Same mental model as macro unquote:
"
;; Bibliography could be generated
[:bibliography "refs.bib"]])
[:bibliography {:src "refs.bib"}]])
;; Compile it
(compile-to-typst paper "paper.typ")
@@ -303,7 +303,7 @@ Build mini-languages for specific domains:
`(do
(register-figure! ~id)
[:figure {:label ~id :caption ["Figure " (figure-num ~id) ": " ~caption]}
[:image {:width ~(or width "100%")} ~src]]))
[:image {:src ~src :width ~(or width "100%")}]]))
(figure :arch
:src "architecture.png"
@@ -319,15 +319,15 @@ Build mini-languages for specific domains:
;; Shorthand for references
(defmacro ref [id]
`[:ref ~(str "@" (name id))])
`[:ref {:target ~id}])
;; Shorthand for citations
(defmacro cite [& keys]
`[:cite ~@(map #(str "@" (name %)) keys)])
`[:cite {:keys [~@keys]}])
;; Usage
(ref :fig:arch) ; => @fig:arch
(cite :smith2020 :jones2021) ; => @smith2020 @jones2021
(ref :fig/arch) ; => [:ref {:target :fig/arch}]
(cite :smith2020 :jones2021) ; => [:cite {:keys [:smith2020 :jones2021]}]
```
### Template Macros
@@ -339,7 +339,7 @@ Build mini-languages for specific domains:
~@structure))
(deftemplate ieee-paper [title authors abstract]
[[:set :page {:paper "us-letter" :columns 2}]
[[:set {:element :page :paper "us-letter" :columns 2}]
[:heading {:level 1 :align "center"} ~title]
(render-authors ~authors)
(render-abstract ~abstract)