[luatex] math list?

Paul Isambert zappathustra at free.fr
Mon Oct 17 08:27:54 CEST 2011


Le 16/10/2011 19:13, Yannis Haralambous a écrit :
> Hi,
>
> I'm using
>
> for t in node.traverse(h) do
>       texio.write_nl(string.rep("...",prof) .. 'NODE type=' ..  node.type(t.id) .. ' subtype=' .. t.subtype )
> end
>
> in the pre_linebreak_filter to display all nodes in an hlist. This works well.
>
> My question is: how to access math lists? When there is math in my document I get only one node, of type "math" (subtype 1),
> I guess that behind that node there is an mlist, but how can I traverse it?
>
> I found the mlist_to_hlist() method, but when I do
>
> for x in node.traverse(node.mlist_to_hlist(t,"text",true)) do
>       		texio.write_nl('in MATH list ' .. string.rep("...",prof) .. 'NODE type=' ..  node.type(x.id) .. ' subtype=' .. x.subtype )
>       	end
>
> I get the following error:
>
> ! This can't happen (mlist1).
> l.14
> I'm broken. Please show this to someone who can fix can fix
>
> And even if I manage to convert the mlist into a hlist to traverse it, the question is: how do I get back to the mlist? (since I want
> to replace some glyphs by others).

In the pre_linebreak_filter the mlist has already been turned into an 
hlist. So you'll find usual nodes surrounded by math nodes. To access 
the mlist itself, you have to use the mlist_to_hlist callback:

callback.register("mlist_to_hlist",
function (h, d, p)
     for t in node.traverse(h) do
         texio.write_nl(string.rep("...",prof) .. 'NODE type=' .. 
node.type(t.id) .. ' subtype=' .. t.subtype )
     end
     return node.mlist_to_hlist(h, d, p)
end)

Note that the node.mlist_to_hlist function is called there, to do the 
conversion the callback normally does by itself.

Best,
Paul



More information about the luatex mailing list