-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.typ
More file actions
26 lines (23 loc) · 783 Bytes
/
lib.typ
File metadata and controls
26 lines (23 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#let _plugin = plugin("main.wasm")
#let tailwind-classes = state("tailwind-classes", "")
#let tailwind-css(config-bytes) = context {
let classes = tailwind-classes.get()
let s = str(_plugin.generate(bytes(classes), config-bytes))
html.style(s)
}
#let update-elem(elem) = {
// this is safe because when the class attr is array
// type typst would ensure that every single element
// inside the array doesn't contain whitespaces
let classes = elem.fields().attrs.at("class", default: ())
if type(classes) == array {
classes = classes.join(" ")
}
tailwind-classes.update(it => it + " " + classes)
elem
}
#let tailwind-page(c, config: auto) = {
show html.elem: update-elem
c
tailwind-css(if config == auto { bytes("") } else { cbor.encode(config) })
}