diff --git a/contrib/typst/book/lib.typ b/contrib/typst/book/lib.typ index 73cdab5..7946f6a 100644 --- a/contrib/typst/book/lib.typ +++ b/contrib/typst/book/lib.typ @@ -135,16 +135,26 @@ // Collect text content of element recursively into a single string // https://discord.com/channels/1054443721975922748/1088371919725793360/1138586827708702810 +// https://github.com/Myriad-Dreamin/typst-book/issues/55 +#let _styled = smallcaps("").func(); +#let _equation = $1$.func(); +#let _sequence = [].func(); #let plain-text(it) = { if type(it) == str { - it + return it } else if it == [ ] { - " " - } else if it.func() == text or it.func() == raw { + return " " + } + let f = it.func() + if f == _styled { + plain-text(it.child) + } else if f == _equation { + plain-text(it.body) + } else if f == text or f == raw { it.text - } else if it.func() == smartquote { + } else if f == smartquote { if it.double { "\"" } else { "'" } - } else if it.func() == [].func() { + } else if f == _sequence { it.children.map(plain-text).filter(t => type(t) == str).join() } else { none