summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/attr-ini.lmt5
-rw-r--r--tex/context/base/mkxl/buff-ini.lmt6
-rw-r--r--tex/context/base/mkxl/cldf-bas.lmt15
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl3
-rw-r--r--tex/context/base/mkxl/driv-shp.lmt28
-rw-r--r--tex/context/base/mkxl/font-pre.mkxl7
-rw-r--r--tex/context/base/mkxl/lpdf-ini.lmt84
-rw-r--r--tex/context/base/mkxl/lpdf-pde.lmt1
-rw-r--r--tex/context/base/mkxl/lpdf-ren.lmt9
-rw-r--r--tex/context/base/mkxl/node-bck.lmt88
-rw-r--r--tex/context/base/mkxl/node-met.lmt20
-rw-r--r--tex/context/base/mkxl/node-nut.lmt1
-rw-r--r--tex/context/base/mkxl/node-rul.lmt1
-rw-r--r--tex/context/base/mkxl/pack-com.mkxl20
-rw-r--r--tex/context/base/mkxl/spac-ver.lmt2
-rw-r--r--tex/context/base/mkxl/strc-lnt.mklx11
-rw-r--r--tex/context/base/mkxl/strc-mat.mkxl8
-rw-r--r--tex/context/base/mkxl/task-ini.lmt2
-rw-r--r--tex/context/base/mkxl/typo-drp.lmt9
-rw-r--r--tex/context/base/mkxl/typo-drp.mkxl27
-rw-r--r--tex/context/base/mkxl/typo-syn.lmt435
-rw-r--r--tex/context/base/mkxl/typo-syn.mkxl108
-rw-r--r--tex/context/base/mkxl/util-fil.lmt18
24 files changed, 747 insertions, 163 deletions
diff --git a/tex/context/base/mkxl/attr-ini.lmt b/tex/context/base/mkxl/attr-ini.lmt
index ca21365cb..2a4805a01 100644
--- a/tex/context/base/mkxl/attr-ini.lmt
+++ b/tex/context/base/mkxl/attr-ini.lmt
@@ -253,6 +253,11 @@ function attributes.hasvalues(index)
return list and next(list) and true or false
end
+function attributes.getvalues(index)
+ local list = values[index]
+ return list and next(list) and list or nil
+end
+
function attributes.setcleaner(index,cleaner)
cleaners[index] = cleaner
end
diff --git a/tex/context/base/mkxl/buff-ini.lmt b/tex/context/base/mkxl/buff-ini.lmt
index 2cde7c72b..a14056f7d 100644
--- a/tex/context/base/mkxl/buff-ini.lmt
+++ b/tex/context/base/mkxl/buff-ini.lmt
@@ -1017,7 +1017,8 @@ do
-- In the end we went for a somewhat hidden low level one (see low level math tests
-- for usage):
- local showbox = tex.showbox
+ local serialized = nodes.nuts.serialized
+ local getbox = nodes.nuts.getbox
implement {
name = "showboxinbuffer",
@@ -1025,7 +1026,8 @@ do
protected = true,
arguments = { "argument", "integer", "integer" },
actions = function(buffer, box, detail)
- assign(buffer or "",showbox(box, detail))
+ local box = getbox(box)
+ assign(buffer or "",box and serialized(box,detail))
end,
}
diff --git a/tex/context/base/mkxl/cldf-bas.lmt b/tex/context/base/mkxl/cldf-bas.lmt
index 6fc6e03a4..40b2b74a5 100644
--- a/tex/context/base/mkxl/cldf-bas.lmt
+++ b/tex/context/base/mkxl/cldf-bas.lmt
@@ -245,3 +245,18 @@ do
end
+-- for the moment here:
+
+do
+
+ local texset = tex.set
+ local maxdimen = tex.magicconstants.maxdimen
+
+ function tex.dontcomplain()
+ texset("hbadness",maxdimen)
+ texset("vbadness",maxdimen)
+ texset("hfuzz", maxdimen)
+ texset("vfuzz", maxdimen)
+ end
+
+end
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index 35e8bf03d..d9a326406 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.12.30 19:00}
+\newcontextversion{2022.01.06 19:47}
%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 385a2c13a..392895fe6 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.12.30 19:00}
+\immutable\edef\contextversion{2022.01.06 19:47}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
@@ -533,6 +533,7 @@
\loadmkxlfile{lang-hup}
\loadmkxlfile{typo-ovl} % fuzzy project (tracing) code
+\loadmkxlfile{typo-syn} % experiment
% old bibtex support: (will be m-oldbibtex.mkiv)
diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt
index 620c69484..2cb351880 100644
--- a/tex/context/base/mkxl/driv-shp.lmt
+++ b/tex/context/base/mkxl/driv-shp.lmt
@@ -1023,7 +1023,8 @@ local hlist_out, vlist_out do
-- pos_v = ref_v - (cur_v + basepoint_v)
pos_v = ref_v - basepoint_v
elseif hasoffset then
- local orientation, xoffset, yoffset = getorientation(current)
+-- local orientation, xoffset, yoffset = getorientation(current)
+ local xoffset, yoffset = getoffsets(current)
local basepoint_h = boxdir ~= pos_r and width or 0
local basepoint_v = shift
if target then
@@ -1398,7 +1399,8 @@ local hlist_out, vlist_out do
end
pos_v = ref_v - (cur_v + basepoint_v)
elseif hasoffset then
- local orientation, xoffset, yoffset = getorientation(current)
+-- local orientation, xoffset, yoffset = getorientation(current)
+ local xoffset, yoffset = getoffsets(current)
-- local basepoint_h = shift
-- local basepoint_v = height
if boxdir ~= pos_r then
@@ -1742,25 +1744,3 @@ do
end)
end
-
--- local function calculate_width_to_enddir(this_box,begindir) -- can be a helper
--- local dir_nest = 1
--- local enddir = begindir
--- for current, subtype in nextdir, getnext(begindir) do
--- if subtype == normaldir_code then -- todo
--- dir_nest = dir_nest + 1
--- else
--- dir_nest = dir_nest - 1
--- end
--- if dir_nest == 0 then -- does the type matter
--- enddir = current
--- local width = rangedimensions(this_box,begindir,enddir)
--- return enddir, width
--- end
--- end
--- if enddir == begindir then
--- local width = rangedimensions(this_box,begindir) -- ,enddir)
--- return enddir, width
--- end
--- return enddir, 0
--- end
diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl
index ffad757a9..c8dac54e6 100644
--- a/tex/context/base/mkxl/font-pre.mkxl
+++ b/tex/context/base/mkxl/font-pre.mkxl
@@ -193,13 +193,18 @@
[semitic-simple]
[script=hebr]
-% indic
+% indic:
+%
+% conjuncts : auto | continue | quit (default)
+% movematra : auto | leftbeforebase | default
\definefontfeature
[indic-common]
[mode=node,
language=dflt,
% localized
+ % indic=auto,
+ % localized
locl=yes,
% positioning
kern=yes,
diff --git a/tex/context/base/mkxl/lpdf-ini.lmt b/tex/context/base/mkxl/lpdf-ini.lmt
index 9357ebe75..d4b0ccc64 100644
--- a/tex/context/base/mkxl/lpdf-ini.lmt
+++ b/tex/context/base/mkxl/lpdf-ini.lmt
@@ -354,22 +354,54 @@ do
end
+local pdfescaped do
+
+ local replacer = S("\0\t\n\r\f ()[]{}/%%#\\") / {
+ ["\00"]="#00",
+ ["\09"]="#09",
+ ["\10"]="#0a",
+ ["\12"]="#0c",
+ ["\13"]="#0d",
+ [ " " ]="#20",
+ [ "#" ]="#23",
+ [ "%" ]="#25",
+ [ "(" ]="#28",
+ [ ")" ]="#29",
+ [ "/" ]="#2f",
+ [ "[" ]="#5b",
+ [ "\\"]="#5c",
+ [ "]" ]="#5d",
+ [ "{" ]="#7b",
+ [ "}" ]="#7d",
+ } + P(1)
+
+ local p_escaped_1 = Cs(Cc("/") * replacer^0)
+ local p_escaped_2 = Cs( replacer^0)
+
+ pdfescaped = function(str,slash)
+ return lpegmatch(slash and p_escaped_1 or p_escaped_2,str) or str
+ end
+
+ lpdf.escaped = pdfescaped
+
+end
+
local tostring_a, tostring_d
do
- local f_key_null = formatters["/%s null"]
- local f_key_value = formatters["/%s %s"]
- -- local f_key_dictionary = formatters["/%s << % t >>"]
+ local f_key_null = formatters["%s null"]
+ local f_key_value = formatters["%s %s"]
+ -- local f_key_dictionary = formatters["%s << % t >>"]
-- local f_dictionary = formatters["<< % t >>"]
- local f_key_dictionary = formatters["/%s << %s >>"]
+ local f_key_dictionary = formatters["%s << %s >>"]
local f_dictionary = formatters["<< %s >>"]
- -- local f_key_array = formatters["/%s [ % t ]"]
+ -- local f_key_array = formatters["%s [ % t ]"]
-- local f_array = formatters["[ % t ]"]
- local f_key_array = formatters["/%s [ %s ]"]
+ local f_key_array = formatters["%s [ %s ]"]
local f_array = formatters["[ %s ]"]
- local f_key_number = formatters["/%s %N"] -- always with max 9 digits and integer is possible
- local f_tonumber = formatters["%N"] -- always with max 9 digits and integer is possible
+ local f_key_number = formatters["%s %N"] -- always with max 9 digits and integer is possible
+ local f_tonumber = formatters["%N"] -- always with max 9 digits and integer is possible
tostring_d = function(t,contentonly,key)
if next(t) then
@@ -394,6 +426,9 @@ do
local v = t[k]
local tv = type(v)
-- mostly tables
+ --
+ k = pdfescaped(k,true)
+ --
if tv == "table" then
-- local mv = getmetatable(v)
-- if mv and mv.__lpdftype then
@@ -424,7 +459,7 @@ do
if contentonly then
return r
elseif key then
- return f_key_dictionary(key,r)
+ return f_key_dictionary(pdfescaped(key,true),r)
else
return f_dictionary(r)
end
@@ -474,7 +509,7 @@ do
if contentonly then
return r
elseif key then
- return f_key_array(key,r)
+ return f_key_array(pdfescaped(key,true),r)
else
return f_array(r)
end
@@ -651,29 +686,10 @@ do
for i=-1,9 do cache[i] = pdfnumber(i) end
- local replacer = S("\0\t\n\r\f ()[]{}/%%#\\") / {
- ["\00"]="#00",
- ["\09"]="#09",
- ["\10"]="#0a",
- ["\12"]="#0c",
- ["\13"]="#0d",
- [ " " ]="#20",
- [ "#" ]="#23",
- [ "%" ]="#25",
- [ "(" ]="#28",
- [ ")" ]="#29",
- [ "/" ]="#2f",
- [ "[" ]="#5b",
- [ "\\"]="#5c",
- [ "]" ]="#5d",
- [ "{" ]="#7b",
- [ "}" ]="#7d",
- } + P(1)
-
- local escaped = Cs(Cc("/") * replacer^0)
+ local escaped = lpdf.escaped
local cache = table.setmetatableindex(function(t,k)
- local v = setmetatable({ lpegmatch(escaped,k) }, mt_c)
+ local v = setmetatable({ escaped(k,true) }, mt_c)
t[k] = v
return v
end)
@@ -685,12 +701,6 @@ do
return cache[str]
end
- local escaped = Cs(replacer^0)
-
- function lpdf.escaped(str)
- return lpegmatch(escaped,str) or str
- end
-
end
local pdfnull, pdfboolean, pdfreference, pdfverbose
diff --git a/tex/context/base/mkxl/lpdf-pde.lmt b/tex/context/base/mkxl/lpdf-pde.lmt
index bb5830735..68712d58d 100644
--- a/tex/context/base/mkxl/lpdf-pde.lmt
+++ b/tex/context/base/mkxl/lpdf-pde.lmt
@@ -1090,6 +1090,7 @@ if images then do
copydictionary = function (xref,copied,object)
local target = pdfdictionary()
local source = object.__raw__
+ -- hm .. no need to sort here as we create a hash
-- for key, value in next, source do
for key, value in sortedhash(source) do
if plugins then
diff --git a/tex/context/base/mkxl/lpdf-ren.lmt b/tex/context/base/mkxl/lpdf-ren.lmt
index 0343ab76a..ea34505fa 100644
--- a/tex/context/base/mkxl/lpdf-ren.lmt
+++ b/tex/context/base/mkxl/lpdf-ren.lmt
@@ -94,7 +94,8 @@ local pagelayers, pagelayersreference, cache = nil, nil, { }
local alphabetic = { }
local escapednames = table.setmetatableindex(function(t,k)
- local v = escaped(k)
+-- local v = escaped(k)
+ local v = escaped(k,true)
t[k] = v
return v
end)
@@ -151,7 +152,8 @@ local function useviewerlayer(name) -- move up so that we can use it as local
else
hidelayers[#hidelayers+1] = nr
end
- pagelayers[escapednames[tag]] = dr -- check
+ -- pagelayers[escapednames[tag]] = dr -- check
+ pagelayers[tag] = dr -- check
else
-- todo: message
end
@@ -241,7 +243,8 @@ function executers.togglelayer(arguments) return setlayer(pdf_toggle,arguments)
-- injection
-local f_bdc = formatters["/OC /%s BDC"]
+-- local f_bdc = formatters["/OC /%s BDC"]
+local f_bdc = formatters["/OC %s BDC"]
local s_emc = "EMC"
function codeinjections.startlayer(name) -- used in mp
diff --git a/tex/context/base/mkxl/node-bck.lmt b/tex/context/base/mkxl/node-bck.lmt
index ad8f8d59e..5d4694600 100644
--- a/tex/context/base/mkxl/node-bck.lmt
+++ b/tex/context/base/mkxl/node-bck.lmt
@@ -60,6 +60,9 @@ local new_hlist = nodepool.hlist
local privateattributes = attributes.private
local unsetvalue = attributes.unsetvalue
+local getvalue = attributes.getvalue
+local hasvalues = attributes.hasvalues
+
local linefillers = nodes.linefillers
local a_background = privateattributes("background")
@@ -83,7 +86,7 @@ trackers.register("backgrounds.alignments",function(v) trace_alignment = v end)
local overshoot = math.floor(65781/5) -- could be an option per table (just also store it)
-local function colored_a(current,list,template,id,data)
+local function colored_a(current,list,template,id)
local width, height, depth = getwhd(current)
local total = height + depth
if width > 0 and total > 0 then
@@ -91,7 +94,7 @@ local function colored_a(current,list,template,id,data)
--
local a = getattr(template,a_linefiller)
if a then
- local d = data[a]
+ local d = getvalue(a_linefiller,a)
if d then
rule = linefillers.filler(template,d,width,height,depth)
end
@@ -106,7 +109,7 @@ local function colored_a(current,list,template,id,data)
end
end
-local function colored_b(current,list,template,id,indent,data)
+local function colored_b(current,list,template,id,indent)
local width, height, depth = getwhd(current)
local total = height + depth
if width > 0 and total > 0 then
@@ -115,7 +118,7 @@ local function colored_b(current,list,template,id,indent,data)
--
local a = getattr(template,a_linefiller)
if a then
- local d = data[a]
+ local d = getvalue(a_linefiller,a)
if d then
rule = linefillers.filler(template,d,width-indent,height,depth)
end
@@ -140,43 +143,47 @@ local currentrow = 0
local enabled = false
local alignments = false
-local function add_alignbackgrounds(head,list,data)
+-- todo: more control over cell attributes
+
+local function add_alignbackgrounds(head,list)
for current, id, subtype, list in nextlist, list do
if list and id == hlist_code and subtype == celllist_code then
for template in nexthlist, list do
local background = getattr(template,a_alignbackground)
if background then
- local list = colored_a(current,list,template,id,data)
+ local list = colored_a(current,list,template,id)
if list then
setlist(current,list)
end
- setattr(template,a_alignbackground,unsetvalue) -- or property
+ -- not that efficient:
+ setattr(template,a_alignbackground,unsetvalue)
end
break
end
end
end
+ -- we can store this differently now
local template = getprop(head,"alignmentchecked")
if template then
- list = colored_b(head,list,template[1],hlist_code,template[2],data)
+ list = colored_b(head,list,template[1],hlist_code,template[2])
flushnodelist(template)
templates[currentrow] = false
return list
end
end
-local function add_backgrounds(head,id,list,data)
+local function add_backgrounds(head,id,list)
if list then
for current, id, subtype, list in nextlist, list do
if list then
- if data and alignments and subtype == alignmentlist_code then
- local l = add_alignbackgrounds(current,list,data)
+ if alignments and subtype == alignmentlist_code then
+ local l = add_alignbackgrounds(current,list)
if l then
list = l
setlist(current,list)
end
end
- local l = add_backgrounds(current,id,list,data)
+ local l = add_backgrounds(current,id,list)
if l then
list = l
setlist(current,l)
@@ -187,36 +194,30 @@ local function add_backgrounds(head,id,list,data)
if id == hlist_code or id == vlist_code then
local background = getattr(head,a_background)
if background then
- list = colored_a(head,list,head,id,data)
+ list = colored_a(head,list,head,id)
-- not needed
- setattr(head,a_background,unsetvalue) -- or property -- todo
+ setattr(head,a_background,unsetvalue) -- or property
return list
end
end
end
function nodes.handlers.backgrounds(head)
- local data = attributes.values[a_linefiller]
--- if data then
- add_backgrounds(head,getid(head),getlist(head),data)
--- end
+ add_backgrounds(head,getid(head),getlist(head))
return head
end
function nodes.handlers.backgroundspage(head,where)
- local data = attributes.values[a_linefiller]
- if data then
- if head and where == "alignment" then
- for n in nexthlist, head do
- local p = getprop(n,"alignmentchecked")
- if not p and getsubtype(n) == alignmentlist_code then
- currentrow = currentrow + 1
- local template = templates[currentrow]
- if trace_alignment then
- report_alignment("%03i %s %s",currentrow,"page",template and "+" or "-")
- end
- setprop(n,"alignmentchecked",template)
+ if head and where == "alignment" then
+ for n in nexthlist, head do
+ local p = getprop(n,"alignmentchecked")
+ if not p and getsubtype(n) == alignmentlist_code then
+ currentrow = currentrow + 1
+ local template = templates[currentrow]
+ if trace_alignment then
+ report_alignment("%03i %s %s",currentrow,"page",template and "+" or "-")
end
+ setprop(n,"alignmentchecked",template)
end
end
end
@@ -224,21 +225,18 @@ function nodes.handlers.backgroundspage(head,where)
end
function nodes.handlers.backgroundsvbox(head,where)
- local data = attributes.values[a_linefiller]
- if data then
- if head and where == "vbox" then
- local list = getlist(head)
- if list then
- for n in nexthlist, list do
- local p = getprop(n,"alignmentchecked")
- if not p and getsubtype(n) == alignmentlist_code then
- currentrow = currentrow + 1
- local template = templates[currentrow]
- if trace_alignment then
- report_alignment("%03i %s %s",currentrow,"vbox",template and "+" or "-")
- end
- setprop(n,"alignmentchecked",template)
+ if head and where == "vbox" then
+ local list = getlist(head)
+ if list then
+ for n in nexthlist, list do
+ local p = getprop(n,"alignmentchecked")
+ if not p and getsubtype(n) == alignmentlist_code then
+ currentrow = currentrow + 1
+ local template = templates[currentrow]
+ if trace_alignment then
+ report_alignment("%03i %s %s",currentrow,"vbox",template and "+" or "-")
end
+ setprop(n,"alignmentchecked",template)
end
end
end
@@ -265,7 +263,7 @@ interfaces.implement {
}
interfaces.implement {
- name = "enablebackgroundalign",
+ name = "enablebackgroundalign", --- move into next one
onlyonce = true,
actions = function()
enable(true)
diff --git a/tex/context/base/mkxl/node-met.lmt b/tex/context/base/mkxl/node-met.lmt
index 83712b5e7..81d5b5561 100644
--- a/tex/context/base/mkxl/node-met.lmt
+++ b/tex/context/base/mkxl/node-met.lmt
@@ -103,15 +103,17 @@ nodes.getpropertiestable = node.get_properties_table
nodes.getproperty = node.getproperty
nodes.setproperty = node.setproperty
--- nodes.usedlist",
--- nodes.inuse",
--- nodes.instock",
--- nodes.type",
--- nodes.types",
--- nodes.subtypes",
--- nodes.values",
--- nodes.id",
--- nodes.show",
+-----.show = node.show
+nodes.serialized = node.serialized
+
+-- nodes.usedlist
+-- nodes.inuse
+-- nodes.instock
+-- nodes.type
+-- nodes.types
+-- nodes.subtypes
+-- nodes.values
+-- nodes.id
-- nodes.tonode = function(n) return n end
-- nodes.tonut = function(n) return n end
diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt
index fa98d26fe..957e937a0 100644
--- a/tex/context/base/mkxl/node-nut.lmt
+++ b/tex/context/base/mkxl/node-nut.lmt
@@ -244,6 +244,7 @@ local nuts = {
setwhd = direct.setwhd,
setwidth = direct.setwidth,
show = direct.show,
+ serialized = direct.serialized,
slide = d_slide,
startofpar = direct.startofpar,
tail = d_find_tail,
diff --git a/tex/context/base/mkxl/node-rul.lmt b/tex/context/base/mkxl/node-rul.lmt
index 3bf18ccf3..5155a9109 100644
--- a/tex/context/base/mkxl/node-rul.lmt
+++ b/tex/context/base/mkxl/node-rul.lmt
@@ -394,6 +394,7 @@ do
rules.handler = function(head)
local data = attributes.values[a_ruled]
+ --or-- local data = getvalues(a_ruled)
if data then
head = processwords(a_ruled,data,flush_ruled,head)
diff --git a/tex/context/base/mkxl/pack-com.mkxl b/tex/context/base/mkxl/pack-com.mkxl
index 1b932895e..ebae2fd4a 100644
--- a/tex/context/base/mkxl/pack-com.mkxl
+++ b/tex/context/base/mkxl/pack-com.mkxl
@@ -174,10 +174,10 @@
\settrue\c_strc_constructions_define_commands
\to \everydefinecombination
-\setvalue{\??combinationlocation\v!left }{\let\m_pack_combinations_leftfiller\relax}
-\setvalue{\??combinationlocation\v!right }{\let\m_pack_combinations_rightfiller\relax}
-\setvalue{\??combinationlocation\v!top }{\let\m_pack_combinations_valigner\depthonlybox}
-\setvalue{\??combinationlocation\v!middle}{\let\m_pack_combinations_valigner\halfwaybox}
+\defcsname\??combinationlocation\v!left \endcsname{\let\m_pack_combinations_leftfiller \relax}
+\defcsname\??combinationlocation\v!right \endcsname{\let\m_pack_combinations_rightfiller\relax}
+\defcsname\??combinationlocation\v!top \endcsname{\let\m_pack_combinations_valigner \depthonlybox}
+\defcsname\??combinationlocation\v!middle\endcsname{\let\m_pack_combinations_valigner \halfwaybox}
\def\pack_combinations_location_reset
{\let\m_pack_combinations_rightfiller\hfil
@@ -360,10 +360,10 @@
\dostarttagged\t!combinationcaption\empty
\expandnamespacemacro\??combinationalternative\p_pack_combinations_alternative\v!text}
-\setvalue{\??combinationalternative\v!text}%
+\defcsname\??combinationalternative\v!text\endcsname
{\expandafterpars\pack_combinations_alternative_text_indeed}
-\setvalue{\??combinationalternative\v!label}%
+\defcsname\??combinationalternative\v!label\endcsname
{\expandafterpars\pack_combinations_alternative_label_indeed}
\def\pack_combinations_alternative_text_indeed
@@ -714,10 +714,10 @@
\newdimen\s_pack_pairedboxes_size
\appendtoks
- \frozen\instance\setuevalue{\e!setup\currentpairedbox\e!endsetup}{\setuppairedbox [\currentpairedbox]}%
- \frozen\instance\setuevalue{\e!place\currentpairedbox }{\placepairedbox [\currentpairedbox]}% one argument is mandate anyway
- \frozen\instance\setuevalue{\e!start\e!place\currentpairedbox }{\startplacepairedbox[\currentpairedbox]}% one argument is mandate anyway
- \frozen\instance\setuevalue{\e!stop\e!place \currentpairedbox }{\stopplacepairedbox }%
+ \frozen\protected\instance\edefcsname\e!setup\currentpairedbox\e!endsetup\endcsname{\setuppairedbox [\currentpairedbox]}%
+ \frozen\protected\instance\edefcsname\e!place\currentpairedbox \endcsname{\placepairedbox [\currentpairedbox]}% one argument is mandate anyway
+ \frozen\protected\instance\edefcsname\e!start\e!place\currentpairedbox \endcsname{\startplacepairedbox[\currentpairedbox]}% one argument is mandate anyway
+ \frozen\protected\instance\edefcsname\e!stop\e!place \currentpairedbox \endcsname{\stopplacepairedbox }%
\to \everydefinepairedbox
\permanent\tolerant\protected\def\startplacepairedbox[#1]#*[#2]%
diff --git a/tex/context/base/mkxl/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt
index 9d58ff167..d41e3be18 100644
--- a/tex/context/base/mkxl/spac-ver.lmt
+++ b/tex/context/base/mkxl/spac-ver.lmt
@@ -1194,7 +1194,7 @@ do
end
local function trace_skip(str,sc,so,sp,data)
- trace_list[#trace_list+1] = { "skip", formatters["%s | %p | category %s | order %s | penalty %s"](str, getwidth(data), sc or "-", so or "-", sp or "-") }
+ trace_list[#trace_list+1] = { "skip", formatters["%s | %p | category %s | order %s | penalty %s | subtype %s"](str, getwidth(data), sc or "-", so or "-", sp or "-", gluecodes[getsubtype(data)]) }
tracing_info = true
end
diff --git a/tex/context/base/mkxl/strc-lnt.mklx b/tex/context/base/mkxl/strc-lnt.mklx
index f389442d8..d88227bc5 100644
--- a/tex/context/base/mkxl/strc-lnt.mklx
+++ b/tex/context/base/mkxl/strc-lnt.mklx
@@ -163,7 +163,7 @@
% compress=yes|no
% compressmethod=separator|stopper
-\setvalue{\??linenotescompressmethod\v!separator}%
+\defcsname\??linenotescompressmethod\v!separator\endcsname
{\edef\p_compressseparator{\noteparameter\c!compressseparator}%
\scratchskip\noteparameter\c!compressdistance\relax
\ifempty\p_compressseparator
@@ -174,7 +174,7 @@
\hskip.5\scratchskip
\fi}
-\setvalue{\??linenotescompressmethod\v!stopper}%
+\defcsname\??linenotescompressmethod\v!stopper\endcsname
{\edef\p_compressstopper{\noteparameter\c!compressstopper}%
\scratchskip\noteparameter\c!compressdistance\relax
\ifempty\p_compressstopper
@@ -184,7 +184,7 @@
\hskip.5\scratchskip
\fi}
-\setvalue{\??linenotescompressmethod\v!space}%
+\defcsname\??linenotescompressmethod\v!space\endcsname
{\hskip\noteparameter\c!compressdistance\relax}
\def\strc_linenotes_check_compression
@@ -200,7 +200,10 @@
\fi}
\def\strc_linenotes_inbetween % \ifcsname\??linenote\currentnote\expandafter\endcsname
- {\begincsname\??linenotescompressmethod\p_linenotes_compressmethod\endcsname}
+ {\begingroup
+ \strc_linenotes_check_compression
+ \begincsname\??linenotescompressmethod\p_linenotes_compressmethod\endcsname
+ \endgroup}
\def\strc_notes_compress_distance{\emwidth \s!plus .5\emwidth \s!minus .25\emwidth}
diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl
index 74ca24f7b..39c70fe87 100644
--- a/tex/context/base/mkxl/strc-mat.mkxl
+++ b/tex/context/base/mkxl/strc-mat.mkxl
@@ -627,7 +627,6 @@
\defcsname\??mathdisplayspacemodel\v!after:1\endcsname % old
{\prevdepth .5\strutdp
- \edef\p_spaceafter{\formulaparameter\c!spaceafter}%
\ifx\p_spaceafter\v!none
% nothing
\else
@@ -644,7 +643,6 @@
\defcsname\??mathdisplayspacemodel\v!after:2\endcsname % old
{\prevdepth\lineheight
- \edef\p_spaceafter{\formulaparameter\c!spaceafter}%
\ifx\p_spaceafter\v!none
% nothing
\else
@@ -675,7 +673,8 @@
\orelse\ifempty\p_spacebefore
\directvspacing\currentvspacing
\else
- \directvspacing{\p_spacebefore,\the\scratchdimen}%
+% \directvspacing{\p_spacebefore,\the\scratchdimen}%
+ \directvspacing\p_spacebefore
\fi
\else
\ifx\p_spacebefore\v!none
@@ -713,7 +712,8 @@
\orelse\ifempty\p_spacebefore
\directvspacing\currentvspacing
\else
- \directvspacing{\p_spacebefore,\the\scratchdimen}%
+% \directvspacing{\p_spacebefore,\the\scratchdimen}%
+ \directvspacing\p_spacebefore
\fi
\fi
\else
diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt
index 4af05b3cf..790b05442 100644
--- a/tex/context/base/mkxl/task-ini.lmt
+++ b/tex/context/base/mkxl/task-ini.lmt
@@ -141,6 +141,7 @@ appendaction("vboxbuilders", "normalizers", "nodes.handlers.backgroundsvbox",
appendaction("vboxbuilders", "normalizers", "builders.vspacing.vboxhandler", nil, "nut", "enabled" )
appendaction("vboxbuilders", "normalizers", "builders.profiling.vboxhandler", nil, "nut", "disabled" )
appendaction("vboxbuilders", "normalizers", "typesetters.checkers.handler", nil, "nut", "disabled" )
+appendaction("vboxbuilders", "normalizers", "typesetters.parallels.handler", nil, "nut", "disabled" )
appendaction("mvlbuilders", "normalizers", "nodes.handlers.backgroundspage", nil, "nut", "disabled" )
appendaction("mvlbuilders", "normalizers", "typesetters.margins.globalhandler", nil, "nut", "disabled" )
@@ -148,6 +149,7 @@ appendaction("mvlbuilders", "normalizers", "nodes.handlers.migrate",
appendaction("mvlbuilders", "normalizers", "builders.vspacing.pagehandler", nil, "nut", "enabled" )
appendaction("mvlbuilders", "normalizers", "builders.profiling.pagehandler", nil, "nut", "disabled" )
appendaction("mvlbuilders", "normalizers", "typesetters.checkers.handler", nil, "nut", "disabled" )
+appendaction("mvlbuilders", "normalizers", "typesetters.parallels.handler", nil, "nut", "disabled" )
appendaction("everypar", "normalizers", "nodes.handlers.checkparcounter", nil, "nut", "disabled" )
diff --git a/tex/context/base/mkxl/typo-drp.lmt b/tex/context/base/mkxl/typo-drp.lmt
index c62b5e718..1ea4f4715 100644
--- a/tex/context/base/mkxl/typo-drp.lmt
+++ b/tex/context/base/mkxl/typo-drp.lmt
@@ -18,7 +18,7 @@ local settings_to_hash = utilities.parsers.settings_to_hash
local trace_initials = false trackers.register("typesetters.initials", function(v) trace_initials = v end)
local report_initials = logs.reporter("nodes","initials")
-local initials = typesetters.paragraphs or { }
+local initials = typesetters.initials or { }
typesetters.initials = initials or { }
local nodes = nodes
@@ -44,7 +44,7 @@ local setlink = nuts.setlink
local setprev = nuts.setprev
local setnext = nuts.setnext
local setfont = nuts.setfont
-local setchar = nuts.setchar
+local setscale = nuts.setscale
local setwhd = nuts.setwhd
local setkern = nuts.setkern
local setoffsets = nuts.setoffsets
@@ -117,6 +117,7 @@ interfaces.implement {
{ "hoffset" ,"dimen" },
{ "voffset" ,"dimen" },
{ "font", "integer" },
+ { "glyphscale", "integer" },
{ "dynamic", "integer" },
{ "ca", "integer" },
{ "ma", "integer" },
@@ -157,6 +158,7 @@ actions[v_default] = function(head,setting)
local lines = tonumber(setting.n) or 0
local dynamic = setting.dynamic
local font = setting.font
+ local scale = setting.glyphscale
local method = settings_to_hash(setting.method)
local length = tonumber(setting.m) or 1
--
@@ -252,6 +254,9 @@ actions[v_default] = function(head,setting)
if font then
setfont(current,font)
end
+ if scale then
+ setscale(current,scale)
+ end
if dynamic > 0 then
setglyphdata(current,dynamic)
end
diff --git a/tex/context/base/mkxl/typo-drp.mkxl b/tex/context/base/mkxl/typo-drp.mkxl
index beed0f244..963edac18 100644
--- a/tex/context/base/mkxl/typo-drp.mkxl
+++ b/tex/context/base/mkxl/typo-drp.mkxl
@@ -113,19 +113,20 @@
\scratchcounter \initialparameter\c!n\relax
\scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax
\clf_setinitial
- location {\initialparameter\c!location}%
- enabled true\space
- n \scratchcounter
- m \numexpr\initialparameter\c!m\relax
- method {\initialparameter\c!method}%
- distance \dimexpr\initialparameter\c!distance\relax
- hoffset \dimexpr\initialparameter\c!hoffset\relax
- voffset \scratchvoffset
- ma \c_attr_colormodel
- ca \c_attr_color
- ta \c_attr_transparency
- font \fontid\font
- dynamic \font_dynamic_value % it's a bit over the top to support this here
+ location {\initialparameter\c!location}%
+ enabled true\space
+ n \scratchcounter
+ m \numexpr\initialparameter\c!m\relax
+ method {\initialparameter\c!method}%
+ distance \dimexpr\initialparameter\c!distance\relax
+ hoffset \dimexpr\initialparameter\c!hoffset\relax
+ voffset \scratchvoffset
+ ma \c_attr_colormodel
+ ca \c_attr_color
+ ta \c_attr_transparency
+ font \fontid\font
+ glyphscale \glyphscale
+ dynamic \font_dynamic_value % it's a bit over the top to support this here
\relax
\c_attr_initial\plusone
\initialparameter\c!text
diff --git a/tex/context/base/mkxl/typo-syn.lmt b/tex/context/base/mkxl/typo-syn.lmt
new file mode 100644
index 000000000..dbc5b27ff
--- /dev/null
+++ b/tex/context/base/mkxl/typo-syn.lmt
@@ -0,0 +1,435 @@
+if not modules then modules = { } end modules ['typo-syn'] = {
+ version = 1.000,
+ optimize = true,
+ comment = "companion to typo-syn.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local nodes = nodes
+
+local tasks = nodes.tasks
+local enableaction = tasks.enableaction
+----- disableaction = tasks.disableaction
+
+local nuts = nodes.nuts
+local tonut = nodes.tonut
+
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getsubtype = nuts.getsubtype
+local getattr = nuts.getattr
+local setattrlist = nuts.setattrlist
+local getattrlist = nuts.getattrlist
+
+local getprop = nuts.getprop
+local setprop = nuts.setprop
+
+local setlink = nuts.setlink
+local setprev = nuts.setprev
+local setnext = nuts.setnext
+local setoffsets = nuts.setoffsets
+
+local getwhd = nuts.getwhd
+
+local getwidth = nuts.getwidth
+local setwidth = nuts.setwidth
+local getdepth = nuts.getdepth
+local setdepth = nuts.setdepth
+local getheight = nuts.getheight
+local setheight = nuts.setheight
+local gettotal = nuts.gettotal
+local getlist = nuts.getlist
+local setlist = nuts.setlist
+local getdisc = nuts.getdisc
+local setdisc = nuts.setdisc
+
+local hpack = nuts.hpack
+local rangedimensions = nuts.rangedimensions
+local insertbefore = nuts.insertbefore
+local removenode = nuts.remove
+local flushnode = nuts.flush
+
+local traverselist = nuts.traverselist
+
+local nodecodes = nodes.nodecodes
+local glyph_code = nodecodes.glyph
+local rule_code = nodecodes.rule
+local disc_code = nodecodes.disc
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glue_code = nodecodes.glue
+local kern_code = nodecodes.kern
+local penalty_code = nodecodes.penalty
+
+local line_code = nodes.listcodes.line
+local fontkern_code = nodes.kerncodes.fontkern
+local parfillrightskip_code = nodes.gluecodes.parfillrightskip
+local baselineskip_code = nodes.gluecodes.baselineskip
+
+-----------------
+
+local a_synchronize = attributes.private("synchronize")
+
+local parallels = typesetters.parallels or { }
+typesetters.parallels = parallels or { }
+
+local registervalue = attributes.registervalue
+local getvalue = attributes.getvalue
+local hasvalues = attributes.hasvalues
+
+local trace = false
+-- local trace = true
+local report = logs.reporter("parallel")
+
+local pushsavelevel = tex.pushsavelevel -- token.expandmacro("bgroup")
+local popsavelevel = tex.popsavelevel -- token.expandmacro("egroup")
+local dontcomplain = tex.dontcomplain
+
+local slack = 6553.6
+local index = 0
+local lastattr = nil
+local lastline = nil
+
+interfaces.implement {
+ name = "registersynchronize",
+ arguments = { "dimen", "dimen", "box" },
+ actions = function(ht,dp,box)
+ index = index + 1
+ box = tonut(box)
+ local t = {
+ index = index,
+ lineheight = ht,
+ linedepth = dp,
+ height = getheight(height),
+ depth = getheight(depth),
+ box = box,
+ }
+ local v = registervalue(a_synchronize,t)
+ tex.setattribute(a_synchronize,v)
+ if index > 0 then
+ enableaction("vboxbuilders", "typesetters.parallels.handler")
+ enableaction("mvlbuilders", "typesetters.parallels.handler")
+ end
+ end,
+
+}
+
+local function hsplit(box,width)
+ local first = getlist(box)
+ local last = first
+ local current = first
+ local previous = current
+ local sofar = 0
+ local lastdisc = nil
+ -- todo: option
+ width = width - slack
+ --
+ while true do
+ previous = current
+ local id = getid(current)
+ if id == glyph_code then
+ local wd = getwidth(current)
+ if sofar + wd > width then
+ break
+ else
+ sofar = sofar + wd
+ end
+ elseif id == kern_code then
+ if getsubtype(current) == fontkern_code then
+ -- assume sane kerns
+ local wd = getwidth(current)
+ sofar = sofar + wd
+ else
+ last = previous
+ local wd = getwidth(current)
+ if sofar + wd > width then
+ break
+ else
+ sofar = sofar + wd
+ end
+ lastdisc = nil
+ end
+ elseif id == disc_code then
+ -- move on / inject post if needed
+ local pre, post, replace = getdisc(current)
+ local wdr = replace and rangedimensions(box,replace) or 0
+ if sofar + wdr > width then
+ -- handle post and pre here
+ last = previous
+ break
+ end
+ local wdp = pre and rangedimensions(box,pre) or 0
+-- if sofar + wdp > width then
+-- last = previous
+--lastdisc = current
+-- break
+-- end
+ sofar = sofar + wdr
+ lastdisc = current
+ elseif id == glue_code then
+ last = previous
+ local wd = getwidth(current)
+ if sofar + wd > width then
+ break
+ else
+ sofar = sofar + wd
+ end
+ lastdisc = nil
+ elseif id == hlist_code or id == vlist_code then
+ last = previous
+ local wd = getwidth(current)
+ if sofar + wd > width then
+ break
+ else
+ sofar = sofar + wd
+ end
+ lastdisc = nil
+ elseif id == rule_code then
+ last = previous
+ local wd = getwidth(current)
+ if sofar + wd > width then
+ break
+ else
+ sofar = sofar + wd
+ end
+ lastdisc = nil
+ else
+ lastdisc = nil
+ end
+ local next = getnext(current)
+ if next then
+ current = next
+ else
+ last = previous
+ break
+ end
+ end
+ local next
+ if lastdisc then
+ local pre, post, replace = getdisc(lastdisc)
+ last = getprev(lastdisc)
+ --
+ next = getnext(lastdisc)
+ if next then
+ setprev(next)
+ end
+ --
+ setlink(last,pre)
+ if post then
+ setlink(post,next)
+ next = post
+ end
+ setdisc(lastdisc,nil,nil,replace)
+ flushnode(lastdisc)
+ else
+ next = getnext(last)
+ if next then
+ setprev(next)
+ end
+ setnext(last)
+ end
+ while last do
+ local id = getid(last)
+ if id == glue_code or id == penalty_code then
+ first, last = removenode(first,last,true)
+ else
+ break
+ end
+ end
+ if first then
+ pushsavelevel()
+ dontcomplain()
+ local result, badness = hpack(first,width,"exactly")
+ if badness > 200 then
+ result = hpack(first)
+ end
+ popsavelevel()
+ setattrlist(result,getattrlist(box)) -- useattrlist(result,box)
+ setheight(result,getheight(box))
+ setdepth(result,getdepth(box))
+ setlist(box,next)
+ setwidth(box,rangedimensions(box,next))
+ return result
+ end
+end
+
+local function getproperties(parent)
+ local props = getprop(parent,"parallel")
+ if not props then
+ local w, h, d = getwhd(parent)
+ props = {
+ width = w,
+ height = h,
+ depth = d,
+ }
+ setprop(parent,"parallel",props)
+ end
+ return props
+end
+
+local function setproperties(parent,data,result,level,ctotal)
+ local props = getproperties(parent)
+ local depth = props.depth
+ local height = props.height
+ local delta = data.linedepth - depth
+ if delta > 0 then
+ depth = data.linedepth
+ setdepth(parent,depth)
+ props.depth = depth
+ local n = getnext(parent)
+ if n and getid(n) == glue_code and getsubtype(n) == baselineskip_code then
+ setwidth(n,getwidth(n) - delta)
+ end
+ end
+-- if height < data.lineheight then
+-- height = data.lineheight
+-- setheight(parent,height)
+-- props.height = height
+-- end
+ local offset = level * ctotal
+ if props.depth + offset > depth then
+ setdepth(parent,props.depth+offset)
+ end
+ setoffsets(result,0,-offset)
+ setwidth(result,0)
+end
+
+local function flush(head,first,last,a,parent,nesting)
+ if first and nesting == 0 then
+ local data = getvalue(a_synchronize,a)
+ local upto = getnext(last)
+ if upto and getid(upto) == penalty_code then
+ upto = getnext(upto)
+ end
+ if upto and getid(upto) == glue_code and getsubtype(upto) == parfillrightskip_code then
+ upto = getnext(upto)
+ end
+ local props = getproperties(parent)
+ local width = rangedimensions(parent,first,upto)
+ if width > props.width then
+ width = props.width
+ end
+ local content = data.box
+ local index = data.index
+ if not content then
+ if trace then
+ report("index %i, verdict %a",index,"done")
+ end
+ else
+ local result = nil
+ local cwidth = getwidth(content)
+ local ctotal = gettotal(content)
+ if cwidth <= width then -- slack
+ if trace then
+ report("index %i, available %p, content %p, verdict %a",index,width,cwidth,"fit")
+ end
+ result = content
+ data.box = nil
+ elseif cwidth > width then
+ if trace then
+ report("index %i, available %p, content %p, verdict %a",index,width,cwidth,"overflow")
+ end
+ result = hsplit(content,width)
+ lastattr = a
+ lastline = parent
+ else
+ report("index %i, verdict %a",index,"weird")
+ end
+ if result then
+ setproperties(parent,data,result,1,ctotal)
+ head = insertbefore(head,first,result)
+ end
+ end
+ end
+ return head
+end
+
+local function lastflush(lastline,lastattr)
+ local data = getvalue(a_synchronize,lastattr)
+ if not data then
+ return
+ end
+ local content = data.box
+ if not content or getwidth(content) == 0 then
+ return
+ end
+ local head = getlist(lastline)
+ if not head then
+ return
+ end
+ local first = head
+ local last = nil
+ local props = getproperties(lastline)
+ local width = props.width
+ local height = props.height
+ local depth = props.depth
+ local level = 1
+ if depth < data.linedepth then
+ depth = data.linedepth
+ setdepth(lastline,depth)
+ end
+ if height < data.lineheight then
+ height = data.lineheight
+ setheight(lastline,height)
+ end
+ while true do
+ local content = data.box
+ local index = data.index
+ if content then
+ local result = nil
+ local total = 0
+ local cwidth = getwidth(content)
+ local ctotal = gettotal(content)
+ if cwidth <= width then -- slack
+ if trace then
+ report("index %i, available %p, content %p, verdict %a",index,width,cwidth,"fit")
+ end
+ result = content
+ data.box = nil
+ elseif cwidth > width then
+ if trace then
+ report("index %i, available %p, content %p, verdict %a",index,width,cwidth,"overflow")
+ end
+ result = hsplit(content,width)
+ else
+ report("index %i, verdict %a",index,"weird")
+ end
+ if result then
+ level = level + 1
+ setproperties(lastline,data,result,level,ctotal)
+ head = insertbefore(head,first,result)
+ setlist(lastline,head)
+ else
+ break
+ end
+ else
+ break
+ end
+ end
+end
+
+local processranges = nuts.processranges
+
+function parallels.handler(head,where)
+ if where == "hmodepar" and hasvalues(a_synchronize) then
+ lastattr = nil
+ lastline = nil
+ for n, id, subtype in traverselist(head) do
+ if subtype == line_code then
+ lastattr = nil
+ local list = getlist(n)
+ local head = processranges(a_synchronize,flush,list,n)
+ if head ~= list then
+ setlist(n,head)
+ end
+ end
+ end
+ if lastattr and lastline then
+ lastflush(lastline,lastattr)
+ end
+ end
+ return head
+end
diff --git a/tex/context/base/mkxl/typo-syn.mkxl b/tex/context/base/mkxl/typo-syn.mkxl
new file mode 100644
index 000000000..adb3603d5
--- /dev/null
+++ b/tex/context/base/mkxl/typo-syn.mkxl
@@ -0,0 +1,108 @@
+%D \module
+%D [ file=typo-syn,
+%D version=2022.01.06,
+%D title=\CONTEXT\ Typesetting Macros,
+%D subtitle=synchronizers,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% Musical timestamp: this code was written when I start relistening my whole
+% digitized cd collection with the (new) r2r soekris dac in my setup.
+
+
+%D Yet another experiment (triggered by a question / demand from Ton Otten.)
+%D
+%D \starttyping
+%D \setupsynchronize [paralleltext] [color=darkblue]
+%D % \setupsynchronize [paralleltext] [style=\tx,color=darkred]
+%D % \setupsynchronize [paralleltext] [style=\txx,color=darkgreen]
+%D
+%D \dorecurse{10}{%
+%D \paralleltext
+%D {[een allereerste zinnetje]}
+%D {[een tweede zinnetje]}%
+%D \space
+%D \paralleltext
+%D {[een derde zin]}
+%D {[een vierde zinnetje]}
+%D \space
+%D } \removeunwantedspaces
+%D \par test line \page
+%D
+%D \paralleltext
+%D {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}
+%D {[\samplefile{ward}\removeunwantedspaces]}%
+%D \par test line \page
+%D
+%D \paralleltext
+%D {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}
+%D {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}%
+%D \par test line \page
+%D
+%D \paralleltext
+%D {[\ignorespaces\samplefile{ward}\removeunwantedspaces]}%
+%D {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}
+%D \par test line \page
+%D \stoptyping
+
+\writestatus{loading}{ConTeXt Typesetting Macros / Synchronizers}
+
+\registerctxluafile{typo-syn}{autosuffix}
+
+\unprotect
+
+\definesystemattribute[synchronize][public]
+
+\installcorenamespace {synchronize}
+
+\installcommandhandler \??synchronize {synchronize} \??synchronize
+
+\tolerant\protected\def\typo_synchronize#1#*[#2]#:#3#4%
+ {\dontleavehmode
+ \begingroup
+ \def\currentsynchronize{#1}%
+ \setupcurrentsynchronize[#2]%
+ \dontcomplain
+ \setbox\scratchboxtwo\hbox\bgroup
+ \usesynchronizestyleandcolor\c!style\c!color
+ \setstrut
+ \strut
+ \ignorespaces#4\removeunwantedspaces
+ \egroup
+ \scratchdimentwo\wd\scratchboxtwo
+ \clf_registersynchronize
+ \strutht
+ \strutdp
+ \box\scratchboxtwo
+ \relax
+ \setbox\scratchboxone\hbox{#3}%
+ \scratchdimenone\wd\scratchboxone
+ \unhbox\scratchboxone
+ \advance\scratchdimentwo-\scratchdimenone
+ \ifdim\scratchdimentwo>\zeropoint
+ \wordboundary
+ \novrule
+ % \vrule
+ \s!width \scratchdimentwo
+ \s!height \exheight
+ \s!depth \zeropoint
+ \relax
+ \fi
+ \endgroup}
+
+\appendtoks
+ \protected\instance\edefcsname\currentsynchronize\endcsname{\typo_synchronize{\currentsynchronize}}%
+\to \everydefinesynchronize
+
+% \setupsynchronize
+% [\c!alternative=\v!horizontal]
+
+\definesynchronize
+ [paralleltext]
+
+\protect \endinput
diff --git a/tex/context/base/mkxl/util-fil.lmt b/tex/context/base/mkxl/util-fil.lmt
index 86200ebe5..b8d374755 100644
--- a/tex/context/base/mkxl/util-fil.lmt
+++ b/tex/context/base/mkxl/util-fil.lmt
@@ -27,15 +27,21 @@ function files.open(filename,zb)
end
function files.close(f)
- zerobased[f] = nil
- f:close()
+ if f then
+ zerobased[f] = nil
+ f:close()
+ end
end
function files.size(f)
- local current = f:seek()
- local size = f:seek("end")
- f:seek("set",current)
- return size
+ if f then
+ local current = f:seek()
+ local size = f:seek("end")
+ f:seek("set",current)
+ return size
+ else
+ return 0
+ end
end
files.getsize = files.size