Josef-Friedrich / nodetree

LuaTeX package to visualize node lists in a tree view.
https://www.ctan.org/pkg/nodetree
LaTeX Project Public License v1.3c
14 stars 2 forks source link

character "0" is not printed / node properties / attributes as inline list #3

Closed Josef-Friedrich closed 4 years ago

Josef-Friedrich commented 4 years ago

1)

I've noticed that character "0" is not printed in a tree this is wrong because in tex fonts 0 slot usually has a symbol. The fix could be:

function tree.format_field(head, field)
  local out = ''
--  if not head[field] or head[field] == 0 then
  if not head[field] or (head[field] == 0 and field ~= "char") then
    return ''
  end

2)

And now luatex nodes can have properties (fontspec uses them). Could you implement a properties printing? If it is a table it could be printed inline. Something like:

    local t = node.getproperty(head)
    if t then
        local out = tpl.branches(level, 'list') .. '--'
        tpl.print(out.. "Properties:" .. tprint_inline(t))
    end
   ├─GLYPH subtype: 256; char: "b" (98); width: 9pt; height: 9.85pt;
     └─Properties:{["userprops"] = {["1"] = "section-stop"}}

3)

Attributes are key/value number pairs they could be printed as inline list too. And attribute 0 could be skipped because it is in every node by default. it could look like: ATTR: key=val, ....

   ├─GLYPH subtype: 256; char: "n" (110); width: 6.16pt; height: 4.71pt;   ATTR: 7=4, 8=1,
   ├─GLYPH subtype: 256; char: "t" (116); width: 3.64pt; height: 6.9pt;   ATTR: 7=4, 8=1, 19=1,
   ├─GLUE subtype: spaceskip; width: 3.92pt; stretch: 1.68pt; shrink: 1.12pt;   ATTR: 7=4, 8=1,