How to check if content contains multiple paragraphs?

Here’s a function that can check this:

#let is-multiple-paragraph(txt) = {
  return "children" in txt.fields() and parbreak() in txt.children
}

If you’re interested in how I figured this out, I first used repr[*Answer* it] and another one with a paragraph break to see what was there. Then I used [*Answer* it].fields() to see what attributes could be accessed. I saw that the children attribute included parbreak() if there was a paragraph break.

Also, quick tip, you don’t need curly braces {} around markdown brackets [] in an if statement if that’s what you’re returning :slight_smile:

3 Likes