Essentially, I think I need is the inverse of what this dude asked for: How to generate a multilevel list from a data structure? - #2 by miles-1 .
Here’s what I have tried so far:
#let list-to-array(it) = {
if it.has("children") {
let content = it.children.filter(it => it.func() != list.item)
if content.any(it => it != [ ]) {
(content.join(),)
}
let items = it.children.filter(it => it.func() == list.item)
for item in items {
(list-to-array(item),)
}
} else if it.has("body") {
list-to-array(it.body)
} else {
it
}
}
This solution almost works, but contains a lot of sequence
content elements. Is this to be expected?
Does anyone have a better solution? Thank you in advance!