summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-08-18 17:40:23 +0300
committerMarius <mariausol@gmail.com>2011-08-18 17:40:23 +0300
commit5463542d926a6ca73d86251154cabc00a9333fa5 (patch)
tree33c0104835277e96d6b0474466e75963fef16de4 /tex
parentee4f24d635e0db2029f026a1c098ae76d1e537d3 (diff)
downloadcontext-5463542d926a6ca73d86251154cabc00a9333fa5.tar.gz
beta 2011.08.18 16:00
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/back-exp.lua22
-rw-r--r--tex/context/base/back-pdf.mkiv2
-rw-r--r--tex/context/base/bibl-tra.mkiv17
-rw-r--r--tex/context/base/buff-ver.mkiv6
-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-base.lmx7
-rw-r--r--tex/context/base/context-version.pdfbin4090 -> 4092 bytes
-rw-r--r--tex/context/base/context-version.pngbin105681 -> 106138 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/data-exp.lua90
-rw-r--r--tex/context/base/data-pre.lua2
-rw-r--r--tex/context/base/file-job.lua2
-rw-r--r--tex/context/base/font-con.lua10
-rw-r--r--tex/context/base/font-ctx.lua11
-rw-r--r--tex/context/base/font-ext.lua18
-rw-r--r--tex/context/base/font-otn.lua6
-rw-r--r--tex/context/base/grph-inc.lua16
-rw-r--r--tex/context/base/l-lpeg.lua13
-rw-r--r--tex/context/base/lang-def.mkiv2
-rw-r--r--tex/context/base/lpdf-mis.lua78
-rw-r--r--tex/context/base/lpdf-xmp.lua12
-rw-r--r--tex/context/base/lxml-lpt.lua13
-rw-r--r--tex/context/base/lxml-tab.lua11
-rw-r--r--tex/context/base/math-ali.mkiv58
-rw-r--r--tex/context/base/mult-aux.mkiv51
-rw-r--r--tex/context/base/mult-sys.mkiv2
-rw-r--r--tex/context/base/node-inj.lua16
-rw-r--r--tex/context/base/node-res.lua10
-rw-r--r--tex/context/base/pack-rul.mkiv71
-rw-r--r--tex/context/base/page-imp.mkiv10
-rw-r--r--tex/context/base/page-mrk.mkiv12
-rw-r--r--tex/context/base/page-one.mkiv2
-rw-r--r--tex/context/base/phys-dim.lua88
-rw-r--r--tex/context/base/phys-dim.mkiv147
-rw-r--r--tex/context/base/scrn-bar.mkvi8
-rw-r--r--tex/context/base/scrn-but.mkvi4
-rw-r--r--tex/context/base/scrn-fld.mkvi2
-rw-r--r--tex/context/base/scrn-hlp.mkvi4
-rw-r--r--tex/context/base/spac-ver.mkiv2
-rw-r--r--tex/context/base/status-files.pdfbin23848 -> 23869 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin162226 -> 162210 bytes
-rw-r--r--tex/context/base/strc-def.mkiv2
-rw-r--r--tex/context/base/strc-doc.lua51
-rw-r--r--tex/context/base/strc-flt.mkiv4
-rw-r--r--tex/context/base/strc-lst.mkiv86
-rw-r--r--tex/context/base/strc-not.mkiv5
-rw-r--r--tex/context/base/strc-num.mkiv76
-rw-r--r--tex/context/base/strc-ren.mkiv1
-rw-r--r--tex/context/base/strc-sbe.mkiv2
-rw-r--r--tex/context/base/strc-sec.mkiv189
-rw-r--r--tex/context/base/syst-aux.mkiv128
-rw-r--r--tex/context/base/type-otf.mkiv44
-rw-r--r--tex/context/base/typo-krn.lua121
-rw-r--r--tex/context/base/typo-mar.lua17
-rw-r--r--tex/context/base/typo-mar.mkiv7
-rw-r--r--tex/context/base/util-str.lua58
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua47
59 files changed, 940 insertions, 731 deletions
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua
index 49ea38041..0fb7ca350 100644
--- a/tex/context/base/back-exp.lua
+++ b/tex/context/base/back-exp.lua
@@ -164,7 +164,7 @@ local numbertoallign = {
[3] = "left", ["3"] = "left", [variables.flushleft ] = "left",
}
-local defaultnature = "mixed" -- "inline"
+local defaultnature = "mixed" -- "inline"
setmetatableindex(used, function(t,k)
if k then
@@ -254,16 +254,18 @@ local function hashlistdata()
end
end
-local spaces = { } -- watch how we also moved the -1 in depth-1 to the creator
+--~ local spaces = { } -- watch how we also moved the -1 in depth-1 to the creator
-setmetatableindex(spaces, function(t,k)
- if not k then
- k = 1
- end
- local s = rep(" ",k-1)
- t[k] = s
- return s
-end)
+--~ setmetatableindex(spaces, function(t,k)
+--~ if not k then
+--~ return ""
+--~ end
+--~ local s = rep(" ",k-1)
+--~ t[k] = s
+--~ return s
+--~ end)
+
+local spaces = utilities.strings.newrepeater(" ",-1)
function structurestags.setattributehash(fulltag,key,value) -- public hash
if type(fulltag) == "number" then
diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv
index 469ead0db..0bd256241 100644
--- a/tex/context/base/back-pdf.mkiv
+++ b/tex/context/base/back-pdf.mkiv
@@ -115,7 +115,7 @@
%D An example of usage is:
-\appendtoks
+\appendtoks % this will be moved to lua
\pdfbackendsetinfo{ConTeXt.Version}{\contextversion}%
\pdfbackendsetinfo{ConTeXt.Time} {\number\normalyear.\twodigits\normalmonth.\twodigits\normalday\space \twodigits\currenthour:\twodigits\currentminute}%
\pdfbackendsetinfo{ConTeXt.Jobname}{\jobname}%
diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv
index 51309327e..e11e6fd6f 100644
--- a/tex/context/base/bibl-tra.mkiv
+++ b/tex/context/base/bibl-tra.mkiv
@@ -656,9 +656,7 @@
%D Now prohibits comments, so % can be used for urls
\unexpanded\def\startpublication
- {\begingroup
- \catcode\commentasciicode\othercatcode
- \dosingleempty\dostartpublication}
+ {\dosingleempty\dostartpublication}
\let\stoppublication\relax
@@ -676,12 +674,17 @@
% hm, we can store at the lua end ...
-\long\def\dostartpublication[#1]#2\stoppublication
- {\doifassignmentelse{#1}%
+\def\dostartpublication[#1]%
+ {\begingroup
+ \doifassignmentelse{#1}%
{\getparameters[\??pb][k=\s!unknown,t=article,n=,s=,a=,y=,o=,u=,#1]}%
{\getparameters[\??pb][k=#1,t=article,n=,s=,a=,y=,o=,u=]}%
\ctxlua{bibtex.hacks.register("\@@pbk")}%
- \setxvalue{pbd:\@@pbk}##1{\noexpand\ifcase##1\noexpand\or
+ \catcode\commentasciicode\othercatcode
+ \dodostartpublication}
+
+\def\dodostartpublication#1\stoppublication
+ {\setxvalue{pbd:\@@pbk}##1{\noexpand\ifcase##1\noexpand\or
\@@pbk\noexpand\or
\@@pba\noexpand\or
\@@pby\noexpand\or
@@ -690,7 +693,7 @@
\@@pbt\noexpand\or
\@@pbo\noexpand\or
\@@pbu\noexpand\or
- \normalunexpanded{#2}\noexpand\fi}%
+ \normalunexpanded{#1}\noexpand\fi}%
\endgroup
\ignorespaces}
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 168de9353..f0f25991e 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -108,7 +108,7 @@
%D Specific inline verbatim commands can be defined with the
%D following command.
-\installcommandhandler{\??ty}{type}{\??ty}
+\installcommandhandler \??ty {type} \??ty
\appendtoks
\normalexpanded{\dodefinetype{\currenttype}}%
@@ -138,7 +138,7 @@
%D
%D The definitions default to the standard typing values.
-\installcommandhandler{\??tp}{typing}{\??tp}
+\installcommandhandler \??tp {typing} \??tp
\appendtoks
\normalexpanded{\dodefinetyping{\currenttyping}}%
@@ -294,7 +294,7 @@
\doifnextoptionalelse\redotype\dodotype}
\def\redotype[#1]%
- {\getparameters[\??ty\currenttype][#1]%
+ {\setupcurrenttype[#1]%
\dodotype}
\def\dodotype
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index ab9b2c0c8..a6083522a 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.08.04 00:42}
+\newcontextversion{2011.08.18 16:00}
%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 3a3d255bf..9fd5d3b2d 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.08.04 00:42}
+\newcontextversion{2011.08.18 16:00}
%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-base.lmx b/tex/context/base/context-base.lmx
index fd27927bf..09817463b 100644
--- a/tex/context/base/context-base.lmx
+++ b/tex/context/base/context-base.lmx
@@ -24,6 +24,13 @@
<link rel="StyleSheet" href="<?lua p(v) ?>" type="text/css" />
<?lua end end ?>
</head>
+ <?lua if (v('refreshtime') and (tonumber(v('refreshtime')) or 0) > 0) and v('refreshurl') then ?>
+ <!--[if IE]>
+ <script type="text/javascript">
+ setTimeout("document.location='<?lua pv('refreshurl') ?>'", 1000*<?lua pv('refreshtime') ?>);
+ </script>
+ <![endif]-->
+ <?lua end ?>
<?lua if v('action') then ?>
<form action="<?lua pv(action) ?>" enctype="multi-part/form-data" method="post">
<?lua end ?>
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 37f99f05f..f016bdb39 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 92421e41a..82d42bb07 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 9bde019ef..1b0263da2 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.08.04 00:42}
+\edef\contextversion{2011.08.18 16:00}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 3fca14cff..11af839bd 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.08.04 00:42}
+\edef\contextversion{2011.08.18 16:00}
%D For those who want to use this:
diff --git a/tex/context/base/data-exp.lua b/tex/context/base/data-exp.lua
index 7f0805c6e..f300f00b0 100644
--- a/tex/context/base/data-exp.lua
+++ b/tex/context/base/data-exp.lua
@@ -130,41 +130,73 @@ end
-- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}}
-- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}
-local cleanup = lpeg.replacer {
- { "!" , "" },
- { "\\" , "/" },
-}
-
-local homedir
-
-function resolvers.cleanpath(str)
- if not homedir then
- homedir = lpegmatch(cleanup,environment.homedir or "")
- if homedir == char(127) or homedir == "" or not lfs.isdir(homedir) then
- if trace_expansions then
- report_expansions("no home dir set, ignoring dependent paths")
- end
- function resolvers.cleanpath(str)
- if find(str,"~") then
- return "" -- special case
- else
- return str and lpegmatch(cleanup,str)
- end
- end
- else
- cleanup = lpeg.replacer {
- { "!" , "" },
- { "\\" , "/" },
- { "~" , homedir },
- }
- function resolvers.cleanpath(str)
- return str and lpegmatch(cleanup,str)
+-- local cleanup = lpeg.replacer {
+-- { "!" , "" },
+-- { "\\" , "/" },
+-- }
+--
+-- local homedir
+--
+-- function resolvers.cleanpath(str) -- tricky, maybe only simple paths
+-- if not homedir then
+-- homedir = lpegmatch(cleanup,environment.homedir or "")
+-- if homedir == char(127) or homedir == "" or not lfs.isdir(homedir) then
+-- if trace_expansions then
+-- report_expansions("no home dir set, ignoring dependent paths")
+-- end
+-- function resolvers.cleanpath(str)
+-- if find(str,"~") then
+-- return "" -- special case
+-- else
+-- return str and lpegmatch(cleanup,str)
+-- end
+-- end
+-- else
+-- cleanup = lpeg.replacer {
+-- { "!" , "" },
+-- { "\\" , "/" },
+-- { "~" , homedir },
+-- }
+-- function resolvers.cleanpath(str)
+-- return str and lpegmatch(cleanup,str)
+-- end
+-- end
+-- end
+-- return resolvers.cleanpath(str)
+-- end
+
+function resolvers.cleanpath(str) -- tricky, maybe only simple paths
+ local doslashes = (P("\\")/"/" + 1)^0
+ local donegation = (P("!") /"" )^0
+ local homedir = lpegmatch(Cs(donegation * doslashes),environment.homedir or "")
+ if homedir == "~" or homedir == "" or not lfs.isdir(homedir) then
+ if trace_expansions then
+ report_expansions("no home dir set, ignoring dependent paths")
+ end
+ function resolvers.cleanpath(str)
+ if not str or find(str,"~") then
+ return "" -- special case
+ else
+ return lpegmatch(cleanup,str)
end
end
+ else
+ local dohome = ((P("~")+P("$HOME"))/homedir)^0
+ local cleanup = Cs(donegation * dohome * doslashes)
+ function resolvers.cleanpath(str)
+ return str and lpegmatch(cleanup,str) or ""
+ end
end
return resolvers.cleanpath(str)
end
+-- print(resolvers.cleanpath(""))
+-- print(resolvers.cleanpath("!"))
+-- print(resolvers.cleanpath("~"))
+-- print(resolvers.cleanpath("~/test"))
+-- print(resolvers.cleanpath("!~/test"))
+-- print(resolvers.cleanpath("~/test~test"))
+
-- This one strips quotes and funny tokens.
local expandhome = P("~") / "$HOME" -- environment.homedir
diff --git a/tex/context/base/data-pre.lua b/tex/context/base/data-pre.lua
index 4a5f0ecf5..383ca291e 100644
--- a/tex/context/base/data-pre.lua
+++ b/tex/context/base/data-pre.lua
@@ -64,7 +64,7 @@ end
prefixes.filename = function(str)
local fullname = findgivenfile(str) or ""
- return cleanpath(file.basename((fullname ~= "" and fullname) or str))
+ return cleanpath(file.basename((fullname ~= "" and fullname) or str)) -- no cleanpath needed here
end
prefixes.pathname = function(str)
diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua
index 8c9b69527..2004cdb85 100644
--- a/tex/context/base/file-job.lua
+++ b/tex/context/base/file-job.lua
@@ -384,7 +384,7 @@ end
local function logtree()
logspushtarget("logfile")
logsnewline()
- report_system("start used stucture")
+ report_system("start used structure")
logsnewline()
root.name = environment.jobname
log_tree(root,"")
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index a7df34199..9028443f0 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -327,6 +327,7 @@ function constructors.scale(tfmdata,specification)
local isvirtual = properties.virtualized or tfmdata.type == "virtual"
local hasquality = target.auto_expand or target.auto_protrude
local hasitalic = properties.italic_correction
+ local autoitalic = properties.auto_italic_correction
local stackmath = not properties.no_stackmath
local nonames = properties.noglyphnames
local nodemode = properties.mode == "node"
@@ -484,8 +485,13 @@ function constructors.scale(tfmdata,specification)
end
end
-- todo: hasitalic
- if hasitalic then
- local vi = description.italic or character.italic
+ if autoitalic then
+ local vi = description.italic or (description.boundingbox[3] - description.width + autoitalic)
+ if vi and vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ elseif hasitalic then
+ local vi = description.italic or character.italic -- why character
if vi and vi ~= 0 then
chr.italic = vi*hdelta
end
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 1d7580d84..7b5b5fd10 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -109,12 +109,14 @@ setmetatableindex(fontdata, function(t,k) return nulldata end)
local chardata = allocate() -- chardata
local parameters = allocate()
local csnames = allocate() -- namedata
-local quaddata = allocate() -- quaddata
+local quaddata = allocate()
+local markdata = allocate()
local xheightdata = allocate() -- xheightdata
hashes.characters = chardata
hashes.parameters = parameters
hashes.quads = quaddata
+hashes.marks = markdata
hashes.xheights = xheightdata
hashes.csnames = csnames
@@ -137,6 +139,13 @@ setmetatableindex(quaddata, function(t,k)
return quad
end)
+setmetatableindex(markdata, function(t,k)
+ local resources = fontdata[k].resources or { }
+ local marks = resources.marks or { }
+ t[k] = marks
+ return marks
+end)
+
setmetatableindex(xheightdata, function(t,k)
local parameters = parameters[k]
local xheight = parameters and parameters.xheight or 0
diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua
index bbe10e95d..598cfb2cb 100644
--- a/tex/context/base/font-ext.lua
+++ b/tex/context/base/font-ext.lua
@@ -495,14 +495,18 @@ local function initializeitlc(tfmdata,value) -- hm, always value
local parameters = tfmdata.parameters
local italicangle = parameters.italicangle
if italicangle and italicangle ~= 0 then
- local uwidth = (parameters.uwidth or 40)/2
- for unicode, d in next, tfmdata.descriptions do -- descriptions !
- local it = d.boundingbox[3] - d.width + uwidth
- if it ~= 0 then
- d.italic = it
- end
- end
+ local factor = tonumber(value) or 1
tfmdata.properties.italic_correction = true
+ tfmdata.properties.auto_italic_correction = factor * (parameters.uwidth or 40)/2
+ -- local descriptions = tfmdata.descriptions
+ -- local uwidth = (parameters.uwidth or 40)/2
+ -- for unicode, d in next, tfmdata.characters do -- we cannot loop over descriptions
+ -- local d = descriptions[unicode]
+ -- local it = d.boundingbox[3] - d.width + uwidth
+ -- if it ~= 0 then
+ -- d.italic = it
+ -- end
+ -- end
end
end
end
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua
index babf8b0d5..d9dc20f6c 100644
--- a/tex/context/base/font-otn.lua
+++ b/tex/context/base/font-otn.lua
@@ -412,7 +412,11 @@ function handlers.gsub_single(start,kind,lookupname,replacement)
end
local function alternative_glyph(start,alternatives,kind,chainname,chainlookupname,lookupname) -- chainname and chainlookupname optional
- local value, choice, n = featurevalue or tfmdata.shared.features[kind], nil, #alternatives -- global value, brrr
+ -- needs checking: (global value, brrr)
+ local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
+ local choice = nil
+ local n = #alternatives
+ --
if value == "random" then
local r = random(1,n)
value, choice = format("random, choice %s",r), alternatives[r]
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 0216c2555..88ad4adf5 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -518,7 +518,9 @@ end
local resolve_too = true -- urls
local function locate(request) -- name, format, cache
- local askedname = resolvers.cleanpath(request.name)
+ -- not resolvers.cleanpath(request.name) as it fails on a!b.pdf and b~c.pdf
+ -- todo: more restricted cleanpath
+ local askedname = request.name
local foundname = figures.found[askedname .. "->" .. (request.conversion or "default") .. "->" .. (request.resolution or "default")]
if foundname then
return foundname
@@ -845,7 +847,10 @@ end
function checkers.generic(data)
local dr, du, ds = data.request, data.used, data.status
- local name, page, size, color = du.fullname or "unknown generic", du.page or dr.page, dr.size or "crop", dr.color or "natural"
+ local name = du.fullname or "unknown generic"
+ local page = du.page or dr.page
+ local size = dr.size or "crop"
+ local color = dr.color or "natural"
local mask = dr.mask or "none"
local conversion = dr.conversion
local resolution = dr.resolution
@@ -1345,3 +1350,10 @@ end
-- os.execute(command)
-- end,
-- }
+
+
+-- local fig = figures.push { name = pdffile }
+-- figures.identify()
+-- figures.check()
+-- local nofpages = fig.used.pages
+-- figures.pop()
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index dbfc7401c..4b40b641e 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-lpeg.lua
@@ -6,6 +6,9 @@ if not modules then modules = { } end modules ['l-lpeg'] = {
license = "see context related readme files"
}
+
+-- a new lpeg fails on a #(1-P(":")) test and really needs a + P(-1)
+
local lpeg = require("lpeg")
-- tracing (only used when we encounter a problem in integration of lpeg in luatex)
@@ -73,7 +76,7 @@ patterns.alwaysmatched = alwaysmatched
local digit, sign = R('09'), S('+-')
local cr, lf, crlf = P("\r"), P("\n"), P("\r\n")
-local newline = crlf + cr + lf
+local newline = crlf + S("\r\n") -- cr + lf
local escaped = P("\\") * anything
local squote = P("'")
local dquote = P('"')
@@ -630,11 +633,3 @@ function lpeg.append(list,pp,delayed)
end
return p
end
-
---~ Cf(Ct("") * (Cg(C(...) * "=" * Cs(...)))^0, rawset)
-
---~ for k, v in next, patterns do
---~ if type(v) ~= "table" then
---~ lpeg.print(v)
---~ end
---~ end
diff --git a/tex/context/base/lang-def.mkiv b/tex/context/base/lang-def.mkiv
index 874eb2c45..3c4721338 100644
--- a/tex/context/base/lang-def.mkiv
+++ b/tex/context/base/lang-def.mkiv
@@ -581,7 +581,7 @@
\c!rightquote=\upperrightsingleninequote,
\c!leftquotation=\upperleftdoublesixquote,
\c!rightquotation=\upperrightdoubleninequote,
- \c!date={\v!day,\space,\v!month,\space,\v!year}]
+ \c!date={\v!day,{ de },\v!month,{ de },\v!year}]
\installlanguage [sp] [\s!es] % old times context
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index 42304f1b2..cf0a54f5e 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -160,47 +160,57 @@ function codeinjections.setupidentity(specification)
end
end
+local done = false -- using "setupidentity = function() end" fails as the meaning is frozen in register
+
local function setupidentity()
- local title = identity.title
- if not title or title == "" then
- title = tex.jobname
- end
- lpdf.addtoinfo("Title", pdfunicode(title), title)
- local subtitle = identity.subtitle or ""
- if subtitle ~= "" then
- lpdf.addtoinfo("Subject", pdfunicode(subtitle), subtitle)
- end
- local author = identity.author or ""
- if author ~= "" then
- lpdf.addtoinfo("Author", pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP
- end
- local creator = identity.creator or ""
- if creator ~= "" then
- lpdf.addtoinfo("Creator", pdfunicode(creator), creator) -- '/Creator' in /Info, 'CreatorTool' in XMP
- end
- lpdf.addtoinfo("CreationDate", pdfstring(lpdf.pdftimestamp(lpdf.timestamp())))
- local date = identity.date or ""
- local pdfdate = lpdf.pdftimestamp(date)
- if pdfdate then
- lpdf.addtoinfo("ModDate", pdfstring(pdfdate), date)
+ if not done then
+ local title = identity.title
+ if not title or title == "" then
+ title = tex.jobname
+ end
+ lpdf.addtoinfo("Title", pdfunicode(title), title)
+ local subtitle = identity.subtitle or ""
+ if subtitle ~= "" then
+ lpdf.addtoinfo("Subject", pdfunicode(subtitle), subtitle)
+ end
+ local author = identity.author or ""
+ if author ~= "" then
+ lpdf.addtoinfo("Author", pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP
+ end
+ local creator = identity.creator or ""
+ if creator ~= "" then
+ lpdf.addtoinfo("Creator", pdfunicode(creator), creator) -- '/Creator' in /Info, 'CreatorTool' in XMP
+ end
+ lpdf.addtoinfo("CreationDate", pdfstring(lpdf.pdftimestamp(lpdf.timestamp())))
+ local date = identity.date or ""
+ local pdfdate = lpdf.pdftimestamp(date)
+ if pdfdate then
+ lpdf.addtoinfo("ModDate", pdfstring(pdfdate), date)
+ else
+ -- users should enter the date in 2010-01-19T23:27:50+01:00 format
+ -- and if not provided that way we use the creation time instead
+ date = lpdf.timestamp()
+ lpdf.addtoinfo("ModDate", pdfstring(lpdf.pdftimestamp(date)), date)
+ end
+ local keywords = identity.keywords or ""
+ if keywords ~= "" then
+ keywords = gsub(keywords, "[%s,]+", " ")
+ lpdf.addtoinfo("Keywords",pdfunicode(keywords), keywords)
+ end
+ local id = lpdf.id()
+ lpdf.addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
+ done = true
else
- -- users should enter the date in 2010-01-19T23:27:50+01:00 format
- -- and if not provided that way we use the creation time instead
- date = lpdf.timestamp()
- lpdf.addtoinfo("ModDate", pdfstring(lpdf.pdftimestamp(date)), date)
+ -- no need for a message
end
- local keywords = identity.keywords or ""
- if keywords ~= "" then
- keywords = gsub(keywords, "[%s,]+", " ")
- lpdf.addtoinfo("Keywords",pdfunicode(keywords), keywords)
- end
- local id = lpdf.id()
- lpdf.addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
- setupidentity = function() end
end
lpdf.registerpagefinalizer(setupidentity,"identity")
+-- or when we want to be able to set things after pag e1:
+--
+-- lpdf.registerdocumentfinalizer(setupidentity,1,"identity")
+
local function flushjavascripts()
local t = interactions.javascripts.flushpreambles()
if #t > 0 then
diff --git a/tex/context/base/lpdf-xmp.lua b/tex/context/base/lpdf-xmp.lua
index 557141449..02d37342b 100644
--- a/tex/context/base/lpdf-xmp.lua
+++ b/tex/context/base/lpdf-xmp.lua
@@ -10,9 +10,11 @@ if not modules then modules = { } end modules ['lpdf-xmp'] = {
local format, random, char, gsub, concat = string.format, math.random, string.char, string.gsub, table.concat
local xmlfillin = xml.fillin
-local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end)
+local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end)
+local trace_info = false trackers.register("backend.info", function(v) trace_info = v end)
-local report_xmp = logs.reporter("backend","xmp")
+local report_xmp = logs.reporter("backend","xmp")
+local report_info = logs.reporter("backend","info")
local backends, lpdf = backends, lpdf
@@ -122,7 +124,11 @@ local addxmpinfo = lpdf.addxmpinfo
function lpdf.addtoinfo(tag,pdfvalue,strvalue)
addtoinfo(tag,pdfvalue)
- addxmpinfo(tag,strvalue or gsub(tostring(pdfvalue),"^%((.*)%)$","%1")) -- hack
+ local value = strvalue or gsub(tostring(pdfvalue),"^%((.*)%)$","%1") -- hack
+ if trace_info then
+ report_info("set '%s' to '%s'",tag,value)
+ end
+ addxmpinfo(tag,value)
end
-- for the do-it-yourselvers
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index aa0b0a22e..44c9d488d 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -711,7 +711,10 @@ local special_1 = P("*") * Cc(register_auto_descendant) * Cc(register_all_nodes
local special_2 = P("/") * Cc(register_auto_self)
local special_3 = P("") * Cc(register_auto_self)
-local pathparser = Ct { "patterns", -- can be made a bit faster by moving pattern outside
+local no_nextcolon = P(-1) + #(1-P(":")) -- newer lpeg needs the P(-1)
+local no_nextlparent = P(-1) + #(1-P("(")) -- newer lpeg needs the P(-1)
+
+local pathparser = Ct { "patterns", -- can be made a bit faster by moving some patterns outside
patterns = spaces * V("protocol") * spaces * (
( V("special") * spaces * P(-1) ) +
@@ -740,10 +743,8 @@ local pathparser = Ct { "patterns", -- can be made a bit faster by moving patter
shortcuts = V("shortcuts_a") * (spaces * "/" * spaces * V("shortcuts_a"))^0,
s_descendant_or_self = (P("***/") + P("/")) * Cc(register_descendant_or_self), --- *** is a bonus
- -- s_descendant_or_self = P("/") * Cc(register_descendant_or_self),
s_descendant = P("**") * Cc(register_descendant),
- s_child = P("*") * #(1-P(":")) * Cc(register_child ),
--- s_child = P("*") * #(P("/")+P(-1)) * Cc(register_child ),
+ s_child = P("*") * no_nextcolon * Cc(register_child ),
s_parent = P("..") * Cc(register_parent ),
s_self = P("." ) * Cc(register_self ),
s_root = P("^^") * Cc(register_root ),
@@ -770,13 +771,13 @@ local pathparser = Ct { "patterns", -- can be made a bit faster by moving patter
expressions = expression / register_expression,
letters = R("az")^1,
- name = (1-lpeg.S("/[]()|:*!"))^1,
+ name = (1-lpeg.S("/[]()|:*!"))^1, -- make inline
negate = P("!") * Cc(false),
nodefunction = V("negate") + P("not") * Cc(false) + Cc(true),
nodetest = V("negate") + Cc(true),
nodename = (V("negate") + Cc(true)) * spaces * ((V("wildnodename") * P(":") * V("wildnodename")) + (Cc(false) * V("wildnodename"))),
- wildnodename = (C(V("name")) + P("*") * Cc(false)) * #(1-P("(")),
+ wildnodename = (C(V("name")) + P("*") * Cc(false)) * no_nextlparent,
nodeset = spaces * Ct(V("nodename") * (spaces * P("|") * spaces * V("nodename"))^0) * spaces,
finalizer = (Cb("protocol") * P("/")^-1 * C(V("name")) * arguments * P(-1)) / register_finalizer,
diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua
index 5c5220cb8..99c7226a8 100644
--- a/tex/context/base/lxml-tab.lua
+++ b/tex/context/base/lxml-tab.lua
@@ -867,18 +867,15 @@ alternative.</p>
function xml.checkbom(root) -- can be made faster
if root.ri then
- local dt, found = root.dt, false
+ local dt = root.dt
for k=1,#dt do
local v = dt[k]
if type(v) == "table" and v.special and v.tg == "@pi@" and find(v.dt[1],"xml.*version=") then
- found = true
- break
+ return
end
end
- if not found then
- insert(dt, 1, { special=true, ns="", tg="@pi@", dt = { "xml version='1.0' standalone='yes'"} } )
- insert(dt, 2, "\n" )
- end
+ insert(dt, 1, { special=true, ns="", tg="@pi@", dt = { "xml version='1.0' standalone='yes'"} } )
+ insert(dt, 2, "\n" )
end
end
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 5a80d340d..4204f0d2b 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -153,64 +153,6 @@
%D Here we implement the user interface part. We start with basic math alignments:
-% \unexpanded\def\setupmathalignment
-% {\dodoubleempty\dosetupmathalignment}
-%
-% \def\dosetupmathalignment[#1][#2]%
-% {\ifsecondargument
-% \getparameters[\??eq#1][#2]%
-% \else
-% \getparameters[\??eq][#1]%
-% \fi}
-%
-% \let\currentmathalignment\empty
-%
-% \def\mathalignmentparameter#1%
-% {\executeifdefined{\??eq\currentmathalignment#1}{\executeifdefined{\??eq#1}\empty}}
-%
-% \setupmathalignment
-% [\c!n=2,
-% \c!m=1,
-% \c!distance=1em]
-%
-% \def\dostartmathalignment[#1][#2]%
-% {% \begingroup not permitted ($$...assignments...\halign... )
-% \pushmacro\doalignNC
-% \edef\currentmathalignment{#1}%
-% \doifassignmentelse{#2}{\setupmathalignment[#1][#2]}\donothing
-% \def\NC{\doalignNC}%
-% \global\let\doalignNC\dodoalignNC
-% \def\EQ{&=}%
-% \def\NR{&\global\let\doalignNC\dodoalignNC\doxxdoubleempty\doalignNR}%
-% % amstex compatibility mode: (ugly, will disappear)
-% \def\notag{\def\\{&\crcr}}%
-% \doifelse{#2}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
-% % end of compatibility mode
-% \eqaligncolumn\zerocount
-% \processcommacommand
-% [\mathalignmentparameter\c!align]
-% {\advance\eqaligncolumn\plusone\doseteqaligncolumn}% takes argument
-% % the real action
-% \global\eqaligncolumn\plusone
-% \numberedeqalign}
-%
-% \def\dostopmathalignment
-% {\finishalignno
-% \popmacro\doalignNC}
-%
-% \unexpanded\def\definemathalignment
-% {\dodoubleempty\dodefinemathalignment}
-%
-% \def\dodefinemathalignment[#1]% [#2]%
-% {\setvalue{\e!start#1}{\dodoubleempty\dostartmathalignment[#1]}%
-% \setvalue{\e!stop #1}{\dostopmathalignment}%
-% \setupmathalignment[#1]}% [#2]
-%
-% \definemathalignment[align] % default case (this is what amstex users expect)
-% \definemathalignment[\v!mathalignment] % prefered case (this is cleaner, less clashing)
-
-% we tag the mlist later but cells are hboxes so we can add wrappers
-
\newtoks \everymathalignment
\def\math_alignment_NR_indeed[#1][#2]%
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index 65cc3b0fe..c5ae2a407 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -64,13 +64,14 @@
% todo: add (relaxed) postsetup and postdefine hooks, just after the everys
-\unexpanded\def\doinstallparameterhandler#1#2#3#4#5#6#7%
+\unexpanded\def\doinstallparameterhandler#1#2#3#4#5#6#7#8%
{\ifx#2\relax\let#2\empty\fi
\def#3##1{\csname#4{#1#2}{##1}\endcsname}%
- \def#4##1##2{\ifcsname##1##2\endcsname##1##2\else\expandafter#5\csname##1\s!parent\endcsname{##2}\fi}%
+ \def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
\def#5##1##2{\ifx##1\relax\s!empty\else#4{##1}{##2}\fi}%
\def#6##1##2{\csname#4{#1##1}{##2}\endcsname}%
- \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}} % always root
+ \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root
+ \def#8##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\s!empty\fi\endcsname}}
\unexpanded\def\installparameterhandler#1#2%
{\normalexpanded
@@ -81,13 +82,17 @@
\expandafter\noexpand\csname do#2parameter\endcsname
\expandafter\noexpand\csname do#2parentparameter\endcsname
\expandafter\noexpand\csname named#2parameter\endcsname
- \expandafter\noexpand\csname detokenized#2parameter\endcsname}}
+ \expandafter\noexpand\csname detokenized#2parameter\endcsname
+ \expandafter\noexpand\csname strict#2parameter\endcsname}}
-\unexpanded\def\doinstallparameterhashhandler#1#2#3#4#5%
+\unexpanded\def\doinstallparameterhashhandler#1#2#3#4#5#6#7%
{\ifx#2\relax\let#2\empty\fi
- \def#3##1{#4{#1#2}{##1}}%
- \def#4##1##2{\ifcsname##1##2\endcsname##1\else\expandafter#5\csname##1\s!parent\endcsname{##2}\fi}%
- \def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}}
+ \def#3##1{#4{#1#2}{##1}:}%
+ \def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
+ \def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}%
+ \def#6{#1#2:}%
+ \def#7##1{#1##1:}}%
+
\unexpanded\def\installparameterhashhandler#1#2%
{\normalexpanded
@@ -96,13 +101,15 @@
\expandafter\noexpand\csname current#2\endcsname
\expandafter\noexpand\csname #2parameterhash\endcsname
\expandafter\noexpand\csname do#2parameterhash\endcsname
- \expandafter\noexpand\csname do#2parentparameterhash\endcsname}}
+ \expandafter\noexpand\csname do#2parentparameterhash\endcsname
+ \expandafter\noexpand\csname current#2hash\endcsname
+ \expandafter\noexpand\csname named#2hash\endcsname}}
\unexpanded\def\doinstallparametersethandler#1#2#3#4#5%
{\ifx#2\relax\let#2\empty\fi
- \def#3{\dosetvalue{#1#2}}% ##1 {##2} (braces are mandate)
- \def#4{\doletvalue{#1#2}}% ##1 ##2
- \def#5{\doletvalue{#1#2}\empty}}% ##1
+ \unexpanded\def#3{\dosetvalue{#1#2:}}% ##1 {##2} (braces are mandate)
+ \unexpanded\def#4{\doletvalue{#1#2:}}% ##1 ##2
+ \unexpanded\def#5{\doletvalue{#1#2:}\empty}}% ##1
\unexpanded\def\installparametersethandler#1#2%
{\normalexpanded
@@ -140,16 +147,16 @@
\the#6% predefine
\ifthirdargument
\edef#8{##2}%
- \getparameters[#1#4][\s!parent=#1##2,##3]%
+ \getparameters[#1#4:][\s!parent=#1##2,##3]%
\else\ifsecondargument
\doifassignmentelse{##2}
{\let#8\empty
- \getparameters[#1#4][\s!parent=#3,##2]}
+ \getparameters[#1#4:][\s!parent=#3,##2]}
{\edef#8{##2}%
- \getparameters[#1#4][\s!parent=#1##2]}%
+ \getparameters[#1#4:][\s!parent=#1##2]}%
\else
\let#8\empty
- \getparameters[#1#4][\s!parent=#3]%
+ \getparameters[#1#4:][\s!parent=#3]%
\fi\fi
\the#7%
\let#4\saveddefinewhatever}}
@@ -169,19 +176,19 @@
\unexpanded\def\doinstallsetuphandler#1#2#3#4#5#6%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#6{\getparameters[#1#3]}%
+ \unexpanded\def#6{\getparameters[#1#3:]}%
\newtoks#5%
\def#4[##1][##2]% maybe helper
{\let\savedsetupwhatever#3%
\ifsecondargument
\def\docommand####1% we will have a simple one as well
{\edef#3{####1}%
- \getparameters[#1#3][##2]%
+ \getparameters[#1#3:][##2]%
\the#5}%
\processcommalist[##1]\docommand
\else
\let#3\empty
- \getparameters[#1][##1]%
+ \getparameters[#1:][##1]%
\the#5%
\fi
\let#3\savedsetupwhatever}}
@@ -199,20 +206,20 @@
\unexpanded\def\doinstallswitchsetuphandler#1#2#3#4#5#6%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
- \unexpanded\def#6{\getparameters[#1#3]}%
+ \unexpanded\def#6{\getparameters[#1#3:]}%
\newtoks#5%
\def#4[##1][##2]% maybe helper
{\ifsecondargument % no commalist here
\let\savedsetupwhatever#3%
\edef#3{##1}%
- \getparameters[#1#3][##2]%
+ \getparameters[#1#3:][##2]%
\the#5%
\let#3\savedsetupwhatever
\else\iffirstargument
\doifassignmentelse{##1}
{\let\savedsetupwhatever#3%
\let#3\empty
- \getparameters[#1][##1]%
+ \getparameters[#1:][##1]%
\the#5%
\let#3\savedsetupwhatever}
{\edef#3{##1}% this will catch reset
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index 60b8c5f3c..b96e267b0 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -206,7 +206,7 @@
\definesystemconstant {link}
\definesystemconstant {parent}
\definesystemconstant {clone}
-\definesystemconstant {section} \let\v!sectionlevel\s!section % for old times sake
+\definesystemconstant {section}
\definesystemconstant {handler}
\definesystemconstant {counter}
\definesystemconstant {single}
diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua
index b9ef9188f..7c91016b6 100644
--- a/tex/context/base/node-inj.lua
+++ b/tex/context/base/node-inj.lua
@@ -34,6 +34,7 @@ local traverse_id = node.traverse_id
local unset_attribute = node.unset_attribute
local has_attribute = node.has_attribute
local set_attribute = node.set_attribute
+local copy_node = node.copy
local insert_node_before = node.insert_before
local insert_node_after = node.insert_after
@@ -44,6 +45,21 @@ local cursbase = attributes.private('cursbase')
local curscurs = attributes.private('curscurs')
local cursdone = attributes.private('cursdone')
local kernpair = attributes.private('kernpair')
+local fontkern = attributes.private('fontkern')
+
+if context then
+
+ local kern = nodes.pool.register(newkern())
+
+ set_attribute(kern,fontkern,1) -- we can have several, attributes are shared
+
+ newkern = function(k)
+ local c = copy_node(kern)
+ c.kern = k
+ return c
+ end
+
+end
local cursives = { }
local marks = { }
diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua
index 7f737ea70..9e17155f2 100644
--- a/tex/context/base/node-res.lua
+++ b/tex/context/base/node-res.lua
@@ -28,6 +28,7 @@ local pool = nodes.pool
local whatsitcodes = nodes.whatsitcodes
local skipcodes = nodes.skipcodes
+local kerncodes = nodes.kerncodes
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
@@ -75,7 +76,8 @@ function pool.usage()
end
local disc = register_node(new_node("disc"))
-local kern = register_node(new_node("kern",1))
+local kern = register_node(new_node("kern",kerncodes.userkern))
+local fontkern = register_node(new_node("kern",kerncodes.fontkern))
local penalty = register_node(new_node("penalty"))
local glue = register_node(new_node("glue")) -- glue.spec = nil
local glue_spec = register_node(new_node("glue_spec"))
@@ -126,6 +128,12 @@ function pool.kern(k)
return n
end
+function pool.fontkern(k)
+ local n = copy_node(fontkern)
+ n.kern = k
+ return n
+end
+
function pool.gluespec(width,stretch,shrink,stretch_order,shrink_order)
local s = copy_node(glue_spec)
if width then s.width = width end
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index 1afc498a3..b1107c3a3 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -605,8 +605,7 @@
\def\defaultframeoffset{.25ex}
\def\presetlocalframed [#1]{\letvalue{#1\s!parent}\??oi}
-\def\inheritlocalframed[#1]#2[#3]{\letvalue{#1\s!parent}#3}
-\def\copylocalframed [#1]#2[#3]{\setvalue{#1\s!parent}{#3}}
+\def\inheritlocalframed[#1]#2[#3]{\setevalue{#1\s!parent}{#3}}
\presetlocalframed[\??ol]
@@ -621,13 +620,6 @@
\unexpanded\def\setupframed
{\dodoubleempty\dosetupframed}
-% \def\dosetupframed
-% {\ifsecondargument
-% \@EA\dodoublesetupframed
-% \else
-% \@EA\dosinglesetupframed
-% \fi}
-
% we can consider setting the parent of the regular framed to
% something else in the otr so that we isolate it there
@@ -638,17 +630,6 @@
\getparameters[\??ol][#1]%
\fi}
-% \def\dosinglesetupframed[#1][#2]%
-% {\getparameters[\??ol][#1]}
-
-% \def\dodoublesetupframed[#1][#2]%
-% {\bgroup
-% \let\dodoubleempty\empty
-% \def\doframed[##1]{\gdef\globalredefinedframed{\dodoubleempty\doframed[##1,#2]}}%
-% \getvalue{#1}%
-% \egroup
-% \letvalue{#1}\globalredefinedframed}
-
%D \startbuffer
%D \setupframed [framecolor=yellow] \framed{A}
%D \defineframed[myframed] [framecolor=blue] \myframed{B}
@@ -769,7 +750,7 @@
%D Because it is used so often the he next macro is (and
%D looks) rather optimized.
-% \def\s!root{root} % maybe configurable
+% todo: see if we can use commandhandler
\let\postprocessframebox\relax
@@ -2772,7 +2753,7 @@
% \insidefloattrue % ? better
\normalexpanded{\noexpand\switchtobodyfont[\framedtextparameter\c!bodyfont]}%
\startcolor[\framedtextparameter\c!color]%
- \localframed[\??kd\currentframedtext][\c!strut=\v!no]% todo: use delayedstrut
+ \localframed[\currentframedtexthash][\c!strut=\v!no]% todo: use delayedstrut
\bgroup
\let\\=\endgraf
\framedtextparameter\c!inner % oud spul
@@ -2825,23 +2806,35 @@
\def\doftstartdepthcorrection
{\bgroup
- \verticalstrut
- % we need \nowhitespace in case of setups setting whitespace
- % nb, not safe, text vs \vbox as next
- \vskip-\struttotal
- \nowhitespace} % na vskip ! new 20/05/2004, fails with next content being box (\scale{..})
+ \ifhmode
+ \par
+ \fi
+ \ifvmode
+ \verticalstrut
+ % we need \nowhitespace in case of setups setting whitespace
+ % nb, not safe, text vs \vbox as next
+ \vskip-\struttotal
+ \nowhitespace
+ \fi} % na vskip ! new 20/05/2004, fails with next content being box (\scale{..})
\def\doftstopdepthcorrection
- {\forgetall
- \vskip-\struttotal
- \verticalstrut
- \egroup
- \forgetall % brrr too often
- \vskip-\lineheight
- % will be an option, not default
- % \setbaselinecorrections
- % \donegbotbaselinecorrection
- \verticalstrut}
+ {\ifhmode
+ \par
+ \fi
+ \ifvmode
+ \forgetall
+ \vskip-\struttotal
+ \verticalstrut
+ \egroup
+ \forgetall % brrr too often
+ \vskip-\lineheight
+ % will be an option, not default
+ % \setbaselinecorrections
+ % \donegbotbaselinecorrection
+ \verticalstrut
+ \else
+ \egroup
+ \fi}
%D Placement can be ignored:
%D
@@ -2868,7 +2861,7 @@
\def\dodoframedtext[#1]% beware!
{\normalexpanded{\noexpand\switchtobodyfont[\framedtextparameter\c!bodyfont]}%
- \localframed[\??kd\currentframedtext][\c!strut=\v!no,#1]%
+ \localframed[\currentframedtexthash][\c!strut=\v!no,#1]%
\bgroup
\blank[\v!disable]%
\let\\=\endgraf
@@ -2914,7 +2907,7 @@
{\bgroup
\expandafter\let\expandafter\tempframedcount\csname\??ol:#1\endcsname
\advance\tempframedcount\plusone
- \expandafter\def\csname\??ol#1:\the\tempframedcount\s!parent\endcsname{\??ol#1}% \copylocalframed
+ \expandafter\def\csname\??ol#1:\the\tempframedcount\s!parent\endcsname{\??ol#1}% \inheritlocalframed
\dodoubleempty\dolocalframed[\??ol#1:\the\tempframedcount]}
%D We can do:
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index 027db2142..de11090d3 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -270,12 +270,12 @@
\doinstallarrangedoption\v!rotated
{\gdef\arrangedrotationO {90}%
\gdef\arrangedrotationE{270}%
- \swapcounts\horizontalcutmarks\verticalcutmarks}
+ \swapcounts\c_page_marks_nx\c_page_marks_ny}
\doinstallarrangedoption{90}
{\gdef\arrangedrotationO {90}%
\gdef\arrangedrotationE{270}%
- \swapcounts\horizontalcutmarks\verticalcutmarks}
+ \swapcounts\c_page_marks_nx\c_page_marks_ny}
\doinstallarrangedoption{180}
{\gdef\arrangedrotationO{180}%
@@ -284,7 +284,7 @@
\doinstallarrangedoption{270}
{\gdef\arrangedrotationO{270}%
\gdef\arrangedrotationE {90}%
- \swapcounts\horizontalcutmarks\verticalcutmarks}
+ \swapcounts\c_page_marks_nx\c_page_marks_ny}
\doinstallarrangedoption\s!reset
{\global\arrangingpagesfalse}
@@ -319,8 +319,8 @@
{\global\arrangedpageX #1%
\global\arrangedpageY #2%
\global\arrangedpageT #3%
- \global\horizontalcutmarks #4%
- \global\verticalcutmarks #5%
+ \global\c_page_marks_nx #4%
+ \global\c_page_marks_ny #5%
\global\let\pusharrangedpage #6%
\global\let\poparrangedpages #7%
\global\let\handlearrangedpage#8}
diff --git a/tex/context/base/page-mrk.mkiv b/tex/context/base/page-mrk.mkiv
index de559fdee..babf7f776 100644
--- a/tex/context/base/page-mrk.mkiv
+++ b/tex/context/base/page-mrk.mkiv
@@ -31,6 +31,9 @@
\newconditional\c_page_marks_add_page_lines
\newconditional\c_page_marks_add_more_number
+\newcount\c_page_marks_nx
+\newcount\c_page_marks_ny
+
\startuniqueMPgraphic{print:color}{w,h,l,o}
page_marks_add_color(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ;
\stopuniqueMPgraphic
@@ -39,8 +42,8 @@
page_marks_add_marking(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ;
\stopuniqueMPgraphic
-\startuniqueMPgraphic{print:lines}{w,h,l,o}
- page_marks_add_lines(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ;
+\startuniqueMPgraphic{print:lines}{w,h,l,o,x,y}
+ 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}
@@ -75,7 +78,8 @@
\uniqueMPgraphic
{print:lines}%
{w=\the\scratchwidth,h=\the\scratchheight,%
- l=\pagecutmarklength,o=\pagecutmarkoffset}%
+ l=\pagecutmarklength,o=\pagecutmarkoffset,%
+ x=\the\c_page_marks_nx,y=\the\c_page_marks_ny}%
\egroup
\wd\scratchbox\scratchwidth\ht\scratchbox\scratchheight\dp\scratchbox\scratchdepth
\hskip-\scratchwidth\box\scratchbox}
@@ -87,7 +91,7 @@
{print:number}%
{w=\the\scratchwidth ,h=\the\scratchheight,%
l=\pagecutmarklength,o=\pagecutmarkoffset,%
- n=\realfolio}%
+ n=\number\ifcase\arrangeno\realpageno\else\arrangeno\fi}%
\egroup
\wd\scratchbox\scratchwidth\ht\scratchbox\scratchheight\dp\scratchbox\scratchdepth
\hskip-\scratchwidth\box\scratchbox}
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index c19b4b970..e1e47abcd 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -362,7 +362,7 @@
{\ifcase\columndirection % nog document wide
\dofloatsflush\s!text{1}%
\else
- \dofloatsflushn\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
+ \dofloatsflush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
\fi
\ifdim\wd\floatbox>\makeupwidth % \hsize
\hbox to \makeupwidth{\hss\box\floatbox\hss}%
diff --git a/tex/context/base/phys-dim.lua b/tex/context/base/phys-dim.lua
index 41f98b5fb..18aac2170 100644
--- a/tex/context/base/phys-dim.lua
+++ b/tex/context/base/phys-dim.lua
@@ -24,18 +24,19 @@ local allocate = utilities.storage.allocate
physics = physics or { }
physics.patterns = physics.patterns or { }
--- digits parser (todo : use patterns)
+local variables = interfaces.variables
+local v_reverse = variables.reverse
---~ local done = false
---~ local mode = 0
+-- digits parser (todo : use patterns)
local digit = R("09")
local sign = S("+-")
local power = S("^e")
local digitspace = S("~@_")
-local digitspacex = digitspace + P(" ")
local comma = P(",")
local period = P(".")
+local semicolon = P(";")
+local colon = P(":")
local signspace = P("/")
local positive = S("p")
local negative = S("n")
@@ -43,14 +44,22 @@ local highspace = P("s")
local padding = P("=")
local plus = P("+")
local minus = P("-")
+local space = P(" ")
-local digits = (digit^1)
+local digits = digit^1
-local ddigitspacex = digitspacex / "" / context.digitsspace
local ddigitspace = digitspace / "" / context.digitsspace
+local dcommayes = semicolon / "" / context.digitsfinalcomma
+local dcommanop = semicolon / "" / context.digitsseparatorspace
+local dperiodyes = colon / "" / context.digitsfinalperiod
+local dperiodnop = colon / "" / context.digitsseparatorspace
local ddigit = digits / context.digitsdigit
-local dseparator = comma / "" / context.digitscomma
- + period / "" / context.digitsperiod
+local dfinalcomma = comma / "" / context.digitsfinalcomma
+local dfinalperiod = period / "" / context.digitsfinalperiod
+local dintercomma = comma * #(digitspace) / "" / context.digitsseparatorspace
+ + comma / "" / context.digitsintermediatecomma
+local dinterperiod = period * #(digitspace) / "" / context.digitsseparatorspace
+ + period / "" / context.digitsintermediateperiod
local dsignspace = signspace / "" / context.digitssignspace
local dpositive = positive / "" / context.digitspositive
local dnegative = negative / "" / context.digitsnegative
@@ -64,22 +73,34 @@ local dpower = power / "" * (
)
local dpadding = padding / "" / context.digitszeropadding -- todo
-local digitparserspace =
- (dsomesign + dsignspace + dpositive + dnegative + dhighspace)^0
- * (dseparator^0 * (ddigitspacex + ddigit)^1)^1
- * dpower^0
+local dleader = (dsomesign + dsignspace + dpositive + dnegative + dhighspace)^0
+local dtrailer = dpower^0
+local dfinal = P(-1) + #P(1 - comma - period - semicolon - colon)
+local dnumber = (ddigitspace + ddigit)^1
+local dtemplate = ddigitspace^1
+
+-- probably too complex, due to lookahead (lookback with state is probably easier)
+
+local dpcfinalnumber = dtemplate * (dfinalcomma + dcommanop ) + dnumber * (dfinalcomma + dcommayes )
+local dcpfinalnumber = dtemplate * (dfinalperiod + dperiodnop) + dnumber * (dfinalperiod + dperiodyes)
+
+local dpcinternumber = dtemplate * (dintercomma + dcommanop ) + dnumber * (dintercomma + dcommayes )
+local dcpinternumber = dtemplate * (dinterperiod + dperiodnop) + dnumber * (dinterperiod + dperiodyes)
+
+local dfallback = (dtemplate * (dcommanop + dperiodnop)^0)^0 * (dcommayes + dperiodyes + ddigit)^0
-local digitparser =
- (dsomesign + dsignspace + dpositive + dnegative + dhighspace)^0
- * (dseparator^0 * (ddigitspace + ddigit)^1)^1
- * dpower^0
+local p_c_number = (dcpinternumber)^0 * (dpcfinalnumber)^0 * ddigit + dfallback -- 000.000.000,00
+local c_p_number = (dpcinternumber)^0 * (dcpfinalnumber)^0 * ddigit + dfallback -- 000,000,000.00
-physics.patterns.digitparserspace = digitparserspace
-physics.patterns.digitparser = digitparser
+local p_c_dparser = dleader * p_c_number * dtrailer * dfinal
+local c_p_dparser = dleader * c_p_number * dtrailer * dfinal
-function commands.digits(str)
---~ done = false
- matchlpeg(digitparserspace,str)
+function commands.digits(str,p_c)
+ if p_c == v_reverse then
+ matchlpeg(p_c_dparser,str)
+ else
+ matchlpeg(c_p_dparser,str)
+ end
end
-- units parser
@@ -412,26 +433,33 @@ local function dimop(o,wherefrom)
end
end
+-- todo 0x -> rm
+-- pretty large lpeg (maybe do dimension lookup otherwise)
+
local dimension = ((l_suffix * combination) * Carg(1)) / dimspu
+ ((combination * s_suffix) * Carg(1)) / dimpus
local number = lpeg.patterns.number / unitsN
local operator = C((l_operator + s_operator) * Carg(1)) / dimop -- weird, why is the extra C needed here
local whatever = (P(1)^0) / unitsU
+local number = (1-R("az","AZ")-P(" "))^1 / unitsN -- todo: catch { }
+
dimension = somespace * dimension * somespace
number = somespace * number * somespace
operator = somespace * operator * somespace
------ unitparser = dimension * dimension^0 * (operator * dimension^1)^-1 + whatever
-local unitparser = dimension^1 * (operator * dimension^1)^-1 + whatever
+local unitparser = dimension^1 * (operator * dimension^1)^-1 + whatever + P(-1)
------ unitdigitparser = (P(true)/unitsNstart) * digitparser * (P(true)/unitsNstop) -- true forces { }
-local unitdigitparser = (Cc(nil)/unitsNstart) * digitparser * (Cc(nil)/unitsNstop) --
-local combinedparser = (unitdigitparser + number)^-1 * unitparser
+local p_c_unitdigitparser = (Cc(nil)/unitsNstart) * p_c_dparser * (Cc(nil)/unitsNstop) --
+local c_p_unitdigitparser = (Cc(nil)/unitsNstart) * c_p_dparser * (Cc(nil)/unitsNstop) --
-physics.patterns.unitparser = unitparser
-physics.patterns.combinedparser = combinedparser
+local p_c_combinedparser = (p_c_unitdigitparser + number)^-1 * unitparser
+local c_p_combinedparser = (c_p_unitdigitparser + number)^-1 * unitparser
-function commands.unit(str,wherefrom)
- matchlpeg(combinedparser,str,1,wherefrom or "")
+function commands.unit(str,wherefrom,p_c)
+ if p_c == v_reverse then
+ matchlpeg(p_c_combinedparser,str,1,wherefrom or "")
+ else
+ matchlpeg(c_p_combinedparser,str,1,wherefrom or "")
+ end
end
diff --git a/tex/context/base/phys-dim.mkiv b/tex/context/base/phys-dim.mkiv
index 4218d9dd0..4df9d3ad9 100644
--- a/tex/context/base/phys-dim.mkiv
+++ b/tex/context/base/phys-dim.mkiv
@@ -16,7 +16,7 @@
\unprotect
%D \macros
-%D {digits, setdigitmode, setdigitsign, setdigitorder}
+%D {digits, setdigitmode, setdigitsign}
%D
%D This is an update of the \MKII\ digits mechanism. Beware,
%D space delimited mode is now resticted!
@@ -128,16 +128,15 @@
%D \getbuffer
%D \stoplines
-% todo: smaller adn raised signs
+\newconstant\c_digits_order
+\newconstant\c_digits_method
+\newconstant\c_digits_sign % we has sized (text script scriptscript)
-\newconditional\c_digits_seen
-\newconstant \c_digits_mode
-\newconstant \c_digits_sign % we has sized (text script scriptscript)
-\newconstant \c_digits_order % 0=period comma 1=comma period
+\def\setdigitmethod#1{\c_digits_method #1\relax}
+\def\setdigitsign #1{\c_digits_sign #1\relax}
+\def\setdigitorder #1{\c_digits_order #1\relax}
-\def\setdigitmode #1{\c_digits_mode #1\relax}
-\def\setdigitsign #1{\c_digits_sign #1\relax}
-\def\setdigitorder#1{\c_digits_order#1\relax}
+\let\setdigitmode\setdigitmethod % compatibility
\def\digits_normalized % we could calculate once and remember
{\ifcase\c_digits_sign
@@ -177,49 +176,55 @@
\def\digitspower {\digits_raised}
\def\digitspowerplus #1{\digits_raised{\digitsplus#1}}
\def\digitspowerminus #1{\digits_raised{\digitsminus#1}}
+\def\digitsdigit #1{#1}
-% we can move the logic to lua
+\def\normaldigitscommasymbol {,}
+\def\normaldigitsperiodsymbol {.}
+\let\normaldigitsseparatorspace\digitsseparatorspace
-\def\digitsdigit #1{\ifconditional\c_digits_seen#1\else\ifnum#1=\zerocount\digitsspace\else\settrue\c_digits_seen#1\fi\fi}
-\def\digitscomma {\ifconditional\c_digits_seen\ifconditional\c_digits_order\digitscommasymbol \else\digitsperiodsymbol\fi\else\digitsseparatorspace\fi}
-\def\digitsperiod {\ifconditional\c_digits_seen\ifconditional\c_digits_order\digitsperiodsymbol\else\digitscommasymbol \fi\else\digitsseparatorspace\fi}
+\letvalue{digit_c_0}\normaldigitscommasymbol
+\letvalue{digit_p_0}\normaldigitsperiodsymbol
+\letvalue{digit_s_0}\normaldigitsseparatorspace
-\def\normaldigitscommasymbol {,}
-\def\normaldigitsperiodsymbol{.}
+\letvalue{digit_c_1}\normaldigitsperiodsymbol
+\letvalue{digit_p_1}\normaldigitscommasymbol
+\letvalue{digit_s_1}\normaldigitsseparatorspace
-\let\digitscommasymbol \normaldigitscommasymbol
-\let\digitsperiodsymbol\normaldigitsperiodsymbol
+\letvalue{digit_c_2}\normaldigitscommasymbol
+\letvalue{digit_p_2}\normaldigitsperiodsymbol
+\letvalue{digit_s_2}\normaldigitsseparatorspace
-\unexpanded\def\tempdigits#1% for testing
+\letvalue{digit_c_3}\thinspace
+\letvalue{digit_p_3}\normaldigitscommasymbol
+\letvalue{digit_s_3}\thinspace
+
+\letvalue{digit_c_4}\thinspace
+\letvalue{digit_p_4}\normaldigitsperiodsymbol
+\letvalue{digit_s_4}\thinspace
+
+\letvalue{digit_c_5}\thickspace
+\letvalue{digit_p_5}\normaldigitscommasymbol
+\letvalue{digit_s_5}\thickspace
+
+\letvalue{digit_c_6}\thickspace
+\letvalue{digit_p_6}\normaldigitsperiodsymbol
+\letvalue{digit_s_6}\thickspace
+
+\def\digitscommasymbol {\csname digit_c_\number\c_digits_method\endcsname}
+\def\digitsperiodsymbol {\csname digit_p_\number\c_digits_method\endcsname}
+\def\digitsseparatorspace {\csname digit_s_\number\c_digits_method\endcsname}
+
+\def\digitsfinalcomma {\digitscommasymbol } % more for tracing
+\def\digitsfinalperiod {\digitsperiodsymbol} % more for tracing
+\def\digitsintermediatecomma {\digitscommasymbol } % more for tracing
+\def\digitsintermediateperiod {\digitsperiodsymbol} % more for tracing
+
+%D The user macro:
+
+\unexpanded\def\digits_indeed#1%
{\dontleavehmode
\begingroup
- \setfalse\c_digits_seen
- \ifcase\c_digits_mode
- % keep as-is
- \or
- \let\digitscommasymbol \normaldigitsperiodsymbol
- \let\digitsperiodsymbol \normaldigitscommasymbol
- \or
- \let\digitscommasymbol \normaldigitscommasymbol
- \let\digitsperiodsymbol \normaldigitsperiodsymbol
- \or
- \let\digitsperiodsymbol \thinspace
- \let\digitscommasymbol \normaldigitscommasymbol
- \let\digitsseparatorspace\thinspace
- \or
- \let\digitsperiodsymbol \thinspace
- \let\digitscommasymbol \normaldigitsperiodsymbol
- \let\digitsseparatorspace\thinspace
- \or
- \let\digitsperiodsymbol \thickspace
- \let\digitscommasymbol \normaldigitscommasymbol
- \let\digitsseparatorspace\thickspace
- \or
- \let\digitsperiodsymbol \thickspace
- \let\digitscommasymbol \normaldigitsperiodsymbol
- \let\digitsseparatorspace\thickspace
- \fi
- \ctxcommand{digits(\!!bs\detokenize{#1}\!!es)}%
+ \ctxcommand{digits(\!!bs\detokenize{#1}\!!es,"\ifcase\c_digits_order \v!normal\else\v!reverse\fi")}%
\endgroup
\settrue\c_units_dospace}
@@ -227,10 +232,10 @@
{\doifnextbgroupelse\digits_argument\digits_spaced}
\def\digits_argument#1%
- {\tempdigits{#1}}
+ {\digits_indeed{#1}}
-\def\digits_spaced#1 %
- {\tempdigits{#1}}
+\def\digits_spaced#1 % space delimited
+ {\digits_indeed{#1}}
%D \macros
%D {unit}
@@ -282,6 +287,46 @@
%D
%D Depending on needs we can add more tweaks (also depends on to what
%D extent we need to be compatible with \MKII.
+%D
+%D Formatting is supported too:
+%D
+%D \startbuffer
+%D \starttabulate[|l|l|l|]
+%D \HL
+%D \NC \unit{10 kilo gram} \NC \digits{10} \NC \unit{10} \NC \NR
+%D \NC \unit{1 kilogram} \NC \digits{1} \NC \unit{1} \NC \NR
+%D \NC \unit{0.1 kilogram} \NC \digits{0.1} \NC \unit{0.1} \NC \NR
+%D \NC \unit{1.1 kilogram} \NC \digits{1.1} \NC \unit{1.1} \NC \NR
+%D \NC \unit{11 kilogram} \NC \digits{11} \NC \unit{11} \NC \NR
+%D \HL
+%D \NC \unit{00,000.10 kilogram} \NC \digits{00,000.10} \NC \unit{00,000.10} \NC \NR
+%D \NC \unit{@@,@@0.10 kilogram} \NC \digits{@@,@@0.10} \NC \unit{@@,@@0.10} \NC \NR
+%D \NC \unit{__,___.10 kilogram} \NC \digits{__,___.10} \NC \unit{__,___.10} \NC \NR
+%D \NC \unit{__,__0:10 kilogram} \NC \digits{__,__0:10} \NC \unit{__,__0:10} \NC \NR
+%D \NC \unit{__,___:10 kilogram} \NC \digits{__,___:10} \NC \unit{__,___:10} \NC \NR
+%D \HL
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D Punctuation can be configures usiing \type {method}:
+%D
+%D \startbuffer
+%D \starttabulate[|l|l|l|]
+%D \HL
+%D \NC \NC \setupunits[method=0]\unit{00,000.10 kilogram} \NC \setupunits[method=0]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \NC 1 \NC \setupunits[method=1]\unit{00,000.10 kilogram} \NC \setupunits[method=1]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \NC 2 \NC \setupunits[method=2]\unit{00,000.10 kilogram} \NC \setupunits[method=2]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \NC 3 \NC \setupunits[method=3]\unit{00,000.10 kilogram} \NC \setupunits[method=3]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \NC 4 \NC \setupunits[method=4]\unit{00,000.10 kilogram} \NC \setupunits[method=4]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \NC 5 \NC \setupunits[method=5]\unit{00,000.10 kilogram} \NC \setupunits[method=5]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \NC 6 \NC \setupunits[method=6]\unit{00,000.10 kilogram} \NC \setupunits[method=6]\unit{@@,@@0.10 kilogram} \NC \NR
+%D \HL
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
% only a space when a number is part of the unit
@@ -291,6 +336,8 @@
[\c!alternative=, % done: text
\c!separator=\v!normal, % done: cdot|big|medium|space
\c!label=, % done: (no interface yet)
+ \c!order=\v!normal, % ,. (reverse: .,)
+ \c!method=0,
%\c!grid=\v!yes, % (maybe)
%\c!style=..., % done
%\c!color=..., % done
@@ -341,6 +388,8 @@
\settrue\c_units_dospace
\removelastskip
\fi
+ \c_digits_method\unitsparameter\c!method\relax
+ \ifmmode\else\dontleavehmode\fi
\edef\currentunits{#1}%
\the\everyunits
%\removeunwantedspaces % now ok yet
@@ -399,7 +448,7 @@
\let\units_direct\units_direct_nested
\to \everyunits
-\unexpanded\def\units_indeed#1{\ctxcommand{unit(\!!bs\detokenize{#1}\!!es,"\unitsparameter\c!label")}}
+\unexpanded\def\units_indeed#1{\ctxcommand{unit(\!!bs\detokenize{#1}\!!es,"\unitsparameter\c!label","\unitsparameter\c!order")}}
\unexpanded\def\unitsPUS#1#2#3{\units_next#1#2\unitsraise{#3}\c_units_state\plusone} % suffix
\unexpanded\def\unitsPU #1#2{\units_next#1#2\c_units_state \plusthree} % unit
diff --git a/tex/context/base/scrn-bar.mkvi b/tex/context/base/scrn-bar.mkvi
index 1bfc6a13c..576b1d62b 100644
--- a/tex/context/base/scrn-bar.mkvi
+++ b/tex/context/base/scrn-bar.mkvi
@@ -68,10 +68,10 @@
{\iflocation
\begingroup
\doifassignmentelse{#tag}
- {\getparameters[\??ib][#tag]%
- \edef\currentinteractionbar{\interactionbarparameter\c!alternative}}%
+ {\edef\currentinteractionbar{\interactionbarparameter\c!alternative}%
+ \setupcurrentinteractionbar[#tag]}%
{\edef\currentinteractionbar{#tag}%
- \ifsecondargument\getparameters[\??ib#tag][#settings]\fi}%
+ \ifsecondargument\setupcurrentinteractionbar[#settings]\fi}%
\doif{\interactionbarparameter\c!state}\v!start
{\interactionbarparameter\c!command}%
\endgroup
@@ -132,7 +132,7 @@
\fi
\doifnothing{\interactionbarparameter\c!height}{\letinteractionbarparameter\c!height\v!broad}%
\doifnothing{\interactionbarparameter\c!depth }{\letinteractionbarparameter\c!depth\!!zeropoint}%%%
- \setbox2\hbox{\localframed[\??ib\currentinteractionbar][\c!background=]{\symbol[\interactionparameter\c!symbolset][\v!previouspage]}}%
+ \setbox2\hbox{\localframed[\currentinteractionbarhash][\c!background=]{\symbol[\interactionparameter\c!symbolset][\v!previouspage]}}%
\!!heighta\ht2 % needed because we default to nothing
\setupinteractionbar[\c!strut=\v!no]%
\letinteractionparameter\c!width\zeropoint
diff --git a/tex/context/base/scrn-but.mkvi b/tex/context/base/scrn-but.mkvi
index c8f1ba243..c5c002150 100644
--- a/tex/context/base/scrn-but.mkvi
+++ b/tex/context/base/scrn-but.mkvi
@@ -11,6 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+% framed needs checking
+
% \restorestandardblank
% better namespace for pos
@@ -67,8 +69,6 @@
\scrn_button_direct_indeed
\scrn_button_direct_ignore}
-%\def\buttonframed{\dodoubleempty\localframed[\??bt]} % goodie
-
% empty=yes
%
% \button[settings]{}[action] % normally used at the tex end
diff --git a/tex/context/base/scrn-fld.mkvi b/tex/context/base/scrn-fld.mkvi
index 506bb4a07..628b68866 100644
--- a/tex/context/base/scrn-fld.mkvi
+++ b/tex/context/base/scrn-fld.mkvi
@@ -659,7 +659,7 @@
{\setuptooltip[\currenttooltip][#settings]}%
{\setuptooltip[\currenttooltip][\c!location=#settings]}%
\setbox\scrn_tooltip_box_text\hbox
- {\localframed[\??wh\currenttooltip][\c!location=]{#tiptext}}%
+ {\localframed[\currenttooltiphash][\c!location=]{#tiptext}}%
\definesymbol
[\currenttooltipname:txt]
[\copy\scrn_tooltip_box_text]%
diff --git a/tex/context/base/scrn-hlp.mkvi b/tex/context/base/scrn-hlp.mkvi
index 6e90fc66d..2d158d762 100644
--- a/tex/context/base/scrn-hlp.mkvi
+++ b/tex/context/base/scrn-hlp.mkvi
@@ -68,7 +68,7 @@
\c!background=\v!color,
\c!backgroundcolor=gray]
-\presetlocalframed[\??wp]
+\presetlocalframed[\??wp] %% not needed
\appendtoks
\setuevalue \currenthelp {\scrn_help_argument{\currenthelp}}%
@@ -115,7 +115,7 @@
\def\scrn_help_register#text%
{\setbox\scrn_help_box\hbox
- {\localframed[\??wp\currenthelp]{#text}}%
+ {\localframed[\currenthelphash]{#text}}%
\definesymbol
[\currenthelpname]
[\copy\scrn_help_box]%
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index cdf4147c1..6cd435e8b 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -1802,7 +1802,7 @@
\def\dodostartlines[#1]% new: optional second argument (WS)
{\iffirstargument
- \getparameters[\??rg\currentlines][#1]%
+ \setupcurrentlines[#1]%
\fi
\edef\linesoption{\linesparameter\c!option}%
\linesparameter\c!before
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index c1fa5d434..813ac55b4 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 4f9165dd7..79ff0a74d 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-def.mkiv b/tex/context/base/strc-def.mkiv
index e60e4f60a..dc86da902 100644
--- a/tex/context/base/strc-def.mkiv
+++ b/tex/context/base/strc-def.mkiv
@@ -114,7 +114,7 @@
\setsectionblock [\v!bodypart]% default
\to \everyjob
-% \definesection
+% \definesection (could become \definehead with one parameter)
\definesection[\s!section-1] % part
\definesection[\s!section-2] % chapter
diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua
index 024baa1c5..fff357574 100644
--- a/tex/context/base/strc-doc.lua
+++ b/tex/context/base/strc-doc.lua
@@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['strc-doc'] = {
-- we need to freeze and document this module
local next, type = next, type
-local format, gsub, find, concat, gmatch, match = string.format, string.gsub, string.find, table.concat, string.gmatch, string.match
+local format, gsub, find, gmatch, match = string.format, string.gsub, string.find, string.gmatch, string.match
local concat = table.concat
local max, min = math.max, math.min
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
@@ -816,6 +816,55 @@ function sections.getnumber(depth,what) -- redefined here
context((sectiondata and sectiondata.numbers[depth]) or 0)
end
+-- experimental
+
+local levels = { }
+
+--~ function commands.autonextstructurelevel(level)
+--~ if level > #levels then
+--~ for i=#levels+1,level do
+--~ levels[i] = ""
+--~ end
+--~ end
+--~ local finish = concat(levels,"\n",level) or ""
+--~ for i=level+1,#levels do
+--~ levels[i] = ""
+--~ end
+--~ levels[level] = [[\finalizeautostructurelevel]]
+--~ context(finish)
+--~ end
+
+--~ function commands.autofinishstructurelevels()
+--~ local finish = concat(levels,"\n") or ""
+--~ levels = { }
+--~ context(finish)
+--~ end
+
+function commands.autonextstructurelevel(level)
+ if level > #levels then
+ for i=#levels+1,level do
+ levels[i] = false
+ end
+ else
+ for i=level,#levels do
+ if levels[i] then
+ context.finalizeautostructurelevel()
+ levels[i] = false
+ end
+ end
+ end
+ levels[level] = true
+end
+
+function commands.autofinishstructurelevels()
+ for i=1,#levels do
+ if levels[i] then
+ context.finalizeautostructurelevel()
+ end
+ end
+ levels = { }
+end
+
-- interface (some are actually already commands, like sections.fullnumber)
commands.structurenumber = function() sections.fullnumber() end
diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv
index 71a15d4af..98fa0fed6 100644
--- a/tex/context/base/strc-flt.mkiv
+++ b/tex/context/base/strc-flt.mkiv
@@ -247,7 +247,7 @@
\presetlocalframed[\??fl]
\def\dododefinefloat[#1][#2]%
- {\copylocalframed[\??fl#1][\??fl]%
+ {\inheritlocalframed[\??fl#1][\??fl]%
\definestructurecounter[#1]%
\addtocommalist{#1}\alldefinedfloats
\setupfloat[#1][\s!parent=\??fl]%
@@ -259,7 +259,7 @@
}% \newnodelocation{\v!float\@@thenumber{#1}}}
\def\redodefinefloat[#1][#2][#3]%
- {\copylocalframed[\??fl#1][\??fl#3]%
+ {\inheritlocalframed[\??fl#1][\??fl#3]%
\setupfloat[#1][\s!parent=\??fl#3]%
\setupcaption[#1][\s!parent=\??kj#3]%
\definestructurecounter[#1][#3]%
diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv
index 312e9f485..8083d61ce 100644
--- a/tex/context/base/strc-lst.mkiv
+++ b/tex/context/base/strc-lst.mkiv
@@ -23,60 +23,6 @@
\unprotect
-% \def\currentlist {\s!unknown}
-%
-% \def\listparameter #1{\csname\dolistparameter{\??li\currentlist}#1\endcsname}
-% \def\namedlistparameter#1#2{\csname\dolistparameter{\??li #1}#2\endcsname}
-% \def\listparameterhash #1{\dolistparameterhash {\??li\currentlist}#1}
-%
-% \def\dolistparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dolistparentparameter \csname#1\s!parent\endcsname#2\fi}
-% \def\dolistparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dolistparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-%
-% \def\dolistparentparameter #1#2{\ifx#1\relax\s!empty\else\dolistparameter #1#2\fi}
-% \def\dolistparentparameterhash#1#2{\ifx#1\relax \else\dolistparameterhash#1#2\fi}
-%
-% \def\setlistparameter#1#2#3{\@EA\def\csname\??li#1#2\endcsname{#3}} % often
-%
-% \def\dosetlistattributes#1#2% style color
-% {\edef\fontattributehash {\listparameterhash#1}%
-% \edef\colorattributehash{\listparameterhash#2}%
-% \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
-% \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
-%
-% \def\donestedlistattributes#1#2%
-% {\dosetlistattributes#1#2%
-% \ifx\colorattributehash\empty \else
-% \resetinteractionparameter\c!color
-% \resetinteractionparameter\c!contrastcolor
-% \fi}
-%
-% \def\checklistexistence#1%
-% {\ifcsname\??li#1\s!parent\endcsname \else
-% \letvalue{\??li#1\s!parent}\??li
-% \fi}
-%
-% \def\dosetuplist[#1][#2]% slow -)
-% {\checklistexistence{#1}%
-% \def\docommand##1{\getparameters[\??li##1][#2]}%
-% \processcommalist[#1]\docommand}
-%
-% \unexpanded\def\setuplist
-% {\dodoubleargument\dosetuplist}
-%
-% \unexpanded\def\definelist
-% {\dotripleempty\dodefinelist}
-%
-% \def\dodefinelist[#1][#2][#3]%
-% {\presetlocalframed[\??li#1]% still inefficient (will change when we redu core-rul)
-% \doifassignmentelse{#2}
-% {\getparameters[\??li#1][\s!parent=\??li,#2]}
-% {\doifelsenothing{#2}
-% {\getparameters[\??li#1][\s!parent=\??li]}
-% {\getparameters[\??li#1][\s!parent=\??li#2,#3]}}}
-%
-% \unexpanded\def\setuplists % new, but not for users (hardly handy)
-% {\dodoubleargument\getparameters[\??li]}
-
\installcommandhandler \??li {list} \??li
\def\donestedlistattributes#1#2% will change
@@ -86,18 +32,10 @@
\resetinteractionparameter\c!contrastcolor
\fi}
-% \appendtoks
-% \ifx\currentlist\empty\else
-% \ifcsname\??li\currentlist\s!parent\endcsname \else
-% \letvalue{\??li\currentlist\s!parent}\??li % Is this still needed? Could be built in.
-% \fi
-% \fi
-% \to \everysetuplist
-
\let\setuplists\setuplist % yes or no
-\def\doifelselist#1% can also move to \installcommandhandler
- {\ifcsname\??li#1\s!parent\endcsname
+\unexpanded\def\doifelselist#1% can also move to \installcommandhandler
+ {\ifcsname\namedlisthash{#1}\s!parent\endcsname
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
@@ -358,6 +296,8 @@
% so far (todo: also recursive)
+% TODO: also make this a commandhandler
+
\def\listalternativeparameter#1%
{\ifcsname\??li\??li\listparameter\c!alternative#1\endcsname
\csname\??li\??li\listparameter\c!alternative#1\endcsname
@@ -384,9 +324,6 @@
%def\listdots{\leaders \hbox to .5em{\hss.\hss}\hfill}
\def\listdots{\gleaders\hbox to .5em{\hss.\hss}\hfill}
-% \setvalue{\??li\c!alternative}{\getvalue{\??li\c!alternative b}} % ?
-% \getvalue{\??li\c!alternative} % ?
-
\unexpanded\def\placelist
{\dodoubleempty\doplacelist}
@@ -639,7 +576,7 @@
{\doifelsenothing{#2}
{\getvalue{\@@dodolistelement\v!command}}%
{\executeifdefined{\@@dodolistelement#2}{\getvalue{\@@dodolistelement\v!command}}}%
- \setvalue{\??li\currentlist\c!command}{\getvalue{\@@dodolistelement::#1}}}%
+ \setlistparameter\c!command{\getvalue{\@@dodolistelement::#1}}}%
\setvalue{\@@dodolistelement::#1}}
% don't mess arround with endgraf/grouping else we loose leftskip
@@ -648,8 +585,6 @@
\def\newlineinlist{\space}
-\let\currentlist\s!unknown
-
\def\docurrentlistalternative
{\edef\currentlistalternative{\listparameter\c!alternative}%
\ifx\currentlistalternative\empty
@@ -667,7 +602,7 @@
\dosomelistelement{#1}{#2}{#3}{#4}{#5}{#6}}
\def\dodocommandlistelement#1#2#3#4#5#6%
- {\doifdefinedelse{\??li#1\c!command}
+ {\doifdefinedelse{\currentlisthash\c!command}
{\listparameter\c!command{#3}{#4}{#5}}
{[\currentlist: #3 -- #4 -- #5]}}
@@ -686,9 +621,9 @@
#3{#4}%
\fi}
-\def\dodofreelistelement#1#2#3#4#5#6#7#8%
+\def\dodofreelistelement#1#2#3#4#5#6#7#8% #1 is sort of redundant
{\listparameter\c!before% can be \hskip
- \doifdefinedelse{\??li#1\c!command}
+ \doifdefinedelse{\currentlisthash\c!command} % maybe ifcsname
{\domakelistelement{\listparameter\c!interaction}{#2}\hbox
{\listparameter\c!command
{#3}% geen conversies etc
@@ -748,7 +683,6 @@
\!!widthc\zeropoint}
{\!!widtha\listparameter\c!width}}
{\!!widtha\listparameter\c!width}}%
-% \getvalue{\??li\c!alternative\listparameter\c!alternative}% ?
\endgraf
\noindent
\domakelistelement\v!all{#2}\hbox
@@ -916,7 +850,7 @@
\def\dodofixdlistelementE#1%
{\dodofixdlistelementEFG
{\setupinteraction[\c!strut=\v!no]}
- {\localframed[\??li\currentlist][\c!depth=\!!zeropoint,\c!color=]}
+ {\localframed[\currentlisthash][\c!depth=\!!zeropoint,\c!color=]}
{}}
\def\dodofixdlistelementF#1%
@@ -934,7 +868,7 @@
\def\dodofixdlistelementEFG#1#2#3#4#5#6#7#8%
{\noindent
\bgroup
- \domakelistelement\v!no{#4}{#2}%
+ \domakelistelement\v!all{#4}{#2}%
{\let\\=\newlineinlist
#1% in case E nils the strut (still needed?)
\dosetlistattributes\c!style\c!color
diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv
index f309fdc29..a1aec9ab5 100644
--- a/tex/context/base/strc-not.mkiv
+++ b/tex/context/base/strc-not.mkiv
@@ -345,6 +345,7 @@
\def\currentnoterulecommandunknown{\noteparameter\c!rule}
\def\letcurrentnoterulecommand{\expandafter\let\csname\??vn\c!rule:c:\currentnote\endcsname}
+\def\letcurrentnoterulealign {\expandafter\let\csname\??vn\c!rule:a:\currentnote\endcsname}
\appendtoks
\letvalue{\??vn\c!rule:c:\currentnote}\currentnoterulecommandnormal
@@ -355,8 +356,8 @@
\processallactionsinset[\noteparameter\c!rule]
[ \v!on=>\letcurrentnoterulecommand\currentnoterulecommandnormal,
\v!normal=>\letcurrentnoterulecommand\currentnoterulecommandnormal,
- \v!left=>\letcurrentnoterulecommand\lefttoright,
- \v!right=>\letcurrentnoterulecommand\righttoleft,
+ \v!left=>\letcurrentnoterulealign \lefttoright,
+ \v!right=>\letcurrentnoterulealign \righttoleft,
\v!off=>\letcurrentnoterulecommand\relax,
\s!default=>\letcurrentnoterulecommand\relax,
\s!unknown=>\letcurrentnoterulecommand\currentnoterulecommandunknown]%
diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv
index 2d70f00ce..675fb2127 100644
--- a/tex/context/base/strc-num.mkiv
+++ b/tex/context/base/strc-num.mkiv
@@ -148,36 +148,36 @@
}%
\fi}
-\def\doifstructurecounterelse#1{\ctxcommand{doifelsestructurecounter("\@@thestructurecounter{#1}")}}
-\def\doifstructurecounter #1{\ctxcommand{doifstructurecounter ("\@@thestructurecounter{#1}")}}
-\def\doifnotstructurecounter #1{\ctxcommand{doifnotstructurecounter ("\@@thestructurecounter{#1}")}}
-
-\def\setstructurecounter [#1]#2{\ctxcommand{setstructurecounter ("\@@thestructurecounter{#1}",1,\number#2)}}
-\def\setstructurecounterown [#1]#2{\ctxcommand{setownstructurecounter ("\@@thestructurecounter{#1}",1,"#2")}}
-\def\resetstructurecounter [#1]{\ctxcommand{resetstructurecounter ("\@@thestructurecounter{#1}",1)}}
-\def\restartstructurecounter [#1]#2{\ctxcommand{restartstructurecounter("\@@thestructurecounter{#1}",1,#2)}}
-\def\savestructurecounter [#1]{\ctxcommand{savestructurecounter ("\@@thestructurecounter{#1}")}}
-\def\restorestructurecounter [#1]{\ctxcommand{restorestructurecounter("\@@thestructurecounter{#1}")}}
-\def\incrementstructurecounter [#1]{\ctxcommand{addstructurecounter ("\@@thestructurecounter{#1}",1,1)}}
-\def\decrementstructurecounter [#1]{\ctxcommand{addstructurecounter ("\@@thestructurecounter{#1}",1,-1)}}
-\def\rawstructurecounter [#1]{\ctxcommand{structurecountervalue ("\@@thestructurecounter{#1}",1)}}
-\def\laststructurecounter [#1]{\ctxcommand{laststructurecounter ("\@@thestructurecounter{#1}",1)}}
-\def\firststructurecounter [#1]{\ctxcommand{firststructurecounter ("\@@thestructurecounter{#1}",1)}}
-\def\nextstructurecounter [#1]{\ctxcommand{nextstructurecounter ("\@@thestructurecounter{#1}",1)}}
-\def\prevstructurecounter [#1]{\ctxcommand{prevstructurecounter ("\@@thestructurecounter{#1}",1)}}
-\def\structurecountersubs [#1]{\ctxcommand{structurecounterssub ("\@@thestructurecounter{#1}",1)}}
-\def\showstructurecounter [#1]{\ctxcommand{tracestructurecounter ("\@@thestructurecounter{#1}")}}
-
-\def\incrementedstructurecounter[#1]{\ctxcommand{incrementedstructurecounter("\@@thestructurecounter{#1}",1, 1)}}
-\def\decrementedstructurecounter[#1]{\ctxcommand{incrementedstructurecounter("\@@thestructurecounter{#1}",1,-1)}}
-
-\def\setsubstructurecounter {\dodoubleargument\dosetsubstructurecounter}
-\def\setsubstructurecounterown {\dodoubleargument\dosetsubstructurecounterown}
-\def\resetsubstructurecounter {\dodoubleargument\doresetsubstructurecounter}
-\def\restartsubstructurecounter {\dodoubleargument\dorestartsubstructurecounter}
-\def\incrementsubstructurecounter {\dodoubleargument\doincrementsubstructurecounter}
-\def\decrementsubstructurecounter {\dodoubleargument\dodecrementsubstructurecounter}
-\def\rawsubstructurecounter {\dodoubleargument\dorawsubstructurecounter}
+\unexpanded\def\doifstructurecounterelse#1{\ctxcommand{doifelsestructurecounter("\@@thestructurecounter{#1}")}}
+\unexpanded\def\doifstructurecounter #1{\ctxcommand{doifstructurecounter ("\@@thestructurecounter{#1}")}}
+\unexpanded\def\doifnotstructurecounter #1{\ctxcommand{doifnotstructurecounter ("\@@thestructurecounter{#1}")}}
+
+\unexpanded\def\setstructurecounter [#1]#2{\ctxcommand{setstructurecounter ("\@@thestructurecounter{#1}",1,\number#2)}}
+\unexpanded\def\setstructurecounterown [#1]#2{\ctxcommand{setownstructurecounter ("\@@thestructurecounter{#1}",1,"#2")}}
+\unexpanded\def\resetstructurecounter [#1]{\ctxcommand{resetstructurecounter ("\@@thestructurecounter{#1}",1)}}
+\unexpanded\def\restartstructurecounter [#1]#2{\ctxcommand{restartstructurecounter("\@@thestructurecounter{#1}",1,#2)}}
+\unexpanded\def\savestructurecounter [#1]{\ctxcommand{savestructurecounter ("\@@thestructurecounter{#1}")}}
+\unexpanded\def\restorestructurecounter [#1]{\ctxcommand{restorestructurecounter("\@@thestructurecounter{#1}")}}
+\unexpanded\def\incrementstructurecounter [#1]{\ctxcommand{addstructurecounter ("\@@thestructurecounter{#1}",1,1)}}
+\unexpanded\def\decrementstructurecounter [#1]{\ctxcommand{addstructurecounter ("\@@thestructurecounter{#1}",1,-1)}}
+ \def\rawstructurecounter [#1]{\ctxcommand{structurecountervalue ("\@@thestructurecounter{#1}",1)}}
+ \def\laststructurecounter [#1]{\ctxcommand{laststructurecounter ("\@@thestructurecounter{#1}",1)}}
+ \def\firststructurecounter [#1]{\ctxcommand{firststructurecounter ("\@@thestructurecounter{#1}",1)}}
+ \def\nextstructurecounter [#1]{\ctxcommand{nextstructurecounter ("\@@thestructurecounter{#1}",1)}}
+ \def\prevstructurecounter [#1]{\ctxcommand{prevstructurecounter ("\@@thestructurecounter{#1}",1)}}
+ \def\structurecountersubs [#1]{\ctxcommand{structurecounterssub ("\@@thestructurecounter{#1}",1)}}
+ \def\showstructurecounter [#1]{\ctxcommand{tracestructurecounter ("\@@thestructurecounter{#1}")}}
+
+\unexpanded\def\incrementedstructurecounter[#1]{\ctxcommand{incrementedstructurecounter("\@@thestructurecounter{#1}",1, 1)}}
+\unexpanded\def\decrementedstructurecounter[#1]{\ctxcommand{incrementedstructurecounter("\@@thestructurecounter{#1}",1,-1)}}
+
+\unexpanded\def\setsubstructurecounter {\dodoubleargument\dosetsubstructurecounter}
+\unexpanded\def\setsubstructurecounterown {\dodoubleargument\dosetsubstructurecounterown}
+\unexpanded\def\resetsubstructurecounter {\dodoubleargument\doresetsubstructurecounter}
+\unexpanded\def\restartsubstructurecounter {\dodoubleargument\dorestartsubstructurecounter}
+\unexpanded\def\incrementsubstructurecounter {\dodoubleargument\doincrementsubstructurecounter}
+\unexpanded\def\decrementsubstructurecounter {\dodoubleargument\dodecrementsubstructurecounter}
+ \def\rawsubstructurecounter {\dodoubleargument\dorawsubstructurecounter}
\def\dosetsubstructurecounter [#1][#2]#3{\ctxcommand{setstructurecounter ("\@@thestructurecounter{#1}",#2,\number#3)}}
\def\dosetsubstructurecounterown [#1][#2]#3{\ctxcommand{setownstructurecounter ("\@@thestructurecounter{#1}",#2,"#3")}}
@@ -199,7 +199,7 @@
\def\docheckstructurecounterbypage#1% since we call lua to get the way we can as well do all in lua
{\doif{\structurecounterway{#1}}\v!page{\checkpagechange{#1}\ifpagechanged\resetstructurecounter[#1]\fi}}
-\def\incrementstructurecounter[#1]%
+\unexpanded\def\incrementstructurecounter[#1]%
{\docheckstructurecounterbypage{#1}%
\ctxcommand{addstructurecounter("\@@thestructurecounter{#1}",1,1)}}
@@ -207,7 +207,7 @@
{\docheckstructurecounterbypage{#1}%
\ctxcommand{addstructurecounter("\@@thestructurecounter{#1}",#2,1)}}
-\def\convertedstructurecounter
+\unexpanded\def\convertedstructurecounter
{\dodoubleempty\doconvertedstructurecounter}
\def\doconvertedstructurecounter[#1][#2]%
@@ -241,8 +241,7 @@
\endgroup}
\def\directconvertedstructurecounter#1#2% name, type
- {\begingroup
- \ctxlua{structures.sections.prefixedconverted(
+ {\ctxlua{structures.sections.prefixedconverted(
"\@@thestructurecounter{#1}",
{
prefix = "\structurecounterparameter{#1}\c!prefix",
@@ -265,8 +264,7 @@
segments = "\structurecounterparameter{#1}\c!numbersegments",
type = "#2",
}
- )}%
- \endgroup}
+ )}}
\unexpanded\def\convertedsubstructurecounter
{\dotripleempty\doconvertedsubstructurecounter}
@@ -280,9 +278,9 @@
\let\getstructurecounter\convertedstructurecounter
-\def\doifdefinedstructurecounter #1{\doifdefined {\csname\s!structurecounter#1\c!number\endcsname}}
-\def\doifundefinedstructurecounter #1{\doifundefined {\csname\s!number#1\c!number\endcsname}}
-\def\doifdefinedstructurecounterelse#1{\doifdefinedelse{\csname\s!number#1\c!number\endcsname}}
+\unexpanded\def\doifdefinedstructurecounter #1{\doifdefined {\csname\s!structurecounter#1\c!number\endcsname}}
+\unexpanded\def\doifundefinedstructurecounter #1{\doifundefined {\csname\s!number#1\c!number\endcsname}}
+\unexpanded\def\doifdefinedstructurecounterelse#1{\doifdefinedelse{\csname\s!number#1\c!number\endcsname}}
\ifx\checkstructurecounter\undefined \def\checkstructurecounter[#1]{} \fi
diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv
index 3106d7cb7..0d82b7f6f 100644
--- a/tex/context/base/strc-ren.mkiv
+++ b/tex/context/base/strc-ren.mkiv
@@ -233,6 +233,7 @@
\forgetbothskips}
{\globallet\localheadskip\!!zeropoint
\forgetall}%
+ \setfalse\inhibitmargindata % brrrr is set in forgetall
\dontcomplain
\postponenotes
\iflocation
diff --git a/tex/context/base/strc-sbe.mkiv b/tex/context/base/strc-sbe.mkiv
index 8ab4b9dbd..fda7f3981 100644
--- a/tex/context/base/strc-sbe.mkiv
+++ b/tex/context/base/strc-sbe.mkiv
@@ -75,7 +75,7 @@
\def\dosetsectionblock[#1]% used to set the default
{\edef\currentsectionblock{\ctxlua{structures.sections.setblock("#1")}}}
-\let\currentsectionblock\s!unknown
+\let\currentsectionblock\empty % was \s!unknown
\unexpanded\def\startsectionblock[#1]%
{%\ctxlua{structures.counters.check(0)}% we assume sane usage of \page, as this is the only workable place (in push)
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index be1cf3b2f..ece7ebb3a 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -63,16 +63,8 @@
\installcommandhandler \??nh {head} \??nh
-\def\headparameterstrict#1{\csname\ifcsname\??nh\currenthead#1\endcsname\??nh\currenthead#1\else\s!empty\fi\endcsname}
-
\let\setupheads\setuphead % will go
-\newif\ifsectionnumber % maybe conditional
-
-\appendtoks
- \doifelse{\headparameter\c!sectionnumber}\v!yes\sectionnumbertrue\sectionnumberfalse
-\to \everysetuphead
-
\appendtoks
\ifx\currentheadparent\empty
\edef\currentheaddefault{\headparameter\c!default}%
@@ -85,8 +77,9 @@
\let\currentheadparent\currentheaddefault
\fi\fi
\normalexpanded {%
- \getparameters[\??nh\currenthead][\c!label=\currenthead]%
- \getparameters[\??nh\currenthead][\s!parent=\??nh\currentheadparent]%
+ \setheadparameter{\c!label }{\currenthead}%
+ \setheadparameter{\c!coupling}{\currenthead}%
+ \setheadparameter{\s!parent}{\??nh\currentheadparent}%
\definemarking[\currenthead] [\currentheadsection]%
\definemarking[\currenthead\v!number][\currentheadsection]%
\setupmarking [\currenthead] [\c!filtercommand=\noexpand\sectionheadmarkingtitle {\currenthead}]%
@@ -96,7 +89,8 @@
{\definelist[\currenthead][\c!prefix=\v!no]}%
\else
\normalexpanded {%
- \getparameters[\??nh\currenthead][\c!label=\currenthead,\c!coupling=\currentheadparent]%
+ \setheadparameter{\c!label}{\currenthead}%
+ \setheadparameter{\c!coupling}{\currentheadparent}%
\definemarking[\currenthead] [\currentheadparent]%
\definemarking[\currenthead\v!number][\currentheadparent\c!number]%
}%
@@ -139,41 +133,41 @@
% structure sections (the parents of chapter etc)
-\newcount\maxstructuredepth
-
-\let\lastsectionname\empty
+\let\firstsectionname\empty
+\let\lastsectionname \empty
\let\resetallstructuremarks \relax
\let\resetcurrentstructuremarks \relax
\let\resetcurrentstructuremarkswithpage\relax
-\def\resetallstructuremarks {\resetmarking[\v!section-1]} % will become option
-\def\resetcurrentstructuremarks {\resetmarking[\lastsectionname]} % will become option
-%def\resetcurrentstructuremarkswithpage{\resetmarking[\lastsectionname]} % will become option
+\def\resetallstructuremarks {\resetmarking[\firstsectionname]} % will become option (was \v!section-1)
+\def\resetcurrentstructuremarks {\resetmarking[\lastsectionname]} % will become option
+%def\resetcurrentstructuremarkswithpage{\resetmarking[\lastsectionname]} % will become option
-\newtoks\everydefinesection
+% -2=text -1=manual 0=block 1+=structurelevel
-\appendtoks
- % This is a rather practical default that we don't want to
- % be part of the parent chain lookup mechanism; it's also
- % mkii compatible. Somewhat weird that it's part of the
- % top level structure but it will be flattened anyway.
- \getparameters[\??nh\currentsection]
- [ \c!textstyle=\headparameterstrict\c!style,
- \c!textcolor=\headparameterstrict\c!color,
- \c!numberstyle=\headparameterstrict\c!style,
- \c!numbercolor=\headparameterstrict\c!color]%
-\to \everydefinesection
+\newcount\maxstructuredepth
+
+\def\setnextsectionlevel#1%
+ {\global\advance\maxstructuredepth\plusone
+ \setevalue{\??nh:\c!level:#1}{\the\maxstructuredepth}}
+
+\def\sectionlevel#1%
+ {\csname\??nh:\c!level:\ifcsname\??nh:\c!level:#1\endcsname#1\else\v!none\fi\endcsname}
+
+\setvalue{\??nh:\c!level:\v!block}{0}
+\setvalue{\??nh:\c!level:\v!none }{-1}
+\setvalue{\??nh:\c!level:\v!text }{-2}
+
+\newtoks\everydefinesection
\unexpanded\def\definesection[#1]%
- {\ifcsname\??nh#1\endcsname
- % redefinition is a rather fatal error
- \else
- \edef\currentsection{#1}%
- \global\advance\maxstructuredepth\plusone
- \setevalue{\??nh#1\c!level}{\the\maxstructuredepth}%
- \setstructurelevel{#1}{\the\maxstructuredepth}%
- \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\lastsectionname]}%
+ {\ifcsname\??nh:\c!level:#1\endcsname \else
+ \edef\currentsection{#1}% not used, will go
+ \edef\currenthead{#1}%
+ \setnextsectionlevel{#1}%
+ \setstructurelevel{#1}{\sectionlevel{#1}}%
+ \normalexpanded{\setheadparameter{\s!parent}{\??nh\lastsectionname}}% TO BE CHECKED
\the\everydefinesection
% so far for these default inheritances
\definemarking[#1]%
@@ -181,48 +175,56 @@
\normalexpanded{\noexpand\relatemarking[#1][\lastsectionname]}% so, the parent will reset the child
\fi
\xdef\lastsectionname{#1}%
- \fi}
+ \ifx\firstsectionname\empty
+ \glet\firstsectionname\lastsectionname
+ \fi
+ \fi}
\unexpanded\def\setupsection
{\dotripleempty\dosetupsection}
\def\dosetupsection[#1]%
- {\doifdefinedelse{\??nh#1}
- {\dodosetupsection[#1]}
- {\dodosetupsection[\sectionheadsection{#1}]}}
-
-\def\dodosetupsection[#1][#2][#3]%
- {\ifthirdargument
- \getparameters[\??nh#1#2][#3]% ? probably sectionblock
+ {\ifcsname\??nh:\c!level:#1\endcsname
+ \dodosetupsection[#1]%
\else
- \getparameters[\??nh#1][#2]%
+ \dodosetupsection[\sectionheadsection{#1}]%
\fi}
-% -2=text -1=manual 0=block 1+=structurelevel
+\def\dodosetupsection[#1][#2][#3]%
+ {\pushmacro\currenthead
+ \ifthirdargument
+ % \getparameters[\??nh#1#2][#3]% ? probably sectionblock
+ \edef\currenthead{#1#2}% % not used at any more in mkiv (sets now)
+ \setupcurrenthead[#3]%
+ \else
+ % \getparameters[\??nh#1][#2]%
+ \edef\currenthead{#1}%
+ \setupcurrenthead[#2]%
+ \fi
+ \popmacro\currenthead}
-\def\sectionlevel#1%
- {\executeifdefined{\??nh#1\c!level}{-1}}
+% we share the parameters as sections are roots of heads so eventually we can
+% consider \definesection -> \definehead with one argument
-\setvalue{\??nh\v!block\c!level}{0}
-\setvalue{\??nh\v!none \c!level}{-1}
-\setvalue{\??nh\v!text \c!level}{-2}
+\appendtoks
+ % This is a rather practical default that we don't want to
+ % be part of the parent chain lookup mechanism; it's also
+ % mkii compatible. Somewhat weird that it's part of the
+ % top level structure but it will be flattened anyway.
+ \let\currenthead\currentsection %
+ \setheadparameter\c!textstyle {\strictheadparameter\c!style}%
+ \setheadparameter\c!textcolor {\strictheadparameter\c!color}%
+ \setheadparameter\c!numberstyle{\strictheadparameter\c!style}%
+ \setheadparameter\c!numbercolor{\strictheadparameter\c!color}%
+\to \everydefinesection
% head -> head
\def\sectionheadmarkingtitle #1#2{\ctxlua{structures.marks.title("#1","#2")}}
\def\sectionheadmarkingnumber#1#2{\ctxlua{structures.marks.number("#1","#2")}}
-% todo, check if section is defined
-
-\def\sectionheadcoupling#1%
- {\ifcsname\??nh#1\c!coupling\endcsname
- \expandafter\sectionheadcoupling\csname\??nh#1\c!coupling\endcsname\else#1%
- \fi}
-
-\def\sectionheadsection#1%
- {\ifcsname\??nh#1\c!section\endcsname
- \expandafter\sectionheadcoupling\csname\??nh#1\c!section\endcsname\else#1%
- \fi}
+\def\sectionheadcoupling#1{\namedheadparameter{#1}\c!coupling}
+\def\sectionheadsection #1{\namedheadparameter{#1}\c!section}
% head construction
@@ -237,10 +239,12 @@
\unexpanded\def\dodohandleheadown[#1][#2]#3#4%
{\settrue\currentstructureown
+ \triggerautostructurelevel
\dohandlehead{#1}{\c!reference={#2},\c!ownnumber={#3},\c!title={#4}}{}} % name ref nr title --
\unexpanded\def\dodohandleheadnop[#1][#2]% for taco: [key=value] variant
{\setfalse\currentstructureown
+ \triggerautostructurelevel
\doifassignmentelse{#2}\dodohandleheadnopA\dodohandleheadnopB{#1}{#2}}
\unexpanded\def\dodohandleheadnopA#1#2%
@@ -264,10 +268,10 @@
\headparameter\c!aftersection
\the\everyafterhead}
-\unexpanded\def\donexthead[#1][#2][#3]% obsolete
- {\setfalse\currentstructureown
- \xdef\currenthead{#1}%
- \dohandlehead{#1}{#2}{#3}} % name -- -- -- userdata
+% \unexpanded\def\donexthead[#1][#2][#3]% obsolete
+% {\setfalse\currentstructureown
+% \xdef\currenthead{#1}%
+% \dohandlehead{#1}{#2}{#3}} % name -- -- -- userdata
% \newconditional\structurereversesectionnumbers % todo: key/val
@@ -344,22 +348,18 @@
\def\dosettructureheadnumbercontent
{\setsystemmode \v!sectionnumber
- \settrue\headshownumber}
+ \settrue\headshownumber} % why ?
\def\doresettructureheadnumbercontent
{\resetsystemmode\v!sectionnumber
- \setfalse\headshownumber}
+ \setfalse\headshownumber} % why ?
\def\setheadnumber
- {\ifsectionnumber
- \doifelse{\sectionblockparameter\c!number}\v!yes % todo
- {\doifelse{\headparameter\c!number}\v!yes
- {\settrue\headshownumber}
- {\setfalse\headshownumber}}
- {\setfalse\headshownumber}%
- \else
- \setfalse\headshownumber
- \fi}
+ {\doifelse{\sectionblockparameter\c!number}\v!yes % todo
+ {\doifelse{\headparameter\c!number}\v!yes
+ {\settrue\headshownumber}
+ {\setfalse\headshownumber}}
+ {\setfalse\headshownumber}}
\unexpanded\def\theheadsynchonization
{\pagetype[\currentheadcoupling]% hm also number
@@ -471,6 +471,8 @@
\endgroup}
\ifdefined\presetnumberheadalternative \else \let\presetnumberheadalternative\relax \fi
+\ifdefined\setautostructurelevel \else \let\setautostructurelevel \relax \fi
+\ifdefined\triggerautostructurelevel \else \let\triggerautostructurelevel \relax \fi
\def\dohandlehead#1#2#3% name data userdata (we can move #1 to the caller)
{\xdef\currenthead {#1}%
@@ -479,6 +481,7 @@
\xdef\currentheadlevel {\sectionlevel \currentheadsection}%
%writestatus\m!system{setup: \currenthead,\currentheadcoupling,\currentheadsection,\currentheadlevel}%
%
+ \setautostructurelevel
\setheadreference % does not do much currently
\setheadincrement
\setheadplacement
@@ -584,7 +587,7 @@
\currentstructuresynchronize}}
\def\synchronizehead#1%
- {\getvalue{#1:sync}}
+ {\csname#1:sync\endcsname}
\unexpanded\def\placerawheaddata [#1]{\synchronizehead {#1}}
\unexpanded\def\placerawheadtext [#1]{\getspecificstructuretitle{\thenamedheadlevel{#1}}}
@@ -783,4 +786,32 @@
\let\startlistreferences\relax
\let\stoplistreferences \relax
+% experimental
+
+\newconditional\auto_structure_level
+
+\appendtoks
+ \settrue\auto_structure_levels
+\to \everyenableelements
+
+\def\setautostructurelevel
+ {\ifconditional\auto_structure_level
+ \ctxcommand{autonextstructurelevel(\number\currentheadlevel)}%
+ \global\setfalse\auto_structure_level
+ \fi}
+
+\def\triggerautostructurelevel
+ {\global\settrue\auto_structure_level}
+
+\def\finalizeautostructurelevels
+ {\ctxcommand{autofinishstructurelevels()}}
+
+\unexpanded\def\finalizeautostructurelevel
+ {\dostoptagged
+ \dostoptagged}
+
+\appendtoks
+ \finalizeautostructurelevels
+\to \everystoptext
+
\protect \endinput
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index f9f604d14..1aae19ee1 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -1072,11 +1072,9 @@
\newcount\processlevel
-%D By default we expand actions:
+% obsolete: \def\expandactions{\let\expandedaction\edef} \expandactions (see mkii)
-\def\expandactions{\let\expandedaction\edef} \expandactions % this command will go away
-
-\def\p!compareprocessactionA[#1=>#2][#3]%
+\unexpanded\def\p!compareprocessactionA[#1=>#2][#3]%
{\edef\!!stringb{#1}%
\ifx\!!stringb\s!default
\let\commalistelement\empty
@@ -1085,34 +1083,30 @@
% met \quitcommalist tot meer dan 25\% sneller
-\def\p!compareprocessactionB[#1=>#2][#3]%
- {\expandedaction\!!stringb{#1}%
+\unexpanded\def\p!compareprocessactionB[#1=>#2][#3]%
+ {\edef\!!stringb{#1}%
\ifx\!!stringa\!!stringb
\def\commalistelement{#3}%
#2%
\expandafter\quitcommalist
- \else
- \edef\!!stringb{#1}%
- \ifx\!!stringb\s!unknown
- \def\commalistelement{#3}% beware of loops
- #2%
- \fi
- \fi}
+ \else\ifx\!!stringb\s!unknown
+ \def\commalistelement{#3}% beware of loops
+ #2%
+ \fi\fi}
-\def\processaction[#1]#2[%
- {\expandedaction\!!stringa{#1}%
+\unexpanded\def\processaction[#1]#2[%
+ {\edef\!!stringa{#1}%
\ifx\!!stringa\empty
\let\p!compareprocessaction\p!compareprocessactionA
\else
\let\p!compareprocessaction\p!compareprocessactionB
\fi
- \def\p!doprocessaction##1%
- {\p!compareprocessaction[##1][#1]}%
- \processnextcommalist\relax\expandactions\p!doprocessaction[}
+ \edef\p!doprocessaction##1{\p!compareprocessaction[##1][#1]}% expands #1
+ \processnextcommalist\relax\relax\p!doprocessaction[}
-\def\p!compareprocessactionC[#1=>#2][#3]%
- {\expandedaction\!!stringa{#1}%
- \expandedaction\!!stringb{#3}%
+\unexpanded\def\p!compareprocessactionC[#1=>#2][#3]%
+ {\edef\!!stringa{#1}%
+ \edef\!!stringb{#3}%
\ifx\!!stringa\!!stringb
\def\commalistelement{#3}%
#2%
@@ -1126,7 +1120,7 @@
\fi}
\unexpanded\def\processfirstactioninset[#1]%
- {\expandedaction\!!stringa{#1}%
+ {\edef\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\processaction
\else
@@ -1136,15 +1130,13 @@
\unexpanded\def\processfirstactionsinsetindeed[#1]#2[#3]%
{\def\p!doprocessaction##1%
- {\def\p!dodoprocessaction####1%
- {\p!compareprocessactionC[####1][##1]}%
+ {\def\p!dodoprocessaction####1{\p!compareprocessactionC[####1][##1]}%
\processcommalist[#3]\p!dodoprocessaction}%
- \processcommalist[#1]\p!doprocessaction
- \expandactions}
+ \normalexpanded{\processcommalist[#1]}\p!doprocessaction}
-\def\p!compareprocessactionD[#1=>#2][#3]%
- {\expandedaction\!!stringa{#1}%
- \expandedaction\!!stringb{#3}%
+\unexpanded\def\p!compareprocessactionD[#1=>#2][#3]%
+ {\edef\!!stringa{#1}%
+ \edef\!!stringb{#3}%
\ifx\!!stringa\!!stringb
\def\commalistelement{#3}%
#2%
@@ -1157,11 +1149,11 @@
\fi
\fi}
-\def\doprocessallactionsinset
+\unexpanded\def\doprocessallactionsinset
{\csname\s!do\the\processlevel\endcsname}
\unexpanded\def\processallactionsinset[#1]%
- {\expandedaction\!!stringa{#1}%
+ {\edef\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\processaction
\else
@@ -1172,55 +1164,23 @@
\unexpanded\def\processallactionsinsetindeed[#1]#2[#3]%
{\advance\processlevel \plusone
\expandafter\def\csname\s!do\the\processlevel\endcsname##1%
- {\def\p!dodoprocessaction####1%
- {\p!compareprocessactionD[####1][##1]}%
+ {\def\p!dodoprocessaction####1{\p!compareprocessactionD[####1][##1]}%
\processcommalist[#3]\p!dodoprocessaction}%
- \processcommalist[#1]\doprocessallactionsinset
- \advance\processlevel \minusone
- \expandactions}
+ \normalexpanded{\processcommalist[#1]}\doprocessallactionsinset
+ \advance\processlevel\minusone}
%D These macros use:
-\def\processnextcommalist#1#2#3[#4#5]%
+\unexpanded\def\processnextcommalist#1#2#3[#4#5]%
{#1%
\let\nexttoken#4%
\global\advance\commalevel \plusone
\long\expandafter\def\csname\s!next\the\commalevel\endcsname##1,%
{#3{##1}\doprocesscommaitem}%
\dodoprocesscommaitem#4#5,]\relax
- \global\advance\commalevel \minusone
+ \global\advance\commalevel\minusone
#2}
-% % THIS IS OBSOLETE (as is \expandedaction)
-%
-% %D \macros
-% %D {unexpandedprocessaction,
-% %D unexpandedprocessfirstactioninset,
-% %D unexpandedprocessallactionsinset}
-% %D
-% %D Now what are those expansion commands doing there. Well,
-% %D sometimes we want to compare actions that may consist off
-% %D commands (i.e. are no constants). In such occasions we can
-% %D use the a bit slower alternatives:
-%
-% \def\unexpandedprocessfirstactioninset{\dontexpandactions\processfirstactioninset}
-% \def\unexpandedprocessaction {\dontexpandactions\processaction}
-% \def\unexpandedprocessallactionsinset {\dontexpandactions\processallactionsinset}
-%
-% %D But when needed we convert the strings to meaningful
-% %D sequences of characters. [THIS CAN GO]
-%
-% \def\unexpandedaction#1>{}
-%
-% \def\noexpandedaction#1#2%
-% {\def\@@convertedargument{#2}%
-% \@EA\edef\@EA#1\@EA{\@EA\unexpandedaction\meaning\@@convertedargument}}
-%
-% \def\dontexpandactions
-% {\let\expandedaction\noexpandedaction}
-%
-% % TILL HERE
-
%D \macros
%D {getfirstcharacter, firstcharacter, remainingcharacters, doiffirstcharacter}
%D
@@ -1249,7 +1209,7 @@
%D \doifinsetelse {substring} {string} {then ...} {else ...}
%D \stoptyping
-\long\def\doifinstringelse#1%
+\unexpanded\def\doifinstringelse#1%
{\edef\@@@instring{#1}% expand #1 here
\ifx\@@@instring\empty
\@EA\thirdofthreearguments
@@ -1257,14 +1217,14 @@
\@EA\dodoifinstringelse
\fi}
-\long\def\dodoifinstringelse#1%
+\unexpanded\def\dodoifinstringelse#1%
{\p!doifinstringelse\@@@instring{#1}%
\@EA\firstoftwoarguments
\else
\@EA\secondoftwoarguments
\fi}
-\long\def\doifinstring#1%%
+\unexpanded\def\doifinstring#1%%
{\edef\@@@instring{#1}% expand #1 here
\ifx\@@@instring\empty
\@EA\gobbletwoarguments
@@ -1272,14 +1232,14 @@
\@EA\dodoifinstring
\fi}
-\long\def\dodoifinstring#1%
+\unexpanded\def\dodoifinstring#1%
{\p!doifinstringelse\@@@instring{#1}%
\@EA\firstofoneargument
\else
\@EA\gobbleoneargument
\fi}
-\long\def\doifnotinstring#1%%
+\unexpanded\def\doifnotinstring#1%%
{\edef\@@@instring{#1}% expand #1 here
\ifx\@@@instring\empty
\@EA\gobbletwoarguments
@@ -1287,7 +1247,7 @@
\@EA\dodoifnotinstring
\fi}
-\long\def\dodoifnotinstring#1%
+\unexpanded\def\dodoifnotinstring#1%
{\p!doifinstringelse\@@@instring{#1}%
\@EA\gobbleoneargument
\else
@@ -1296,7 +1256,7 @@
% replaces prev
-\long\def\p!doifinstringelse#1#2% ##2 can be {abc}
+\unexpanded\def\p!doifinstringelse#1#2% ##2 can be {abc}
{\long\@EA\def\@EA\pp!doifinstringelse\@EA##\@EA1#1##2##3\war{\unless\if##2@}% expand #1 here
\expandafter\pp!doifinstringelse\normalexpanded{#2#1}@@\war} % expand #2 here
@@ -1313,12 +1273,12 @@
%D possible, the latter alternative does minimal (one level)
%D expansion.
-\long\def\p!doifincsnameelse#1#2%
+\unexpanded\def\p!doifincsnameelse#1#2%
{\long\def\pp!doifincsnameelse##1#1##2##3\war
{\unless\if##2@}%
\@EA\pp!doifincsnameelse#2#1@@\war}
-\long\def\doifincsnameelse#1#2% % #3#4%
+\unexpanded\def\doifincsnameelse#1#2% % #3#4%
{\edef\@@@instring{#1}%
\@EA\p!doifincsnameelse\@EA{\@@@instring}{#2}% % #3\else#4\fi}
\expandafter\firstoftwoarguments
@@ -1342,7 +1302,7 @@
%D \type{\getal} and \type{\the\count...}. This macro is a
%D rather dirty one.
-\long\def\doifnumberelse#1% does not accept counters
+\long\def\doifnumberelse#1% does not accept counters (fully expandable)
{\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space
\expandafter\secondoftwoarguments
\else
@@ -1377,7 +1337,7 @@
%D length of the argument (the longer the argument, the less
%D we gain).
-\def\makerawcommalist[#1]#2% use \processnext ... here
+\unexpanded\def\makerawcommalist[#1]#2% use \processnext ... here
{\def\domakerawcommalist##1% we don't expand ##1
{\ifx#2\empty
\def#2{##1}%
@@ -1407,7 +1367,7 @@
\def\@@rawempty{,,}
-\long\def\rawdoifinsetelse#1%
+\unexpanded\def\rawdoifinsetelse#1%
{\edef\@@@instring{,#1,}% expand #1 here
\ifx\@@@instring\@@rawempty
\@EA\thirdofthreearguments
@@ -1415,14 +1375,14 @@
\@EA\rawdodoifinsetelse
\fi}
-\long\def\rawdodoifinsetelse#1%
+\unexpanded\def\rawdodoifinsetelse#1%
{\p!doifinstringelse\@@@instring{,#1,}%
\@EA\firstoftwoarguments
\else
\@EA\secondoftwoarguments
\fi}
-\long\def\rawdoifinset#1%
+\unexpanded\def\rawdoifinset#1%
{\edef\@@@instring{,#1,}% expand #1 here
\ifx\@@@instring\@@rawempty
\@EA\gobbletwoarguments
@@ -1430,7 +1390,7 @@
\@EA\rawdodoifinset
\fi}
-\long\def\rawdodoifinset#1%%
+\unexpanded\def\rawdodoifinset#1%%
{\p!doifinstringelse\@@@instring{,#1,}%
\@EA\firstofoneargument
\else
@@ -1446,7 +1406,7 @@
\fi}%
\pp!rawprocessaction,#2,#1=>,@\war}
-\def\rawprocessaction[#1]#2[#3]%
+\unexpanded\def\rawprocessaction[#1]#2[#3]%
{\edef\!!stringa{#1}%
\edef\!!stringb{undefined}% better \!!undefined
\let\!!processaction\!!stringb
diff --git a/tex/context/base/type-otf.mkiv b/tex/context/base/type-otf.mkiv
index df4809e05..c01a0f5c7 100644
--- a/tex/context/base/type-otf.mkiv
+++ b/tex/context/base/type-otf.mkiv
@@ -630,6 +630,8 @@
\stoptypescriptcollection
+% nb: on my system already 'type-imp-dejavu.mkiv' and 'type-imp-dejavu-condensed.mkiv'
+
\starttypescriptcollection[dejavu]
\starttypescript [serif] [dejavu] [name]
@@ -663,6 +665,38 @@
\definetypeface [dejavu] [mm] [math] [xits] [default] [rscale=auto]
\stoptypescript
+ \starttypescript [serif] [dejavu-condensed] [name]
+ \setups[font:fallback:serif]
+ \definefontsynonym [Serif] [name:dejavuserifcondensed] [features=default]
+ \definefontsynonym [SerifBold] [name:dejavuserifcondensedbold] [features=default]
+ \definefontsynonym [SerifItalic] [name:dejavuserifcondenseditalic] [features=default]
+ \definefontsynonym [SerifBoldItalic] [name:dejavuserifcondensedbolditalic] [features=default]
+ \stoptypescript
+
+ \starttypescript [sans] [dejavu-condensed] [name]
+ \setups[font:fallback:sans]
+ \definefontsynonym [Sans] [name:dejavusanscondensed] [features=default]
+ \definefontsynonym [SansBold] [name:dejavusanscondensedbold] [features=default]
+ \definefontsynonym [SansItalic] [name:dejavusanscondensedoblique] [features=default]
+ \definefontsynonym [SansBoldItalic] [name:dejavusanscondensedboldoblique] [features=default]
+ \stoptypescript
+
+ % \starttypescript [mono] [dejavu-condensed] [name]
+ % \setups[font:fallback:mono]
+ % \definefontsynonym [Mono] [name:dejavusansmono] [features=none]
+ % \definefontsynonym [MonoBold] [name:dejavusansmonobold] [features=none]
+ % \definefontsynonym [MonoItalic] [name:dejavusansmonooblique] [features=none]
+ % \definefontsynonym [MonoBoldItalic] [name:dejavusansmonoboldoblique] [features=none]
+ % \stoptypescript
+
+ \starttypescript[dejavu-condensed]
+ \definetypeface [dejavu-condensed] [rm] [serif] [dejavu-condensed] [default]
+ \definetypeface [dejavu-condensed] [ss] [sans] [dejavu-condensed] [default]
+ \definetypeface [dejavu-condensed] [tt] [mono] [dejavu-condensed] [default]
+ % \definetypeface [dejavu-condensed] [tt] [mono] [dejavu] [default]
+ \definetypeface [dejavu-condensed] [mm] [math] [xits] [default] [rscale=auto]
+ \stoptypescript
+
\stoptypescriptcollection
\starttypescriptcollection[antykwa]
@@ -1887,13 +1921,13 @@
\starttypescriptcollection[punk]
\definefontfeature [punknova] [mode=node,script=latn,rand=yes,kern=yes,liga=yes,tlig=yes]
- \definefontfeature [punknova-slanted] [punknova] [slant=.25]
+ % \definefontfeature [punknova-slanted] [punknova] [slant=.25] % obsolete as we now have all
\starttypescript [serif] [punknova]
- \definefontsynonym [Serif] [\s!file:punknova-regular] [\s!features=punknova]
- \definefontsynonym [SerifSlanted] [\s!file:punknova-regular] [\s!features=punknova-slanted]
- \definefontsynonym [SerifBold] [\s!file:punknova-bold] [\s!features=punknova]
- \definefontsynonym [SerifBoldSlanted][\s!file:punknova-bold] [\s!features=punknova-slanted]
+ \definefontsynonym [Serif] [\s!file:punknova-regular] [\s!features=punknova]
+ \definefontsynonym [SerifSlanted] [\s!file:punknova-slanted] [\s!features=punknova]
+ \definefontsynonym [SerifBold] [\s!file:punknova-bold] [\s!features=punknova]
+ \definefontsynonym [SerifBoldSlanted][\s!file:punknova-boldslanted] [\s!features=punknova]
\definefontsynonym [SerifItalic] [SerifSlanted]
\definefontsynonym [SerifBoldItalic] [SerifBoldSlanted]
\stoptypescript
diff --git a/tex/context/base/typo-krn.lua b/tex/context/base/typo-krn.lua
index a9428439c..7d8f65a38 100644
--- a/tex/context/base/typo-krn.lua
+++ b/tex/context/base/typo-krn.lua
@@ -50,6 +50,7 @@ local fonthashes = fonts.hashes
local fontdata = fonthashes.identifiers
local chardata = fonthashes.characters
local quaddata = fonthashes.quads
+local markdata = fonthashes.marks
typesetters = typesetters or { }
local typesetters = typesetters
@@ -60,6 +61,7 @@ local kerns = typesetters.kerns
kerns.mapping = kerns.mapping or { }
kerns.factors = kerns.factors or { }
local a_kerns = attributes.private("kern")
+local a_fontkern = attributes.private('fontkern')
kerns.attribute = kerns.attribute
storage.register("typesetters/kerns/mapping", kerns.mapping, "typesetters.kerns.mapping")
@@ -83,8 +85,8 @@ kerns.keeptogether = false -- just for fun (todo: control setting with key/value
local function do_process(namespace,attribute,head,force) -- todo: glue so that we can fully stretch
local start, done, lastfont = head, false, nil
-local keepligature = kerns.keepligature
-local keeptogether = kerns.keeptogether
+ local keepligature = kerns.keepligature
+ local keeptogether = kerns.keeptogether
while start do
-- faster to test for attr first
local attr = force or has_attribute(start,attribute)
@@ -97,55 +99,62 @@ local keeptogether = kerns.keeptogether
lastfont = start.font
local c = start.components
if c then
-if keepligature and keepligature(start) then
- -- keep 'm
-else
- c = do_process(namespace,attribute,c,attr)
- local s = start
- local p, n = s.prev, s.next
- local tail = find_node_tail(c)
- if p then
- p.next = c
- c.prev = p
+ if keepligature and keepligature(start) then
+ -- keep 'm
else
- head = c
- end
- if n then
- n.prev = tail
+ c = do_process(namespace,attribute,c,attr)
+ local s = start
+ local p, n = s.prev, s.next
+ local tail = find_node_tail(c)
+ if p then
+ p.next = c
+ c.prev = p
+ else
+ head = c
+ end
+ if n then
+ n.prev = tail
+ end
+ tail.next = n
+ start = c
+ s.components = nil
+ -- we now leak nodes !
+ -- free_node(s)
+ done = true
end
- tail.next = n
- start = c
- s.components = nil
- -- we now leak nodes !
- -- free_node(s)
- done = true
-end
end
local prev = start.prev
- if prev then
+ if not prev then
+ -- skip
+ elseif markdata[lastfont][start.char] then
+ -- skip
+ else
local pid = prev.id
if not pid then
-- nothing
- elseif pid == kern_code and prev.subtype == kerning_code then
-if keeptogether and prev.prev.id == glyph_code and keeptogether(prev.prev,start) then -- we could also pass start
- -- keep 'm
-else
- prev.subtype = userkern_code
- prev.kern = prev.kern + quaddata[lastfont]*krn -- here
- done = true
-end
+ elseif pid == kern_code then
+ if prev.subtype == kerning_code or has_attribute(prev,a_fontkern) then
+ if keeptogether and prev.prev.id == glyph_code and keeptogether(prev.prev,start) then -- we could also pass start
+ -- keep 'm
+ else
+ -- not yet ok, as injected kerns can be overlays (from node-inj.lua)
+ prev.subtype = userkern_code
+ prev.kern = prev.kern + quaddata[lastfont]*krn -- here
+ done = true
+ end
+ end
elseif pid == glyph_code then
if prev.font == lastfont then
local prevchar, lastchar = prev.char, start.char
-if keeptogether and keeptogether(prev,start) then
- -- keep 'm
-else
- local kerns = chardata[lastfont][prevchar].kerns
- local kern = kerns and kerns[lastchar] or 0
- krn = kern + quaddata[lastfont]*krn -- here
- insert_node_before(head,start,new_kern(krn))
- done = true
-end
+ if keeptogether and keeptogether(prev,start) then
+ -- keep 'm
+ else
+ local kerns = chardata[lastfont][prevchar].kerns
+ local kern = kerns and kerns[lastchar] or 0
+ krn = kern + quaddata[lastfont]*krn -- here
+ insert_node_before(head,start,new_kern(krn))
+ done = true
+ end
else
krn = quaddata[lastfont]*krn -- here
insert_node_before(head,start,new_kern(krn))
@@ -210,20 +219,24 @@ end
end
end
end
- elseif id == glue_code and start.subtype == userskip_code then
- local s = start.spec
- local w = s.width
- if w > 0 then
- local width, stretch, shrink = w+gluefactor*w*krn, s.stretch, s.shrink
- start.spec = new_gluespec(width,stretch*width/w,shrink*width/w)
- done = true
- end
- elseif false and id == kern_code and start.subtype == kerning_code then -- handle with glyphs
- local sk = start.kern
- if sk > 0 then
- start.kern = sk*krn
- done = true
+ elseif id == glue_code then
+ if start.subtype == userskip_code then
+ local s = start.spec
+ local w = s.width
+ if w > 0 then
+ local width, stretch, shrink = w+gluefactor*w*krn, s.stretch, s.shrink
+ start.spec = new_gluespec(width,stretch*width/w,shrink*width/w)
+ done = true
+ end
end
+ elseif id == kern_code then
+ -- if start.subtype == kerning_code then -- handle with glyphs
+ -- local sk = start.kern
+ -- if sk > 0 then
+ -- start.kern = sk*krn
+ -- done = true
+ -- end
+ -- end
elseif lastfont and (id == hlist_code or id == vlist_code) then -- todo: lookahead
local p = start.prev
if p and p.id ~= glue_code then
diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua
index e356bd7d0..8b25d95f9 100644
--- a/tex/context/base/typo-mar.lua
+++ b/tex/context/base/typo-mar.lua
@@ -58,6 +58,7 @@ local slide_nodes = node.slide
local hpack_nodes = node.hpack -- nodes.fasthpack not really faster here
local traverse_id = node.traverse_id
local free_node_list = node.flush_list
+local insert_node_after= node.insert_after
local link_nodes = nodes.link
@@ -75,6 +76,9 @@ local leftskip_code = gluecodes.leftskip
local rightskip_code = gluecodes.rightskip
local userdefined_code = whatsitcodes.userdefined
+local dir_code = whatsitcodes.dir
+local localpar_code = whatsitcodes.localpar
+
local nodepool = nodes.pool
local new_kern = nodepool.kern
@@ -301,6 +305,7 @@ local function realign(current,candidate)
-- we assume that list is a hbox, otherwise we had to take the whole current
-- in order to get it right
current.width = 0
+--~ delta = delta + hsize
current.list = hpack_nodes(link_nodes(new_kern(-delta),current.list,new_kern(delta)))
current.width = 0
if trace_margindata then
@@ -406,11 +411,19 @@ local function inject(parent,head,candidate)
end
box.shift = shift
box.width = 0
- if head then
+ if not head then
+ head = box
+ elseif head.id == whatsit_code and head.subtype == localpar_code then
+ -- experimental
+ if head.dir == "TRT" then
+ box.list = hpack_nodes(link_nodes(new_kern(candidate.hsize),box.list,new_kern(-candidate.hsize)))
+ end
+ insert_node_after(head,head,box)
+ else
head.prev = box
box.next = head
+ head = box
end
- head = box
set_attribute(box,a_margindata,nofstatus)
if trace_margindata then
report_margindata("injected: %s, location: %s",candidate.n,location)
diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv
index 8093f17c9..5275625b1 100644
--- a/tex/context/base/typo-mar.mkiv
+++ b/tex/context/base/typo-mar.mkiv
@@ -144,6 +144,7 @@
\begingroup
%\settrue\inhibitmargindata % no flushing in here
\def\currentmargindata{#name}%
+ \let\currentmarginframed\currentmargindata
\dodoubleempty\domargindata}
\appendtoks
@@ -160,18 +161,18 @@
\unexpanded\def\domargindata[#dataparameters][#textparameters]#content%
{\iffirstargument
- \setupmargindata[\currentmargindata][#dataparameters]%
+ \setupcurrentmargindata[#dataparameters]%
\fi
\doifelsenothing{#content}\donefalse\donetrue
\ifdone
\edef\currentmargindatastrut{\margindataparameter\c!strut}%
\the\everymargindatacontent
\dostarttagged\t!margintext\currentmargindata
- \ifcsname\??mf\currentmargindata\s!parent\endcsname
+ \ifcsname\currentmargindatahash\s!parent\endcsname
\setbox\nextbox\hbox\bgroup
\the\everymargindatacontent
\dosetmargindataattributes\c!style\c!color
- \localframedwithsettings[\??mf\currentmargindata][\c!location=\v!normal,#textparameters]\bgroup
+ \localframedwithsettings[\currentmarginframedhash][\c!location=\v!normal,#textparameters]\bgroup
\ifx\currentmargindatastrut\empty \else
\dosetupstrut[\currentmargindatastrut]%
\fi
diff --git a/tex/context/base/util-str.lua b/tex/context/base/util-str.lua
index adcbf1654..13d9b8a63 100644
--- a/tex/context/base/util-str.lua
+++ b/tex/context/base/util-str.lua
@@ -10,7 +10,7 @@ utilities = utilities or {}
utilities.strings = utilities.strings or { }
local strings = utilities.strings
-local find, gsub, rep = string.find, string.gsub, string.rep
+local gsub, rep = string.gsub, string.rep
local Cs, C, Cp, P, Carg = lpeg.Cs, lpeg.C, lpeg.Cp, lpeg.P, lpeg.Carg
local patterns, lpegmatch = lpeg.patterns, lpeg.match
@@ -33,27 +33,45 @@ end
-- The following functions might end up in another namespace.
---~ function strings.tabtospace(str,tab)
---~ -- we don't handle embedded newlines
---~ while true do
---~ local s = find(str,"\t")
---~ if s then
---~ if not tab then tab = 7 end -- only when found
---~ local d = tab-(s-1) % tab
---~ if d > 0 then
---~ str = gsub(str,"\t",rep(" ",d),1)
---~ else
---~ str = gsub(str,"\t","",1)
---~ end
---~ else
---~ break
---~ end
---~ end
---~ return str
---~ end
+local repeaters = { } -- watch how we also moved the -1 in depth-1 to the creator
+
+function strings.newrepeater(str,offset)
+ offset = offset or 0
+ local s = repeaters[str]
+ if not s then
+ s = { }
+ repeaters[str] = s
+ end
+ local t = s[offset]
+ if t then
+ return t
+ end
+ t = { }
+ setmetatable(t, {
+ __index = function(t,k)
+ if not k then
+ return ""
+ end
+ local n = k + offset
+ local s = n > 0 and rep(str,n) or ""
+ t[k] = s
+ return s
+ end
+ } )
+ s[offset] = t
+ return t
+end
+
+--~ local dashes = strings.newrepeater("--",-1)
+
+--~ print(dashes[2])
+--~ print(dashes[3])
+--~ print(dashes[1])
local extra, tab, start = 0, 0, 4, 0
+local nspaces = strings.newrepeater(" ")
+
local pattern =
Carg(1) / function(t)
extra, tab, start = 0, t or 7, 1
@@ -64,7 +82,7 @@ local pattern =
local spaces = tab-(current-1) % tab
if spaces > 0 then
extra = extra + spaces - 1
- return rep(" ",spaces)
+ return nspaces[spaces] -- rep(" ",spaces)
else
return ""
end
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index e4f752770..c4929d170 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 : 08/04/11 00:42:26
+-- merge date : 08/18/11 16:00:53
do -- begin closure to overcome local limits and interference
@@ -1098,6 +1098,9 @@ if not modules then modules = { } end modules ['l-lpeg'] = {
license = "see context related readme files"
}
+
+-- a new lpeg fails on a #(1-P(":")) test and really needs a + P(-1)
+
local lpeg = require("lpeg")
-- tracing (only used when we encounter a problem in integration of lpeg in luatex)
@@ -1165,7 +1168,7 @@ patterns.alwaysmatched = alwaysmatched
local digit, sign = R('09'), S('+-')
local cr, lf, crlf = P("\r"), P("\n"), P("\r\n")
-local newline = crlf + cr + lf
+local newline = crlf + S("\r\n") -- cr + lf
local escaped = P("\\") * anything
local squote = P("'")
local dquote = P('"')
@@ -1723,14 +1726,6 @@ function lpeg.append(list,pp,delayed)
return p
end
---~ Cf(Ct("") * (Cg(C(...) * "=" * Cs(...)))^0, rawset)
-
---~ for k, v in next, patterns do
---~ if type(v) ~= "table" then
---~ lpeg.print(v)
---~ end
---~ end
-
end -- closure
do -- begin closure to overcome local limits and interference
@@ -3426,6 +3421,7 @@ function constructors.scale(tfmdata,specification)
local isvirtual = properties.virtualized or tfmdata.type == "virtual"
local hasquality = target.auto_expand or target.auto_protrude
local hasitalic = properties.italic_correction
+ local autoitalic = properties.auto_italic_correction
local stackmath = not properties.no_stackmath
local nonames = properties.noglyphnames
local nodemode = properties.mode == "node"
@@ -3583,8 +3579,13 @@ function constructors.scale(tfmdata,specification)
end
end
-- todo: hasitalic
- if hasitalic then
- local vi = description.italic or character.italic
+ if autoitalic then
+ local vi = description.italic or (description.boundingbox[3] - description.width + autoitalic)
+ if vi and vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ elseif hasitalic then
+ local vi = description.italic or character.italic -- why character
if vi and vi ~= 0 then
chr.italic = vi*hdelta
end
@@ -7637,6 +7638,7 @@ local traverse_id = node.traverse_id
local unset_attribute = node.unset_attribute
local has_attribute = node.has_attribute
local set_attribute = node.set_attribute
+local copy_node = node.copy
local insert_node_before = node.insert_before
local insert_node_after = node.insert_after
@@ -7647,6 +7649,21 @@ local cursbase = attributes.private('cursbase')
local curscurs = attributes.private('curscurs')
local cursdone = attributes.private('cursdone')
local kernpair = attributes.private('kernpair')
+local fontkern = attributes.private('fontkern')
+
+if context then
+
+ local kern = nodes.pool.register(newkern())
+
+ set_attribute(kern,fontkern,1) -- we can have several, attributes are shared
+
+ newkern = function(k)
+ local c = copy_node(kern)
+ c.kern = k
+ return c
+ end
+
+end
local cursives = { }
local marks = { }
@@ -8477,7 +8494,11 @@ function handlers.gsub_single(start,kind,lookupname,replacement)
end
local function alternative_glyph(start,alternatives,kind,chainname,chainlookupname,lookupname) -- chainname and chainlookupname optional
- local value, choice, n = featurevalue or tfmdata.shared.features[kind], nil, #alternatives -- global value, brrr
+ -- needs checking: (global value, brrr)
+ local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
+ local choice = nil
+ local n = #alternatives
+ --
if value == "random" then
local r = random(1,n)
value, choice = format("random, choice %s",r), alternatives[r]