typst-web-template/lib/html_utils.typ
Jean-Marie 'Histausse' Mineau 7e0235fb88
style code
2026-03-17 00:31:44 +01:00

28 lines
647 B
Typst

#import "./custom_html.typ": code-block
#let css-list = state("css-list", ())
/// Add string `css` to `css-list` if not already present
#let add-css(css) = context {
css-list.update(x => if css in x { x } else { x + (css,) })
}
/// Concatenate all css found in css-list at the end of the document
#let get-css() = context {
css-list.final().join("\n\n")
}
#let html_show(body) = {
show raw: it => {
if it.lang == "raw-css" {
// remove code and add it to css style
add-css(it.text)
} else if it.block {
// wrap <pre><code> inside a <code-block>
code-block(it)
} else {
it
}
}
body
}