Files
clean-sheets/src/helpers.typ
T
2026-09-10 20:02:22 +02:00

69 lines
1.6 KiB
Typst

#import "config.typ": months-de, weekdays-short-de
#import "theme.typ": fonts
#let Cal(body) = math.class(
"normal",
text(font: fonts.cmu-math, math.cal(body)),
)
#let Complement = math.class(
"normal",
text(font: fonts.cmu-math, math.complement),
)
#let qed = [#h(1fr) $square$]
#let jb = linebreak(justify: true)
#let chevrons(..children) = {
let body = children.pos().join(", ")
math.lr([$chevron.l #body chevron.r$])
}
#let german-date-time(value) = [#{ weekdays-short-de.at(int(value.display("[weekday repr:monday]")) - 1) }.,
#{ value.day() }. #{ months-de.at(int(value.display("[month]")) - 1) },
#value.display("[hour]") Uhr]
#let group-digits-text(value, sep: sym.space.nobreak.narrow) = {
let chars = value.clusters()
let n = chars.len()
for (i, ch) in chars.enumerate() {
if i > 0 and calc.rem(n - i, 3) == 0 {
sep
}
ch
}
}
#let content-to-string(content) = {
if type(content) == str {
content
} else if content.has("text") {
if type(content.text) == str {
content.text
} else {
content-to-string(content.text)
}
} else if content.has("children") {
content.children.map(content-to-string).join("")
} else if content.has("body") {
content-to-string(content.body)
} else if content == [] {
" "
}
}
#let render-footnote-entry(entry, numbering-pattern: "[1]") = {
let loc = entry.note.location()
let mark = numbering(numbering-pattern + ":", ..counter(footnote).at(loc))
pad(left: entry.indent)[
#grid(
columns: (auto, 1fr),
gutter: 0.3em,
mark,
entry.note.body,
)
]
}