summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/anch-bck.mkvi12
-rw-r--r--tex/context/base/anch-pgr.lua244
-rw-r--r--tex/context/base/anch-pgr.mkiv5
-rw-r--r--tex/context/base/char-def.lua4
-rw-r--r--tex/context/base/cldf-ini.lua6
-rw-r--r--tex/context/base/colo-ini.mkiv16
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv12
-rw-r--r--tex/context/base/cont-nop.mkiv22
-rw-r--r--tex/context/base/cont-yes.mkiv72
-rw-r--r--tex/context/base/context-version.pdfbin4128 -> 4142 bytes
-rw-r--r--tex/context/base/context-version.pngbin105721 -> 105447 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv6
-rw-r--r--tex/context/base/core-ctx.ctx23
-rw-r--r--tex/context/base/core-ctx.lua308
-rw-r--r--tex/context/base/core-ctx.mkiv17
-rw-r--r--tex/context/base/core-def.mkiv31
-rw-r--r--tex/context/base/file-job.lua204
-rw-r--r--tex/context/base/file-job.mkvi17
-rw-r--r--tex/context/base/font-pre.mkiv3
-rw-r--r--tex/context/base/l-io.lua47
-rw-r--r--tex/context/base/l-lpeg.lua14
-rw-r--r--tex/context/base/l-md5.lua33
-rw-r--r--tex/context/base/luat-cod.lua2
-rw-r--r--tex/context/base/luat-env.lua8
-rw-r--r--tex/context/base/luat-ini.lua41
-rw-r--r--tex/context/base/lxml-ini.mkiv2
-rw-r--r--tex/context/base/math-def.mkiv4
-rw-r--r--tex/context/base/math-noa.lua13
-rw-r--r--tex/context/base/mult-aux.mkiv25
-rw-r--r--tex/context/base/mult-low.lua1
-rw-r--r--tex/context/base/page-mak.mkvi5
-rw-r--r--tex/context/base/status-files.pdfbin24413 -> 24381 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin180149 -> 181077 bytes
-rw-r--r--tex/context/base/status-mkiv.lua10
-rw-r--r--tex/context/base/strc-lst.lua2
-rw-r--r--tex/context/base/tabl-xnt.mkvi2
-rw-r--r--tex/context/base/tabl-xtb.lua3
-rw-r--r--tex/context/base/trac-deb.mkiv4
-rw-r--r--tex/context/base/trac-set.lua34
-rw-r--r--tex/context/base/typo-mar.mkiv4
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua63
43 files changed, 1026 insertions, 297 deletions
diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi
index 8ec056468..8f22d8a6d 100644
--- a/tex/context/base/anch-bck.mkvi
+++ b/tex/context/base/anch-bck.mkvi
@@ -276,7 +276,7 @@
\kern\textbackgroundskip\nobreak
\fi \fi
\nobreak
- \vskip-\dimexpr\lineheight+\parskip\relax
+ \vskip-\dimexpr\lineheight+\parskip\relax % problem: we loose the hangindent
\nobreak
\endgroup
\begingroup
@@ -307,7 +307,7 @@
\setuptextbackground
[\c!mp=mpos:region:draw,
- \c!method=mpos:region,
+ \c!method=mpos:region, % mpos:regionshape
\c!state=\v!start,
\c!location=\v!text,
\c!leftoffset=\!!zeropoint, % 1em,
@@ -397,6 +397,14 @@
\includeMPgraphic{mpos:region:anchor} ;
\stopMPpositiongraphic
+\startMPpositiongraphic{mpos:regionshape}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset}
+ \includeMPgraphic{mpos:region:setup} ;
+ \includeMPgraphic{mpos:region:extra} ;
+ \MPgetmultishapes{\MPvar{self}}{\MPanchorid} ;
+ \includeMPgraphic{\MPvar{mp}} ;
+ \includeMPgraphic{mpos:region:anchor} ;
+\stopMPpositiongraphic
+
\startMPpositionmethod{mpos:region}
\MPpositiongraphic{mpos:region}{}%
\stopMPpositionmethod
diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua
index bf4dcbe02..6143d166e 100644
--- a/tex/context/base/anch-pgr.lua
+++ b/tex/context/base/anch-pgr.lua
@@ -51,30 +51,44 @@ local function add(t,x,y,last)
local n = #t
if n == 0 then
t[n+1] = { x, y }
- elseif n == 1 then
- local tn = t[1]
- if abs(tn[1]-x) <= eps or abs(tn[2]-y) <= eps then
- t[n+1] = { x, y }
- end
else
- local tm = t[n-1]
local tn = t[n]
local lx = tn[1]
local ly = tn[2]
- if abs(lx-tm[1]) <= eps and abs(lx-x) <= eps then
- if abs(ly-y) > eps then
- tn[2] = y
+ if x == lx and y == ly then
+ -- quick skip
+ elseif n == 1 then
+-- if abs(lx-x) <= eps or abs(ly-y) <= eps then
+ if abs(lx-x) > eps or abs(ly-y) > eps then
+ t[n+1] = { x, y }
end
- elseif abs(ly-tm[2]) <= eps and abs(ly-y) <= eps then
- if abs(lx-x) > eps then
- tn[1] = x
+ else
+ local tm = t[n-1]
+ local px = tm[1]
+ local py = tm[2]
+if y > ly then
+ -- move back from too much hang
+else
+ if abs(lx-px) <= eps and abs(lx-x) <= eps then
+ if abs(ly-y) > eps then
+ tn[2] = y
+ end
+ elseif abs(ly-py) <= eps and abs(ly-y) <= eps then
+ if abs(lx-x) > eps then
+ tn[1] = x
+ end
+ elseif not last then
+ t[n+1] = { x, y }
end
- elseif not last then
- t[n+1] = { x, y }
+end
end
end
end
+-- local function add(t,x,y,last)
+-- t[#t+1] = { x, y }
+-- end
+
local function finish(t)
local n = #t
if n > 1 then
@@ -109,105 +123,103 @@ end
-- todo: mark regions and free paragraphs in collected
-local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot)
+local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang)
-- we assume that we only hang per page and not cross pages
-- which makes sense as hanging is only uses in special cases
--
-- we can remove data as soon as a page is done so we could
-- remember per page and discard areas after each shipout
local leftshape, rightshape
--- leftshape = r.leftshape
--- rightshape = r.rightshape
--- if not leftshape then
- leftshape = { { rx, rh } }
- rightshape = { { rw, rh } }
- local paragraphs = r.paragraphs
- local extending = false
- if paragraphs then
- for i=1,#paragraphs do
- local p = paragraphs[i]
- local ha = p.ha
- if ha and ha ~= 0 then
+ leftshape = { { rx, rh } } -- spikes get removed so we can start at the edge
+ rightshape = { { rw, rh } } -- even if we hang next
+ local paragraphs = r.paragraphs
+ local extending = false
+ if paragraphs then
+ for i=1,#paragraphs do
+ local p = paragraphs[i]
+ local ha = p.ha
+ if obeyhang and ha and ha ~= 0 then
+ local py = p.y
+ local ph = p.h
+ local pd = p.d
+ local hi = p.hi
+ local hang = ha * (ph + pd)
+ local py_ph = py + ph
+ -- ha < 0 hi < 0 : right top
+ -- ha < 0 hi > 0 : left top
+ if ha < 0 then
+ if hi < 0 then -- right
+ add(rightshape,rw , py_ph)
+ add(rightshape,rw + hi, py_ph)
+ add(rightshape,rw + hi, py_ph + hang)
+ add(rightshape,rw , py_ph + hang)
+ else
+ -- left
+ add(leftshape,rx, py_ph)
+ add(leftshape,rx + hi, py_ph)
+ add(leftshape,rx + hi, py_ph + hang)
+ add(leftshape,rx, py_ph + hang)
+ end
+ else
+ -- maybe some day
+ end
+ extending = true -- false
+ else -- we need to clip to the next par
+ local ps = p.ps
+ if ps then
local py = p.y
local ph = p.h
local pd = p.d
- local hi = p.hi
- local hang = ha * (ph + pd)
+ local step = ph + pd
+ local size = #ps * step
local py_ph = py + ph
- -- ha < 0 hi < 0 : right top
- -- ha < 0 hi > 0 : left top
- if ha < 0 then
- if hi < 0 then -- right
- add(rightshape,rw , py_ph)
- add(rightshape,rw + hi, py_ph)
- add(rightshape,rw + hi, py_ph + hang)
- add(rightshape,rw , py_ph + hang)
- else
- -- left
- add(leftshape,rx, py_ph)
- add(leftshape,rx + hi, py_ph)
- add(leftshape,rx + hi, py_ph + hang)
- add(leftshape,rx, py_ph + hang)
- end
- end
-extending = false
- else -- we need to clip to the next par
- local ps = p.ps
- if ps then
- local py = p.y
- local ph = p.h
- local pd = p.d
- local step = ph + pd
- local size = #ps * step
- local py_ph = py + ph
- add(leftshape,rx,py_ph)
- add(rightshape,rw,py_ph)
- for i=1,#ps do
- local p = ps[i]
- local l = p[1]
- local w = p[2]
- add(leftshape,rx + l, py_ph)
- add(rightshape,rx + l + w, py_ph)
- py_ph = py_ph - step
- add(leftshape,rx + l, py_ph)
- add(rightshape,rx + l + w, py_ph)
- end
- extending = true
--- add(left,rx,py_ph)
--- add(right,rw,py_ph)
- else
- if extending then
- local py = p.y
- local ph = p.h
- local pd = p.d
- local py_ph = py + ph
- local py_pd = py - pd
- add(leftshape,leftshape[#leftshape][1],py_ph)
- add(rightshape,rightshape[#rightshape][1],py_ph)
- add(leftshape,rx,py_ph)
- add(rightshape,rw,py_ph)
-extending = false
- end
+ add(leftshape,rx,py_ph)
+ add(rightshape,rw,py_ph)
+ for i=1,#ps do
+ local p = ps[i]
+ local l = p[1]
+ local w = p[2]
+ add(leftshape,rx + l, py_ph)
+ add(rightshape,rx + l + w, py_ph)
+ py_ph = py_ph - step
+ add(leftshape,rx + l, py_ph)
+ add(rightshape,rx + l + w, py_ph)
end
+ extending = true
+ elseif extending then
+ local py = p.y
+ local ph = p.h
+ local pd = p.d
+ local py_ph = py + ph
+ local py_pd = py - pd
+ add(leftshape,leftshape[#leftshape][1],py_ph)
+ add(rightshape,rightshape[#rightshape][1],py_ph)
+ add(leftshape,rx,py_ph) -- shouldn't this be py_pd
+ add(rightshape,rw,py_ph) -- shouldn't this be py_pd
+ extending = false
end
end
end
- -- we can have a simple variant when no paragraphs
- if extending then
- -- not ok
- leftshape[#leftshape][2] = rd
- rightshape[#rightshape][2] = rw
- else
- add(leftshape,rx,rd)
- add(rightshape,rw,rd)
- end
--- r.leftshape = leftshape
--- r.rightshape = rightshape
--- end
+ end
+ -- we can have a simple variant when no paragraphs
+ if extending then
+ -- not ok
+ leftshape[#leftshape][2] = rd
+ rightshape[#rightshape][2] = rw
+ else
+ add(leftshape,rx,rd)
+ add(rightshape,rw,rd)
+ end
return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot)
end
-local function singlepart(b,e,r,left,right)
+-- local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang)
+-- local leftshape = { { rx, rh }, { rx, rd } }
+-- local rightshape = { { rw, rh }, { rw, rd } }
+-- return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot)
+-- end
+
+local function singlepart(b,e,r,left,right,obeyhang)
local bx, by = b.x, b.y
local ex, ey = e.x, e.y
local rx, ry = r.x, r.y
@@ -238,7 +250,7 @@ local function singlepart(b,e,r,left,right)
}
else
area = { }
- local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh)
+ local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh,obeyhang)
add(area,bx,bh-ry)
for i=1,#rightshapes do
local ri = rightshapes[i]
@@ -265,7 +277,7 @@ local function singlepart(b,e,r,left,right)
}
end
-local function firstpart(b,r,left,right)
+local function firstpart(b,r,left,right,obeyhang)
local bx, by = b.x, b.y
local rx, ry = r.x, r.y
local rw = rx + r.w
@@ -278,7 +290,7 @@ local function firstpart(b,r,left,right)
local bh = by + b.h
local bd = by - b.d
local area = { }
- local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd)
+ local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd,obeyhang)
add(area,bx,bh-ry)
for i=1,#rightshapes do
local ri = rightshapes[i]
@@ -302,7 +314,7 @@ local function firstpart(b,r,left,right)
}
end
-local function middlepart(r,left,right)
+local function middlepart(r,left,right,obeyhang)
local rx, ry = r.x, r.y
local rw = rx + r.w
local rh = ry + r.h
@@ -312,7 +324,7 @@ local function middlepart(r,left,right)
rw = rw - right
end
local area = { }
- local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,rd,rh,rd)
+ local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,rd,rh,rd,obeyhang)
for i=#leftshapes,1,-1 do
local li = leftshapes[i]
add(area,li[1],li[2]-ry)
@@ -333,7 +345,7 @@ local function middlepart(r,left,right)
}
end
-local function lastpart(e,r,left,right)
+local function lastpart(e,r,left,right,obeyhang)
local ex, ey = e.x, e.y
local rx, ry = r.x, r.y
local rw = rx + r.w
@@ -347,7 +359,7 @@ local function lastpart(e,r,left,right)
local ed = ey - e.d
local area = { }
-- two cases: till end and halfway e line
- local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh)
+ local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh,obeyhang)
for i=1,#rightshapes do
local ri = rightshapes[i]
add(area,ri[1],ri[2]-ry)
@@ -375,7 +387,7 @@ local backgrounds = { }
graphics.backgrounds = backgrounds
-local function calculatemultipar(tag)
+local function calculatemultipar(tag,obeyhang)
local collected = jobpositions.collected
local b = collected[format("b:%s",tag)]
local e = collected[format("e:%s",tag)]
@@ -429,13 +441,13 @@ local function calculatemultipar(tag)
--
if bindex == eindex then
return {
- list = { [b.p] = { singlepart(b,e,collected[br],left,right) } },
+ list = { [b.p] = { singlepart(b,e,collected[br],left,right,obeyhang) } },
bpos = b,
epos = e,
}
else
local list = {
- [b.p] = { firstpart(b,collected[br],left,right) },
+ [b.p] = { firstpart(b,collected[br],left,right,obeyhang) },
}
for i=bindex+1,eindex-1 do
br = format("%s:%s",btag,i)
@@ -446,18 +458,18 @@ local function calculatemultipar(tag)
local p = r.p
local pp = list[p]
if pp then
- pp[#pp+1] = middlepart(r,left,right)
+ pp[#pp+1] = middlepart(r,left,right,obeyhang)
else
- list[p] = { middlepart(r,left,right) }
+ list[p] = { middlepart(r,left,right,obeyhang) }
end
end
end
local p = e.p
local pp = list[p]
if pp then
- pp[#pp+1] = lastpart(e,collected[er],left,right)
+ pp[#pp+1] = lastpart(e,collected[er],left,right,obeyhang)
else
- list[p] = { lastpart(e,collected[er],left,right) }
+ list[p] = { lastpart(e,collected[er],left,right,obeyhang) }
end
return {
list = list,
@@ -537,10 +549,10 @@ local template_d = [[
setbounds currentpicture to multibox ;
]]
-function backgrounds.fetchmultipar(n,anchor,page)
+function backgrounds.fetchmultipar(n,anchor,page,obeyhang)
local data = pbg[n]
if not data then
- data = calculatemultipar(n)
+ data = calculatemultipar(n,obeyhang)
pbg[n] = data -- can be replaced by register
-- register(data.list,n,anchor)
end
@@ -590,6 +602,10 @@ function commands.fetchmultipar(n,anchor,page)
context(backgrounds.fetchmultipar(n,anchor,page))
end
+function commands.fetchmultishape(n,anchor,page)
+ context(backgrounds.fetchmultipar(n,anchor,page,true))
+end
+
local template_a = [[
path posboxes[], posregions[] ;
numeric pospages[] ;
@@ -642,10 +658,10 @@ end
local doifelse = commands.doifelse
-function commands.doifelsemultipar(n,page)
+function commands.doifelsemultipar(n,page,obeyhang)
local data = pbg[n]
if not data then
- data = calculatemultipar(n)
+ data = calculatemultipar(n,obeyhang)
pbg[n] = data
end
if page then
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index a417d26e3..38e0ff0af 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -492,7 +492,8 @@
% Helpers:
-\def\MPgetposboxes #1#2{\ctxcommand{fetchposboxes("#1","#2",\the\realpageno)}}
-\def\MPgetmultipars#1#2{\ctxcommand{fetchmultipar("#1","#2",\the\realpageno)}}
+\def\MPgetposboxes #1#2{\ctxcommand{fetchposboxes("#1","#2",\the\realpageno)}}
+\def\MPgetmultipars #1#2{\ctxcommand{fetchmultipar("#1","#2",\the\realpageno)}}
+\def\MPgetmultishapes#1#2{\ctxcommand{fetchmultishape("#1","#2",\the\realpageno)}}
\protect \endinput
diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua
index 1e3b8a595..804468c2d 100644
--- a/tex/context/base/char-def.lua
+++ b/tex/context/base/char-def.lua
@@ -64501,6 +64501,8 @@ characters.data={
description="TOP SQUARE BRACKET",
direction="on",
linebreak="al",
+ mathclass="topaccent",
+ mathname="overbracket",
unicodeslot=0x23B4,
},
[0x23B5]={
@@ -64508,6 +64510,8 @@ characters.data={
description="BOTTOM SQUARE BRACKET",
direction="on",
linebreak="al",
+ mathclass="botaccent",
+ mathname="underbracket",
unicodeslot=0x23B5,
},
[0x23B6]={
diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua
index ed86c2923..c35ca4b4a 100644
--- a/tex/context/base/cldf-ini.lua
+++ b/tex/context/base/cldf-ini.lua
@@ -410,7 +410,11 @@ local function writer(parent,command,first,...) -- already optimized before call
done = true
end
end
- flush(currentcatcodes,"]")
+ if done then
+ flush(currentcatcodes,"]")
+ else
+ flush(currentcatcodes,"[]")
+ end
elseif tn == 1 then -- some 20% faster than the next loop
local tj = ti[1]
if type(tj) == "function" then
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv
index 5721bb513..a46555534 100644
--- a/tex/context/base/colo-ini.mkiv
+++ b/tex/context/base/colo-ini.mkiv
@@ -242,8 +242,8 @@
\setfalse\c_colo_convert_gray
\getvalue{\??colorconversions\directcolorsparameter\c!conversion}% could be a nice \ifcsname
% too often:
- \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors9\v!rgb \fi
- \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors9\v!cmyk\fi
+ \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi
+ \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi
\colo_helpers_set_current_model
\ifproductionrun
\edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}%
@@ -802,9 +802,19 @@
\def\defaulttextcolor {black}
\def\s!themaintextcolor{themaintextcolor}
+\unexpanded\def\inheritmaintextcolor
+ {\ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi}
+
+\unexpanded\def\onlyinheritmaintextcolor
+ {\ifx\maintextcolor\empty
+ \deactivatecolor
+ \else
+ \colo_helpers_activate\maintextcolor
+ \fi}
+
\appendtoks
\deactivatecolor % public?
- \ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi
+ \inheritmaintextcolor
\to \everybeforeoutput
\def\colo_helpers_switch_to_maintextcolor#1%
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index b4958762f..2f49f0bd4 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.05.30 11:26}
+\newcontextversion{2012.06.05 09:16}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 5a28f8e29..2c7ae9942 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.05.30 11:26}
+\newcontextversion{2012.06.05 09:16}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
@@ -48,7 +48,7 @@
% \let\cs\getvalue % no, we want \cs to be czech
-% experimental so this may change
+% experimental so this may change ! ! ! not adapted to new low level description names
\def\startdescriptions
{\dosingleempty\dostartdescriptions}
@@ -231,7 +231,7 @@
\egroup
-\def\inlinedbox
+\unexpanded\def\inlinedbox
{\bgroup
\dowithnextbox
{\scratchdimen\nextboxht
@@ -256,7 +256,7 @@
#2\expandafter\expandafter\expandafter\doxprecurse\expandafter
\fi\expandafter{\the\numexpr#1-1\relax}{#2}}
-\def\buttonframed{\dodoubleempty\localframed[\??bt]} % goodie
+\unexpanded\def\buttonframed{\dodoubleempty\localframed[\??bt]} % goodie
\unexpanded\def\asciistr#1{\dontleavehmode{\defconvertedargument\ascii{#1}\verbatimfont\ascii}}
@@ -345,13 +345,13 @@
% \tableifelse{\doifelse{a}{a}}{\NC Xtest \NC test \NC \NR}{}%
% \stoptabulate}
-\long\def\tableifelse#1%
+\def\tableifelse#1%
{\tablenoalign
{#1%
{\aftergroup \firstoftwoarguments}%
{\aftergroup\secondoftwoarguments}}}
-\long \def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}}
+\def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}}
\def\tightvbox{\dowithnextbox{\nextboxdp\zeropoint\flushnextbox}\vbox}
\def\tightvtop{\dowithnextbox{\nextboxht\zeropoint\flushnextbox}\vtop}
diff --git a/tex/context/base/cont-nop.mkiv b/tex/context/base/cont-nop.mkiv
new file mode 100644
index 000000000..c8188503e
--- /dev/null
+++ b/tex/context/base/cont-nop.mkiv
@@ -0,0 +1,22 @@
+%D \module
+%D [ file=cont-nop,
+%D version=2012.06.01,
+%D title=\CONTEXT\ Miscellaneous Macros,
+%D subtitle=Startup Dummy,
+%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.
+
+\unprotect
+
+\writestatus\m!system{loading dummy replacement for jobname}
+
+\protect
+
+\finishjob
+
+\endinput
diff --git a/tex/context/base/cont-yes.mkiv b/tex/context/base/cont-yes.mkiv
new file mode 100644
index 000000000..51be3a569
--- /dev/null
+++ b/tex/context/base/cont-yes.mkiv
@@ -0,0 +1,72 @@
+%D \module
+%D [ file=cont-yes,
+%D version=2012.06.01,
+%D title=\CONTEXT\ Miscellaneous Macros,
+%D subtitle=Startup Stub,
+%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.
+
+% At some point I will reconsider the \starttext .. \stoptext
+% wraping as we can assume proper styling. It's a left-over from
+% mkii that we need to get rid of.
+
+\startluacode
+
+ -- When a style is loaded there is a good change that we never enter
+ -- this code.
+
+ local arguments = environment.arguments
+ local filename = arguments.input or tex.jobname
+ local suffix = file.suffix(filename)
+
+ if suffix == "xml" or arguments.forcexml then
+
+ -- Maybe we should move the preamble parsing here as it
+ -- can be part of (any) loaded (sub) file. The \starttext
+ -- wrapping might go away.
+
+ context.starttext()
+ context.xmlprocess("main",filename,"")
+ context.stoptext()
+
+ elseif suffix == "cld" or arguments.forcecld then
+
+ context.runfile(filename)
+
+ elseif suffix == "lua" or arguments.forcelua then
+
+ -- The wrapping might go away. Why is is it there in the
+ -- first place.
+
+ context.starttext()
+ context.ctxlua(string.format('dofile("%s")',filename))
+ context.stoptext()
+
+ -- elseif suffix == "prep" then
+ --
+ -- -- Why do we wrap here. Because it can be xml? Let's get rid
+ -- -- of prepping in general.
+ --
+ -- context.starttext()
+ -- context.input(filename)
+ -- context.stoptext()
+
+ else
+
+ -- We have a regular tex file so no \starttext yet as we can
+ -- load fonts.
+
+ context.input(filename)
+
+ end
+
+ context.finishjob()
+
+\stopluacode
+
+\endinput
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 7b8733c88..edf4268a2 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index bb280817c..eb6d3d9ea 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 8cd02fd9e..3686f12d0 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.05.30 11:26}
+\edef\contextversion{2012.06.05 09:16}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 5044edae1..896baecbf 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -23,7 +23,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.05.30 11:26}
+\edef\contextversion{2012.06.05 09:16}
%D For those who want to use this:
@@ -454,7 +454,7 @@
\loadmarkfile{cldf-ver} % verbatim, this can come late
\loadmarkfile{cldf-com} % commands, this can come late
-\loadmarkfile{core-ctx}
+\loadmarkfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace
\loadmarkfile{core-ini}
\loadmarkfile{core-def}
@@ -465,7 +465,7 @@
% now we hook in backend code (needs checking)
-\loadmarkfile{back-pdf} % actually, this one should load the next three
+\loadmarkfile{back-pdf} % actually, this one should load the next three using document.arguments.backend
\loadmarkfile{mlib-pdf}
\loadmarkfile{mlib-pps}
\loadmarkfile{meta-pdf}
diff --git a/tex/context/base/core-ctx.ctx b/tex/context/base/core-ctx.ctx
new file mode 100644
index 000000000..5126ad2d2
--- /dev/null
+++ b/tex/context/base/core-ctx.ctx
@@ -0,0 +1,23 @@
+<?xml version='1.0' standalone='yes'?>
+
+<ctx:job>
+ <ctx:message>demo file</ctx:message>
+ <ctx:preprocess suffix='prep'>
+ <ctx:processors>
+ <ctx:processor name='step-1' suffix='one' >dummy-prep-command-1 <ctx:value name='old'/> <ctx:value name='new'/></ctx:processor>
+ <ctx:processor name='step-2' suffix='prep'>dummy-prep-command-2 <ctx:value name='old'/> <ctx:value name='new'/></ctx:processor>
+ </ctx:processors>
+ <ctx:files>
+ <ctx:file processor='step-1' >one*.xml</ctx:file>
+ <ctx:file processor='step-2' >two*.xml</ctx:file>
+ <ctx:file processor='step-1,step-2'>all*.xml</ctx:file>
+ </ctx:files>
+ </ctx:preprocess>
+ <ctx:process>
+ <ctx:resources>
+ <ctx:environment>step-1-step-2.tex</ctx:environment>
+ </ctx:resources>
+ </ctx:process>
+ <ctx:postprocess>
+ </ctx:postprocess>
+</ctx:job>
diff --git a/tex/context/base/core-ctx.lua b/tex/context/base/core-ctx.lua
index e6fb7bb5f..616f82a58 100644
--- a/tex/context/base/core-ctx.lua
+++ b/tex/context/base/core-ctx.lua
@@ -6,72 +6,271 @@ if not modules then modules = { } end modules ['core-ctx'] = {
license = "see context related readme files"
}
+--[[
+Job control files aka ctx files are rather old and date from the mkii times.
+They were handled in texexec and mtx-context and deals with modes, modules,
+environments and preprocessing in projects where one such file drives the
+processing of lots of files without the need to provide command line
+arguments.
+
+In mkiv this concept was of course supported as well. The first implementation
+of mtx-context took much of the approach of texexec, but by now we have gotten
+rid of the option file (for passing modes, modules and environments), the stubs
+(for directly processing cld and xml) as well as the preprocessing component
+of the ctx files. Special helper features, like typesetting listings, were
+already moved to the extras (a direct side effect of the ability to pass along
+command line arguments.) All this made mtx-context more simple than its ancestor
+texexec.
+
+Because some of the modes might affect the mtx-context end, the ctx file is
+still loaded there but only for getting the modes. The file is loaded again
+during the run but as loading and basic processing takes less than a
+millisecond it's not that much of a burden.
+--]]
+
+-- the ctxrunner tabel might either become private or move to the job namespace
+-- which also affects the loading order
+
local trace_prepfiles = false trackers.register("system.prepfiles", function(v) trace_prepfiles = v end)
+local gsub, find = string.gsub, string.find
+
local report_prepfiles = logs.reporter("system","prepfiles")
commands = commands or { }
local commands = commands
-local list, suffix, islocal, found = { }, "prep", false, false
-
-function commands.loadctxpreplist()
- local ctlname = file.replacesuffix(tex.jobname,"ctl")
- if lfs.isfile(ctlname) then
- local x = xml.load(ctlname)
- if x then
- islocal = xml.found(x,"ctx:preplist[@local=='yes']")
---~ if trace_prepfiles then
- if islocal then
- report_prepfiles("loading ctx log file (local)") -- todo: m!system
- else
- report_prepfiles("loading ctx log file (specified)") -- todo: m!system
+ctxrunner = ctxrunner or { }
+
+ctxrunner.prepfiles = utilities.storage.allocate()
+
+local function dontpreparefile(t,k)
+ return k -- we only store when we have a prepper
+end
+
+table.setmetatableindex(ctxrunner.prepfiles,dontpreparefile)
+
+local function filtered(str,method) -- in resolvers?
+ str = tostring(str)
+ if method == 'name' then str = file.removesuffix(file.basename(str))
+ elseif method == 'path' then str = file.dirname(str)
+ elseif method == 'suffix' then str = file.extname(str)
+ elseif method == 'nosuffix' then str = file.removesuffix(str)
+ elseif method == 'nopath' then str = file.basename(str)
+ elseif method == 'base' then str = file.basename(str)
+-- elseif method == 'full' then
+-- elseif method == 'complete' then
+-- elseif method == 'expand' then -- str = file.expandpath(str)
+ end
+ return (gsub(str,"\\","/"))
+end
+
+-- local function substitute(e,str)
+-- local attributes = e.at
+-- if str and attributes then
+-- if attributes['method'] then
+-- str = filtered(str,attributes['method'])
+-- end
+-- if str == "" and attributes['default'] then
+-- str = attributes['default']
+-- end
+-- end
+-- return str
+-- end
+
+local function substitute(str)
+ return str
+end
+
+local function justtext(str)
+ str = xml.unescaped(tostring(str))
+ str = xml.cleansed(str)
+ str = gsub(str,"\\+",'/')
+ str = gsub(str,"%s+",' ')
+ return str
+end
+
+function ctxrunner.load(ctxname)
+
+ local xmldata = xml.load(ctxname)
+
+ local jobname = tex.jobname -- todo
+
+ local variables = { job = jobname }
+ local commands = { }
+ local flags = { }
+ local paths = { } -- todo
+ local treatments = { }
+ local suffix = "prep"
+
+ xml.include(xmldata,'ctx:include','name', {'.', file.dirname(ctxname), "..", "../.." })
+
+ for e in xml.collected(xmldata,"/ctx:job/ctx:flags/ctx:flag") do
+ local key, value = match(flag,"^(.-)=(.+)$")
+ if key and value then
+ environment.setargument(key,value)
+ else
+ environment.setargument(flag,true)
+ end
+ end
+
+ -- add to document.options.ctxfile[...]
+
+ local ctxfile = document.options.ctxfile
+
+ local modes = ctxfile.modes
+ local modules = ctxfile.modules
+ local environments = ctxfile.environments
+
+ for e in xml.collected(xmldata,"/ctx:job/ctx:process/ctx:resources/ctx:mode") do
+ modes[#modes+1] = xml.text(e)
+ -- context.enablemode { xml.text(e) }
+ end
+
+ for e in xml.collected(xmldata,"/ctx:job/ctx:process/ctx:resources/ctx:module") do
+ modules[#modules+1] = xml.text(e)
+ -- context.module { xml.text(e) }
+ end
+
+ for e in xml.collected(xmldata,"/ctx:job/ctx:process/ctx:resources/ctx:environment") do
+ environments[#environments+1] = xml.text(e)
+ -- context.environment { xml.text(e) }
+ end
+
+ for e in xml.collected(xmldata,"ctx:message") do
+ report_prepfiles("ctx comment: %s", xml.text(e))
+ end
+
+ for r, d, k in xml.elements(xmldata,"ctx:value[@name='job']") do
+ d[k] = variables['job'] or ""
+ end
+
+ for e in xml.collected(xmldata,"/ctx:job/ctx:preprocess/ctx:processors/ctx:processor") do
+ commands[e.at and e.at['name'] or "unknown"] = e
+ end
+
+ local suffix = xml.filter(xmldata,"xml:///ctx:job/ctx:preprocess/attribute('suffix')") -- or ...
+ local runlocal = xml.filter(xmldata,"xml:///ctx:job/ctx:preprocess/ctx:processors/attribute('local')")
+
+ runlocal = toboolean(runlocal)
+
+ -- todo: only collect, then plug into file handler
+
+ for files in xml.collected(xmldata,"/ctx:job/ctx:preprocess/ctx:files") do
+ for pattern in xml.collected(files,"ctx:file") do
+ local preprocessor = pattern.at['processor'] or ""
+ if preprocessor ~= "" then
+ treatments[#treatments+1] = {
+ pattern = string.topattern(justtext(xml.tostring(pattern))),
+ preprocessors = utilities.parsers.settings_to_array(preprocessor),
+ }
+ end
+ end
+ end
+
+ variables.old = jobname
+
+ local function needstreatment(oldfile)
+ for i=1,#treatments do
+ local treatment = treatments[i]
+ local pattern = treatment.pattern
+ if find(oldfile,pattern) then
+ return treatment
+ end
+ end
+ end
+
+ local preparefile = #treatments > 0 and function(prepfiles,filename)
+
+ local treatment = needstreatment(filename)
+ if treatment then
+ local oldfile = filename
+ newfile = oldfile .. "." .. suffix
+ if runlocal then
+ newfile = file.basename(newfile)
+ end
+
+ if file.needsupdating(oldfile,newfile) then
+ local preprocessors = treatment.preprocessors
+ local runners = { }
+ for i=1,#preprocessors do
+ local preprocessor = preprocessors[i]
+ local command = commands[preprocessor]
+ if command then
+ command = xml.copy(command)
+ local suf = command.at and command.at['suffix'] or suffix
+ if suf then
+ newfile = oldfile .. "." .. suf
+ end
+ if runlocal then
+ newfile = file.basename(newfile)
+ end
+ for r, d, k in xml.elements(command,"ctx:old") do
+ d[k] = substitute(oldfile)
+ end
+ for r, d, k in xml.elements(command,"ctx:new") do
+ d[k] = substitute(newfile)
+ end
+ variables.old = oldfile
+ variables.new = newfile
+ for r, d, k in xml.elements(command,"ctx:value") do
+ local ek = d[k]
+ local ekat = ek.at and ek.at['name']
+ if ekat then
+ d[k] = substitute(variables[ekat] or "")
+ end
+ end
+ command = xml.content(command)
+ runners[#runners+1] = justtext(command)
+ oldfile = newfile
+ if runlocal then
+ oldfile = file.basename(oldfile)
+ end
+ end
end
---~ end
- for e in xml.collected(x,"ctx:prepfile") do
- local name = xml.text(e)
- if islocal then
- name = file.basename(name)
+ -- for tracing we have collected commands first
+ for i=1,#runners do
+ report_prepfiles("step %i: %s",i,runners[i])
end
- local done = e.at['done'] or 'no'
- if trace_prepfiles then
- report_prepfiles("registering %s -> %s",done)
+ --
+ for i=1,#runners do
+ local command = runners[i]
+ report_prepfiles("command: %s",command)
+ local result = os.spawn(command) or 0
+ -- if result > 0 then
+ -- report_prepfiles("error, return code: %s",result)
+ -- end
end
- found = true
- list[name] = done -- 'yes' or 'no'
+ if lfs.isfile(newfile) then
+ file.syncmtimes(filename,newfile)
+ report_prepfiles("%q is converted to %q",filename,newfile)
+ else
+ report_prepfiles("%q is not converted to %q",filename,newfile)
+ newfile = filename
+ end
+ elseif lfs.isfile(newfile) then
+ report_prepfiles("%q is already converted to %q",filename,newfile)
+ else
+ -- report_prepfiles("%q is not converted to %q",filename,newfile)
+ newfile = filename
end
+ else
+ newfile = filename
end
- end
-end
+ prepfiles[filename] = newfile
--- -- --
+ return newfile
-local function found(name) -- used in resolve
- local prepname = name .. "." .. suffix
- if list[name] and lfs.isfile(prepname) then
- if trace_prepfiles then
- report_prepfiles("preprocessing: using %s",prepname)
- end
- return prepname
end
- return false
+
+ table.setmetatableindex(ctxrunner.prepfiles,preparefile or dontpreparefile)
+
end
local function resolve(name) -- used a few times later on
- local filename = file.collapsepath(name)
- local prepname = islocal and found(file.basename(name))
- if prepname then
- return prepname
- end
- prepname = found(filename)
- if prepname then
- return prepname
- end
- return false
+ return ctxrunner.prepfiles[file.collapsepath(name)] or false
end
---~ support.doiffileexistelse(name)
-
local processfile = commands.processfile
local doifinputfileelse = commands.doifinputfileelse
@@ -94,3 +293,20 @@ end
function commands.preparedfile(name)
return resolve(name) or name
end
+
+function commands.getctxfile()
+ local ctxfile = document.arguments.ctx or ""
+ if ctxfile ~= "" then
+ ctxrunner.load(ctxfile) -- do we need to locate it?
+ end
+end
+
+-- ctxrunner.load("t:/sources/core-ctx.ctx")
+--
+-- context(ctxrunner.prepfiles["one-a.xml"]) context.par()
+-- context(ctxrunner.prepfiles["one-b.xml"]) context.par()
+-- context(ctxrunner.prepfiles["two-c.xml"]) context.par()
+-- context(ctxrunner.prepfiles["two-d.xml"]) context.par()
+-- context(ctxrunner.prepfiles["all-x.xml"]) context.par()
+--
+-- inspect(ctxrunner.prepfiles)
diff --git a/tex/context/base/core-ctx.mkiv b/tex/context/base/core-ctx.mkiv
index e178ee21b..c7298187d 100644
--- a/tex/context/base/core-ctx.mkiv
+++ b/tex/context/base/core-ctx.mkiv
@@ -13,18 +13,15 @@
\writestatus{loading}{ConTeXt Core Macros / Job Control}
-\unprotect
-
-\setnewconstant\preprocessmethod\plustwo % always check in mkiv
-
\registerctxluafile{core-ctx}{1.000}
-\def\loadctxpreplist
- {\ctxcommand{loadctxpreplist()}%
- \glet\loadctxpreplist\relax}
+\unprotect
-\appendtoks
- \loadctxpreplist
-\to \everystarttext % maybe too late but don't change it now
+\unexpanded\def\job_options_get_commandline {\ctxcommand{getcommandline()}}
+\unexpanded\def\job_options_get_ctxfile {\ctxcommand{getctxfile()}}
+\unexpanded\def\job_options_log {\ctxcommand{logoptions()}}
+\unexpanded\def\job_options_set_modes {\ctxcommand{setdocumentmodes()}}
+\unexpanded\def\job_options_set_modules {\ctxcommand{setdocumentmodules()}}
+\unexpanded\def\job_options_set_environments{\ctxcommand{setdocumentenvironments()}}
\protect \endinput
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index 4f856f996..5423b97aa 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -33,28 +33,39 @@
\appendtoks \font_preloads_at_start_text \to \everystarttext
\appendtoks \font_preloads_at_stop_text \to \everystoptext
-%prependtoks \preloadtypescript \to \everyjob
\appendtoks \showcontextbanner \to \everyjob
\appendtoks \initializenewlinechar \to \everyjob
\appendtoks \calculatecurrenttime \to \everyjob
\appendtoks \loadsystemfiles \to \everyjob
-\appendtoks \loadoptionfile \to \everyjob % can load files !
+
+\appendtoks \loadoptionfile \to \everyjob % obsolete
+\appendtoks
+ \job_options_get_commandline % expands some commands
+ \job_options_get_ctxfile % might expand some commands
+\to \everyjob % ok here?
+
\appendtoks \font_preloads_at_every_job \to \everyjob
\appendtoks \settopskip \to \everyjob
\appendtoks \initializemainlanguage \to \everyjob
-%appendtoks \MPLIBregister \to \everyjob
-\appendtoks \xmlinitialize \to \everyjob
+\appendtoks \xmlinitialize \to \everyjob % is this still needed?
\appendtoks \setfalse\c_page_backgrounds_new \to \everyjob
\appendtoks \setfalse\c_page_backgrounds_some \to \everyjob
\appendtoks \initializepagecounters \to \everyjob
-\appendtoks \directsetup{*runtime:options} \to \everyjob % we could erase them afterwards % order can change
-\appendtoks \directsetup{*runtime:modules} \to \everyjob % we could erase them afterwards % order can change
-%appendtoks \page[\v!last] \page \to \everybye % moved to core-job, we need to do this cleaner
-\appendtoks \ifarrangingpages\poparrangedpages\fi \to \everybye
-%appendtoks \registerfileinfo[end]\jobfilename \to \everybye
+\appendtoks \directsetup{*runtime:options} \to \everyjob % obsolete
+\appendtoks \directsetup{*runtime:modules} \to \everyjob % obsolete
-%appendtoks \MPLIBallocate{1000} \to \everydump
+\appendtoks
+ \job_options_set_modes
+ \job_options_set_modules
+ \job_options_set_environments
+\to \everyjob
+
+\appendtoks
+ \job_options_log
+\to \everystarttext
+
+\appendtoks \ifarrangingpages\poparrangedpages\fi \to \everybye
\prependtoks \resetallattributes \to \everybeforeoutput
diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua
index 992e4b7ec..f210f444d 100644
--- a/tex/context/base/file-job.lua
+++ b/tex/context/base/file-job.lua
@@ -9,22 +9,28 @@ if not modules then modules = { } end modules ['file-job'] = {
-- in retrospect dealing it's not that bad to deal with the nesting
-- and push/poppign at the tex end
-local format, gsub, match = string.format, string.gsub, string.match
+local format, gsub, match, find = string.format, string.gsub, string.match, string.find
local insert, remove, concat = table.insert, table.remove, table.concat
local commands, resolvers, context = commands, resolvers, context
+local settings_to_array = utilities.parsers.settings_to_array
+local write_nl = texio.write_nl
+
local trace_jobfiles = false trackers.register("system.jobfiles", function(v) trace_jobfiles = v end)
local report_jobfiles = logs.reporter("system","jobfiles")
local texsetcount = tex.setcount
local elements = interfaces.elements
+local constants = interfaces.constants
local variables = interfaces.variables
local logsnewline = logs.newline
local logspushtarget = logs.pushtarget
local logspoptarget = logs.poptarget
+local allocate = utilities.storage.allocate
+
local v_outer = variables.outer
local v_text = variables.text
local v_project = variables.project
@@ -683,3 +689,199 @@ function commands.loadexamodes(filename)
report_examodes("no mode file %s",filename) -- todo: message system
end
end
+
+-- changed in mtx-context
+-- code moved from luat-ini
+
+-- todo: locals when mtx-context is changed
+
+document = document or {
+ arguments = allocate(),
+ files = allocate(),
+ options = {
+ commandline = {
+ environments = allocate(),
+ modules = allocate(),
+ modes = allocate(),
+ },
+ ctxfile = {
+ environments = allocate(),
+ modules = allocate(),
+ modes = allocate(),
+ },
+ },
+}
+
+function document.setargument(key,value)
+ document.arguments[key] = value
+end
+
+function document.setdefaultargument(key,default)
+ local v = document.arguments[key]
+ if v == nil or v == "" then
+ document.arguments[key] = default
+ end
+end
+
+function document.setfilename(i,name)
+ if name then
+ document.files[tonumber(i)] = name
+ else
+ document.files[#document.files+1] = tostring(i)
+ end
+end
+
+function document.getargument(key,default) -- commands
+ local v = document.arguments[key]
+ if type(v) == "boolean" then
+ v = (v and "yes") or "no"
+ document.arguments[key] = v
+ end
+ context(v or default or "")
+end
+
+function document.getfilename(i) -- commands
+ context(document.files[i] or "")
+end
+
+local function validstring(s)
+ return type(s) == "string" and s ~= "" and s or nil
+end
+
+function commands.getcommandline() -- has to happen at the tex end in order to expand
+
+ -- the document[arguments|files] tables are copies
+
+ local arguments = document.arguments
+ local files = document.files
+ local options = document.options
+
+ for k, v in next, environment.arguments do
+ k = gsub(k,"^c:","") -- already done, but better be safe than sorry
+ if arguments[k] == nil then
+ arguments[k] = v
+ end
+ end
+
+ -- in the new mtx=context approach we always pass a stub file so we need to
+ -- to trick the files table which actually only has one entry in a tex job
+
+ if arguments.timing then
+ context.usemodule("timing")
+ end
+
+ if arguments.batchmode then
+ context.batchmode(false)
+ end
+
+ if arguments.nonstopmode then
+ context.nonstopmode(false)
+ end
+
+ if arguments.nostatistics then
+ directives.enable("system.nostatistics")
+ end
+
+ if arguments.paranoid then
+ context.setvalue("maxreadlevel",1)
+ end
+
+ if validstring(arguments.path) then
+ context.usepath { arguments.path }
+ end
+
+ local inputfile = validstring(arguments.input)
+
+ if inputfile and file.dirname(inputfile) == "." and lfs.isfile(inputfile) then
+ -- nicer in checks
+ inputfile = file.basename(inputfile)
+ end
+
+ context.setupsystem {
+ [constants.directory] = validstring(arguments.setuppath),
+ [constants.inputfile] = inputfile,
+ [constants.file] = validstring(arguments.result),
+ [constants.random] = validstring(arguments.randomseed),
+ [constants.n] = validstring(arguments.kindofrun),
+ [constants.m] = validstring(arguments.currentrun),
+ }
+
+ if validstring(arguments.arguments) then
+ context.setupenv { arguments.arguments }
+ end
+
+ if arguments.once then
+ directives.enable("system.runonce")
+ end
+
+ if arguments.noarrange then
+ context.setuparranging { variables.disable }
+ end
+
+ --
+
+ local commandline = options.commandline
+
+ commandline.environments = table.append(commandline.environments,settings_to_array(validstring(arguments.environments)))
+ commandline.modules = table.append(commandline.modules, settings_to_array(validstring(arguments.modules)))
+ commandline.modes = table.append(commandline.modes, settings_to_array(validstring(arguments.modes)))
+
+ --
+
+ if #files == 0 then
+ local list = settings_to_array(validstring(arguments.files))
+ if list and #list > 0 then
+ files = list
+ end
+ end
+
+ if #files == 0 then
+ files = { validstring(arguments.input) }
+ end
+
+ --
+
+ document.arguments = arguments
+ document.files = files
+
+end
+
+-- commandline wins over ctxfile
+
+local function apply(list,action)
+ if list then
+ for i=1,#list do
+ action { list[i] }
+ end
+ end
+end
+
+function commands.setdocumentmodes() -- was setup: *runtime:modes
+ apply(document.options.ctxfile .modes,context.enablemode)
+ apply(document.options.commandline.modes,context.enablemode)
+end
+
+function commands.setdocumentmodules() -- was setup: *runtime:modules
+ apply(document.options.ctxfile .modules,context.usemodule)
+ apply(document.options.commandline.modules,context.usemodule)
+end
+
+function commands.setdocumentenvironments() -- was setup: *runtime:environments
+ apply(document.options.ctxfile .environments,context.environment)
+ apply(document.options.commandline.environments,context.environment)
+end
+
+function commands.logoptions()
+ local arguments = document.arguments
+ local files = document.files
+ write_nl("log","\n% begin of command line arguments\n%\n")
+ for k, v in next, arguments do
+ write_nl("log",format("%% %-20s = %s",k,tostring(v)))
+ end
+ write_nl("log","%\n% end of command line arguments\n")
+ write_nl("log","\n% begin of command line files\n%\n")
+ for i=1,#files do
+ write_nl("log",format("%% %i %s",i,files[i]))
+ end
+ write_nl("log","%\n% end of command line files\n\n")
+end
diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi
index 112400cbd..a801f7309 100644
--- a/tex/context/base/file-job.mkvi
+++ b/tex/context/base/file-job.mkvi
@@ -75,11 +75,16 @@
\def\syst_files_load#name% only mkiv files
{\readsysfile{#name.\mksuffix}{\showmessage\m!system2{#name.\mksuffix}}\donothing}
-\unexpanded\def\loadoptionfile
+% \unexpanded\def\loadoptionfile
+% {\readjobfile{\jobname.\f!optionextension}
+% {\writestatus\m!system{\jobname.\f!optionextension\space loaded}%
+% \ctxcommand{copyfiletolog("\jobname.\f!optionextension")}}%
+% {\writestatus\m!system{no \jobname.\f!optionextension}}}
+
+\unexpanded\def\loadoptionfile % this one is soon obsolete
{\readjobfile{\jobname.\f!optionextension}
- {\writestatus\m!system{\jobname.\f!optionextension\space loaded}%
- \ctxcommand{copyfiletolog("\jobname.\f!optionextension")}}%
- {\writestatus\m!system{no \jobname.\f!optionextension}}}
+ {\ctxcommand{copyfiletolog("\jobname.\f!optionextension")}}%
+ {}}
% document structure
@@ -110,6 +115,8 @@
\unexpanded\def\autostarttext{\ctxcommand{autostarttext()}}
\unexpanded\def\autostoptext {\ctxcommand{autostoptext()}}
+\unexpanded\def\finishjob{\stoptext} % nicer in luatex call commandline
+
\newtoks\everystartnotext
\newtoks\everystopnotext
@@ -190,7 +197,7 @@
%D Handy for modules that have a test/demo appended.
-\def\continueifinputfile#name{\doifnot\inputfilename{#name}\endinput}
+\def\continueifinputfile#name{\doifnot\inputfilename{#name}\endinput} % will be lua call ./ check
%def\processifinputfile #name{\doif \inputfilename{#name}}
% \startproject test
diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv
index 9a2c45172..141bfd2ff 100644
--- a/tex/context/base/font-pre.mkiv
+++ b/tex/context/base/font-pre.mkiv
@@ -365,6 +365,9 @@
\definealternativestyle [\v!sans,\v!sansserif] [\ss] []
\definealternativestyle [\v!sansbold] [\ss\bf] []
+\definealternativestyle [\v!roman,\v!serif,\v!regular] [\rm]
+\definealternativestyle [\v!handwritten] [\hw]
+\definealternativestyle [\v!calligraphic] [\cg]
% % maybe we need interface neutral as well (for use in cld):
%
diff --git a/tex/context/base/l-io.lua b/tex/context/base/l-io.lua
index 4f27dc1dc..657b755b8 100644
--- a/tex/context/base/l-io.lua
+++ b/tex/context/base/l-io.lua
@@ -17,14 +17,14 @@ else
io.fileseparator, io.pathseparator = "/" , ":"
end
-function io.loaddata(filename,textmode)
+function io.loaddata(filename,textmode) -- return nil if empty
local f = io.open(filename,(textmode and 'r') or 'rb')
if f then
local data = f:read('*all')
f:close()
- return data
- else
- return nil
+ if #data > 0 then
+ return data
+ end
end
end
@@ -46,6 +46,45 @@ function io.savedata(filename,data,joiner)
end
end
+function io.loadlines(filename,n) -- return nil if empty
+ local f = io.open(filename,'r')
+ if f then
+ if n then
+ local lines = { }
+ for i=1,n do
+ local line = f:read("*lines")
+ if line then
+ lines[#lines+1] = line
+ else
+ break
+ end
+ end
+ f:close()
+ lines = concat(lines,"\n")
+ if #lines > 0 then
+ return lines
+ end
+ else
+ local line = f:read("*line") or ""
+ assert(f:close())
+ if #line > 0 then
+ return line
+ end
+ end
+ end
+end
+
+function io.loadchunk(filename,n)
+ local f = io.open(filename,'rb')
+ if f then
+ local data = f:read(n or 1024)
+ f:close()
+ if #data > 0 then
+ return data
+ end
+ end
+end
+
function io.exists(filename)
local f = io.open(filename)
if f == nil then
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index 13294ab0d..50b14db06 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-lpeg.lua
@@ -234,12 +234,16 @@ function lpeg.split(separator,str)
end
function string.split(str,separator)
- local c = cache[separator]
- if not c then
- c = tsplitat(separator)
- cache[separator] = c
+ if separator then
+ local c = cache[separator]
+ if not c then
+ c = tsplitat(separator)
+ cache[separator] = c
+ end
+ return match(c,str)
+ else
+ return { str }
end
- return match(c,str)
end
local spacing = patterns.spacer^0 * newline -- sort of strip
diff --git a/tex/context/base/l-md5.lua b/tex/context/base/l-md5.lua
index 1d471c966..6abf2e17d 100644
--- a/tex/context/base/l-md5.lua
+++ b/tex/context/base/l-md5.lua
@@ -31,15 +31,30 @@ if not md5.dec then function md5.dec(str) return convert(str,"%03i") end end
--~ function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end
--~ end
-function file.needs_updating(oldname,newname,threshold) -- size modification access change
- local oldtime = lfs.attributes(oldname, modification)
- local newtime = lfs.attributes(newname, modification)
- if newtime >= oldtime then
- return false
- elseif oldtime - newtime < (threshold or 1) then
- return false
+function file.needsupdating(oldname,newname,threshold) -- size modification access change
+ local oldtime = lfs.attributes(oldname,"modification")
+ if oldtime then
+ local newtime = lfs.attributes(newname,"modification")
+ if not newtime then
+ return true -- no new file, so no updating needed
+ elseif newtime >= oldtime then
+ return false -- new file definitely needs updating
+ elseif oldtime - newtime < (threshold or 1) then
+ return false -- new file is probably still okay
+ else
+ return true -- new file has to be updated
+ end
else
- return true
+ return false -- no old file, so no updating needed
+ end
+end
+
+file.needs_updating = file.needsupdating
+
+function file.syncmtimes(oldname,newname)
+ local oldtime = lfs.attributes(oldname,"modification")
+ if oldtime and lfs.isfile(newname) then
+ lfs.touch(newname,oldtime,oldtime)
end
end
@@ -61,7 +76,7 @@ function file.loadchecksum(name)
return nil
end
-function file.savechecksum(name, checksum)
+function file.savechecksum(name,checksum)
if not checksum then checksum = file.checksum(name) end
if checksum then
io.savedata(name .. ".md5",checksum)
diff --git a/tex/context/base/luat-cod.lua b/tex/context/base/luat-cod.lua
index b022f31c3..8c721aa15 100644
--- a/tex/context/base/luat-cod.lua
+++ b/tex/context/base/luat-cod.lua
@@ -103,7 +103,7 @@ if not environment.luafilechunk then
end
-if not environment.engineflags then
+if not environment.engineflags then -- raw flags
local engineflags = { }
for i=-10,#arg do
local a = arg[i]
diff --git a/tex/context/base/luat-env.lua b/tex/context/base/luat-env.lua
index 4f1b661c2..840b2344f 100644
--- a/tex/context/base/luat-env.lua
+++ b/tex/context/base/luat-env.lua
@@ -79,6 +79,8 @@ local mt = {
setmetatable(environment,mt)
+-- context specific arguments (in order not to confuse the engine)
+
function environment.initializearguments(arg)
local arguments, files = { }, { }
environment.arguments, environment.files, environment.sortedflags = arguments, files, nil
@@ -87,10 +89,12 @@ function environment.initializearguments(arg)
if index > 0 then
local flag, value = match(argument,"^%-+(.-)=(.-)$")
if flag then
+ flag = gsub(flag,"^c:","")
arguments[flag] = unquoted(value or "")
else
flag = match(argument,"^%-+(.+)")
if flag then
+ flag = gsub(flag,"^c:","")
arguments[flag] = true
else
files[#files+1] = argument
@@ -110,7 +114,7 @@ end
-- tricky: too many hits when we support partials unless we add
-- a registration of arguments so from now on we have 'partial'
-function environment.argument(name,partial)
+function environment.getargument(name,partial)
local arguments, sortedflags = environment.arguments, environment.sortedflags
if arguments[name] then
return arguments[name]
@@ -133,6 +137,8 @@ function environment.argument(name,partial)
return nil
end
+environment.argument = environment.getargument
+
function environment.splitarguments(separator) -- rather special, cut-off before separator
local done, before, after = false, { }, { }
local originalarguments = environment.originalarguments
diff --git a/tex/context/base/luat-ini.lua b/tex/context/base/luat-ini.lua
index 204cc7bd1..1f7cca4af 100644
--- a/tex/context/base/luat-ini.lua
+++ b/tex/context/base/luat-ini.lua
@@ -12,8 +12,6 @@ local debug = require "debug"
local string, table, lpeg, math, io, system = string, table, lpeg, math, io, system
local next, setfenv = next, setfenv or debug.setfenv
-local mark = utilities.storage.mark
-
--[[ldx--
<p>We cannot load anything yet. However what we will do us reserve a fewtables.
These can be used for runtime user data or third party modules and will not be
@@ -26,15 +24,6 @@ moduledata = moduledata or { } -- only for development team
documentdata = documentdata or { } -- for users (e.g. raw data)
parametersets = parametersets or { } -- experimental for team
-document = document or { } -- only for context itself
-
---[[ldx--
-<p>These can be used/set by the caller program; <t>mtx-context.lua</t> does it.</p>
---ldx]]--
-
-document.arguments = mark(document.arguments or { })
-document.files = mark(document.files or { })
-
--[[ldx--
<p>Please create a namespace within these tables before using them!</p>
@@ -157,33 +146,3 @@ end
storage.register("lua/numbers", lua.numbers, "lua.numbers")
storage.register("lua/messages", lua.messages, "lua.messages")
-
---~ local arguments, files = document.arguments, document.files -- set later
-
-function document.setargument(key,value)
- document.arguments[key] = value
-end
-
-function document.setdefaultargument(key,default)
- local v = document.arguments[key]
- if v == nil or v == "" then
- document.arguments[key] = default
- end
-end
-
-function document.getargument(key,default)
- local v = document.arguments[key]
- if type(v) == "boolean" then
- v = (v and "yes") or "no"
- document.arguments[key] = v
- end
- context(v or default or "")
-end
-
-function document.setfilename(i,name)
- document.files[tonumber(i)] = name
-end
-
-function document.getfilename(i)
- context(document.files[i] or "")
-end
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index 84ebc5823..14fbd68e6 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -313,7 +313,7 @@
\xmlprocessingmode\executeifdefined{\??xmldefaults\directxmlparameter\c!default}\plusone
\to \everysetupxml
-\unexpanded\def\xmlinitialize
+\unexpanded\def\xmlinitialize % is this still needed?
{\the\everysetupxml}
\let\p_lxml_entities\empty
diff --git a/tex/context/base/math-def.mkiv b/tex/context/base/math-def.mkiv
index 43a511e43..1c602187f 100644
--- a/tex/context/base/math-def.mkiv
+++ b/tex/context/base/math-def.mkiv
@@ -330,6 +330,8 @@
\let\normalunderbrace \underbrace
\let\normaloverparent \overparent
\let\normalunderparent \underparent
+\let\normaloverbracket \overbracket
+\let\normalunderbracket \underbracket
\let\normalunderleftarrow \underleftarrow
\let\normaloverleftarrow \overleftarrow
\let\normalunderrightarrow\underrightarrow
@@ -343,6 +345,8 @@
\unexpanded\def\doublebrace {\mathopwithlimits\normaldoublebrace }
\unexpanded\def\overparent {\mathopwithlimits\normaloverparent }
\unexpanded\def\underparent {\mathopwithlimits\normalunderparent }
+\unexpanded\def\overbracket {\mathopwithlimits\normaloverbracket }
+\unexpanded\def\underbracket {\mathopwithlimits\normalunderbracket }
\unexpanded\def\doubleparent {\mathopwithlimits\normaldoubleparent }
\unexpanded\def\underleftarrow {\mathopwithlimits\normalunderleftarrow }
\unexpanded\def\overleftarrow {\mathopwithlimits\normaloverleftarrow }
diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua
index 8caf21cc2..02288432f 100644
--- a/tex/context/base/math-noa.lua
+++ b/tex/context/base/math-noa.lua
@@ -799,9 +799,20 @@ italics[math_char] = function(pointer,what,n,parent)
end
end
end
+
+ -- maybe also correction when next == nil
+
if correction and correction ~= 0 then
local next_noad = parent.next
- if next_noad and next_noad.id == math_noad then
+ if not next_noad then
+ if true then -- this might become an option
+ if trace_italics then
+ report_italics("method %s: adding %s italic correction between %s (0x%05X) and end math",
+ method,number.points(correction),utfchar(char),char)
+ end
+ insert_node_after(parent,parent,new_kern(correction))
+ end
+ elseif next_noad.id == math_noad then
local next_subtype = next_noad.subtype
if next_subtype == noad_punct or next_subtype == noad_ord then
local next_nucleus = next_noad.nucleus
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index b4c6ad039..011fba7d3 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -707,6 +707,31 @@
\expandafter\mult_interfaces_show_parent_chain\csname#1:\s!parent\endcsname
\fi}
+%D Another helper:
+
+\unexpanded\def\doifelsecommandhandler#1#2% namespace name
+ {\ifcsname#1#2:\s!parent\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\unexpanded\def\doifcommandhandler#1#2% namespace name
+ {\ifcsname#1#2:\s!parent\endcsname
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\unexpanded\def\doifnotcommandhandler#1#2% namespace name
+ {\ifcsname#1#2:\s!parent\endcsname
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+\let\doifcommandhandlerelse\doifelsecommandhandler
+
%D Conventions:
%D
%D \starttyping
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index 7d61d0427..134e4c82a 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -124,6 +124,7 @@ return {
"starttexcode", "stoptexcode",
--
"doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup",
+ "doifelsecommandhandler","doifnotcommandhandler","doifcommandhandler",
--
"newmode", "setmode", "resetmode",
"newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode",
diff --git a/tex/context/base/page-mak.mkvi b/tex/context/base/page-mak.mkvi
index f37c4f613..e5a722676 100644
--- a/tex/context/base/page-mak.mkvi
+++ b/tex/context/base/page-mak.mkvi
@@ -88,7 +88,10 @@
\newbox \b_page_makeup
\newtoks\t_page_makeup_every_setup
-\def\page_makeup_start_yes[#name][#settings]%
+\def\page_makeup_start_yes[#name]% [#settings]%
+ {\doifelsecommandhandler\??makeup{#name}\page_makeup_start_indeed\page_makeup_start_nop[#name]}%
+
+\def\page_makeup_start_indeed[#name][#settings]%
{\doifelsenothing{\namedmakeupparameter{#name}\c!page}
{\page}% new, so best not have dangling mess here like references (we could capture then and flush embedded)
{\page[\namedmakeupparameter{#name}\c!page]}%
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 8d2ac5857..d92622355 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 0d58d1b16..d8ab22c4e 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index d7ab099a6..cbb7040db 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -344,6 +344,16 @@ return {
status = "okay",
},
{
+ filename = "cont-nop",
+ marktype = "mkiv",
+ status = "okay",
+ },
+ {
+ filename = "cont-yes",
+ marktype = "mkiv",
+ status = "okay",
+ },
+ {
filename = "regi-ini",
marktype = "mkiv",
status = "okay",
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index 48aab78db..4666738d5 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -597,7 +597,7 @@ function lists.hasnumberdata(name,n)
local data = lists.result[n]
if data then
local numberdata = data.numberdata
- if numberdata then
+ if numberdata and not numberdata.hidenumber then -- th ehide number is true
return true
end
end
diff --git a/tex/context/base/tabl-xnt.mkvi b/tex/context/base/tabl-xnt.mkvi
index 35451abe0..ffa1f501e 100644
--- a/tex/context/base/tabl-xnt.mkvi
+++ b/tex/context/base/tabl-xnt.mkvi
@@ -129,7 +129,7 @@
\unexpanded\def\tabl_x_TABLE_start_indeed[#settings]%
{\bgroup
\tabl_x_prepare{#settings}%
- \edef\tabl_x_current_buffer{\x_table_default_buffer}%
+ \edef\tabl_x_current_buffer{\tabl_x_default_buffer}%
\buff_pickup\tabl_x_current_buffer{bTABLE}{eTABLE}\relax\tabl_x_process}
\protect \endinput
diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua
index 395d65a03..e999cbd74 100644
--- a/tex/context/base/tabl-xtb.lua
+++ b/tex/context/base/tabl-xtb.lua
@@ -391,7 +391,7 @@ function xtables.reflow_width()
for c=1,nofcolumns do
local drc = row[c]
if drc.list then
- --- flush_node_list(drc.list)
+ -- flush_node_list(drc.list)
drc.list = false
end
end
@@ -512,7 +512,6 @@ function xtables.reflow_width()
end
-- maybe also options[v_width] here but tricky as width does not say
-- much about amount
-
if options[v_width] then -- not that much (we could have a clever vpack loop balancing .. no fun)
local factor = (widetotal + delta) / width
if trace_xtable then
diff --git a/tex/context/base/trac-deb.mkiv b/tex/context/base/trac-deb.mkiv
index 4f5f0e931..10e462a31 100644
--- a/tex/context/base/trac-deb.mkiv
+++ b/tex/context/base/trac-deb.mkiv
@@ -31,7 +31,7 @@
\unexpanded\def\enableexperiments [#1]{\ctxlua{experiments.enable("#1")}}
\unexpanded\def\disableexperiments[#1]{\ctxlua{experiments.disable("#1")}}
-\unexpanded\def\showdebuginfo{\ctxlua{lmx.showdebuginfo()}}
-\unexpanded\def\overloaderror{\ctxlua{lmx.overloaderror()}} % \enabledirectives[system.showerror]
+\unexpanded\def\showdebuginfo {\ctxlua{lmx.showdebuginfo()}}
+\unexpanded\def\overloaderror {\ctxlua{lmx.overloaderror()}} % \enabledirectives[system.showerror]
\unexpanded\def\showlogcategories {\ctxlua{logs.show()}}
diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua
index bc0070eb4..ed7367b4f 100644
--- a/tex/context/base/trac-set.lua
+++ b/tex/context/base/trac-set.lua
@@ -205,7 +205,7 @@ function setters.show(t)
local value, default, modules = functions.value, functions.default, #functions
value = value == nil and "unset" or tostring(value)
default = default == nil and "unset" or tostring(default)
- t.report("%-30s modules: %2i default: %6s value: %6s",name,modules,default,value)
+ t.report("%-50s modules: %2i default: %6s value: %6s",name,modules,default,value)
end
end
t.report()
@@ -297,17 +297,31 @@ end)
-- experiment
-local flags = environment and environment.engineflags
+if environment then
-if flags then
- if trackers and flags.trackers then
- setters.initialize("flags","trackers", settings_to_hash(flags.trackers))
- -- t_enable(flags.trackers)
- end
- if directives and flags.directives then
- setters.initialize("flags","directives", settings_to_hash(flags.directives))
- -- d_enable(flags.directives)
+ -- The engineflags are known earlier than environment.arguments but maybe we
+ -- need to handle them both as the later are parsed differently. The c: prefix
+ -- is used by mtx-context to isolate the flags from those that concern luatex.
+
+ local engineflags = environment.engineflags
+
+ if engineflags then
+ if trackers then
+ local list = engineflags["c:trackers"] or engineflags["trackers"]
+ if type(list) == "string" then
+ setters.initialize("flags","trackers",settings_to_hash(list))
+ -- t_enable(list)
+ end
+ end
+ if directives then
+ local list = engineflags["c:directives"] or engineflags["directives"]
+ if type(list) == "string" then
+ setters.initialize("flags","directives", settings_to_hash(list))
+ -- d_enable(list)
+ end
+ end
end
+
end
-- here
diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv
index a393fc250..fbd06acc9 100644
--- a/tex/context/base/typo-mar.mkiv
+++ b/tex/context/base/typo-mar.mkiv
@@ -110,7 +110,7 @@
% \c!align=,
% \c!method=,
\c!style=\v!bold,
- \c!color=, % maybe textcolor
+ \c!color=, % maybe \maintextcolor
% \c!name=,
% \c!category=,
\c!threshold=.25ex,
@@ -148,7 +148,7 @@
\appendtoks
\forgetall
\tf
- \deactivatecolor
+ \deactivatecolor % needed, but maybe we should switch to maintextcolor: \onlyinheritmaintextcolor
\to \everymargindatacontent
% trialtypesetting: no need for margin stuff while trialing as
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index ea509c338..96a34326e 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 05/30/12 11:26:34
+-- merge date : 06/05/12 09:16:10
do -- begin closure to overcome local limits and interference
@@ -1331,12 +1331,16 @@ function lpeg.split(separator,str)
end
function string.split(str,separator)
- local c = cache[separator]
- if not c then
- c = tsplitat(separator)
- cache[separator] = c
+ if separator then
+ local c = cache[separator]
+ if not c then
+ c = tsplitat(separator)
+ cache[separator] = c
+ end
+ return match(c,str)
+ else
+ return { str }
end
- return match(c,str)
end
local spacing = patterns.spacer^0 * newline -- sort of strip
@@ -2468,14 +2472,14 @@ else
io.fileseparator, io.pathseparator = "/" , ":"
end
-function io.loaddata(filename,textmode)
+function io.loaddata(filename,textmode) -- return nil if empty
local f = io.open(filename,(textmode and 'r') or 'rb')
if f then
local data = f:read('*all')
f:close()
- return data
- else
- return nil
+ if #data > 0 then
+ return data
+ end
end
end
@@ -2497,6 +2501,45 @@ function io.savedata(filename,data,joiner)
end
end
+function io.loadlines(filename,n) -- return nil if empty
+ local f = io.open(filename,'r')
+ if f then
+ if n then
+ local lines = { }
+ for i=1,n do
+ local line = f:read("*lines")
+ if line then
+ lines[#lines+1] = line
+ else
+ break
+ end
+ end
+ f:close()
+ lines = concat(lines,"\n")
+ if #lines > 0 then
+ return lines
+ end
+ else
+ local line = f:read("*line") or ""
+ assert(f:close())
+ if #line > 0 then
+ return line
+ end
+ end
+ end
+end
+
+function io.loadchunk(filename,n)
+ local f = io.open(filename,'rb')
+ if f then
+ local data = f:read(n or 1024)
+ f:close()
+ if #data > 0 then
+ return data
+ end
+ end
+end
+
function io.exists(filename)
local f = io.open(filename)
if f == nil then