I don’t see why there’s a need to eval
line-by-line – it is also possible to eval the entire text, if we replace newlines and double newlines with \
and #parbreak()
:
#show raw.where(lang: "poem"): it => {
set par(leading: 0.76em) // increase spacing between lines
set text(font: "EB Garamond", size: 1em * 1.25) //factor of 1.25 cancels default raw font-size
set raw(theme: none)
let space-width = 0.5em
block(
inset: (x: 2em, y: 1em),
eval(
it.text
.replace(regex("\n\n+"), "#parbreak()")
.replace(regex("\n( *)"), (i) => {
"\ "
if i.captures.at(0).len() > 0 { "#h(" + repr(i.captures.at(0).len() * space-width) + ")" }
}),
mode: "markup",
scope: (
:
// add whatever you need here
)
)
)
}
This then allows for line-spanning markup (see the italics in the second part) and allows handling blank lines as proper paragraph breaks.