If I wanted to apply a particular show rule to every “foo” and to every time there’s emph text then I’d just make two separate rules in which the selectors are different but the set function’s the same.
However, how do I do it if I want to apply a show rule only to instances of “foo” which are emph? In other words, if there’s a “foo” which is just roman or bold then the show rule doesn’t apply?
Say, for example, I want any foo to become foo:
foo → foo
foo → foo
any emph text that isn’t foo → any emph text that isn’t foo
If the text is something specific, you can use where:
#show emph.where(body: [foo]): strong
_this contains foo_
this _foo_ is on its own
this foo is normal
Note that the reason this is so different and so much shorter than what is shown in the linked question is that you want to find emphand “foo”, not emphor “foo”.
Since you mention regex in your title: you can’t do that inside where, but you can just use an if in a simpler show rule:
#show emph: it => {
// I prefer writing this as a "early return",
// in case the actual show rule becomes longer
// in this `if`, you can also have regex and other complex stuff
if it.body != [foo] {
return it
}
strong(it)
}
_this contains foo_
this _foo_ is on its own
this foo is normal
Just in case you or someone looking for this question wants
any emph text that isn’t foo → any emph text that isn’t foo
That would look like this:
#show emph: it => {
show "foo": strong
it
}
_this contains foo_
this _foo_ is on its own
this foo is normal
Just helpful and I’m a teacher and currently there’s a school break, so that means I have a bit more time rn and also an “explain stuff to people” deficit
Putting on my mod hat again: if your question is completely answered, don’t forget to add the checkmark!