Skip to content

Commit

Permalink
fix Myriad-Dreamin#55: improve plain-text
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Mar 31, 2024
1 parent 30f19ab commit f2f1a09
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contrib/typst/book/lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,22 @@

// 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 plain-text(it) = {
if type(it) == str {
it
} else if type(it) == content {
if it.func() == styled {
plain-text(it.child)
} else if it.func() == equation {
plain-text(it.body)
} else if it.func() == text or it.func() == raw {
it.text
} else {
none
}
} else if it == [ ] {
" "
} else if it.func() == text or it.func() == raw {
it.text
} else if it.func() == smartquote {
if it.double { "\"" } else { "'" }
} else if it.func() == [].func() {
Expand Down

0 comments on commit f2f1a09

Please sign in to comment.