summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-tra.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-tra.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-tra.lua62
1 files changed, 52 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-tra.lua b/Master/texmf-dist/tex/context/base/node-tra.lua
index 38855f65934..70e4639b896 100644
--- a/Master/texmf-dist/tex/context/base/node-tra.lua
+++ b/Master/texmf-dist/tex/context/base/node-tra.lua
@@ -63,8 +63,6 @@ local whatsit_code = nodecodes.whatsit
local localpar_code = whatcodes.localpar
local dir_code = whatcodes.dir
-local userskip_code = skipcodes.userskip
-
local nodepool = nodes.pool
local new_glyph = nodepool.glyph
@@ -218,7 +216,7 @@ function step_tracers.reset()
end
function step_tracers.nofsteps()
- return tex.write(#collection)
+ return context(#collection)
end
function step_tracers.glyphs(n,i)
@@ -541,15 +539,27 @@ end
nodes.showsimplelist = function(h,depth) showsimplelist(h,depth,0) end
-function nodes.listtoutf(h,joiner)
- local joiner = (joiner ==true and utfchar(0x200C)) or joiner -- zwnj
+local function listtoutf(h,joiner,textonly)
+ local joiner = (joiner == true and utfchar(0x200C)) or joiner -- zwnj
local w = { }
while h do
- if h.id == glyph_code then -- always true
+ local id = h.id
+ if id == glyph_code then -- always true
w[#w+1] = utfchar(h.char)
if joiner then
w[#w+1] = joiner
end
+ elseif id == disc_code then
+ local pre, rep, pos = h.pre, h.replace, h.post
+ w[#w+1] = format("[%s|%s|%s]",
+ pre and listtoutf(pre,joiner,textonly) or "",
+ rep and listtoutf(rep,joiner,textonly) or "",
+ mid and listtoutf(mid,joiner,textonly) or ""
+ )
+ elseif textonly then
+ if id == glue_code and h.width > 0 then
+ w[#w+1] = " "
+ end
else
w[#w+1] = "[-]"
end
@@ -558,6 +568,8 @@ function nodes.listtoutf(h,joiner)
return concat(w)
end
+nodes.listtoutf = listtoutf
+
local what = { [0] = "unknown", "line", "box", "indent", "row", "cell" }
local function showboxes(n,symbol,depth)
@@ -612,7 +624,7 @@ local function toutf(list,result,nofresult,stopcriterium)
--~ result[nofresult] = " "
--~ end
result, nofresult = toutf(n.list,result,nofresult)
- elseif id == glue_code and n.subtype == userskip_code and n.spec.width > threshold then
+ elseif id == glue_code then
if nofresult > 0 and result[nofresult] ~= " " then
nofresult = nofresult + 1
result[nofresult] = " "
@@ -628,6 +640,10 @@ local function toutf(list,result,nofresult,stopcriterium)
end
end
end
+ if nofresult > 0 and result[nofresult] == " " then
+ result[nofresult] = nil
+ nofresult = nofresult - 1
+ end
return result, nofresult
end
@@ -636,22 +652,48 @@ function nodes.toutf(list,stopcriterium)
return concat(result)
end
--- might move elsewhere
+-- this will move elsewhere
local ptfactor = number.dimenfactors.pt
local bpfactor = number.dimenfactors.bp
local stripper = lpeg.patterns.stripzeros
local points = function(n)
- return lpegmatch(stripper,format("%.5fpt",n*ptfactor))
+ if not n or n == 0 then
+ return "0pt"
+ else
+ return lpegmatch(stripper,format("%.5fpt",n*ptfactor))
+ end
end
local basepoints = function(n)
- return lpegmatch(stripper,format("%.5fbp",n*bpfactor))
+ if not n or n == 0 then
+ return "0bp"
+ else
+ return lpegmatch(stripper,format("%.5fbp",n*bpfactor))
+ end
+end
+
+local pts = function(n)
+ if not n or n == 0 then
+ return "0pt"
+ else
+ return format("%.5fpt",n*ptfactor)
+ end
+end
+
+local nopts = function(n)
+ if not n or n == 0 then
+ return "0"
+ else
+ return format("%.5f",n*ptfactor)
+ end
end
number.points = points
number.basepoints = basepoints
+number.pts = pts
+number.nopts = nopts
--~ function nodes.thespec(s)
--~ local stretch_order = s.stretch_order