From 6932ea879b43b36d023797e18b8bdcfc8cef05ba Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 6 Aug 2020 19:42:33 +0200 Subject: 2020-08-06 18:58:00 --- tex/context/base/mkiv/typo-lin.lua | 94 +++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 36 deletions(-) (limited to 'tex/context/base/mkiv/typo-lin.lua') diff --git a/tex/context/base/mkiv/typo-lin.lua b/tex/context/base/mkiv/typo-lin.lua index 1d523a200..95f9c13fa 100644 --- a/tex/context/base/mkiv/typo-lin.lua +++ b/tex/context/base/mkiv/typo-lin.lua @@ -236,53 +236,75 @@ function paragraphs.checkline(n) return getprop(n,"line") or normalize(n,true) end -function paragraphs.normalize(head,islocal) - if texgetcount("pagebodymode") > 0 then - -- can be an option, maybe we need a proper state in lua itself ... is this check still needed? - return head, false +-- do we still need this: + +if CONTEXTLMTXMODE > 0 then + + function paragraphs.normalize(head,islocal) + if texgetcount("pagebodymode") > 0 then + -- can be an option, maybe we need a proper state in lua itself ... is this check still needed? + return head, false + end + -- normalizer : todo, get the data, no need to normalize + for line, subtype in nexthlist, head do + if subtype == linelist_code and not getprop(line,"line") then + normalize(line) + end + end + return head, true -- true is obsolete end - -- this can become a separate handler but it makes sense to integrate it here - local mode = texgetcount("parfillleftmode") - if mode > 0 then - local l_width, l_stretch, l_shrink = texgetglue("parfillleftskip") - if l_width ~= 0 or l_stretch ~= 0 or l_shrink ~= 0 then - local last = nil -- a nut - local done = mode == 2 -- false - for line, subtype in nexthlist, head do - if subtype == linelist_code and not getprop(line,"line") then - if done then - last = line - else - done = true + +else + + function paragraphs.normalize(head,islocal) + if texgetcount("pagebodymode") > 0 then + -- can be an option, maybe we need a proper state in lua itself ... is this check still needed? + return head, false + end + -- this can become a separate handler but it makes sense to integrate it here + local mode = texgetcount("parfillleftmode") + if mode > 0 then + local l_width, l_stretch, l_shrink = texgetglue("parfillleftskip") + if l_width ~= 0 or l_stretch ~= 0 or l_shrink ~= 0 then + local last = nil -- a nut + local done = mode == 2 -- false + for line, subtype in nexthlist, head do + if subtype == linelist_code and not getprop(line,"line") then + if done then + last = line + else + done = true + end end end - end - if last then -- only if we have more than one line - local head = getlist(last) - local current = head - if current then - if getid(current) == glue_code and getsubtype(current,leftskip_code) then - current = getnext(current) - end + if last then -- only if we have more than one line + local head = getlist(last) + local current = head if current then - head, current = insert_before(head,current,new_glue(l_width,l_stretch,l_shrink)) - if head == current then - setlist(last,head) + if getid(current) == glue_code and getsubtype(current,leftskip_code) then + current = getnext(current) + end + if current then + head, current = insert_before(head,current,new_glue(l_width,l_stretch,l_shrink)) + if head == current then + setlist(last,head) + end + -- can be a 'rehpack(h )' + rehpack(last) end - -- can be a 'rehpack(h )' - rehpack(last) end end end end - end - -- normalizer - for line, subtype in nexthlist, head do - if subtype == linelist_code and not getprop(line,"line") then - normalize(line) + -- normalizer + for line, subtype in nexthlist, head do + if subtype == linelist_code and not getprop(line,"line") then + normalize(line) + end end + return head, true -- true is obsolete end - return head, true -- true is obsolete + end -- print(nodes.idstostring(head)) -- cgit v1.2.3