summaryrefslogtreecommitdiff
path: root/tex/context/base
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base')
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/colo-ini.lua6
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkxl2
-rw-r--r--tex/context/base/mkiv/font-ocl.lua30
-rw-r--r--tex/context/base/mkiv/font-sty.mklx9
-rw-r--r--tex/context/base/mkiv/font-sty.mkvi11
-rw-r--r--tex/context/base/mkiv/grph-bmp.lua3
-rw-r--r--tex/context/base/mkiv/grph-fil.lua26
-rw-r--r--tex/context/base/mkiv/grph-img.lua5
-rw-r--r--tex/context/base/mkiv/grph-rul.lua2
-rw-r--r--tex/context/base/mkiv/l-pdfview.lua2
-rw-r--r--tex/context/base/mkiv/l-table.lua31
-rw-r--r--tex/context/base/mkiv/lpdf-img.lua93
-rw-r--r--tex/context/base/mkiv/lpdf-pde.lua162
-rw-r--r--tex/context/base/mkiv/luat-fmt.lua3
-rw-r--r--tex/context/base/mkiv/mlib-ctx.mkiv2
-rw-r--r--tex/context/base/mkiv/mlib-lua.lua446
-rw-r--r--tex/context/base/mkiv/mlib-pdf.lua5
-rw-r--r--tex/context/base/mkiv/mlib-pdf.mkxl40
-rw-r--r--tex/context/base/mkiv/mlib-scn.lua37
-rw-r--r--tex/context/base/mkiv/mult-fun.lua2
-rw-r--r--tex/context/base/mkiv/pack-bck.mkvi5
-rw-r--r--tex/context/base/mkiv/pack-rul.mkiv10
-rw-r--r--tex/context/base/mkiv/pack-rul.mkxl10
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin26096 -> 26704 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin230173 -> 268937 bytes
-rw-r--r--tex/context/base/mkiv/syst-ini.mkiv2
-rw-r--r--tex/context/base/mkiv/syst-ini.mkxl2
-rw-r--r--tex/context/base/mkiv/trac-log.lua10
-rw-r--r--tex/context/base/mkiv/trac-set.lua2
-rw-r--r--tex/context/base/mkiv/util-tab.lua20
-rw-r--r--tex/context/base/mkiv/util-tpl.lua66
35 files changed, 714 insertions, 338 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index f4666bcd9..bca3721ce 100644
--- a/tex/context/base/mkii/cont-new.mkii
+++ b/tex/context/base/mkii/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2019.08.24 22:42}
+\newcontextversion{2019.09.09 13:44}
%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/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index 1663c168f..f56da6309 100644
--- a/tex/context/base/mkii/context.mkii
+++ b/tex/context/base/mkii/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2019.08.24 22:42}
+\edef\contextversion{2019.09.09 13:44}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua
index c7b1d4de4..d865668a5 100644
--- a/tex/context/base/mkiv/colo-ini.lua
+++ b/tex/context/base/mkiv/colo-ini.lua
@@ -1010,6 +1010,12 @@ local function complement(one,fraction,i)
return otf
end
+colors.helpers = {
+ inbetween = inbetween,
+ justone = justone,
+ complement = complement,
+}
+
defineintermediatecolor = function(name,fraction,c_one,c_two,a_one,a_two,specs,global,freeze)
fraction = tonumber(fraction) or 1
local one, two = colorvalues[c_one], colorvalues[c_two] -- beware, it uses the globals
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 47ee3650e..37364a19a 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2019.08.24 22:42}
+\newcontextversion{2019.09.09 13:44}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index a768bffde..b417e09a7 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -45,7 +45,7 @@
%D {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2019.08.24 22:42}
+\edef\contextversion{2019.09.09 13:44}
\edef\contextkind {beta}
%D Kind of special:
diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl
index a6e36cfaf..aaf35d985 100644
--- a/tex/context/base/mkiv/context.mkxl
+++ b/tex/context/base/mkiv/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2019.08.24 22:42}
+\edef\contextversion{2019.09.09 13:44}
\edef\contextkind {beta}
%D Kind of special:
diff --git a/tex/context/base/mkiv/font-ocl.lua b/tex/context/base/mkiv/font-ocl.lua
index d79ed657e..29aa3eac7 100644
--- a/tex/context/base/mkiv/font-ocl.lua
+++ b/tex/context/base/mkiv/font-ocl.lua
@@ -193,11 +193,11 @@ local pop = { "pdf", "page", "Q" }
-- local goback = w ~= 0 and leftcommand[w] or nil -- needs checking: are widths the same
-- local t = {
-- start,
--- not u and actualb or { "pdf", "page", (getactualtext(tounicode(u))) }
+-- not u and actualb or { "pdf", "page", (getactualtext(tounicode(u))) },
+-- push,
-- }
--- local n = 2
+-- local n = 3
-- local l = nil
--- n = n + 1 t[n] = push
-- for i=1,s do
-- local entry = colorlist[i]
-- local v = colorvalues[entry.class] or default
@@ -220,9 +220,6 @@ local pop = { "pdf", "page", "Q" }
-- end
-- end
-- end
---
--- -- Here we have no color change in BT .. ET and more q Q pairs but even then acrobat
--- -- fails displaying the overlays correctly. Other renderers do it right.
local function initialize(tfmdata,kind,value)
if value then
@@ -271,40 +268,25 @@ local function initialize(tfmdata,kind,value)
local s = #colorlist
local goback = w ~= 0 and leftcommand[w] or nil -- needs checking: are widths the same
local t = {
- start, -- really needed
- not u and actualb or { "pdf", "page", (getactualtext(tounicode(u))) }
+ not u and actualb or { "pdf", "page", (getactualtext(tounicode(u))) },
+ push,
}
local n = 2
local l = nil
- local f = false
for i=1,s do
local entry = colorlist[i]
local v = colorvalues[entry.class] or default
if v and l ~= v then
- if f then
- n = n + 1 t[n] = pop
- end
- n = n + 1 t[n] = push
- f = true
n = n + 1 t[n] = v
l = v
- else
- if f then
- n = n + 1 t[n] = pop
- end
- f = false
- l = nil
end
n = n + 1 t[n] = charcommand[entry.slot]
if s > 1 and i < s and goback then
n = n + 1 t[n] = goback
end
end
- if f then
- n = n + 1 t[n] = pop
- end
+ n = n + 1 t[n] = pop
n = n + 1 t[n] = actuale
- -- n = n + 1 t[n] = stop -- not needed
character.commands = t
end
end
diff --git a/tex/context/base/mkiv/font-sty.mklx b/tex/context/base/mkiv/font-sty.mklx
index 385a9cdbe..81884333b 100644
--- a/tex/context/base/mkiv/font-sty.mklx
+++ b/tex/context/base/mkiv/font-sty.mklx
@@ -222,6 +222,7 @@
\installcorenamespace{style}
\installcorenamespace{stylecheck}
+\installcorenamespace{stylehack}
\installcommandhandler \??style {style} \??style
@@ -272,6 +273,8 @@
{\csname\??styleargument
\ifcsname\??stylecheck#name\endcsname
2% defined as style
+ \orelse\ifcsname\??stylehack#name\endcsname
+ 4% defined as command
\orelse\ifcsname#name\endcsname
1% defined as command
\else
@@ -294,6 +297,12 @@
\setvalue{\??styleargument3}#specification%
{\doifelseassignment{#specification}\font_styles_assignment\font_styles_direct{#specification}}
+\setvalue{\??styleargument4}#name%
+ {\expandafter\triggergroupedcommandcs\begincsname\??stylehack#name\endcsname}
+
+\setvalue{\??stylehack\s!math}% dirty trick
+ {\groupedcommand\normalstartimath\normalstopimath}
+
% \def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}}
% \def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}}
diff --git a/tex/context/base/mkiv/font-sty.mkvi b/tex/context/base/mkiv/font-sty.mkvi
index 8200aa957..a24194355 100644
--- a/tex/context/base/mkiv/font-sty.mkvi
+++ b/tex/context/base/mkiv/font-sty.mkvi
@@ -222,6 +222,7 @@
\installcorenamespace{style}
\installcorenamespace{stylecheck}
+\installcorenamespace{stylehack}
\installcommandhandler \??style {style} \??style
@@ -272,11 +273,13 @@
{\csname\??styleargument
\ifcsname\??stylecheck#name\endcsname
2% defined as style
+ \else\ifcsname\??stylehack#name\endcsname
+ 4% defined as command
\else\ifcsname#name\endcsname
1% defined as command
\else
3% specification
- \fi\fi
+ \fi\fi\fi
\endcsname{#name}}
% \setvalue{\??styleargument1}#name%
@@ -294,6 +297,12 @@
\setvalue{\??styleargument3}#specification%
{\doifelseassignment{#specification}\font_styles_assignment\font_styles_direct{#specification}}
+\setvalue{\??styleargument4}#name%
+ {\expandafter\triggergroupedcommandcs\begincsname\??stylehack#name\endcsname}
+
+\setvalue{\??stylehack\s!math}% dirty trick
+ {\groupedcommand\normalstartimath\normalstopimath}
+
% \def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}}
% \def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}}
diff --git a/tex/context/base/mkiv/grph-bmp.lua b/tex/context/base/mkiv/grph-bmp.lua
index d863b1a98..e10b01aa4 100644
--- a/tex/context/base/mkiv/grph-bmp.lua
+++ b/tex/context/base/mkiv/grph-bmp.lua
@@ -16,7 +16,7 @@ graphics.bitmaps = bitmaps
local wrapimage = images.wrap
-function bitmaps.new(xsize,ysize,colorspace,colordepth,mask)
+function bitmaps.new(xsize,ysize,colorspace,colordepth,mask,index)
if not xsize or not ysize or xsize == 0 or ysize == 0 then
report_bitmap("provide 'xsize' and 'ysize' larger than zero")
return
@@ -35,6 +35,7 @@ function bitmaps.new(xsize,ysize,colorspace,colordepth,mask)
xsize = xsize,
ysize = ysize,
mask = mask and true or nil,
+ index = index and true or nil,
}
end
diff --git a/tex/context/base/mkiv/grph-fil.lua b/tex/context/base/mkiv/grph-fil.lua
index 155d4211b..b39807830 100644
--- a/tex/context/base/mkiv/grph-fil.lua
+++ b/tex/context/base/mkiv/grph-fil.lua
@@ -57,10 +57,32 @@ function jobfiles.run(name,action)
local oldchecksum = collected[usedname]
local newchecksum = checksum(usedname)
local resultfile = replacesuffix(usedname,resultsuffix)
- if jobfiles.forcerun or not oldchecksum or oldchecksum ~= newchecksum or not isfile(resultfile) then
+ local tobedone = false
+ if jobfiles.forcerun then
+ tobedone = true
if trace_run then
- report_run("processing file, changes in %a, processing forced",name)
+ report_run("processing file, changes in %a, %s",name,"processing forced")
end
+ end
+ if not tobedone and not oldchecksum then
+ tobedone = true
+ if trace_run then
+ report_run("processing file, changes in %a, %s",name,"no checksum yet")
+ end
+ end
+ if not tobedone and oldchecksum ~= newchecksum then
+ tobedone = true
+ if trace_run then
+ report_run("processing file, changes in %a, %s",name,"checksum mismatch")
+ end
+ end
+ if not tobedone and not isfile(resultfile) then
+ tobedone = true
+ if trace_run then
+ report_run("processing file, changes in %a, %s",name,"no result file")
+ end
+ end
+ if tobedone then
local ta = type(action)
if ta == "function" then
action(name)
diff --git a/tex/context/base/mkiv/grph-img.lua b/tex/context/base/mkiv/grph-img.lua
index 55ae5a3a0..cde9c8442 100644
--- a/tex/context/base/mkiv/grph-img.lua
+++ b/tex/context/base/mkiv/grph-img.lua
@@ -677,6 +677,7 @@ do
local pixel = false
local data = specification.data
local mask = specification.mask
+ local index = specification.index
if colorspace == 1 or colorspace == "gray" then
pixel = gray
colorspace = 1
@@ -712,6 +713,9 @@ do
mask[i] = setmetatableindex(gray)
end
end
+ if index then
+ index = setmetatableindex(pixel)
+ end
local specification = {
xsize = xsize,
ysize = ysize,
@@ -721,6 +725,7 @@ do
colorspace = colorspace,
data = data,
mask = mask,
+ index = index,
}
return specification
end
diff --git a/tex/context/base/mkiv/grph-rul.lua b/tex/context/base/mkiv/grph-rul.lua
index 194823161..b39fd6fdb 100644
--- a/tex/context/base/mkiv/grph-rul.lua
+++ b/tex/context/base/mkiv/grph-rul.lua
@@ -285,7 +285,7 @@ do
}
elseif method == 21 then
list = {
- "q", line, "w", xxmax, ymax, m, xmax, ymax, xmax, yymax, "y", xmin, yymax, "m",
+ "q", line, "w", xxmax, ymax, "m", xmax, ymax, xmax, yymax, "y", xmin, yymax, "m",
xmin, ymax, xxmin, ymax, "y", how, "Q",
}
elseif method == 22 then
diff --git a/tex/context/base/mkiv/l-pdfview.lua b/tex/context/base/mkiv/l-pdfview.lua
index 29dfaf81f..dc3888df5 100644
--- a/tex/context/base/mkiv/l-pdfview.lua
+++ b/tex/context/base/mkiv/l-pdfview.lua
@@ -162,7 +162,7 @@ function pdfview.close(...)
for i=1,#t do
local name = expander(fullname(t[i]))
if io.exists(name) then
- replace(closecall,{ filename = name })
+ runner(closecall,{ filename = name })
end
end
end
diff --git a/tex/context/base/mkiv/l-table.lua b/tex/context/base/mkiv/l-table.lua
index cffdcc23e..e82820386 100644
--- a/tex/context/base/mkiv/l-table.lua
+++ b/tex/context/base/mkiv/l-table.lua
@@ -287,6 +287,37 @@ local function sortedhash(t,cmp)
return nothing
end
+-- local function iterate(t,i)
+-- local i = i + 1
+-- if i <= t.n then
+-- local k = t[i]
+-- return i, k, t.t[k]
+-- end
+-- end
+--
+-- local function indexedhash(t,cmp)
+-- if t then
+-- local s
+-- if cmp then
+-- -- it would be nice if the sort function would accept a third argument (or nicer, an optional first)
+-- s = sortedhashkeys(t,function(a,b) return cmp(t,a,b) end)
+-- else
+-- s = sortedkeys(t) -- the robust one
+-- end
+-- local m = #s
+-- if m == 1 then
+-- return next, t
+-- elseif m > 0 then
+-- s.n = m
+-- s.t = t
+-- return iterate, s, 0
+-- end
+-- end
+-- return nothing
+-- end
+--
+-- -- for i, k, v in indexedhash(t) do print(k,v,s) end
+
table.sortedhash = sortedhash
table.sortedpairs = sortedhash -- obsolete
diff --git a/tex/context/base/mkiv/lpdf-img.lua b/tex/context/base/mkiv/lpdf-img.lua
index a299a023d..64ed642fa 100644
--- a/tex/context/base/mkiv/lpdf-img.lua
+++ b/tex/context/base/mkiv/lpdf-img.lua
@@ -26,6 +26,7 @@ local band, rshift = bit32.band, bit32.rshift
local loaddata = io.loaddata
local setmetatableindex = table.setmetatableindex
+local formatters = string.formatters
local streams = utilities.streams
local openstring = streams.openstring
@@ -41,6 +42,7 @@ local pdfconstant = lpdf.constant
local pdfstring = lpdf.string
local pdfflushstreamobject = lpdf.flushstreamobject
local pdfreference = lpdf.reference
+local pdfverbose = lpdf.verbose
local pdfmajorversion = lpdf.majorversion
local pdfminorversion = lpdf.minorversion
@@ -1117,37 +1119,66 @@ do
if what == "mask" then
d = specification.mask
s = 1
+ elseif what == "indexed" then
+ s = 1
+ elseif what == "index" then
+ d = specification.index
+ s = - s
end
- if s == 1 then
- for i=1,y do
- local r = d[i]
- for j=1,x do
- n = n + 1 ; t[n] = chars[r[j]]
+ if s > 0 then
+ if s == 1 then
+ for i=1,y do
+ local r = d[i]
+ for j=1,x do
+ n = n + 1 ; t[n] = chars[r[j]]
+ end
end
- end
- elseif s == 2 then
- for i=1,y do
- local r = d[i]
- for j=1,x do
- local c = r[j]
- n = n + 1 ; t[n] = chars[c[1]]
- n = n + 1 ; t[n] = chars[c[2]]
- n = n + 1 ; t[n] = chars[c[3]]
+ elseif s == 2 then
+ for i=1,y do
+ local r = d[i]
+ for j=1,x do
+ local c = r[j]
+ n = n + 1 ; t[n] = chars[c[1]]
+ n = n + 1 ; t[n] = chars[c[2]]
+ n = n + 1 ; t[n] = chars[c[3]]
+ end
+ end
+ elseif s == 3 then
+ for i=1,y do
+ local r = d[i]
+ for j=1,x do
+ local c = r[j]
+ n = n + 1 ; t[n] = chars[c[1]]
+ n = n + 1 ; t[n] = chars[c[2]]
+ n = n + 1 ; t[n] = chars[c[3]]
+ n = n + 1 ; t[n] = chars[c[4]]
+ end
end
end
- elseif s == 3 then
- for i=1,y do
- local r = d[i]
- for j=1,x do
- local c = r[j]
- n = n + 1 ; t[n] = chars[c[1]]
- n = n + 1 ; t[n] = chars[c[2]]
- n = n + 1 ; t[n] = chars[c[3]]
- n = n + 1 ; t[n] = chars[c[4]]
+ return concat(t)
+ else
+ local z = d[0] and 0 or 1
+ if s == -1 then
+ local f = formatters["%02X"]
+ for i=z,#d do
+ n = n + 1 ; t[n] = f(d[i])
+ end
+ elseif s == -2 then
+ local f = formatters["%02X%02X%02X"]
+ for i=z,#d do
+ local c = d[i]
+ n = n + 1 ; t[n] = f(c[1],c[2],c[3])
+ end
+ elseif s == -3 then
+ local f = formatters["%02X%02X%02X%02X"]
+ for i=z,#d do
+ local c = d[i]
+ n = n + 1 ; t[n] = f(c[1],c[2],c[3],c[4])
end
end
+ return "<" .. concat(t," ") .. ">"
end
- return concat(t)
+ return ""
end
function injectors.bitmap(specification)
@@ -1169,8 +1200,18 @@ do
colorspace = "DeviceCMYK"
end
local colordepth = (specification.colordepth or 2) == 16 or 8
- local content = pack(specification,"data")
+ local index = specification.index
+ local content = pack(specification,index and "indexed" or "data")
local mask = specification.mask
+ local colorspace = pdfconstant(colorspace)
+if index then
+ colorspace = pdfarray {
+ pdfconstant("Indexed"),
+ colorspace,
+ #index + (index[0] and 0 or -1), -- upper index
+ pdfverbose(pack(specification,"index"))
+ }
+end
local xobject = pdfdictionary {
Type = pdfconstant("XObject"),
Subtype = pdfconstant("Image"),
@@ -1178,7 +1219,7 @@ do
Width = xsize,
Height = ysize,
BitsPerComponent = colordepth,
- ColorSpace = pdfconstant(colorspace),
+ ColorSpace = colorspace,
Length = #content, -- specification.length
}
if mask then
diff --git a/tex/context/base/mkiv/lpdf-pde.lua b/tex/context/base/mkiv/lpdf-pde.lua
index 8c5c6ffc1..b159df24f 100644
--- a/tex/context/base/mkiv/lpdf-pde.lua
+++ b/tex/context/base/mkiv/lpdf-pde.lua
@@ -1062,92 +1062,96 @@ if images then do
local page = pdfdoc.pages[pagenumber or 1]
local pageinfo = querypdf(pdfdoc,pagenumber)
local contents = page.Contents
- local xref = pdfdoc.__xrefs__
- local copied = pdfdoc.__copied__
- if compact and lpdf_epdf.plugin then
- plugins = lpdf_epdf.plugin(pdfdoc,xref,copied,page)
- end
- local xobject = pdfdictionary {
- Type = pdfconstant("XObject"),
- Subtype = pdfconstant("Form"),
- FormType = 1,
- Group = copyobject(xref,copied,page,"Group"),
- LastModified = copyobject(xref,copied,page,"LastModified"),
- Metadata = copyobject(xref,copied,page,"Metadata"),
- PieceInfo = copyobject(xref,copied,page,"PieceInfo"),
- Resources = copyresources(pdfdoc,xref,copied,page),
- SeparationInfo = copyobject(xref,copied,page,"SeparationInfo"),
- } + attr
- if attributes then
- for k, v in expanded(attributes) do
- page[k] = v -- maybe nested
+ if contents then
+ local xref = pdfdoc.__xrefs__
+ local copied = pdfdoc.__copied__
+ if compact and lpdf_epdf.plugin then
+ plugins = lpdf_epdf.plugin(pdfdoc,xref,copied,page)
end
- end
- local content = ""
- local nolength = nil
- local ctype = contents.__type__
- -- we always recompress because image object streams can not be
- -- influenced (yet)
- if ctype == stream_object_code then
- if stripmarked then
- content = contents() -- uncompressed
- local stripped = lpdf_epdf.stripcontent(content)
- if stripped ~= content then
- -- report("%i bytes stripped on page %i",#content-#stripped,pagenumber or 1)
- content = stripped
+ local xobject = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Form"),
+ FormType = 1,
+ Group = copyobject(xref,copied,page,"Group"),
+ LastModified = copyobject(xref,copied,page,"LastModified"),
+ Metadata = copyobject(xref,copied,page,"Metadata"),
+ PieceInfo = copyobject(xref,copied,page,"PieceInfo"),
+ Resources = copyresources(pdfdoc,xref,copied,page),
+ SeparationInfo = copyobject(xref,copied,page,"SeparationInfo"),
+ } + attr
+ if attributes then
+ for k, v in expanded(attributes) do
+ page[k] = v -- maybe nested
end
- elseif recompress then
- content = contents() -- uncompressed
- else
- local Filter = copyobject(xref,copied,contents,"Filter")
- local Length = copyobject(xref,copied,contents,"Length")
- if Length and Filter then
- nolength = true
- xobject.Length = Length
- xobject.Filter = Filter
- content = contents(false) -- uncompressed
- else
+ end
+ local content = ""
+ local nolength = nil
+ local ctype = contents.__type__
+ -- we always recompress because image object streams can not be
+ -- influenced (yet)
+ if ctype == stream_object_code then
+ if stripmarked then
+ content = contents() -- uncompressed
+ local stripped = lpdf_epdf.stripcontent(content)
+ if stripped ~= content then
+ -- report("%i bytes stripped on page %i",#content-#stripped,pagenumber or 1)
+ content = stripped
+ end
+ elseif recompress then
content = contents() -- uncompressed
+ else
+ local Filter = copyobject(xref,copied,contents,"Filter")
+ local Length = copyobject(xref,copied,contents,"Length")
+ if Length and Filter then
+ nolength = true
+ xobject.Length = Length
+ xobject.Filter = Filter
+ content = contents(false) -- uncompressed
+ else
+ content = contents() -- uncompressed
+ end
end
+ elseif ctype == array_object_code then
+ content = { }
+ for i=1,#contents do
+ content[i] = contents[i]() -- uncompressed
+ end
+ content = concat(content," ")
end
- elseif ctype == array_object_code then
- content = { }
- for i=1,#contents do
- content[i] = contents[i]() -- uncompressed
+ -- still not nice: we double wrap now
+ plugins = nil
+ local rotation = pageinfo.rotation
+ local boundingbox = pageinfo.boundingbox
+ local transform = nil
+ if rotation == 90 then
+ transform = 3
+ elseif rotation == 180 then
+ transform = 2
+ elseif rotation == 270 then
+ transform = 1
+ elseif rotation > 1 and rotation < 4 then
+ transform = rotation
end
- content = concat(content," ")
- end
- -- still not nice: we double wrap now
- plugins = nil
- local rotation = pageinfo.rotation
- local boundingbox = pageinfo.boundingbox
- local transform = nil
- if rotation == 90 then
- transform = 3
- elseif rotation == 180 then
- transform = 2
- elseif rotation == 270 then
- transform = 1
- elseif rotation > 1 and rotation < 4 then
- transform = rotation
+ xobject.BBox = pdfarray {
+ boundingbox[1] * bpfactor,
+ boundingbox[2] * bpfactor,
+ boundingbox[3] * bpfactor,
+ boundingbox[4] * bpfactor,
+ }
+ -- maybe like bitmaps
+ return createimage { -- beware: can be a img.new or a dummy
+ bbox = boundingbox,
+ transform = transform,
+ nolength = nolength,
+ nobbox = true,
+ notype = true,
+ stream = content, -- todo: no compress, pass directly also length, filter etc
+ attr = xobject(),
+ kind = images.types.stream,
+ }
+ else
+ -- maybe report an error
end
- xobject.BBox = pdfarray {
- boundingbox[1] * bpfactor,
- boundingbox[2] * bpfactor,
- boundingbox[3] * bpfactor,
- boundingbox[4] * bpfactor,
- }
- -- maybe like bitmaps
- return createimage { -- beware: can be a img.new or a dummy
- bbox = boundingbox,
- transform = transform,
- nolength = nolength,
- nobbox = true,
- notype = true,
- stream = content, -- todo: no compress, pass directly also length, filter etc
- attr = xobject(),
- kind = images.types.stream,
- }
end
end
diff --git a/tex/context/base/mkiv/luat-fmt.lua b/tex/context/base/mkiv/luat-fmt.lua
index 86cf5cf9e..e56728e58 100644
--- a/tex/context/base/mkiv/luat-fmt.lua
+++ b/tex/context/base/mkiv/luat-fmt.lua
@@ -48,6 +48,9 @@ local function secondaryflags()
if arguments.ansi then
flags[#flags+1] = "--c:ansi"
end
+ if arguments.ansilog then
+ flags[#flags+1] = "--c:ansilog"
+ end
if arguments.strip then
flags[#flags+1] = "--c:strip"
end
diff --git a/tex/context/base/mkiv/mlib-ctx.mkiv b/tex/context/base/mkiv/mlib-ctx.mkiv
index 145cdb261..78a26ad1c 100644
--- a/tex/context/base/mkiv/mlib-ctx.mkiv
+++ b/tex/context/base/mkiv/mlib-ctx.mkiv
@@ -19,6 +19,8 @@
\registerctxluafile{mlib-lmp}{}
\registerctxluafile{mlib-int}{}
+\doifelsefileexists{mlib-cnt.lua}{\registerctxluafile{mlib-int}{}}{}
+
\unprotect
\protect \endinput
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua
index 80d893319..9e3802396 100644
--- a/tex/context/base/mkiv/mlib-lua.lua
+++ b/tex/context/base/mkiv/mlib-lua.lua
@@ -25,7 +25,6 @@ local report_script = logs.reporter("metapost","script")
local report_message = logs.reporter("metapost")
local trace_luarun = false trackers.register("metapost.lua",function(v) trace_luarun = v end)
-local trace_enabled = true
local be_tolerant = true directives.register("metapost.lua.tolerant", function(v) be_tolerant = v end)
@@ -134,55 +133,15 @@ end
do
- local buffer = { }
- local n = 0
- local max = 20 -- we reuse upto max
- local nesting = 0
- local runs = 0
-
- local function _f_()
- if trace_enabled and trace_luarun then
- local result = concat(buffer," ",1,n)
- if n > max then
- buffer = { } -- newtable(20,0)
- end
- n = 0
- report_luarun("%i: data: %s",nesting,result)
- return result
- else
- if n == 0 then
- return "" -- can be nil
- end
- local result
- if n == 1 then
- result = buffer[1]
- else
- result = concat(buffer," ",1,n)
- end
- if n > max then
- buffer = { } -- newtable(20,0)
- end
- n = 0
- return result
- end
- end
-
- mp._f_ = _f_ -- convenient to have it in a top module
- aux.flush = _f_
-
- ----- f_code = formatters["%s return mp._f_()"]
+ -- serializers
local f_integer = formatters["%i"]
+ local f_numeric = formatters["%F"]
-- no %n as that can produce -e notation and that is not so nice for scaled butmaybe we
-- should then switch between ... i.e. make a push/pop for the formatters here ... not now.
- -- local f_numeric = formatters["%n"] -- maybe %N
- -- local f_pair = formatters["(%n,%n)"]
- -- local f_ctrl = formatters["(%n,%n) .. controls (%n,%n) and (%n,%n)"]
- -- local f_triplet = formatters["(%n,%n,%n)"]
- -- local f_quadruple = formatters["(%n,%n,%n,%n)"]
-
+ local f_integer = formatters["%i"]
local f_numeric = formatters["%F"]
local f_pair = formatters["(%F,%F)"]
local f_ctrl = formatters["(%F,%F) .. controls (%F,%F) and (%F,%F)"]
@@ -206,6 +165,184 @@ do
mp.cleaned = function(s) return lpegmatch(p,s) or s end
+ -- management
+
+ -- sometimes we gain (e.g. .5 sec on the sync test)
+
+ local cache = table.makeweak()
+
+ local runscripts = { }
+ local runnames = { }
+ local nofscripts = 0
+
+ function metapost.registerscript(name,f)
+ nofscripts = nofscripts + 1
+ if f then
+ runscripts[nofscripts] = f
+ runnames[name] = nofscripts
+ else
+ runscripts[nofscripts] = name
+ end
+ return nofscripts
+ end
+
+ function metapost.scriptindex(name)
+ return runnames[name] or 0
+ end
+
+ -- The gbuffer sharing and such is not really needed now but make a dent when
+ -- we have a high volume of simpel calls (loops) so we keep it around for a
+ -- while.
+
+ local nesting = 0
+ local runs = 0
+ local gbuffer = { }
+ local buffer = gbuffer
+ local n = 0
+
+ local function mpdirect1(a)
+ n = n + 1 buffer[n] = a
+ end
+ local function mpdirect2(a,b)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ end
+ local function mpdirect3(a,b,c)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ end
+ local function mpdirect4(a,b,c,d)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ n = n + 1 buffer[n] = d
+ end
+ local function mpdirect5(a,b,c,d,e)
+ n = n + 1 buffer[n] = a
+ n = n + 1 buffer[n] = b
+ n = n + 1 buffer[n] = c
+ n = n + 1 buffer[n] = d
+ n = n + 1 buffer[n] = e
+ end
+
+ local function mpflush(separator)
+ buffer[1] = concat(buffer,separator or "",1,n)
+ n = 1
+ end
+
+ function metapost.runscript(code)
+ nesting = nesting + 1
+ runs = runs + 1
+
+ local index = type(code) == "number"
+ local f
+ local result
+
+ if index then
+ f = runscripts[code]
+ if not f then
+ report_luarun("%i: bad index: %s",nesting,code)
+ elseif trace_luarun then
+ report_luarun("%i: index: %i",nesting,code)
+ end
+ else
+ if trace_luarun then
+ report_luarun("%i: code: %s",nesting,code)
+ end
+ f = cache[code]
+ if not f then
+ f = loadstring("return " .. code)
+ if f then
+ cache[code] = f
+ elseif be_tolerant then
+ f = loadstring(code)
+ if f then
+ cache[code] = f
+ end
+ end
+ end
+ end
+
+ -- returning nil is more efficient and a signal not to scan in mp
+
+ if f then
+
+ local lbuffer, ln
+
+ if nesting == 1 then
+ buffer = gbuffer
+ n = 0
+ else
+ lbuffer = buffer
+ ln = n
+ buffer = { }
+ n = 0
+ end
+
+ result = f()
+
+ if result then
+ local t = type(result)
+ if t == "number" then
+ result = f_numeric(result)
+ elseif t == "table" then
+ result = concat(result) -- no spaces here
+ else
+ result = tostring(result)
+ end
+ if trace_luarun then
+ report_luarun("%i: %s result: %s",nesting,t,result)
+ end
+ elseif n == 0 then
+ result = ""
+ if trace_luarun then
+ report_luarun("%i: no buffered result",nesting)
+ end
+ elseif n == 1 then
+ result = buffer[1]
+ if trace_luarun then
+ report_luarun("%i: 1 buffered result: %s",nesting,result)
+ end
+ else
+ -- the space is why we sometimes have collectors
+ if nesting == 1 then
+ result = concat(buffer," ",1,n)
+ if n > 500 or #result > 10000 then
+ gbuffer = { } -- newtable(20,0)
+ lbuffer = gbuffer
+ end
+ else
+ result = concat(buffer," ")
+ end
+ if trace_luarun then
+ report_luarun("%i: %i buffered results: %s",nesting,n,result)
+ end
+ end
+
+ if nesting == 1 then
+ n = 0
+ else
+ buffer = lbuffer
+ n = ln
+ end
+
+ else
+ report_luarun("%i: no result, invalid code: %s",nesting,code)
+ result = ""
+ end
+
+ nesting = nesting - 1
+
+ return result
+ end
+
+ function metapost.nofscriptruns()
+ return runs
+ end
+
+ -- writers
+
local function mpp(value)
n = n + 1
local t = type(value)
@@ -482,6 +619,13 @@ do
end
end
+ aux.direct = mpdirect1
+ aux.direct1 = mpdirect1
+ aux.direct2 = mpdirect2
+ aux.direct3 = mpdirect3
+ aux.direct4 = mpdirect4
+ aux.flush = mpflush
+
aux.print = mpprint
aux.vprint = mpvprint
aux.boolean = mpboolean
@@ -503,107 +647,74 @@ do
aux.quoted = mpquoted
aux.transform = mptransform
- -- we need access to the variables
-
- function metapost.nofscriptruns()
- return runs
- end
-
- -- sometimes we gain (e.g. .5 sec on the sync test)
-
- local cache = table.makeweak()
-
- local runscripts = { }
- local runnames = { }
- local nofscripts = 0
-
- function metapost.registerscript(name,f)
- nofscripts = nofscripts + 1
- if f then
- runscripts[nofscripts] = f
- runnames[name] = nofscripts
- else
- runscripts[nofscripts] = name
- end
- return nofscripts
- end
-
- function metapost.scriptindex(name)
- return runnames[name] or 0
- end
+ -- for the moment
- function metapost.runscript(code)
- nesting = nesting + 1
- local index = type(code) == "number"
- local trace = trace_enabled and trace_luarun
- runs = runs + 1
- local f
- if index then
- f = runscripts[code]
- if not f then
- report_luarun("%i: bad index: %s",nesting,code)
- elseif trace then
- report_luarun("%i: index: %i",nesting,code)
+ local function mpdraw(lines,list) -- n * 4
+ if list then
+ local c = #lines
+ for i=1,c do
+ local ci = lines[i]
+ local ni = #ci
+ n = n + 1 buffer[n] = i < c and "d(" or "D("
+ for j=1,ni,2 do
+ local l = j + 1
+ n = n + 1 buffer[n] = ci[j]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = ci[l]
+ n = n + 1 buffer[n] = l < ni and ")--(" or ");"
+ end
end
else
- if trace then
- report_luarun("%i: code: %s",nesting,code)
- end
- f = cache[code]
- if not f then
- f = loadstring(code .. " return mp._f_()")
- if f then
- cache[code] = f
- elseif be_tolerant then
- f = loadstring(code)
- if f then
- cache[code] = f
- end
- end
+ local l = #lines
+ local m = l - 4
+ for i=1,l,4 do
+ n = n + 1 buffer[n] = i < m and "d(" or "D("
+ n = n + 1 buffer[n] = lines[i]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+1]
+ n = n + 1 buffer[n] = ")--("
+ n = n + 1 buffer[n] = lines[i+2]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+3]
+ n = n + 1 buffer[n] = ");"
end
end
+ end
- -- returning nil is more efficient and a signel not to scan in mp
-
- if f then
- local _buffer_ = buffer
- local _n_ = n
- buffer = { }
- n = 0
- local result = f()
- if index and not result then
- result = _f_()
- end
- if result then
- local t = type(result)
- if t == "number" then
- result = f_numeric(result)
- elseif t ~= "string" then
- result = tostring(result)
+ local function mpfill(lines,list)
+ if list then
+ local c = #lines
+ for i=1,c do
+ local ci = lines[i]
+ local ni = #ci
+ n = n + 1 buffer[n] = i < c and "f(" or "F("
+ for j=1,ni,2 do
+ local l = j + 1
+ n = n + 1 buffer[n] = ci[j]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = ci[l]
+ n = n + 1 buffer[n] = l < ni and ")--(" or ")--C;"
end
- if trace then
- if #result == 0 then
- report_luarun("%i: no result",nesting)
- else
- report_luarun("%i: result: %s",nesting,result)
- end
- end
- buffer = _buffer_
- n = _n_
- nesting = nesting - 1
- return result
- elseif trace then
- report_luarun("%i: no result",nesting)
end
- buffer, n = _buffer_, _n_
else
- report_luarun("%i: no result, invalid code: %s",nesting,code)
+ local l = #lines
+ local m = l - 4
+ for i=1,l,4 do
+ n = n + 1 buffer[n] = i < m and "f(" or "F("
+ n = n + 1 buffer[n] = lines[i]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+1]
+ n = n + 1 buffer[n] = ")--("
+ n = n + 1 buffer[n] = lines[i+2]
+ n = n + 1 buffer[n] = ","
+ n = n + 1 buffer[n] = lines[i+3]
+ n = n + 1 buffer[n] = ")--C;"
+ end
end
- nesting = nesting - 1
- return ""
end
- -- for the moment
+ aux.draw = mpdraw
+ aux.fill = mpfill
for k, v in next, aux do mp[k] = v end
@@ -1092,3 +1203,72 @@ do
end
end
+
+function mp.flatten(t)
+ local tn = #t
+
+ local t1 = t[1]
+ local t2 = t[2]
+ local t3 = t[3]
+ local t4 = t[4]
+
+ for i=1,tn-5,2 do
+ local t5 = t[i+4]
+ local t6 = t[i+5]
+ if t1 == t3 and t3 == t5 and ((t2 <= t4 and t4 <= t6) or (t6 <= t4 and t4 <= t2)) then
+ t[i+3] = t2
+ t4 = t2
+ t[i] = false
+ t[i+1] = false
+ elseif t2 == t4 and t4 == t6 and ((t1 <= t3 and t3 <= t5) or (t5 <= t3 and t3 <= t1)) then
+ t[i+2] = t1
+ t3 = t1
+ t[i] = false
+ t[i+1] = false
+ end
+ t1 = t3
+ t2 = t4
+ t3 = t5
+ t4 = t6
+ end
+
+ -- remove duplicates
+
+ local t1 = t[1]
+ local t2 = t[2]
+ for i=1,tn-2,2 do
+ local t3 = t[i+2]
+ local t4 = t[i+3]
+ if t1 == t3 and t2 == t4 then
+ t[i] = false
+ t[i+1] = false
+ end
+ t1 = t3
+ t2 = t4
+ end
+
+ -- move coordinates
+
+ local m = 0
+ for i=1,tn,2 do
+ if t[i] then
+ m = m + 1 t[m] = t[i]
+ m = m + 1 t[m] = t[i+1]
+ end
+ end
+
+ -- prune the table (not gc'd)
+
+ for i=tn,m+1,-1 do
+ t[i] = nil
+ end
+
+ -- safeguard so that we have at least one segment
+
+ if m == 2 then
+ t[3] = t[1]
+ t[4] = t[2]
+ end
+
+end
+
diff --git a/tex/context/base/mkiv/mlib-pdf.lua b/tex/context/base/mkiv/mlib-pdf.lua
index 92fde5e13..65f3b2016 100644
--- a/tex/context/base/mkiv/mlib-pdf.lua
+++ b/tex/context/base/mkiv/mlib-pdf.lua
@@ -400,6 +400,7 @@ function metapost.flush(specification,result)
local linecap = -1
local linejoin = -1
local dashed = false
+local linewidth = false
local llx = properties.llx
local lly = properties.lly
local urx = properties.urx
@@ -527,7 +528,10 @@ function metapost.flush(specification,result)
if pen then
if pen.type == "elliptical" then
transformed, penwidth = pen_characteristics(original) -- boolean, value
+if penwidth ~= linewidth then
result[#result+1] = f_w(penwidth) -- todo: only if changed
+ linewidth = penwidth
+end
if objecttype == "fill" then
objecttype = "both"
end
@@ -614,6 +618,7 @@ function metapost.flush(specification,result)
if object.grouped then
-- can be qQ'd so changes can end up in groups
miterlimit, linecap, linejoin, dashed = -1, -1, -1, "" -- was false
+linewidth = false
end
end
end
diff --git a/tex/context/base/mkiv/mlib-pdf.mkxl b/tex/context/base/mkiv/mlib-pdf.mkxl
index 113dfe129..763e7ecdd 100644
--- a/tex/context/base/mkiv/mlib-pdf.mkxl
+++ b/tex/context/base/mkiv/mlib-pdf.mkxl
@@ -58,16 +58,14 @@
\global\MPury \the\MPury
\relax}}
-% \unexpanded\def\repositionMPboxindeed
-% {\setbox\MPbox\hpack\bgroup
-% \kern-\MPllx
-% \raise-\MPlly
-% \box\MPbox
-% \egroup}
+% we need to combine these
\unexpanded\def\repositionMPboxindeed
- {\boxxmove\MPbox-\MPllx
- \boxymove\MPbox-\MPlly}
+ {\setbox\MPbox\hpack\bgroup
+ \kern-\MPllx
+ \raise-\MPlly
+ \box\MPbox
+ \egroup}
\unexpanded\def\repositionMPbox
{\ifzeropt\MPllx
@@ -80,20 +78,22 @@
\repositionMPboxindeed
\fi}
-% \unexpanded\def\finalizeMPbox
-% {\repositionMPbox
-% \setbox\MPbox\vpack to \MPheight\bgroup
-% \vfill
-% \hsize\MPwidth
-% \smashbox\MPbox
-% \box\MPbox
-% \egroup
-% \wd\MPbox\MPwidth
-% \ht\MPbox\MPheight}
-
\unexpanded\def\finalizeMPbox
{\repositionMPbox
- \boxyoffset\MPbox\dimexpr\boxyoffset\MPbox-\MPheight\relax
+ \setbox\MPbox\vpack to \MPheight\bgroup
+ \vfill
+ \hsize\MPwidth
+ \smashbox\MPbox
+ \box\MPbox
+ \egroup
+ \wd\MPbox\MPwidth
+ \ht\MPbox\MPheight}
+
+% combined
+
+\unexpanded\def\finalizeMPbox
+ {\boxxoffset\MPbox-\MPllx\relax
+ \boxyoffset\MPbox\dimexpr\boxyoffset\MPbox-\MPheight-\MPlly\relax
\wd\MPbox\MPwidth
\ht\MPbox\MPheight}
diff --git a/tex/context/base/mkiv/mlib-scn.lua b/tex/context/base/mkiv/mlib-scn.lua
index a7c1924eb..ec0f7397b 100644
--- a/tex/context/base/mkiv/mlib-scn.lua
+++ b/tex/context/base/mkiv/mlib-scn.lua
@@ -424,6 +424,40 @@ local function hasparameter()
end
end
+local function hasoption()
+ local list, n = collectnames()
+ if n > 1 then
+ local v = namespaces
+ if n > 2 then
+ for i=1,n-1 do
+ local l = list[i]
+ local vl = v[l]
+ if vl == nil then
+ return mpboolean(false)
+ end
+ v = vl
+ end
+ else
+ v = v[list[1]]
+ end
+ if type(v) == "string" then
+ -- no caching .. slow anyway
+ local o = list[n]
+ if v == o then
+ return mpboolean(true)
+ end
+ for vv in gmatch(v,"[^%s,]+") do
+ for oo in gmatch(o,"[^%s,]+") do
+ if vv == oo then
+ return mpboolean(true)
+ end
+ end
+ end
+ end
+ end
+ return mpboolean(false)
+end
+
local function getparameterdefault()
local list, n = collectnames()
local v = namespaces
@@ -620,6 +654,7 @@ metapost.registerscript("getparameters", getparameters)
metapost.registerscript("applyparameters", applyparameters)
metapost.registerscript("presetparameters", presetparameters)
metapost.registerscript("hasparameter", hasparameter)
+metapost.registerscript("hasoption", hasoption)
metapost.registerscript("getparameter", getparameter)
metapost.registerscript("getparameterdefault", getparameterdefault)
metapost.registerscript("getparametercount", getparametercount)
@@ -645,7 +680,7 @@ function metapost.getparameter(list)
end
function metapost.getparameterset(namespace)
- return namespaces[namespace]
+ return namespace and namespaces[namespace] or namespaces
end
-- goodies
diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua
index eb5cc4f08..b652e4d44 100644
--- a/tex/context/base/mkiv/mult-fun.lua
+++ b/tex/context/base/mkiv/mult-fun.lua
@@ -137,7 +137,7 @@ return {
"passvariable", "passarrayvariable", "tostring", "topair", "format", "formatted", "quotation", "quote",
"startpassingvariable", "stoppassingvariable",
--
- "eofill", "eoclip", "nofill", "fillup", "eofillup",
+ "eofill", "eoclip", "nofill", "fillup", "eofillup", "nodraw",
"area",
--
"addbackground",
diff --git a/tex/context/base/mkiv/pack-bck.mkvi b/tex/context/base/mkiv/pack-bck.mkvi
index a87bc6994..6cbe281d9 100644
--- a/tex/context/base/mkiv/pack-bck.mkvi
+++ b/tex/context/base/mkiv/pack-bck.mkvi
@@ -105,6 +105,11 @@
\strut
\vskip-2\lineheight
\strut
+ % safeguard added
+ \ifdim\dimexpr\pagetotal+2\lineheight\relax>\pagegoal
+ \page
+ \fi
+ % till here
\egroup
\dimen2\leftskip % new **
\forgetall
diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv
index e85891680..8732c7e6b 100644
--- a/tex/context/base/mkiv/pack-rul.mkiv
+++ b/tex/context/base/mkiv/pack-rul.mkiv
@@ -255,7 +255,7 @@
\fi}
\def\pack_framed_filled_box_round
- {\frule
+ {\raise\d_framed_target_dp\hpack{\frule
type fill
width \d_framed_target_wd
height \d_framed_target_ht
@@ -263,7 +263,7 @@
line \d_framed_linewidth
radius \p_framed_backgroundradius\space
corner {\p_framed_backgroundcorner}
- \relax}
+ \relax}}
\def\pack_framed_stroked_box
{\edef\p_framed_framecorner{\framedparameter\c!framecorner}%
@@ -284,14 +284,14 @@
% \pack_framed_stroked_box_normal % later
\def\pack_framed_stroked_box_round
- {\frule
+ {\raise\d_framed_target_dp\hpack{\frule
width \d_framed_target_wd
height \d_framed_target_ht
depth \d_framed_target_dp
line \d_framed_linewidth
radius \p_framed_frameradius\space
- corner {\p_framed_backgroundcorner}
- \relax}
+ corner {\p_framed_framecorner}
+ \relax}}
% a lot of weird corners
%
diff --git a/tex/context/base/mkiv/pack-rul.mkxl b/tex/context/base/mkiv/pack-rul.mkxl
index d2818b4df..4304430d1 100644
--- a/tex/context/base/mkiv/pack-rul.mkxl
+++ b/tex/context/base/mkiv/pack-rul.mkxl
@@ -256,7 +256,7 @@
\fi}
\def\pack_framed_filled_box_round
- {\frule
+ {\raise\d_framed_target_dp\hpack{\frule
type fill
width \d_framed_target_wd
height \d_framed_target_ht
@@ -264,7 +264,7 @@
line \d_framed_linewidth
radius \p_framed_backgroundradius\space
corner {\p_framed_backgroundcorner}
- \relax}
+ \relax}}
\def\pack_framed_stroked_box
{\edef\p_framed_framecorner{\framedparameter\c!framecorner}%
@@ -285,14 +285,14 @@
% \pack_framed_stroked_box_normal % later
\def\pack_framed_stroked_box_round
- {\frule
+ {\raise\d_framed_target_dp\hpack{\frule
width \d_framed_target_wd
height \d_framed_target_ht
depth \d_framed_target_dp
line \d_framed_linewidth
radius \p_framed_frameradius\space
- corner {\p_framed_backgroundcorner}
- \relax}
+ corner {\p_framed_framecorner}
+ \relax}}
% a lot of weird corners
%
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 13031a23c..274a5a155 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 640a7f161..f2e008447 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/syst-ini.mkiv b/tex/context/base/mkiv/syst-ini.mkiv
index eaea7e4cc..63e1cebab 100644
--- a/tex/context/base/mkiv/syst-ini.mkiv
+++ b/tex/context/base/mkiv/syst-ini.mkiv
@@ -710,7 +710,7 @@
\tracinggroups \plusone
\tracingifs \plusone
\tracingscantokens\plusone
- \tracingnesting \plusone
+ \tracingnesting \plustwo
\tracingassigns \plustwo}
\normalprotected\def\loggingall
diff --git a/tex/context/base/mkiv/syst-ini.mkxl b/tex/context/base/mkiv/syst-ini.mkxl
index 11f82dd34..22b3ba039 100644
--- a/tex/context/base/mkiv/syst-ini.mkxl
+++ b/tex/context/base/mkiv/syst-ini.mkxl
@@ -682,7 +682,7 @@
\tracinggroups \plusone
\tracingifs \plusone
\tracingscantokens\plusone
- \tracingnesting \plusone
+ \tracingnesting \plustwo
\tracingassigns \plustwo}
\normalprotected\def\loggingall
diff --git a/tex/context/base/mkiv/trac-log.lua b/tex/context/base/mkiv/trac-log.lua
index fd7b5016a..b35e53f2e 100644
--- a/tex/context/base/mkiv/trac-log.lua
+++ b/tex/context/base/mkiv/trac-log.lua
@@ -126,6 +126,9 @@ if runningtex and texio then
if v == "--ansi" or v == "--c:ansi" then
variant = "ansi"
break
+ elseif v == "--ansilog" or v == "--c:ansilog" then
+ variant = "ansilog"
+ break
end
end
end
@@ -246,6 +249,11 @@ if runningtex and texio then
}
}
+ variants.ansilog = {
+ formats = variants.ansi.formats,
+ targets = variants.default.targets,
+ }
+
logs.flush = io.flush
writer = function(...)
@@ -394,7 +402,7 @@ if runningtex and texio then
subdirect_nop = f.subdirect_nop
status_yes = f.status_yes
status_nop = f.status_nop
- if variant == "ansi" then
+ if variant == "ansi" or variant == "ansilog" then
useluawrites() -- because tex escapes ^^, not needed in lmtx
end
settarget(whereto)
diff --git a/tex/context/base/mkiv/trac-set.lua b/tex/context/base/mkiv/trac-set.lua
index 6311d6382..4a22282a8 100644
--- a/tex/context/base/mkiv/trac-set.lua
+++ b/tex/context/base/mkiv/trac-set.lua
@@ -278,7 +278,7 @@ function setters.new(name) -- we could use foo:bar syntax (but not used that oft
disable = function(...) disable (setter,...) end,
reset = function(...) reset (setter,...) end, -- can be dangerous
register = function(...) register(setter,...) end,
- list = function(...) list (setter,...) end,
+ list = function(...) return list (setter,...) end,
show = function(...) show (setter,...) end,
default = function(...) return default (setter,...) end,
value = function(...) return value (setter,...) end,
diff --git a/tex/context/base/mkiv/util-tab.lua b/tex/context/base/mkiv/util-tab.lua
index f970d8ace..410292ca8 100644
--- a/tex/context/base/mkiv/util-tab.lua
+++ b/tex/context/base/mkiv/util-tab.lua
@@ -341,7 +341,21 @@ function table.fastserialize(t,prefix) -- todo, move local function out
m = m + 1
r[m] = "{"
if n > 0 then
- for i=0,n do
+ local v = t[0]
+ if v then
+ local tv = type(v)
+ if tv == "string" then
+ m = m + 1 r[m] = f_indexed_string(0,v)
+ elseif tv == "number" then
+ m = m + 1 r[m] = f_indexed_number(0,v)
+ elseif tv == "table" then
+ m = m + 1 r[m] = f_indexed_table(0)
+ fastserialize(v)
+ elseif tv == "boolean" then
+ m = m + 1 r[m] = f_indexed_boolean(0,v)
+ end
+ end
+ for i=1,n do
local v = t[i]
local tv = type(v)
if tv == "string" then
@@ -355,6 +369,8 @@ function table.fastserialize(t,prefix) -- todo, move local function out
end
end
end
+ -- hm, can't we avoid this ... lua should have a way to check if there
+ -- is a hash part
for k, v in next, t do
local tk = type(k)
if tk == "number" then
@@ -411,7 +427,7 @@ function table.deserialize(str)
return code
end
--- inspect(table.fastserialize { a = 1, b = { 4, { 5, 6 } }, c = { d = 7, e = 'f"g\nh' } })
+-- inspect(table.fastserialize { a = 1, b = { [0]=4, { 5, 6 } }, c = { d = 7, e = 'f"g\nh' } })
function table.load(filename,loader)
if filename then
diff --git a/tex/context/base/mkiv/util-tpl.lua b/tex/context/base/mkiv/util-tpl.lua
index 57d7df3a9..318f2efc3 100644
--- a/tex/context/base/mkiv/util-tpl.lua
+++ b/tex/context/base/mkiv/util-tpl.lua
@@ -20,6 +20,8 @@ local tostring, next = tostring, next
local format, sub, byte = string.format, string.sub, string.byte
local P, C, R, Cs, Cc, Carg, lpegmatch, lpegpatterns = lpeg.P, lpeg.C, lpeg.R, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match, lpeg.patterns
+local formatters = string.formatters
+
-- todo: make installable template.new
local replacer
@@ -133,34 +135,42 @@ local function replaceoptional(l,m,r,t,how,recurse)
return v and v ~= "" and lpegmatch(replacer,r,1,t,how or "lua",recurse or false) or ""
end
-local single = P("%") -- test %test% test : resolves test
-local double = P("%%") -- test 10%% test : %% becomes %
-local lquoted = P("%[") -- test '%[test]%' test : resolves to test with escaped "'s
-local rquoted = P("]%") --
-local lquotedq = P("%(") -- test %(test)% test : resolves to 'test' with escaped "'s
-local rquotedq = P(")%") --
-
-local escape = double / '%%'
-local nosingle = single / ''
-local nodouble = double / ''
-local nolquoted = lquoted / ''
-local norquoted = rquoted / ''
-local nolquotedq = lquotedq / ''
-local norquotedq = rquotedq / ''
-
-local noloptional = P("%?") / ''
-local noroptional = P("?%") / ''
-local nomoptional = P(":") / ''
-
-
-local args = Carg(1) * Carg(2) * Carg(3)
-local key = nosingle * ((C((1-nosingle )^1) * args) / replacekey ) * nosingle
-local quoted = nolquotedq * ((C((1-norquotedq )^1) * args) / replacekeyquoted ) * norquotedq
-local unquoted = nolquoted * ((C((1-norquoted )^1) * args) / replacekeyunquoted) * norquoted
-local optional = noloptional * ((C((1-nomoptional)^1) * nomoptional * C((1-noroptional)^1) * args) / replaceoptional) * noroptional
-local any = P(1)
+local function replaceformatted(l,m,r,t,how,recurse)
+ local v = t[r]
+ return v and formatters[l](v)
+end
- replacer = Cs((unquoted + quoted + escape + optional + key + any)^0)
+local single = P("%") -- test %test% test : resolves test
+local double = P("%%") -- test 10%% test : %% becomes %
+local lquoted = P("%[") -- test '%[test]%' test : resolves to test with escaped "'s
+local rquoted = P("]%") --
+local lquotedq = P("%(") -- test %(test)% test : resolves to 'test' with escaped "'s
+local rquotedq = P(")%") --
+
+local escape = double / '%%'
+local nosingle = single / ''
+local nodouble = double / ''
+local nolquoted = lquoted / ''
+local norquoted = rquoted / ''
+local nolquotedq = lquotedq / ''
+local norquotedq = rquotedq / ''
+
+local nolformatted = P(":") / "%%"
+local norformatted = P(":") / ""
+
+local noloptional = P("%?") / ''
+local noroptional = P("?%") / ''
+local nomoptional = P(":") / ''
+
+local args = Carg(1) * Carg(2) * Carg(3)
+local key = nosingle * ((C((1-nosingle)^1) * args) / replacekey) * nosingle
+local quoted = nolquotedq * ((C((1-norquotedq)^1) * args) / replacekeyquoted) * norquotedq
+local unquoted = nolquoted * ((C((1-norquoted)^1) * args) / replacekeyunquoted) * norquoted
+local optional = noloptional * ((C((1-nomoptional)^1) * nomoptional * C((1-noroptional)^1) * args) / replaceoptional) * noroptional
+local formatted = nosingle * ((Cs(nolformatted * (1-norformatted )^1) * norformatted * C((1-nosingle)^1) * args) / replaceformatted) * nosingle
+local any = P(1)
+
+ replacer = Cs((unquoted + quoted + formatted + escape + optional + key + any)^0)
local function replace(str,mapping,how,recurse)
if mapping and str then
@@ -179,6 +189,8 @@ end
-- print(replace([[test %[x]% test]],{ x = [[a "x"  a]]}))
-- print(replace([[test %(x)% test]],{ x = [[a "x"  a]]}))
-- print(replace([[convert %?x: -x "%x%" ?% %?y: -y "%y%" ?%]],{ x = "yes" }))
+-- print(replace("test %:0.3N:x% test",{ x = 123.45 }))
+-- print(replace("test %:0.3N:x% test",{ x = 12345 }))
templates.replace = replace