The best solutions for applying a dynamic amount of show rules are listed here: How can I create show rules in a loop? - #2 by SillyFreak
Your example is almost correct, but you forgot to update the it
variable on each iteration to also hold previous show rules. (As is, you’re simply making a copy of your text where each copy only applies exactly one of the show rules.)
Here’s how a fixed version might look like:
#let en2ch_point_dict = (
"\\.\\s*": "。",
"\\,\\s*": ","
)
#let auto_chinese_point(doc) = {
show par: it => {
show text: it => {
for (pat, replacement) in en2ch_point_dict {
// New 'it' with one more show rule each time
it = {
show regex(pat): replacement
it
}
}
it
}
it
}
doc
}