[Dev-luatex] node properties lost after mlist_to_hlist conversion

Linas Stonys lstonys at vtex.lt
Thu Feb 9 14:12:13 CET 2023


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.


     %% 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

       elseif node.type(n.id) == 'sub_mlist' then

         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)

     function parse_math_char(h)
       return h
parse_math_char, 'set_mathchar_property')


Here is the output. You can see that after line break only WHATSIT has 
and attributes 888=888, 999=999 stays sticky:
Callback: mlist_to_hlist
- need_penalties: true
- display_type: text
         ├─WHATSIT subtype: user_defined, type: 115, value: math added 
whatsit, attr: 888=888
         │   properties: {['math_whatsit'] = true}
         │ ╚═nucleus:
         │   └─MATH_CHAR fam: 1, char: a, attr: 999=999
         │       properties: {['math_char'] = true}
             └─MATH_CHAR fam: 1, char: a

Callback: post_linebreak_filter
├─GLUE subtype: baselineskip, width: 7.69pt
└─HLIST subtype: line, width: 345pt, height: 4.31pt
     ├─HLIST subtype: indent, width: 15pt
     ├─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

More information about the dev-luatex mailing list