luatex examples - Traversing TeX nodes
Hello, I am trying to compile luatex examples from http://luatex.bluwiki.com . How could I make it work with ConTeXt? The following fails. ----------------------------------------------------------------------------------------------------------------------------------- \directlua0{ local glyph = node.id('glyph') local hlist = node.id('hlist') local vlist = node.id('vlist') function gothru(h,prof) for t in node.traverse(h) do texio.write_nl(string.rep("...",prof) .. 'NODE type=' .. node.type(t.id) .. ' subtype=' .. t.subtype ) if t.id == hlist or t.id == vlist then texio.write(' w=' .. t.width .. ' h=' .. t.height .. ' d=' .. t.depth .. ' s=' .. t.shift ) gothru(t.list,prof+1) end if t.id == glyph then texio.write(' font=' .. t.font .. ' char=' .. t.char .. ' width=' font.fonts[t.font].characters[t.char]['width']) end end end callback.register('pre_linebreak_filter', function(h) gothru(h,0) return true end ) } \starttext bla bla bla bla \stoptext ------------------------------------------------------------------------------------------------------- best Piotr -- http://okle.pl
Piotr Kopszak wrote:
Hello,
I am trying to compile luatex examples from http://luatex.bluwiki.com
i have no time to look into it now but be aware of the fact that if you set a callback like this you're likely to overload one that context itself sets and that can result in problems elsewhere there are user hooks but i need to describe them (as one should be very careful in doing thinsg that interfere) a safe way to play with node is is \setbox0=\vbox{....} and the look at tex.box[0].list ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Great thanks for your hint.
Ever onward!
Piotr
2009/6/1 Hans Hagen
Piotr Kopszak wrote:
Hello,
I am trying to compile luatex examples from http://luatex.bluwiki.com
i have no time to look into it now but be aware of the fact that if you set a callback like this you're likely to overload one that context itself sets and that can result in problems elsewhere
there are user hooks but i need to describe them (as one should be very careful in doing thinsg that interfere)
a safe way to play with node is is
\setbox0=\vbox{....}
and the look at tex.box[0].list
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (2)
-
Hans Hagen
-
Piotr Kopszak