Skip to content

Turning content into string #3876

Answered by lvjr
lvjr asked this question in Q&A
Discussion options

You must be logged in to vote

I found the cause of this problem: for sin function, op.text = [sin] which is not a string. And the following is an improved to-string function:

#let to-string(content) = {
  if content.has("text") {
    if type(content.text) == "string" {
      content.text
    } else {
      to-string(content.text)
    }
  } else if content.has("children") {
    content.children.map(to-string).join("")
  } else if content.has("body") {
    to-string(content.body)
  } else if content == [ ] {
    " "
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lvjr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant