would look. Is that possible? If I need to remove the blank line between the header and the paragraph text, that’s fine too, though I don’t know if that makes a difference.
#show heading.where(level: 2): it => {
set text(14pt)
box(it) + ":"
}
#show: doc => {
let i = 0
let elements = doc.children
while i < elements.len() {
if elements.at(i).func() == heading and elements.at(i).depth == 2 {
elements.at(i)
let j = i + 1
while (
j < elements.len() and elements.at(j).func() in (parbreak, [ ].func())
) {
j += 1
}
if j >= elements.len() { break }
" "
i = j
}
elements.at(i)
i += 1
}
}
== Heading
// space
#lorem(50)
== Heading
#lorem(50)
== Heading
#lorem(50)
#heading(depth: 2)[Heading]#lorem(50)
== Heading
You can start writing a paragraph however you want, but global show rules can break something else. Though only real testing can say for sure. If there is a top-level styling added, then the styled element will have to be parsed a bit differently, though still should be possible.
The algorithm goes over all elements in the sequence element and filters out parbreak and space elements that go after the depth: 2 headings. And adds a single space after all the removed stuff if there is still something after the heading.