Truly custom selectors (I think that’s the word you’re looking for, maybe edit it in the title) are not supported, but you can probably use the technique shown here: How can I create show rules in a loop? - #2 by SillyFreak
In that post’s example, you first go from
#show "foo": strong
#show "baz": strong
to
#show: body => {
show "foo": strong
show "baz": strong
body
}
The benefit is that now you don’t need to handle show rules as values, but a function, and Typst is functional and can thus do that.
You would want to go from
#show metadata: metadata => ...
to
#show: metadata-with-id("xlink", metadata => ...)
I’ll leave writing metadata-with-id
for you, but I can also help if you need it.