summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-06-24 19:37:45 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-06-24 19:37:45 +0200
commit820657bb1e9acfb36f24dfa8801526b0d5f2b464 (patch)
treefc93fd3936e84b9b0a6402719e185d35e332eee9 /tex/context/base/mkxl
parent4272a26c49cbfee8917e5272fc0f964cbcfc4b03 (diff)
downloadcontext-820657bb1e9acfb36f24dfa8801526b0d5f2b464.tar.gz
2021-06-24 18:52:00
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/anch-loc.lmt5
-rw-r--r--tex/context/base/mkxl/back-exp-imp-mth.lmt81
-rw-r--r--tex/context/base/mkxl/back-exp.lmt185
-rw-r--r--tex/context/base/mkxl/back-pdf.mkxl89
-rw-r--r--tex/context/base/mkxl/back-pdp.lmt54
-rw-r--r--tex/context/base/mkxl/cldf-lmt.lmt27
-rw-r--r--tex/context/base/mkxl/colo-ini.mkxl8
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/core-env.mkxl2
-rw-r--r--tex/context/base/mkxl/font-chk.lmt3
-rw-r--r--tex/context/base/mkxl/font-con.lmt4
-rw-r--r--tex/context/base/mkxl/font-imp-math.lmt30
-rw-r--r--tex/context/base/mkxl/font-ots.lmt2
-rw-r--r--tex/context/base/mkxl/font-pre.mkxl20
-rw-r--r--tex/context/base/mkxl/lang-ini.lmt16
-rw-r--r--tex/context/base/mkxl/libs-imp-curl.lmt13
-rw-r--r--tex/context/base/mkxl/libs-imp-lzma.lmt52
-rw-r--r--tex/context/base/mkxl/lpdf-col.lmt4
-rw-r--r--tex/context/base/mkxl/lpdf-emb.lmt2
-rw-r--r--tex/context/base/mkxl/lpdf-ini.lmt27
-rw-r--r--tex/context/base/mkxl/luat-cnf.lmt2
-rw-r--r--tex/context/base/mkxl/luat-cod.lmt53
-rw-r--r--tex/context/base/mkxl/luat-lib.mkxl5
-rw-r--r--tex/context/base/mkxl/luat-run.lmt2
-rw-r--r--tex/context/base/mkxl/math-ini.mkxl42
-rw-r--r--tex/context/base/mkxl/math-noa.lmt119
-rw-r--r--tex/context/base/mkxl/math-stc.mklx26
-rw-r--r--tex/context/base/mkxl/math-tag.lmt8
-rw-r--r--tex/context/base/mkxl/mlib-mpf.lmt3
-rw-r--r--tex/context/base/mkxl/mlib-pps.lmt2
-rw-r--r--tex/context/base/mkxl/node-ext.lmt4
-rw-r--r--tex/context/base/mkxl/node-fin.lmt35
-rw-r--r--tex/context/base/mkxl/node-res.lmt2
-rw-r--r--tex/context/base/mkxl/pack-rul.mkxl67
-rw-r--r--tex/context/base/mkxl/page-ffl.mkxl237
-rw-r--r--tex/context/base/mkxl/page-lay.mkxl2
-rw-r--r--tex/context/base/mkxl/spac-ver.mkxl2
-rw-r--r--tex/context/base/mkxl/strc-mat.mkxl8
-rw-r--r--tex/context/base/mkxl/supp-box.lmt39
-rw-r--r--tex/context/base/mkxl/supp-box.mkxl11
-rw-r--r--tex/context/base/mkxl/syst-ini.mkxl17
-rw-r--r--tex/context/base/mkxl/syst-lua.lmt24
-rw-r--r--tex/context/base/mkxl/toks-aux.lmt99
-rw-r--r--tex/context/base/mkxl/trac-inf.lmt5
-rw-r--r--tex/context/base/mkxl/trac-vis.lmt4
-rw-r--r--tex/context/base/mkxl/typo-brk.mkxl4
-rw-r--r--tex/context/base/mkxl/typo-duc.lmt50
-rw-r--r--tex/context/base/mkxl/util-fil.lmt3
-rw-r--r--tex/context/base/mkxl/util-sac.lmt59
50 files changed, 1021 insertions, 541 deletions
diff --git a/tex/context/base/mkxl/anch-loc.lmt b/tex/context/base/mkxl/anch-loc.lmt
index 09c1406ff..054d4dd07 100644
--- a/tex/context/base/mkxl/anch-loc.lmt
+++ b/tex/context/base/mkxl/anch-loc.lmt
@@ -284,6 +284,7 @@ implement {
name = "pushlocalanchors",
public = true,
protected = true,
+ untraced = true,
actions = pushpositions,
}
@@ -291,6 +292,7 @@ implement {
name = "poplocalanchors",
public = true,
protected = true,
+ untraced = true,
actions = poppositions,
}
@@ -299,6 +301,7 @@ implement {
arguments = { "integerargument" },
public = true,
protected = true,
+ untraced = true,
actions = function(n)
analyze(driver,texgetbox(n))
end
@@ -309,6 +312,7 @@ implement {
arguments = { "integerargument" },
public = true,
protected = true,
+ untraced = true,
actions = drivers.converters.resyncbox,
}
@@ -383,6 +387,7 @@ interfaces.implement {
name = "async",
arguments = { "argument", "integerargument", "argument" },
protected = true,
+ untraced = true,
public = true,
actions = function(name,x,align)
local t = positions[name].cnt
diff --git a/tex/context/base/mkxl/back-exp-imp-mth.lmt b/tex/context/base/mkxl/back-exp-imp-mth.lmt
index 73c09d79e..8751ca89d 100644
--- a/tex/context/base/mkxl/back-exp-imp-mth.lmt
+++ b/tex/context/base/mkxl/back-exp-imp-mth.lmt
@@ -21,6 +21,10 @@ local extras = backend.extras
local checks = backend.checks
local finalizers = backend.finalizers
+----- bpfactor = number.dimenfactors.bp
+----- f_points = string.formatters["%p"]
+local f_em = string.formatters["%.6Nem"]
+
local implement = interfaces.implement
do
@@ -155,6 +159,7 @@ do
mi = true,
mo = true,
mn = true,
+ mspace = true,
}
local function checkmath(root) -- we can provide utf.toentities as an option
@@ -394,6 +399,17 @@ do
elseif tg == "break" then
di.skip = "comment"
i = i + 1
+ elseif tg == "mspace" then
+ -- di.empty = true
+ local s = specifications[di.fulltag]
+ local e = s and s.emfactor
+ if e and e ~= 0 then
+ di.element = "mspace"
+ di.attributes = {
+ width = f_em(e),
+ }
+ end
+ i = i + 1
elseif tg == "mtext" then
-- this is only needed for unboxed mtexts ... all kind of special
-- tex border cases and optimizations ... trial and error
@@ -519,6 +535,8 @@ do
local tg = di.tg
if tg == "mtext" or tg == "ms" then
return di
+ elseif tg == "mspace" then
+ return di
else
local data = di.data
local ndata = #data
@@ -530,38 +548,43 @@ do
end
if d then
local content = d.content
- if not content then
+ if d.tg == "mspace" then
+ n = n + 1
+ data[n] = d
+ d.data = { }
+ elseif not content then
+-- if not content then
n = n + 1
d.__i__ = n
data[n] = d
- elseif content == " " or content == "" then
- if di.tg == "mspace" then
- -- we append or prepend a space to a preceding or following mtext
- local parent = di.__p__
- local index = di.__i__ -- == i
- local data = parent.data
- if index > 1 then
- local d = data[index-1]
- if d.tg == "mtext" then
- local dd = d.data
- local dn = dd[#dd]
- local dc = dn.content
- if dc then
- dn.content = dc .. content
- end
- end
- elseif index < ndata then
- local d = data[index+1]
- if d.tg == "mtext" then
- local dd = d.data
- local dn = dd[1]
- local dc = dn.content
- if dc then
- dn.content = content .. dc
- end
- end
- end
- end
+-- elseif content == " " or content == "" then
+-- if d.tg == "mspace" then
+-- -- we append or prepend a space to a preceding or following mtext
+-- local parent = di.__p__
+-- local index = di.__i__ -- == i
+-- local data = parent.data
+-- if index > 1 then
+-- local d = data[index-1]
+-- if d.tg == "mtext" then
+-- local dd = d.data
+-- local dn = dd[#dd]
+-- local dc = dn.content
+-- if dc then
+-- dn.content = dc .. content
+-- end
+-- end
+-- elseif index < ndata then
+-- local d = data[index+1]
+-- if d.tg == "mtext" then
+-- local dd = d.data
+-- local dn = dd[1]
+-- local dc = dn.content
+-- if dc then
+-- dn.content = content .. dc
+-- end
+-- end
+-- end
+-- end
else
n = n + 1
data[n] = d
diff --git a/tex/context/base/mkxl/back-exp.lmt b/tex/context/base/mkxl/back-exp.lmt
index f0d8e120e..81a0bf7d5 100644
--- a/tex/context/base/mkxl/back-exp.lmt
+++ b/tex/context/base/mkxl/back-exp.lmt
@@ -921,7 +921,9 @@ do
local element = di.element
if not element then
-- skip
- elseif element == "break" then -- or element == "pagebreak"
+ elseif element == "break" then -- or element == "pagebreak" -- todo: use empty flag
+ emptytag(result,element,nature,di)
+ elseif element == "mspace" then -- todo: use empty flag
emptytag(result,element,nature,di)
elseif element == "" or di.skip == "ignore" then
-- skip
@@ -941,6 +943,11 @@ do
flushtree(result,di.after,nature)
end
end
+ else
+-- local element = di.element
+-- if element == "mspace" then -- todo: use empty flag
+-- emptytag(result,element,nature,di)
+-- end
end
end
end
@@ -961,8 +968,8 @@ do
-- skip
elseif di.skip == "ignore" then
-- skip (new)
-elseif di.tg == "ignore" then
- -- skip (new)
+ elseif di.tg == "ignore" then
+ -- skip (new)
elseif di.content then
if di.samepar then
prevparnumber = false
@@ -1046,12 +1053,22 @@ elseif di.tg == "ignore" then
-- also tabulaterow reconstruction .. maybe better as a checker
-- i.e cell attribute
+ local function showtree(data,when,where)
+ if data then
+ for i=1,#data do
+ local d = data[i]
+ if type(d) == "table" and d.element then
+ print(when,where,i,d.element,d.parnumber or 0)
+ end
+ end
+ end
+ end
+
local function collapsetree(tree)
--- for tag, trees in sortedhash(treehash) do
+ -- showtree(data,"before","collapse")
+ -- for tag, trees in sortedhash(treehash) do
for tag, trees in next, treehash do
local d = trees[1].data
--- print("!!!!!!!!",tag)
--- inspect(trees)
if d then
local nd = #d
if nd > 0 then
@@ -1097,30 +1114,22 @@ elseif di.tg == "ignore" then
end
end
end
+ -- showtree(data,"after","collapse")
end
local function finalizetree(tree)
+ -- showtree(data,"before","finalize")
for _, finalizer in next, finalizers do
finalizer(tree)
end
+ -- showtree(data,"after","finalize")
end
- -- local function showtree(data,when,where)
- -- if data then
- -- for i=1,#data do
- -- local d = data[i]
- -- if type(d) == "table" and d.element then
- -- print(when,where,i,d.element,d.parnumber or 0)
- -- end
- -- end
- -- end
- -- end
-
local function indextree(tree)
local data = tree.data
if data then
- local n, new = 0, { }
-- showtree(data,"before","index")
+ local n, new = 0, { }
for i=1,#data do
local d = data[i]
if not d then
@@ -1148,9 +1157,12 @@ elseif di.tg == "ignore" then
for i=1,#data do
local d = data[i]
if type(d) == "table" then
- local check = checks[d.tg]
- if check then
- check(d,data,i)
+ local tg = d.tg
+ if tg then
+ local check = checks[tg]
+ if check then
+ check(d,data,i)
+ end
end
checktree(d) -- so parts can pass twice
end
@@ -1166,9 +1178,12 @@ elseif di.tg == "ignore" then
for i=1,#data do
local d = data[i]
if type(d) == "table" then
- local fix = fixes[d.tg]
- if fix then
- fix(d,data,i)
+ local tg = d.tg
+ if tg then
+ local fix = fixes[tg]
+ if fix then
+ fix(d,data,i)
+ end
end
fixtree(d) -- so parts can pass twice
end
@@ -1406,29 +1421,30 @@ end
local collectresults do -- too many locals otherwise
- local nodecodes = nodes.nodecodes
- local gluecodes = nodes.gluecodes
- local listcodes = nodes.listcodes
- local whatsitcodes = nodes.whatsitcodes
+ local nodecodes = nodes.nodecodes
+ local gluecodes = nodes.gluecodes
+ local listcodes = nodes.listcodes
+ local whatsitcodes = nodes.whatsitcodes
- local subtypes = nodes.subtypes
+ local subtypes = nodes.subtypes
- local hlist_code = nodecodes.hlist
- local vlist_code = nodecodes.vlist
- local glyph_code = nodecodes.glyph
- local glue_code = nodecodes.glue
- local kern_code = nodecodes.kern
- local disc_code = nodecodes.disc
- local whatsit_code = nodecodes.whatsit
- local par_code = nodecodes.par
+ local hlist_code = nodecodes.hlist
+ local vlist_code = nodecodes.vlist
+ local glyph_code = nodecodes.glyph
+ local glue_code = nodecodes.glue
+ local kern_code = nodecodes.kern
+ local disc_code = nodecodes.disc
+ local whatsit_code = nodecodes.whatsit
+ local par_code = nodecodes.par
- local userskip_code = gluecodes.userskip
- local rightskip_code = gluecodes.rightskip
- local parfillskip_code = gluecodes.parfillskip
- local spaceskip_code = gluecodes.spaceskip
- local xspaceskip_code = gluecodes.xspaceskip
+ local userskip_code = gluecodes.userskip
+ local rightskip_code = gluecodes.rightskip
+ local parfillskip_code = gluecodes.parfillskip
+ local spaceskip_code = gluecodes.spaceskip
+ local xspaceskip_code = gluecodes.xspaceskip
+ local intermathskip_code = gluecodes.intermathskip
- local linelist_code = listcodes.line
+ local linelist_code = listcodes.line
local userdefinedwhatsit_code = whatsitcodes.userdefined
@@ -1654,6 +1670,21 @@ local collectresults do -- too many locals otherwise
currentcontent[nofcurrentcontent] = c
end
elseif subtype == userskip_code then
+-- local at = getattr(n,a_tagged)
+-- local tl = taglist[at]
+-- if tl and structurestags.strip(tl.taglist[#tl.taglist]) == "mspace" then
+-- if nofcurrentcontent > 0 then
+-- pushcontent()
+-- pushentry(currentnesting) -- ??
+-- end
+-- -- in the past we'd push a space here ... check mkiv : otherwise no threshold with mspace
+-- pushentry(tl)
+-- if trace_export then
+-- report_export("%w<!-- processing mspace tagged %a",currentdepth,at)
+-- end
+-- last = nil
+-- currentparagraph = nil
+-- else
if getwidth(n) > threshold then
if last and not somespace[currentcontent[nofcurrentcontent]] then
local a = getattr(n,a_tagged) or pat
@@ -1681,6 +1712,7 @@ local collectresults do -- too many locals otherwise
end
end
end
+-- end
elseif subtype == spaceskip_code or subtype == xspaceskip_code then
if not somespace[currentcontent[nofcurrentcontent]] then
local a = getattr(n,a_tagged) or pat
@@ -1703,6 +1735,8 @@ local collectresults do -- too many locals otherwise
currentattribute = last
end
end
+ elseif subtype == intermathskip_code then
+ -- put this as attribute when it differs, maybe more ... check mathml
elseif subtype == rightskip_code then
-- a line
if nofcurrentcontent > 0 then
@@ -1769,49 +1803,50 @@ local collectresults do -- too many locals otherwise
elseif id == kern_code then
local kern = getkern(n)
if kern > 0 then
-local a = getattr(n,a_tagged) or pat
-local t = taglist[a]
-if not t or t.tagname ~= "ignore" then -- maybe earlier on top)
- local limit = threshold
- if p then
- local c, f = isglyph(p)
- if c then
- limit = fontquads[f] / 4
+ local a = getattr(n,a_tagged) or pat
+ local t = taglist[a]
+ if not t or t.tagname ~= "ignore" then -- maybe earlier on top)
+ local limit = threshold
+ if p then
+ local c, f = isglyph(p)
+ if c then
+ limit = fontquads[f] / 4
+ end
end
- end
- if kern > limit then
- if last and not somespace[currentcontent[nofcurrentcontent]] then
--- local a = getattr(n,a_tagged) or pat
- if a == last then
- if not somespace[currentcontent[nofcurrentcontent]] then
+ if kern > limit then
+ if last and not somespace[currentcontent[nofcurrentcontent]] then
+ -- local a = getattr(n,a_tagged) or pat
+ if a == last then
+ if not somespace[currentcontent[nofcurrentcontent]] then
+ if trace_export then
+ report_export("%w<!-- injecting spacing 8 (kern %p) -->",currentdepth,kern)
+ end
+ nofcurrentcontent = nofcurrentcontent + 1
+ currentcontent[nofcurrentcontent] = " "
+ end
+ elseif a then
+ -- e.g LOGO<space>LOGO
if trace_export then
- report_export("%w<!-- injecting spacing 8 (kern %p) -->",currentdepth,kern)
+ report_export("%w<!-- processing kern, threshold %p, tag %s => %s -->",currentdepth,limit,last,a)
+ end
+ last = a
+ pushcontent()
+ if trace_export then
+ report_export("%w<!-- injecting spacing 9 (kern %p) -->",currentdepth,kern)
end
nofcurrentcontent = nofcurrentcontent + 1
currentcontent[nofcurrentcontent] = " "
+ -- currentnesting = taglist[last]
+ currentnesting = t
+ pushentry(currentnesting)
+ currentattribute = last
end
- elseif a then
- -- e.g LOGO<space>LOGO
- if trace_export then
- report_export("%w<!-- processing kern, threshold %p, tag %s => %s -->",currentdepth,limit,last,a)
- end
- last = a
- pushcontent()
- if trace_export then
- report_export("%w<!-- injecting spacing 9 (kern %p) -->",currentdepth,kern)
- end
- nofcurrentcontent = nofcurrentcontent + 1
- currentcontent[nofcurrentcontent] = " "
--- currentnesting = taglist[last]
-currentnesting = t
- pushentry(currentnesting)
- currentattribute = last
end
end
end
-end
end
elseif id == whatsit_code then
+ -- todo (lmtx)
if subtype == userdefinedwhatsit_code then
-- similar to images, see above
local at = getattr(n,a_tagged)
diff --git a/tex/context/base/mkxl/back-pdf.mkxl b/tex/context/base/mkxl/back-pdf.mkxl
index 4ec1501a5..5770e6aad 100644
--- a/tex/context/base/mkxl/back-pdf.mkxl
+++ b/tex/context/base/mkxl/back-pdf.mkxl
@@ -61,35 +61,40 @@
%D Because we do a lot in \LUA\ and don't want interferences, we nil most of the
%D \PDFTEX\ primitives. Of course one can always use the \type {\pdfvariable},
%D \type {\pdfextension} and \type {\pdffeedback} primitives but it will probably
-%D have bad side effects.
+%D have bad side effects. We fake them as primitives which is why they are
+%D defined as untraced.
-\permanent\protected\def\pdfextension{\clf_pdfextension}
-\permanent \def\pdffeedback {\clf_pdffeedback}
-\permanent \def\pdfvariable {\clf_pdfvariable}
+% \pdfextension % defined in lua
+% \pdffeedback % idem
+% \pdfvariable % idem
+% \pdfliteral % idem
+% \pdfobj % idem
+% \pdflastobj % idem
+% \pdfrefobj % idem
-%D For the moment we keep this for tikz but hopefully it will at some point use
-%D the proper ones. Consider them obsolete:
+\untraced\permanent\protected\def\pdfrestore {\pdfextension restore}
+\untraced\permanent\protected\def\pdfsave {\pdfextension save}
+\untraced\permanent\protected\def\pdfsetmatrix{\pdfextension setmatrix}
-\permanent\protected\def\pdfliteral {\clf_pdfliteral}
-\permanent\protected\def\pdfobj {\clf_pdfobj}%
-\permanent\protected\def\pdflastobj {\numexpr\clf_pdflastobj\relax}
-\permanent\protected\def\pdfrefobj {\clf_pdfrefobj}
+\untraced\permanent\def\pdfxform {\saveboxresource}
+\untraced\permanent\def\pdflastxform {\lastsavedboxresourceindex}
+\untraced\permanent\def\pdfrefxform {\useboxresource}
-\permanent\protected\def\pdfrestore {\pdfextension restore}
-\permanent\protected\def\pdfsave {\pdfextension save}
-\permanent\protected\def\pdfsetmatrix{\pdfextension setmatrix}
+%D This is also needed for tikz:
-\permanent\let\pdfxform \saveboxresource
-\permanent\let\pdflastxform\lastsavedboxresourceindex
-\permanent\let\pdfrefxform \useboxresource
+\ifdefined\pdfsavepos\else
+ \untraced\permanent\def\pdfsavepos {\savepos }
+ \untraced\permanent\def\pdflastxpos{\lastxpos}
+ \untraced\permanent\def\pdflastypos{\lastypos}
+\fi
%D Here are quick and dirty compression flippers, mostly used when testing something
%D as one can best stick to the defaults that also adapt to specific standards.
-\permanent\protected\def\nopdfcompression {\clf_setpdfcompression\zerocount\zerocount}
-\permanent\protected\def\onlypdfobjectcompression{\clf_setpdfcompression\zerocount\plusthree}
-\permanent\protected\def\maximumpdfcompression {\clf_setpdfcompression\plusnine \plusnine }
-\permanent\protected\def\normalpdfcompression {\clf_setpdfcompression\plusthree\plusthree}
+\untraced\permanent\protected\def\nopdfcompression {\clf_setpdfcompression\zerocount\zerocount}
+\untraced\permanent\protected\def\onlypdfobjectcompression{\clf_setpdfcompression\zerocount\plusthree}
+\untraced\permanent\protected\def\maximumpdfcompression {\clf_setpdfcompression\plusnine \plusnine }
+\untraced\permanent\protected\def\normalpdfcompression {\clf_setpdfcompression\plusthree\plusthree}
%D PDF/X (maybe combine the two lua calls)
@@ -119,23 +124,23 @@
%D These are the only official methods to add stuff to the resources. If more is
%D needed for third party low level code, it can be added.
-\permanent\protected\def\pdfbackendsetcatalog #1#2{\clf_lpdf_addtocatalog{#1}{#2}}
-\permanent\protected\def\pdfbackendsetinfo #1#2{\clf_lpdf_addtoinfo{#1}{#2}}
-\permanent\protected\def\pdfbackendsetname #1#2{\clf_lpdf_addtonames{#1}{#2}}
-
-\permanent\protected\def\pdfbackendsetpageattribute #1#2{\clf_lpdf_addtopageattributes{#1}{#2}}
-\permanent\protected\def\pdfbackendsetpagesattribute#1#2{\clf_lpdf_addtopagesattributes{#1}{#2}}
-\permanent\protected\def\pdfbackendsetpageresource #1#2{\clf_lpdf_addtopageresources{#1}{#2}}
-
-\permanent\protected\def\pdfbackendsetextgstate #1#2{\clf_lpdf_adddocumentextgstate{#1}{#2}}
-\permanent\protected\def\pdfbackendsetcolorspace #1#2{\clf_lpdf_adddocumentcolorspace{#1}{#2}}
-\permanent\protected\def\pdfbackendsetpattern #1#2{\clf_lpdf_adddocumentpattern{#1}{#2}}
-\permanent\protected\def\pdfbackendsetshade #1#2{\clf_lpdf_adddocumentshade{#1}{#2}}
-
-\permanent \def\pdfbackendcurrentresources {\clf_lpdf_collectedresources}
-\permanent \def\pdfcolor #1{\clf_lpdf_color\numexpr\rawcolorattribute{#1}\relax}
-
-%D This is a temporary hack mthat will be removed, improved or somehow can become
+% \pdfbackendsetcatalog #1#2 % defined in lua
+% \pdfbackendsetinfo #1#2 % idem
+% \pdfbackendsetname #1#2 % idem
+%
+% \pdfbackendsetpageattribute #1#2 % idem
+% \pdfbackendsetpagesattribute#1#2 % idem
+% \pdfbackendsetpageresource #1#2 % idem
+%
+% \pdfbackendsetextgstate #1#2 % idem
+% \pdfbackendsetcolorspace #1#2 % idem
+% \pdfbackendsetpattern #1#2 % idem
+% \pdfbackendsetshade #1#2 % idem
+%
+% \pdfbackendcurrentresources % idem, expandable
+% \pdfcolor #1 % idem, expandable
+
+%D This is a temporary hack that will be removed, improved or somehow can become
%D default.
\permanent\def\TransparencyHack{\setupcolors[\c!pagecolormodel=\v!auto]}
@@ -146,19 +151,11 @@
%D text \pdfbackendactualtext{Meier}{Müller} text
%D \stoptyping
-\permanent\protected\def\pdfbackendactualtext#1#2% not interfaced
+\untraced\permanent\protected\def\pdfbackendactualtext#1#2% not interfaced
{\clf_startactualtext{#2}%
#1%
\clf_stopactualtext}
\aliased\let\pdfactualtext\pdfbackendactualtext
-%D Bah, this is also needed for tikz:
-
-\ifdefined\pdfsavepos\else
- \permanent\let\pdfsavepos \savepos
- \permanent\let\pdflastxpos\lastxpos
- \permanent\let\pdflastypos\lastypos
-\fi
-
\protect \endinput
diff --git a/tex/context/base/mkxl/back-pdp.lmt b/tex/context/base/mkxl/back-pdp.lmt
index 76a6f4b67..5c786d53e 100644
--- a/tex/context/base/mkxl/back-pdp.lmt
+++ b/tex/context/base/mkxl/back-pdp.lmt
@@ -27,6 +27,12 @@ local scanstring = tokenscanners.string
local scaninteger = tokenscanners.integer
local scanwhd = tokenscanners.whd
+local values = tokens.values
+local dimension_value = values.dimension
+local cardinal_value = values.cardinal
+
+local immediate_code = tex.flagcodes.immediate
+
local trace = false trackers.register("backend", function(v) trace = v end)
local report = logs.reporter("backend")
@@ -50,14 +56,14 @@ end
local lastobjnum = 0
-local function pdf_obj()
+local function pdf_obj(prefix)
if scankeyword("reserveobjnum") then
lastobjnum = pdfreserveobject()
if trace then
report("\\pdfobj reserveobjnum: object %i",lastobjnum)
end
else
- local immediate = true
+ local immediate = prefix and (prefix & immediate_code) ~= 0 -- was just "true"
local objnum = scankeyword("useobjnum") and scaninteger() or pdfreserveobject()
local uncompress = scankeyword("uncompressed") or pdfcompresslevel() == 0
local streamobject = scankeyword("stream")
@@ -90,10 +96,14 @@ local function pdf_obj()
end
local function pdf_lastobj()
- context("%i",lastobjnum)
if trace then
report("\\lastobj: object %i",lastobjnum)
end
+ return cardinal_value, lastobjnum
+end
+
+local function pdf_pagereference()
+ return cardinal_value, pdfpagereference()
end
local function pdf_refobj()
@@ -218,9 +228,9 @@ end
-- lastlink lastobj pageref retval revision version xformname
local feedbacks = {
- lastobj = pdf_lastobj,
- pageref = function() context(pdfpagereference()) end,
- xformname = function() context(pdfgetxformname ()) end,
+ lastobj = pdf_lastobj,
+ pageref = pdf_pagereference,
+ xformname = function() context(pdfgetxformname ()) end,
}
local function pdf_feedback()
@@ -262,20 +272,18 @@ local function pdf_variable()
end
end
--- kept:
-
-implement { name = "pdfextension", actions = pdf_extension }
-implement { name = "pdffeedback", actions = pdf_feedback }
-implement { name = "pdfvariable", actions = pdf_variable }
-
--- for the moment (tikz)
-
-implement { name = "pdfliteral", actions = pdf_literal }
-implement { name = "pdfobj", actions = pdf_obj }
-implement { name = "pdflastobj", actions = pdf_lastobj }
-implement { name = "pdfrefobj", actions = pdf_refobj }
---------- { name = "pdfannot", actions = pdf_annot }
---------- { name = "pdfdest", actions = pdf_dest }
---------- { name = "pdfsave", actions = pdf_save }
---------- { name = "pdfrestore", actions = pdf_restore }
---------- { name = "pdfsetmatrix", actions = pdf_setmatrix }
+-- kept (also because tikz needs including the pdftex primitives):
+
+implement { name = "pdfextension", actions = pdf_extension, public = true, untraced = true, protected = true }
+implement { name = "pdffeedback", actions = pdf_feedback, public = true, untraced = true } -- expandable / todo : value
+implement { name = "pdfvariable", actions = pdf_variable, public = true, untraced = true } -- expandable / todo : value
+implement { name = "pdfliteral", actions = pdf_literal, public = true, untraced = true, protected = true }
+implement { name = "pdfobj", actions = pdf_obj, public = true, usage = "value", protected = true }
+implement { name = "pdflastobj", actions = pdf_lastobj, public = true, usage = "value", protected = true }
+implement { name = "pdfrefobj", actions = pdf_refobj, public = true, untraced = true, protected = true }
+
+--------- { name = "pdfannot", actions = pdf_annot }
+--------- { name = "pdfdest", actions = pdf_dest }
+--------- { name = "pdfsave", actions = pdf_save }
+--------- { name = "pdfrestore", actions = pdf_restore }
+--------- { name = "pdfsetmatrix", actions = pdf_setmatrix }
diff --git a/tex/context/base/mkxl/cldf-lmt.lmt b/tex/context/base/mkxl/cldf-lmt.lmt
index 0c9da145f..e6c046763 100644
--- a/tex/context/base/mkxl/cldf-lmt.lmt
+++ b/tex/context/base/mkxl/cldf-lmt.lmt
@@ -187,6 +187,7 @@ implement {
name = "newarray",
public = true,
protected = true,
+ untraced = true,
arguments = { {
{ "name", "string" },
{ "nx", "integer" },
@@ -335,6 +336,7 @@ implement {
name = "showarray",
public = true,
protected = true,
+ untraced = true,
actions = function()
local name = scanstring()
if name then
@@ -358,9 +360,10 @@ end)
table.makeweak(cache)
implement {
- name = "luaexpression",
- public = true,
- actions = function()
+ name = "luaexpression",
+ public = true,
+ untraced = true,
+ actions = function()
local how = scanword()
local code = cache[scanargument()]
if code then
@@ -544,6 +547,7 @@ end
implement {
name = "newluatable",
protected = true,
+ untraced = true,
arguments = "csname",
actions = newluatable,
}
@@ -551,6 +555,7 @@ implement {
implement {
name = "useluatable",
protected = true,
+ untraced = true,
arguments = { "csname", true },
actions = newluatable,
}
@@ -558,6 +563,7 @@ implement {
implement {
name = "disposeluatable",
protected = true,
+ untraced = true,
public = true,
arguments = "csname",
actions = disposeluatable,
@@ -566,6 +572,7 @@ implement {
implement {
name = "inspectluatable",
protected = true,
+ untraced = true,
public = true,
arguments = "csname",
actions = inspectluatable,
@@ -574,6 +581,7 @@ implement {
implement {
name = "showluatables",
protected = true,
+ untraced = true,
public = true,
actions = showluatables,
}
@@ -581,6 +589,7 @@ implement {
implement {
name = "setluatable",
protected = true,
+ untraced = true,
public = true,
arguments = { "csname", "argument" },
actions = function(name,data)
@@ -597,6 +606,7 @@ implement {
implement {
name = "getfromluatable",
protected = false,
+ untraced = true,
public = true,
arguments = { "csname", "argument" },
actions = getfromluatable,
@@ -605,6 +615,7 @@ implement {
implement {
name = "idxfromluatable",
protected = false,
+ untraced = true,
public = true,
arguments = { "csname", "integer" },
actions = idxfromluatable,
@@ -628,9 +639,10 @@ local tables = { }
local stack = setmetatableindex("table")
implement {
- name = "droptablegroup",
- public = true,
- actions = function()
+ name = "droptablegroup",
+ public = true,
+ untraced = true,
+ actions = function()
local g = texget("currentgrouplevel") -- todo: tex.getgrouplevel()
local s = stack[g]
if s then
@@ -715,6 +727,7 @@ end
implement {
name = "newhashedtable",
protected = true,
+ untraced = true,
public = true,
actions = newtable,
}
@@ -722,6 +735,7 @@ implement {
implement {
name = "newindexedtable",
protected = true,
+ untraced = true,
public = true,
actions = function() newtable(true) end,
}
@@ -974,6 +988,7 @@ do
implement {
name = "codedef",
public = true,
+ untraced = true,
protected = true,
actions = function(what)
local name = scancsname(true)
diff --git a/tex/context/base/mkxl/colo-ini.mkxl b/tex/context/base/mkxl/colo-ini.mkxl
index 07d35089d..2c9c93950 100644
--- a/tex/context/base/mkxl/colo-ini.mkxl
+++ b/tex/context/base/mkxl/colo-ini.mkxl
@@ -1129,10 +1129,10 @@
\letcsname\??colorsetter \endcsname\empty \letcsname\??colorattribute \endcsname\!!zerocount
\letcsname\??transparencysetter\endcsname\empty \letcsname\??transparencyattribute\endcsname\!!zerocount
-\def\colo_helpers_inherited_direct_cs#1{\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
-\def\colo_helpers_inherited_direct_ca#1{\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
-\def\colo_helpers_inherited_direct_ts#1{\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
-\def\colo_helpers_inherited_direct_ta#1{\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_direct_cs#1{\begincsname\??colorsetter #1\endcsname}
+\def\colo_helpers_inherited_direct_ca#1{\ifcsname \??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
+\def\colo_helpers_inherited_direct_ts#1{\begincsname\??transparencysetter #1\endcsname}
+\def\colo_helpers_inherited_direct_ta#1{\ifcsname \??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
\let\colo_defcsname\defcsname
\let\colo_endcsname\endcsname
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index da3244da2..caa9a866b 100644
--- a/tex/context/base/mkxl/cont-new.mkxl
+++ b/tex/context/base/mkxl/cont-new.mkxl
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2021.06.14 17:06}
+\newcontextversion{2021.06.24 18:50}
%D This file is loaded at runtime, thereby providing an excellent place for hacks,
%D patches, extensions and new features. There can be local overloads in cont-loc
diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl
index d51a92236..17c5ec38d 100644
--- a/tex/context/base/mkxl/context.mkxl
+++ b/tex/context/base/mkxl/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\immutable\edef\contextformat {\jobname}
-\immutable\edef\contextversion{2021.06.14 17:06}
+\immutable\edef\contextversion{2021.06.24 18:50}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/core-env.mkxl b/tex/context/base/mkxl/core-env.mkxl
index 86be40548..f3d0a62ba 100644
--- a/tex/context/base/mkxl/core-env.mkxl
+++ b/tex/context/base/mkxl/core-env.mkxl
@@ -407,7 +407,7 @@
\permanent\def\autosetups#1{\clf_autosetups{#1}} % todo: public implementor
-\permanent\edef\setupwithargument#1% saves a few expansions
+\permanent\edef\setupwithargument#1% saves a few expansions and is faster
{\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#1\endcsname#1\noexpand\else\??empty\noexpand\fi\endcsname}
\permanent\edef\setupwithargumentswapped#1#2% saves a few expansions (can be \let)
diff --git a/tex/context/base/mkxl/font-chk.lmt b/tex/context/base/mkxl/font-chk.lmt
index f14e89aeb..b5a875261 100644
--- a/tex/context/base/mkxl/font-chk.lmt
+++ b/tex/context/base/mkxl/font-chk.lmt
@@ -168,6 +168,9 @@ function checkers.placeholder(font,char)
local scale = units/1000
local rawdata = tfmdata.shared and tfmdata.shared.rawdata
local weight = (rawdata and rawdata.metadata and rawdata.metadata.pfmweight or 400)/400
+-- if slant then
+-- slant = 0.2
+-- end
local specification = {
code = "MissingGlyph",
scale = scale,
diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt
index 25aa9b1bc..a9a04557b 100644
--- a/tex/context/base/mkxl/font-con.lmt
+++ b/tex/context/base/mkxl/font-con.lmt
@@ -511,6 +511,10 @@ function constructors.scale(tfmdata,specification)
targetproperties.oldmath = oldmath
target.oldmath = oldmath
+ local mathcontrol = properties.mathcontrol
+ targetproperties.mathcontrol = mathcontrol
+ target.mathcontrol = mathcontrol
+
else
properties.hasmath = false
target.nomath = true
diff --git a/tex/context/base/mkxl/font-imp-math.lmt b/tex/context/base/mkxl/font-imp-math.lmt
index 277190f24..c505d7ddf 100644
--- a/tex/context/base/mkxl/font-imp-math.lmt
+++ b/tex/context/base/mkxl/font-imp-math.lmt
@@ -99,7 +99,7 @@ function fonts.helpers.mathscriptslots(tfmdata,textcode)
end
end
-local function manipulate(tfmdata,key,value)
+local function manipulate(tfmdata,value)
if texconditionals["c_font_compact"] then
local rawdata = tfmdata.shared.rawdata
local rawresources = rawdata and rawdata.resources
@@ -140,7 +140,7 @@ local function manipulate(tfmdata,key,value)
end
end
-local function initialize(tfmdata,key,value)
+local function initialize(tfmdata,value)
if texconditionals["c_font_compact"] then
local rawdata = tfmdata.shared.rawdata
local rawresources = rawdata and rawdata.resources
@@ -199,7 +199,7 @@ registerotffeature(specification)
-- end
-- end
-local function initialize(tfmdata,key,value)
+local function initialize(tfmdata,value)
if value then
local rawdata = tfmdata.shared.rawdata
local rawresources = rawdata and rawdata.resources
@@ -224,3 +224,27 @@ local specification = {
}
registerotffeature(specification)
+
+local function initialize(tfmdata,value)
+ if type(value) == "string" then
+ local rawdata = tfmdata.shared.rawdata
+ local rawresources = rawdata and rawdata.resources
+ local mathconstants = rawresources.mathconstants
+ if mathconstants then
+ local bitmap = tex.stringtocodesbitmap(value,tex.mathcontrolcodes)
+ -- logs.report("mathfont","setting math control to %08X",bitmap)
+ tfmdata.properties.mathcontrol = bitmap
+ end
+ end
+end
+
+local specification = {
+ name = "mathcontrol",
+ description = "control specific old/new math handling",
+ initializers = {
+ base = initialize,
+ node = initialize,
+ }
+}
+
+registerotffeature(specification)
diff --git a/tex/context/base/mkxl/font-ots.lmt b/tex/context/base/mkxl/font-ots.lmt
index def09684a..b8fbc9702 100644
--- a/tex/context/base/mkxl/font-ots.lmt
+++ b/tex/context/base/mkxl/font-ots.lmt
@@ -3824,7 +3824,7 @@ do
-- This permits injection, watch the different arguments. Watch out, the arguments passed
-- are not frozen as we might extend or change this. Is this used at all apart from some
-- experiments?
- local h, ok = handler(head,dataset,sequence,initialrl,font,dynamic) -- less arguments now
+ local h = handler(head,dataset,sequence,initialrl,font,dynamic) -- less arguments now
if h and h ~= head then
head = h
end
diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl
index 0ae90d7cf..52a7dc60f 100644
--- a/tex/context/base/mkxl/font-pre.mkxl
+++ b/tex/context/base/mkxl/font-pre.mkxl
@@ -501,6 +501,26 @@
% [boldened]
% [extend=1.2]
+%D Tweaks:
+%D
+%D \starttyping
+%D \setupbodyfont[dejavu]
+%D
+%D \starttext
+%D \startTEXpage[align={tolerant,stretch},offset=1ex]
+%D {\addff{camelcasing} \samplefile{tufte}\par}
+%D {\addff{uppercasing} \samplefile{tufte}\par}
+%D {\addff{lowercasing} \samplefile{tufte}\par}
+%D {\addff{primes} 123'345''\par}
+%D \stopTEXpage
+%D \stoptext
+%D \stoptyping
+
+\definefontfeature[primes] [primes=yes]
+\definefontfeature[uppercasing][uppercasing=yes]
+\definefontfeature[lowercasing][lowercasing=yes]
+\definefontfeature[camelcasing][camelcasing=yes]
+
%D Neat:
% By eye:
diff --git a/tex/context/base/mkxl/lang-ini.lmt b/tex/context/base/mkxl/lang-ini.lmt
index be1b8f651..2030fb697 100644
--- a/tex/context/base/mkxl/lang-ini.lmt
+++ b/tex/context/base/mkxl/lang-ini.lmt
@@ -164,11 +164,16 @@ local function sethjcodes(instance,loaded,what,factor)
loaded.codehash = h
end
--
- local function setcode(l)
- local u = uccodes[l]
+ local function setcode(code)
+ local l = lccodes[code] -- just in case we get a mixture
+ local u = uccodes[code] -- just in case we get a mixture
local s = l
+ if type(s) ~= "number" then
+ l = code
+ s = code
+ end
if hjcounts then
- local c = hjcounts[l]
+ local c = hjcounts[s]
if c then
c = c.count
if not c then
@@ -186,10 +191,9 @@ local function sethjcodes(instance,loaded,what,factor)
end
end
sethjcode(instance,l,s)
- h[l] = s
if u ~= l and type(u) == "number" then
sethjcode(instance,u,s)
- h[u] = lccodes[l]
+ h[u] = s
end
end
--
@@ -204,7 +208,7 @@ local function sethjcodes(instance,loaded,what,factor)
end
else
-- hash: { ["chr"] = true, ... }
- for k, v in next, c do
+ for k, v in sortedhash(c) do
if v then
setcode(utfbyte(k))
end
diff --git a/tex/context/base/mkxl/libs-imp-curl.lmt b/tex/context/base/mkxl/libs-imp-curl.lmt
index 05b2b8f48..0aa6d0855 100644
--- a/tex/context/base/mkxl/libs-imp-curl.lmt
+++ b/tex/context/base/mkxl/libs-imp-curl.lmt
@@ -19,6 +19,7 @@ if not curllib then return end
local next, type = next, type
local lower, gsub = string.lower, string.gsub
+local dirname = file.dirname
local mapping = {
["acceptencoding"] = 102,
@@ -272,6 +273,9 @@ local function fetch(options)
o[index] = value
end
end
+ -- if o.capath == true then
+ -- o.capath = libpath
+ -- end
return curl_fetch(o)
elseif t == "string" then
return curl_fetch { [mapping.url] = options }
@@ -288,10 +292,19 @@ local curl = {
escape = function (s) return okay() and curl_escape (s) end,
unescape = function (s) return okay() and curl_unescape (s) end,
fetch = fetch,
+ libfile = libfile,
+ libpath = dirname(libfile),
}
-- inspect(curl.fetch("http://www.pragma-ade.com/index.html"))
-- inspect(curl.fetch { url = "http://www.pragma-ade.com/index.html" })
+--
+-- inspect(curl.fetch {
+-- url = "https://www.ctan.org/json/2.0/packages",
+-- sslverifyhost = 0,
+-- sslverifypeer = 0,
+-- -- capath = true
+-- } )
package.loaded[libname] = curl
diff --git a/tex/context/base/mkxl/libs-imp-lzma.lmt b/tex/context/base/mkxl/libs-imp-lzma.lmt
new file mode 100644
index 000000000..69762a54c
--- /dev/null
+++ b/tex/context/base/mkxl/libs-imp-lzma.lmt
@@ -0,0 +1,52 @@
+if not modules then modules = { } end modules ['libs-imp-lzma'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Instead of linking in libs like this we now do them optional. After all, once
+-- we start adding more and more stuff statically we en dup with a mess.
+
+local libname = "lzma"
+local libfile = "liblzma"
+
+local lzmalib = resolvers.libraries.validoptional(libname)
+
+if not lzmalib then return end
+
+local lzma_compress = lzmalib.compress
+local lzma_decompress = lzmalib.decompress
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local lzma = {
+ compress = function (...) return okay() and lzma_compress (...) end,
+ decompress = function (...) return okay() and lzma_decompress (...) end,
+}
+
+package.loaded[libname] = lzma
+
+-- local raw = io.loaddata("e:/luatex/luametatex-source.tar")
+-- local old = io.loaddata("e:/luatex/luametatex-source.tar.xz")
+-- local new = lzma.decompress(old)
+-- local xz1 = lzma.compress(raw,9)
+-- local xz2 = lzma.decompress(xz1)
+
+-- print("raw",raw and #raw)
+-- print("old",old and #old)
+-- print("new",new and #new)
+-- print("chk",new == raw)
+-- print("xz1",xz1 and #xz1)
+-- print("xz2",xz2 and #xz2)
+-- print("chk",xz2 == raw)
+
+return lzma
diff --git a/tex/context/base/mkxl/lpdf-col.lmt b/tex/context/base/mkxl/lpdf-col.lmt
index e76471b89..28413fd9a 100644
--- a/tex/context/base/mkxl/lpdf-col.lmt
+++ b/tex/context/base/mkxl/lpdf-col.lmt
@@ -558,7 +558,9 @@ end
lpdf.color = lpdfcolor
interfaces.implement {
- name = "lpdf_color",
+ name = "pdfcolor",
+ public = true,
+ untraced = true,
actions = { lpdfcolor, context },
arguments = "integer"
}
diff --git a/tex/context/base/mkxl/lpdf-emb.lmt b/tex/context/base/mkxl/lpdf-emb.lmt
index fd0f0cf6b..4781b5bad 100644
--- a/tex/context/base/mkxl/lpdf-emb.lmt
+++ b/tex/context/base/mkxl/lpdf-emb.lmt
@@ -85,6 +85,8 @@ local getmapentry = fonts.mappings.getentry
-- needs checking: signed vs unsigned
+-- todo: use streams.tocardinal4 etc
+
local tocardinal1 = char
local function tocardinal2(n)
diff --git a/tex/context/base/mkxl/lpdf-ini.lmt b/tex/context/base/mkxl/lpdf-ini.lmt
index f58727edf..3b2ee17ac 100644
--- a/tex/context/base/mkxl/lpdf-ini.lmt
+++ b/tex/context/base/mkxl/lpdf-ini.lmt
@@ -1278,19 +1278,20 @@ do
end
--- interface
-
-implement { name = "lpdf_collectedresources", actions = { lpdf.collectedresources, context } }
-implement { name = "lpdf_addtocatalog", arguments = "2 strings", actions = lpdf.addtocatalog }
-implement { name = "lpdf_addtoinfo", arguments = "2 strings", actions = function(a,b,c) lpdf.addtoinfo(a,b,c) end } -- gets adapted
-implement { name = "lpdf_addtonames", arguments = "2 strings", actions = lpdf.addtonames }
-implement { name = "lpdf_addtopageattributes", arguments = "2 strings", actions = lpdf.addtopageattributes }
-implement { name = "lpdf_addtopagesattributes", arguments = "2 strings", actions = lpdf.addtopagesattributes }
-implement { name = "lpdf_addtopageresources", arguments = "2 strings", actions = lpdf.addtopageresources }
-implement { name = "lpdf_adddocumentextgstate", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentextgstate (a,pdfverbose(b)) end }
-implement { name = "lpdf_adddocumentcolorspace", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentcolorspace(a,pdfverbose(b)) end }
-implement { name = "lpdf_adddocumentpattern", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentpattern (a,pdfverbose(b)) end }
-implement { name = "lpdf_adddocumentshade", arguments = "2 strings", actions = function(a,b) lpdf.adddocumentshade (a,pdfverbose(b)) end }
+-- Bah, tikz uses \immediate for some reason which is probably a bug, so the usage
+-- will deal with that. However, we will not provide the serialization.
+
+implement { name = "pdfbackendcurrentresources", public = true, untraced = true, actions = { lpdf.collectedresources, context } }
+implement { name = "pdfbackendsetcatalog", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = lpdf.addtocatalog }
+implement { name = "pdfbackendsetinfo", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = function(a,b,c) lpdf.addtoinfo(a,b,c) end } -- gets adapted
+implement { name = "pdfbackendsetname", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = lpdf.addtonames }
+implement { name = "pdfbackendsetpageattribute", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = lpdf.addtopageattributes }
+implement { name = "pdfbackendsetpagesattribute", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = lpdf.addtopagesattributes }
+implement { name = "pdfbackendsetpageresource", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = lpdf.addtopageresources }
+implement { name = "pdfbackendsetextgstate", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = function(a,b) lpdf.adddocumentextgstate (a,pdfverbose(b)) end }
+implement { name = "pdfbackendsetcolorspace", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = function(a,b) lpdf.adddocumentcolorspace(a,pdfverbose(b)) end }
+implement { name = "pdfbackendsetpattern", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = function(a,b) lpdf.adddocumentpattern (a,pdfverbose(b)) end }
+implement { name = "pdfbackendsetshade", usage = "value", public = true, protected = true, arguments = "2 arguments", actions = function(a,b) lpdf.adddocumentshade (a,pdfverbose(b)) end }
-- more helpers: copy from lepd to lpdf
diff --git a/tex/context/base/mkxl/luat-cnf.lmt b/tex/context/base/mkxl/luat-cnf.lmt
index 081f2462f..ea9eb0d89 100644
--- a/tex/context/base/mkxl/luat-cnf.lmt
+++ b/tex/context/base/mkxl/luat-cnf.lmt
@@ -224,4 +224,4 @@ local function makestub()
report()
end
-lua.registerfinalizer(makestub,"create stub file")
+lua.registerinitexfinalizer(makestub,"create stub file")
diff --git a/tex/context/base/mkxl/luat-cod.lmt b/tex/context/base/mkxl/luat-cod.lmt
index 7047726b5..2e5fa8062 100644
--- a/tex/context/base/mkxl/luat-cod.lmt
+++ b/tex/context/base/mkxl/luat-cod.lmt
@@ -99,28 +99,6 @@ function lua.registercode(filename,options)
end
end
-local finalizers = { }
-
-function lua.registerfinalizer(f,comment)
- comment = comment or "unknown"
- if type(f) == "function" then
- finalizers[#finalizers+1] = { action = f, comment = comment }
- else
- print(format("\nfatal error: invalid finalizer, action: %s\n",comment))
- os.exit()
- end
-end
-
-function lua.finalize(logger)
- for i=1,#finalizers do
- local finalizer = finalizers[i]
- finalizer.action()
- if logger then
- logger("finalize action: %s",finalizer.comment)
- end
- end
-end
-
-- A first start with environments. This will be overloaded later.
environment = environment or { }
@@ -175,6 +153,37 @@ environment.jitsupported = JITSUPPORTED
environment.initex = INITEXMODE
environment.initexmode = INITEXMODE
+if INITEXMODE then
+
+ local finalizers = { }
+
+ function lua.registerinitexfinalizer(f,comment)
+ comment = comment or "unknown"
+ if type(f) == "function" then
+ finalizers[#finalizers+1] = { action = f, comment = comment }
+ else
+ print(format("\nfatal error: invalid finalizer, action: %s\n",comment))
+ os.exit()
+ end
+ end
+
+ function lua.finalizeinitex(logger)
+ for i=1,#finalizers do
+ local finalizer = finalizers[i]
+ finalizer.action()
+ if logger then
+ logger("finalize action: %s",finalizer.comment)
+ end
+ end
+ end
+
+else
+
+ function lua.registerinitexfinalizer() end
+ function lua.finalizeinitex () end
+
+end
+
-- if INITEXMODE then
-- -- we have about that amount so we preallocate then which gives less
-- -- reallocations (we're talking tiny record so no real gain)
diff --git a/tex/context/base/mkxl/luat-lib.mkxl b/tex/context/base/mkxl/luat-lib.mkxl
index a01e7f86f..d26c90af5 100644
--- a/tex/context/base/mkxl/luat-lib.mkxl
+++ b/tex/context/base/mkxl/luat-lib.mkxl
@@ -46,6 +46,7 @@
\registerctxluafile{util-soc-imp-tp} {}
\registerctxluafile{util-zip}{}
+\registerctxluafile{util-tar}{}
\registerctxluafile{data-ini}{}
\registerctxluafile{data-exp}{}
@@ -62,6 +63,8 @@
\registerctxluafile{data-tex}{} % after data-pre
\registerctxluafile{data-vir}{}
\registerctxluafile{data-zip}{}
+\registerctxluafile{data-dec}{}
+\registerctxluafile{data-tar}{}
%registerctxluafile{data-crl}{}
\registerctxluafile{data-sch}{}
\registerctxluafile{data-tre}{}
@@ -74,7 +77,7 @@
\registerctxluafile{luat-cbk}{autosuffix}
\registerctxluafile{luat-run}{autosuffix}
\registerctxluafile{luat-fio}{autosuffix}
-\registerctxluafile{luat-cnf}{autosuffix}
+\registerctxluafile{luat-cnf}{autosuffix,initexonly}
\registerctxluafile{luat-lua}{}
\registerctxluafile{luat-sto}{}
\registerctxluafile{luat-ini}{autosuffix}
diff --git a/tex/context/base/mkxl/luat-run.lmt b/tex/context/base/mkxl/luat-run.lmt
index 075f5bd62..fa3336d4b 100644
--- a/tex/context/base/mkxl/luat-run.lmt
+++ b/tex/context/base/mkxl/luat-run.lmt
@@ -102,7 +102,7 @@ local function pre_dump_actions()
for i=1,#dumpactions do
dumpactions[i]()
end
- lua.finalize(trace_lua_dump and report_lua or nil)
+ lua.finalizeinitex(trace_lua_dump and report_lua or nil)
end
local function wrapup_synctex()
diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl
index df2bb7ccb..37c48121c 100644
--- a/tex/context/base/mkxl/math-ini.mkxl
+++ b/tex/context/base/mkxl/math-ini.mkxl
@@ -122,10 +122,16 @@
\definesystemattribute[displaymath] [public]
-\mathflattenmode 31
+\mathflattenmode\numexpr
+ \ordflattencode
+ +\binflattencode
+ +\relflattencode
+ +\punctflattencode
+ +\innerflattencode
+\relax
\ifdefined\ordlimits\else
- \let\ordlimits\limits
+ \let\ordlimits\Umathlimits % downward compatible
\fi
\appendtoks
@@ -3003,6 +3009,38 @@
\normalsupmarkmode\plusone % 2 also disable ^[^+] in text mode
+\permanent\protected\tolerant\def\supscr[#1]#:#2%
+ {\ifchkdim#1\or\Umathopenupheight#1\relax\fi
+ \Usuperscript{#2}}
+
+\permanent\protected\tolerant\def\subscr[#1]#:#2%
+ {\ifchkdim#1\or\Umathopenupdepth #1\relax\fi
+ \Usubscript{#2}}
+
+\permanent\protected\tolerant\def\supsubscr[#1]#:#2#3%
+ {\ifchkdim#1\or\Umathopenupheight#1\relax\Umathopenupdepth#1\relax\fi
+ \Usuperscript{#2}\Usubscript{#3}}
+
+\permanent\protected\tolerant\def\subsupscr[#1]#:#*#2#3%
+ {\ifchkdim#1\or\Umathopenupheight#1\relax\Umathopenupdepth#1\relax\fi
+ \Usubscript{#2}\Usuperscript{#3}}
+
+\permanent\protected\tolerant\def\supprescr[#1]#:#2%
+ {\ifchkdim#1\or\Umathopenupheight#1\relax\fi
+ \Usuperprescript{#2}}
+
+\permanent\protected\tolerant\def\subprescr[#1]#:#2%
+ {\ifchkdim#1\or\Umathopenupdepth #1\relax\fi
+ \Usubprescript{#2}}
+
+\permanent\protected\tolerant\def\supsubprescr[#1]#:#2#3%
+ {\ifchkdim#1\or\Umathopenupheight#1\relax\Umathopenupdepth#1\relax\fi
+ \Usuperprescript{#2}\Usubprescript{#3}}
+
+\permanent\protected\tolerant\def\subsupprescr[#1]#:#*#2#3%
+ {\ifchkdim#1\or\Umathopenupheight#1\relax\Umathopenupdepth#1\relax\fi
+ \Usubprescript{#2}\Usuperprescript{#3}}
+
\protect \endinput
% % not used (yet)
diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt
index 5ce0702de..09c67b8a1 100644
--- a/tex/context/base/mkxl/math-noa.lmt
+++ b/tex/context/base/mkxl/math-noa.lmt
@@ -182,20 +182,17 @@ local nodecodes = nodes.nodecodes
local noadcodes = nodes.noadcodes
local fencecodes = nodes.fencecodes
-local ordnoad_code = noadcodes.ord
-local opdisplaylimitsnoad_code = noadcodes.opdisplaylimits
-local oplimitsnoad_code = noadcodes.oplimits
-local opnolimitsnoad_code = noadcodes.opnolimits
-local binnoad_code = noadcodes.bin
-local relnode_code = noadcodes.rel
-local opennoad_code = noadcodes.open
-local closenoad_code = noadcodes.close
-local punctnoad_code = noadcodes.punct
-local innernoad_code = noadcodes.inner
-local undernoad_code = noadcodes.under
-local overnoad_code = noadcodes.over
-local vcenternoad_code = noadcodes.vcenter
-local ordlimitsnoad_code = noadcodes.ordlimits or oplimitsnoad_code
+local ordnoad_code = noadcodes.ord
+local opnoad_code = noadcodes.op
+local binnoad_code = noadcodes.bin
+local relnode_code = noadcodes.rel
+local opennoad_code = noadcodes.open
+local closenoad_code = noadcodes.close
+local punctnoad_code = noadcodes.punct
+local innernoad_code = noadcodes.inner
+local undernoad_code = noadcodes.under
+local overnoad_code = noadcodes.over
+local vcenternoad_code = noadcodes.vcenter
local noad_code = nodecodes.noad -- attr nucleus sub sup
local accent_code = nodecodes.accent -- attr nucleus sub sup accent
@@ -1801,20 +1798,17 @@ do
local collapse = { }
local mathlists = characters.mathlists
local validpair = {
- [ordnoad_code] = true,
- [opdisplaylimitsnoad_code] = true,
- [oplimitsnoad_code] = true,
- [opnolimitsnoad_code] = true,
- [binnoad_code] = true, -- new
- [relnode_code] = true,
- [opennoad_code] = true, -- new
- [closenoad_code] = true, -- new
- [punctnoad_code] = true, -- new
- [innernoad_code] = false,
- [undernoad_code] = false,
- [overnoad_code] = false,
- [vcenternoad_code] = false,
- [ordlimitsnoad_code] = true,
+ [ordnoad_code] = true,
+ [opnoad_code] = true,
+ [binnoad_code] = true, -- new
+ [relnode_code] = true,
+ [opennoad_code] = true, -- new
+ [closenoad_code] = true, -- new
+ [punctnoad_code] = true, -- new
+ [innernoad_code] = false,
+ [undernoad_code] = false,
+ [overnoad_code] = false,
+ [vcenternoad_code] = false,
}
local reported = setmetatableindex("table")
@@ -2099,20 +2093,17 @@ do
local classes = { }
local colors = {
- [relnode_code] = "trace:dr",
- [ordnoad_code] = "trace:db",
- [binnoad_code] = "trace:dg",
- [opennoad_code] = "trace:dm",
- [closenoad_code] = "trace:dm",
- [punctnoad_code] = "trace:dc",
- -- [opdisplaylimitsnoad_code] = "",
- -- [oplimitsnoad_code] = "",
- -- [opnolimitsnoad_code] = "",
- -- [ordlimitsnoad_code] = "",
- -- [innernoad_code = "",
- -- [undernoad_code] = "",
- -- [overnoad_code] = "",
- -- [vcenternoad_code] = "",
+ [relnode_code] = "trace:dr",
+ [ordnoad_code] = "trace:db",
+ [binnoad_code] = "trace:dg",
+ [opennoad_code] = "trace:dm",
+ [closenoad_code] = "trace:dm",
+ [punctnoad_code] = "trace:dc",
+ -- [opnoad_code] = "",
+ -- [innernoad_code = "",
+ -- [undernoad_code] = "",
+ -- [overnoad_code] = "",
+ -- [vcenternoad_code] = "",
}
local setcolor = colortracers.set
@@ -2325,33 +2316,25 @@ end
-- the normal builder
-do
-
- local force_penalties = false
-
- -- registertracker("math.penalties",function(v)
- -- force_penalties = v
- -- end)
-
- function builders.kernel.mlisttohlist(head,style,penalties)
- return mlisttohlist(head,style,force_penalties or penalties)
- end
-
- -- function builders.kernel.mlisttohlist(head,style,penalties)
- -- local h = mlisttohlist(head,style,force_penalties or penalties)
- -- inspect(nodes.totree(h,true,true,true))
- -- return h
- -- end
-
- implement {
- name = "setmathpenalties",
- arguments = "integer",
- actions = function(p)
- force_penalties = p > 0
- end,
- }
+-- do
+--
+-- local force_penalties = false
+--
+-- function builders.kernel.mlisttohlist(head,style,penalties)
+-- return mlisttohlist(head,style,force_penalties or penalties)
+-- end
+--
+-- implement {
+-- name = "setmathpenalties",
+-- arguments = "integer",
+-- actions = function(p)
+-- force_penalties = p > 0
+-- end,
+-- }
+--
+-- end
-end
+builders.kernel.mlisttohlist = mlisttohlist
local actions = tasks.actions("math") -- head, style, penalties
diff --git a/tex/context/base/mkxl/math-stc.mklx b/tex/context/base/mkxl/math-stc.mklx
index 944185c23..b819c3ca5 100644
--- a/tex/context/base/mkxl/math-stc.mklx
+++ b/tex/context/base/mkxl/math-stc.mklx
@@ -116,7 +116,7 @@
% $\Umathaccent 0 0 "2190{x}$ \par $\Umathaccent 0 0 "27F8{x}$\par
% $\Udelimiterunder 0 "2190{x}$ \par $\Udelimiterunder 0 "27F8{x}$\par
-\setvalue{\??mathextensiblefallbacks}%
+\defcsname\??mathextensiblefallbacks\endcsname
{\hpack{\vrule\s!width\scratchwidth\s!height.1\mathexheight\s!depth\zeropoint}}
% \def\math_stackers_with_fallback#codepoint%
@@ -201,12 +201,12 @@
\installcorenamespace {mathstackerslocation}
\installcorenamespace {mathstackersalternative}
-\letvalue{\??mathstackerslocation\v!top }\plusone % on top of baseline
-\letvalue{\??mathstackerslocation\v!high }\plustwo % 25 % down
-\letvalue{\??mathstackerslocation\v!middle }\plusthree % centered
-\letvalue{\??mathstackerslocation\v!low }\plusfour % 75 % down
-\letvalue{\??mathstackerslocation\v!bottom }\plusfive % below baseline
-\letvalue{\??mathstackerslocation }\zerocount
+\letcsname\??mathstackerslocation\v!top \endcsname\plusone % on top of baseline
+\letcsname\??mathstackerslocation\v!high \endcsname\plustwo % 25 % down
+\letcsname\??mathstackerslocation\v!middle \endcsname\plusthree % centered
+\letcsname\??mathstackerslocation\v!low \endcsname\plusfour % 75 % down
+\letcsname\??mathstackerslocation\v!bottom \endcsname\plusfive % below baseline
+\letcsname\??mathstackerslocation \endcsname\zerocount
%D First we implement the helper that deals with an extensible in the middle and
%D top and|/|or bottom texts:
@@ -242,8 +242,8 @@
% no checking, we assume sane use
-\letvalue{\??mathstackersalternative\v!normal }\math_stackers_content
-\letvalue{\??mathstackersalternative\v!default}\math_stackers_content
+\letcsname\??mathstackersalternative\v!normal \endcsname\math_stackers_content
+\letcsname\??mathstackersalternative\v!default\endcsname\math_stackers_content
\setupmathstackers
[\c!mp=math:stacker:\number\scratchunicode,
@@ -251,7 +251,7 @@
\c!mpdepth=\mathchardp\scratchunicode,
\c!mpoffset=.25\mathexheight]
-\setvalue{\??mathstackersalternative\v!mp}%
+\defcsname\??mathstackersalternative\v!mp\endcsname
{\normalexpanded{\math_stackers_mp_box
{\the\dimexpr\mathstackersparameter\c!mpheight}%
{\the\dimexpr\mathstackersparameter\c!mpdepth}%
@@ -526,9 +526,9 @@
\installcorenamespace {mathclasses}
-\letvalue{\??mathclasses }\mathord
-\letvalue{\??mathclasses rel}\mathrel
-\letvalue{\??mathclasses ord}\mathord
+\letcsname\??mathclasses \endcsname\mathord
+\letcsname\??mathclasses rel\endcsname\mathrel
+\letcsname\??mathclasses ord\endcsname\mathord
\def\math_class_by_parameter#1%
{\normalexpanded{\noexpand\math_class_by_parameter_indeed{#1\c!mathclass}}}
diff --git a/tex/context/base/mkxl/math-tag.lmt b/tex/context/base/mkxl/math-tag.lmt
index a602870c9..80e78b328 100644
--- a/tex/context/base/mkxl/math-tag.lmt
+++ b/tex/context/base/mkxl/math-tag.lmt
@@ -555,8 +555,12 @@ process = function(start) -- we cannot use the processor as we have no finalizer
processsubsup(start)
end
elseif id == glue_code then
- -- setattr(start,a_tagged,start_tagged("mspace",{ width = getwidth(start) }))
- setattr(start,a_tagged,start_tagged("mspace"))
+ -- before processing, so other intermathglue is not tagged
+ local em = fonts.hashes.emwidths[nuts.getfont(start)]
+ local wd = getwidth(start)
+ if em and wd then
+ setattr(start,a_tagged,start_tagged("mspace",{ emfactor = wd/em }))
+ end
stop_tagged()
else
setattr(start,a_tagged,start_tagged("merror", { detail = nodecodes[i] }))
diff --git a/tex/context/base/mkxl/mlib-mpf.lmt b/tex/context/base/mkxl/mlib-mpf.lmt
index b03c664b8..f60f31076 100644
--- a/tex/context/base/mkxl/mlib-mpf.lmt
+++ b/tex/context/base/mkxl/mlib-mpf.lmt
@@ -941,6 +941,7 @@ do
local scanstring = scan.string
local scannumeric = scan.numeric
+ local scaninteger = scan.integer
local skiptoken = skip.token
----- injectstring = inject.string
@@ -982,7 +983,7 @@ do
registerscript("setglobalmacro", function() setmacro(scanstring(),scanstring(),"global") end)
registerscript("setglobaldimen", function() setdimen("global",scanstring(),scannumeric()/bpfactor) end)
- registerscript("setglobalcount", function() setcount("global",scanstring(),scannumeric()) end)
+ registerscript("setglobalcount", function() setcount("global",scanstring(),scaninteger()) end)
registerscript("setglobaltoks", function() settoks ("global",scanstring(),scanstring()) end)
local utfnum = utf.byte
diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt
index 6f38f30ff..cae1bbb5f 100644
--- a/tex/context/base/mkxl/mlib-pps.lmt
+++ b/tex/context/base/mkxl/mlib-pps.lmt
@@ -1021,7 +1021,7 @@ local tx_reset, tx_process do
end
end
- local fasttrack = true
+ local fasttrack = false -- we loose colors done with withcolor when true
directives.register("metapost.text.fasttrack", function(v) fasttrack = v end)
diff --git a/tex/context/base/mkxl/node-ext.lmt b/tex/context/base/mkxl/node-ext.lmt
index 9068cd976..896dd8f99 100644
--- a/tex/context/base/mkxl/node-ext.lmt
+++ b/tex/context/base/mkxl/node-ext.lmt
@@ -51,7 +51,8 @@ local whatsitcodes = allocate { }
nodes.whatsitcodes = whatsitcodes
local lastwhatsit = 0
-nodes.subtypes.whatsit = whatsitcodes
+nodes.subtypes.whatsit = whatsitcodes
+nodes.subtypes[whatsit_code] = whatsitcodes
local function registerwhatsit(name)
lastwhatsit = lastwhatsit + 1
@@ -165,6 +166,7 @@ do
name = "latelua",
public = true,
protected = true,
+ untraced = true,
actions = function()
local node = copynut(lateluanode)
local name = "latelua"
diff --git a/tex/context/base/mkxl/node-fin.lmt b/tex/context/base/mkxl/node-fin.lmt
index ae5d0eac5..ffabd25ea 100644
--- a/tex/context/base/mkxl/node-fin.lmt
+++ b/tex/context/base/mkxl/node-fin.lmt
@@ -198,11 +198,12 @@ local function process(attribute,head,inheritance,default) -- one attribute
elseif id == hlist_code or id == vlist_code then
-- tricky checking
local outer
- if subtype == container_code then
- check = true
- current = 0
- end
- if getorientation(stack) then
+-- if subtype == container_code then
+-- check = true
+-- current = 0
+-- end
+-- if getorientation(stack) then
+ if subtype == container_code or getorientation(stack) then
outer = getattr(stack,attribute)
if outer then
if default and outer == inheritance then
@@ -321,11 +322,12 @@ local function simple(attribute,head)
check = true
leader = content
elseif id == hlist_code or id == vlist_code then
- if subtype == container_code then
- check = true
-current = 0
- end
- if getorientation(stack) then
+-- if subtype == container_code then
+-- check = true
+-- current = 0
+-- end
+-- if getorientation(stack) then
+ if subtype == container_code or getorientation(stack) then
local outer = getattr(stack,attribute)
if outer then
if current ~= outer then
@@ -526,13 +528,14 @@ local function selective(attribute,head,inheritance,default) -- two attributes
check = true
leader = content -- getleader(stack)
elseif id == hlist_code or id == vlist_code then
- -- tricky checking
- if subtype == container_code then
- check = true
-current = 0
- end
local outer, s
- if getorientation(stack) then
+ -- tricky checking
+-- if subtype == container_code then
+-- check = true
+-- current = 0
+-- end
+-- if getorientation(stack) then
+if subtype == container_code or getorientation(stack) then
outer, s = getattrs(stack,attribute,nsselector)
if outer then
if default and outer == inheritance then
diff --git a/tex/context/base/mkxl/node-res.lmt b/tex/context/base/mkxl/node-res.lmt
index fbf52ae3b..b1ab7e22b 100644
--- a/tex/context/base/mkxl/node-res.lmt
+++ b/tex/context/base/mkxl/node-res.lmt
@@ -538,7 +538,7 @@ statistics.register("node memory usage", function() -- comes after cleanup !
end
end)
-lua.registerfinalizer(cleanup, "cleanup reserved nodes")
+lua.registerinitexfinalizer(cleanup, "cleanup reserved nodes")
do
diff --git a/tex/context/base/mkxl/pack-rul.mkxl b/tex/context/base/mkxl/pack-rul.mkxl
index 36266bc98..c4e510623 100644
--- a/tex/context/base/mkxl/pack-rul.mkxl
+++ b/tex/context/base/mkxl/pack-rul.mkxl
@@ -642,10 +642,48 @@
\box\b_framed_normal
\box\b_framed_extra}}
+%D A probably unknown feature:
+%D
+%D \startbuffer
+%D \hpack\bgroup
+%D \framed[framecolor=MyColor,frame=on] {!!!!!!!!}
+%D \framed[framecolor=MyColor,frame=closed]{!!!!!!!!}
+%D \framed[framecolor=MyColor,frame=small] {!!!!!!!!}
+%D \egroup
+%D \stopbuffer
+%D
+%D \typebuffer \startlinecorrection[blank] \getbuffer \stoplinecorrection
+
+% \def\pack_framed_stroked_box_normal_opened
+% {\setbox\scratchbox\vpack \bgroup
+% \csname\??framedtop\p_framed_frame\framedparameter\c!topframe\endcsname
+% \nointerlineskip % new (needed for fences)
+% \hpack \bgroup
+% \csname\??framedleft\p_framed_frame\framedparameter\c!leftframe\endcsname
+% \novrule
+% \s!width \d_framed_target_wd
+% \s!height\d_framed_target_ht
+% \s!depth \d_framed_target_dp
+% \csname\??framedright\p_framed_frame\framedparameter\c!rightframe\endcsname
+% \egroup
+% \nointerlineskip % new (needed for fences)
+% \csname\??framedbottom\p_framed_frame\framedparameter\c!bottomframe\endcsname
+% \egroup
+% \wd\scratchbox\d_framed_target_wd
+% \ht\scratchbox\d_framed_target_ht
+% \dp\scratchbox\d_framed_target_dp
+% \box\scratchbox}
+
+% less logging:
+
\def\pack_framed_stroked_box_normal_opened
{\setbox\scratchbox\vpack \bgroup
+ % \normaloffinterlineskip % sets baselineskip, lineskip and lineskiplimit
+ \baselineskip-\thousandpoint
+ \lineskip \zeropoint
+ \lineskiplimit\maxdimen
\csname\??framedtop\p_framed_frame\framedparameter\c!topframe\endcsname
- \nointerlineskip % new (needed for fences)
+ % \nointerlineskip % new (needed for fences)
\hpack \bgroup
\csname\??framedleft\p_framed_frame\framedparameter\c!leftframe\endcsname
\novrule
@@ -654,7 +692,7 @@
\s!depth \d_framed_target_dp
\csname\??framedright\p_framed_frame\framedparameter\c!rightframe\endcsname
\egroup
- \nointerlineskip % new (needed for fences)
+ % \nointerlineskip % new (needed for fences)
\csname\??framedbottom\p_framed_frame\framedparameter\c!bottomframe\endcsname
\egroup
\wd\scratchbox\d_framed_target_wd
@@ -704,10 +742,27 @@
% no overlapping rules
-\def\pack_framed_t_rules{\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}\nointerlineskip\kern-\d_framed_linewidth}
-\def\pack_framed_b_rules{\kern-\d_framed_linewidth\nointerlineskip\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}}
-\def\pack_framed_r_rules{\kern-\d_framed_linewidth\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth}
-\def\pack_framed_l_rules{\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth\kern-\d_framed_linewidth}
+% \def\pack_framed_t_rules{\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}\nointerlineskip\kern-\d_framed_linewidth}
+% \def\pack_framed_b_rules{\kern-\d_framed_linewidth\nointerlineskip\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}}
+% \def\pack_framed_r_rules{\kern-\d_framed_linewidth\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth}
+% \def\pack_framed_l_rules{\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth\kern-\d_framed_linewidth}
+%
+% see above, less tracing
+%
+% \def\pack_framed_t_rules{\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}\kern-\d_framed_linewidth}
+% \def\pack_framed_b_rules{\kern-\d_framed_linewidth\hpack{\kern\d_framed_linewidth\vrule\s!width\dimexpr\d_framed_target_wd-2\d_framed_linewidth\relax\s!height\d_framed_linewidth}}
+% \def\pack_framed_r_rules{\kern-\d_framed_linewidth\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth}
+% \def\pack_framed_l_rules{\vrule\s!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\s!depth-\d_framed_linewidth\s!width\d_framed_linewidth\kern-\d_framed_linewidth}
+%
+% more modern:
+
+\def\pack_framed_rules_hrule{\hrule\s!height\d_framed_linewidth\s!left\d_framed_linewidth\s!right \d_framed_linewidth}
+\def\pack_framed_rules_vrule{\vrule\s!width \d_framed_linewidth\s!top \d_framed_linewidth\s!bottom\d_framed_linewidth\s!yoffset-\d_framed_linewidth}
+
+\def\pack_framed_t_rules{\pack_framed_rules_hrule\kern-\d_framed_linewidth}
+\def\pack_framed_b_rules{\kern-\d_framed_linewidth\pack_framed_rules_hrule}
+\def\pack_framed_r_rules{\kern-\d_framed_linewidth\pack_framed_rules_vrule}
+\def\pack_framed_l_rules{\pack_framed_rules_vrule\kern-\d_framed_linewidth}
\letcsname\??framedtop \v!small\v!small\endcsname\pack_framed_t_rules
\letcsname\??framedtop \v!off \v!small\endcsname\pack_framed_t_rules
diff --git a/tex/context/base/mkxl/page-ffl.mkxl b/tex/context/base/mkxl/page-ffl.mkxl
index 7c0c5af9d..7c04d01e1 100644
--- a/tex/context/base/mkxl/page-ffl.mkxl
+++ b/tex/context/base/mkxl/page-ffl.mkxl
@@ -51,13 +51,93 @@
%D \startcontent \dorecurse{10}{\samplefile{ward} } \stopcontent
%D \stopfacingfloat
%D
+%D \flushfacingfloats[whatever]
+%D
%D \dorecurse{10}{\samplefile{sapolsky} }
+%D
+%D \flushpendingtopcontent
+%D
%D \stoptyping
%D
%D The idea is to flush related floats more or less in parallel.
\unprotect
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% \starttext
+%
+% \registertopcontent[3]\vbox{\framed[align=normal,width=\textwidth]{\samplefile{ward}}}
+% \registertopcontent[3]\vbox{\framed[align=normal,width=\textwidth]{\samplefile{davis}}}
+% \registertopcontent[5]\vbox{\framed[align=normal,width=\textwidth]{\samplefile{ward}}}
+%
+% \dorecurse{20}{\samplefile{tufte}\par}
+%
+% \stoptext
+
+\newdimen\d_page_adapts_preroll
+\newcount\c_page_adapts_pushed
+
+% this assumes a constant textheight and no adaptations otherwise so we
+% should block these for already set pages in adaptheight .. or we can
+% make these independent (so not use adaptheight)
+
+\def\page_adapts_layout_preroll#1%
+ {\begingroup
+ \global\d_page_adapts_preroll\zeropoint
+ \def\page_adapts_layout_indeed##1%
+ {\setupcurrentadaptlayout[\c!top=\zeropoint,##1]%
+ \global\d_page_adapts_preroll\dimexpr\adaptlayoutparameter\c!top\relax}
+ \begincsname\??pageadaptations\number#1\endcsname
+ \endgroup}
+
+\permanent\protected\def\registertopcontent[#1]%
+ {\begingroup
+ \dowithnextbox
+ {\page_adapts_layout_preroll{#1}%
+ \scratchdimen\dimexpr
+ \htdp\nextbox+\d_page_adapts_preroll
+ \ifzeropt\d_page_adapts_preroll
+ +\lineheight
+ \fi
+ \relax
+ \putboxincache{\v!page:\number#1}{+}\nextbox
+ \normalexpanded{\adaptlayout[\number#1][\c!top=\the\scratchdimen]}%
+ \global\advance\c_page_adapts_pushed\plusone
+ \endgroup}}
+
+\def\page_otr_flush_top_content
+ {\scratchcounter\getboxcountfromcache{\v!page:\number\realpageno}\relax
+ \ifcase\scratchcounter\else
+ \dorecurse\scratchcounter
+ {\directboxfromcache{\v!page:\number\realpageno}\recurselevel
+ \nointerlineskip
+ \par}%
+ \disposeboxesincache{\v!page:\number\realpageno}%
+ \global\advance\c_page_adapts_pushed\minusone
+ \nointerlineskip
+ \fi}
+
+\permanent\protected\def\flushpendingtopcontent
+ {\ifcase\c_page_adapts_pushed\else
+ \null
+ \page
+ \expandafter\flushpendingtopcontent
+ \fi}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% \let\page_check_weird_page\relax
+
+\def\page_check_weird_page_indeed % for now only when facing floats
+ {\ifdim\vsize>\zeropoint\else
+ %\showmessage\m!layouts9{}%
+ \writestatus\m!layouts{forcing zero height page}%
+ \emptyhbox\page
+ \fi}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
% width:
%
% -- fit : do nothing
@@ -76,11 +156,17 @@
%\c!color,
\c!width=\v!fit]
+\newcount\c_defining_facing_float
+
\appendtoks
- \ifempty\currentfacingfloatparent
- \normalexpanded{\definefacingfloat[\currentfacingfloat:\v!left ][\currentfacingfloat]}%
- \normalexpanded{\definefacingfloat[\currentfacingfloat:\v!right][\currentfacingfloat]}%
+ \advance\c_defining_facing_float\plusone
+ \ifcase\c_defining_facing_float\or
+ \expanded{
+ \definefacingfloat[\currentfacingfloat:\v!left ][\currentfacingfloat]%
+ \definefacingfloat[\currentfacingfloat:\v!right][\currentfacingfloat]%
+ }%
\fi
+ \advance\c_defining_facing_float\minusone
\to \everydefinefacingfloat
\newcount\c_strc_floats_facing_saved
@@ -91,88 +177,79 @@
\let\m_strc_floats_state\relax
-% \permanent\protected\def\strc_floats_facing_flush
-% {\ifnum\c_strc_floats_facing_flushed<\c_strc_floats_facing_saved
-% \ifodd\c_strc_floats_facing_flushed
-% \ifodd\realpageno
-% \strc_floats_facing_flush_indeed
-% \doifelsependingpagecontent\relax{\kern\zeropoint\page}%
-% \fi
-% \else
-% \ifodd\realpageno\else
-% \strc_floats_facing_flush_indeed
-% \doifelsependingpagecontent\relax{\kern\zeropoint\page}%
-% \fi
-% \fi
-% \fi}
-%
-% \permanent\protected\def\strc_floats_facing_flush_indeed
-% {\global\advance\c_strc_floats_facing_flushed\plusone
-% \floatingpenalty\zerocount
-% \page_inserts_inject\namedinsertionnumber\s!topfloat\bgroup
-% \forgetall
-% \ifconditional\c_page_one_top_of_insert
-% \ifconditional\c_page_one_correct_top_insert
-% \topskipcorrection % [xx] new: see icare topbleed
-% \kern-\lineskip
-% \par
-% \prevdepth\maxdimen
-% \fi
-% \fi
-% \directboxfromcache{\currentfacingfloat}{\number\c_strc_floats_facing_flushed}%
-% \vkern\s_page_one_between_top_insert
-% \egroup
-% \ifnum\c_strc_floats_facing_saved=\c_strc_floats_facing_flushed
-% \global\c_strc_floats_facing_saved \zerocount
-% \global\c_strc_floats_facing_flushed\zerocount
-% \resetboxesincache{\currentfacingfloat}%
-% \fi}
-%
-% \aliased\let\flushfacingfloats\strc_floats_facing_flush
-
+\installcorenamespace {facingfloatflusher}
-% \let\page_check_weird_page\relax
-
-\def\page_check_weird_page_indeed % for now only when facing floats
- {\ifdim\vsize>\zeropoint\else
- %\showmessage\m!layouts9{}%
- \writestatus\m!layouts{forcing zero height page}%
- \emptyhbox\page
+\def\strc_floats_facing_flush_indeed_step#1#2#3%
+ {\ifnum#2<#3\relax
+ \advance#2\plusone
+ \donetrue
+ \writestatus
+ {facing}
+ {page: \the\scratchcounterone, location: #1, blob: \the#2, max: \the#3}%
+ \registertopcontent
+ [\scratchcounterone]
+ \hbox{\directboxfromcache{\currentfacingfloat:#1}{\the#2}}%
\fi}
-\permanent\protected\def\flushfacingfloats
- {\ifnum\c_strc_floats_facing_flushed<\c_strc_floats_facing_saved
- \strc_floats_facing_flush_indeed
- \fi}
-
-\permanent\protected\def\strc_floats_facing_flush_indeed
+\def\strc_floats_facing_flush_indeed#1%
{\begingroup
+ \edef\currentfacingfloat{#1}%
\glet\page_check_weird_page\page_check_weird_page_indeed % for now only when facing floats
- \dorecurse\c_strc_floats_facing_saved
- {\scratchdimen\getboxhtfromcache{\currentfacingfloat}{\recurselevel}\relax
- \advance\scratchdimen\lineheight % this will become configurable, maybe some criterium
- \normalexpanded{\adaptlayout[\the\numexpr\realpageno+\recurselevel\relax][\c!top=\the\scratchdimen]}}%
- \glet\page_otr_flush_top_content\page_otr_flush_top_content_waiting % not at current page
+ \scratchcounterone \realpageno
+ \scratchcounterthree\getboxcountfromcache{\currentfacingfloat:\v!left }\relax
+ \scratchcounterfour \getboxcountfromcache{\currentfacingfloat:\v!right}\relax
+ \scratchcounterfive \zerocount
+ \scratchcountersix \zerocount
+ % find first empty spread i.e. odd (left) and even (right) empty
+ \ifdim\pagetotal>\zeropoint
+ \advance\scratchcounterone\plusone
+ \fi
+ \ifodd\scratchcounterone
+ \advance\scratchcounterone\plusone
+ \fi
+ \writestatus
+ {facing}
+ {page: \the\scratchcounterone, start checking}%
+ \doloop{%
+ \page_adapts_layout_preroll\scratchcounterone
+ \ifzeropt\d_page_adapts_preroll
+ % left empty
+ \advance\scratchcounterone\plusone
+ \page_adapts_layout_preroll\scratchcounterone
+ \ifzeropt\d_page_adapts_preroll
+ % right empty
+ \advance\scratchcounterone\minusone
+ \exitloop
+ \fi
+ \else
+ \advance\scratchcounterone\plustwo
+ \fi
+ }
+ \writestatus
+ {facing}
+ {page: \the\scratchcounterone, start flushing}%
+ \doloop{%
+ \ifodd\scratchcounterone
+ \strc_floats_facing_flush_indeed_step\v!right\scratchcountersix \scratchcounterfour
+ \else
+ \strc_floats_facing_flush_indeed_step\v!left \scratchcounterfive\scratchcounterthree
+ \fi
+ \ifnum\scratchcountersix<\scratchcounterfour
+ % more
+ \orelse\ifnum\scratchcounterfive<\scratchcounterthree
+ % more
+ \else
+ \exitloop
+ \fi
+ \advance\scratchcounterone\plusone
+ }
+ \disposeboxesincache{\currentfacingfloat:\v!right}%
+ \disposeboxesincache{\currentfacingfloat:\v!left}%
+ \page_check_weird_page_indeed
\endgroup}
-\let\page_otr_flush_top_content\relax
-
-\def\page_otr_flush_top_content_waiting
- {\glet\page_otr_flush_top_content\page_otr_flush_top_content_inject} % but in next page
-
-\def\page_otr_flush_top_content_inject
- {\ifnum\c_strc_floats_facing_flushed<\c_strc_floats_facing_saved
- \global\advance\c_strc_floats_facing_flushed\plusone
- \directboxfromcache{\currentfacingfloat}{\number\c_strc_floats_facing_flushed}%
- \ifnum\c_strc_floats_facing_saved=\c_strc_floats_facing_flushed
- \global\c_strc_floats_facing_saved \zerocount
- \global\c_strc_floats_facing_flushed\zerocount
- \resetboxesincache{\currentfacingfloat}%
- \glet\page_otr_flush_top_content\relax % till we're done
- \fi
- \nointerlineskip
- \par
- \fi}
+\permanent\protected\tolerant\def\flushfacingfloats[#1]%
+ {\processcommalist[#1]\strc_floats_facing_flush_indeed}
\protected\def\strc_floats_facing_setup
{\edef\currentfacingfloat{\currentfacingfloat:\m_strc_floats_state}%
@@ -258,6 +335,7 @@
\doloop{%
\strc_floats_facing_flush_wrap\b_strc_floats_facing_l\v!left
\strc_floats_facing_flush_wrap\b_strc_floats_facing_r\v!right
+ \global\advance\c_strc_floats_facing_saved\plusone
\ifvoid\b_strc_floats_facing_l\relax\ifvoid\b_strc_floats_facing_r\relax
\exitloop
\fi\fi}}
@@ -286,8 +364,7 @@
\else
to \textheight{\box\scratchbox\vss}%
\fi
- \global\advance\c_strc_floats_facing_saved\plusone
- \putboxincache{\currentfacingfloat}{\number\c_strc_floats_facing_saved}\scratchbox
+ \putboxincache{\currentfacingfloat:#2}{+}\scratchbox
\endgroup
\fi}
diff --git a/tex/context/base/mkxl/page-lay.mkxl b/tex/context/base/mkxl/page-lay.mkxl
index b4bccd85b..a4f4666e2 100644
--- a/tex/context/base/mkxl/page-lay.mkxl
+++ b/tex/context/base/mkxl/page-lay.mkxl
@@ -984,6 +984,8 @@
%D \macros
%D {adaptlayout}
+% this will move to lua
+
\installcorenamespace{adaptlayout}
\installcorenamespace{pageadaptations}
diff --git a/tex/context/base/mkxl/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl
index 413f03d36..42c424e83 100644
--- a/tex/context/base/mkxl/spac-ver.mkxl
+++ b/tex/context/base/mkxl/spac-ver.mkxl
@@ -1263,7 +1263,7 @@
\pushoverloadmode
-\overloaded\permanent\protected\def\offinterlineskip
+\overloaded\permanent\protected\def\offinterlineskip % later we will overload this with a push pop
{\baselineskip-\thousandpoint
\lineskip \zeropoint
\lineskiplimit\maxdimen
diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl
index e5eaab435..94a273f80 100644
--- a/tex/context/base/mkxl/strc-mat.mkxl
+++ b/tex/context/base/mkxl/strc-mat.mkxl
@@ -846,12 +846,12 @@
\global\c_strc_math_vertical\zerocount
\fi
\ifcase\c_strc_math_vertical
- % \mathpenaltiesmode \zerocount
- \clf_setmathpenalties\zerocount
+ % \clf_setmathpenalties\zerocount
+ \mathpenaltiesmode \zerocount
\clf_resetmathhang
\else
- % \mathpenaltiesmode \plusone
- \clf_setmathpenalties\plusone
+ % \clf_setmathpenalties\plusone
+ \mathpenaltiesmode \plusone
\edef\p_hang{\formulaparameter\c!hang}%
\ifx\p_hang\v!none
\global\setfalse\c_strc_math_indent
diff --git a/tex/context/base/mkxl/supp-box.lmt b/tex/context/base/mkxl/supp-box.lmt
index a26cb3960..03bb54137 100644
--- a/tex/context/base/mkxl/supp-box.lmt
+++ b/tex/context/base/mkxl/supp-box.lmt
@@ -164,7 +164,7 @@ implement {
arguments = "integer",
actions = function(n)
-- we just hyphenate (as we pass a hpack) .. a bit too much casting but ...
- local l = languages.hyphenators.handler(tonode(checkedlist(n)))
+ local l = languages.hyphenators.handler(checkedlist(n))
report_hyphenation("show: %s",listtoutf(l,false,true))
end
}
@@ -496,6 +496,7 @@ do
local values = tokens.values
local dimension_value = values.dimension
+ local cardinal_value = values.cardinal
local boxes = { }
nodes.boxes = boxes
@@ -511,6 +512,9 @@ do
if trace then
report("category %a, name %a, %s (%s)",category,name,"save",b and "content" or "empty")
end
+ if name == "+" then
+ name = #cache[category] + 1
+ end
cache[category][name] = b or false
end
@@ -527,10 +531,19 @@ do
return cache[category][name] and true or false
end
+ function boxes.count(category)
+ return #cache[category]
+ end
+
function boxes.direct(category,name,copy)
name = tonumber(name) or name
local c = cache[category]
local b = c[name]
+-- if name == "+" then
+-- b = remove(c, 1)
+-- else
+-- b = c[name]
+-- end
if not b then
-- do nothing, maybe trace
elseif copy then
@@ -604,6 +617,11 @@ do
end
end
+ function boxes.dispose(category)
+ boxes.reset(category)
+ cache[category] = nil -- or false (for tracing)
+ end
+
implement {
name = "putboxincache",
public = true,
@@ -662,9 +680,28 @@ do
actions = boxes.reset,
}
+ implement {
+ name = "disposeboxesincache",
+ public = true,
+ protected = true,
+ arguments = "string",
+ actions = boxes.dispose,
+ }
+
-- we can share this ...
implement {
+ name = "getboxcountfromcache",
+ public = true,
+ protected = true,
+ usage = "value",
+ arguments = "string",
+ actions = function(category)
+ return cardinal_value, #cache[category]
+ end,
+ }
+
+ implement {
name = "getboxwdfromcache",
public = true,
protected = true,
diff --git a/tex/context/base/mkxl/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl
index 113cf7d2d..fc880852b 100644
--- a/tex/context/base/mkxl/supp-box.mkxl
+++ b/tex/context/base/mkxl/supp-box.mkxl
@@ -2874,6 +2874,17 @@
%D
%D setsplitlisthtdp\scratchbox\struthp\strutdp
+%D Handy but I'll probably forget it:
+%D
+%D \starttyping
+%D \setbox0\hbox{!!!!!}
+%D \permanent\protected\def\showboxhere{\showbox nolevels content online }
+%D \showbox 0
+%D \showboxhere 0 % always on console, less clutter
+%D \stoptyping
+
+\permanent\protected\def\showboxhere{\showbox nolevels content online }
+
\protect \endinput
% a bit of test code:
diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl
index f6f1d4044..c13e5eaef 100644
--- a/tex/context/base/mkxl/syst-ini.mkxl
+++ b/tex/context/base/mkxl/syst-ini.mkxl
@@ -156,7 +156,7 @@
function tex.enableprimitives() end % so we kind of protect what's there
}
-\permanent\let\undefined\undefined
+\untraced\permanent\let\undefined\undefined
\immutable\def\space{ }
\immutable\def\empty{}
@@ -1021,8 +1021,7 @@
\lineskip = 1pt
\lineskiplimit = 0pt
-%D Sometimes kerns make more sense than glue but we need to be in the
-%D right mode:
+%D Sometimes kerns make more sense than glue but we need to be in the right mode:
\permanent\protected\def\vkern {\ifhmode\par \fi\kern}
\permanent\protected\def\hkern {\ifvmode\dontleavehmode\fi\kern}
@@ -1030,8 +1029,8 @@
\permanent\protected\def\vpenalty{\ifhmode\par \fi\penalty}
\permanent\protected\def\hpenalty{\ifvmode\dontleavehmode\fi\penalty}
-%D Again a few kind-of-extensions the core. These come from plain \TEX\ but
-%D are probably not used in \CONTEXT.
+%D Again a few kind-of-extensions the core. These come from plain \TEX\ but are
+%D probably not used in \CONTEXT.
\newskip \hideskip \hideskip = -1000pt plus 1fill
\newskip \centering \centering = 0pt plus 1000pt minus 1000pt
@@ -1138,12 +1137,12 @@
\glyphoptions"80 % replaces \glyphdimensionsmode=1
-%D Just in case users use this:
+%D Just in case users use this (or some styles still have it):
-\aliased\let\immediateassign \immediate
-\aliased\let\immediateassigned\localcontrolled
+\aliased\let\immediateassignment\immediate
+\aliased\let\immediateassigned \localcontrolled
-%D Needed:
+%D Needed (maybe no longer the multiple next ones):
\mutable\let\nexttoken \relax
\mutable\let\next \relax
diff --git a/tex/context/base/mkxl/syst-lua.lmt b/tex/context/base/mkxl/syst-lua.lmt
index 44d2fd2e9..0eef7afd0 100644
--- a/tex/context/base/mkxl/syst-lua.lmt
+++ b/tex/context/base/mkxl/syst-lua.lmt
@@ -342,10 +342,10 @@ do
local l = 0
implement {
- name = "openin",
- public = true,
- usage = "value",
- actions = function()
+ name = "openin",
+ public = true,
+ usage = "value",
+ actions = function()
local n = scaninteger()
scankeyword("=")
local s = scanstring(true)
@@ -365,10 +365,10 @@ do
}
implement {
- name = "closein",
- public = true,
- usage = "value",
- actions = function()
+ name = "closein",
+ public = true,
+ usage = "value",
+ actions = function()
local n = scaninteger()
local c = channels[n]
if c then
@@ -388,10 +388,10 @@ do
end
interfaces.implement {
- name = "read",
- public = true,
- usage = "value",
- actions = function(prefix)
+ name = "read",
+ public = true,
+ usage = "value",
+ actions = function(prefix)
local n = scaninteger()
local c = channels[n]
if scankeyword("line") and c then
diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt
index 86b796b1e..1b640b8ad 100644
--- a/tex/context/base/mkxl/toks-aux.lmt
+++ b/tex/context/base/mkxl/toks-aux.lmt
@@ -5,9 +5,9 @@ if not modules then modules = { } end modules ['toks-aux'] = {
license = "see context related readme files"
}
-local type, tostring = type, tostring
+local type, tostring, next = type, tostring, next
local max = math.max
-local formatters, gsub, char = string.formatters, string.gsub, string.char
+local formatters, gsub, char, gmatch = string.formatters, string.gsub, string.char, string.gmatch
local concat = table.concat
-- todo : locals from scanners
@@ -130,54 +130,53 @@ interfaces.implement {
-- For the moment here, will move to initex only (also see node-ini.lua); we need
-- to actually store these.
-local groupcodes = { }
-local glyphoptioncodes = { }
-local discoptioncodes = { }
-local mathoptioncodes = { }
-local hyphenationcodes = { }
-local frozenparcodes = { }
-local flagcodes = { }
-local normalizecodes = { }
------ parcontextcodes = { }
------ parbegincodes = { }
-
-for k, v in next, tex.getgroupvalues() do groupcodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.gethyphenationvalues() do hyphenationcodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.getglyphoptionvalues() do glyphoptioncodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.getdiscoptionvalues() do discoptioncodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.getmathoptionvalues() do mathoptioncodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.getfrozenparvalues() do frozenparcodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.getflagvalues() do flagcodes[k] = gsub(v,"[_ ]","") end
-for k, v in next, tex.getnormalizevalues() do normalizecodes[k] = gsub(v,"[_ ]","") end
-
-if environment.initex then
-
- local texintegerdef = tex.integerdef
-
- for k, v in next, groupcodes do texintegerdef(v .. "groupcode", k,"immutable") end
- for k, v in next, glyphoptioncodes do texintegerdef(v .. "code", k,"immutable") end
- for k, v in next, discoptioncodes do texintegerdef(v .. "code", k,"immutable") end
- for k, v in next, hyphenationcodes do texintegerdef(v .. "hyphenationmodecode",k,"immutable") end
- for k, v in next, frozenparcodes do texintegerdef("frozen" .. v .. "code", k,"immutable") end
- for k, v in next, flagcodes do texintegerdef(v .. "flagcode", k,"immutable") end
- for k, v in next, normalizecodes do texintegerdef(v .. "code", k,"immutable") end
-
+local function getthem(getter,pre,post)
+ local codes = { }
+ if getter then
+ local texintegerdef = tex.integerdef
+ for k, v in next, getter() do
+ codes[k] = gsub(v,"[_ ]","")
+ end
+ if post ~= "" and environment.initex then
+ for k, v in next, codes do
+ texintegerdef(pre .. v .. post,k,"immutable")
+ end
+ end
+ end
+ return utilities.storage.allocate(table.swapped(codes,codes))
end
-groupcodes = utilities.storage.allocate(table.swapped(groupcodes, groupcodes))
-glyphoptioncodes = utilities.storage.allocate(table.swapped(glyphoptioncodes,glyphoptioncodes))
-discoptioncodes = utilities.storage.allocate(table.swapped(discoptioncodes, discoptioncodes))
-mathoptioncodes = utilities.storage.allocate(table.swapped(mathoptioncodes, mathoptioncodes))
-hyphenationcodes = utilities.storage.allocate(table.swapped(hyphenationcodes,hyphenationcodes))
-frozenparcodes = utilities.storage.allocate(table.swapped(frozenparcodes, frozenparcodes))
-flagcodes = utilities.storage.allocate(table.swapped(flagcodes, flagcodes))
-normalizecodes = utilities.storage.allocate(table.swapped(normalizecodes, normalizecodes))
+tex.groupcodes = getthem(tex.getgroupvalues, "", "groupcode")
+tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "", "code")
+tex.discoptioncodes = getthem(tex.getdiscoptionvalues, "", "code")
+tex.mathoptioncodes = getthem(tex.getmathoptionvalues, "", "")
+tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "", "mathcontrolcode")
+tex.mathflattencodes = getthem(tex.getmathflattenvalues, "", "flattencode")
+tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "", "hyphenationmodecode")
+tex.frozenparcodes = getthem(tex.getfrozenparvalues, "frozen", "code")
+tex.flagcodes = getthem(tex.getflagvalues, "", "flagcode" )
+tex.normalizecodes = getthem(tex.getnormalizevalues, "", "code")
-tex.groupcodes = groupcodes
-tex.glyphoptioncodes = glyphoptioncodes
-tex.discoptioncodes = discoptioncodes
-tex.mathoptioncodes = mathoptioncodes
-tex.hyphenationcodes = hyphenationcodes
-tex.frozenparcodes = frozenparcodes
-tex.flagcodes = flagcodes
-tex.normalizecodes = normalizecodes
+function tex.stringtocodesbitmap(str,codes)
+ local bitmap = 0
+ if codes then
+ if not str or str == "" then
+ -- zero
+ elseif str == "all" then
+ for k in next, codes do
+ if type(k) == "number" then
+ bitmap = bitmap | k
+ end
+ end
+ else
+ str = gsub(str,"[_ ]","")
+ for s in gmatch(str,"[^%,]+") do
+ local b = codes[s]
+ if b then
+ bitmap = bitmap | b
+ end
+ end
+ end
+ end
+ return bitmap
+end
diff --git a/tex/context/base/mkxl/trac-inf.lmt b/tex/context/base/mkxl/trac-inf.lmt
index a2366b611..feef3714f 100644
--- a/tex/context/base/mkxl/trac-inf.lmt
+++ b/tex/context/base/mkxl/trac-inf.lmt
@@ -265,8 +265,9 @@ status.iocodes = setmetatableindex(tex.getiovalues(), function() return "unknown
local report = logs.reporter("system")
local list = {
- "string", "pool", "hash", "lookup", "node", "token", "extra", "sparse", "buffer",
- "input", "file", "nest", "parameter", "save", "font", "language", "mark", "insert",
+ "string", "pool", "hash", "lookup", "node", "token",
+ "buffer", "input", "file", "nest", "parameter", "save", "font", "language", "mark", "insert",
+ -- "extra", "sparse",
}
local function show(data,fields)
diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt
index d278a40b0..fc136539e 100644
--- a/tex/context/base/mkxl/trac-vis.lmt
+++ b/tex/context/base/mkxl/trac-vis.lmt
@@ -630,12 +630,13 @@ local dir, par do
setattr(info,a_layer,l_dir)
d_cache[what] = info
end
+ head, current = insertnodeafter(head,current,copylist(info))
return head, current
end
dir = function(head,current)
local what = getsubtype(current)
- if what == cancelcode then
+ if what == cancel_code then
what = "cancel"
elseif getdirection(current) == r2l_code then
what = "r2l"
@@ -650,6 +651,7 @@ local dir, par do
setattr(info,a_layer,l_dir)
d_cache[what] = info
end
+ head, current = insertnodeafter(head,current,copylist(info))
return head, current
end
diff --git a/tex/context/base/mkxl/typo-brk.mkxl b/tex/context/base/mkxl/typo-brk.mkxl
index 47e5da886..0988e3a6b 100644
--- a/tex/context/base/mkxl/typo-brk.mkxl
+++ b/tex/context/base/mkxl/typo-brk.mkxl
@@ -53,11 +53,11 @@
\endgroup}
\permanent\protected\def\setbreakpoints[#1]%
- {\exhyphenchar\minusone % we use a different order than base tex, so we really need this
+ {%\exhyphenchar\minusone % we now use collapsing so ...
\clf_setbreakpoints{#1}}
\permanent\protected\def\resetbreakpoints
- {\exhyphenchar\hyphenasciicode % 2020.03.05
+ {%\exhyphenchar\hyphenasciicode % 2020.03.05 / we now use collapsing so ...
\c_attr_breakpoint\attributeunsetvalue}
\definebreakpoints[compound]
diff --git a/tex/context/base/mkxl/typo-duc.lmt b/tex/context/base/mkxl/typo-duc.lmt
index 87190a1ab..00f761c19 100644
--- a/tex/context/base/mkxl/typo-duc.lmt
+++ b/tex/context/base/mkxl/typo-duc.lmt
@@ -958,30 +958,46 @@ local function apply_to_list(list,size,head,pardir)
setdirection(current,pardir) -- is this really needed?
elseif id == glue_code then
-- Maybe I should also fix dua and dub but on the other hand ... why?
- if enddir and getsubtype(current) == parfillskip_code then
- -- insert the last enddir before \parfillskip glue
- local c = current
- local p = getprev(c)
- if p and getid(p) == glue_code and getsubtype(p) == parfillleftskip_code then
- c = p
- p = getprev(c)
- end
- if p and getid(p) == penalty_code then -- linepenalty
- c = p
- end
- -- there is always a par nodes so head will stay
- head = insertnodebefore(head,c,new_direction(enddir,true))
+-- if enddir and getsubtype(current) == parfillskip_code then
+-- -- insert the last enddir before \parfillskip glue
+-- local c = current
+-- local p = getprev(c)
+-- if p and getid(p) == glue_code and getsubtype(p) == parfillleftskip_code then
+-- c = p
+-- p = getprev(c)
+-- end
+-- while p and getid(p) == glue_code do
+-- c = p
+-- p = getprev(c)
+-- end
+-- if p and getid(p) == penalty_code then -- linepenalty
+-- c = p
+-- end
+-- -- there is always a par nodes so head will stay
+-- local d = new_direction(enddir,true)
+-- setattrlist(d,current)
+-- head = insertnodebefore(head,c,d)
+-- enddir = false
+-- end
+ if enddir then
+ local d = new_direction(enddir,true)
+ setattrlist(d,current)
+ head = insertnodebefore(head,current,d)
enddir = false
end
elseif begindir then
if id == par_code and startofpar(current) then
-- par should always be the 1st node
- head, current = insertnodeafter(head,current,new_direction(begindir))
+ local d = new_direction(begindir)
+ setattrlist(d,current)
+ head, current = insertnodeafter(head,current,d)
begindir = nil
end
end
if begindir then
- head = insertnodebefore(head,current,new_direction(begindir))
+ local d = new_direction(begindir)
+ setattrlist(d,current)
+ head = insertnodebefore(head,current,d)
end
local skip = entry.skip
if skip and skip > 0 then
@@ -996,7 +1012,9 @@ local function apply_to_list(list,size,head,pardir)
end
end
if enddir then
- head, current = insertnodeafter(head,current,new_direction(enddir,true))
+ local d = new_direction(enddir,true)
+ setattrlist(d,current)
+ head, current = insertnodeafter(head,current,d)
end
if not entry.remove then
current = getnext(current)
diff --git a/tex/context/base/mkxl/util-fil.lmt b/tex/context/base/mkxl/util-fil.lmt
index a3631d043..86200ebe5 100644
--- a/tex/context/base/mkxl/util-fil.lmt
+++ b/tex/context/base/mkxl/util-fil.lmt
@@ -116,6 +116,9 @@ files.readbytetable = fio.readbytetable
files.readcardinaltable = fio.readcardinaltable
files.readintegertable = fio.readintegertable
+files.readcstring = fio.readcstring
+files.readcline = fio.readcline
+
function files.readchar(f)
return f:read(1)
end
diff --git a/tex/context/base/mkxl/util-sac.lmt b/tex/context/base/mkxl/util-sac.lmt
index 60ecb0e33..e0a9f77de 100644
--- a/tex/context/base/mkxl/util-sac.lmt
+++ b/tex/context/base/mkxl/util-sac.lmt
@@ -126,10 +126,10 @@ end
function streams.skipshort(f,n) f[2] = f[2] + 2*(n or 1) end
function streams.skiplong (f,n) f[2] = f[2] + 4*(n or 1) end
-local readcardinal1 = sio.readcardinal1
-local readcardinal2 = sio.readcardinal2
-local readcardinal3 = sio.readcardinal3
-local readcardinal4 = sio.readcardinal4
+local readcardinal1 = sio.readcardinal1
+local readcardinal2 = sio.readcardinal2
+local readcardinal3 = sio.readcardinal3
+local readcardinal4 = sio.readcardinal4
function streams.readcardinal1(f) local i = f[2] f[2] = i + 1 return readcardinal1(f[1],i) end
function streams.readcardinal2(f) local i = f[2] f[2] = i + 2 return readcardinal2(f[1],i) end
@@ -146,34 +146,49 @@ function streams.readcardinal2le(f) local i = f[2] f[2] = i + 2 return readcardi
function streams.readcardinal3le(f) local i = f[2] f[2] = i + 3 return readcardinal3le(f[1],i) end
function streams.readcardinal4le(f) local i = f[2] f[2] = i + 4 return readcardinal4le(f[1],i) end
-local readinteger1 = sio.readinteger1
-local readinteger2 = sio.readinteger2
-local readinteger3 = sio.readinteger3
-local readinteger4 = sio.readinteger4
+local readinteger1 = sio.readinteger1
+local readinteger2 = sio.readinteger2
+local readinteger3 = sio.readinteger3
+local readinteger4 = sio.readinteger4
function streams.readinteger1(f) local i = f[2] f[2] = i + 1 return readinteger1(f[1],i) end
function streams.readinteger2(f) local i = f[2] f[2] = i + 2 return readinteger2(f[1],i) end
function streams.readinteger3(f) local i = f[2] f[2] = i + 3 return readinteger3(f[1],i) end
function streams.readinteger4(f) local i = f[2] f[2] = i + 4 return readinteger4(f[1],i) end
-local readinteger1le = sio.readinteger1le
-local readinteger2le = sio.readinteger2le
-local readinteger3le = sio.readinteger3le
-local readinteger4le = sio.readinteger4le
+local readinteger1le = sio.readinteger1le
+local readinteger2le = sio.readinteger2le
+local readinteger3le = sio.readinteger3le
+local readinteger4le = sio.readinteger4le
function streams.readinteger1le(f) local i = f[2] f[2] = i + 1 return readinteger1le(f[1],i) end
function streams.readinteger2le(f) local i = f[2] f[2] = i + 2 return readinteger2le(f[1],i) end
function streams.readinteger3le(f) local i = f[2] f[2] = i + 3 return readinteger3le(f[1],i) end
function streams.readinteger4le(f) local i = f[2] f[2] = i + 4 return readinteger4le(f[1],i) end
-local readfixed2 = sio.readfixed2
-local readfixed4 = sio.readfixed4
-local read2dot14 = sio.read2dot14
+local readfixed2 = sio.readfixed2
+local readfixed4 = sio.readfixed4
+local read2dot14 = sio.read2dot14
function streams.readfixed2(f) local i = f[2] f[2] = i + 2 return readfixed2(f[1],i) end
function streams.readfixed4(f) local i = f[2] f[2] = i + 4 return readfixed4(f[1],i) end
function streams.read2dot14(f) local i = f[2] f[2] = i + 2 return read2dot14(f[1],i) end
+local readcstring = sio.readcstring
+local readcline = sio.readcline
+
+function streams.readcstring(f)
+ local s, p = readcstring(f[1],f[2])
+ f[2] = p
+ return s
+end
+
+function streams.readcline(f,n)
+ local s, p = readcline(f[1],f[2])
+ f[2] = p
+ return s
+end
+
local readbytes = sio.readbytes
local readbytetable = sio.readbytetable
@@ -249,10 +264,10 @@ if files then
function io.newreader(str,method)
local f, m
if method == "string" then
- f = openstring(str)
+ f = openstring(str,true)
m = streams
elseif method == "stream" then
- f = openstream(str)
+ f = openstream(str,true)
m = streams
else
f = openfile(str,"rb")
@@ -283,3 +298,13 @@ if files then
end
end
+
+streams.tocardinal1 = sio.tocardinal1
+streams.tocardinal2 = sio.tocardinal2
+streams.tocardinal3 = sio.tocardinal3
+streams.tocardinal4 = sio.tocardinal4
+
+streams.tocardinal1le = sio.tocardinal1le
+streams.tocardinal2le = sio.tocardinal2le
+streams.tocardinal3le = sio.tocardinal3le
+streams.tocardinal4le = sio.tocardinal4le