Bauke/cv
Bauke
/
cv
1
Fork 0
cv/utilities/content-to-string.typ

16 lines
511 B
Plaintext

// Convert a `Content` type to a string by recursively going through it and
// collecting any text nodes, discarding everything else.
// Copied from GitHub:
// https://github.com/typst/typst/issues/2196#issuecomment-1728135476
#let content_to_string(content) = {
if content.has("text") {
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 == [ ] {
" "
}
}