summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fonts/afm/hoekwater/context/contnav.afm88
-rw-r--r--fonts/misc/xetex/fontmapping/context/tlig.map (renamed from fonts/misc/xetex/fontmapping/tlig.map)0
-rw-r--r--fonts/misc/xetex/fontmapping/context/tlig.tec (renamed from fonts/misc/xetex/fontmapping/tlig.tec)bin199 -> 199 bytes
-rw-r--r--metapost/context/base/mp-grph.mp24
-rw-r--r--scripts/context/lua/mtx-context.lua10
-rw-r--r--scripts/context/lua/mtxrun.lua18
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua18
-rw-r--r--scripts/context/stubs/unix/mtxrun18
-rw-r--r--tex/context/base/anch-pgr.mkiv4
-rw-r--r--tex/context/base/buff-ver.lua195
-rw-r--r--tex/context/base/buff-ver.mkiv5
-rw-r--r--tex/context/base/cldf-ini.lua24
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/file-job.lua2
-rw-r--r--tex/context/base/file-res.lua1
-rw-r--r--tex/context/base/font-con.lua2
-rw-r--r--tex/context/base/font-gds.lua7
-rw-r--r--tex/context/base/font-ini.mkiv8
-rw-r--r--tex/context/base/lxml-tex.lua4
-rw-r--r--tex/context/base/math-dim.lua6
-rw-r--r--tex/context/base/math-frc.mkiv4
-rw-r--r--tex/context/base/meta-ini.mkiv4
-rw-r--r--tex/context/base/mlib-pdf.lua34
-rw-r--r--tex/context/base/mlib-pdf.mkiv41
-rw-r--r--tex/context/base/mlib-pps.lua60
-rw-r--r--tex/context/base/mlib-pps.mkiv2
-rw-r--r--tex/context/base/mlib-run.lua4
-rw-r--r--tex/context/base/node-aux.lua2
-rw-r--r--tex/context/base/node-mig.lua20
-rw-r--r--tex/context/base/node-mig.mkiv2
-rw-r--r--tex/context/base/phys-dim.lua5
-rw-r--r--tex/context/base/spac-ver.mkiv3
-rw-r--r--tex/context/base/status-files.pdfbin23774 -> 23768 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin162103 -> 162156 bytes
-rw-r--r--tex/context/base/strc-ini.lua37
-rw-r--r--tex/context/base/strc-tag.lua28
-rw-r--r--tex/context/base/util-prs.lua18
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua4
41 files changed, 519 insertions, 191 deletions
diff --git a/fonts/afm/hoekwater/context/contnav.afm b/fonts/afm/hoekwater/context/contnav.afm
index 1c78d99bc..83102282f 100644
--- a/fonts/afm/hoekwater/context/contnav.afm
+++ b/fonts/afm/hoekwater/context/contnav.afm
@@ -1,44 +1,44 @@
-StartFontMetrics 2.0
-Comment AFM Generated by Ghostscript/pf2afm
-FontName ContextNavigation
-FullName ContextNavigation
-FamilyName ContextNavigation
-Weight Medium
-Notice Copyright (c) Pragma, Taco Hoekwater, 1998. All rights reserved.
-ItalicAngle 0
-IsFixedPitch false
-UnderlinePosition -100
-UnderlineThickness 50
-Version 1.0
-EncodingScheme FontSpecific
-FontBBox -25 -64 780 602
-StartCharMetrics 27
-C 1 ; WX 507 ; N char01 ; B -18 -64 532 564 ;
-C 2 ; WX 507 ; N char02 ; B -25 -64 525 564 ;
-C 3 ; WX 625 ; N char03 ; B -25 -64 650 564 ;
-C 4 ; WX 625 ; N char04 ; B -25 -64 650 564 ;
-C 5 ; WX 755 ; N char05 ; B -20 -64 780 564 ;
-C 6 ; WX 755 ; N char06 ; B -25 -64 775 564 ;
-C 7 ; WX 577 ; N char07 ; B -25 -25 602 602 ;
-C 8 ; WX 192 ; N char08 ; B -25 -25 217 602 ;
-C 9 ; WX 531 ; N char09 ; B -25 -25 556 602 ;
-C 101 ; WX 507 ; N char65 ; B -18 -64 532 564 ;
-C 102 ; WX 507 ; N char66 ; B -25 -64 525 564 ;
-C 103 ; WX 625 ; N char67 ; B -25 -64 650 564 ;
-C 104 ; WX 625 ; N char68 ; B -25 -64 650 564 ;
-C 105 ; WX 755 ; N char69 ; B -20 -64 780 564 ;
-C 106 ; WX 755 ; N char6a ; B -25 -64 775 564 ;
-C 107 ; WX 577 ; N char6b ; B -25 -25 602 602 ;
-C 108 ; WX 192 ; N char6c ; B -25 -25 217 602 ;
-C 109 ; WX 531 ; N char6d ; B -25 -25 556 602 ;
-C 201 ; WX 507 ; N charc9 ; B -18 -64 532 564 ;
-C 202 ; WX 507 ; N charca ; B -25 -64 525 564 ;
-C 203 ; WX 625 ; N charcb ; B -25 -64 650 564 ;
-C 204 ; WX 625 ; N charcc ; B -25 -64 650 564 ;
-C 205 ; WX 755 ; N charcd ; B -20 -64 780 564 ;
-C 206 ; WX 755 ; N charce ; B -25 -64 775 564 ;
-C 207 ; WX 577 ; N charcf ; B -25 -25 602 602 ;
-C 208 ; WX 192 ; N chard0 ; B -25 -25 217 602 ;
-C 209 ; WX 531 ; N chard1 ; B -25 -25 556 602 ;
-EndCharMetrics
-EndFontMetrics
+StartFontMetrics 2.0
+Comment AFM Generated by Ghostscript/pf2afm
+FontName ContextNavigation
+FullName ContextNavigation
+FamilyName ContextNavigation
+Weight Medium
+Notice Copyright (c) Pragma, Taco Hoekwater, 1998. All rights reserved.
+ItalicAngle 0
+IsFixedPitch false
+UnderlinePosition -100
+UnderlineThickness 50
+Version 1.0
+EncodingScheme FontSpecific
+FontBBox -25 -64 780 602
+StartCharMetrics 27
+C 1 ; WX 507 ; N char01 ; B -18 -64 532 564 ;
+C 2 ; WX 507 ; N char02 ; B -25 -64 525 564 ;
+C 3 ; WX 625 ; N char03 ; B -25 -64 650 564 ;
+C 4 ; WX 625 ; N char04 ; B -25 -64 650 564 ;
+C 5 ; WX 755 ; N char05 ; B -20 -64 780 564 ;
+C 6 ; WX 755 ; N char06 ; B -25 -64 775 564 ;
+C 7 ; WX 577 ; N char07 ; B -25 -25 602 602 ;
+C 8 ; WX 192 ; N char08 ; B -25 -25 217 602 ;
+C 9 ; WX 531 ; N char09 ; B -25 -25 556 602 ;
+C 101 ; WX 507 ; N char65 ; B -18 -64 532 564 ;
+C 102 ; WX 507 ; N char66 ; B -25 -64 525 564 ;
+C 103 ; WX 625 ; N char67 ; B -25 -64 650 564 ;
+C 104 ; WX 625 ; N char68 ; B -25 -64 650 564 ;
+C 105 ; WX 755 ; N char69 ; B -20 -64 780 564 ;
+C 106 ; WX 755 ; N char6a ; B -25 -64 775 564 ;
+C 107 ; WX 577 ; N char6b ; B -25 -25 602 602 ;
+C 108 ; WX 192 ; N char6c ; B -25 -25 217 602 ;
+C 109 ; WX 531 ; N char6d ; B -25 -25 556 602 ;
+C 201 ; WX 507 ; N charc9 ; B -18 -64 532 564 ;
+C 202 ; WX 507 ; N charca ; B -25 -64 525 564 ;
+C 203 ; WX 625 ; N charcb ; B -25 -64 650 564 ;
+C 204 ; WX 625 ; N charcc ; B -25 -64 650 564 ;
+C 205 ; WX 755 ; N charcd ; B -20 -64 780 564 ;
+C 206 ; WX 755 ; N charce ; B -25 -64 775 564 ;
+C 207 ; WX 577 ; N charcf ; B -25 -25 602 602 ;
+C 208 ; WX 192 ; N chard0 ; B -25 -25 217 602 ;
+C 209 ; WX 531 ; N chard1 ; B -25 -25 556 602 ;
+EndCharMetrics
+EndFontMetrics
diff --git a/fonts/misc/xetex/fontmapping/tlig.map b/fonts/misc/xetex/fontmapping/context/tlig.map
index 2f296f311..2f296f311 100644
--- a/fonts/misc/xetex/fontmapping/tlig.map
+++ b/fonts/misc/xetex/fontmapping/context/tlig.map
diff --git a/fonts/misc/xetex/fontmapping/tlig.tec b/fonts/misc/xetex/fontmapping/context/tlig.tec
index ab2268c20..ab2268c20 100644
--- a/fonts/misc/xetex/fontmapping/tlig.tec
+++ b/fonts/misc/xetex/fontmapping/context/tlig.tec
Binary files differ
diff --git a/metapost/context/base/mp-grph.mp b/metapost/context/base/mp-grph.mp
index 3cd9f2cfb..48776a09f 100644
--- a/metapost/context/base/mp-grph.mp
+++ b/metapost/context/base/mp-grph.mp
@@ -22,13 +22,29 @@ string CRLF ; CRLF := char 10 & char 13 ;
picture _currentpicture_ ;
+numeric _fig_nesting_ ; _fig_nesting_ := 0 ;
+
def beginfig (expr c) =
- begingroup
- charcode := c ;
- resetfig ;
- scantokens extra_beginfig ;
+ _fig_nesting_ := _fig_nesting_ + 1 ;
+ if _fig_nesting_ = 1 :
+ begingroup
+ charcode := c ;
+ resetfig ;
+ scantokens extra_beginfig ;
+ fi ;
enddef ;
+def endfig =
+ ; % safeguard
+ if _fig_nesting_ = 1 :
+ scantokens extra_endfig;
+ shipit ;
+ endgroup ;
+ fi ;
+ _fig_nesting_ := _fig_nesting_ - 1 ;
+enddef;
+
+
def resetfig =
clearxy ;
clearit ;
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index c014f9d78..3376ad432 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -1134,14 +1134,10 @@ function scripts.context.autoctx()
scripts.context.run(ctxdata)
end
--- todo: quite after first image
-
local template = [[
- \starttext
- \startMPpage %% %s
- input "%s" ;
- \stopMPpage
- \stoptext
+\starttext
+ \directMPgraphic{%s}{input "%s"}
+\stoptext
]]
local loaded = false
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 04f8c21c4..29665417e 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -4443,9 +4443,9 @@ if not modules then modules = { } end modules ['util-prs'] = {
license = "see context related readme files"
}
-local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg
+local P, R, V, C, Ct, Cs, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg
local lpegmatch = lpeg.match
-local concat, format, gmatch = table.concat, string.format, string.gmatch
+local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find
local tostring, type, next = tostring, type, next
utilities = utilities or {}
@@ -4473,8 +4473,12 @@ local rbrace = P("}")
local nobrace = 1 - (lbrace+rbrace)
local nested = P { lbrace * (nobrace + V(1))^0 * rbrace }
local spaces = space^0
+local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/""))
+local content = (1-P(-1))^0
-lpeg.patterns.nested = nested
+lpeg.patterns.nested = nested -- no capture
+lpeg.patterns.argument = argument -- argument after e.g. =
+lpeg.patterns.content = content -- rest after e.g =
local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0)
@@ -4555,9 +4559,15 @@ parsers.patterns.settings_to_array = pattern
-- we could use a weak table as cache
-function parsers.settings_to_array(str)
+function parsers.settings_to_array(str,strict)
if not str or str == "" then
return { }
+ elseif strict then
+ if find(str,"{") then
+ return lpegmatch(pattern,str)
+ else
+ return { str }
+ end
else
return lpegmatch(pattern,str)
end
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 04f8c21c4..29665417e 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -4443,9 +4443,9 @@ if not modules then modules = { } end modules ['util-prs'] = {
license = "see context related readme files"
}
-local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg
+local P, R, V, C, Ct, Cs, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg
local lpegmatch = lpeg.match
-local concat, format, gmatch = table.concat, string.format, string.gmatch
+local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find
local tostring, type, next = tostring, type, next
utilities = utilities or {}
@@ -4473,8 +4473,12 @@ local rbrace = P("}")
local nobrace = 1 - (lbrace+rbrace)
local nested = P { lbrace * (nobrace + V(1))^0 * rbrace }
local spaces = space^0
+local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/""))
+local content = (1-P(-1))^0
-lpeg.patterns.nested = nested
+lpeg.patterns.nested = nested -- no capture
+lpeg.patterns.argument = argument -- argument after e.g. =
+lpeg.patterns.content = content -- rest after e.g =
local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0)
@@ -4555,9 +4559,15 @@ parsers.patterns.settings_to_array = pattern
-- we could use a weak table as cache
-function parsers.settings_to_array(str)
+function parsers.settings_to_array(str,strict)
if not str or str == "" then
return { }
+ elseif strict then
+ if find(str,"{") then
+ return lpegmatch(pattern,str)
+ else
+ return { str }
+ end
else
return lpegmatch(pattern,str)
end
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 04f8c21c4..29665417e 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -4443,9 +4443,9 @@ if not modules then modules = { } end modules ['util-prs'] = {
license = "see context related readme files"
}
-local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg
+local P, R, V, C, Ct, Cs, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg
local lpegmatch = lpeg.match
-local concat, format, gmatch = table.concat, string.format, string.gmatch
+local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find
local tostring, type, next = tostring, type, next
utilities = utilities or {}
@@ -4473,8 +4473,12 @@ local rbrace = P("}")
local nobrace = 1 - (lbrace+rbrace)
local nested = P { lbrace * (nobrace + V(1))^0 * rbrace }
local spaces = space^0
+local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/""))
+local content = (1-P(-1))^0
-lpeg.patterns.nested = nested
+lpeg.patterns.nested = nested -- no capture
+lpeg.patterns.argument = argument -- argument after e.g. =
+lpeg.patterns.content = content -- rest after e.g =
local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0)
@@ -4555,9 +4559,15 @@ parsers.patterns.settings_to_array = pattern
-- we could use a weak table as cache
-function parsers.settings_to_array(str)
+function parsers.settings_to_array(str,strict)
if not str or str == "" then
return { }
+ elseif strict then
+ if find(str,"{") then
+ return lpegmatch(pattern,str)
+ else
+ return { str }
+ end
else
return lpegmatch(pattern,str)
end
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 8f3804fae..8b5853029 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -803,8 +803,8 @@
\ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint
\kern\textbackgroundskip\nobreak
\fi \fi
- \nobreak \vskip-\lineheight \nobreak
- \nowhitespace
+ \nobreak \vskip-\dimexpr\lineheight+\parskip\relax \nobreak
+% \nobreak \vskip-\lineheight \nobreak \nowhitespace % does not work
\egroup
\bgroup \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM
\nobreak \noindent \strut \hfill \kern\zeropoint
diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua
index c76f17efc..522bf0c4c 100644
--- a/tex/context/base/buff-ver.lua
+++ b/tex/context/base/buff-ver.lua
@@ -15,7 +15,7 @@ local type, next, rawset, rawget, setmetatable, getmetatable = type, next, rawse
local format, lower, upper,match, find, sub = string.format, string.lower, string.upper, string.match, string.find, string.sub
local splitlines = string.splitlines
local concat = table.concat
-local C, P, R, V, Carg, Cc, Cs = lpeg.C, lpeg.P, lpeg.R, lpeg.V, lpeg.Carg, lpeg.Cc, lpeg.Cs
+local C, P, R, S, V, Carg, Cc, Cs = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.Carg, lpeg.Cc, lpeg.Cs
local patterns, lpegmatch, is_lpeg = lpeg.patterns, lpeg.match, lpeg.is_lpeg
local trace_visualize = false trackers.register("buffers.visualize", function(v) trace_visualize = v end)
@@ -340,25 +340,141 @@ local function hack(pattern)
return Cs(pattern * Cc(signal))
end
-function visualizers.registerescapepattern(name,before,after,normalmethod,escapemethod)
+local split_processor = structures.processors.split
+local apply_processor = structures.processors.apply
+
+-- function visualizers.registerescapepattern(name,before,after,normalmethod,escapemethod,processor)
+-- local escapepattern = escapepatterns[name]
+-- if not escapepattern then
+-- before = type(before) == "table" and before [1] or before
+-- after = type(after) == "table" and after [1] or after
+-- processor = type(processor) == "table" and processor[1] or processor
+-- if trace_visualize then
+-- report_visualizers("registering escape pattern, name: '%s', before: '%s', after: '%s'",name,before,after)
+-- end
+-- before = P(before) * space_pattern
+-- after = space_pattern * P(after)
+-- local action
+-- if processor then
+-- action = function(s) apply_processor(processor,s) end
+-- else
+-- action = escapemethod or texmethod
+-- end
+-- escapepattern = (
+-- (before / "")
+-- * ((1 - after)^0 / action)
+-- * (after / "")
+-- + hack((1 - before)^1) / (normalmethod or defaultmethod)
+-- )^0
+-- escapepatterns[name] = escapepattern
+-- end
+-- return escapepattern
+-- end
+
+-- todo: { before = b, after = a, processor = p }, ...
+
+function visualizers.registerescapepattern(name,befores,afters,normalmethod,escapemethod,processors)
local escapepattern = escapepatterns[name]
if not escapepattern then
- if trace_visualize then
- report_visualizers("registering escape pattern, name: '%s', before: '%s', after: '%s'",name,before,after)
+ if type(befores) ~= "table" then befores = { befores } end
+ if type(afters) ~= "table" then afters = { afters } end
+ if type(processors) ~= "table" then processors = { processors } end
+ for i=1,#befores do
+ local before = befores[i]
+ local after = afters[i]
+ local processor = processors[i]
+ if trace_visualize then
+ report_visualizers("registering escape pattern, name: '%s', index: '%s', before: '%s', after: '%s', processor: '%s'",
+ name,i,before,after,processor or "default")
+ end
+ before = P(before) * space_pattern
+ after = space_pattern * P(after)
+ local action
+ if processor then
+ action = function(s) apply_processor(processor,s) end
+ else
+ action = escapemethod or texmethod
+ end
+ local ep = (before / "") * ((1 - after)^0 / action) * (after / "")
+ if escapepattern then
+ escapepattern = escapepattern + ep
+ else
+ escapepattern = ep
+ end
+ end
+ escapepattern = (
+ escapepattern
+ + hack((1 - escapepattern)^1) / (normalmethod or defaultmethod)
+ )^0
+ escapepatterns[name] = escapepattern
+ end
+ return escapepattern
+end
+
+--~ function visualizers.registerescapeline(name,before,normalmethod,escapemethod,processor)
+--~ local escapepattern = escapepatterns[name]
+--~ if not escapepattern then
+--~ before = type(before) == "table" and before [1] or before
+--~ processor = type(processor) == "table" and processor[1] or processor
+--~ if trace_visualize then
+--~ report_visualizers("registering escape line pattern, name: '%s', before: '%s', after: <<newline>>",name,before)
+--~ end
+--~ before = P(before) * space_pattern
+--~ after = space_pattern * P("\n")
+--~ local action
+--~ if processor then
+--~ action = function(s) apply_processor(processor,s) end
+--~ else
+--~ action = escapemethod or texmethod
+--~ end
+--~ escapepattern = (
+--~ (before / "")
+--~ * ((1 - after)^0 / action)
+--~ * (space_pattern / "")
+--~ -- * (after / (normalmethod or defaultmethod))
+--~ + hack((1 - before)^1) / (normalmethod or defaultmethod)
+--~ )^0
+--~ escapepatterns[name] = escapepattern
+--~ end
+--~ return escapepattern
+--~ end
+
+function visualizers.registerescapeline(name,befores,normalmethod,escapemethod,processors)
+ local escapepattern = escapepatterns[name]
+ if not escapepattern then
+ if type(befores) ~= "table" then befores = { befores } end
+ if type(processors) ~= "table" then processors = { processors } end
+ for i=1,#befores do
+ local before = befores[i]
+ local processor = processors[i]
+ if trace_visualize then
+ report_visualizers("registering escape line pattern, name: '%s', before: '%s', after: <<newline>>",name,before)
+ end
+ before = P(before) * space_pattern
+ after = space_pattern * P("\n")
+ local action
+ if processor then
+ action = function(s) apply_processor(processor,s) end
+ else
+ action = escapemethod or texmethod
+ end
+ local ep = (before / "") * ((1 - after)^0 / action) * (space_pattern / "")
+ if escapepattern then
+ escapepattern = escapepattern + ep
+ else
+ escapepattern = ep
+ end
end
- before, after = P(before) * space_pattern, space_pattern * P(after)
escapepattern = (
- (before / "")
- * ((1 - after)^0 / (escapemethod or texmethod))
- * (after / "")
- + hack((1 - before)^1) / (normalmethod or defaultmethod)
+ escapepattern
+ + hack((1 - escapepattern)^1) / (normalmethod or defaultmethod)
)^0
escapepatterns[name] = escapepattern
end
return escapepattern
end
-function visualizers.registerescapecommand(name,token,normalmethod,escapecommand)
+function visualizers.registerescapecommand(name,token,normalmethod,escapecommand,processor)
local escapepattern = escapepatterns[name]
if not escapepattern then
if trace_visualize then
@@ -385,24 +501,39 @@ local function visualize(content,settings) -- maybe also method in settings
local m
local e = settings.escape
if e and e ~= "" then
- local newname = format("%s-%s",e,method)
+ local newname = format("%s : %s",method,e)
local newspec = specifications[newname]
if newspec then
m = newspec
else
- local start, stop
+ local starts, stops, processors = { }, { }, { }
if e == v_yes then
- start, stop = "/BTEX", "/ETEX"
+ starts[1] = "/BTEX"
+ stops [1] = "/ETEX"
else
- start, stop = match(e,"^(.-),(.-)$") -- todo: lpeg
+ local s = settings_to_array(e,true)
+ for i=1,#s do
+ local si = s[i]
+ local processor, pattern = split_processor(si)
+ si = processor and pattern or si
+ local start, stop = match(si,"^(.-),(.-)$")
+ if start then
+ local n = #starts + 1
+ starts[n] = start
+ stops [n] = stop or ""
+ processors[n] = processor
+ end
+ end
end
local oldvisualizer = specifications[method] or specifications.default
local oldparser = oldvisualizer.direct
local newparser
- if start and stop then
- newparser = visualizers.registerescapepattern(newname,start,stop,oldparser)
+ if starts[1] and stops[1] ~= "" then
+ newparser = visualizers.registerescapepattern(newname,starts,stops,oldparser,nil,processors)
+ elseif starts[1] then
+ newparser = visualizers.registerescapeline(newname,starts,oldparser,nil,processors)
else -- for old times sake: /em
- newparser = visualizers.registerescapecommand(newname,e,oldparser)
+ newparser = visualizers.registerescapecommand(newname,e,oldparser,nil,processors)
end
m = visualizers.register(newname, {
parser = newparser,
@@ -483,31 +614,31 @@ end
-- helpers
-local function realign(lines,forced_n) -- no, auto, <number>
- forced_n = (forced_n == v_auto and huge) or tonumber(forced_n)
- if forced_n then
- local n = 0
+local function realign(lines,strip) -- "yes", <number>
+ local n
+ if strip == v_yes then
+ n = math.huge
for i=1, #lines do
local spaces = find(lines[i],"%S")
if not spaces then
-- empty line
- elseif not n then
- n = spaces
elseif spaces == 0 then
n = 0
break
- elseif n > spaces then
+ elseif spaces < n then
n = spaces
end
end
- if n > 0 then
- if n > forced_n then
- n = forced_n
- end
- for i=1,#d do
- lines[i] = sub(lines[i],n)
- end
+ n = n - 1
+ else
+ n = tonumber(strip)
+ end
+ if n and n > 0 then
+ local copy = { }
+ for i=1,#lines do
+ copy[i] = sub(lines[i],n+1)
end
+ return copy
end
return lines
end
@@ -593,7 +724,7 @@ end
local function filter(lines,settings) -- todo: inline or display in settings
local strip = settings.strip
- if strip == v_yes then
+ if strip and strip ~= "" then
lines = realign(lines,strip)
end
local line, n = 0, 0
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 7ee11cbab..168de9353 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -568,9 +568,12 @@
{\dodododotypefile{#1}\askedtypingfile}
{\showmessage\m!verbatims1{#2}}}
-\def\doifelsetypingfile#1% sets \readfilename (we will make this proper mkiv i.e. less messy)
+\def\doifelsetypingfile#1%
{\edef\askedtypingfile{\locfilename{#1}}%
\ifx\askedtypingfile\empty
+ \edef\askedtypingfile{\locfilename{#1.tex}}% downward compatible
+ \fi
+ \ifx\askedtypingfile\empty
\expandafter\secondoftwoarguments
\else
\expandafter\firstoftwoarguments
diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua
index 624066784..38c61a023 100644
--- a/tex/context/base/cldf-ini.lua
+++ b/tex/context/base/cldf-ini.lua
@@ -152,15 +152,21 @@ end
context.pushcatcodes = pushcatcodes
context.popcatcodes = popcatcodes
--- -- -- todo: tracing
+-- -- --
+
+--~ local capture = (
+--~ space^0 * newline^2 * lpeg.Cc("") / texprint +
+--~ space^0 * newline * space^0 * lpeg.Cc(" ") / texsprint +
+--~ content / texsprint
+--~ )^0
local newline = lpeg.patterns.newline
local space = lpeg.patterns.spacer
local spacing = newline * space^0
-local content = lpegC((1-spacing)^1)
-local emptyline = space^0 * newline^2
-local endofline = space^0 * newline * space^0
-local simpleline = endofline * lpegP(-1)
+local content = lpegC((1-spacing)^1) -- texsprint
+local emptyline = space^0 * newline^2 -- texprint("")
+local endofline = space^0 * newline * space^0 -- texsprint(" ")
+local simpleline = endofline * lpegP(-1) --
local verbose = lpegC((1-space-newline)^1)
local beginstripper = (lpegS(" \t")^1 * newline^1) / ""
@@ -183,7 +189,7 @@ local function n_emptyline()
end
local function n_simpleline()
- flushdirect(currentcatcodes,"\r")
+ flush(currentcatcodes," \r")
end
local n_exception = ""
@@ -216,7 +222,8 @@ function context.newtexthandler(specification) -- can also be used for verbose
local content = lpegC((1-spacing-p_exception)^1)
pattern =
simpleline / f_simpleline
- + (
+ +
+ (
emptyline / f_emptyline
+ endofline / f_endofline
+ p_exception
@@ -226,7 +233,8 @@ function context.newtexthandler(specification) -- can also be used for verbose
local content = lpegC((1-spacing)^1)
pattern =
simpleline / f_simpleline
- + (
+ +
+ (
emptyline / f_emptyline
+ endofline / f_endofline
+ content / f_content
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 9914003b9..4e6779220 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{2011.07.14 16:09}
+\newcontextversion{2011.07.19 10:35}
%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 924780826..444709ebd 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{2011.07.14 16:09}
+\newcontextversion{2011.07.19 10:35}
%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/context.mkii b/tex/context/base/context.mkii
index cceae9e16..8f0450eda 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{2011.07.14 16:09}
+\edef\contextversion{2011.07.19 10:35}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index f1dddaccc..5cbc7e79a 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.07.14 16:09}
+\edef\contextversion{2011.07.19 10:35}
%D For those who want to use this:
diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua
index 21b3f069e..7893b9396 100644
--- a/tex/context/base/file-job.lua
+++ b/tex/context/base/file-job.lua
@@ -35,7 +35,7 @@ local v_component = variables.component
-- main code .. there is some overlap .. here we have loc://
local function findctxfile(name) -- loc ? any ?
- if file.is_qualified_path(name) then
+ if file.is_qualified_path(name) then -- maybe when no suffix do some test for tex
return name
elseif not url.hasscheme(filename) then
return findbyscheme("loc",filename) or ""
diff --git a/tex/context/base/file-res.lua b/tex/context/base/file-res.lua
index cd301d656..d0db95f59 100644
--- a/tex/context/base/file-res.lua
+++ b/tex/context/base/file-res.lua
@@ -87,6 +87,7 @@ function getreadfilename(scheme,path,name) -- better do a split and then pass ta
else
fullname = ((path == "") and format("%s:///%s",scheme,name)) or format("%s:///%s/%s",scheme,path,name)
end
+--~ print(">>>",fullname)
return resolvers.findtexfile(fullname) or "" -- can be more direct
end
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index d330d4c1e..45bb5ee59 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -1036,7 +1036,7 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
for i=1,#initializers do
local step = initializers[i]
local feature = step.name
--- we could intercept mode here .. needs a rewrite of this whole loop then btu it's cleaner that way
+-- we could intercept mode here .. needs a rewrite of this whole loop then but it's cleaner that way
local value = features[feature]
if not value then
-- disabled
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua
index 84e98fb3e..7747eb9f0 100644
--- a/tex/context/base/font-gds.lua
+++ b/tex/context/base/font-gds.lua
@@ -162,14 +162,13 @@ end
fontgoodies.register("featureset",initialize)
-local function setfeatureset(tfmdata,set)
+local function setfeatureset(tfmdata,set,features)
local goodies = tfmdata.goodies -- shared ?
if goodies then
- local features = tfmdata.shared.features
local properties = tfmdata.properties
local what
for i=1,#goodies do
- -- last one counts
+ -- last one wins
local g = goodies[i]
what = (g.featuresets and g.featuresets[set]) or what
end
@@ -179,7 +178,7 @@ local function setfeatureset(tfmdata,set)
features[feature] = value
end
end
- properties.mode = features.mode or properties.mode
+ properties.mode = what.mode or properties.mode
end
end
end
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 066e2b7f0..67932657e 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -2460,10 +2460,10 @@
\def\dodosetfont#1#2% #1 = set/switch state | check fo rempty, else space
{\doifsomething{#2}{\dododosetfont{#1}{#2}{\showmessage\m!fonts4{#2}}}}
-\def\dododosetfont#1#2#3% #1 = set/switch state ! ! ! !could also be used for mkii
+\def\dododosetfont#1#2#3% #1 = set/switch state
{\doifnumberelse{#2}\dodododosetfont\redododosetfont{#1}{#2}{#3}}
-\def\redododosetfont#1#2#3% #1 = set/switch state ! ! ! !could also be used for mkii
+\def\redododosetfont#1#2#3% #1 = set/switch state
{\edef\expandedfontthing{#2}%
\def\interfacedfontsize{\normalizedbodyfontsize\interfaced\expandedfontthing}%
\ifcsname\??ft\interfacedfontsize\endcsname
@@ -2548,9 +2548,9 @@
\edef\fontclass{#1}%
\else\ifcsname\@no@fontclass@#1\endcsname
% already tried
- \else\ifcase\currentgrouplevel
+ \else % too messy: \ifcase\currentgrouplevel % (unpredictable)
\trycurrentfontclass{#1}%
- \fi\fi\fi}
+ \fi\fi} % \fi}
\def\savefontclassparameters#1#2#3#4#5#6% #1=rm|ss|.. rscale features fallbacks goodies direction
{\setxvalue{\fontclass#1\s!rscale }{#2}%
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index 1195f3be2..8c6cbbb06 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -126,12 +126,12 @@ local entity = ampersand * C((1-semicolon)^1) * semicolon / lxml.resolvedenti
local _, xmltextcapture = context.newtexthandler {
exception = entity,
- catcodes = notcatcodes
+ catcodes = notcatcodes,
}
local _, ctxtextcapture = context.newtexthandler {
exception = entity,
- catcodes = ctxcatcodes
+ catcodes = ctxcatcodes,
}
-- cdata
diff --git a/tex/context/base/math-dim.lua b/tex/context/base/math-dim.lua
index 8407fd077..861e768b7 100644
--- a/tex/context/base/math-dim.lua
+++ b/tex/context/base/math-dim.lua
@@ -46,7 +46,7 @@ local defaults = {
limit_below_bgap = { default = { "LowerLimitBaselineDropMin", "big_op_spacing4" }, },
limit_below_vgap = { default = { "LowerLimitGapMin", "big_op_spacing2" }, },
limit_below_kern = { default = { "0", "big_op_spacing5" }, },
--- .... = { default = { "DisplayOperatorMinHeight", "....." }, },
+ math_operator_size = { default = { "DisplayOperatorMinHeight", "math_x_height*3" }, }, -- 2
overbar_kern = { default = { "OverbarExtraAscender", "default_rule_thickness" }, },
overbar_rule = { default = { "OverbarRuleThickness", "default_rule_thickness" }, },
overbar_vgap = { default = { "OverbarVerticalGap", "3*default_rule_thickness" }, },
@@ -139,6 +139,8 @@ function mathematics.dimensions(dimens) -- beware, dimens get spoiled
dimens["7*default_rule_thickness"] = 7 * default_rule_thickness
dimens["(5/18)*quad"] = (math_quad * 5) / 18
dimens["(-10/18)*quad"] = - (math_quad * 10) / 18
+ dimens["math_x_height*2"] = math_x_height * 2 -- needs checking
+ dimens["math_x_height*3"] = math_x_height * 3 -- needs checking
dimens["abs(math_x_height*4)/5"] = abs(math_x_height * 4) / 5
dimens["default_rule_thickness+(abs(default_rule_thickness)/4)"] = default_rule_thickness+(abs(default_rule_thickness) / 4)
dimens["default_rule_thickness+(abs(math_x_height)/4)"] = default_rule_thickness+(abs(math_x_height) / 4)
@@ -168,7 +170,7 @@ function mathematics.dimensions(dimens) -- beware, dimens get spoiled
AccentBaseHeight = t . accent_base_height . text_style,
AxisHeight = t . axis . text_style,
-- DelimitedSubFormulaMinHeight
- -- DisplayOperatorMinHeight
+ DisplayOperatorMinHeight = t . math_operator_size . text_style, -- no longer let tex decide (weird values)
-- FlattenedAccentBaseHeight
FractionDenominatorDisplayStyleGapMin = t . fraction_denom_vgap . display_style,
FractionDenominatorDisplayStyleShiftDown = t . fraction_denom_down . display_style,
diff --git a/tex/context/base/math-frc.mkiv b/tex/context/base/math-frc.mkiv
index 9f3b3b135..19070a3a0 100644
--- a/tex/context/base/math-frc.mkiv
+++ b/tex/context/base/math-frc.mkiv
@@ -226,7 +226,7 @@
\unexpanded\def\genfrac#1#2#3#4%
{\edef\!!stringa
{#1#2}%
- \expanded
+ \normalexpanded
{\dogenfrac{#4}%
\csname
\ifx @#3@%
@@ -245,7 +245,7 @@
\endcsname}%
{#1#2#3}}
-\def\dogenfrac#1#2#3#4#5%
+\unexpanded\def\dogenfrac#1#2#3#4#5%
{{#1{\begingroup#4\endgroup#2#3\relax#5}}}
%D \macros
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index e24908f9e..da52c1368 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -423,8 +423,8 @@
\def\doobeyMPboxorigin % mode = 3
{\setbox\MPgraphicbox\hbox\bgroup
- \hskip\MPllx\onebasepoint
- \raise\MPlly\onebasepoint\box\MPgraphicbox
+ \hskip\MPllx\onebasepoint
+ \raise\MPlly\onebasepoint\box\MPgraphicbox
\egroup}
\def\obeyMPboxdepth {\MPboxmode\plusone}
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index 8000d5a28..3eaffded1 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -64,14 +64,24 @@ function metapost.convert(result, trialrun, flusher, multipass, askedfig)
return true -- done
end
-metapost.flushers = { }
+metapost.flushers = { }
metapost.flushers.pdf = { }
-local savedliterals = nil
+-- \def\MPLIBtoPDF#1{\ctxlua{metapost.flushliteral(#1)}}
+
+local savedliterals = nil -- needs checking
local mpsliteral = nodes.pool.register(node.new("whatsit",8)) -- pdfliteral
-function metapost.flushliteral(d) -- \def\MPLIBtoPDF#1{\ctxlua{metapost.flush_literal(#1)}}
+local pdfliteral = function(s)
+ local literal = copy_node(mpsliteral)
+ literal.data = s
+ return literal
+end
+
+local experiment = true -- uses context(node) that already does delayed nodes
+
+function metapost.flushliteral(d)
if savedliterals then
local literal = copy_node(mpsliteral)
literal.data = savedliterals[d]
@@ -88,6 +98,9 @@ end
function metapost.flushers.pdf.comment(message)
if message then
message = format("%% mps graphic %s: %s", metapost.n, message)
+if experiment then
+ context(pdfliteral(message))
+else
if savedliterals then
local last = #savedliterals + 1
savedliterals[last] = message
@@ -96,6 +109,7 @@ function metapost.flushers.pdf.comment(message)
savedliterals = { message }
context.MPLIBtoPDF(1)
end
+end
end
end
@@ -115,6 +129,9 @@ end
function metapost.flushers.pdf.flushfigure(pdfliterals) -- table
if #pdfliterals > 0 then
pdfliterals = concat(pdfliterals,"\n")
+if experiment then
+ context(pdfliteral(pdfliterals))
+else
if savedliterals then
local last = #savedliterals + 1
savedliterals[last] = pdfliterals
@@ -123,6 +140,7 @@ function metapost.flushers.pdf.flushfigure(pdfliterals) -- table
savedliterals = { pdfliterals }
context.MPLIBtoPDF(1)
end
+end
end
end
@@ -267,7 +285,7 @@ function metapost.flush(result,flusher,askedfig)
local figure = figures[f]
local objects = getobjects(result,figure,f)
local fignum = figure:charcode() or 0
- if not askedfig or (askedfig == fignum) then
+ if askedfig == "direct" or askedfig == "all" or askedfig == fignum then
local t = { }
local miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
local bbox = figure:boundingbox()
@@ -416,7 +434,7 @@ function metapost.flush(result,flusher,askedfig)
flushfigure(t)
stopfigure("end")
end
- if askedfig then
+ if askedfig ~= "all" then
break
end
end
@@ -433,7 +451,7 @@ function metapost.parse(result,askedfig)
for f=1, #figures do
local figure = figures[f]
local fignum = figure:charcode() or 0
- if not askedfig or (askedfig == fignum) then
+ if askedfig == "direct" or askedfig == "all" or askedfig == fignum then
local bbox = figure:boundingbox()
local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4] -- faster than unpack
metapost.llx = llx
@@ -452,7 +470,9 @@ function metapost.parse(result,askedfig)
analyzeplugins(objects[o])
end
end
- break
+ if askedfig ~= "all" then
+ break
+ end
end
end
end
diff --git a/tex/context/base/mlib-pdf.mkiv b/tex/context/base/mlib-pdf.mkiv
index f1b2f040d..0f2f4c728 100644
--- a/tex/context/base/mlib-pdf.mkiv
+++ b/tex/context/base/mlib-pdf.mkiv
@@ -93,4 +93,45 @@
\def\MPLIBflushreset
{\ctxlua{metapost.flushreset()}}
+
+%D Kind of special:
+%
+% test.mp:
+%
+% beginfig(1) fill fullcircle scaled 10cm withcolor red ; endfig ;
+% beginfig(2) draw fullcircle scaled 5cm withcolor blue ; endfig ;
+% beginfig(3) draw textext("just some text") ; endfig ;
+%
+% standalone pages:
+%
+% \starttext
+% \directMPgraphic{input "test.mp" ;}
+% \stoptext
+
+\let\normalstartMPLIBtoPDF\startMPLIBtoPDF
+\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF
+
+\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF}
+\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage}
+
+\unexpanded\def\directMPgraphic
+ {\dodoublegroupempty\dodirectMPgraphic}
+
+\unexpanded\long\def\directMPgraphic#1#2% makes pages (todo: make boxes)
+ {\beginMPgraphicgroup{#1}%
+ \let\startMPLIBtoPDF\directstartMPLIBtoPDF
+ \let\stopMPLIBtoPDF \directstopMPLIBtoPDF
+ \dostartcurrentMPgraphic
+ \forgetall
+ \normalexpanded{\noexpand\ctxlua{metapost.graphic(
+ "\currentMPgraphicinstance",
+ "\currentMPgraphicformat",
+ \!!bs#2;\!!es,
+ \!!bs\currentMPinitializations;\!!es,
+ \!!bs\currentMPpreamble;\!!es,
+ "all"
+ )}}%
+ \dostopcurrentMPgraphic
+ \endMPgraphicgroup}
+
\protect \endinput
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index a9fd5e9e2..3dd90ab50 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -6,11 +6,6 @@ if not modules then modules = { } end modules ['mlib-pps'] = {
license = "see context related readme files",
}
--- pps: prescript, postscripts and specials (although specials are dropped)
---
--- current limitation: if we have textext as well as a special color then due to
--- prescript/postscript overload we can have problems
---
-- todo: report max textexts
local format, gmatch, match, split = string.format, string.gmatch, string.match, string.split
@@ -31,6 +26,7 @@ local sortedhash = table.sortedhash
local starttiming = statistics.starttiming
local stoptiming = statistics.stoptiming
+local trace_runs = false trackers.register("metapost.runs", function(v) trace_runs = v end)
local trace_textexts = false trackers.register("metapost.textexts", function(v) trace_textexts = v end)
local trace_scripts = false trackers.register("metapost.scripts", function(v) trace_scripts = v end)
@@ -467,8 +463,8 @@ end
local no_trial_run = "_trial_run_ := false ;"
local do_trial_run = "if unknown _trial_run_ : boolean _trial_run_ fi ; _trial_run_ := true ;"
-local text_data_template = "_tt_w_[%i]:=%f;_tt_h_[%i]:=%f;_tt_d_[%i]:=%f;"
-local do_begin_fig = "; beginfig(1); "
+local text_data_template = "_tt_w_[%i] := %f ; _tt_h_[%i] := %f ; _tt_d_[%i] := %f ;"
+local do_begin_fig = "; beginfig(1) ; "
local do_end_fig = "; endfig ;"
local do_safeguard = ";"
@@ -497,8 +493,28 @@ metapost.method = 1 -- 1:dumb 2:clever
-- maybe we can latelua the texts some day
+local nofruns = 0 -- askedfig: "all", "first", number
+
+local function checkaskedfig(askedfig) -- return askedfig, wrappit
+ if not askedfig then
+ return "direct", true
+ elseif askedfig == "all" then
+ return "all", false
+ elseif askedfig == "direct" then
+ return "all", true
+ else
+ askedfig = tonumber(askedfig)
+ if askedfig then
+ return askedfig, false
+ else
+ return "direct", true
+ end
+ end
+end
+
function metapost.graphic_base_pass(mpsformat,str,initializations,preamble,askedfig)
- local nofig = (askedfig and "") or false
+ nofruns = nofruns + 1
+ local askedfig, wrappit = checkaskedfig(askedfig)
local done_1, done_2, forced_1, forced_2
str, done_1, forced_1 = checktexts(str)
if not preamble or preamble == "" then
@@ -510,16 +526,18 @@ function metapost.graphic_base_pass(mpsformat,str,initializations,preamble,asked
metapost.multipass = false -- no needed here
current_format, current_graphic, current_initializations = mpsformat, str, initializations or ""
if metapost.method == 1 or (metapost.method == 2 and (done_1 or done_2)) then
+ if trace_runs then
+ report_metapost("first run of job %s (asked: %s)",nofruns,tostring(askedfig))
+ end
-- first true means: trialrun, second true means: avoid extra run if no multipass
local flushed = metapost.process(mpsformat, {
preamble,
- nofig or do_begin_fig,
+ wrappit and do_begin_fig or "",
do_trial_run,
current_initializations,
do_safeguard,
current_graphic,
- nofig or do_end_fig
- -- }, true, nil, true )
+ wrappit and do_end_fig or "",
}, true, nil, not (forced_1 or forced_2), false, askedfig)
if metapost.intermediate.needed then
for _, action in next, metapost.intermediate.actions do
@@ -529,32 +547,38 @@ function metapost.graphic_base_pass(mpsformat,str,initializations,preamble,asked
if not flushed or not metapost.optimize then
-- tricky, we can only ask once for objects and therefore
-- we really need a second run when not optimized
- context.MPLIBextrapass(askedfig or "false")
+ context.MPLIBextrapass(askedfig)
end
else
+ if trace_runs then
+ report_metapost("running job %s (asked: %s)",nofruns,tostring(askedfig))
+ end
metapost.process(mpsformat, {
preamble,
- nofig or do_begin_fig,
+ wrappit and do_begin_fig or "",
no_trial_run,
current_initializations,
do_safeguard,
current_graphic,
- nofig or do_end_fig
+ wrappit and do_end_fig or "",
}, false, nil, false, false, askedfig )
end
end
function metapost.graphic_extra_pass(askedfig)
- local nofig = (askedfig and "") or false
+ if trace_runs then
+ report_metapost("second run of job %s (asked: %s)",nofruns,tostring(askedfig))
+ end
+ local askedfig, wrappit = checkaskedfig(askedfig)
metapost.process(current_format, {
- nofig or do_begin_fig,
+ wrappit and do_begin_fig or "",
no_trial_run,
concat(metapost.texttextsdata()," ;\n"),
current_initializations,
do_safeguard,
current_graphic,
- nofig or do_end_fig
- }, false, nil, false, true, askedfig )
+ wrappit and do_end_fig or "",
+ }, false, nil, false, true, askedfig)
context.MPLIBresettexts() -- must happen afterwards
end
diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv
index a4b41072e..25ebab6fa 100644
--- a/tex/context/base/mlib-pps.mkiv
+++ b/tex/context/base/mlib-pps.mkiv
@@ -52,7 +52,7 @@
{\dosavepositionwhd{#1}{0}{#2sp}{#3sp}{#4sp}{#5sp}{0sp}}
\def\MPLIBextrapass#1%
- {\ctxlua{metapost.graphic_extra_pass(#1)}}
+ {\ctxlua{metapost.graphic_extra_pass("#1")}}
\def\MPLIBresettexts
{\ctxlua{metapost.resettextexts()}}
diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua
index 1155792b3..900f466e2 100644
--- a/tex/context/base/mlib-run.lua
+++ b/tex/context/base/mlib-run.lua
@@ -288,8 +288,10 @@ end
local mp_inp, mp_log, mp_tag = { }, { }, 0
+-- key/values
+
function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, askedfig)
- local converted, result = false, {}
+ local converted, result = false, { }
if type(mpx) == "string" then
mpx = metapost.format(mpx) -- goody
end
diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua
index 38f1561fd..df62dda27 100644
--- a/tex/context/base/node-aux.lua
+++ b/tex/context/base/node-aux.lua
@@ -37,6 +37,8 @@ local slide_nodes = node.slide
local insert_node_after = node.insert_after
local isnode = node.is_node
+local current_font = font.current()
+
local texbox = tex.box
function nodes.repackhlist(list,...)
diff --git a/tex/context/base/node-mig.lua b/tex/context/base/node-mig.lua
index 8f1e3d71c..1384f6024 100644
--- a/tex/context/base/node-mig.lua
+++ b/tex/context/base/node-mig.lua
@@ -28,7 +28,7 @@ local trace_migrations = false trackers.register("nodes.migrations", function(v)
local report_nodes = logs.reporter("nodes","migrations")
-local migrate_inserts, migrate_marks
+local migrate_inserts, migrate_marks, inserts_too
local t_inserts, t_marks, t_sweeps = 0, 0, 0
@@ -69,11 +69,15 @@ end
function nodes.handlers.migrate(head,where)
local done = false
if head then
---~ report_nodes("migration sweep '%s'",where)
+ if trace_migrations then
+ report_nodes("migration sweep '%s'",where)
+ end
local current = head
while current do
local id = current.id
- if id == vlist_code or id == hlist_code and not has_attribute(current,migrated) then
+ -- inserts_too is a temp hack, we should only do them when it concerns
+ -- newly placed (flushed) inserts
+ if id == vlist_code or id == hlist_code or (inserts_too and id == insert_code) and not has_attribute(current,migrated) then
set_attribute(current,migrated,1)
t_sweeps = t_sweeps + 1
local h = current.list
@@ -88,7 +92,8 @@ function nodes.handlers.migrate(head,where)
if first then
t_inserts, t_marks = t_inserts + ni, t_marks + nm
if trace_migrations and (ni > 0 or nm > 0) then
- report_nodes("sweep %s, %s inserts and %s marks migrated outwards during '%s'",t_sweeps,ni,nm,where)
+ report_nodes("sweep %s, container %s, %s inserts and %s marks migrated outwards during '%s'",
+ t_sweeps,nodecodes[id],ni,nm,where)
end
-- inserts after head
local n = current.next
@@ -121,6 +126,13 @@ experiments.register("inserts.migrate", function(v)
migrate_inserts = v
end)
+experiments.register("inserts.migrate.nested", function(v)
+ if v then
+ tasks.enableaction("mvlbuilders", "nodes.handlers.migrate")
+ end
+ inserts_too = v
+end)
+
statistics.register("node migrations", function()
if trace_migrations and t_sweeps > 0 then
return format("%s sweeps, %s inserts moved, %s marks moved",t_sweeps,t_inserts,t_marks)
diff --git a/tex/context/base/node-mig.mkiv b/tex/context/base/node-mig.mkiv
index 69ed1d9e7..088f256cf 100644
--- a/tex/context/base/node-mig.mkiv
+++ b/tex/context/base/node-mig.mkiv
@@ -50,7 +50,7 @@
\appendtoks
\let\postponenotes\relax
- \enableexperiments[inserts.migrate]%
+ \enableexperiments[inserts.migrate,inserts.migrate.nested]%
\to \everyautomigratefootnotes
\appendtoks
diff --git a/tex/context/base/phys-dim.lua b/tex/context/base/phys-dim.lua
index c52359341..bc65fcff2 100644
--- a/tex/context/base/phys-dim.lua
+++ b/tex/context/base/phys-dim.lua
@@ -129,7 +129,7 @@ local long_units = {
Second = [[s]],
Hour = [[h]],
Liter = [[l]],
- Litre = [[l]],
+-- Litre = [[l]],
Gram = [[g]],
Newton = [[N]],
Pascal = [[Pa]],
@@ -241,6 +241,9 @@ local short_units_to_long = {
u = "Hour",
h = "Hour",
s = "Second",
+
+ Litre = "Liter",
+ Metre = "Meter",
}
local short_operators_to_long = {
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index da82ebbb0..cdf4147c1 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -1677,6 +1677,9 @@
\definevspacingamount[\v!height] [\strutheight] [\bodyfontstrutheight]
\definevspacingamount[\v!depth] [\strutdepth] [\bodyfontstrutdepth]
+\definevspacingamount[-\v!line] [-\openlineheight] [-\bodyfontlineheight]
+\definevspacingamount[-\v!halfline][-.5\openlineheight][-.5\bodyfontlineheight]
+
\def\bodyfontwhitespace
{\dimexpr
\ifdim\parskip=\zeropoint
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 0b0ce8617..c1dde9c0d 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 4509a0268..b4d1dd6e5 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-ini.lua b/tex/context/base/strc-ini.lua
index 784518048..969e1e5f2 100644
--- a/tex/context/base/strc-ini.lua
+++ b/tex/context/base/strc-ini.lua
@@ -23,7 +23,7 @@ but it does not make sense to store all processdata.
local format, concat, match = string.format, table.concat, string.match
local count = tex.count
local type, next, tonumber, tostring = type, next, tonumber, tostring
-local lpegmatch = lpeg.match
+local lpegmatch, patterns, P, C, Cs = lpeg.match, lpeg.patterns, lpeg.P, lpeg.C, lpeg.Cs
local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash
local allocate = utilities.storage.allocate
@@ -223,7 +223,11 @@ function processors.reset(p)
registered[p] = nil
end
-local splitter = lpeg.splitat("->",true)
+--~ local splitter = lpeg.splitat("->",true) -- also support =>
+
+local becomes = P('->')
+local processor = (1-becomes)^1
+local splitter = C(processor) * becomes * Cs(patterns.argument + patterns.content)
function processors.split(str)
local p, s = lpegmatch(splitter,str)
@@ -248,8 +252,11 @@ end
--~ context.sprint(catcodes,code) -- was: texsprint(catcodes,code)
--~ end
-function processors.apply(str)
- local p, s = lpegmatch(splitter,str)
+function processors.apply(p,s)
+ local str = p
+ if s == nil then
+ p, s = lpegmatch(splitter,p)
+ end
if p and registered[p] then
if trace_processors then
report_processors("known: %s, argument: %s",p,s or "")
@@ -268,21 +275,33 @@ function processors.apply(str)
end
end
-function processors.startapply(str)
- local p, s = lpegmatch(splitter,str)
+function processors.startapply(p,s)
+ local str = p
+ if s == nil then
+ p, s = lpegmatch(splitter,p)
+ end
if p and registered[p] then
if trace_processors then
report_processors("start: %s",p or "?")
end
context.applyprocessor(p)
+ context("{")
+ return s
+ elseif p then
+ if trace_processors then
+ report_processors("start: %s (unknown)",p)
+ end
+ context.firstofoneargument()
+ context("{")
+ return s
else
if trace_processors then
- report_processors("start: %s (unknown)",p or "?")
+ report_processors("start: ? (unset)")
end
context.firstofoneargument()
+ context("{")
+ return str
end
- context("{")
- return s -- not: or str
end
function processors.stopapply()
diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua
index 20da7782d..a0c1d1d32 100644
--- a/tex/context/base/strc-tag.lua
+++ b/tex/context/base/strc-tag.lua
@@ -175,18 +175,24 @@ function tags.detailedtag(tag,detail,attribute)
if not attribute then
attribute = texattribute[a_tagged]
end
- local tl = taglist[attribute]
- local pattern
- if detail and detail ~= "" then
- pattern = "^" .. tag .. ":".. detail .. "%-"
- else
- pattern = "^" .. tag .. "%-"
- end
- for i=#tl,1,-1 do
- local tli = tl[i]
- if find(tli,pattern) then
- return tli
+ if attribute >= 0 then
+ local tl = taglist[attribute]
+ if tl then
+ local pattern
+ if detail and detail ~= "" then
+ pattern = "^" .. tag .. ":".. detail .. "%-"
+ else
+ pattern = "^" .. tag .. "%-"
+ end
+ for i=#tl,1,-1 do
+ local tli = tl[i]
+ if find(tli,pattern) then
+ return tli
+ end
+ end
end
+ else
+ -- enabled but not auto
end
return false -- handy as bogus index
end
diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua
index 591453760..ab1bfb8eb 100644
--- a/tex/context/base/util-prs.lua
+++ b/tex/context/base/util-prs.lua
@@ -6,9 +6,9 @@ if not modules then modules = { } end modules ['util-prs'] = {
license = "see context related readme files"
}
-local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg
+local P, R, V, C, Ct, Cs, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg
local lpegmatch = lpeg.match
-local concat, format, gmatch = table.concat, string.format, string.gmatch
+local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find
local tostring, type, next = tostring, type, next
utilities = utilities or {}
@@ -36,8 +36,12 @@ local rbrace = P("}")
local nobrace = 1 - (lbrace+rbrace)
local nested = P { lbrace * (nobrace + V(1))^0 * rbrace }
local spaces = space^0
+local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/""))
+local content = (1-P(-1))^0
-lpeg.patterns.nested = nested
+lpeg.patterns.nested = nested -- no capture
+lpeg.patterns.argument = argument -- argument after e.g. =
+lpeg.patterns.content = content -- rest after e.g =
local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0)
@@ -118,9 +122,15 @@ parsers.patterns.settings_to_array = pattern
-- we could use a weak table as cache
-function parsers.settings_to_array(str)
+function parsers.settings_to_array(str,strict)
if not str or str == "" then
return { }
+ elseif strict then
+ if find(str,"{") then
+ return lpegmatch(pattern,str)
+ else
+ return { str }
+ end
else
return lpegmatch(pattern,str)
end
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index f5f6991ea..bae10bc5c 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 : 07/14/11 16:09:42
+-- merge date : 07/19/11 10:35:41
do -- begin closure to overcome local limits and interference
@@ -4154,7 +4154,7 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
for i=1,#initializers do
local step = initializers[i]
local feature = step.name
--- we could intercept mode here .. needs a rewrite of this whole loop then btu it's cleaner that way
+-- we could intercept mode here .. needs a rewrite of this whole loop then but it's cleaner that way
local value = features[feature]
if not value then
-- disabled