Hi,
If I add properties to math nodes they do not appear in HLIST converted
nodes. But if I add
attributes they stay to this node for all time. And if I create custom
node (for example `user_defined` WHATSIT) then properties doesn't
disappear when MLIST is converted to HLIST.
EXAMPLE:
```
\documentclass{article}
\usepackage[color=no,verbosity=0,channel=log]{nodetree}
\nodetreeregister{preout}
\nodetreeregister{mhlist}
\directlua{
%% node.set_properties_mode(true,true)
function set_mathchar_property(n)
if node.type(n.id) == "math_char" then
% set any attribute
node.set_attribute(n, 999, 999)
% set any property
node.setproperty(n, {math_char = true})
elseif node.type(n.id) == "noad" then
if n.nucleus then
set_mathchar_property(n.nucleus)
end
elseif node.type(n.id) == 'sub_mlist' then
set_mathchar_property(n.head)
local USER_MARK = node.new(node.id("whatsit"), 8)
USER_MARK.type = 115
USER_MARK.value = "math added whatsit"
node.set_attribute(USER_MARK, 888, 888)
node.setproperty(USER_MARK, {math_whatsit = true})
n.head = node.insert_before(n.head, n.head, USER_MARK)
end
end
function parse_math_char(h)
set_mathchar_property(h)
return h
end
luatexbase.add_to_callback('pre_mlist_to_hlist_filter',
parse_math_char, 'set_mathchar_property')
}
\begin{document}
${aa}$
\end{document}
```
Here is the output. You can see that after line break only WHATSIT has
properties
and attributes 888=888, 999=999 stays sticky:
```
Callback: mlist_to_hlist
- need_penalties: true
- display_type: text
------------------------------------------
└─NOAD
╚═nucleus:
└─SUB_MLIST
╚═head:
├─WHATSIT subtype: user_defined, type: 115, value: math added
whatsit, attr: 888=888
│ properties: {['math_whatsit'] = true}
├─NOAD
│ ╚═nucleus:
│ └─MATH_CHAR fam: 1, char: a, attr: 999=999
│ properties: {['math_char'] = true}
└─NOAD
╚═nucleus:
└─MATH_CHAR fam: 1, char: a
-----------------------
Callback: post_linebreak_filter
------------------------------------------
├─GLUE subtype: baselineskip, width: 7.69pt
└─HLIST subtype: line, width: 345pt, height: 4.31pt
╚═head:
├─LOCAL_PAR
├─HLIST subtype: indent, width: 15pt
├─MATH
├─HLIST width: 10.57pt, height: 4.31pt
│ ╚═head:
│ ├─WHATSIT subtype: user_defined, type: 115, value: math added
whatsit, attr: 888=888
│ │ ╚═ properties: {['math_whatsit'] = true}
│ ├─GLYPH subtype: 256, char: a, width: 5.29pt, height: 4.31pt,
attr: 999=999
│ └─GLYPH subtype: 256, char: a, width: 5.29pt, height: 4.31pt
├─MATH subtype: endmath
├─PENALTY subtype: linepenalty, penalty: 10000
├─GLUE subtype: parfillskip, stretch: +1fil
└─GLUE subtype: rightskip
-----------------------
```
There is setup `node.set_properties_mode(true,true)` which should do
something with properties copying but here it does nothing.
Could math noad properties be copied to corresponding new noads:
- MATH_CHAR properties moved to GLYPH;
- SUB_MLIST properties moved to HLIST;
- and others depending on conversion
Thanks, Linas