Ah yes. My example has four lines of the chorus of that song. It happens to be that the third line is too long to fit the container width, so the line is broken. What I want is that the broken part is right-aligned. So basically similar to a hanging-indent but a “hanging-alignment”.
Edit: I have tried to work with lists here (but with an insivible marker) but for those not even set par(hanging-indent: true) works.
#set page(width: 6cm)
#set par(justify: true)
#let f(it) = layout(size => {
it.children.split(linebreak()).map(array.join).map(x => {
if measure(x).width > size.width {
box(width: 100%, align(right, x))
} else {
x + linebreak()
}
}).join()
})
#f[
Forever young\
I want to be forever young\
Do you really want to live forever?\
Forever and ever
]
but for ragged text I don’t know… It seems that this would require hooking up into the paragraph shaping algorithm, after the linebreaks have been decided but before the final result. You can do this in LuaTeX but I don’t think Typst supports that yet.