[luatex] Processing every letter in math

Javier Bezos jbezosl at gmail.com
Tue Mar 15 18:16:48 CET 2022


How can I process every single letter in math? Processing
glyph nodes in text is more or less trivial, and to some
extent even in-line math (surrounded by 'math' type nodes),
but processing math, including displays, sub/superscripts,
fractions, radicals. etc.? From the manual I think the
solution must be the node.mlist_to_hlist and the
corresponding callback, and this is what I’ve achieved
so far:

-----------------------
\directlua{

function math_tweak(head, d, p)
   head = node.mlist_to_hlist(head, d, p)
   for item in node.traverse(head) do
     if item.id == node.id'glyph' then
       item.char = 88
     end
   end
   return head, d, p
end

callback.register('mlist_to_hlist', math_tweak)

}

$a$ ${b\over c}$ $\sqrt{d}$ $e$

$$f$$

\bye
------------------------

Here, only ‘a’, ‘e’ and ‘f’ are converted to ‘X’ (= 88).

With a branch for item.id == 0 calling recursively the
function sub/superscripts are processed, but that’s not
quite correct.

Javier



More information about the luatex mailing list.