It doesn’t work because the element (it
) in a show rule has already “materialized”, meaning that its styles and properties have already been set in stone. Any set rules for the same element then aren’t applied anymore (but rules for children are, thus set text(..)
works inside). Instead, you need to create a new justified paragraph, which you can do like this:
#show par: it => {
if it.justify {
// Already justified, so don't try to apply the show rule again.
return it
}
context if measure(it).width > 5000pt {
// Create a new paragraph with the same properties, but justified.
let fields = it.fields()
let body = fields.remove("body")
par(..fields, justify: true, body)
} else {
it
}
}