How to convert an array of content into content (how do display it)?

I want to be able to call a function by splitting some text containing a marker.

I found a way to correctly extract the text I need, split it on a marker (-- in the example), but then I have an array of content instead of just having content, and I don’t know how to convert it back to something that can be displayed normally.

#let print(lhs, rhs) = [
  - Left: "#lhs"
  - Right: "#rhs"
]

#show heading.where(level: 2): it => {
  let (lhs, rhs) = it.body.fields().children.split([--])
  print(lhs, rhs)
}

== left part -- right *part* with more words

This does print:

- ([left part], [ ])
- ([ ], [right], [ ], strong(body: [part]), [ ], [with more words])

What I want (with the word part in bold:

- left part
- right part with more words

children is a field of sequence content type, which is an array of content elements. Same as array of strings, just use array.join.

#let print(lhs, rhs) = [
  - Left: "#lhs"
  - Right: "#rhs"
]

#show heading.where(level: 2): it => {
  let sequence = [].func()
  if it.body.func() != sequence { return it }
  let (lhs, rhs) = it.body.children.split([--])
  print(lhs.slice(0, -1).join(), rhs.slice(1).join())
}

== left part -- right _part_ with more words
2 Likes