On 8/20/20 11:08 AM, Taco Hoekwater wrote: > [...] > There is pretty much always ‘a way’, but I do not know of a ’nice’ way. > Your problem is that lxml.flush() and friends do not return a value, > they just do a direct context(‘xxxx’) call behind the scenes with no > return string for you to modify.
Many thanks for your explanation, Taco. > Also, the special (catcode, space handling) rules for setups and \cldcontext > do not help you. > > That does not mean it can’t be done. As I don’t know a of a nice way, > here is a low-level ‘ugly' way: > > \startluacode > function filter(a) > local div = lxml.getid(a) > process(div) > lxml.flush(div) > end > function process(div) > for c=1,#div.dt do > if type(div.dt[c]) == 'string' then > div.dt[c] = string.gsub(div.dt[c], " of the ", "") > else > process(div.dt[c]) > end > end > end > \stopluacode > > \startxmlsetups xml:special > \ctxlua{filter([[#1]])} > \stopxmlsetups > > process() is recursive because your xml:special gets the whole <div>. > Not sure if you intended it that way. And if it can be done nicer, I > am sure someone will correct me :) You’re right, my xml:special wasn’t intended to get the whole <div>. I was tinkering with a previous sample. And I removed an \xmlfilter. Since I got no output, I didn’t see what I was missing. Many thanks for your help, Pablo -- http://www.ousia.tk ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________