How to combine many show rules into one show rule?

Another option using the same method but collecting all the text->color conversions into a table:

#let colors = (
  "one": blue,
  "two": red,
  "three": green
)

#show regex("\b(?:" + colors.keys().join("|") + ")\b"): name => {
  let key = name.text
  let color = colors.at(key)
  set text(color)
  name
}

Dummy text one, Dummy text two, Dummy text three

image

The following topic also mentions another way of achieving this, using selector.or():

2 Likes