With the function ns defined below, I can replace spaces with the text SPACE
#let ns(txt) = {
show regex("\ "): it => [SPACE]
txt
}
#ns[one two three four] // shows oneSPACEtwoSPACEthreeSPACEfour
However, if some of that content is bolded, the show rule is ineffective for adjacent spaces:
#ns[one *two* three four]
This shows “one two threeSPACEfour”. Using repr, I see the two inputs are structured differently:
#repr[one two three four]
// gives [one two three four]
#repr[one *two* three four]
// gives sequence([one], [ ], strong(body:[two]), [ ], [three four])
… but I’m still not sure why the show rule isn’t catching the space between bolded and unbolded words. How can I use show rules that apply to those spaces as well?
#let func-seq = [].func()
#show func-seq: it => {
let blank = [ ]
let c = it.children
if (blank in c) {
func-seq(c.filter(x => x != blank))
} else {
it
}
}
one *two* three
#let func-seq = [].func()
#let ns(txt) = {
show regex("\ "): it => []
show func-seq: it => {
let blank = [ ]
let c = it.children
if (blank in c) {func-seq(c.filter(x => x != blank))} else {it}
}
txt
}
/aʊ/ as in #ns[*ou* t]