summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-08-19 01:38:26 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-08-19 01:38:26 +0200
commited42bd4c79946716033bf5dbedbd54bbe81f49e8 (patch)
treea3d63d74f0e07f799c538eb04096195b6b6d4631 /tex/context/base/mkiv
parent30b3a925bfc1857a31e23d9b17b8da0be572d02a (diff)
downloadcontext-ed42bd4c79946716033bf5dbedbd54bbe81f49e8.tar.gz
2016-08-19 00:35:00
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r--tex/context/base/mkiv/anch-bar.mkiv1
-rw-r--r--tex/context/base/mkiv/anch-bck.mkvi3
-rw-r--r--tex/context/base/mkiv/anch-snc.mkiv1
-rw-r--r--tex/context/base/mkiv/char-def.lua3
-rw-r--r--tex/context/base/mkiv/chem-str.mkiv2
-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/core-env.lua2
-rw-r--r--tex/context/base/mkiv/font-ctx.lua2
-rw-r--r--tex/context/base/mkiv/font-ext.lua85
-rw-r--r--tex/context/base/mkiv/font-ini.mkvi17
-rw-r--r--tex/context/base/mkiv/font-pre.mkiv7
-rw-r--r--tex/context/base/mkiv/grph-inc.mkiv5
-rw-r--r--tex/context/base/mkiv/math-ali.mkiv64
-rw-r--r--tex/context/base/mkiv/math-ini.mkiv3
-rw-r--r--tex/context/base/mkiv/math-pln.mkiv2
-rw-r--r--tex/context/base/mkiv/meta-imp-txt.mkiv2
-rw-r--r--tex/context/base/mkiv/meta-tex.lua59
-rw-r--r--tex/context/base/mkiv/mlib-pps.lua22
-rw-r--r--tex/context/base/mkiv/page-mrk.mkiv8
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin9240 -> 9243 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin368827 -> 368801 bytes
-rw-r--r--tex/context/base/mkiv/supp-vis.mkiv2
-rw-r--r--tex/context/base/mkiv/util-str.lua88
24 files changed, 268 insertions, 114 deletions
diff --git a/tex/context/base/mkiv/anch-bar.mkiv b/tex/context/base/mkiv/anch-bar.mkiv
index c58d48abd..3ae138a22 100644
--- a/tex/context/base/mkiv/anch-bar.mkiv
+++ b/tex/context/base/mkiv/anch-bar.mkiv
@@ -149,7 +149,6 @@
\startMPpositionmethod{mpos:sidebar}
\startMPpositiongraphic{mpos:sidebar}{linecolor,linewidth,distance,alternative}%
- if unknown context_apos : input mp-apos.mpiv ; fi ;
anch_sidebars_draw (
\MPp\MPbself,\MPp\MPeself,\MPy\MPbself,\MPy\MPeself,\MPh\MPbself,\MPd\MPeself,
\MPx{\textanchor},\MPy{\textanchor},\MPw{\textanchor},\MPh{\textanchor},
diff --git a/tex/context/base/mkiv/anch-bck.mkvi b/tex/context/base/mkiv/anch-bck.mkvi
index 953c3440f..fe9f9a168 100644
--- a/tex/context/base/mkiv/anch-bck.mkvi
+++ b/tex/context/base/mkiv/anch-bck.mkvi
@@ -348,7 +348,6 @@
dashtype=1]
\startuseMPgraphic{mpos:region:setup}
- if unknown context_abck : input mp-abck.mpiv ; fi ;
boxgridtype := \MPvar{gridtype} ;
boxlinetype := \MPvar{linetype} ;
boxfilltype := \MPvar{filltype} ;
@@ -448,7 +447,6 @@
linewidth=1pt]
\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset}
- if unknown context_apos : input mp-apos.mpiv ; fi ;
\MPgetposboxes{\MPvar{self}}{\MPanchorid}
if nofposboxes = 1 :
posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered \MPvar{lineoffset} ;
@@ -464,7 +462,6 @@
linewidth=1pt]
\startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth}
- if unknown context_apos : input mp-apos.mpiv ; fi ;
boxlinewidth := \MPvar{linewidth} ;
boxlineoffset := \MPvar{lineoffset} ;
def boxlineoptions = withcolor \MPvar{linecolor} enddef ;
diff --git a/tex/context/base/mkiv/anch-snc.mkiv b/tex/context/base/mkiv/anch-snc.mkiv
index d0d3a58d1..3e99da8a6 100644
--- a/tex/context/base/mkiv/anch-snc.mkiv
+++ b/tex/context/base/mkiv/anch-snc.mkiv
@@ -168,7 +168,6 @@
\definesyncpositions[1]
\startuseMPgraphic{sync}
- if unknown context_abck : input mp-abck.mpiv ; fi ;
StartPage ;
\getsyncpositions{1} ;
SyncThreshold := 2LineHeight ;
diff --git a/tex/context/base/mkiv/char-def.lua b/tex/context/base/mkiv/char-def.lua
index 98882b561..38fe57c19 100644
--- a/tex/context/base/mkiv/char-def.lua
+++ b/tex/context/base/mkiv/char-def.lua
@@ -432,11 +432,14 @@ characters.data={
adobename="hyphen",
category="pd",
cjkwd="na",
+ contextname="texthyphen",
description="HYPHEN-MINUS",
direction="es",
linebreak="hy",
mathextensible="h",
mathfiller="relfill",
+ mathclass="nothing",
+ mathname="mathhyphen",
mathsymbol=0x2212,
unicodeslot=0x2D,
},
diff --git a/tex/context/base/mkiv/chem-str.mkiv b/tex/context/base/mkiv/chem-str.mkiv
index ec2067f60..2ff229b12 100644
--- a/tex/context/base/mkiv/chem-str.mkiv
+++ b/tex/context/base/mkiv/chem-str.mkiv
@@ -72,7 +72,7 @@
\c!method=\s!double]
\startMPdefinitions{chemistry}
- input mp-chem.mpiv ;
+ loadmodule "chem" ;
\stopMPdefinitions
\defineframed
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 11508c4c1..aaf7f7186 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2016.08.15 22:40}
+\newcontextversion{2016.08.19 00:30}
%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 fc4b3427a..b49ed822b 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -39,7 +39,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2016.08.15 22:40}
+\edef\contextversion{2016.08.19 00:30}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/core-env.lua b/tex/context/base/mkiv/core-env.lua
index cd5439919..583a6ed1e 100644
--- a/tex/context/base/mkiv/core-env.lua
+++ b/tex/context/base/mkiv/core-env.lua
@@ -38,7 +38,7 @@ local modes = { }
local systemmodes = { }
-- we could use the built-in tex.is[count|dimen|skip|toks] here but caching
--- at the lua en dis not that bad (and we need more anyway)
+-- at the lua end is not that bad (and we need more anyway)
-- undefined: mode == 0 or cmdname = "undefined_cs"
diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua
index 2f51f5129..98accd7a3 100644
--- a/tex/context/base/mkiv/font-ctx.lua
+++ b/tex/context/base/mkiv/font-ctx.lua
@@ -569,7 +569,7 @@ local function presetcontext(name,parent,features) -- will go to con and shared
-- optimization)
local t = { } -- can we avoid t ?
for k,v in next, features do
--- if v then t[k] = v end
+ -- if v then t[k] = v end
t[k] = v
end
-- needed for dynamic features
diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua
index 7ab11ffb0..cadce625c 100644
--- a/tex/context/base/mkiv/font-ext.lua
+++ b/tex/context/base/mkiv/font-ext.lua
@@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['font-ext'] = {
}
local next, type, byte = next, type, string.byte
+local utfchar = utf.char
local context = context
local fonts = fonts
@@ -32,11 +33,13 @@ local registerotffeature = handlers.otf.features.register
local registerafmfeature = handlers.afm.features.register
local fontdata = hashes.identifiers
+local fontproperties = hashes.properties
local allocate = utilities.storage.allocate
local settings_to_array = utilities.parsers.settings_to_array
local getparameters = utilities.parsers.getparameters
local gettexdimen = tex.getdimen
+local family_font = node.family_font
local setmetatableindex = table.setmetatableindex
@@ -977,16 +980,16 @@ registerafmfeature(dimensions_specification)
local nodepool = nodes.pool
-local new_special = nodepool.special
+----- new_special = nodepool.special
+----- hpack_node = node.hpack
local new_glyph = nodepool.glyph
-local hpack_node = node.hpack
local helpers = fonts.helpers
local currentfont = font.current
function helpers.addprivate(tfmdata,name,characterdata)
- local properties = tfmdata.properties
- local privates = properties.privates
+ local properties = tfmdata.properties
+ local privates = properties.privates
local lastprivate = properties.lastprivate
if lastprivate then
lastprivate = lastprivate + 1
@@ -1008,25 +1011,36 @@ function helpers.addprivate(tfmdata,name,characterdata)
return lastprivate
end
+local function getprivateslot(id,name)
+ if not name then
+ name = id
+ id = currentfont()
+ end
+ local properties = fontproperties[id]
+ local privates = properties and properties.privates
+ return privates and privates[name]
+end
+
+helpers.getprivateslot = getprivateslot
+
+-- was originally meant for missing chars:
+--
+-- local char = tfmdata.characters[p]
+-- local commands = char.commands
+-- if commands then
+-- local fake = hpack_node(new_special(commands[1][2]))
+-- fake.width = char.width
+-- fake.height = char.height
+-- fake.depth = char.depth
+-- return fake
+-- else
+
local function getprivatenode(tfmdata,name)
- local properties = tfmdata.properties
- local privates = properties and properties.privates
- if privates then
- local p = privates[name]
- if p then
- local char = tfmdata.characters[p]
- local commands = char.commands
- if commands then
- local fake = hpack_node(new_special(commands[1][2]))
- fake.width = char.width
- fake.height = char.height
- fake.depth = char.depth
- return fake
- else
- -- todo: set current attribibutes
- return new_glyph(properties.id,p)
- end
- end
+ local id = tfmdata.properties.id
+ local p = getprivateslot(id,name)
+ if p then
+ -- todo: set current attribibutes
+ return new_glyph(id,p)
end
end
@@ -1042,6 +1056,31 @@ implement {
name = "getprivatechar",
arguments = "string",
actions = function(name)
- context(getprivatenode(fontdata[currentfont()],name))
+ local p = getprivateslot(name)
+ if p then
+ context(utfchar(p))
+ end
+ end
+}
+
+implement {
+ name = "getprivatemathchar",
+ arguments = "string",
+ actions = function(name)
+ local p = getprivateslot(family_font(0),name)
+ if p then
+ context(utfchar(p))
+ end
+ end
+}
+
+implement {
+ name = "getprivateslot",
+ arguments = "string",
+ actions = function(name)
+ local p = getprivateslot(name)
+ if p then
+ context(p)
+ end
end
}
diff --git a/tex/context/base/mkiv/font-ini.mkvi b/tex/context/base/mkiv/font-ini.mkvi
index 93753f986..26a644aba 100644
--- a/tex/context/base/mkiv/font-ini.mkvi
+++ b/tex/context/base/mkiv/font-ini.mkvi
@@ -2669,7 +2669,22 @@
%D Handy for defining additional glyphs:
-\let\getprivateglyphslot\clf_getprivateglyphslot
+\let\getprivateglyphslot\clf_getprivateglyphslot % kind of private macro
+
+\let\getprivatechar \clf_getprivatechar % gives back a utf !
+\let\getprivatemathchar \clf_getprivatemathchar % gives back a utf !
+\let\getprivateslot \clf_getprivateslot % companion to fonts.helpers.addprivate
+
+% \unexpanded\def\getprivatemathchar#1%
+% {\begingroup\the\textfont\zerocount\getprivatechar{#1}\endgroup}
+
+
+\def\privatechar % the text variant gets expanded to utf
+ {\ifmmode
+ \expandafter\getprivatemathchar
+ \else
+ \expandafter\getprivatechar
+ \fi}
% yes or no:
diff --git a/tex/context/base/mkiv/font-pre.mkiv b/tex/context/base/mkiv/font-pre.mkiv
index 801702e15..5d93ab4f1 100644
--- a/tex/context/base/mkiv/font-pre.mkiv
+++ b/tex/context/base/mkiv/font-pre.mkiv
@@ -245,10 +245,10 @@
\definefontfeature
[mathematics]
[mode=base,
- liga=yes,
kern=yes,
- tlig=yes,
- trep=yes,
+ % liga=yes, % makes no sense
+ % tlig=yes, % makes no sense
+ % trep=yes, % makes no sense
mathalternates=yes,
mathitalics=yes, % we pass them
% mathgaps=yes,
@@ -271,7 +271,6 @@
[mathematics-r2l]
[mathematics]
[rtlm=yes,
- %dtls=yes,
locl=yes]
\definefontfeature[virtualmath] [mathematics] % downward compatibility
diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv
index 5600ac868..d7eb77262 100644
--- a/tex/context/base/mkiv/grph-inc.mkiv
+++ b/tex/context/base/mkiv/grph-inc.mkiv
@@ -874,7 +874,10 @@
\defineexternalfigure
[\v!combination]
- [\c!width=\dimexpr(\textwidth-\numexpr\combinationparameter\c!nx-\plusone\relax\dimexpr\combinationparameter\c!distance\relax)/\combinationparameter\c!nx\relax]
+ [\c!width=\dimexpr(%
+ \textwidth-\effectiveleftskip-\effectiverightskip
+ -\numexpr\combinationparameter\c!nx-\plusone\relax\dimexpr\combinationparameter\c!distance\relax
+ )/\combinationparameter\c!nx\relax]
% \startcombination[nx=2,ny=1]
% {\externalfigure[dummy][combination]} {}
diff --git a/tex/context/base/mkiv/math-ali.mkiv b/tex/context/base/mkiv/math-ali.mkiv
index 756939eec..497712818 100644
--- a/tex/context/base/mkiv/math-ali.mkiv
+++ b/tex/context/base/mkiv/math-ali.mkiv
@@ -155,7 +155,9 @@
{\hfil
\tabskip\centering
\aligntab
- \llap{\span\math_text_in_eqalign{\alignmark\alignmark}}%
+ \span
+ \rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
+ % \math_text_in_eqalign{\alignmark\alignmark}%
\tabskip\zeropoint}%
\fi\fi
\global\mathnumberstatus\zerocount
@@ -165,17 +167,17 @@
\def\math_prepare_l_eqalign_no % \checkeddisplaymath
{\t_math_align_a
- {\strut
- \tabskip\zeropoint
- \alignmark\alignmark % for picking up the number
- \aligntab
- \math_first_in_eqalign
- \hfil
- \math_left_of_equalign
- \span
- \math_math_in_eqalign{\alignmark\alignmark}%
- \math_right_of_eqalign
- \tabskip\zeropoint}%
+ {\strut
+ \tabskip\zeropoint
+ \alignmark\alignmark % for picking up the number
+ \aligntab
+ \math_first_in_eqalign
+ \hfil
+ \math_left_of_equalign
+ \span
+ \math_math_in_eqalign{\alignmark\alignmark}%
+ \math_right_of_eqalign
+ \tabskip\zeropoint}%
\t_math_align_b
{\aligntab
\math_next_in_eqalign
@@ -187,10 +189,11 @@
\ifnum\mathraggedstatus=\plusone
\t_math_align_c
{\hfil
- \aligntab
- \kern-\displaywidth
- \rlap{\span\math_text_in_eqalign{\alignmark\alignmark}}%
- \tabskip\displaywidth}%
+ \aligntab
+ \kern-\displaywidth
+ \span
+ \rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
+ \tabskip\displaywidth}%
\else\ifnum\mathraggedstatus=\plusthree
\t_math_align_c
{\hfil
@@ -198,7 +201,7 @@
\aligntab
\kern-\displaywidth
\span
- \math_rlap{\span\math_text_in_eqalign{\alignmark\alignmark}}%
+ \math_rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
\tabskip\displaywidth}%
\else
\t_math_align_c
@@ -206,7 +209,8 @@
\tabskip\centering
\aligntab
\kern-\displaywidth
- \rlap{\span\math_text_in_eqalign{\alignmark\alignmark}}%
+ \span
+ \rlap{\math_text_in_eqalign{\alignmark\alignmark}}%
\tabskip\displaywidth}%
\fi\fi
\global\mathnumberstatus\zerocount
@@ -214,6 +218,7 @@
\the\mathdisplayaligntweaks
\tabskip\centering}
+
\def\math_halign_checked
{\halign
\ifnum\c_strc_formulas_mode=\plustwo
@@ -299,7 +304,7 @@
\def\math_alignment_NC_first#1\NR
{\glet\math_alignment_NC\math_alignment_NC_rest
- \scratchtoks{\aligntab#1\NR}%
+ \scratchtoks{\math_number_left_of_eqalign\aligntab#1\NR}%
\dodoubleempty\math_alignment_NC_first_indeed}
\def\math_alignment_NC_first_indeed[#1][#2]%
@@ -308,6 +313,7 @@
\def\math_alignment_NR
{\aligntab
\dostoptagged % finish cell
+ \math_number_right_of_eqalign
\crcr
\dostoptagged % finish row
\noalign{\glet\math_alignment_NC\math_alignment_NC_first}} % noalign used for change state, conditional does not work here
@@ -438,25 +444,29 @@
\dostarttagged\t!mathtablecell\empty}
\def\math_left_of_equalign
- {\ifcase\wd\b_strc_formulas_number\else
- \ifcase\c_strc_math_number_location\or
- \box\b_strc_formulas_number
- \fi
- \fi
- \ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname
+ {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname
\ifcase\lastnamedcs \or \relax \or \hfill \or \hfill \fi
\fi}
\def\math_right_of_eqalign
{\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname
\ifcase\lastnamedcs \or \hfill \or \relax \or \hfill \fi
- \fi
- \ifcase\wd\b_strc_formulas_number\else
+ \fi}
+
+\def\math_number_right_of_eqalign
+ {\ifcase\wd\b_strc_formulas_number\else
\ifcase\c_strc_math_number_location\or\or
\box\b_strc_formulas_number
\fi
\fi}
+\def\math_number_left_of_eqalign
+ {\ifcase\wd\b_strc_formulas_number\else
+ \ifcase\c_strc_math_number_location\or
+ \box\b_strc_formulas_number
+ \fi
+ \fi}
+
\def\math_eqalign_set_column#1% we could just add to the preamble (as with other alignments)
{\expandafter\let\csname\??mathalignmentvariant\number\c_math_eqalign_column\expandafter\endcsname
\csname\??mathalignmentvariant\ifcsname\??mathalignmentvariant#1\endcsname#1\else\v!normal\fi\endcsname}
diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv
index f9963b9b3..ed92876ac 100644
--- a/tex/context/base/mkiv/math-ini.mkiv
+++ b/tex/context/base/mkiv/math-ini.mkiv
@@ -107,9 +107,6 @@
\appendtoks
\attribute\mathmodeattribute\plusone
-\to \everybeforedisplayformula
-
-\appendtoksonce
\attribute\displaymathattribute\plusone
\to \everybeforedisplayformula
diff --git a/tex/context/base/mkiv/math-pln.mkiv b/tex/context/base/mkiv/math-pln.mkiv
index a5ecdd11d..754cb6141 100644
--- a/tex/context/base/mkiv/math-pln.mkiv
+++ b/tex/context/base/mkiv/math-pln.mkiv
@@ -29,7 +29,7 @@
% will move
\def\oalign#1%
- {\leavevmode
+ {\leavevmode % plain tex uses this
\vtop
{\baselineskip\zeroskip
\lineskip.25\exheight
diff --git a/tex/context/base/mkiv/meta-imp-txt.mkiv b/tex/context/base/mkiv/meta-imp-txt.mkiv
index 7069d21a4..ae616ddb2 100644
--- a/tex/context/base/mkiv/meta-imp-txt.mkiv
+++ b/tex/context/base/mkiv/meta-imp-txt.mkiv
@@ -31,7 +31,7 @@
\definesystemvariable {sh} % ShapedText .. todo: commandhandler
\startMPextensions
- if unknown context_text: input "mp-text.mpiv" ; fi;
+ loadmodule "text" ;
\stopMPextensions
%%%%%%%
diff --git a/tex/context/base/mkiv/meta-tex.lua b/tex/context/base/mkiv/meta-tex.lua
index 9c5a2186d..205024fae 100644
--- a/tex/context/base/mkiv/meta-tex.lua
+++ b/tex/context/base/mkiv/meta-tex.lua
@@ -124,6 +124,10 @@ function metapost.format_string(fmt,...)
end
function metapost.format_number(fmt,num)
+ if not num then
+ num = fmt
+ fmt = "%e"
+ end
local number = tonumber(num)
if number then
local base, exponent = lpegmatch(enumber,formatters[lpegmatch(cleaner,fmt)](number))
@@ -150,6 +154,59 @@ end
implement { name = "metapostformatted", actions = metapost.svformat, arguments = { "string", "string" } }
implement { name = "metapostgraphformat", actions = metapost.nvformat, arguments = { "string", "string" } }
+-- kind of new
+
+local f_exponent = formatters["\\MPexponent{%s}{%s}"]
+
+local mpformatters = table.setmetatableindex(function(t,k)
+ local v = formatters[lpegmatch(cleaner,k)]
+ t[k] = v
+ return v
+end)
+
+function metapost.texexp(num,bfmt,efmt)
+ local number = tonumber(num)
+ if number then
+ local base, exponent = lpegmatch(enumber,format("%e",number))
+ if base and exponent then
+ if bfmt then
+ -- base = formatters[lpegmatch(cleaner,bfmt)](base)
+ base = mpformatters[bfmt](base)
+ else
+ base = format("%f",base)
+ end
+ if efmt then
+ -- exponent = formatters[lpegmatch(cleaner,efmt)](exponent)
+ exponent = mpformatters[efmt](exponent)
+ else
+ exponent = format("%i",exponent)
+ end
+ return f_exponent(base,exponent)
+ elseif bfmt then
+ -- return formatters[lpegmatch(cleaner,bfmt)](number)
+ return mpformatters[bfmt](number)
+ else
+ return number
+ end
+ else
+ return num
+ end
+end
+
+-- not in context a namespace
+
+if _LUAVERSION < 5.2 then
+ utilities.strings.formatters.add(formatters,"texexp", [[texexp(...)]], "local texexp = metapost.texexp")
+else
+ utilities.strings.formatters.add(formatters,"texexp", [[texexp(...)]], { texexp = metapost.texexp })
+end
+
+-- print(string.formatters["%!3.3!texexp!"](10.4345E30))
+-- print(string.formatters["%3!texexp!"](10.4345E30,"%2.3f","%2i"))
+-- print(string.formatters["%2!texexp!"](10.4345E30,"%2.3f"))
+-- print(string.formatters["%1!texexp!"](10.4345E30))
+-- print(string.formatters["%!texexp!"](10.4345E30))
+
-- local function test(fmt,n)
-- logs.report("mp format test","fmt: %s, n: %s, result: %s, \\exponent{%s}{%s}",fmt,n,
-- formatters[lpegmatch(cleaner,fmt)](n),
@@ -180,6 +237,8 @@ local f_textext = formatters[ [[textext("%s")]] ]
local f_mthtext = formatters[ [[textext("\mathematics{%s}")]] ]
local f_exptext = formatters[ [[textext("\mathematics{%s\times10^{%s}}")]] ]
+-- local cleaner = Cs((P("\\")/"\\\\" + P("@@")/"@" + P("@")/"%%" + P(1))^0)
+
local mpprint = mp.print
function mp.format(fmt,str)
diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua
index 8d200ac63..23091342f 100644
--- a/tex/context/base/mkiv/mlib-pps.lua
+++ b/tex/context/base/mkiv/mlib-pps.lua
@@ -971,6 +971,25 @@ local ctx_MPLIBsettext = context.MPLIBsettext
-- we always create at least one instance (for dimensions)
-- we make sure we don't do that when we use one (else counter issues with e.g. \definelabel)
+local eol = S("\n\r")^1
+local cleaner = Cs((P("@@")/"@" + P("@")/"%%" + P(1))^0)
+local splitter = Ct(
+ ( (
+ P("s:") * C((1-eol)^1)
+ + P("n:") * ((1-eol)^1/tonumber)
+ + P("b:") * ((1-eol)^1/toboolean)
+ ) * eol^0 )^0)
+
+local function applyformat(s)
+ local t = lpegmatch(splitter,s)
+ if #t == 1 then
+ return s
+ else
+ local f = lpegmatch(cleaner,t[1])
+ return formatters[f](unpack(t,2))
+ end
+end
+
local function tx_analyze(object,prescript)
local data = top.texdata[metapost.properties.number]
local tx_stage = prescript.tx_stage
@@ -986,6 +1005,9 @@ local function tx_analyze(object,prescript)
c = lpegmatch(pat,txc)
end
end
+ if prescript.tx_type == "format" then
+ s = applyformat(s)
+ end
local a = tonumber(prescript.tr_alternative)
local t = tonumber(prescript.tr_transparency)
local h = fmt(tx_number,a or "-",t or "-",c or "-")
diff --git a/tex/context/base/mkiv/page-mrk.mkiv b/tex/context/base/mkiv/page-mrk.mkiv
index 0cd615f8a..d84e9c60e 100644
--- a/tex/context/base/mkiv/page-mrk.mkiv
+++ b/tex/context/base/mkiv/page-mrk.mkiv
@@ -35,22 +35,22 @@
\newcount\c_page_marks_ny
\startuniqueMPgraphic{print:color}{w,h,l,o}
- if unknown context_crop : input mp-crop.mpiv ; fi ;
+ loadmodule "crop" ;
page_marks_add_color(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ;
\stopuniqueMPgraphic
\startuniqueMPgraphic{print:marking}{w,h,l,o}
- if unknown context_crop : input mp-crop.mpiv ; fi ;
+ loadmodule "crop" ;
page_marks_add_marking(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ;
\stopuniqueMPgraphic
\startuniqueMPgraphic{print:lines}{w,h,l,o,x,y}
- if unknown context_crop : input mp-crop.mpiv ; fi ;
+ loadmodule "crop" ;
page_marks_add_lines(\MPvar w,\MPvar h,\MPvar l,\MPvar o,\MPvar x,\MPvar y) ;
\stopuniqueMPgraphic
\startuseMPgraphic{print:number}{w,h,l,o,n}
- if unknown context_crop : input mp-crop.mpiv ; fi ;
+ loadmodule "crop" ;
page_marks_add_number(\MPvar w,\MPvar h,\MPvar l,\MPvar o,\MPvar n) ;
\stopuseMPgraphic
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 10ad1bcfd..eec704b7f 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 05f1666a9..390810d51 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/supp-vis.mkiv b/tex/context/base/mkiv/supp-vis.mkiv
index 8b9420162..e12c4c534 100644
--- a/tex/context/base/mkiv/supp-vis.mkiv
+++ b/tex/context/base/mkiv/supp-vis.mkiv
@@ -1360,7 +1360,7 @@
%D \ShowBufferedExample
\def\supp_visualizers_hglue_indeed
- {\leavevmode
+ {\leavevmode % plain tex uses this
\scratchcounter\spacefactor
\visualvrule\s!width\zeropoint
\normalpenalty\plustenthousand
diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua
index a54a4aac9..42dbf16b3 100644
--- a/tex/context/base/mkiv/util-str.lua
+++ b/tex/context/base/mkiv/util-str.lua
@@ -10,7 +10,7 @@ utilities = utilities or { }
utilities.strings = utilities.strings or { }
local strings = utilities.strings
-local format, gsub, rep, sub = string.format, string.gsub, string.rep, string.sub
+local format, gsub, rep, sub, find = string.format, string.gsub, string.rep, string.sub, string.find
local load, dump = load, string.dump
local tonumber, type, tostring = tonumber, type, tostring
local unpack, concat = table.unpack, table.concat
@@ -385,6 +385,43 @@ function number.signed(i)
end
end
+-- maybe to util-num
+
+local digit = patterns.digit
+local period = patterns.period
+local three = digit * digit * digit
+
+local splitter = Cs (
+ (((1 - (three^1 * period))^1 + C(three)) * (Carg(1) * three)^1 + C((1-period)^1))
+ * (P(1)/"" * Carg(2)) * C(2)
+)
+
+patterns.formattednumber = splitter
+
+function number.formatted(n,sep1,sep2)
+ local s = type(s) == "string" and n or format("%0.2f",n)
+ if sep1 == true then
+ return lpegmatch(splitter,s,1,".",",")
+ elseif sep1 == "." then
+ return lpegmatch(splitter,s,1,sep1,sep2 or ",")
+ elseif sep1 == "," then
+ return lpegmatch(splitter,s,1,sep1,sep2 or ".")
+ else
+ return lpegmatch(splitter,s,1,sep1 or ",",sep2 or ".")
+ end
+end
+
+-- print(number.formatted(1))
+-- print(number.formatted(12))
+-- print(number.formatted(123))
+-- print(number.formatted(1234))
+-- print(number.formatted(12345))
+-- print(number.formatted(123456))
+-- print(number.formatted(1234567))
+-- print(number.formatted(12345678))
+-- print(number.formatted(12345678,true))
+-- print(number.formatted(1234.56,"!","?"))
+
local zero = P("0")^1 / ""
local plus = P("+") / ""
local minus = P("-")
@@ -732,43 +769,6 @@ local format_W = function(f) -- handy when doing depth related indent
return format("nspaces[%s]",tonumber(f) or 0)
end
--- maybe to util-num
-
-local digit = patterns.digit
-local period = patterns.period
-local three = digit * digit * digit
-
-local splitter = Cs (
- (((1 - (three^1 * period))^1 + C(three)) * (Carg(1) * three)^1 + C((1-period)^1))
- * (P(1)/"" * Carg(2)) * C(2)
-)
-
-patterns.formattednumber = splitter
-
-function number.formatted(n,sep1,sep2)
- local s = type(s) == "string" and n or format("%0.2f",n)
- if sep1 == true then
- return lpegmatch(splitter,s,1,".",",")
- elseif sep1 == "." then
- return lpegmatch(splitter,s,1,sep1,sep2 or ",")
- elseif sep1 == "," then
- return lpegmatch(splitter,s,1,sep1,sep2 or ".")
- else
- return lpegmatch(splitter,s,1,sep1 or ",",sep2 or ".")
- end
-end
-
--- print(number.formatted(1))
--- print(number.formatted(12))
--- print(number.formatted(123))
--- print(number.formatted(1234))
--- print(number.formatted(12345))
--- print(number.formatted(123456))
--- print(number.formatted(1234567))
--- print(number.formatted(12345678))
--- print(number.formatted(12345678,true))
--- print(number.formatted(1234.56,"!","?"))
-
local format_m = function(f)
n = n + 1
if not f or f == "" then
@@ -801,9 +801,16 @@ end
local format_extension = function(extensions,f,name)
local extension = extensions[name] or "tostring(%s)"
local f = tonumber(f) or 1
+ local w = find(extension,"%.%.%.")
if f == 0 then
+ if w then
+ extension = gsub(extension,"%.%.%.","")
+ end
return extension
elseif f == 1 then
+ if w then
+ extension = gsub(extension,"%.%.%.","%%s")
+ end
n = n + 1
local a = "a" .. n
return format(extension,a,a) -- maybe more times?
@@ -811,6 +818,11 @@ local format_extension = function(extensions,f,name)
local a = "a" .. (n + f + 1)
return format(extension,a,a)
else
+ if w then
+ extension = gsub(extension,"%.%.%.",rep("%%s,",f-1).."%%s")
+ end
+ -- we could fill an array and then n = n + 1 unpack(t,n,n+f) but as we
+ -- cache we don't save much and there are hardly any extensions anyway
local t = { }
for i=1,f do
n = n + 1