[luatex] The "read" half of TeX_without_TeX (in a REPL)

Henri Menke henrimenke at gmail.com
Wed Jul 18 01:35:52 CEST 2018



On 18/07/18 09:55, Eduardo Ochs wrote:
> Hi list,
> 
> in a few days - in july 20 - I will give a talk at a TUG meeting about
> the LuaTeX-based package ("dednat6") that I've been using for diagrams
> since several years ago... the slides for the talk are here:
> 
> http://angg.twu.net/math-b.html#tug-2018
> http://angg.twu.net/LATEX/2018tug-dednat6.pdf
> 
> The thing is: in one of the last slides I show how we can use dednat6
> to run a Lua REPL in the middle of a .tex file, and how we can then
> use that to inspect TeX structures - for example, we can inspect the
> contents of tex.box[0] from Lua... but I am probably one of the most
> un-knowleadgeable persons on that in this mailing list...
> 
> Many years ago I worked through this page
> 
> http://wiki.luatex.org/index.php/TeX_without_TeX
> 
> quite carefully, and translated its code into something that I could
> run interactively by sending commands one by one to the Lua
> interpreter; I had to fix several little things - the code in
> TeX_without_TeX seemed to be slightly outdated - and the last time
> that I tested my scripts they didn't work, they would need more fixes.
> 
> Anyone has (a link for?) an example of how to _inspect_ a TeX box from
> Lua? Even a simple example, like how to show the glyphs in
> 
>    \setbox0\hbox{abc}

To traverse the glyphs in a box use node.traverse_id().  It's all 
documented in the LuaTeX manual.  The following example will print abc 
in the log.  N.B.: node.traverse_id() does not recurse into sublists.

\setbox0=\hbox{abc}

\directlua{
local head = tex.box[0].list
%
for n in node.traverse_id(node.id("glyph"),head) do
     print(utf8.char(n.char))
end
}

\bye


> 
> would help me a lot...
> 
> Thanks in advance!!!
>    Cheers,
>      Eduardo Ochs
> 


More information about the luatex mailing list