The way I’d do it is indeed to add a catch-all show rule, though the implementation is a bit convoluted:
// Element function for sequences
#let sequence = [].func()
// Convert content to an array of its children
#let to-children(cnt) = {
let inner(content) = {
if type(content) in (str, symbol) {
str(content).clusters().map(char => [#char])
} else if content.func() == sequence {
content.children.map(inner)
} else if content.func() == text {
inner(content.text)
} else if content.func() == math.equation {
inner(content.body)
} else {
(content,)
}
}
return inner(cnt).flatten()
}
#show: it => {
let temp = to-children(it)
temp = temp.map(i => {
let test = i.func()
if i.func() == heading {
return (i, lorem(50))
}
return i
}).flatten()
sequence(temp)
}
= one
= two
#[
also works for a nested heading
= three
]
If you have a large document there might be some performance issues, but I didn’t run into any issues while testing.
I do aknowledge that this solution is quite ugly, so if anyone knows a better way i’d be happy to hear about it