Files
chfoit-ipa/util/glossary.typ
T
2026-09-18 16:36:52 +02:00

52 lines
953 B
Typst

#let _glossaryDict = state("e8759020-8d68-4920-9ce6-246b09c3094b", none)
#let setDefaults(defaults) = {
_glossaryDict.update(dict => {
for (term, explanation) in defaults.pairs() {
dict.insert(term, explanation)
}
return dict
})
}
#let term(term, explanation) = {
_glossaryDict.update(dict => {
if dict == none {
return (
"" + term: explanation,
)
}
dict.insert(term, explanation)
return dict
})
term
}
#let glossary() = {
context {
if _glossaryDict.get() == none {
return
}
[ = Glossar]
terms(tight: true)
figure(
table(
columns: (1fr, 3fr),
table.header([Begriff], [Bedeutung]),
.._glossaryDict
.get()
.keys()
.sorted(key: lower)
.map(key => (
key,
_glossaryDict.get().at(key),
))
.flatten(),
),
caption: [Glossar],
)
}
}