On 1/9/2013 2:54 PM, Andre Caldas wrote:
Hello!
Given some
\startbuffer Blah, blah, blah... \stopbuffer
I'd like to get a "node tree" corresponding to how the buffer would be processed at a given point. Using luatex, I'd like to identify certain sub-nodes and change their attributes (to be specific: transparency).
Any hint on how to do it?
here's an example (I'll add it to the cld manual): \starttext \definecolor[mytransparency][a=1,t=.5] \startluacode local enabled = false local count = 0 function userdata.processmystuff(head) if enabled then count = count + 1 for n in node.traverse(head) do logs.report("node","run %s: %s",count,n) if count % 2 == 0 then nodes.tracers.transparencies.set(n,"mytransparency") end end return head, true end return head, false end function userdata.enablemystuff() enabled = true end function userdata.disablemystuff() enabled = false end nodes.tasks.appendaction("processors", "normalizers", "userdata.processmystuff") \stopluacode \startbuffer whatever \hbox{you} want \stopbuffer \ctxlua{userdata.enablemystuff()} \par \getbuffer \par \ctxlua{userdata.disablemystuff()} \stoptext
Also, are there any good examples on how to use "nodes"?
all over context ... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------