diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua | 107 |
1 files changed, 49 insertions, 58 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua index 65a53a702fb..5603d119342 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/lang-dis.lua @@ -17,14 +17,10 @@ local nuts = nodes.nuts local enableaction = tasks.enableaction local setaction = tasks.setaction -local tonode = nuts.tonode -local tonut = nuts.tonut - local setfield = nuts.setfield local getnext = nuts.getnext local getprev = nuts.getprev local getid = nuts.getid -local getfont = nuts.getfont local getattr = nuts.getattr local getsubtype = nuts.getsubtype local setsubtype = nuts.setsubtype @@ -40,10 +36,11 @@ local isglyph = nuts.isglyph local copy_node = nuts.copy local remove_node = nuts.remove -local traverse_id = nuts.traverse_id local flush_list = nuts.flush_list local flush_node = nuts.flush_node +local nextdisc = nuts.traversers.disc + local new_disc = nuts.pool.disc local nodecodes = nodes.nodecodes @@ -52,10 +49,7 @@ local disccodes = nodes.disccodes local disc_code = nodecodes.disc local glyph_code = nodecodes.glyph -local discretionary_code = disccodes.discretionary -local explicit_code = disccodes.explicit -local automatic_code = disccodes.automatic -local regular_code = disccodes.regular +local explicitdisc_code = disccodes.explicit local a_visualize = attributes.private("visualizediscretionary") local setattribute = tex.setattribute @@ -69,7 +63,7 @@ local check_regular = true local setlistcolor = nodes.tracers.colors.setlist function languages.visualizediscretionaries(head) - for d in traverse_id(disc_code,tonut(head)) do + for d in nextdisc, head do if getattr(d,a_visualize) then local pre, post, replace = getdisc(d) if pre then @@ -83,6 +77,7 @@ function languages.visualizediscretionaries(head) end end end + return head end local enabled = false @@ -129,13 +124,9 @@ end local wiped = 0 -local flatten_discretionaries = node.flatten_discretionaries -- todo in nodes +local flatten_discretionaries = nuts.flatten_discretionaries -- todo in nodes -if flatten_discretionaries then - - -- This is not that much faster than the lua variant simply because there is - -- seldom a replace list but it fits in the picture. See luatex-todo.w for the - -- code. +-- if flatten_discretionaries then function languages.flatten(head) local h, n = flatten_discretionaries(head) @@ -143,51 +134,50 @@ if flatten_discretionaries then return h, n > 0 end -else - - local function wipe(head,delayed) - local p, n = getboth(delayed) - local _, _, h, _, _, t = getdisc(delayed,true) - if p or n then - if h then - setlink(p,h) - setlink(t,n) - setfield(delayed,"replace") - else - setlink(p,n) - end - end - if head == delayed then - head = h - end - wiped = wiped + 1 - flush_node(delayed) - return head - end - - function languages.flatten(head) - local nuthead = tonut(head) - local delayed = nil - for d in traverse_id(disc_code,nuthead) do - if delayed then - nuthead = wipe(nuthead,delayed) - end - delayed = d - end - if delayed then - return tonode(wipe(nuthead,delayed)), true - else - return head, false - end - end - -end +-- else +-- +-- local function wipe(head,delayed) +-- local p, n = getboth(delayed) +-- local _, _, h, _, _, t = getdisc(delayed,true) +-- if p or n then +-- if h then +-- setlink(p,h) +-- setlink(t,n) +-- setfield(delayed,"replace") +-- else +-- setlink(p,n) +-- end +-- end +-- if head == delayed then +-- head = h +-- end +-- wiped = wiped + 1 +-- flush_node(delayed) +-- return head +-- end +-- +-- function languages.flatten(head) +-- local delayed = nil +-- for d in nextdisc, head do +-- if delayed then +-- head = wipe(head,delayed) +-- end +-- delayed = d +-- end +-- if delayed then +-- return wipe(head,delayed), true +-- else +-- return head, false +-- end +-- end +-- +-- end function languages.nofflattened() return wiped -- handy for testing end --- experiment +-- experiment: for now not in not in export mode! local flatten = languages.flatten local getlist = nodes.getlist @@ -198,10 +188,11 @@ function nodes.handlers.flatten(head,where) if head and (where == "box" or where == "adjusted_hbox") then return flatten(head) end - return true + return head end directives.register("hyphenator.flatten",function(v) + -- use with care setaction("processors","nodes.handlers.flatten",v) setaction("contributers","nodes.handlers.flattenline",v) end) @@ -227,6 +218,6 @@ function languages.explicithyphen(template) end end end - setdisc(disc,pre,post,nil,explicit_code,tex.exhyphenpenalty) + setdisc(disc,pre,post,nil,explicitdisc_code,tex.exhyphenpenalty) return disc end |