From a8c525cd14d77b94662021671ef8eb62d5a7fe50 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 13 Sep 2021 10:02:31 +0200 Subject: 2021-09-13 09:40:00 --- tex/context/base/mkxl/node-tra.lmt | 91 ++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 42 deletions(-) (limited to 'tex/context/base/mkxl/node-tra.lmt') diff --git a/tex/context/base/mkxl/node-tra.lmt b/tex/context/base/mkxl/node-tra.lmt index 6fe2e2081..214c8a27c 100644 --- a/tex/context/base/mkxl/node-tra.lmt +++ b/tex/context/base/mkxl/node-tra.lmt @@ -307,57 +307,64 @@ end nodes.showsimplelist = function(h,depth) showsimplelist(h,depth,0) end local function listtoutf(h,joiner,textonly,last,nodisc) - local w = { } - local n = 0 - local g = formatters["<%i>"] - local d = formatters["[%s|%s|%s]"] - while h do - local c, id = isglyph(h) - if c then - n = n + 1 ; w[n] = c >= 0 and utfchar(c) or g(c) - if joiner then - n = n + 1 ; w[n] = joiner - end - elseif id == disc_code then - local pre, pos, rep = getdisc(h) - if not nodisc then - n = n + 1 ; w[n] = d( - pre and listtoutf(pre,joiner,textonly) or "", - pos and listtoutf(pos,joiner,textonly) or "", - rep and listtoutf(rep,joiner,textonly) or "" - ) - elseif rep then - n = n + 1 ; w[n] = listtoutf(rep,joiner,textonly) or "" - end - if joiner then - n = n + 1 ; w[n] = joiner - end - elseif textonly then - if id == glue_code then - if getwidth(h) > 0 then - n = n + 1 ; w[n] = " " + if h then + local w = { } + local n = 0 + local g = formatters["<%i>"] + local d = formatters["[%s|%s|%s]"] + while h do + local c, id = isglyph(h) + if c then + n = n + 1 ; w[n] = c >= 0 and utfchar(c) or g(c) + if joiner then + n = n + 1 ; w[n] = joiner + end + elseif id == disc_code then + local pre, pos, rep = getdisc(h) + if not nodisc then + n = n + 1 ; w[n] = d( + pre and listtoutf(pre,joiner,textonly) or "", + pos and listtoutf(pos,joiner,textonly) or "", + rep and listtoutf(rep,joiner,textonly) or "" + ) + elseif rep then + n = n + 1 ; w[n] = listtoutf(rep,joiner,textonly) or "" + end + if joiner then + n = n + 1 ; w[n] = joiner + end + elseif textonly then + if id == glue_code then + if getwidth(h) > 0 then + n = n + 1 ; w[n] = " " + end + elseif id == hlist_code or id == vlist_code then + local l = getlist(h) + n = n + 1 ; w[n] = "[" + if l then + n = n + 1 ; w[n] = listtoutf(l,joiner,textonly,last,nodisc) + end + n = n + 1 ; w[n] = "]" end - elseif id == hlist_code or id == vlist_code then - n = n + 1 ; w[n] = "[" - n = n + 1 ; w[n] = listtoutf(getlist(h),joiner,textonly,last,nodisc) - n = n + 1 ; w[n] = "]" + else + n = n + 1 ; w[n] = "[-]" + end + if h == last then + break + else + h = getnext(h) end - else - n = n + 1 ; w[n] = "[-]" - end - if h == last then - break - else - h = getnext(h) end + return concat(w,"",1,(w[n] == joiner) and (n-1) or n) + else + return "" end - return concat(w,"",1,(w[n] == joiner) and (n-1) or n) end function nodes.listtoutf(h,joiner,textonly,last,nodisc) if h then local joiner = joiner == true and utfchar(0x200C) or joiner -- zwnj - return listtoutf(tonut(h),joiner,textonly,last and tonut(last),nodisc) + return listtoutf(tonut(h),joiner,textonly,last and tonut(last) or nil,nodisc) else return "" end -- cgit v1.2.3