summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-05-18 23:36:26 +0000
committerKarl Berry <karl@freefriends.org>2014-05-18 23:36:26 +0000
commit49cdd10ba6dfc461ce5e70b61695ba2aba0cbeb7 (patch)
tree040f532958cd03ab74d9a1eace2a064fd7ed2695 /Master/texmf-dist/tex/context/base
parentd64820a42321d65868c63bd49e657b88c58967bb (diff)
context from May 18 beta/cont-tmf.zip (11854476 bytes)
git-svn-id: svn://tug.org/texlive/trunk@34112 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base')
-rw-r--r--Master/texmf-dist/tex/context/base/back-exp.lua1
-rw-r--r--Master/texmf-dist/tex/context/base/back-ini.lua6
-rw-r--r--Master/texmf-dist/tex/context/base/back-ini.mkiv6
-rw-r--r--Master/texmf-dist/tex/context/base/back-u3d.mkiv2
-rw-r--r--Master/texmf-dist/tex/context/base/char-ini.lua53
-rw-r--r--Master/texmf-dist/tex/context/base/cont-new.mkiv2
-rw-r--r--Master/texmf-dist/tex/context/base/context-version.pdfbin4056 -> 4283 bytes
-rw-r--r--Master/texmf-dist/tex/context/base/context.mkiv2
-rw-r--r--Master/texmf-dist/tex/context/base/data-tex.lua28
-rw-r--r--Master/texmf-dist/tex/context/base/font-con.lua7
-rw-r--r--Master/texmf-dist/tex/context/base/font-otb.lua38
-rw-r--r--Master/texmf-dist/tex/context/base/font-otc.lua9
-rw-r--r--Master/texmf-dist/tex/context/base/grph-inc.lua4
-rw-r--r--Master/texmf-dist/tex/context/base/l-lpeg.lua7
-rw-r--r--Master/texmf-dist/tex/context/base/lpdf-grp.lua4
-rw-r--r--Master/texmf-dist/tex/context/base/lpdf-ini.lua23
-rw-r--r--Master/texmf-dist/tex/context/base/lpdf-u3d.lua10
-rw-r--r--Master/texmf-dist/tex/context/base/lxml-ini.mkiv155
-rw-r--r--Master/texmf-dist/tex/context/base/lxml-tex.lua84
-rw-r--r--Master/texmf-dist/tex/context/base/m-pipemode.mkiv7
-rw-r--r--Master/texmf-dist/tex/context/base/math-frc.mkiv45
-rw-r--r--Master/texmf-dist/tex/context/base/math-ini.mkiv6
-rw-r--r--Master/texmf-dist/tex/context/base/math-map.lua251
-rw-r--r--Master/texmf-dist/tex/context/base/math-noa.lua34
-rw-r--r--Master/texmf-dist/tex/context/base/meta-ini.mkiv1
-rw-r--r--Master/texmf-dist/tex/context/base/mlib-lua.lua77
-rw-r--r--Master/texmf-dist/tex/context/base/mult-de.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-def.lua3
-rw-r--r--Master/texmf-dist/tex/context/base/mult-def.mkiv3
-rw-r--r--Master/texmf-dist/tex/context/base/mult-en.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-fr.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-fun.lua1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-it.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-low.lua3
-rw-r--r--Master/texmf-dist/tex/context/base/mult-mps.lua2
-rw-r--r--Master/texmf-dist/tex/context/base/mult-nl.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-pe.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/mult-ro.mkii1
-rw-r--r--Master/texmf-dist/tex/context/base/node-acc.lua12
-rw-r--r--Master/texmf-dist/tex/context/base/node-typ.lua2
-rw-r--r--Master/texmf-dist/tex/context/base/pack-mrl.mkiv2
-rw-r--r--Master/texmf-dist/tex/context/base/page-lin.mkiv557
-rw-r--r--Master/texmf-dist/tex/context/base/page-mix.mkiv3
-rw-r--r--Master/texmf-dist/tex/context/base/publ-dat.lua46
-rw-r--r--Master/texmf-dist/tex/context/base/publ-imp-cite.mkiv223
-rw-r--r--Master/texmf-dist/tex/context/base/publ-ini.lua1276
-rw-r--r--Master/texmf-dist/tex/context/base/publ-ini.mkiv264
-rw-r--r--Master/texmf-dist/tex/context/base/s-math-coverage.lua158
-rw-r--r--Master/texmf-dist/tex/context/base/s-math-coverage.mkiv2
-rw-r--r--Master/texmf-dist/tex/context/base/spac-chr.lua14
-rw-r--r--Master/texmf-dist/tex/context/base/spac-chr.mkiv2
-rw-r--r--Master/texmf-dist/tex/context/base/status-files.pdfbin24657 -> 24609 bytes
-rw-r--r--Master/texmf-dist/tex/context/base/status-lua.pdfbin242871 -> 244006 bytes
-rw-r--r--Master/texmf-dist/tex/context/base/strc-ref.lua2
-rw-r--r--Master/texmf-dist/tex/context/base/strc-ref.mkvi15
-rw-r--r--Master/texmf-dist/tex/context/base/tabl-ntb.mkiv27
-rw-r--r--Master/texmf-dist/tex/context/base/tabl-tbl.mkiv3
-rw-r--r--Master/texmf-dist/tex/context/base/trac-deb.lua7
-rw-r--r--Master/texmf-dist/tex/context/base/trac-log.lua6
-rw-r--r--Master/texmf-dist/tex/context/base/type-imp-cambria.mkiv8
-rw-r--r--Master/texmf-dist/tex/context/base/type-imp-lato.mkiv56
-rw-r--r--Master/texmf-dist/tex/context/base/util-str.lua7
-rw-r--r--Master/texmf-dist/tex/context/base/x-asciimath.lua6
-rw-r--r--Master/texmf-dist/tex/context/base/x-asciimath.mkiv4
-rw-r--r--Master/texmf-dist/tex/context/base/x-mathml.lua2
65 files changed, 2038 insertions, 1547 deletions
diff --git a/Master/texmf-dist/tex/context/base/back-exp.lua b/Master/texmf-dist/tex/context/base/back-exp.lua
index 79538eb728b..44c2cd539b2 100644
--- a/Master/texmf-dist/tex/context/base/back-exp.lua
+++ b/Master/texmf-dist/tex/context/base/back-exp.lua
@@ -2446,3 +2446,4 @@ commands.settagfigure = structurestags.setfigure
commands.settagcombination = structurestags.setcombination
commands.settagtablecell = structurestags.settablecell
commands.settagtabulatecell = structurestags.settabulatecell
+
diff --git a/Master/texmf-dist/tex/context/base/back-ini.lua b/Master/texmf-dist/tex/context/base/back-ini.lua
index e2dabd91e9b..c1f973a0c6f 100644
--- a/Master/texmf-dist/tex/context/base/back-ini.lua
+++ b/Master/texmf-dist/tex/context/base/back-ini.lua
@@ -103,3 +103,9 @@ function codeinjections.gethpos () return 0 end
function codeinjections.getvpos () return 0 end
function codeinjections.hasmatrix() return false end
function codeinjections.getmatrix() return 1, 0, 0, 1, 0, 0 end
+
+-- can best be here
+
+function commands.setrealspaces(v)
+ nodes.tasks.setaction("shipouts","nodes.handlers.accessibility",v == interfaces.variables.yes)
+end
diff --git a/Master/texmf-dist/tex/context/base/back-ini.mkiv b/Master/texmf-dist/tex/context/base/back-ini.mkiv
index de4ba6138e7..c3bc78ae660 100644
--- a/Master/texmf-dist/tex/context/base/back-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/back-ini.mkiv
@@ -154,4 +154,10 @@
\back_job_set_suffix{pdf} % default
+% \setupbackend[space=yes] % replace spacing in (pdf) file
+
+\appendtoks
+ \ctxcommand{setrealspaces("\backendparameter\c!space")}%
+\to \everysetupbackend
+
\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/back-u3d.mkiv b/Master/texmf-dist/tex/context/base/back-u3d.mkiv
index 89d26ee41e8..297dd554579 100644
--- a/Master/texmf-dist/tex/context/base/back-u3d.mkiv
+++ b/Master/texmf-dist/tex/context/base/back-u3d.mkiv
@@ -127,7 +127,7 @@
\startluaparameterset[u3d:myset:display:3]
toolbar = true,
tree = false,
- preview = 'area.png'
+ preview = 'axes.png'
\stopluaparameterset
\startluaparameterset[u3d:myset:display:4]
diff --git a/Master/texmf-dist/tex/context/base/char-ini.lua b/Master/texmf-dist/tex/context/base/char-ini.lua
index d6e8d18a94d..7dc381031fc 100644
--- a/Master/texmf-dist/tex/context/base/char-ini.lua
+++ b/Master/texmf-dist/tex/context/base/char-ini.lua
@@ -459,29 +459,33 @@ local is_mark = allocate ( tohash {
"mn", "ms",
} )
+local is_punctuation = allocate ( tohash {
+ "pc","pd","ps","pe","pi","pf","po",
+} )
+
-- to be redone: store checked characters
-characters.is_character = is_character
-characters.is_letter = is_letter
-characters.is_command = is_command
-characters.is_spacing = is_spacing
-characters.is_mark = is_mark
-
-local mt = { -- yes or no ?
- __index = function(t,k)
- if type(k) == "number" then
- local c = data[k].category
- return c and rawget(t,c)
- else
- -- avoid auto conversion in data.characters lookups
- end
+characters.is_character = is_character
+characters.is_letter = is_letter
+characters.is_command = is_command
+characters.is_spacing = is_spacing
+characters.is_mark = is_mark
+characters.is_punctuation = is_punctuation
+
+local mti = function(t,k)
+ if type(k) == "number" then
+ local c = data[k].category
+ return c and rawget(t,c)
+ else
+ -- avoid auto conversion in data.characters lookups
end
-}
+end
-setmetatableindex(characters.is_character, mt)
-setmetatableindex(characters.is_letter, mt)
-setmetatableindex(characters.is_command, mt)
-setmetatableindex(characters.is_spacing, mt)
+setmetatableindex(characters.is_character, mti)
+setmetatableindex(characters.is_letter, mti)
+setmetatableindex(characters.is_command, mti)
+setmetatableindex(characters.is_spacing, mti)
+setmetatableindex(characters.is_punctuation,mti)
-- todo: also define callers for the above
@@ -776,6 +780,17 @@ function characters.lower (str) return lpegmatch(tolower,str) end
function characters.upper (str) return lpegmatch(toupper,str) end
function characters.shaped(str) return lpegmatch(toshape,str) end
+-- maybe: (twice as fast when much ascii)
+--
+-- local tolower = lpeg.patterns.tolower
+-- local lower = string.lower
+--
+-- local allascii = R("\000\127")^1 * P(-1)
+--
+-- function characters.checkedlower(str)
+-- return lpegmatch(allascii,str) and lower(str) or lpegmatch(tolower,str) or str
+-- end
+
function characters.lettered(str,spacing)
local new, n = { }, 0
if spacing then
diff --git a/Master/texmf-dist/tex/context/base/cont-new.mkiv b/Master/texmf-dist/tex/context/base/cont-new.mkiv
index cf9aa9a870d..e20a7df915f 100644
--- a/Master/texmf-dist/tex/context/base/cont-new.mkiv
+++ b/Master/texmf-dist/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2014.05.05 22:31}
+\newcontextversion{2014.05.18 15:57}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/Master/texmf-dist/tex/context/base/context-version.pdf b/Master/texmf-dist/tex/context/base/context-version.pdf
index b544f56fea8..acc0c1f3671 100644
--- a/Master/texmf-dist/tex/context/base/context-version.pdf
+++ b/Master/texmf-dist/tex/context/base/context-version.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/context/base/context.mkiv b/Master/texmf-dist/tex/context/base/context.mkiv
index 9ef439e45d5..abf7d5c140d 100644
--- a/Master/texmf-dist/tex/context/base/context.mkiv
+++ b/Master/texmf-dist/tex/context/base/context.mkiv
@@ -28,7 +28,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2014.05.05 22:31}
+\edef\contextversion{2014.05.18 15:57}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/Master/texmf-dist/tex/context/base/data-tex.lua b/Master/texmf-dist/tex/context/base/data-tex.lua
index f5c986d7708..04c5ef469ee 100644
--- a/Master/texmf-dist/tex/context/base/data-tex.lua
+++ b/Master/texmf-dist/tex/context/base/data-tex.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['data-tex'] = {
license = "see context related readme files"
}
-local char = string.char
+local char, find = string.char, string.find
local insert, remove = table.insert, table.remove
local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
@@ -15,10 +15,11 @@ local report_tex = logs.reporter("resolvers","tex")
local resolvers = resolvers
-local sequencers = utilities.sequencers
-local methodhandler = resolvers.methodhandler
-local splitlines = string.splitlines
-local utffiletype = utf.filetype
+local sequencers = utilities.sequencers
+local methodhandler = resolvers.methodhandler
+local splitlines = string.splitlines
+local utffiletype = utf.filetype
+local setmetatableindex = table.setmetatableindex
-- local fileprocessor = nil
-- local lineprocessor = nil
@@ -99,10 +100,11 @@ function helpers.textopener(tag,filename,filehandle,coding)
end
logs.show_open(filename)
insert(inputstack,filename)
- return {
+ local currentline, noflines = 0, noflines
+ local t = {
filename = filename,
noflines = noflines,
- currentline = 0,
+ -- currentline = 0,
close = function()
if trace_locating then
report_tex("%a closer: %a closed",tag,filename)
@@ -113,12 +115,12 @@ function helpers.textopener(tag,filename,filehandle,coding)
end,
reader = function(self)
self = self or t
- local currentline, noflines = self.currentline, self.noflines
+ -- local currentline, noflines = self.currentline, self.noflines
if currentline >= noflines then
return nil
else
currentline = currentline + 1
- self.currentline = currentline
+ -- self.currentline = currentline
local content = lines[currentline]
if not content then
return nil
@@ -137,6 +139,14 @@ function helpers.textopener(tag,filename,filehandle,coding)
end
end
}
+ setmetatableindex(t,function(t,k)
+ if k == "currentline" then
+ return currentline
+ else
+ -- no such key
+ end
+ end)
+ return t
end
function resolvers.findtexfile(filename,filetype)
diff --git a/Master/texmf-dist/tex/context/base/font-con.lua b/Master/texmf-dist/tex/context/base/font-con.lua
index b43961ec62e..aca7055235e 100644
--- a/Master/texmf-dist/tex/context/base/font-con.lua
+++ b/Master/texmf-dist/tex/context/base/font-con.lua
@@ -599,6 +599,7 @@ function constructors.scale(tfmdata,specification)
-- basemode hack (we try to catch missing tounicodes, e.g. needed for ssty in math cambria)
local c = changed[unicode]
if c then
+ local ligatures = character.ligatures -- the original ligatures (as we cannot rely on remapping)
description = descriptions[c] or descriptions[unicode] or character
character = characters[c] or character
index = description.index or c
@@ -610,6 +611,9 @@ function constructors.scale(tfmdata,specification)
touni = tounicode[i] -- nb: index!
end
end
+ if ligatures and not character.ligatures then
+ character.ligatures = ligatures -- the original targets (for now at least.. see libertine smallcaps)
+ end
else
description = descriptions[unicode] or character
index = description.index or unicode
@@ -780,7 +784,7 @@ function constructors.scale(tfmdata,specification)
chr.ligatures = vl -- shared
else
local tt = { }
- for i,l in next, vl do
+ for i, l in next, vl do
tt[i] = l
end
chr.ligatures = tt
@@ -963,7 +967,6 @@ function constructors.finalize(tfmdata)
--
properties.finalized = true
--
- --
return tfmdata
end
diff --git a/Master/texmf-dist/tex/context/base/font-otb.lua b/Master/texmf-dist/tex/context/base/font-otb.lua
index 946d552e48c..2e98d3ecbb9 100644
--- a/Master/texmf-dist/tex/context/base/font-otb.lua
+++ b/Master/texmf-dist/tex/context/base/font-otb.lua
@@ -47,13 +47,14 @@ local function gref(descriptions,n)
return f_unicode(n)
end
elseif n then
- local num, nam = { }, { }
- for i=2,#n do
+ local num, nam, j = { }, { }, 0
+ for i=1,#n do
local ni = n[i]
if tonumber(ni) then -- first is likely a key
+ j = j + 1
local di = descriptions[ni]
- num[i] = f_unicode(ni)
- nam[i] = di and di.name or "-"
+ num[j] = f_unicode(ni)
+ nam[j] = di and di.name or "-"
end
end
return f_unilist(num,nam)
@@ -169,7 +170,8 @@ end
-- pseudo names like hyphen_hyphen to endash so in practice we end
-- up with a bit too many definitions but the overhead is neglectable.
--
--- Todo: if changed[first] or changed[second] then ... end
+-- We can have changed[first] or changed[second] but it quickly becomes
+-- messy if we need to take that into account.
local trace = false
@@ -188,8 +190,8 @@ local function finalize_ligatures(tfmdata,ligatures)
local ligature = ligatures[i]
if ligature then
local unicode, lookupdata = ligature[1], ligature[2]
- if trace then
- trace_ligatures_detail("building % a into %a",lookupdata,unicode)
+ if trace_ligatures_detail then
+ report_prepare("building % a into %a",lookupdata,unicode)
end
local size = #lookupdata
local firstcode = lookupdata[1] -- [2]
@@ -201,8 +203,8 @@ local function finalize_ligatures(tfmdata,ligatures)
local firstdata = characters[firstcode]
if not firstdata then
firstcode = private
- if trace then
- trace_ligatures_detail("defining %a as %a",firstname,firstcode)
+ if trace_ligatures_detail then
+ report_prepare("defining %a as %a",firstname,firstcode)
end
unicodes[firstname] = firstcode
firstdata = { intermediate = true, ligatures = { } }
@@ -225,8 +227,8 @@ local function finalize_ligatures(tfmdata,ligatures)
break
end
end
- if trace then
- trace_ligatures_detail("codes (%a,%a) + (%a,%a) -> %a",firstname,firstcode,secondname,secondcode,target)
+ if trace_ligatures_detail then
+ report_prepare("codes (%a,%a) + (%a,%a) -> %a",firstname,firstcode,secondname,secondcode,target)
end
local firstligs = firstdata.ligatures
if firstligs then
@@ -237,6 +239,8 @@ local function finalize_ligatures(tfmdata,ligatures)
firstcode = target
firstname = secondname
end
+ elseif trace_ligatures_detail then
+ report_prepare("no glyph (%a,%a) for building %a",firstname,firstcode,target)
end
if okay then
ligatures[i] = false
@@ -246,12 +250,14 @@ local function finalize_ligatures(tfmdata,ligatures)
end
alldone = done == 0
end
- if trace then
- for k, v in next, characters do
- if v.ligatures then table.print(v,k) end
+ if trace_ligatures_detail then
+ for k, v in table.sortedhash(characters) do
+ if v.ligatures then
+ table.print(v,k)
+ end
end
end
- tfmdata.resources.private = private
+ resources.private = private
end
end
@@ -487,7 +493,7 @@ local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplis
end
changed[unicode] = data
elseif lookuptype == "alternate" then
- local replacement = data[alternate]
+ local replacement = data[alternate]
if replacement then
changed[unicode] = replacement
if trace_alternatives then
diff --git a/Master/texmf-dist/tex/context/base/font-otc.lua b/Master/texmf-dist/tex/context/base/font-otc.lua
index 92775270dc3..f7f8e9ce2c1 100644
--- a/Master/texmf-dist/tex/context/base/font-otc.lua
+++ b/Master/texmf-dist/tex/context/base/font-otc.lua
@@ -134,7 +134,7 @@ local function addfeature(data,feature,specifications)
askedfeatures[k] = table.tohash(v)
end
end
- sequences[#sequences+1] = {
+ local sequence = {
chain = 0,
features = { [feature] = askedfeatures },
flags = featureflags,
@@ -143,6 +143,11 @@ local function addfeature(data,feature,specifications)
subtables = st,
type = featuretype,
}
+ if specification.prepend then
+ insert(sequences,1,sequence)
+ else
+ insert(sequences,sequence)
+ end
-- register in metadata (merge as there can be a few)
if not gsubfeatures then
gsubfeatures = { }
@@ -208,6 +213,7 @@ local tlig_specification = {
data = tlig,
order = { "tlig" },
flags = noflags,
+ prepend = true,
}
otf.addfeature("tlig",tlig_specification)
@@ -231,6 +237,7 @@ local trep_specification = {
data = trep,
order = { "trep" },
flags = noflags,
+ prepend = true,
}
otf.addfeature("trep",trep_specification)
diff --git a/Master/texmf-dist/tex/context/base/grph-inc.lua b/Master/texmf-dist/tex/context/base/grph-inc.lua
index 392aa58b12e..d89c52996c7 100644
--- a/Master/texmf-dist/tex/context/base/grph-inc.lua
+++ b/Master/texmf-dist/tex/context/base/grph-inc.lua
@@ -1619,3 +1619,7 @@ end
-- interfacing
commands.setfigurelookuporder = figures.setorder
+
+--
+
+figures.images = images
diff --git a/Master/texmf-dist/tex/context/base/l-lpeg.lua b/Master/texmf-dist/tex/context/base/l-lpeg.lua
index 6feb7089c74..666af210386 100644
--- a/Master/texmf-dist/tex/context/base/l-lpeg.lua
+++ b/Master/texmf-dist/tex/context/base/l-lpeg.lua
@@ -107,7 +107,8 @@ local uppercase = R("AZ")
local underscore = P("_")
local hexdigit = digit + lowercase + uppercase
local cr, lf, crlf = P("\r"), P("\n"), P("\r\n")
-local newline = crlf + S("\r\n") -- cr + lf
+----- newline = crlf + S("\r\n") -- cr + lf
+local newline = P("\r") * (P("\n") + P(true)) + P("\n")
local escaped = P("\\") * anything
local squote = P("'")
local dquote = P('"')
@@ -141,8 +142,8 @@ patterns.utfbom_16_be = utfbom_16_be
patterns.utfbom_16_le = utfbom_16_le
patterns.utfbom_8 = utfbom_8
-patterns.utf_16_be_nl = P("\000\r\000\n") + P("\000\r") + P("\000\n")
-patterns.utf_16_le_nl = P("\r\000\n\000") + P("\r\000") + P("\n\000")
+patterns.utf_16_be_nl = P("\000\r\000\n") + P("\000\r") + P("\000\n") -- P("\000\r") * (P("\000\n") + P(true)) + P("\000\n")
+patterns.utf_16_le_nl = P("\r\000\n\000") + P("\r\000") + P("\n\000") -- P("\r\000") * (P("\n\000") + P(true)) + P("\n\000")
patterns.utf8one = R("\000\127")
patterns.utf8two = R("\194\223") * utf8next
diff --git a/Master/texmf-dist/tex/context/base/lpdf-grp.lua b/Master/texmf-dist/tex/context/base/lpdf-grp.lua
index befe52c7656..b3cc7ce1f5f 100644
--- a/Master/texmf-dist/tex/context/base/lpdf-grp.lua
+++ b/Master/texmf-dist/tex/context/base/lpdf-grp.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['lpdf-grp'] = {
license = "see context related readme files"
}
-local format, gsub = string.format, string.gsub
+local formatters, gsub = string.formatters, string.gsub
local concat = table.concat
local round = math.round
@@ -236,7 +236,7 @@ function img.package(image) -- see lpdf-u3d **
local height = boundingbox[4]
local xform = img.scan {
attr = resources(),
- stream = format("%F 0 0 %F 0 0 cm /%s Do",width,height,imagetag),
+ stream = formatters["%F 0 0 %F 0 0 cm /%s Do"](width,height,imagetag),
bbox = { 0, 0, width/factor, height/factor },
}
img.immediatewrite(xform)
diff --git a/Master/texmf-dist/tex/context/base/lpdf-ini.lua b/Master/texmf-dist/tex/context/base/lpdf-ini.lua
index a89b8b8c55a..025f62c4f84 100644
--- a/Master/texmf-dist/tex/context/base/lpdf-ini.lua
+++ b/Master/texmf-dist/tex/context/base/lpdf-ini.lua
@@ -254,6 +254,8 @@ local f_key_dictionary = formatters["/%s << % t >>"]
local f_dictionary = formatters["<< % t >>"]
local f_key_array = formatters["/%s [ % t ]"]
local f_array = formatters["[ % t ]"]
+local f_key_number = formatters["/%s %F"]
+local f_tonumber = formatters["%F"]
-- local f_key_value = formatters["/%s %s"]
-- local f_key_dictionary = formatters["/%s <<% t>>"]
@@ -271,6 +273,8 @@ tostring_d = function(t,contentonly,key)
local tv = type(v)
if tv == "string" then
r[rn] = f_key_value(k,toeight(v))
+ elseif tv == "number" then
+ r[rn] = f_key_number(k,v)
elseif tv == "unicode" then
r[rn] = f_key_value(k,tosixteen(v))
elseif tv == "table" then
@@ -309,6 +313,8 @@ tostring_a = function(t,contentonly,key)
local tv = type(v)
if tv == "string" then
r[k] = toeight(v)
+ elseif tv == "number" then
+ r[k] = f_tonumber(v)
elseif tv == "unicode" then
r[k] = tosixteen(v)
elseif tv == "table" then
@@ -339,14 +345,15 @@ tostring_a = function(t,contentonly,key)
end
end
-local tostring_x = function(t) return concat(t," ") end
-local tostring_s = function(t) return toeight(t[1]) end
-local tostring_u = function(t) return tosixteen(t[1]) end
-local tostring_n = function(t) return tostring(t[1]) end -- tostring not needed
-local tostring_c = function(t) return t[1] end -- already prefixed (hashed)
-local tostring_z = function() return "null" end
-local tostring_t = function() return "true" end
-local tostring_f = function() return "false" end
+local tostring_x = function(t) return concat(t," ") end
+local tostring_s = function(t) return toeight(t[1]) end
+local tostring_u = function(t) return tosixteen(t[1]) end
+local tostring_n = function(t) return tostring(t[1]) end -- tostring not needed
+local tostring_n = function(t) return f_tonumber(t[1]) end -- tostring not needed
+local tostring_c = function(t) return t[1] end -- already prefixed (hashed)
+local tostring_z = function() return "null" end
+local tostring_t = function() return "true" end
+local tostring_f = function() return "false" end
local tostring_r = function(t) local n = t[1] return n and n > 0 and (n .. " 0 R") or "NULL" end
local tostring_v = function(t)
diff --git a/Master/texmf-dist/tex/context/base/lpdf-u3d.lua b/Master/texmf-dist/tex/context/base/lpdf-u3d.lua
index f0fca0762f8..c9f4a03691e 100644
--- a/Master/texmf-dist/tex/context/base/lpdf-u3d.lua
+++ b/Master/texmf-dist/tex/context/base/lpdf-u3d.lua
@@ -18,7 +18,7 @@ if not modules then modules = { } end modules ['lpdf-u3d'] = {
-- it makes sense to add the same activation code as with swf.
local tonumber = tonumber
-local format, find = string.format, string.find
+local formatters, find = string.formatters, string.find
local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs
local backends, lpdf = backends, lpdf
@@ -428,13 +428,13 @@ local function insert3d(spec) -- width, height, factor, display, controls, label
local preview = checkedkey(param,"preview","string")
if preview then
activationdict.A = pdfconstant("XA")
- local tag = format("%s:%s:%s",label,stream,preview)
+ local tag = formatters["%s:%s:%s"](label,stream,preview)
local ref = stored_pr[tag]
if not ref then
local figure = img.immediatewrite {
filename = preview,
- width = width,
- height = height
+ width = width,
+ height = height
}
ref = figure.objnum
stored_pr[tag] = ref
@@ -461,7 +461,7 @@ local function insert3d(spec) -- width, height, factor, display, controls, label
},
ProcSet = pdfarray { pdfconstant("PDF"), pdfconstant("ImageC") },
}
- local pwd = pdfflushstreamobject(format("q /GS gs %F 0 0 %F 0 0 cm /IM Do Q",factor*width,factor*height),pw)
+ local pwd = pdfflushstreamobject(formatters["q /GS gs %F 0 0 %F 0 0 cm /IM Do Q"](factor*width,factor*height),pw)
annot.AP = pdfdictionary {
N = pdfreference(pwd)
}
diff --git a/Master/texmf-dist/tex/context/base/lxml-ini.mkiv b/Master/texmf-dist/tex/context/base/lxml-ini.mkiv
index 239fe4ac0c3..752e315da5e 100644
--- a/Master/texmf-dist/tex/context/base/lxml-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/lxml-ini.mkiv
@@ -27,77 +27,78 @@
\unprotect % todo \!!bs \!!es where handy (slower)
-\def\ctxlxml #1{\ctxlua{lxml.#1}}
-
-\def\xmlmain #1{\ctxlxml{main("#1")}}
-\def\xmlmatch #1{\ctxlxml{match("#1")}}
-\def\xmlall #1#2{\ctxlxml{all("#1","#2")}}
-\def\xmlatt #1#2{\ctxlxml{att("#1","#2")}}
-\def\xmlattdef #1#2#3{\ctxlxml{att("#1","#2","#3")}}
-\def\xmlchainatt #1#2{\ctxlxml{chainattribute("#1","/","#2")}}
-\def\xmlchainattdef #1#2#3{\ctxlxml{chainattribute("#1","/","#2","#3")}}
-\def\xmlattribute #1#2#3{\ctxlxml{attribute("#1","#2","#3")}}
-\def\xmlattributedef #1#2#3#4{\ctxlxml{attribute("#1","#2","#3","#4")}}
-\def\xmlcommand #1#2#3{\ctxlxml{command("#1","#2","#3")}}
-\def\xmlconcat #1#2#3{\ctxlxml{concat("#1","#2",[[\detokenize{#3}]])}}
-\def\xmlconcatrange#1#2#3#4#5{\ctxlxml{concatrange("#1","#2","#3","#4",[[\detokenize{#5}]])}}
-\def\xmlcount #1#2{\ctxlxml{count("#1","#2")}}
-\def\xmldelete #1#2{\ctxlxml{delete("#1","#2")}}
-\def\xmldirectives #1{\ctxlxml{directives.setup("#1")}}
-\def\xmldirectivesbefore #1{\ctxlxml{directives.before("#1")}}
-\def\xmldirectivesafter #1{\ctxlxml{directives.after("#1")}}
-\def\xmlfilter #1#2{\ctxlxml{filter("#1",\!!bs#2\!!es)}}
-\def\xmlfilterlist #1#2{\ctxlxml{filterlist("#1",\!!bs#2\!!es)}}
-\def\xmlfunction #1#2{\ctxlxml{applyfunction("#1",\!!bs#2\!!es)}}
-\def\xmlfirst #1#2{\ctxlxml{first("#1","#2")}}
-\def\xmlflush #1{\ctxlxml{flush("#1")}}
-\def\xmlflushlinewise #1{\ctxlxml{flushlinewise("#1")}}
-\def\xmlflushspacewise #1{\ctxlxml{flushspacewise("#1")}}
-%def\xmlcontent #1{\ctxlxml{content("#1")}}
-%def\xmlflushstripped #1{\ctxlxml{strip("#1",true)}}
-\def\xmldirect #1{\ctxlxml{direct("#1")}} % in loops, not dt but root
-\def\xmlidx #1#2#3{\ctxlxml{idx("#1","#2",\number#3)}}
-\def\xmlinclude #1#2#3{\ctxlxml{include("#1","#2","#3",true)}}
-\def\xmlsave #1#2{\ctxlxml{save("#1","#2")}}
-\def\xmlindex #1#2#3{\ctxlxml{index("#1","#2",\number#3)}}
-\def\xmlinfo #1{\hbox{\ttxx[\ctxlxml{info("#1")}]}}
-\def\xmlshow #1{\startpacked\ttx\xmlverbatim{#1}\stoppacked}
-\def\xmllast #1#2{\ctxlxml{last("#1","#2")}}
-\def\xmlname #1{\ctxlxml{name("#1")}}
-\def\xmlnamespace #1{\ctxlxml{namespace("#1")}}
-\def\xmlnonspace #1#2{\ctxlxml{nonspace("#1","#2")}}
-\def\xmlraw #1#2{\ctxlxml{raw("#1","#2")}}
-\def\xmlcontext #1#2{\ctxlxml{context("#1","#2")}}
-\def\xmlflushcontext #1{\ctxlxml{context("#1")}}
-\def\xmlsnippet #1#2{\ctxlxml{snippet("#1",#2)}}
-\def\xmlelement #1#2{\ctxlxml{element("#1",#2)}}
-\def\xmlregisterns #1#2{\ctxlua{xml.registerns("#1","#2")}} % document
-\def\xmlremapname #1#2#3#4{\ctxlua{xml.remapname(lxml.id("#1"),"#2","#3","#4")}} % element
-\def\xmlremapnamespace #1#2#3{\ctxlua{xml.renamespace(lxml.id("#1"),"#2","#3")}} % document
-\def\xmlchecknamespace #1#2#3{\ctxlua{xml.checknamespace(lxml.id("#1"),"#2","#3")}} % element
-\def\xmlsetfunction #1#2#3{\ctxlxml{setaction("#1",\!!bs#2\!!es,#3)}}
-\def\xmlsetsetup #1#2#3{\ctxlxml{setsetup("#1",\!!bs#2\!!es,"#3")}}
-\def\xmlstrip #1#2{\ctxlxml{strip("#1","#2")}}
-\def\xmlstripnolines #1#2{\ctxlxml{strip("#1","#2",true)}}
-\def\xmlstripanywhere #1#2{\ctxlxml{strip("#1","#2",true,true)}}
-\def\xmlstripped #1#2{\ctxlxml{stripped("#1","#2")}}
-\def\xmlstrippednolines #1#2{\ctxlxml{stripped("#1","#2",true)}}
-\def\xmltag #1{\ctxlxml{tag("#1")}}
-\def\xmltext #1#2{\ctxlxml{text("#1","#2")}}
-\def\xmlverbatim #1{\ctxlxml{verbatim("#1")}}
-\def\xmldisplayverbatim #1{\ctxlxml{displayverbatim("#1")}}
-\def\xmlinlineverbatim #1{\ctxlxml{inlineverbatim("#1")}}
-
-\def\xmlload #1#2{\ctxlxml{load("#1","#2","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloadbuffer #1#2{\ctxlxml{loadbuffer("#1","#2","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloaddata #1#2{\ctxlxml{loaddata("#1",\!!bs#2\!!es,"\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloadregistered #1#2{\ctxlxml{loadregistered("#1","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloaddirectives #1{\ctxlxml{directives.load("any:///#1")}}
-\def\xmlpos #1{\ctxlxml{pos("#1")}}
-
-\def\xmltoparameters #1{\ctxlxml{toparameters("#1")}}
-
-\def\xmltofile #1#2#3{\ctxlxml{tofile("#1","#2","#3")}} % id pattern filename
+\def\ctxlxml #1{\ctxlua{lxml.#1}}
+
+\def\xmlmain #1{\ctxlxml{main("#1")}}
+\def\xmlmatch #1{\ctxlxml{match("#1")}}
+\def\xmlall #1#2{\ctxlxml{all("#1","#2")}}
+\def\xmlatt #1#2{\ctxlxml{att("#1","#2")}}
+\def\xmlattdef #1#2#3{\ctxlxml{att("#1","#2","#3")}}
+\def\xmlchainatt #1#2{\ctxlxml{chainattribute("#1","/","#2")}}
+\def\xmlchainattdef #1#2#3{\ctxlxml{chainattribute("#1","/","#2","#3")}}
+\def\xmlattribute #1#2#3{\ctxlxml{attribute("#1","#2","#3")}}
+\def\xmlattributedef #1#2#3#4{\ctxlxml{attribute("#1","#2","#3","#4")}}
+\def\xmlcommand #1#2#3{\ctxlxml{command("#1","#2","#3")}}
+\def\xmlconcat #1#2#3{\ctxlxml{concat("#1","#2",[[\detokenize{#3}]])}}
+\def\xmlconcatrange #1#2#3#4#5{\ctxlxml{concatrange("#1","#2","#3","#4",[[\detokenize{#5}]])}}
+\def\xmlcount #1#2{\ctxlxml{count("#1","#2")}}
+\def\xmldelete #1#2{\ctxlxml{delete("#1","#2")}}
+\def\xmldirectives #1{\ctxlxml{directives.setup("#1")}}
+\def\xmldirectivesbefore #1{\ctxlxml{directives.before("#1")}}
+\def\xmldirectivesafter #1{\ctxlxml{directives.after("#1")}}
+\def\xmlfilter #1#2{\ctxlxml{filter("#1",\!!bs#2\!!es)}}
+\def\xmlfilterlist #1#2{\ctxlxml{filterlist("#1",\!!bs#2\!!es)}}
+\def\xmlfunction #1#2{\ctxlxml{applyfunction("#1",\!!bs#2\!!es)}}
+\def\xmlfirst #1#2{\ctxlxml{first("#1","#2")}}
+\def\xmlflush #1{\ctxlxml{flush("#1")}}
+\def\xmlflushlinewise #1{\ctxlxml{flushlinewise("#1")}}
+\def\xmlflushspacewise #1{\ctxlxml{flushspacewise("#1")}}
+%def\xmlcontent #1{\ctxlxml{content("#1")}}
+%def\xmlflushstripped #1{\ctxlxml{strip("#1",true)}}
+\def\xmldirect #1{\ctxlxml{direct("#1")}} % in loops, not dt but root
+\def\xmlidx #1#2#3{\ctxlxml{idx("#1","#2",\number#3)}}
+\def\xmlinclude #1#2#3{\ctxlxml{include("#1","#2","#3",true)}}
+\def\xmlincludeoptions#1#2#3#4{\ctxlxml{include("#1","#2","#3","#4")}}
+\def\xmlsave #1#2{\ctxlxml{save("#1","#2")}}
+\def\xmlindex #1#2#3{\ctxlxml{index("#1","#2",\number#3)}}
+\def\xmlinfo #1{\hbox{\ttxx[\ctxlxml{info("#1")}]}}
+\def\xmlshow #1{\startpacked\ttx\xmlverbatim{#1}\stoppacked}
+\def\xmllast #1#2{\ctxlxml{last("#1","#2")}}
+\def\xmlname #1{\ctxlxml{name("#1")}}
+\def\xmlnamespace #1{\ctxlxml{namespace("#1")}}
+\def\xmlnonspace #1#2{\ctxlxml{nonspace("#1","#2")}}
+\def\xmlraw #1#2{\ctxlxml{raw("#1","#2")}}
+\def\xmlcontext #1#2{\ctxlxml{context("#1","#2")}}
+\def\xmlflushcontext #1{\ctxlxml{context("#1")}}
+\def\xmlsnippet #1#2{\ctxlxml{snippet("#1",#2)}}
+\def\xmlelement #1#2{\ctxlxml{element("#1",#2)}}
+\def\xmlregisterns #1#2{\ctxlua{xml.registerns("#1","#2")}} % document
+\def\xmlremapname #1#2#3#4{\ctxlua{xml.remapname(lxml.id("#1"),"#2","#3","#4")}} % element
+\def\xmlremapnamespace #1#2#3{\ctxlua{xml.renamespace(lxml.id("#1"),"#2","#3")}} % document
+\def\xmlchecknamespace #1#2#3{\ctxlua{xml.checknamespace(lxml.id("#1"),"#2","#3")}} % element
+\def\xmlsetfunction #1#2#3{\ctxlxml{setaction("#1",\!!bs#2\!!es,#3)}}
+\def\xmlsetsetup #1#2#3{\ctxlxml{setsetup("#1",\!!bs#2\!!es,"#3")}}
+\def\xmlstrip #1#2{\ctxlxml{strip("#1","#2")}}
+\def\xmlstripnolines #1#2{\ctxlxml{strip("#1","#2",true)}}
+\def\xmlstripanywhere #1#2{\ctxlxml{strip("#1","#2",true,true)}}
+\def\xmlstripped #1#2{\ctxlxml{stripped("#1","#2")}}
+\def\xmlstrippednolines #1#2{\ctxlxml{stripped("#1","#2",true)}}
+\def\xmltag #1{\ctxlxml{tag("#1")}}
+\def\xmltext #1#2{\ctxlxml{text("#1","#2")}}
+\def\xmlverbatim #1{\ctxlxml{verbatim("#1")}}
+\def\xmldisplayverbatim #1{\ctxlxml{displayverbatim("#1")}}
+\def\xmlinlineverbatim #1{\ctxlxml{inlineverbatim("#1")}}
+
+\def\xmlload #1#2{\ctxlxml{load("#1","#2","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
+\def\xmlloadbuffer #1#2{\ctxlxml{loadbuffer("#1","#2","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
+\def\xmlloaddata #1#2{\ctxlxml{loaddata("#1",\!!bs#2\!!es,"\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
+\def\xmlloadregistered #1#2{\ctxlxml{loadregistered("#1","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
+\def\xmlloaddirectives #1{\ctxlxml{directives.load("any:///#1")}}
+\def\xmlpos #1{\ctxlxml{pos("#1")}}
+
+\def\xmltoparameters #1{\ctxlxml{toparameters("#1")}}
+
+\def\xmltofile #1#2#3{\ctxlxml{tofile("#1","#2","#3")}} % id pattern filename
% kind of special:
@@ -106,12 +107,12 @@
% todo: \xmldoifelseattribute
-\def\xmldoif #1#2{\ctxlxml{doif (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
-\def\xmldoifnot #1#2{\ctxlxml{doifnot (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
-\def\xmldoifelse #1#2{\ctxlxml{doifelse (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
-\def\xmldoiftext #1#2{\ctxlxml{doiftext (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
-\def\xmldoifnottext #1#2{\ctxlxml{doifnottext (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
-\def\xmldoifelsetext #1#2{\ctxlxml{doifelsetext(\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
+\def\xmldoif #1#2{\ctxlxml{doif (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
+\def\xmldoifnot #1#2{\ctxlxml{doifnot (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
+\def\xmldoifelse #1#2{\ctxlxml{doifelse (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
+\def\xmldoiftext #1#2{\ctxlxml{doiftext (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
+\def\xmldoifnottext #1#2{\ctxlxml{doifnottext (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
+\def\xmldoifelsetext #1#2{\ctxlxml{doifelsetext(\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable
%def\xmldoifelseempty #1#2{\ctxlxml{doifelseempty("#1","#2")}} % #2, "*" or "" == self not yet implemented
%def\xmldoifelseselfempty #1{\ctxlxml{doifelseempty("#1")}}
diff --git a/Master/texmf-dist/tex/context/base/lxml-tex.lua b/Master/texmf-dist/tex/context/base/lxml-tex.lua
index 0503c511c45..0c58a47cc9f 100644
--- a/Master/texmf-dist/tex/context/base/lxml-tex.lua
+++ b/Master/texmf-dist/tex/context/base/lxml-tex.lua
@@ -38,9 +38,11 @@ local xmlapplylpath = xml.applylpath
local xmlunprivatized, xmlprivatetoken, xmlprivatecodes = xml.unprivatized, xml.privatetoken, xml.privatecodes
local xmlstripelement = xml.stripelement
-local variables = (interfaces and interfaces.variables) or { }
+local variables = interfaces and interfaces.variables or { }
-local insertbeforevalue, insertaftervalue = utilities.tables.insertbeforevalue, utilities.tables.insertaftervalue
+local settings_to_hash = utilities.parsers.settings_to_hash
+local insertbeforevalue = utilities.tables.insertbeforevalue
+local insertaftervalue = utilities.tables.insertaftervalue
local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
@@ -352,7 +354,7 @@ end
function lxml.checkindex(name)
local root = getid(name)
- return (root and root.index) or 0
+ return root and root.index or 0
end
function lxml.withindex(name,n,command) -- will change as name is always there now
@@ -434,16 +436,74 @@ function lxml.register(id,xmltable,filename)
return xmltable
end
-function lxml.include(id,pattern,attribute,recurse)
+-- function lxml.include(id,pattern,attribute,recurse,resolve)
+-- starttiming(xml)
+-- local root = getid(id)
+-- xml.include(root,pattern,attribute,recurse,function(filename)
+-- if filename then
+-- -- preprocessing
+-- filename = commands.preparedfile(filename)
+-- -- some protection
+-- if file.dirname(filename) == "" and root.filename then
+-- local dn = file.dirname(root.filename)
+-- if dn ~= "" then
+-- filename = file.join(dn,filename)
+-- end
+-- end
+-- if trace_loading then
+-- report_lxml("including file %a",filename)
+-- end
+-- -- handy if we have a flattened structure
+-- if resolve then
+-- filename = resolvers.resolve(filename) or filename
+-- end
+-- -- todo: check variants and provide
+-- noffiles, nofconverted = noffiles + 1, nofconverted + 1
+-- return resolvers.loadtexfile(filename) or ""
+-- else
+-- return ""
+-- end
+-- end)
+-- stoptiming(xml)
+-- end
+
+-- recurse prepare rootpath resolve basename
+
+local options_true = { "recurse", "prepare", "rootpath" }
+local options_nil = { "prepare", "rootpath" }
+
+function lxml.include(id,pattern,attribute,options)
starttiming(xml)
local root = getid(id)
- xml.include(root,pattern,attribute,recurse,function(filename)
+ if options == true then
+ -- downward compatible
+ options = options_true
+ elseif not options then
+ -- downward compatible
+ options = options_nil
+ else
+ options = settings_to_hash(options) or { }
+ end
+ xml.include(root,pattern,attribute,options.recurse,function(filename)
if filename then
- filename = commands.preparedfile(filename)
- if file.dirname(filename) == "" and root.filename then
- local dn = file.dirname(root.filename)
- if dn ~= "" then
- filename = file.join(dn,filename)
+ -- preprocessing
+ if options.prepare then
+ filename = commands.preparedfile(filename)
+ end
+ -- handy if we have a flattened structure
+ if options.basename then
+ filename = file.basename(filename)
+ end
+ if options.resolve then
+ filename = resolvers.resolve(filename) or filename
+ end
+ -- some protection
+ if options.rootpath then
+ if file.dirname(filename) == "" and root.filename then
+ local dn = file.dirname(root.filename)
+ if dn ~= "" then
+ filename = file.join(dn,filename)
+ end
end
end
if trace_loading then
@@ -1125,7 +1185,9 @@ local function command(collected,cmd,otherwise)
lxml.addindex(name,false,true)
ix = e.ix
end
- if wildcard then
+ if not ix then
+ report_lxml("no valid node index for element %a in command %s",name,cmd)
+ elseif wildcard then
contextsprint(ctxcatcodes,"\\xmlw{",(gsub(cmd,"%*",e.tg)),"}{",name,"::",ix,"}")
else
contextsprint(ctxcatcodes,"\\xmlw{",cmd,"}{",name,"::",ix,"}")
diff --git a/Master/texmf-dist/tex/context/base/m-pipemode.mkiv b/Master/texmf-dist/tex/context/base/m-pipemode.mkiv
new file mode 100644
index 00000000000..e96394c431e
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/m-pipemode.mkiv
@@ -0,0 +1,7 @@
+% For Mojca: context --global m-pipemode.mkiv
+
+\disabledirectives[system.errorcontext]
+
+\starttext
+
+\let\stoptext\relax
diff --git a/Master/texmf-dist/tex/context/base/math-frc.mkiv b/Master/texmf-dist/tex/context/base/math-frc.mkiv
index f4f3f2b84a1..7032c665b08 100644
--- a/Master/texmf-dist/tex/context/base/math-frc.mkiv
+++ b/Master/texmf-dist/tex/context/base/math-frc.mkiv
@@ -106,12 +106,57 @@
\c!rulethickness=.25\exheight,
\c!left=0x2E,
\c!right=0x2E,
+ \c!topdistance=,
+ \c!bottomdistance=,
\c!rule=\v!auto]
\appendtoks
\setuevalue{\currentmathfraction}{\math_frac{\currentmathfraction}}%
\to \everydefinemathfraction
+% Sometimes users want control over the distances:
+
+\let\math_fraction_set_distance\relax
+
+\appendtoks
+ \math_fraction_set_distance
+\to \everymathematics
+
+\unexpanded\def\math_fraction_set_distance_top
+ {\Umathfractionnumup \displaystyle\m_math_fraction_distance_top
+ \relax}
+
+\unexpanded\def\math_fraction_set_distance_bot
+ {\Umathfractiondenomdown\displaystyle\m_math_fraction_distance_bot
+ \relax}
+
+\unexpanded\def\math_fraction_set_distance_all
+ {\Umathfractionnumup \displaystyle\m_math_fraction_distance_top
+ \Umathfractiondenomdown\displaystyle\m_math_fraction_distance_bot
+ \relax}
+
+\appendtoks
+ \ifx\currentmathfraction\empty
+ \edef\m_math_fraction_distance_top{\mathfractionparameter\c!topdistance}%
+ \edef\m_math_fraction_distance_bot{\mathfractionparameter\c!bottomdistance}%
+ \ifx\m_math_fraction_distance_top\empty
+ \ifx\m_math_fraction_distance_bot\empty
+ \let\math_fraction_set_distance\relax
+ \else
+ \let\math_fraction_set_distance\math_fraction_set_distance_bot
+ \fi
+ \else
+ \ifx\m_math_fraction_distance_bot\empty
+ \let\math_fraction_set_distance\math_fraction_set_distance_top
+ \else
+ \let\math_fraction_set_distance\math_fraction_set_distance_all
+ \fi
+ \fi
+ \fi
+\to \everysetupmathfraction
+
+% So far for control.
+
\newdimen\d_math_fraction_margin
\unexpanded\def\math_frac#1%
diff --git a/Master/texmf-dist/tex/context/base/math-ini.mkiv b/Master/texmf-dist/tex/context/base/math-ini.mkiv
index dcd2a5c3343..adf252d9526 100644
--- a/Master/texmf-dist/tex/context/base/math-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/math-ini.mkiv
@@ -230,6 +230,12 @@
\ifdefined\mr \else \let\mr\relax \fi
\ifdefined\mb \else \let\mb\relax \fi
+% 1: $\setmathattribute{ss}{bf}3$
+% 2: $\setmathattribute{ss}{bf}\setmathfontstylealterternate{bf}3$
+% 3: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}3$
+% 4: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}\setmathfontstylealterternate{bf}3$
+% 5: $e=mc^2 \quad \mb e=mc^2$
+
\prependtoks
\mathdefault
\to \everymathematics
diff --git a/Master/texmf-dist/tex/context/base/math-map.lua b/Master/texmf-dist/tex/context/base/math-map.lua
index 2ebcdfc8696..f2a588fc7de 100644
--- a/Master/texmf-dist/tex/context/base/math-map.lua
+++ b/Master/texmf-dist/tex/context/base/math-map.lua
@@ -44,8 +44,8 @@ local registerotffeature = otffeatures.register
local setmetatableindex = table.setmetatableindex
-local texgetattribute = tex.getattribute
-local texsetattribute = tex.setattribute
+local texgetattribute = tex.getattribute
+local texsetattribute = tex.setattribute
local trace_greek = false trackers.register("math.greek", function(v) trace_greek = v end)
local report_remapping = logs.reporter("mathematics","remapping")
@@ -59,7 +59,52 @@ local mathematics = mathematics
-- diagnostics and quick and dirty alphabet tracing (s-mat-10.mkiv) as we deal with
-- it otherwise.
-mathematics.gaps = {
+-- todo: allocate
+
+mathematics.styles = allocate { "regular", "sansserif", "monospaced", "fraktur", "script", "blackboard" }
+mathematics.alternatives = allocate { "normal", "bold", "italic", "bolditalic" }
+mathematics.sets = allocate { "ucletters", "lcletters", "digits", "ucgreek", "lcgreek", "symbols" }
+
+mathematics.charactersets = allocate {
+ ucletters = {
+ 0x00041, 0x00042, 0x00043, 0x00044, 0x00045,
+ 0x00046, 0x00047, 0x00048, 0x00049, 0x0004A,
+ 0x0004B, 0x0004C, 0x0004D, 0x0004E, 0x0004F,
+ 0x00050, 0x00051, 0x00052, 0x00053, 0x00054,
+ 0x00055, 0x00056, 0x00057, 0x00058, 0x00059,
+ 0x0005A,
+ },
+ lcletters = {
+ 0x00061, 0x00062, 0x00063, 0x00064, 0x00065,
+ 0x00066, 0x00067, 0x00068, 0x00069, 0x0006A,
+ 0x0006B, 0x0006C, 0x0006D, 0x0006E, 0x0006F,
+ 0x00070, 0x00071, 0x00072, 0x00073, 0x00074,
+ 0x00075, 0x00076, 0x00077, 0x00078, 0x00079,
+ 0x0007A,
+ },
+ digits = {
+ 0x00030, 0x00031, 0x00032, 0x00033, 0x00034,
+ 0x00035, 0x00036, 0x00037, 0x00038, 0x00039,
+ },
+ ucgreek = {
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395,
+ 0x0396, 0x0397, 0x0398, 0x0399, 0x039A,
+ 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5,
+ 0x03A6, 0x03A7, 0x03A8, 0x03A9
+ },
+ lcgreek = {
+ 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5,
+ 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA,
+ 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4,
+ 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9,
+ 0x03D1, 0x03D5, 0x03D6, 0x03F0, 0x03F1,
+ 0x03F4, 0x03F5
+ },
+}
+
+mathematics.gaps = allocate {
[0x1D455] = 0x0210E, -- ℎ h
[0x1D49D] = 0x0212C, -- ℬ script B
[0x1D4A0] = 0x02130, -- ℰ script E
@@ -112,9 +157,10 @@ registerotffeature {
-- following approach permits easier remapping of a-a, A-Z and 0-9 to
-- fallbacks; symbols is currently mostly greek
-local function todigit(n) local t = { } for i=0, 9 do t[0x00030+i] = n+i end return t end
-local function toupper(n) local t = { } for i=0,25 do t[0x00041+i] = n+i end return t end
-local function tolower(n) local t = { } for i=0,25 do t[0x00061+i] = n+i end return t end
+local function todigit (n) local t = { } for i=0, 9 do t[0x00030+i] = n+i end return t end
+local function toupper (n) local t = { } for i=0,25 do t[0x00041+i] = n+i end return t end
+local function tolower (n) local t = { } for i=0,25 do t[0x00061+i] = n+i end return t end
+local function tovector(t) return t end
local regular_tf = {
digits = todigit(0x00030),
@@ -143,7 +189,7 @@ local regular_tf = {
}
local regular_it = {
- digits = regular_tf.digits,
+ digits = tovector(regular_tf.digits),
ucletters = toupper(0x1D434),
lcletters = { -- H
[0x00061]=0x1D44E, [0x00062]=0x1D44F, [0x00063]=0x1D450, [0x00064]=0x1D451, [0x00065]=0x1D452,
@@ -202,7 +248,7 @@ local regular_bf= {
}
local regular_bi = {
- digits = regular_bf.digits,
+ digits = tovector(regular_bf.digits),
ucletters = toupper(0x1D468),
lcletters = tolower(0x1D482),
ucgreek = {
@@ -238,18 +284,18 @@ local sansserif_tf = {
digits = todigit(0x1D7E2),
ucletters = toupper(0x1D5A0),
lcletters = tolower(0x1D5BA),
- lcgreek = regular_tf.lcgreek,
- ucgreek = regular_tf.ucgreek,
- symbols = regular_tf.symbols,
+ lcgreek = tovector(regular_tf.lcgreek),
+ ucgreek = tovector(regular_tf.ucgreek),
+ symbols = tovector(regular_tf.symbols),
}
local sansserif_it = {
- digits = regular_tf.digits,
+ digits = tovector(regular_tf.digits),
ucletters = toupper(0x1D608),
lcletters = tolower(0x1D622),
- lcgreek = regular_tf.lcgreek,
- ucgreek = regular_tf.ucgreek,
- symbols = regular_tf.symbols,
+ lcgreek = tovector(regular_tf.lcgreek),
+ ucgreek = tovector(regular_tf.ucgreek),
+ symbols = tovector(regular_tf.symbols),
}
local sansserif_bf = {
@@ -279,7 +325,7 @@ local sansserif_bf = {
}
local sansserif_bi = {
- digits = sansserif_bf.digits,
+ digits = tovector(sansserif_bf.digits),
ucletters = toupper(0x1D63C),
lcletters = tolower(0x1D656),
ucgreek = {
@@ -315,16 +361,20 @@ local monospaced_tf = {
digits = todigit(0x1D7F6),
ucletters = toupper(0x1D670),
lcletters = tolower(0x1D68A),
- lcgreek = sansserif_tf.lcgreek,
- ucgreek = sansserif_tf.ucgreek,
- symbols = sansserif_tf.symbols,
+ lcgreek = tovector(sansserif_tf.lcgreek),
+ ucgreek = tovector(sansserif_tf.ucgreek),
+ symbols = tovector(sansserif_tf.symbols),
}
+local monospaced_it = tovector(sansserif_it)
+local monospaced_bf = tovector(sansserif_bf)
+local monospaced_bi = tovector(sansserif_bi)
+
local monospaced = {
tf = monospaced_tf,
- it = sansserif_tf,
- bf = sansserif_tf,
- bi = sansserif_bf,
+ it = monospaced_tf,
+ bf = monospaced_tf,
+ bi = monospaced_bf,
}
local blackboard_tf = {
@@ -362,7 +412,7 @@ local blackboard = {
}
local fraktur_tf= {
- digits = regular_tf.digits,
+ digits = tovector(regular_tf.digits),
ucletters = { -- C H I R Z
[0x00041]=0x1D504, [0x00042]=0x1D505, [0x00043]=0x0212D, [0x00044]=0x1D507, [0x00045]=0x1D508,
[0x00046]=0x1D509, [0x00047]=0x1D50A, [0x00048]=0x0210C, [0x00049]=0x02111, [0x0004A]=0x1D50D,
@@ -372,18 +422,18 @@ local fraktur_tf= {
[0x0005A]=0x02128,
},
lcletters = tolower(0x1D51E),
- lcgreek = regular_tf.lcgreek,
- ucgreek = regular_tf.ucgreek,
- symbols = regular_tf.symbols,
+ lcgreek = tovector(regular_tf.lcgreek),
+ ucgreek = tovector(regular_tf.ucgreek),
+ symbols = tovector(regular_tf.symbols),
}
local fraktur_bf = {
- digits = regular_bf.digits,
+ digits = tovector(regular_bf.digits),
ucletters = toupper(0x1D56C),
lcletters = tolower(0x1D586),
- lcgreek = regular_bf.lcgreek,
- ucgreek = regular_bf.ucgreek,
- symbols = regular_bf.symbols,
+ lcgreek = tovector(regular_bf.lcgreek),
+ ucgreek = tovector(regular_bf.ucgreek),
+ symbols = tovector(regular_bf.symbols),
}
local fraktur = { -- ok
@@ -394,7 +444,7 @@ local fraktur = { -- ok
}
local script_tf = {
- digits = regular_tf.digits,
+ digits = tovector(regular_tf.digits),
ucletters = { -- B E F H I L M R -- P 2118
[0x00041]=0x1D49C, [0x00042]=0x0212C, [0x00043]=0x1D49E, [0x00044]=0x1D49F, [0x00045]=0x02130,
[0x00046]=0x02131, [0x00047]=0x1D4A2, [0x00048]=0x0210B, [0x00049]=0x02110, [0x0004A]=0x1D4A5,
@@ -411,18 +461,18 @@ local script_tf = {
[0x00075]=0x1D4CA, [0x00076]=0x1D4CB, [0x00077]=0x1D4CC, [0x00078]=0x1D4CD, [0x00079]=0x1D4CE,
[0x0007A]=0x1D4CF,
},
- lcgreek = regular_tf.lcgreek,
- ucgreek = regular_tf.ucgreek,
- symbols = regular_tf.symbols,
+ lcgreek = tovector(regular_tf.lcgreek),
+ ucgreek = tovector(regular_tf.ucgreek),
+ symbols = tovector(regular_tf.symbols),
}
local script_bf = {
- digits = regular_bf.digits,
+ digits = tovector(regular_bf.digits),
ucletters = toupper(0x1D4D0),
lcletters = tolower(0x1D4EA),
- lcgreek = regular_bf.lcgreek,
- ucgreek = regular_bf.ucgreek,
- symbols = regular_bf.symbols,
+ lcgreek = tovector(regular_bf.lcgreek),
+ ucgreek = tovector(regular_bf.ucgreek),
+ symbols = tovector(regular_bf.symbols),
}
local script = {
@@ -441,82 +491,83 @@ local alphabets = allocate {
script = script,
}
-mathematics.alphabets = alphabets
+alphabets.tt = tovector(monospaced)
+alphabets.ss = tovector(sansserif)
+alphabets.rm = tovector(regular)
+alphabets.bb = tovector(blackboard)
+alphabets.fr = tovector(fraktur)
+alphabets.sr = tovector(script)
-local boldmap = { }
-
--- ["blackboard"] = { ["bf"] = { ["digits"] = {
-
-local function remap(tf,bf)
- for _, alphabet in next, alphabets do
- local tfdata = alphabet[tf]
- local bfdata = alphabet[bf]
- if tfdata then
- for k, tfd in next, tfdata do
- if type(tfd) == "table" then
- local bfd = bfdata[k]
- if bfd then
- for n, u in next, tfd do
- local bn = bfd[n]
- if bn then
- boldmap[u] = bn
- end
- end
- end
- end
- end
- end
- end
-end
+monospaced.normal = tovector(monospaced_tf)
+monospaced.italic = tovector(monospaced_it)
+monospaced.bold = tovector(monospaced_bf)
+monospaced.bolditalic = tovector(monospaced_bi)
+
+sansserif.normal = tovector(sansserif_tf)
+sansserif.italic = tovector(sansserif_it)
+sansserif.bold = tovector(sansserif_bf)
+sansserif.bolditalic = tovector(sansserif_bi)
+
+regular.normal = tovector(regular_tf)
+regular.italic = tovector(regular_it)
+regular.bold = tovector(regular_bf)
+regular.bolditalic = tovector(regular_bi)
+
+alphabets.serif = tovector(regular)
+alphabets.type = tovector(monospaced)
+alphabets.teletype = tovector(monospaced)
-remap("tf","bf")
-remap("it","bi")
+mathematics.alphabets = alphabets
+
+local mathremap = allocate { }
+mathematics.mapremap = mathremap
-mathematics.boldmap = boldmap
+local boldmap = allocate { }
+mathematics.boldmap = boldmap
-local mathremap = allocate { }
+-- all math (a bit of redundancy here)
for alphabet, styles in next, alphabets do -- per 9/6/2011 we also have attr for missing
for style, data in next, styles do
-- let's keep the long names (for tracing)
local n = #mathremap + 1
- data.attribute = n
- data.alphabet = alphabet
- data.style = style
- mathremap[n] = data
+ local d = {
+ attribute = n,
+ alphabet = alphabet,
+ style = style,
+ }
+ styles[style] = d
+ setmetatableindex(d,data) -- we could use a alphadata table
+ mathremap[n] = d
end
end
-mathematics.mapremap = mathremap
-
--- beware, these are shared tables (no problem since they're not
--- in unicode)
-
-alphabets.tt = monospaced
-alphabets.ss = sansserif
-alphabets.rm = regular
-alphabets.bb = blackboard
-alphabets.fr = fraktur
-alphabets.sr = script
-
-alphabets.serif = regular
-alphabets.type = monospaced
-alphabets.teletype = monospaced
-
-regular.normal = regular_tf
-regular.italic = regular_it
-regular.bold = regular_bf
-regular.bolditalic = regular_bi
+-- bold math
+
+local function remapbold(tf,bf)
+ local styles = mathematics.styles
+ local sets = mathematics.sets
+ for i=1,#styles do
+ for j=1,#sets do
+ local one = styles[i]
+ local two = sets[j]
+ local a = alphabets[one]
+ local tf = a[tf][two]
+ local bf = a[bf][two]
+ if tf and bf then
+ for k, v in next, tf do
+ boldmap[v] = bf[k]
+ end
+ end
+ end
+ end
+end
-sansserif.normal = sansserif_tf
-sansserif.italic = sansserif_it
-sansserif.bold = sansserif_bf
-sansserif.bolditalic = sansserif_bi
+remapbold("tf","bf")
+remapbold("it","bi")
-monospaced.normal = monospaced_tf
-monospaced.italic = monospaced_it
-monospaced.bold = monospaced_bf
-monospaced.bolditalic = monospaced_bi
+-- table.save("e:/tmp/a.lua",alphabets)
+-- table.save("e:/tmp/b.lua",boldmap)
function mathematics.tostyle(attribute)
local r = mathremap[attribute]
diff --git a/Master/texmf-dist/tex/context/base/math-noa.lua b/Master/texmf-dist/tex/context/base/math-noa.lua
index a7f0fcf55e6..3a0af01cc9e 100644
--- a/Master/texmf-dist/tex/context/base/math-noa.lua
+++ b/Master/texmf-dist/tex/context/base/math-noa.lua
@@ -251,40 +251,6 @@ local familymap = { [0] =
"pseudobold",
}
--- families[math_char] = function(pointer)
--- if getfield(pointer,"fam") == 0 then
--- local a = getattr(pointer,a_mathfamily)
--- if a and a > 0 then
--- setattr(pointer,a_mathfamily,0)
--- if a > 5 then
--- local char = getchar(pointer)
--- local bold = boldmap[char]
--- local newa = a - 3
--- if bold then
--- setattr(pointer,a_exportstatus,char)
--- setfield(pointer,"char",bold)
--- if trace_families then
--- report_families("replacing %C by bold %C, family %s with remap %s becomes %s with remap %s",char,bold,a,familymap[a],newa,familymap[newa])
--- end
--- else
--- if trace_families then
--- report_families("no bold replacement for %C, family %s with remap %s becomes %s with remap %s",char,a,familymap[a],newa,familymap[newa])
--- end
--- end
--- setfield(pointer,"fam",newa)
--- else
--- if trace_families then
--- local char = getchar(pointer)
--- report_families("family of %C becomes %s with remap %s",char,a,familymap[a])
--- end
--- setfield(pointer,"fam",a)
--- end
--- else
--- -- pointer.fam = 0
--- end
--- end
--- end
-
families[math_char] = function(pointer)
if getfield(pointer,"fam") == 0 then
local a = getattr(pointer,a_mathfamily)
diff --git a/Master/texmf-dist/tex/context/base/meta-ini.mkiv b/Master/texmf-dist/tex/context/base/meta-ini.mkiv
index 281143e40b0..555deca2cbf 100644
--- a/Master/texmf-dist/tex/context/base/meta-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/meta-ini.mkiv
@@ -220,6 +220,7 @@
\defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
\defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double]
+\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary]
\defineMPinstance[decimalfun][\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal]
\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
\defineMPinstance[metapost] [\s!format=mpost]
diff --git a/Master/texmf-dist/tex/context/base/mlib-lua.lua b/Master/texmf-dist/tex/context/base/mlib-lua.lua
index 9c7a2e43a42..e3a3ba5d8db 100644
--- a/Master/texmf-dist/tex/context/base/mlib-lua.lua
+++ b/Master/texmf-dist/tex/context/base/mlib-lua.lua
@@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['mlib-pdf'] = {
-- This is very preliminary code!
+-- maybe we need mplib.model, but how with instances
+
local type, tostring, select, loadstring = type, tostring, select, loadstring
local formatters = string.formatters
local find, gsub = string.find, string.gsub
@@ -51,14 +53,25 @@ function mp._f_()
end
end
-local f_pair = formatters["(%s,%s)"]
-local f_triplet = formatters["(%s,%s,%s)"]
-local f_quadruple = formatters["(%s,%s,%s,%s)"]
+local f_numeric = formatters["%.16f"]
+local f_pair = formatters["(%.16f,%.16f)"]
+local f_triplet = formatters["(%.16f,%.16f,%.16f)"]
+local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"]
function mp.print(...)
for i=1,select("#",...) do
- n = n + 1
- buffer[n] = tostring((select(i,...)))
+ local value = select(i,...)
+ if value then
+ n = n + 1
+ local t = type(value)
+ if t == "number" then
+ buffer[n] = f_numeric(value)
+ elseif t == "string" then
+ buffer[n] = value
+ else
+ buffer[n] = tostring(value)
+ end
+ end
end
end
@@ -113,14 +126,23 @@ end
local f_code = formatters["%s return mp._f_()"]
-function metapost.runscript(code)
- local f = loadstring(f_code(code))
- if f then
- return tostring(f())
- else
- return ""
- end
-end
+-- function metapost.runscript(code)
+-- local f = loadstring(f_code(code))
+-- if f then
+-- local result = f()
+-- if result then
+-- local t = type(result)
+-- if t == "number" then
+-- return f_numeric(result)
+-- elseif t == "string" then
+-- return result
+-- else
+-- return tostring(result)
+-- end
+-- end
+-- end
+-- return ""
+-- end
local cache, n = { }, 0 -- todo: when > n then reset cache or make weak
@@ -128,29 +150,34 @@ function metapost.runscript(code)
if trace_enabled and trace_luarun then
report_luarun("code: %s",code)
end
+ local f
if n > 100 then
cache = nil -- forget about caching
- local f = loadstring(f_code(code))
- if f then
- return tostring(f())
- else
- return ""
- end
+ f = loadstring(f_code(code))
else
- local f = cache[code]
- if f then
- return tostring(f())
- else
+ f = cache[code]
+ if not f then
f = loadstring(f_code(code))
if f then
n = n + 1
cache[code] = f
- return tostring(f())
+ end
+ end
+ end
+ if f then
+ local result = f()
+ if result then
+ local t = type(result)
+ if t == "number" then
+ return f_numeric(result)
+ elseif t == "string" then
+ return result
else
- return ""
+ return tostring(result)
end
end
end
+ return ""
end
-- function metapost.initializescriptrunner(mpx)
diff --git a/Master/texmf-dist/tex/context/base/mult-de.mkii b/Master/texmf-dist/tex/context/base/mult-de.mkii
index 0c4dae5b6f0..9e7ecd93071 100644
--- a/Master/texmf-dist/tex/context/base/mult-de.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-de.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{datei}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{ersteseite}
\setinterfaceconstant{focus}{focus}
diff --git a/Master/texmf-dist/tex/context/base/mult-def.lua b/Master/texmf-dist/tex/context/base/mult-def.lua
index fc2b932c249..bd8b361851e 100644
--- a/Master/texmf-dist/tex/context/base/mult-def.lua
+++ b/Master/texmf-dist/tex/context/base/mult-def.lua
@@ -6643,6 +6643,9 @@ return {
["lastpubsep"]={
["en"]="lastpubsep",
},
+ ["finalpubsep"]={
+ ["en"]="finalpubsep",
+ },
["refcommand"]={
["en"]="refcommand",
},
diff --git a/Master/texmf-dist/tex/context/base/mult-def.mkiv b/Master/texmf-dist/tex/context/base/mult-def.mkiv
index 35b2127106d..321f06154a8 100644
--- a/Master/texmf-dist/tex/context/base/mult-def.mkiv
+++ b/Master/texmf-dist/tex/context/base/mult-def.mkiv
@@ -97,6 +97,9 @@
\def\s!double {double}
\def\s!decimal {decimal}
+\def\s!binary {binary}
+
+\def\s!internal {internal}
\def\s!current {current}
diff --git a/Master/texmf-dist/tex/context/base/mult-en.mkii b/Master/texmf-dist/tex/context/base/mult-en.mkii
index 00861c3be98..bf72af384c7 100644
--- a/Master/texmf-dist/tex/context/base/mult-en.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-en.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{file}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{firstpage}
\setinterfaceconstant{focus}{focus}
diff --git a/Master/texmf-dist/tex/context/base/mult-fr.mkii b/Master/texmf-dist/tex/context/base/mult-fr.mkii
index 9afe371c2b8..e1129848fec 100644
--- a/Master/texmf-dist/tex/context/base/mult-fr.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-fr.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{fichier}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{premierepage}
\setinterfaceconstant{focus}{focus}
diff --git a/Master/texmf-dist/tex/context/base/mult-fun.lua b/Master/texmf-dist/tex/context/base/mult-fun.lua
index 0f5bd8ace7d..846a50ddf3d 100644
--- a/Master/texmf-dist/tex/context/base/mult-fun.lua
+++ b/Master/texmf-dist/tex/context/base/mult-fun.lua
@@ -24,6 +24,7 @@ return {
"llcircle", "lrcircle", "urcircle", "ulcircle",
"tcircle", "bcircle", "lcircle", "rcircle",
"lltriangle", "lrtriangle", "urtriangle", "ultriangle",
+ "uptriangle", "downtriangle", "lefttriangle", "righttriangle", "triangle",
"smoothed", "cornered", "superellipsed", "randomized", "squeezed", "enlonged", "shortened",
"punked", "curved", "unspiked", "simplified", "blownup", "stretched",
"enlarged", "leftenlarged", "topenlarged", "rightenlarged", "bottomenlarged",
diff --git a/Master/texmf-dist/tex/context/base/mult-it.mkii b/Master/texmf-dist/tex/context/base/mult-it.mkii
index 802cb840cd3..5646a212e21 100644
--- a/Master/texmf-dist/tex/context/base/mult-it.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-it.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{file}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{primapagina}
\setinterfaceconstant{focus}{focus}
diff --git a/Master/texmf-dist/tex/context/base/mult-low.lua b/Master/texmf-dist/tex/context/base/mult-low.lua
index f41104986f7..dda4e5aadb4 100644
--- a/Master/texmf-dist/tex/context/base/mult-low.lua
+++ b/Master/texmf-dist/tex/context/base/mult-low.lua
@@ -126,6 +126,7 @@ return {
"twoperemspace", "threeperemspace", "fourperemspace", "fiveperemspace", "sixperemspace",
"figurespace", "punctuationspace", "hairspace",
"zerowidthspace", "zerowidthnonjoiner", "zerowidthjoiner", "zwnj", "zwj",
+ "optionalspace",
},
["helpers"] = {
--
@@ -307,6 +308,8 @@ return {
--
"leftorright",
--
+ "offinterlineskip", "oninterlineskip", "nointerlineskip",
+ --
"strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "begstrut", "endstrut", "lineheight",
--
"ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing",
diff --git a/Master/texmf-dist/tex/context/base/mult-mps.lua b/Master/texmf-dist/tex/context/base/mult-mps.lua
index 104b9d42ef0..717536fbf91 100644
--- a/Master/texmf-dist/tex/context/base/mult-mps.lua
+++ b/Master/texmf-dist/tex/context/base/mult-mps.lua
@@ -60,6 +60,8 @@ return {
"expandafter",
"minute", "hour", "outputformat", "outputtemplate", "filenametemplate", "fontmapfile", "fontmapline",
"fontpart", "fontsize", "glyph", "restoreclipcolor", "troffmode",
+ --
+ "runscript",
},
commands = {
"beginfig", "endfig",
diff --git a/Master/texmf-dist/tex/context/base/mult-nl.mkii b/Master/texmf-dist/tex/context/base/mult-nl.mkii
index 015f58ff15c..aa376c39a1e 100644
--- a/Master/texmf-dist/tex/context/base/mult-nl.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-nl.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{file}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{eerstepagina}
\setinterfaceconstant{focus}{focus}
diff --git a/Master/texmf-dist/tex/context/base/mult-pe.mkii b/Master/texmf-dist/tex/context/base/mult-pe.mkii
index 999b16cf5e0..16871bb6260 100644
--- a/Master/texmf-dist/tex/context/base/mult-pe.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-pe.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{پرونده}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{صفحه‌اول}
\setinterfaceconstant{focus}{تمرکز}
diff --git a/Master/texmf-dist/tex/context/base/mult-ro.mkii b/Master/texmf-dist/tex/context/base/mult-ro.mkii
index f577eabda1f..d01822944da 100644
--- a/Master/texmf-dist/tex/context/base/mult-ro.mkii
+++ b/Master/texmf-dist/tex/context/base/mult-ro.mkii
@@ -701,6 +701,7 @@
\setinterfaceconstant{file}{fisier}
\setinterfaceconstant{filtercommand}{filtercommand}
\setinterfaceconstant{finalnamesep}{finalnamesep}
+\setinterfaceconstant{finalpubsep}{finalpubsep}
\setinterfaceconstant{firstnamesep}{firstnamesep}
\setinterfaceconstant{firstpage}{primapagina}
\setinterfaceconstant{focus}{focus}
diff --git a/Master/texmf-dist/tex/context/base/node-acc.lua b/Master/texmf-dist/tex/context/base/node-acc.lua
index 59fa031bf70..e684aeb7b88 100644
--- a/Master/texmf-dist/tex/context/base/node-acc.lua
+++ b/Master/texmf-dist/tex/context/base/node-acc.lua
@@ -31,7 +31,7 @@ local copy_node = nuts.copy
local free_nodelist = nuts.flush_list
local insert_after = nuts.insert_after
-local new_gluespec = nuts.pool.gluespec -- temp hack
+local new_gluespec = nuts.pool.gluespec -- temp hack
local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
@@ -41,7 +41,8 @@ local vlist_code = nodecodes.vlist
local a_characters = attributes.private("characters")
-local threshold = 65536
+local threshold = 65536 -- not used
+local nofreplaced = 0
-- todo: nbsp etc
-- todo: collapse kerns
@@ -83,6 +84,7 @@ local function injectspaces(head)
end
setattr(s,a_characters,0)
setattr(n,a_characters,0)
+ nofreplaced = nofreplaced + 1
end
-- end
elseif id == hlist_code or id == vlist_code then
@@ -113,6 +115,12 @@ nodes.handlers.accessibility = function(head)
return tonode(head), done
end
+statistics.register("inserted spaces in output",function()
+ if nofreplaced > 0 then
+ return nofreplaced
+ end
+end)
+
-- todo:
-- local a_hyphenated = attributes.private('hyphenated')
diff --git a/Master/texmf-dist/tex/context/base/node-typ.lua b/Master/texmf-dist/tex/context/base/node-typ.lua
index 4c33e31991d..f1aacf25a86 100644
--- a/Master/texmf-dist/tex/context/base/node-typ.lua
+++ b/Master/texmf-dist/tex/context/base/node-typ.lua
@@ -46,7 +46,7 @@ local function tonodes(str,fontid,spacing,templateglyph) -- quick and dirty
if spacing then
s, p, m = spacing, 0, 0
else
- s, p, m = fp.space, fp.space_stretch, fp,space_shrink
+ s, p, m = fp.space, fp.space_stretch, fp.space_shrink
end
local spacedone = false
for c in utfvalues(str) do
diff --git a/Master/texmf-dist/tex/context/base/pack-mrl.mkiv b/Master/texmf-dist/tex/context/base/pack-mrl.mkiv
index 3e81a4d6944..c0097cb5fa5 100644
--- a/Master/texmf-dist/tex/context/base/pack-mrl.mkiv
+++ b/Master/texmf-dist/tex/context/base/pack-mrl.mkiv
@@ -614,7 +614,7 @@
\fi
\doifelse{\directtextrulesparameter\c!depthcorrection}\v!on\pack_textrule_correct_depth_yes\pack_textrule_correct_depth_nop
\nointerlineskip
- \dontleavehmode\vbox
+ \noindent\vbox % was \dontleavehmode
{\color[\directtextrulesparameter\c!rulecolor]
{\hrule\s!depth\directtextrulesparameter\c!rulethickness\s!height\zeropoint\s!width\availablehsize}}}
{\pack_textrule_with_text{#1}}%
diff --git a/Master/texmf-dist/tex/context/base/page-lin.mkiv b/Master/texmf-dist/tex/context/base/page-lin.mkiv
deleted file mode 100644
index 0f8b7839810..00000000000
--- a/Master/texmf-dist/tex/context/base/page-lin.mkiv
+++ /dev/null
@@ -1,557 +0,0 @@
-%D \module
-%D [ file=page-lin,
-%D version=2007.11.29,
-%D title=\CONTEXT\ Core Macros,
-%D subtitle=Line Numbering,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-% generic or not ... maybe not bother too much and simplify to mkiv only
-% get rid of \mk* (left over from experimental times)
-%
-% to be redone (was experiment) .. can be hooked into margin code
-
-\writestatus{loading}{ConTeXt Core Macros / Line Numbering}
-
-\unprotect
-
-% todo: save settings
-%
-% low level interface
-%
-% we should use normal counters but then we need to sync settings
-
-% some line
-%
-% \startlocallinenumbering
-% some source code 1\par
-% some source code 2\par
-% some source code 3\par
-% \stoplocallinenumbering
-%
-% some line
-
-\registerctxluafile{page-lin}{1.001}
-
-\definesystemattribute[linenumber] [public]
-\definesystemattribute[linereference][public]
-
-\appendtoksonce
- \attribute\linenumberattribute\attributeunsetvalue
-\to \everyforgetall
-
-\newcount \linenumber % not used
-\newbox \b_page_lines_scratch
-\newcount \c_page_lines_reference
-\newconstant\c_page_lines_nesting
-
-\newconditional\tracelinenumbering
-
-% id nr shift width leftskip dir
-
-\installcorenamespace{linenumberinginstance}
-
-\let\makelinenumber\gobblesevenarguments % used at lua end
-
-\newconditional\page_postprocessors_needed_box
-
-\unexpanded\def\page_postprocessors_linenumbers_page #1{\page_lines_add_numbers_to_box{#1}\plusone \plusone \zerocount}
-\unexpanded\def\page_postprocessors_linenumbers_box #1{\page_lines_add_numbers_to_box{#1}\plusone \plusone \zerocount}
-\unexpanded\def\page_postprocessors_linenumbers_deepbox#1{\page_lines_add_numbers_to_box{#1}\plusone \plusone \plusone }
-\unexpanded\def\page_postprocessors_linenumbers_column #1{\page_lines_add_numbers_to_box{#1}\currentcolumn\nofcolumns\zerocount}
-
-\def\page_lines_parameters_regular
- {continue = "\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi",
- start = \number\linenumberingparameter\c!start,
- step = \number\linenumberingparameter\c!step,
- method = "\linenumberingparameter\c!method",
- tag = "\currentlinenumbering"}
-
-\def\page_lines_parameters_update
- {continue = "\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi"}
-
-\def\page_lines_start_define
- {\setxvalue{\??linenumberinginstance\currentlinenumbering}{\ctxcommand{registerlinenumbering({\page_lines_parameters_regular})}}}
-
-\def\page_lines_start_update
- {\ctxcommand{setuplinenumbering(\csname\??linenumberinginstance\currentlinenumbering\endcsname,{\page_lines_parameters_update})}}
-
-\def\page_lines_setup
- {\ifcsname \??linenumberinginstance\currentlinenumbering\endcsname
- \ctxcommand{setuplinenumbering(\csname\??linenumberinginstance\currentlinenumbering\endcsname,{\page_lines_parameters_regular})}%
- \fi}
-
-% we could make this a bit more efficient by putting the end reference
-% in the same table as the start one but why make things complex ...
-
-\let\dofinishlinereference\dofinishfullreference % at lua end
-
-\unexpanded\def\page_lines_some_reference#1#2#3%
- {\dontleavehmode\begingroup
- \global\advance\c_page_lines_reference\plusone
- \attribute\linereferenceattribute\c_page_lines_reference
- #3%
- % for the moment we use a simple system i.e. no prefixes etc .. todo: store as number
- \normalexpanded{\strc_references_set_named_reference{line}{#2}{conversion=\linenumberingparameter\c!conversion}{\the\c_page_lines_reference}}% kind labels userdata text
- \endgroup}
-
-\def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{}\ignorespaces}
-\def\page_lines_reference_stop #1{\removeunwantedspaces\page_lines_some_reference{#1}{lr:e:#1}{}}
-
-% \def\mklinestartreference#1[#2]{\in{#1}[lr:b:#2]} % not interfaced/ not used
-% \def\mklinestopreference #1[#2]{\in{#1}[lr:e:#2]} % not interfaced/ not used
-
-\newif\ifnumberinglines % will change
-\newif\iftypesettinglines % will change
-
-\installcorenamespace{linenumbering}
-
-\installcommandhandler \??linenumbering {linenumbering} \??linenumbering
-
-\setnewconstant\c_page_lines_mode \plusone % 0=continue, 1=restart
-\setnewconstant\c_page_lines_location \plusone % 0=middle, 1=left, 2=right, 3=inner, 4=outer, 5=text, 6=begin, 7=end
-\setnewconstant\c_page_lines_alignment\plusfive % 0=middle, 1=left, 2=right, 5=auto
-
-\newdimen\d_page_lines_width
-\newdimen\d_page_lines_distance
-
-\newevery \beforeeverylinenumbering \relax
-\newevery \aftereverylinenumbering \relax
-\newevery \everylinenumber \relax
-
-\appendtoks
- \page_lines_setup
-\to \everysetuplinenumbering
-
-\appendtoks
- \page_lines_start_define
-\to \everydefinelinenumbering
-
-\setuplinenumbering
- [\c!conversion=\v!numbers,
- \c!start=1,
- \c!step=1,
- \c!method=\v!first,
- \c!continue=\v!no,
- \c!location=\v!left,
- \c!style=,
- \c!color=,
- \c!width=2\emwidth,
- \c!left=,
- \c!right=,
- \c!command=,
- \c!distance=\zeropoint,
- \c!align=\v!auto]
-
-\definelinenumbering
- []
-
-% no intermediate changes in values, define a class, otherwise each range
-% would need a number
-
-% todo: text
-
-\installcorenamespace{linennumberinglocation}
-\installcorenamespace{linennumberingalternative}
-
-\expandafter\let\csname\??linennumberinglocation\v!middle \endcsname \zerocount
-\expandafter\let\csname\??linennumberinglocation\v!left \endcsname \plusone
-\expandafter\let\csname\??linennumberinglocation\v!margin \endcsname \plusone
-\expandafter\let\csname\??linennumberinglocation\v!inmargin \endcsname \plusone
-\expandafter\let\csname\??linennumberinglocation\v!inleft \endcsname \plusone
-\expandafter\let\csname\??linennumberinglocation\v!right \endcsname \plustwo
-\expandafter\let\csname\??linennumberinglocation\v!inright \endcsname \plustwo
-\expandafter\let\csname\??linennumberinglocation\v!inner \endcsname \plusthree
-\expandafter\let\csname\??linennumberinglocation\v!outer \endcsname \plusfour
-\expandafter\let\csname\??linennumberinglocation\v!text \endcsname \plusfive
-\expandafter\let\csname\??linennumberinglocation\v!begin \endcsname \plussix
-\expandafter\let\csname\??linennumberinglocation\v!end \endcsname \plusseven
-
-\expandafter\let\csname\??linennumberingalternative\v!middle \endcsname \zerocount
-\expandafter\let\csname\??linennumberingalternative\v!right \endcsname \plusone
-\expandafter\let\csname\??linennumberingalternative\v!flushleft \endcsname \plusone
-\expandafter\let\csname\??linennumberingalternative\v!left \endcsname \plustwo
-\expandafter\let\csname\??linennumberingalternative\v!flushright\endcsname \plustwo
-\expandafter\let\csname\??linennumberingalternative\v!auto \endcsname \plusfive
-
-% \startlinenumbering[<startvalue>|continue|settings|name]
-% \startlinenumbering[name][<startvalue>|continue|settings]
-
-\unexpanded\def\startlinenumbering
- {\dodoubleempty\page_lines_start}
-
-\def\page_lines_start % we stay downward compatible
- {\begingroup
- \ifsecondargument
- \expandafter\page_lines_start_two
- \else\iffirstargument
- \doubleexpandafter\page_lines_start_one
- \else
- \doubleexpandafter\page_lines_start_zero
- \fi\fi}
-
-\def\page_lines_start_zero[#1][#2]%
- {\edef\m_argument{\linenumberingparameter\c!continue}%
- \ifx\m_argument\v!continue
- \c_page_lines_mode\zerocount
- \else
- \c_page_lines_mode\plusone
- \fi
- \page_lines_start_followup}
-
-\def\page_lines_start_one[#1][#2]% [continue|<number>|settings] % historic
- {\edef\m_argument{#1}%
- \ifx\m_argument\v!continue
- \c_page_lines_mode\zerocount
- \let\currentlinenumbering\empty
- \else
- \c_page_lines_mode\plusone
- \ifx\m_argument\v!empty
- \let\currentlinenumbering\empty
- \else
- \doifassignmentelse{#1}
- {\let\currentlinenumbering\empty
- \setupcurrentlinenumbering[#1]}
- {\doifnumberelse\m_argument
- {\let\currentlinenumbering\empty
- \letlinenumberingparameter\c!start\m_argument}
- {\let\currentlinenumbering\m_argument}}%
- \fi
- \edef\p_continue{\linenumberingparameter\c!continue}%
- \ifx\p_continue\v!yes
- \c_page_lines_mode\zerocount
- \fi
- \fi
- \page_lines_start_followup}
-
-\def\page_lines_start_two[#1][#2]% [tag][continue|<number>|settings]
- {\edef\currentlinenumbering{#1}%
- \edef\m_argument{#2}%
- \ifx\m_argument\v!continue
- \c_page_lines_mode\zerocount
- \else
- \c_page_lines_mode\plusone
- \ifx\m_argument\v!empty \else
- \doifassignmentelse{#2}
- {\setupcurrentlinenumbering[#2]}
- {\doifnumber\m_argument
- {\letlinenumberingparameter\c!start\m_argument}}%
- \fi
- \edef\p_continue{\linenumberingparameter\c!continue}%
- \ifx\p_continue\v!yes
- \c_page_lines_mode\zerocount
- \fi
- \fi
- \page_lines_start_followup}
-
-\def\page_lines_start_followup
- {\numberinglinestrue
- \the\beforeeverylinenumbering
- \globallet\page_postprocessors_page \page_postprocessors_linenumbers_page
- \globallet\page_postprocessors_column\page_postprocessors_linenumbers_column
- \global\settrue\page_postprocessors_needed_box % see core-rul.mkiv
- \ifcase\c_page_lines_mode\relax
- \page_lines_start_update % continue
- \or
- \page_lines_start_define % only when assignment
- \fi
- \attribute\linenumberattribute\getvalue{\??linenumberinginstance\currentlinenumbering}\relax}
-
-\unexpanded\def\stoplinenumbering
- {\attribute\linenumberattribute\attributeunsetvalue
- \the\aftereverylinenumbering
- \endgroup}
-
-% number placement .. will change into (the new) margin code
-
-\def\page_lines_number_inner_indeed{\doifoddpageelse\page_lines_number_left_indeed\page_lines_number_right_indeed}
-\def\page_lines_number_outer_indeed{\doifoddpageelse\page_lines_number_right_indeed\page_lines_number_left_indeed}
-
-\def\page_lines_number_left
- {\ifcase\c_page_lines_location
- \expandafter\page_lines_number_left_indeed
- \or
- \expandafter\page_lines_number_left_indeed
- \or
- \expandafter\page_lines_number_left_indeed
- \or
- \expandafter\page_lines_number_inner_indeed
- \or
- \expandafter\page_lines_number_outer_indeed
- \or
- \expandafter\page_lines_number_text_indeed
- \or
- \expandafter\page_lines_number_begin_indeed
- \or
- \expandafter\page_lines_number_end_indeed
- \fi}
-
-\def\page_lines_number_right
- {\ifcase\c_page_lines_location
- \expandafter\page_lines_number_right_indeed
- \or
- \expandafter\page_lines_number_right_indeed
- \or
- \expandafter\page_lines_number_right_indeed
- \or
- \expandafter\page_lines_number_outer_indeed
- \or
- \expandafter\page_lines_number_inner_indeed
- \or
- \expandafter\page_lines_number_text_indeed
- \or
- \expandafter\page_lines_number_end_indeed
- \or
- \expandafter\page_lines_number_begin_indeed
- \fi}
-
-\newconditional\c_page_lines_fake_number
-\newconstant \b_page_lines_number
-\newconstant \c_page_lines_column
-\newconstant \c_page_lines_last_column
-
-\def\page_lines_add_numbers_to_box#1#2#3#4% box col max nesting
- {\bgroup
- \b_page_lines_number #1\relax
- \c_page_lines_column #2\relax
- \c_page_lines_last_column#3\relax
- \c_page_lines_nesting #4\relax
- \fullrestoreglobalbodyfont
- \let\makelinenumber\page_lines_make_number % used at lua end
- \setbox\b_page_lines_scratch\vbox
- {\forgetall
- \offinterlineskip
- \ctxcommand{linenumbersstageone(\number\b_page_lines_number,\ifcase\c_page_lines_nesting false\else true\fi)}}%
- \ctxcommand{linenumbersstagetwo(\number\b_page_lines_number,\number\b_page_lines_scratch)}% can move to lua code
- \egroup}
-
-\let\page_lines_make_number_indeed\relax
-
-\def\page_lines_make_number#1#2%
- {\edef\currentlinenumbering{#1}%
- \ifcase#2\relax
- \settrue \c_page_lines_fake_number
- \else
- \setfalse\c_page_lines_fake_number
- \fi
- \c_page_lines_location \executeifdefined{\??linennumberinglocation \linenumberingparameter\c!location}\plusone \relax % left
- \c_page_lines_alignment\executeifdefined{\??linennumberingalternative\linenumberingparameter\c!align }\plusfive\relax % auto
- \ifcase\c_page_lines_last_column\relax
- \settrue \c_page_lines_fake_number
- \or
- % one column
- \ifcase\c_page_lines_location
- \settrue \c_page_lines_fake_number
- \let\page_lines_make_number_indeed\page_lines_number_fake_indeed
- \or
- \let\page_lines_make_number_indeed\page_lines_number_left
- \or
- \let\page_lines_make_number_indeed\page_lines_number_right
- \or % inner
- \let\page_lines_make_number_indeed\page_lines_number_inner_indeed
- \or % outer
- \let\page_lines_make_number_indeed\page_lines_number_outer_indeed
- \or % text
- \let\page_lines_make_number_indeed\page_lines_number_text_indeed
- \or
- \let\page_lines_make_number_indeed\page_lines_number_begin_indeed
- \or
- \let\page_lines_make_number_indeed\page_lines_number_end_indeed
- \fi
- \else\ifcase\c_page_lines_column\relax
- \settrue \c_page_lines_fake_number
- \or
- \let\page_lines_make_number_indeed\page_lines_number_left
- \ifcase\c_page_lines_location\or
- \c_page_lines_location\plusone
- \or
- \c_page_lines_location\plustwo
- \else
- \c_page_lines_location\plusone
- \or
- \c_page_lines_location\plusone
- \or
- \c_page_lines_location\plusone
- \or
- \c_page_lines_location\plusone % todo
- \or
- \c_page_lines_location\plusone % todo
- \fi
- \else
- \let\page_lines_make_number_indeed\page_lines_number_right
- \ifcase\c_page_lines_location\or
- \c_page_lines_location\plustwo
- \or
- \c_page_lines_location\plusone
- \or
- \c_page_lines_location\plustwo
- \or
- \c_page_lines_location\plustwo
- \or
- \c_page_lines_location\plustwo % todo
- \or
- \c_page_lines_location\plustwo % todo
- \fi
- \fi\fi
- \page_lines_make_number_indeed{#1}}
-
-\let\page_lines_number_fake_indeed\gobblesixarguments % needs checking
-
-\def\page_lines_number_text_indeed#1#2#3#4#5#6% beware, one needs so compensate for this in the \hsize
- {\hbox{\page_lines_number_construct{#1}{2}{#2}{#5}\hskip#3\scaledpoint}}
-
-\def\page_lines_number_left_indeed#1#2#3#4#5#6%
- {\naturalhbox to \zeropoint
- {\ifcase\istltdir#6\else \hskip-#4\scaledpoint \fi
- \llap{\page_lines_number_construct{#1}{2}{#2}{#5}\kern#3\scaledpoint}}}
-
-\def\page_lines_number_right_indeed#1#2#3#4#5#6%
- {\naturalhbox to \zeropoint
- {\ifcase\istltdir#6\else \hskip-#4\scaledpoint \fi
- \rlap{\hskip\dimexpr#4\scaledpoint+#3\scaledpoint\relax\page_lines_number_construct{#1}{1}{#2}{#5}}}}
-
-\def\page_lines_number_begin_indeed#1#2#3#4#5#6%
- {\ifcase\istltdir#6\relax
- \c_page_lines_location\plusone
- \expandafter\page_lines_number_left_indeed
- \else
- \c_page_lines_location\plustwo
- \expandafter\page_lines_number_left_indeed
- \fi{#1}{#2}{#3}{#4}{#5}{#6}}
-
-\def\page_lines_number_end_indeed#1#2#3#4#5#6%
- {\ifcase\istltdir#6\relax
- \c_page_lines_location\plustwo
- \expandafter\page_lines_number_left_indeed
- \else
- \c_page_lines_location\plusone
- \expandafter\page_lines_number_left_indeed
- \fi{#1}{#2}{#3}{#4}{#5}{#6}}
-
-\def\page_lines_number_construct#1#2#3#4% tag 1=left|2=right linenumber leftskip
- {\begingroup
- \def\currentlinenumbering{#1}%
- \def\linenumber{#3}% unsafe
- \doifelse{\linenumberingparameter\c!width}\v!margin
- {\d_page_lines_width\leftmarginwidth}
- {\d_page_lines_width\linenumberingparameter\c!width}%
- \d_page_lines_distance\linenumberingparameter\c!distance\relax
- \ifcase#2\relax\or\hskip\d_page_lines_distance\fi\relax
- \ifnum\c_page_lines_location=\plusfive
- \scratchdimen\dimexpr#4\scaledpoint-\d_page_lines_distance\relax
- \c_page_lines_location\plusone
- \else
- \scratchdimen\zeropoint
- \fi
- \ifcase\c_page_lines_alignment
- \c_page_lines_location\zerocount % middle
- \or
- \c_page_lines_location\plusone % left
- \or
- \c_page_lines_location\plustwo % right
- \fi
- \ifconditional\tracelinenumbering\ruledhbox\else\hbox\fi to \d_page_lines_width
- {\ifcase\c_page_lines_location
- \hss % middle
- \or
- % left
- \or
- \hss % right
- \or
- \doifoddpageelse\relax\hss % inner
- \or
- \doifoddpageelse\hss\relax % outer
- \fi
- \ifconditional\c_page_lines_fake_number
- % we need to reserve space
- \else
- \uselinenumberingstyleandcolor\c!style\c!color
- \linenumberingparameter\c!command
- {\linenumberingparameter\c!left
- \convertnumber{\linenumberingparameter\c!conversion}{#3}%
- \linenumberingparameter\c!right}%
- \fi
- \ifcase\c_page_lines_location
- \hss % middle
- \or
- \hss % left
- \or
- % right
- \or
- \doifoddpageelse\hss\relax % inner
- \or
- \doifoddpageelse\relax\hss % outer
- \fi}%
- \ifcase#2\relax
- \hskip-\scratchdimen
- \or
- \hskip-\scratchdimen
- \or
- \hskip\dimexpr\d_page_lines_distance-\scratchdimen\relax
- \fi
- \relax
- \the\everylinenumber
- \endgroup}
-
-% referencing
-
-\unexpanded\def\someline [#1]{\page_lines_reference_start{#1}\page_lines_reference_stop{#1}} % was just a def
-\unexpanded\def\startline[#1]{\page_lines_reference_start{#1}}
-\unexpanded\def\stopline [#1]{\page_lines_reference_stop {#1}}
-
-\def\page_lines_reference_show_start#1%
- {\ifconditional\tracelinenumbering
- \setbox\scratchbox\hbox{\llap
- {\vrule\s!width\onepoint\s!depth\strutdp\s!height.8\strutht\raise.85\strutht\hbox{\llap{\tt\txx#1}}}}%
- \smashbox\scratchbox
- \box\scratchbox
- \fi}
-
-\def\page_lines_reference_show_stop#1%
- {\ifconditional\tracelinenumbering
- \setbox\scratchbox\hbox{\rlap
- {\raise.85\strutht\hbox{\rlap{\tt\txx#1}}\vrule\s!width\onepoint\s!depth\strutdp\s!height.8\strutht}}%
- \smashbox\scratchbox
- \box\scratchbox
- \fi}
-
-\def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{\page_lines_reference_show_start{#1}}\ignorespaces}
-\def\page_lines_reference_stop #1{\removeunwantedspaces\page_lines_some_reference{#1}{lr:e:#1}{\page_lines_reference_show_stop{#1}}}
-
-% eventually we will do this in lua
-
-\def\currentreferencelinenumber{\ctxcommand{filterreference("linenumber")}}
-
-\let\m_page_lines_from\empty
-\let\m_page_lines_to \empty
-
-\unexpanded\def\doifelsesamelinereference#1#2#3%
- {\doifreferencefoundelse{lr:b:#1}
- {\edef\m_page_lines_from{\currentreferencelinenumber}%
- \doifreferencefoundelse{lr:e:#1}
- {\edef\m_page_lines_to{\currentreferencelinenumber}%
- %[\m_page_lines_from,\m_page_lines_to]
- \ifx\m_page_lines_from\m_page_lines_to#2\else#3\fi}
- {#2}}
- {#2}}
-
-\unexpanded\def\inline#1[#2]%
- {\doifelsenothing{#1}
- {\doifelsesamelinereference{#2}
- {\in{\leftlabeltext\v!line}{\rightlabeltext\v!line}[lr:b:#2]}
- {\in{\leftlabeltext\v!lines}{}[lr:b:#2]--\in{}{\rightlabeltext\v!lines}[lr:e:#2]}}
- {\doifelsesamelinereference{#2}
- {\in{#1}[lr:b:#2]}
- {\in{#1}[lr:b:#2]--\in[lr:e:#2]}}}
-
-\unexpanded\def\inlinerange[#1]%
- {\doifelsesamelinereference{#1}
- {\in[lr:b:#1]}
- {\in[lr:b:#1]\endash\in[lr:e:#1]}}
-
-\protect \endinput
diff --git a/Master/texmf-dist/tex/context/base/page-mix.mkiv b/Master/texmf-dist/tex/context/base/page-mix.mkiv
index 41897f6ddc7..57de14b88b4 100644
--- a/Master/texmf-dist/tex/context/base/page-mix.mkiv
+++ b/Master/texmf-dist/tex/context/base/page-mix.mkiv
@@ -29,6 +29,7 @@
% wide floats
% move floats
% offsets (inner ones, so we change the hsize ... needed with backgrounds
+% when no content we currently loose the page
% luatex buglet:
%
@@ -208,7 +209,7 @@
\fi
\global\setbox\b_page_mix_preceding\vbox
{\page_otr_command_flush_top_insertions
- \ifdim\ht\b_page_mix_preceding=\zeropoint \else
+ \ifdim\htdp\b_page_mix_preceding=\zeropoint \else
\writestatus\m!columns{preceding error}%
\unvbox\b_page_mix_preceding
\fi
diff --git a/Master/texmf-dist/tex/context/base/publ-dat.lua b/Master/texmf-dist/tex/context/base/publ-dat.lua
index b463064ca53..5e255029a48 100644
--- a/Master/texmf-dist/tex/context/base/publ-dat.lua
+++ b/Master/texmf-dist/tex/context/base/publ-dat.lua
@@ -24,8 +24,9 @@ end
local chardata = characters.data
local lowercase = characters.lower
-local lower, gsub, concat = string.lower, string.gsub, table.concat
-local next, type = next, type
+local lower, gsub, find = string.lower, string.gsub, string.find
+local concat = table.concat
+local next, type, rawget = next, type, rawget
local utfchar = utf.char
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
local textoutf = characters and characters.tex.toutf
@@ -73,6 +74,42 @@ local defaultshortcuts = {
dec = "12",
}
+local l_splitter = lpeg.tsplitat("+")
+local d_splitter = lpeg.splitat ("+")
+
+function publications.parenttag(dataset,tag)
+ if find(tag,"%+") then
+ local tags = lpegmatch(l_splitter,tag)
+ local parent = tags[1]
+ local luadata = datasets[dataset].luadata
+ local first = luadata[parent]
+ if first then
+ local combined = first.combined
+ if not combined then
+ combined = { }
+ first.combined = combined
+ end
+ -- add new ones but only once
+ for i=2,#tags do
+ local tag = tags[i]
+ for j=1,#combined do
+ if combined[j] == tag then
+ tag = false
+ end
+ end
+ if tag then
+ local entry = luadata[tag]
+ if entry then
+ combined[#combined+1] = tag
+ end
+ end
+ end
+ return parent
+ end
+ end
+ return tag
+end
+
function publications.new(name)
publicationsstats.nofdatasets = publicationsstats.nofdatasets + 1
local dataset = {
@@ -95,6 +132,9 @@ function publications.new(name)
userdata = false,
},
}
+ -- we delay details till we need it (maybe we just delay the
+ -- individual fields but that is tricky as there can be some
+ -- depedencies)
setmetatableindex(dataset,function(t,k)
-- will become a plugin
if k == "details" and publications.enhance then
@@ -150,7 +190,7 @@ local filter_2 = Cs(
)
-- Currently we expand shortcuts and for large ones (like the acknowledgements
--- in tugboat.bib this is not that efficient. However, eventually strings get
+-- in tugboat.bib) this is not that efficient. However, eventually strings get
-- hashed again.
local function do_shortcut(key,value,dataset)
diff --git a/Master/texmf-dist/tex/context/base/publ-imp-cite.mkiv b/Master/texmf-dist/tex/context/base/publ-imp-cite.mkiv
index d64c2132cee..0f0c69fa70c 100644
--- a/Master/texmf-dist/tex/context/base/publ-imp-cite.mkiv
+++ b/Master/texmf-dist/tex/context/base/publ-imp-cite.mkiv
@@ -11,64 +11,217 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\startsetups btx:cite:author
- \btxcitevariant{author}
-\stopsetups
+\unprotect
-\startsetups btx:cite:authoryear
- \btxcitevariant{authoryear}
-\stopsetups
+% The null case:
-\startsetups btx:cite:authoryears
- \btxcitevariant{authoryears}
+\startsetups \s!btx:\s!cite:none
+ % dummy
\stopsetups
-% \startsetups btx:cite:authornum
-% \btxcitevariant{author}
-% \btxcitevariantparameter\c!inbetween
-% \btxcitevariant{num}
-% \stopsetups
+% This saves keying:
-\startsetups btx:cite:authornum
- \btxcitevariant{authornum}
+\startsetups \s!btx:\s!cite:common:normal
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\v!inbetween
+ \currentbtxsecond
+ \fi
\stopsetups
-\startsetups btx:cite:year
- \btxcitevariant{year}
+\startsetups \s!btx:\s!cite:common:range
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\c!range
+ \currentbtxsecond
+ \fi
\stopsetups
-\startsetups btx:cite:short
- \btxcitevariant{short}
+\startsetups \s!btx:\s!cite:concat
+ \ifcase\currentbtxconcat \or \or
+ \btxcitevariantparameter\c!pubsep
+ \or
+ \btxcitevariantparameter\c!finalpubsep
+ \or
+ \btxcitevariantparameter\c!lastpubsep
+ \fi
\stopsetups
-\startsetups btx:cite:serial
- \btxcitevariant{serial}
+% \startsetups \s!btx:\s!cite:render:normal
+% \directsetup{\s!btx:\s!cite:concat}
+% \ifconditional\btxinteractive
+% \goto {
+% \directsetup{\s!btx:\s!cite:common:normal}
+% } [
+% \s!internal(\currentbtxinternal)
+% ]
+% \else
+% \directsetup{\s!btx:\s!cite:common:normal}
+% \fi
+% \stopsetups
+%
+% more efficient:
+
+\startsetups \s!btx:\s!cite:render:normal
+ \directsetup{\s!btx:\s!cite:concat}
+ \ifconditional\btxinteractive
+ \goto {
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\v!inbetween
+ \currentbtxsecond
+ \fi
+ } [
+ \s!internal(\currentbtxinternal)
+ ]
+ \else
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\v!inbetween
+ \currentbtxsecond
+ \fi
+ \fi
\stopsetups
-\startsetups btx:cite:key
- \currentbtxtag % \btxcitevariant{tag}
+% \startsetups \s!btx:\s!cite:render:range
+% \directsetup{\s!btx:\s!cite:concat}
+% \ifconditional\btxinteractive
+% \goto {
+% \directsetup{\s!btx:\s!cite:common:range}
+% } [
+% \s!internal(\currentbtxinternal)
+% ]
+% \else
+% \directsetup{\s!btx:\s!cite:common:range}
+% \fi
+% \stopsetups
+%
+% more efficient:
+
+\startsetups \s!btx:\s!cite:render:range
+ \directsetup{\s!btx:\s!cite:concat}
+ \ifconditional\btxinteractive
+ \goto {
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\c!range
+ \currentbtxsecond
+ \fi
+ } [
+ \s!internal(\currentbtxinternal)
+ ]
+ \else
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\c!range
+ \currentbtxsecond
+ \fi
+ \fi
\stopsetups
-\startsetups btx:cite:doi
- todo: \btxcitevariant{doi}
+\startsetups \s!btx:\s!cite:render:variant
+ \directsetup{\s!btx:\s!cite:concat}
+ \ifconditional\btxinteractive
+ \goto {
+ \directsetup{\s!btx:\s!cite:render:\currentbtxcitevariant}
+ } [
+ \s!internal(\currentbtxinternal)
+ ]
+ \else
+ \directsetup{\s!btx:\s!cite:render:\currentbtxcitevariant}
+ \fi
\stopsetups
-\startsetups btx:cite:url
- todo: \btxcitevariant{url}
+% author lists: can be less
+
+\startsetups \s!btx:\s!cite:common:author
+ \ifx\currentbtxcitevariant\v!normal
+ \currentbtxfirst
+ \else
+ \currentbtxciteauthor
+ \fi
\stopsetups
-\startsetups btx:cite:type
- \btxcitevariant{category}
+\startsetups \s!btx:\s!cite:render:author
+ \directsetup{\s!btx:\s!cite:common:author}
+\stopsetups
+\startsetups \s!btx:\s!cite:render:authoryear
+ \directsetup{\s!btx:\s!cite:common:author}
+\stopsetups
+\startsetups \s!btx:\s!cite:render:authoryears
+ \directsetup{\s!btx:\s!cite:common:author}
+\stopsetups
+\startsetups \s!btx:\s!cite:render:authornum
+ \directsetup{\s!btx:\s!cite:common:author}
\stopsetups
-\startsetups btx:cite:page
- \btxcitevariant{page}
+\startsetups \s!btx:\s!cite:author:num
+ \directsetup{\s!btx:\s!cite:render:range}
+\stopsetups
+\startsetups \s!btx:\s!cite:author:year
+ \directsetup{\s!btx:\s!cite:render:range}
+\stopsetups
+\startsetups \s!btx:\s!cite:author:years
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
-\startsetups btx:cite:none
- % dummy
+\startsetups \s!btx:\s!cite:author
+ \directsetup{\s!btx:\s!cite:render:variant}
+\stopsetups
+\startsetups \s!btx:\s!cite:authoryear
+ \directsetup{\s!btx:\s!cite:render:variant}
+\stopsetups
+\startsetups \s!btx:\s!cite:authoryears
+ \directsetup{\s!btx:\s!cite:render:variant}
+\stopsetups
+\startsetups \s!btx:\s!cite:authornum
+ \directsetup{\s!btx:\s!cite:render:variant}
\stopsetups
-\startsetups btx:cite:num
- \btxcitevariant{num}
+\startsetups \s!btx:\s!cite:year
+ \directsetup{\s!btx:\s!cite:render:range}
+\stopsetups
+\startsetups \s!btx:\s!cite:short
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:serial
+ \directsetup{\s!btx:\s!cite:render:range}
+\stopsetups
+\startsetups \s!btx:\s!cite:tag
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:key
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
+\startsetups \s!btx:\s!cite:doi
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:url
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:category
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:type
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:num
+ \directsetup{\s!btx:\s!cite:render:range}
+\stopsetups
+\startsetups \s!btx:\s!cite:page
+ \directsetup{\s!btx:\s!cite:render:normal}
+\stopsetups
+
+\protect
diff --git a/Master/texmf-dist/tex/context/base/publ-ini.lua b/Master/texmf-dist/tex/context/base/publ-ini.lua
index e25c57e297d..d713f552cb5 100644
--- a/Master/texmf-dist/tex/context/base/publ-ini.lua
+++ b/Master/texmf-dist/tex/context/base/publ-ini.lua
@@ -6,10 +6,12 @@ if not modules then modules = { } end modules ['publ-ini'] = {
license = "see context related readme files"
}
--- for the moment here
+-- we could store the destinations in the user list entries
+
+-- will move:
local lpegmatch = lpeg.match
-local P, C, Ct, Cs = lpeg.P, lpeg.C, lpeg.Ct, lpeg.Cs
+local P, R, C, Ct, Cs = lpeg.P, lpeg.R, lpeg.C, lpeg.Ct, lpeg.Cs
local lpegmatch = lpeg.match
local pattern = Cs((1 - P(1) * P(-1))^0 * (P(".")/"" + P(1)))
@@ -41,19 +43,26 @@ end
-- use: for rest in gmatch(reference,"[^, ]+") do
-local next, rawget, type = next, rawget, type
+local next, rawget, type, tostring, tonumber = next, rawget, type, tostring, tonumber
local match, gmatch, format, gsub = string.match, string.gmatch, string.format, string.gsub
-local concat, sort = table.concat, table.sort
+local concat, sort, tohash = table.concat, table.sort, table.tohash
local utfsub = utf.sub
local formatters = string.formatters
local allocate = utilities.storage.allocate
local settings_to_array, settings_to_set = utilities.parsers.settings_to_array, utilities.parsers.settings_to_set
local sortedkeys, sortedhash = table.sortedkeys, table.sortedhash
+local setmetatableindex = table.setmetatableindex
local lpegmatch = lpeg.match
local P, C, Ct = lpeg.P, lpeg.C, lpeg.Ct
-local report = logs.reporter("publications")
-local trace = false trackers.register("publications", function(v) trace = v end)
+local report = logs.reporter("publications")
+local report_cite = logs.reporter("publications","cite")
+local report_reference = logs.reporter("publications","reference")
+
+local trace = false trackers.register("publications", function(v) trace = v end)
+local trace_cite = false trackers.register("publications.cite", function(v) trace_cite = v end)
+local trace_missing = false trackers.register("publications.cite.missing", function(v) trace_missing = v end)
+local trace_references = false trackers.register("publications.cite.references", function(v) trace_references = v end)
local datasets = publications.datasets
@@ -70,7 +79,7 @@ local v_left = variables.left
local v_right = variables.right
local v_middle = variables.middle
local v_inbetween = variables.inbetween
-
+local v_yes = variables.yes
local v_short = variables.short
local v_cite = variables.cite
local v_default = variables.default
@@ -91,6 +100,8 @@ local sortcomparer = sorters.comparers.basic -- (a,b)
local sortstripper = sorters.strip
local sortsplitter = sorters.splitters.utf
+local settings_to_array = utilities.parsers.settings_to_array
+
local context = context
local ctx_btxlistparameter = context.btxlistparameter
@@ -105,8 +116,20 @@ local ctx_gobbleoneargument = context.gobbleoneargument
local ctx_btxdirectlink = context.btxdirectlink
local ctx_btxhandlelistentry = context.btxhandlelistentry
local ctx_btxchecklistentry = context.btxchecklistentry
-local ctx_dodirectfullreference = context.dodirectfullreference
+local ctx_btxchecklistcombi = context.btxchecklistcombi
+----- ctx_dodirectfullreference = context.dodirectfullreference
+local ctx_btxsetreference = context.btxsetreference
local ctx_directsetup = context.directsetup
+local ctx_btxmissing = context.btxmissing
+
+local ctx_btxsettag = context.btxsettag
+local ctx_btxcitesetup = context.btxcitesetup
+local ctx_btxsetfirst = context.btxsetfirst
+local ctx_btxsetsecond = context.btxsetsecond
+local ctx_btxsetinternal = context.btxsetinternal
+local ctx_btxsetconcat = context.btxsetconcat
+local ctx_btxstartsubcite = context.btxstartsubcite
+local ctx_btxstopsubcite = context.btxstopsubcite
statistics.register("publications load time", function()
local publicationsstats = publications.statistics
@@ -249,6 +272,197 @@ if not publications.authors then
initializer() -- for now, runtime loaded
end
+local usedentries = { }
+local initialized = false
+
+-- {
+-- ["metadata"]=1,
+-- ["references"]={
+-- ["block"]="bodypart",
+-- ["internal"]=2,
+-- ["realpage"]=1,
+-- ["section"]=0,
+-- },
+-- ["userdata"]={
+-- ["btxref"]="Cleveland1985",
+-- ["btxset"]="standard",
+-- },
+-- },
+
+setmetatableindex(usedentries,function(t,k)
+ if not initialized then
+ usedentries = { }
+ local internals = structures.references.internals
+ for i=1,#internals do
+ local entry = internals[i]
+ local metadata = entry.metadata
+ if metadata.kind == "full" then
+ local userdata = entry.userdata
+ if userdata then
+ local set = userdata.btxset
+ if set then
+ local tag = userdata.btxref
+ local s = usedentries[set]
+ if s then
+ local u = s[tag]
+ if u then
+ u[#u+1] = entry
+ else
+ u = { entry }
+ s[tag] = u
+ end
+ else
+ usedentries[set] = { [tag] = { entry } }
+ end
+ end
+ end
+ end
+ end
+ return usedentries[k]
+ end
+end)
+
+-- local subsets = nil
+-- local block = tex.count.btxblock
+-- local collected = references.collected
+-- local prefix = nil -- todo: dataset ?
+-- if prefix and prefix ~= "" then
+-- subsets = { collected[prefix] or collected[""] }
+-- else
+-- local components = references.productdata.components
+-- local subset = collected[""]
+-- if subset then
+-- subsets = { subset }
+-- else
+-- subsets = { }
+-- end
+-- for i=1,#components do
+-- local subset = collected[components[i]]
+-- if subset then
+-- subsets[#subsets+1] = subset
+-- end
+-- end
+-- end
+-- if #subsets == 0 then
+-- subsets = { collected[""] }
+-- end
+-- local list = type(reference) == "string" and settings_to_array(reference) or reference
+-- local todo = table.tohash(list)
+-- if #subsets > 0 then
+-- local result, nofresult, done = { }, 0, { }
+-- for i=1,#subsets do
+-- local subset = subsets[i]
+-- for i=1,#list do
+-- local rest = list[i]
+-- local blk, tag, found = block, nil, nil
+-- if block then
+-- tag = f_destination(dataset,blk,rest)
+-- found = subset[tag]
+-- if not found then
+-- for i=block-1,1,-1 do
+-- tag = f_destination(dataset,i,rest)
+-- found = subset[tag]
+-- if found then
+-- blk = i
+-- break
+-- end
+-- end
+-- end
+-- end
+-- if not found then
+-- blk = "*"
+-- tag = f_destination(dataset,blk,rest)
+-- found = subset[tag]
+-- end
+-- if found then
+-- local entries = found.entries
+-- if entries then
+-- local current = tonumber(entries.text) -- todo: no ranges when no tonumber
+-- if current and not done[current] then
+-- nofresult = nofresult + 1
+-- result[nofresult] = { blk, rest, current, found.references.internal }
+-- done[current] = true
+-- end
+-- end
+-- end
+-- end
+-- end
+
+local reported = { }
+
+local function findallused(dataset,reference,block,section)
+ local tags = settings_to_array(reference)
+ local todo = { }
+ local okay = { } -- only if mark
+ local set = usedentries[dataset]
+ local valid = datasets[dataset].luadata
+ if set then
+ for i=1,#tags do
+ local tag = tags[i]
+ if valid[tag] then
+ local entry = set[tag]
+ if entry then
+ -- only once in a list
+ if #entry == 1 then
+ entry = entry[1]
+ else
+ -- find best match (todo)
+ entry = entry[1] -- for now
+ end
+ okay[#okay+1] = entry
+ end
+ todo[tag] = true
+ elseif not reported[tag] then
+ reported[tag] = true
+ report_cite("non-existent entry %a in %a",tag,dataset)
+ end
+ end
+ else
+ for i=1,#tags do
+ local tag = tags[i]
+ if valid[tag] then
+ todo[tag] = true
+ elseif not reported[tag] then
+ reported[tag] = true
+ report_cite("non-existent entry %a in %a",tag,dataset)
+ end
+ end
+ end
+ return okay, todo, tags
+end
+
+local function flushcollected(flush,nofcollected)
+ if nofcollected > 0 then
+ flush(1,1)
+ if nofcollected > 2 then
+ for i=2,nofcollected-1 do
+ flush(i,2)
+ end
+ flush(nofcollected,3)
+ elseif nofcollected > 1 then
+ flush(nofcollected,4)
+ end
+ end
+end
+
+local function markcite(dataset,tag)
+ if trace_cite then
+ report_cite("mark, dataset: %s, tag: %s",dataset,tag)
+ end
+ ctx_btxdomarkcitation(dataset,tag)
+end
+
+local function flushmarked(dataset,list,todo)
+ if todo then
+ for i=1,#list do
+ local tag = list[i]
+ if todo[tag] then
+ markcite(dataset,tag)
+ end
+ end
+ end
+end
+
-- basic access
local function getfield(dataset,tag,name)
@@ -344,10 +558,10 @@ function publications.enhance(dataset) -- for the moment split runs (maybe publi
if type(tags) == "table" then
sort(tags)
for i=1,#tags do
--- details[tags[i]].short = short .. numbertochar(i)
-local detail = details[tags[i]]
-detail.short = short
-detail.suffix = numbertochar(i)
+ -- details[tags[i]].short = short .. numbertochar(i)
+ local detail = details[tags[i]]
+ detail.short = short
+ detail.suffix = numbertochar(i)
end
else
details[tags].short = short
@@ -402,9 +616,9 @@ end
-- rendering of fields (maybe multiple manipulators)
-local manipulation = utilities.parsers.manipulation
-local manipulators = utilities.parsers.manipulators
-
+-- local manipulation = utilities.parsers.manipulation
+-- local manipulators = utilities.parsers.manipulators
+--
-- local function checked(field)
-- local m, f = lpegmatch(manipulation,field)
-- if m then
@@ -415,6 +629,7 @@ local manipulators = utilities.parsers.manipulators
-- end
local manipulation = Ct((C((1-P("->"))^1) * P("->"))^1) * C(P(1)^0)
+local manipulators = utilities.parsers.manipulators
local function checked(field)
local m, f = lpegmatch(manipulation,field)
@@ -443,7 +658,6 @@ function commands.btxflush(name,tag,field)
local manipulator, field = checked(field)
local value = fields[field]
if type(value) == "string" then
- -- context(manipulator and manipulator(value) or value)
context(manipulator and manipulated(manipulator,value) or value)
return
end
@@ -451,7 +665,6 @@ function commands.btxflush(name,tag,field)
if details then
local value = details[field]
if type(value) == "string" then
- -- context(manipulator and manipulator(value) or value)
context(manipulator and manipulated(manipulator,value) or value)
return
end
@@ -473,7 +686,6 @@ function commands.btxdetail(name,tag,field)
local manipulator, field = checked(field)
local value = details[field]
if type(value) == "string" then
- -- context(manipulator and manipulator(value) or value)
context(manipulator and manipulated(manipulator,value) or value)
else
report("unknown detail %a of tag %a in dataset %a",field,tag,name)
@@ -494,7 +706,6 @@ function commands.btxfield(name,tag,field)
local manipulator, field = checked(field)
local value = fields[field]
if type(value) == "string" then
- -- context(manipulator and manipulator(value) or value)
context(manipulator and manipulated(manipulator,value) or value)
else
report("unknown field %a of tag %a in dataset %a",field,tag,name)
@@ -550,44 +761,6 @@ end
-- -- alternative approach: keep data at the tex end
-function publications.listconcat(t)
- local n = #t
- if n > 0 then
- context(t[1])
- if n > 1 then
- if n > 2 then
- for i=2,n-1 do
- ctx_btxlistparameter("sep")
- context(t[i])
- end
- ctx_btxlistparameter("finalsep")
- else
- ctx_btxlistparameter("lastsep")
- end
- context(t[n])
- end
- end
-end
-
-function publications.citeconcat(t)
- local n = #t
- if n > 0 then
- context(t[1])
- if n > 1 then
- if n > 2 then
- for i=2,n-1 do
- ctx_btxcitevariantparameter("sep")
- context(t[i])
- end
- ctx_btxcitevariantparameter("finalsep")
- else
- ctx_btxcitevariantparameter("lastsep")
- end
- context(t[n])
- end
- end
-end
-
function publications.singularorplural(singular,plural)
if lastconcatsize and lastconcatsize > 1 then
context(plural)
@@ -596,106 +769,6 @@ function publications.singularorplural(singular,plural)
end
end
--- function commands.makebibauthorlist(settings) -- ?
--- if not settings then
--- return
--- end
--- local dataset = datasets[settings.dataset]
--- if not dataset or dataset == "" then
--- return
--- end
--- local tag = settings.tag
--- if not tag or tag == "" then
--- return
--- end
--- local asked = settings_to_array(tag)
--- if #asked == 0 then
--- return
--- end
--- local compress = settings.compress
--- local interaction = settings.interactionn == v_start
--- local limit = tonumber(settings.limit)
--- local found = { }
--- local hash = { }
--- local total = 0
--- local luadata = dataset.luadata
--- for i=1,#asked do
--- local tag = asked[i]
--- local data = luadata[tag]
--- if data then
--- local author = data.a or "Xxxxxxxxxx"
--- local year = data.y or "0000"
--- if not compress or not hash[author] then
--- local t = {
--- author = author,
--- name = name, -- first
--- year = { [year] = name },
--- }
--- total = total + 1
--- found[total] = t
--- hash[author] = t
--- else
--- hash[author].year[year] = name
--- end
--- end
--- end
--- for i=1,total do
--- local data = found[i]
--- local author = data.author
--- local year = table.keys(data.year)
--- table.sort(year)
--- if interaction then
--- for i=1,#year do
--- year[i] = formatters["\\bibmaybeinteractive{%s}{%s}"](data.year[year[i]],year[i])
--- end
--- end
--- ctx_setvalue("currentbibyear",concat(year,","))
--- if author == "" then
--- ctx_setvalue("currentbibauthor","")
--- else -- needs checking
--- local authors = settings_to_array(author) -- {{}{}},{{}{}}
--- local nofauthors = #authors
--- if nofauthors == 1 then
--- if interaction then
--- author = formatters["\\bibmaybeinteractive{%s}{%s}"](data.name,author)
--- end
--- ctx_setvalue("currentbibauthor",author)
--- else
--- limit = limit or nofauthors
--- if interaction then
--- for i=1,#authors do
--- authors[i] = formatters["\\bibmaybeinteractive{%s}{%s}"](data.name,authors[i])
--- end
--- end
--- if limit == 1 then
--- ctx_setvalue("currentbibauthor",authors[1] .. "\\bibalternative{otherstext}")
--- elseif limit == 2 and nofauthors == 2 then
--- ctx_setvalue("currentbibauthor",concat(authors,"\\bibalternative{andtext}"))
--- else
--- for i=1,limit-1 do
--- authors[i] = authors[i] .. "\\bibalternative{namesep}"
--- end
--- if limit < nofauthors then
--- authors[limit+1] = "\\bibalternative{otherstext}"
--- ctx_setvalue("currentbibauthor",concat(authors,"",1,limit+1))
--- else
--- authors[limit-1] = authors[limit-1] .. "\\bibalternative{andtext}"
--- ctx_setvalue("currentbibauthor",concat(authors))
--- end
--- end
--- end
--- end
--- -- the following use: currentbibauthor and currentbibyear
--- if i == 1 then
--- context.ixfirstcommand()
--- elseif i == total then
--- context.ixlastcommand()
--- else
--- context.ixsecondcommand()
--- end
--- end
--- end
-
local patterns = { "publ-imp-%s.mkiv", "publ-imp-%s.tex" }
local function failure(name)
@@ -731,7 +804,7 @@ local sections = structures.sections
local renderings = { } --- per dataset
-table.setmetatableindex(renderings,function(t,k)
+setmetatableindex(renderings,function(t,k)
local v = {
list = { },
done = { },
@@ -788,8 +861,6 @@ local function validkeyword(dataset,tag,keyword)
end
local kw = dt.keyword
if kw then
--- inspect(keyword)
--- inspect(kw)
for k in next, keyword do
if kw[k] then
return true
@@ -804,12 +875,10 @@ function lists.collectentries(specification)
return
end
local rendering = renderings[dataset]
--- specification.names = "btx"
local method = rendering.method
if method == v_none then
return
end
--- method=v_local --------------------
local result = structures.lists.filter(specification)
--
local keyword = specification.keyword
@@ -948,16 +1017,32 @@ function lists.flushentries(dataset,sortvariant)
list = sort(dataset,rendering,list) or list
end
for i=1,#list do
- ctx_setvalue("currentbtxindex",i)
- ctx_btxhandlelistentry(list[i][1]) -- we can pass i here too ... more efficient to avoid the setvalue
- end
+-- ctx_setvalue("currentbtxindex",i) -- todo: helper
+-- -- todo: also flush combinations
+-- ctx_btxhandlelistentry(list[i][1]) -- we can pass i here too ... more efficient to avoid the setvalue
+ local tag = list[i][1]
+ local entry = datasets[dataset].luadata[tag]
+ if entry then
+ ctx_setvalue("currentbtxindex",i) -- todo: helper
+ local combined = entry.combined
+ if combined then
+ ctx_setvalue("currentbtxcombis",concat(combined,","))
+ else
+ ctx_setvalue("currentbtxcombis","")
+ end
+ ctx_btxhandlelistentry(tag) -- pas i instead
+ end
+ end
end
function lists.fetchentries(dataset)
local list = renderings[dataset].list
for i=1,#list do
- ctx_setvalue("currentbtxindex",i)
- ctx_btxchecklistentry(list[i][1])
+ local tag = list[i][1]
+ local entry = datasets[dataset].luadata[tag]
+ if entry then
+ ctx_btxchecklistentry(tag) -- integrate doifalreadyplaced here
+ end
end
end
@@ -987,158 +1072,38 @@ local function compare(a,b)
return aa and bb and aa < bb
end
--- maybe hash subsets
--- how efficient is this? old leftovers?
-
-- rendering ?
+-- todo: nicer refs
+
local f_reference = formatters["r:%s:%s:%s"] -- dataset, instance (block), tag
local f_destination = formatters["d:%s:%s:%s"] -- dataset, instance (block), tag
-
-function lists.resolve(dataset,reference) -- maybe already feed it split
- -- needs checking (the prefix in relation to components)
- local subsets = nil
- local block = tex.count.btxblock
- local collected = references.collected
- local prefix = nil -- todo: dataset ?
- if prefix and prefix ~= "" then
- subsets = { collected[prefix] or collected[""] }
- else
- local components = references.productdata.components
- local subset = collected[""]
- if subset then
- subsets = { subset }
- else
- subsets = { }
- end
- for i=1,#components do
- local subset = collected[components[i]]
- if subset then
- subsets[#subsets+1] = subset
- end
- end
- end
--- inspect(subsets)
- if #subsets > 0 then
- local result, nofresult, done = { }, 0, { }
- for i=1,#subsets do
- local subset = subsets[i]
- for rest in gmatch(reference,"[^, ]+") do
- local blk, tag, found = block, nil, nil
- if block then
- tag = f_destination(dataset,blk,rest)
- found = subset[tag]
- if not found then
- for i=block-1,1,-1 do
- tag = f_destination(dataset,blk,rest)
--- tag = i .. ":" .. rest
- found = subset[tag]
- if found then
- blk = i
- break
- end
- end
- end
- end
- if not found then
- blk = "*"
- tag = f_destination(dataset,blk,rest)
- found = subset[tag]
- end
- if found then
- local current = tonumber(found.entries and found.entries.text) -- tonumber needed
- if current and not done[current] then
- nofresult = nofresult + 1
- result[nofresult] = { blk, rest, current }
- done[current] = true
- end
- end
- end
- end
- local first, last, firsti, lasti, firstr, lastr
- local collected, nofcollected = { }, 0
- for i=1,nofresult do
- local r = result[i]
- local current = r[3]
- if not first then
- first, last, firsti, lasti, firstr, lastr = current, current, i, i, r, r
- elseif current == last + 1 then
- last, lasti, lastr = current, i, r
- else
- if last > first + 1 then
- nofcollected = nofcollected + 1
- collected[nofcollected] = { firstr, lastr }
- else
- nofcollected = nofcollected + 1
- collected[nofcollected] = firstr
- if last > first then
- nofcollected = nofcollected + 1
- collected[nofcollected] = lastr
- end
- end
- first, last, firsti, lasti, firstr, lastr = current, current, i, i, r, r
- end
- end
- if first and last then
- if last > first + 1 then
- nofcollected = nofcollected + 1
- collected[nofcollected] = { firstr, lastr }
- else
- nofcollected = nofcollected + 1
- collected[nofcollected] = firstr
- if last > first then
- nofcollected = nofcollected + 1
- collected[nofcollected] = lastr
- end
- end
- end
- if nofcollected > 0 then
--- inspect(reference)
--- inspect(result)
--- inspect(collected)
- for i=1,nofcollected do
- local c = collected[i]
- if i == nofcollected then
- ctx_btxlistvariantparameter("lastpubsep")
- elseif i > 1 then
- ctx_btxlistvariantparameter("pubsep")
- end
- if #c == 3 then -- a range (3 is first or last)
- ctx_btxdirectlink(f_reference(dataset,c[1],c[2]),c[3])
- else
- local f, l = c[2], c[2]
- ctx_btxdirectlink(f_reference(dataset,f[1],f[2]),f[3])
- context.endash() -- to do
- ctx_btxdirectlink(f_reference(dataset,l[4],l[5]),l[6])
- end
- end
- else
- context("[btx error 1]")
- end
- else
- context("[btx error 2]")
- end
-end
+local f_listentry = formatters["d:%s:%s:%s"] -- dataset, instance (block), tag
+local f_internal = formatters["internal(%s)"] -- dataset, instance (block), tag
local done = { }
function commands.btxreference(dataset,block,tag,data)
- local ref = f_reference(dataset,block,tag)
+ local ref = f_reference(dataset,block,tag) -- we just need a unique key
if not done[ref] then
+ if trace_references then
+ report_reference("link: %s",ref)
+ end
done[ref] = true
--- context("<%s>",data)
- ctx_dodirectfullreference(ref,data)
+ ctx_btxsetreference(dataset,tag,ref,data)
end
end
local done = { }
function commands.btxdestination(dataset,block,tag,data)
- local ref = f_destination(dataset,block,tag)
+ local ref = f_destination(dataset,block,tag) -- we just need a unique key
if not done[ref] then
+ if trace_references then
+ report_reference("link: %s",ref)
+ end
done[ref] = true
--- context("<<%s>>",data)
- ctx_dodirectfullreference(ref,data)
+ ctx_btxsetreference(dataset,tag,ref,data)
end
end
@@ -1184,11 +1149,48 @@ local function sortedtags(dataset,list,sorttype)
end
end
--- todo: standard : current
+-- if sorttype and sorttype ~= "" then
+-- tags = sortedtags(dataset,tags,sorttype)
+-- end
local prefixsplitter = lpeg.splitat("::")
-function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,setup) -- variant for tracing
+function commands.btxhandlecite(specification)
+ local tag = specification.reference
+ if not tag or tag == "" then
+ return
+ end
+ --
+ local dataset = specification.dataset or ""
+ local mark = specification.markentry ~= false
+ local variant = specification.variant or "num"
+ local sorttype = specification.sorttype
+ local compress = specification.compress == v_yes
+ --
+ local prefix, rest = lpegmatch(prefixsplitter,tag)
+ if rest then
+ dataset = prefix
+ else
+ rest = tag
+ end
+ local action = citevariants[variant] -- there is always fallback on default
+ if trace_cite then
+ report_cite("inject, dataset: %s, tag: %s, variant: %s, compressed",dataset or "-",rest,variant)
+ end
+ ctx_setvalue("currentbtxdataset",dataset)
+ action(dataset,rest,mark,compress,variant)
+end
+
+function commands.btxhandlenocite(specification)
+ local mark = specification.markentry ~= false
+ if not mark then
+ return
+ end
+ local tag = specification.reference
+ if not tag or tag == "" then
+ return
+ end
+ local dataset = specification.dataset or ""
local prefix, rest = lpegmatch(prefixsplitter,tag)
if rest then
dataset = prefix
@@ -1197,190 +1199,551 @@ function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,setup) -- vari
end
ctx_setvalue("currentbtxdataset",dataset)
local tags = settings_to_array(rest)
- if #tags > 0 then
- if sorttype and sorttype ~= "" then
- tags = sortedtags(dataset,tags,sorttype)
+ if trace_cite then
+ report_cite("mark, dataset: %s, tags: % | t",dataset or "-",tags)
+ end
+ for i=1,#tags do
+ markcite(dataset,tags[i])
+ end
+end
+
+-- function commands.btxcitevariant(dataset,block,tags,variant) -- uses? specification ?
+-- local action = citevariants[variant]
+-- if action then
+-- action(dataset,tags,variant)
+-- end
+-- end
+
+-- sorter
+
+local keysorter = function(a,b) return a.sortkey < b.sortkey end
+
+local function compresslist(source)
+ for i=1,#source do
+ if type(source[i].sortkey) ~= "number" then
+ return source
end
- ctx_btxcitevariantparameter(v_left)
- for i=1,#tags do
- local tag = tags[i]
- ctx_setvalue("currentbtxtag",tag)
- if i > 1 then
- ctx_btxcitevariantparameter(v_middle)
- end
- if mark ~= false then
- ctx_btxdomarkcitation(dataset,tag)
+ end
+ local first, last, firstr, lastr
+ local target, noftarget, tags = { }, 0, { }
+ sort(source,keysorter)
+ local function flushrange()
+ noftarget = noftarget + 1
+ if last > first + 1 then
+ target[noftarget] = {
+ first = firstr,
+ last = lastr,
+ tags = tags,
+ }
+ else
+ target[noftarget] = firstr
+ if last > first then
+ noftarget = noftarget + 1
+ target[noftarget] = lastr
end
- ctx_directsetup(setup) -- cite can become alternative
end
- ctx_btxcitevariantparameter(v_right)
- else
- -- error
+ tags = { }
end
+ for i=1,#source do
+ local entry = source[i]
+ local current = entry.sortkey
+ if not first then
+ first, last, firstr, lastr = current, current, entry, entry
+ elseif current == last + 1 then
+ last, lastr = current, entry
+ else
+ flushrange()
+ first, last, firstr, lastr = current, current, entry, entry
+ end
+ tags[#tags+1] = entry.tag
+ end
+ if first and last then
+ flushrange()
+ end
+ return target
end
-function commands.btxhandlenocite(dataset,tag,mark)
- if mark ~= false then
- local prefix, rest = lpegmatch(prefixsplitter,tag)
- if rest then
- dataset = prefix
+-- local source = {
+-- { tag = "one", internal = 1, value = "foo", page = 1 },
+-- { tag = "two", internal = 2, value = "bar", page = 2 },
+-- { tag = "three", internal = 3, value = "gnu", page = 3 },
+-- }
+--
+-- local target = compresslist(source)
+
+local numberonly = R("09")^1 / tonumber + P(1)^0
+local f_missing = formatters["<%s>"]
+
+-- maybe also sparse (e.g. pages)
+
+local function processcite(dataset,reference,mark,compress,setup,getter,setter,compressor)
+ reference = publications.parenttag(dataset,reference)
+ local found, todo, list = findallused(dataset,reference)
+ if found and setup then
+ local source = { }
+ local badkey = false
+ for i=1,#found do
+ local entry = found[i]
+ local tag = entry.userdata.btxref
+ local internal = entry.references.internal
+ local data = getter(dataset,tag,entry,internal)
+ if compress and not compressor then
+ local sortkey = data.sortkey
+ if sortkey then
+ local key = lpegmatch(numberonly,sortkey)
+ if key then
+ data.sortkey = key
+ else
+ badkey = true
+ end
+ else
+ badkey = true
+ end
+ end
+ source[i] = data
+ end
+ if compress and not badkey then
+ local target = (compressor or compresslist)(source)
+ local function flush(i,state)
+ local entry = target[i]
+ local first = entry.first
+ if first then
+ local tags = entry.tags
+ if mark then
+ for i=1,#tags do
+ local tag = tags[i]
+ markcite(dataset,tag)
+ todo[tag] = false
+ end
+ end
+ ctx_btxsettag(tags[1])
+ local internal = first.internal
+ if internal then
+ ctx_btxsetinternal(internal)
+ end
+ if not setter(first,entry.last) then
+ ctx_btxsetfirst(f_missing(first.tag))
+ end
+ else
+ local tag = entry.tag
+ if mark then
+ markcite(dataset,tag)
+ todo[tag] = false
+ end
+ ctx_btxsettag(tag)
+ local internal = entry.internal
+ if internal then
+ ctx_btxsetinternal(internal)
+ end
+ if not setter(entry) then
+ ctx_btxsetfirst(f_missing(entry.tag))
+ end
+ end
+ ctx_btxsetconcat(state)
+ ctx_btxcitesetup(setup)
+ end
+ flushcollected(flush,#target)
else
- rest = tag
+ local function flush(i,state)
+ local entry = source[i]
+ local tag = entry.tag
+ if mark then
+ markcite(dataset,tag)
+ todo[tag] = false
+ end
+ ctx_btxsettag(tag)
+ local internal = entry.internal
+ if internal then
+ ctx_btxsetinternal(internal)
+ end
+ ctx_btxsetconcat(state)
+ if not setter(entry) then
+ ctx_btxsetfirst(f_missing(entry.tag))
+ end
+ ctx_btxcitesetup(setup)
+ end
+ flushcollected(flush,#source)
end
- ctx_setvalue("currentbtxdataset",dataset)
- local tags = settings_to_array(rest)
- for i=1,#tags do
- ctx_btxdomarkcitation(dataset,tags[i])
+ end
+ if mark then
+ flushmarked(dataset,list,todo)
+ end
+end
+
+local function simplegetter(first,last,field)
+ local value = first[field]
+ if value then
+ ctx_btxsetfirst(value)
+ if last then
+ ctx_btxsetsecond(last[field])
end
+ return true
end
end
-function commands.btxcitevariant(dataset,block,tags,variant)
- local action = citevariants[variant] or citevariants.default
- if action then
- action(dataset,tags,variant)
+local setters = setmetatableindex({},function(t,k)
+ local v = function(dataset,tag,entry,internal)
+ local value = getfield(dataset,tag,k)
+ return {
+ tag = tag,
+ internal = internal,
+ [k] = value,
+ sortkey = value,
+ }
+ end
+ t[k] = v
+ return v
+end)
+
+local getters = setmetatableindex({},function(t,k)
+ local v = function(first,last)
+ return simplegetter(first,last,k)
+ end
+ t[k] = v
+ return v
+end)
+
+-- default
+
+setmetatableindex(citevariants,function(t,k)
+ local v = t.default
+ t[k] = v
+ return v
+end)
+
+function citevariants.default(dataset,reference,mark,compress,variant,setup)
+ processcite(dataset,reference,mark,compress,setup or variant,setters[variant],getters[variant])
+end
+
+-- short
+
+local function setter(dataset,tag,entry,internal)
+ return {
+ tag = tag,
+ internal = internal,
+ short = getfield(dataset,tag,"short"),
+ suffix = getfield(dataset,tag,"suffix"),
+ }
+end
+
+local function getter(first,last) -- last not used
+ local short = first.short
+ if short then
+ local suffix = first.suffix
+ if suffix then
+ ctx_btxsetfirst(short .. suffix)
+ else
+ ctx_btxsetfirst(short)
+ end
+ return true
end
end
-function citevariants.default(dataset,tags,variant)
- local content = getfield(dataset,tags,variant)
- if content then
- context(content)
+function citevariants.short(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,false,"short",setter,getter)
+end
+
+-- pages (no compress)
+
+local function setter(dataset,tag,entry,internal)
+ return {
+ tag = tag,
+ internal = internal,
+ pages = getdetail(dataset,tag,"pages"),
+ }
+end
+
+local function getter(first,last)
+ local pages = first.pages
+ if pages then
+ if type(pages) == "table" then
+ ctx_btxsetfirst(pages[1])
+ ctx_btxsetsecond(pages[2])
+ else
+ ctx_btxsetfirst(pages)
+ end
+ return true
end
end
+function citevariants.page(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"page",setter,getter)
+end
+
+-- num
+
+local function setter(dataset,tag,entry,internal)
+ local text = entry.entries.text
+ return {
+ tag = tag,
+ internal = internal,
+ num = text,
+ sortkey = text,
+ }
+end
+
+local function getter(first,last)
+ return simplegetter(first,last,"num")
+end
+
+function citevariants.num(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"num",setter,getter)
+end
+
+-- year
+
+local function setter(dataset,tag,entry,internal)
+ local year = getfield(dataset,tag,"year")
+ return {
+ tag = tag,
+ internal = internal,
+ year = year,
+ sortkey = year,
+ }
+end
+
+local function getter(first,last)
+ return simplegetter(first,last,"year")
+end
+
+function citevariants.year(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"year",setter,getter)
+end
+
+-- index | serial
+
+local function setter(dataset,tag,entry,internal)
+ local index = getfield(dataset,tag,"index")
+ return {
+ tag = tag,
+ internal = internal,
+ index = index,
+ sortkey = index,
+ }
+end
+
+local function getter(first,last)
+ return simplegetter(first,last,"index")
+end
+
+function citevariants.index(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"index",setter,getter)
+end
+
+function citevariants.serial(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"serial",setter,getter)
+end
+
+-- category | type
+
+local function setter(dataset,tag,entry,internal)
+ return {
+ tag = tag,
+ internal = internal,
+ category = getfield(dataset,tag,"category"),
+ }
+end
+
+local function getter(first,last)
+ return simplegetter(first,last,"category")
+end
+
+function citevariants.category(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"category",setter,getter)
+end
+
+function citevariants.type(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"type",setter,getter)
+end
+
+-- key | tag
+
+local function setter(dataset,tag,entry,internal)
+ return {
+ tag = tag,
+ internal = internal,
+ }
+end
+
+local function getter(first,last)
+ ctx_btxsetfirst(first.tag)
+ return true
+end
+
+function citevariants.key(dataset,reference,mark,compress) return
+ processcite(dataset,reference,mark,compress,"key",setter,getter)
+end
+
+function citevariants.tag(dataset,reference,mark,compress) return
+ processcite(dataset,reference,mark,compress,"tag",setter,getter)
+end
+
+-- author
+
+local function setter(dataset,tag,entry,internal)
+ return {
+ tag = tag,
+ internal = internal,
+ author = getfield(dataset,tag,"author"),
+ }
+end
+
+local function getter(first,last)
+ ctx_btxsetfirst(first.author) -- todo: formatted
+ return true
+end
+
+function citevariants.author(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,false,"author",setter,getter)
+end
+
-- todo : sort
-- todo : choose between publications or commands namespace
-- todo : use details.author
-- todo : sort details.author
+-- (name, name and name) .. how names? how sorted?
+-- todo: we loop at the tex end .. why not here
+-- \cite[{hh,afo},kvm]
-local function collectauthoryears(dataset,tags)
- local luadata = datasets[dataset].luadata
- local list = settings_to_array(tags)
- local found = { }
+-- common
+
+local function authorcompressor(found,key)
local result = { }
- local order = { }
- for i=1,#list do
- local tag = list[i]
- local entry = luadata[tag]
- if entry then
- local year = entry.year
- local author = entry.author
- if author and year then
- local a = found[author]
- if not a then
- a = { }
- found[author] = a
- order[#order+1] = author
- end
- local y = a[year]
- if not y then
- y = { }
- a[year] = y
- end
- y[#y+1] = tag
- end
+ local entries = { }
+ for i=1,#found do
+ local entry = found[i]
+ local author = entry.author
+ local aentries = entries[author]
+ -- will be just entry but for tracing ...
+ entry = { internal = entry.internal, author = author, [key] = entry[key], sortkey = entry.sortkey }
+ if aentries then
+ aentries[#aentries+1] = entry
+ else
+ entries[author] = { entry }
end
end
- -- found = { author = { year_1 = { e1, e2, e3 } } }
- for i=1,#order do
- local author = order[i]
- local years = found[author]
- local yrs = { }
- for year, entries in next, years do
- if subyears then
- -- -- add letters to all entries of an author and if so shouldn't
- -- -- we tag all years of an author as soon as we do this?
- -- if #entries > 1 then
- -- for i=1,#years do
- -- local entry = years[i]
- -- -- years[i] = year .. string.char(i + string.byte("0") - 1)
- -- end
- -- end
- else
- yrs[#yrs+1] = year
+ for i=1,#found do
+ local entry = found[i]
+ local author = entry.author
+ local aentries = entries[author]
+ if not aentries then
+ result[#result+1] = entry
+ elseif aentries == true then
+ -- already done
+ else
+ result[#result+1] = entry
+ entry.entries = aentries
+ entries[author] = true
+ end
+ end
+ -- todo: add letters (should we then tag all?)
+ return result
+end
+
+local function authorconcat(target,key,setup)
+ local function flush(i,state)
+ local entry = target[i]
+ local first = entry.first
+ if first then
+ local internal = first.internal
+ if internal then
+ ctx_btxsetinternal(internal)
end
+ ctx_btxsetfirst(first[key] or f_missing(first.tag))
+ ctx_btxsetsecond(entry.last[key])
+ else
+ local internal = entry.internal
+ if internal then
+ ctx_btxsetinternal(internal)
+ end
+ ctx_btxsetfirst(entry[key] or f_missing(entry.tag))
end
- result[i] = { author = author, years = yrs }
+ ctx_btxsetconcat(state)
+ ctx_btxcitesetup(setup)
end
- return result, order
+ ctx_btxstartsubcite(setup)
+ flushcollected(flush,#target)
+ ctx_btxstopsubcite()
end
--- (name, name and name) .. how names? how sorted?
--- todo: we loop at the tex end .. why not here
--- \cite[{hh,afo},kvm]
+local function authorsingle(entry,key,setup)
+ ctx_btxstartsubcite(setup)
+ ctx_btxsetfirst(entry[key] or f_missing(entry.tag))
+ ctx_btxcitesetup(setup)
+ ctx_btxstopsubcite()
+end
--- maybe we will move this tex anyway
+local function authorgetter(first,last,key,setup) -- only first
+ ctx_btxsetfirst(first.author) -- todo: reformat
+ local entries = first.entries
+ if entries then
+ local c = compresslist(entries)
+ ctx_btxsetsecond(function() authorconcat(c,key,setup) end)
+ else
+ ctx_btxsetsecond(function() authorsingle(first,key,setup) end)
+ end
+ return true
+end
-function citevariants.author(dataset,tags)
- local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors
- publications.citeconcat(order)
+-- authornum
+
+local function setter(dataset,tag,entry,internal)
+ local text = entry.entries.text
+ return {
+ tag = tag,
+ internal = internal,
+ author = getfield(dataset,tag,"author"),
+ num = text,
+ sortkey = text and lpegmatch(numberonly,text)
+ }
end
-local function authorandyear(dataset,tags,formatter)
- local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors
- for i=1,#result do
- local r = result[i]
- order[i] = formatter(r.author,r.years) -- reuse order
- end
- publications.citeconcat(order)
+local function getter(first,last)
+ authorgetter(first,last,"num","author:num")
+ return true
end
-function citevariants.authoryear(dataset,tags)
- authorandyear(dataset,tags,formatters["%s (%, t)"])
+local function compressor(found)
+ return authorcompressor(found,"num")
end
-function citevariants.authoryears(dataset,tags)
- authorandyear(dataset,tags,formatters["%s, %, t"])
+function citevariants.authornum(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"authornum",setter,getter,compressor)
end
-function citevariants.authornum(dataset,tags)
- local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors
- publications.citeconcat(order)
- ctx_btxcitevariantparameter(v_inbetween)
- lists.resolve(dataset,tags) -- left/right ?
+-- authoryear | authoryears
+
+local function setter(dataset,tag,entry,internal)
+ local year = getfield(dataset,tag,"year")
+ return {
+ tag = tag,
+ internal = internal,
+ author = getfield(dataset,tag,"author"),
+ year = year,
+ sortkey = year and lpegmatch(numberonly,year)
+ }
end
--- function citevariants.short(dataset,tags)
--- local short = getdetail(dataset,tags,"short")
--- if short then
--- context(short)
--- end
--- end
+local function getter(first,last)
+ authorgetter(first,last,"year","author:year")
+ return true
+end
-function citevariants.short(dataset,tags)
- local short = getdetail(dataset,tags,"short")
- local suffix = getdetail(dataset,tags,"suffix")
- if suffix then
- context(short .. suffix)
- elseif short then
- context(short)
- end
+local function compressor(found)
+ return authorcompressor(found,"year")
end
-function citevariants.page(dataset,tags)
- local pages = getdetail(dataset,tags,"pages")
- if not pages then
- -- nothing
- elseif type(pages) == "table" then
- context(pages[1])
- ctx_btxcitevariantparameter(v_inbetween)
- context(pages[2])
- else
- context(pages)
- end
+function citevariants.authoryear(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"authoryear",setter,getter,compressor)
end
-function citevariants.num(dataset,tags)
--- ctx_btxdirectlink(f_destination(dataset,block,tags),listindex) -- not okay yet
- lists.resolve(dataset,tags)
+local function getter(first,last)
+ authorgetter(first,last,"year","author:years")
+ return true
end
-function citevariants.serial(dataset,tags) -- the traditional fieldname is "serial" and not "index"
- local index = getfield(dataset,tags,"index")
- if index then
- context(index)
- end
+function citevariants.authoryears(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"authoryears",setter,getter,compressor)
end
-- List variants
@@ -1388,41 +1751,30 @@ end
local listvariants = { }
publications.listvariants = listvariants
--- function commands.btxhandlelist(dataset,block,tag,variant,setup)
--- if sorttype and sorttype ~= "" then
--- tags = sortedtags(dataset,tags,sorttype)
--- end
--- ctx_setvalue("currentbtxtag",tag)
--- ctx_btxlistvariantparameter(v_left)
--- ctx_directsetup(setup)
--- ctx_btxlistvariantparameter(v_right)
--- end
-
-function commands.btxlistvariant(dataset,block,tags,variant,listindex)
+function commands.btxlistvariant(dataset,block,tag,variant,listindex)
local action = listvariants[variant] or listvariants.default
if action then
- action(dataset,block,tags,variant,tonumber(listindex) or 0)
+ action(dataset,block,tag,variant,tonumber(listindex) or 0)
end
end
-function listvariants.default(dataset,block,tags,variant)
+function listvariants.default(dataset,block,tag,variant)
context("?")
end
-function listvariants.num(dataset,block,tags,variant,listindex)
- ctx_btxdirectlink(f_destination(dataset,block,tags),listindex) -- not okay yet
+function listvariants.num(dataset,block,tag,variant,listindex)
+ local lst = f_listentry(dataset,block,tag)
+ local ref = f_reference(dataset,block,tag)
+ if trace_references then
+ report_reference("list: %s",lst)
+ end
+ -- todo
+ ctx_btxdirectlink(ref,listindex) -- a goto
end
--- function listvariants.short(dataset,block,tags,variant,listindex)
--- local short = getdetail(dataset,tags,variant,variant)
--- if short then
--- context(short)
--- end
--- end
-
-function listvariants.short(dataset,block,tags,variant,listindex)
- local short = getdetail(dataset,tags,"short","short")
- local suffix = getdetail(dataset,tags,"suffix","suffix")
+function listvariants.short(dataset,block,tag,variant,listindex)
+ local short = getdetail(dataset,tag,"short","short")
+ local suffix = getdetail(dataset,tag,"suffix","suffix")
if suffix then
context(short .. suffix)
elseif short then
diff --git a/Master/texmf-dist/tex/context/base/publ-ini.mkiv b/Master/texmf-dist/tex/context/base/publ-ini.mkiv
index adbf8f7fcf0..68e185f2375 100644
--- a/Master/texmf-dist/tex/context/base/publ-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/publ-ini.mkiv
@@ -15,6 +15,7 @@
% todo: \v!cite => \s!cite
% todo: interface with (ml)bibtex (export -> call -> import)
% todo: check if 'all' etc are ok ... either use list or use other criterium
+% todo: \the\everysetupbtxciteplacement probably too often
% \definecolor[btx:field] [darkred]
% \definecolor[btx:crossref][darkblue]
@@ -44,7 +45,10 @@
\unprotect
-\def\s!btx{btx}
+\startcontextdefinitioncode
+
+\def\s!btx {btx}
+\def\s!cite {cite}
\def\v!btxlist{btxlist}
% a dedicated construction mechanism
@@ -346,12 +350,34 @@
\fi
\to \everydefinebtxrendering
+% \unexpanded\def\btx_entry_inject
+% {\begingroup
+% \edef\currentbtxcategory{\btxfield{category}}%
+% \ignorespaces
+% \directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}%
+% \removeunwantedspaces
+% \endgroup}
+
+\let\currentbtxcombis\empty % goes into the setups
+
\unexpanded\def\btx_entry_inject
{\begingroup
\edef\currentbtxcategory{\btxfield{category}}%
\ignorespaces
\directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}%
\removeunwantedspaces
+ \ifx\currentbtxcombis\empty \else
+ ;\space % todo .. parameter .. what is a good name .. problem: what if ends with .
+ \processcommacommand[\currentbtxcombis]\btx_entry_inject_combi
+ \fi
+ \endgroup}
+
+\def\btx_entry_inject_combi#1%
+ {\begingroup
+ \def\currentbtxtag{#1}%
+ \ignorespaces
+ \directsetup{\s!btx:\currentbtxalternative:\currentbtxcategory}%
+ \removeunwantedspaces
\endgroup}
\unexpanded\def\completebtxrendering{\dodoubleempty\publ_place_list_complete}
@@ -428,7 +454,8 @@
keyword = "\btxrenderingparameter\c!keyword",
}}%
% next we analyze the width
- \ifx\btx_reference_inject_indeed\relax \else
+ \ifx\btx_reference_inject_indeed\relax
+ \else
\edef\p_width{\btxrenderingparameter\c!width}%
\ifx\p_width\v!auto
\scratchcounter\btxcounter
@@ -484,6 +511,13 @@
\fi
\endgroup}
+\unexpanded\def\btxchecklistcombi#1% called at the lua end
+ {\begingroup
+ \edef\currentbtxtag{#1}%
+ ; % todo
+ \publ_check_list_entry
+ \endgroup}
+
\unexpanded\def\publ_check_list_entry
{\global\advance\btxcounter\plusone
% todo, switch to font
@@ -549,6 +583,13 @@
\unexpanded\def\btxflushauthorinverted {\btx_flush_author{inverted}} % #1
\unexpanded\def\btxflushauthorinvertedshort{\btx_flush_author{invertedshort}} % #1
+\unexpanded\def\currentbtxciteauthor % always author
+ {\ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","author",{
+ combiner = "\btxcitevariantparameter\c!author",
+ etallimit = \number\btxcitevariantparameter\c!etallimit,
+ etaldisplay = \number\btxcitevariantparameter\c!etaldisplay,
+ })}}
+
% \btxflushauthor{author}
% \btxflushauthor{artauthor}
% \btxflushauthor{editor}
@@ -558,38 +599,44 @@
% \btxflushauthor[inverted]{author}
% \btxflushauthor[invertedshort]{author}
-% Interaction
+% Interaction: only list
\newconditional\btxinteractive
-\unexpanded\def\btxdoifelseinteraction
- {\iflocation
- \edef\p_interaction{\btxcitevariantparameter\c!interaction}%
- \ifx\p_interaction\v!stop
- \doubleexpandafter\secondoftwoarguments
- \else
- \doubleexpandafter\firstoftwoarguments
- \fi
- \else
- \expandafter\secondoftwoarguments
- \fi}
+\unexpanded\def\btxdoifelseinteraction{\secondoftwoarguments}
\appendtoks
\iflocation
\edef\p_interaction{\btxlistvariantparameter\c!interaction}%
\ifx\p_interaction\v!stop
- \let\doifelsebtxinteractionelse\secondoftwoarguments
+ \let\btxdoifelseinteraction\secondoftwoarguments
\setfalse\btxinteractive
\else
- \let\doifelsebtxinteractionelse\firstoftwoarguments
+ \let\btxdoifelseinteraction\firstoftwoarguments
\settrue\btxinteractive
\fi
\else
- \let\doifelsebtxinteractionelse\secondoftwoarguments
+ \let\btxdoifelseinteraction\secondoftwoarguments
\setfalse\btxinteractive
\fi
\to \everysetupbtxlistplacement
+\appendtoks
+ \iflocation
+ \edef\p_interaction{\btxcitevariantparameter\c!interaction}%
+ \ifx\p_interaction\v!stop
+ \let\btxdoifelseinteraction\secondoftwoarguments
+ \setfalse\btxinteractive
+ \else
+ \let\btxdoifelseinteraction\firstoftwoarguments
+ \settrue\btxinteractive
+ \fi
+ \else
+ \let\btxdoifelseinteraction\secondoftwoarguments
+ \setfalse\btxinteractive
+ \fi
+\to \everysetupbtxciteplacement
+
% bib -> btx
\unexpanded\def\btxgotolink#1[#2]{\doifreferencefoundelse{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}}
@@ -651,15 +698,21 @@
% \iftrialtypesetting \else
% \processcommacommand[\currentbtxtag]{\publ_cite_indeed\currentbtxrendering}%
% \fi}
+%
+% \def\publ_cite_indeed#1#2%
+% {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}}
-\def\publ_cite_indeed#1#2%
- {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}}
-
-\def\btxdomarkcitation#1#2% called from lua end
- {\iftrialtypesetting \else
- \writedatatolist[btx][btxset=#1,btxref=#2]% \c!location=\v!here
+\unexpanded\def\btxdomarkcitation % called from lua end
+ {\iftrialtypesetting
+ \expandafter\gobbletwoarguments
+ \else
+ \expandafter\publ_cite_mark_citation
\fi}
+\def\publ_cite_mark_citation#1#2% called from lua end
+ {\dontleavehmode
+ \writedatatolist[btx][btxset=#1,btxref=#2]} % \c!location=\v!here
+
%D \macros{cite,nocite,citation,nocitation,usecitation}
%D
%D The inline \type {\cite} command creates a (often) short reference to a publication
@@ -687,6 +740,7 @@
{\letinteractionparameter\c!style\empty
\edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}%
\edef\currentbtxcitetag{#1}%
+ \the\everysetupbtxciteplacement
\publ_cite_variant
\endgroup}
@@ -695,21 +749,31 @@
\unexpanded\def\publ_cite_tags_options[#1]%
{\strictdoifnextoptionalelse{\publ_cite_tags_options_indeed{#1}}{\publ_cite_tags_indeed{#1}}}
+% \unexpanded\def\publ_cite_tags_options_indeed#1[#2]%
+% {\edef\currentbtxcitetag{#2}%
+% \doifassignmentelse{#1}
+% {\publ_cite_tags_settings_indeed{#1}}
+% {\publ_cite_tags_variants_indeed{#1}}}
+
\unexpanded\def\publ_cite_tags_options_indeed#1[#2]%
{\edef\currentbtxcitetag{#2}%
- \doifassignmentelse{#1}
- {\publ_cite_tags_settings_indeed{#1}}
- {\publ_cite_tags_variants_indeed{#1}}}
+ \doifassignmentelse{#1}\publ_cite_tags_settings_indeed\publ_cite_tags_variants_indeed{#1}}
\def\publ_cite_tags_settings_indeed#1%
{\letinteractionparameter\c!style\empty
%\letinteractionparameter\c!color\empty
- \getdummyparameters[\c!alternative=,\c!extras=,#1]%
+ \letdummyparameter\c!before \empty
+ \letdummyparameter\c!after \empty
+ \letdummyparameter\c!extras \empty
+ \letdummyparameter\c!alternative\empty
+ \getdummyparameters[#1]%
\edef\p_alternative{\dummyparameter\c!alternative}%
- \ifx\p_alternative\empty \else
+ \ifx\p_alternative\empty
+ \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}%
+ \else
\let\currentbtxcitevariant\p_alternative
\fi
- \setupcurrentbtxcitevariantparameters[#1]%
+ \setupcurrentbtxcitevariant[#1]%
\edef\p_extras{\dummyparameter\c!extras}%
\ifx\p_extras\empty \else
\edef\p_right{\btxcitevariantparameter\c!right}%
@@ -717,45 +781,53 @@
\setexpandedbtxcitevariantparameter\p_right{\p_extras\p_right}%
\fi
\fi
+ \edef\p_before{\dummyparameter\c!before}%
+ \edef\p_after {\dummyparameter\c!after}%
+ \ifx\p_before\empty \else
+ \p_before
+ \space
+ \fi
\publ_cite_variant
+ \ifx\p_after\empty \else
+ \optionalspace
+ \p_after
+ \fi
\endgroup}
\def\publ_cite_tags_variants_indeed#1%
{\letinteractionparameter\c!style\empty
\edef\currentbtxcitevariant{#1}%
+ \the\everysetupbtxciteplacement
\publ_cite_variant
\endgroup}
\newconditional\btxcitecompress
\def\publ_cite_variant
- {\edef\p_compress{\btxcitevariantparameter\c!compress}%
- % \ifx\p_compress\v!no
- % \setfalse\btxcitecompress
- % \else
- % \settrue\btxcitecompress
- % \fi
- \begingroup
+ {\begingroup
\settrue\c_publ_cite_write
\publ_cite_handle_variant_indeed[\currentbtxcitetag]}
\unexpanded\def\publ_cite_handle_variant#1%
{\begingroup
- \the\everysetupbtxciteplacement
\edef\currentbtxcitevariant{#1}%
+ \the\everysetupbtxciteplacement
\dosingleargument\publ_cite_handle_variant_indeed}
\def\publ_cite_handle_variant_indeed[#1]%
{\usebtxcitevariantstyleandcolor\c!style\c!color
\letbtxcitevariantparameter\c!alternative\currentbtxcitevariant
- \ctxcommand{btxhandlecite(%
- "\currentbtxdataset",%
- "#1",%
- \iftrialtypesetting false\else true\fi,%
- "\currentbtxcitevariant",%
- "\btxcitevariantparameter\c!sorttype",%
- "\btxcitevariantparameter\c!setups"%
- )}%
+ \btxcitevariantparameter\v!left
+ \ctxcommand{btxhandlecite{%
+ dataset = "\currentbtxdataset",%
+ reference = "#1",%
+ markentry = \iftrialtypesetting false\else true\fi,%
+ variant = "\currentbtxcitevariant",%
+ sorttype = "\btxcitevariantparameter\c!sorttype",%
+ compress = "\btxcitevariantparameter\c!compress",%
+ author = "\btxcitevariantparameter\c!author",%
+ }}%
+ \btxcitevariantparameter\v!right
\endgroup}
\unexpanded\def\btxcitation
@@ -775,9 +847,16 @@
\unexpanded\def\publ_cite_no[#1]%
{\iftrialtypesetting \else
- \ctxcommand{btxhandlenocite("\currentbtxdataset","#1",true)}%
+ \ctxcommand{btxhandlecite{%
+ dataset = "\currentbtxdataset",%
+ reference = "#1",%
+ markentry = \iftrialtypesetting false\else true\fi,%
+ }}%
\fi}
+\unexpanded\def\btxmissing#1%
+ {{\tttf<#1>}}
+
%D Compatibility:
\let\cite \btxcite
@@ -788,8 +867,42 @@
%D Cite helpers:
-\unexpanded\def\btxcitevariant#1%
- {\ctxcommand{btxcitevariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","#1")}}
+\newconstant\currentbtxconcat
+
+% \unexpanded\def\btxcitevariant#1%
+% {\ctxcommand{btxcitevariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","#1")}}
+
+\unexpanded\def\btxcitereset
+ {\let\currentbtxfirst \empty
+ \let\currentbtxsecond \empty
+ \let\currentbtxinternal\empty
+ \let\currentbtxtag \empty
+ \setconstant\currentbtxconcat\zerocount}
+
+\btxcitereset
+
+\unexpanded\def\btxcitesetup#1%
+ {\directsetup{btx:cite:#1}%
+ \btxcitereset}
+
+\unexpanded\def\btxsetfirst {\def\currentbtxfirst}
+\unexpanded\def\btxsetsecond {\def\currentbtxsecond}
+\unexpanded\def\btxsettag {\def\currentbtxtag}
+\unexpanded\def\btxsetinternal{\def\currentbtxinternal}
+\unexpanded\def\btxsetconcat#1{\setconstant\currentbtxconcat#1\relax}
+
+\unexpanded\def\btxsetreference#1#2% #3#4%
+ {\strc_references_direct_full_user{btxset="#1",btxref="#2"}}
+
+\unexpanded\def\btxstartsubcite#1%
+ {\bgroup
+ \btxcitereset
+ \def\currentbtxcitevariant{#1}%
+ \btxcitevariantparameter\c!left}
+
+\unexpanded\def\btxstopsubcite
+ {\btxcitevariantparameter\c!right
+ \egroup}
%D List helpers:
@@ -816,6 +929,8 @@
\loadbtxdefinitionfile[\btxrenderingparameter\c!alternative]
\to \everysetupbtxrendering
+\stopcontextdefinitioncode
+
%D Defaults:
\setupbtxrendering
@@ -842,9 +957,12 @@
\c!otherstext={ et al.},
\c!pubsep={, },
\c!lastpubsep={ and },
+ \c!finalpubsep={ and },
\c!compress=\v!no,
\c!inbetween={ },
+ \c!range=\endash,
\c!left=,
+ \c!middle=,
\c!right=]
\definebtxcitevariant
@@ -855,6 +973,11 @@
\c!right={)}]
\definebtxcitevariant
+ [authornum]
+ [author]
+ [\c!inbetween={ }]
+
+\definebtxcitevariant
[authoryear]
[\c!compress=\v!yes,
\c!inbetween={, },
@@ -867,62 +990,90 @@
[authoryear]
\definebtxcitevariant
+ [author:num]
[authornum]
- [author]
[\c!left={[},
\c!right={]}]
\definebtxcitevariant
+ [author:year]
+ [authoryear]
+ [\c!left={(},
+ \c!right={)}]
+
+\definebtxcitevariant
+ [author:years]
+ [authoryears]
+ [\c!left=,
+ \c!right=]
+
+\definebtxcitevariant
[year]
[\c!left={(},
+ \c!middle={, }, % is middle used?
\c!right={)}]
\definebtxcitevariant
- [key]
+ [tag]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
+ [key]
+ [tag]
+
+\definebtxcitevariant
[serial]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[page]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[short]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
- [type]
+ [category]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
+ [type]
+ [category]
+
+\definebtxcitevariant
[doi]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[url]
[\c!left={[},
+ \c!middle={, },
\c!right={]}]
\definebtxcitevariant
[page]
[\c!left=,
- \c!right=,
- \c!inbetween=\endash]
+ \c!middle={, },
+ \c!right=]
\definebtxcitevariant
[num]
[\c!compress=\v!yes,
- \c!inbetween={--},
\c!left={[},
+ \c!middle={, },
\c!right={]}]
\setupbtxlistvariant
@@ -953,6 +1104,11 @@
[artauthor]
[author]
+\setupbtxcitevariant
+ [\c!author =\btxlistvariantparameter\c!author,
+ \c!etallimit =\btxlistvariantparameter\c!etallimit,
+ \c!etaldisplay =\btxlistvariantparameter\c!etaldisplay]
+
% Do we want these in the format? Loading them delayed is somewhat messy.
\loadbtxdefinitionfile[apa]
diff --git a/Master/texmf-dist/tex/context/base/s-math-coverage.lua b/Master/texmf-dist/tex/context/base/s-math-coverage.lua
index 5f1c7cc5a17..56880f76db0 100644
--- a/Master/texmf-dist/tex/context/base/s-math-coverage.lua
+++ b/Master/texmf-dist/tex/context/base/s-math-coverage.lua
@@ -6,76 +6,37 @@ if not modules then modules = { } end modules ['s-math-coverage'] = {
license = "see context related readme files"
}
-moduledata.math = moduledata.math or { }
-moduledata.math.coverage = moduledata.math.coverage or { }
-
local utfchar, utfbyte = utf.char, utf.byte
local formatters, lower = string.formatters, string.lower
local concat = table.concat
-local context = context
-local NC, NR, HL = context.NC, context.NR, context.HL
-local char, getglyph, bold = context.char, context.getglyph, context.bold
+moduledata.math = moduledata.math or { }
+moduledata.math.coverage = moduledata.math.coverage or { }
-local ucgreek = {
- 0x0391, 0x0392, 0x0393, 0x0394, 0x0395,
- 0x0396, 0x0397, 0x0398, 0x0399, 0x039A,
- 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
- 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5,
- 0x03A6, 0x03A7, 0x03A8, 0x03A9
-}
+local context = context
-local lcgreek = {
- 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5,
- 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA,
- 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
- 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4,
- 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9,
- 0x03D1, 0x03D5, 0x03D6, 0x03F0, 0x03F1,
- 0x03F4, 0x03F5
-}
+local ctx_NC = context.NC
+local ctx_NR = context.NR
+local ctx_HL = context.HL
-local ucletters = {
- 0x00041, 0x00042, 0x00043, 0x00044, 0x00045,
- 0x00046, 0x00047, 0x00048, 0x00049, 0x0004A,
- 0x0004B, 0x0004C, 0x0004D, 0x0004E, 0x0004F,
- 0x00050, 0x00051, 0x00052, 0x00053, 0x00054,
- 0x00055, 0x00056, 0x00057, 0x00058, 0x00059,
- 0x0005A,
-}
+local ctx_rawmathematics = context.formatted.rawmathematics
+local ctx_mathematics = context.formatted.mathematics
+local ctx_startimath = context.startimath
+local ctx_stopimath = context.stopimath
+local ctx_setmathattribute = context.setmathattribute
+local ctx_underbar = context.underbar
+local ctx_getglyph = context.getglyph
-local lcletters = {
- 0x00061, 0x00062, 0x00063, 0x00064, 0x00065,
- 0x00066, 0x00067, 0x00068, 0x00069, 0x0006A,
- 0x0006B, 0x0006C, 0x0006D, 0x0006E, 0x0006F,
- 0x00070, 0x00071, 0x00072, 0x00073, 0x00074,
- 0x00075, 0x00076, 0x00077, 0x00078, 0x00079,
- 0x0007A,
-}
+local styles = mathematics.styles
+local alternatives = mathematics.alternatives
+local charactersets = mathematics.charactersets
-local digits = {
- 0x00030, 0x00031, 0x00032, 0x00033, 0x00034,
- 0x00035, 0x00036, 0x00037, 0x00038, 0x00039,
-}
-
-local styles = {
- "regular", "sansserif", "monospaced", "fraktur", "script", "blackboard"
-}
+local getboth = mathematics.getboth
+local remapalphabets = mathematics.remapalphabets
-local alternatives = {
- "normal", "bold", "italic", "bolditalic"
-}
-
-local alphabets = {
- ucletters, lcletters, ucgreek, lcgreek, digits,
-}
-
-local getboth = mathematics.getboth
-local remapalphabets = mathematics.remapalphabets
-
-local chardata = characters.data
-local superscripts = characters.superscripts
-local subscripts = characters.subscripts
+local chardata = characters.data
+local superscripts = characters.superscripts
+local subscripts = characters.subscripts
context.writestatus("math coverage","underline: not remapped")
@@ -85,37 +46,37 @@ function moduledata.math.coverage.showalphabets()
local style = styles[i]
for i=1,#alternatives do
local alternative = alternatives[i]
- for i=1,#alphabets do
- local alphabet = alphabets[i]
- NC()
+ for i=1,#charactersets do
+ local alphabet = charactersets[i]
+ ctx_NC()
if i == 1 then
context("%s %s",style,alternative)
end
- NC()
- context.startimath()
- context.setmathattribute(style,alternative)
+ ctx_NC()
+ ctx_startimath()
+ ctx_setmathattribute(style,alternative)
for i=1,#alphabet do
local letter = alphabet[i]
local id = getboth(style,alternative)
local unicode = remapalphabets(letter,id)
if not unicode then
- context.underbar(utfchar(letter))
+ ctx_underbar(utfchar(letter))
elseif unicode == letter then
context(utfchar(unicode))
else
context(utfchar(unicode))
end
end
- context.stopimath()
- NC()
+ ctx_stopimath()
+ ctx_NC()
local first = alphabet[1]
local last = alphabet[#alphabet]
local id = getboth(style,alternative)
local f_unicode = remapalphabets(first,id) or utfbyte(first)
local l_unicode = remapalphabets(last,id) or utfbyte(last)
context("%05X - %05X",f_unicode,l_unicode)
- NC()
- NR()
+ ctx_NC()
+ ctx_NR()
end
end
end
@@ -126,15 +87,15 @@ function moduledata.math.coverage.showcharacters()
context.startmixedcolumns()
context.setupalign { "nothyphenated" }
context.starttabulate { "|T|i2|Tpl|" }
- for u, d in table.sortedpairs(chardata) do
+ for u, d in table.sortedhash(chardata) do
local mathclass = d.mathclass
local mathspec = d.mathspec
if mathclass or mathspec then
- NC()
+ ctx_NC()
context("%05X",u)
- NC()
- getglyph("MathRoman",u)
- NC()
+ ctx_NC()
+ ctx_getglyph("MathRoman",u)
+ ctx_NC()
if mathspec then
local t = { }
for i=1,#mathspec do
@@ -145,8 +106,8 @@ function moduledata.math.coverage.showcharacters()
else
context(mathclass)
end
- NC()
- NR()
+ ctx_NC()
+ ctx_NR()
end
end
context.stoptabulate()
@@ -157,26 +118,33 @@ end
function moduledata.math.coverage.showscripts()
context.starttabulate { "|cT|c|cT|c|c|c|l|" }
- for k, v in table.sortedpairs(table.merged(superscripts,subscripts)) do
+ for k, v in table.sortedhash(table.merged(superscripts,subscripts)) do
local ck = utfchar(k)
local cv = utfchar(v)
local ss = superscripts[k] and "^" or "_"
- NC()
- context("%05X",k)
- NC()
- context(ck)
- NC()
- context("%05X",v)
- NC()
- context(cv)
- NC()
- context.formatted.rawmathematics("x%s = x%s%s",ck,ss,cv)
- NC()
- context.formatted.mathematics("x%s = x%s%s",ck,ss,cv)
- NC()
- context(lower(chardata[k].description))
- NC()
- NR()
+ ctx_NC() context("%05X",k)
+ ctx_NC() context(ck)
+ ctx_NC() context("%05X",v)
+ ctx_NC() context(cv)
+ ctx_NC() ctx_rawmathematics("x%s = x%s%s",ck,ss,cv)
+ ctx_NC() ctx_mathematics("x%s = x%s%s",ck,ss,cv)
+ ctx_NC() context(lower(chardata[k].description))
+ ctx_NC() ctx_NR()
+ end
+ context.stoptabulate()
+end
+
+-- Handy too.
+
+function moduledata.math.coverage.showbold()
+ context.starttabulate { "|lT|cm|lT|cm|lT|" }
+ for k, v in table.sortedhash(mathematics.boldmap) do
+ ctx_NC() context("%U",k)
+ ctx_NC() context("%c",k)
+ ctx_NC() context("%U",v)
+ ctx_NC() context("%c",v)
+ ctx_NC() context(chardata[k].description)
+ ctx_NC() ctx_NR()
end
context.stoptabulate()
end
diff --git a/Master/texmf-dist/tex/context/base/s-math-coverage.mkiv b/Master/texmf-dist/tex/context/base/s-math-coverage.mkiv
index d68ffe58751..9f084b2841c 100644
--- a/Master/texmf-dist/tex/context/base/s-math-coverage.mkiv
+++ b/Master/texmf-dist/tex/context/base/s-math-coverage.mkiv
@@ -18,6 +18,7 @@
\installmodulecommandluasingle \showmathalphabets {moduledata.math.coverage.showalphabets}
\installmodulecommandluasingle \showmathcharacters {moduledata.math.coverage.showcharacters}
\installmodulecommandluasingle \showmathscripts {moduledata.math.coverage.showscripts}
+\installmodulecommandluasingle \showmathbold {moduledata.math.coverage.showbold}
\stopmodule
@@ -30,5 +31,6 @@
\showmathalphabets \page
\showmathcharacters \page
\showmathscripts \page
+ \showmathbold \page
\stoptext
diff --git a/Master/texmf-dist/tex/context/base/spac-chr.lua b/Master/texmf-dist/tex/context/base/spac-chr.lua
index 1abba350ad8..5b3a15478ce 100644
--- a/Master/texmf-dist/tex/context/base/spac-chr.lua
+++ b/Master/texmf-dist/tex/context/base/spac-chr.lua
@@ -39,6 +39,7 @@ local setattr = nuts.setattr
local getfont = nuts.getfont
local getchar = nuts.getchar
+local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local remove_node = nuts.remove
local copy_node_list = nuts.copy_list
@@ -58,6 +59,7 @@ local glue_code = nodecodes.glue
local space_skip_code = skipcodes["spaceskip"]
local chardata = characters.data
+local is_punctuation = characters.is_punctuation
local typesetters = typesetters
@@ -162,6 +164,18 @@ local methods = {
-- The next one uses an attribute assigned to the character but still we
-- don't have the 'local' value.
+ [0x001F] = function(head,current)
+ local next = getnext(current)
+ if next and getid(next) == glyph_code then
+ local char = getchar(next)
+ head, current = remove_node(head,current,true)
+ if not is_punctuation[char] then
+ local p = fontparameters[getfont(next)]
+ head, current = insert_node_before(head,current,new_glue(p.space,p.space_stretch,p.space_shrink))
+ end
+ end
+ end,
+
[0x00A0] = function(head,current) -- nbsp
local next = getnext(current)
if next and getid(next) == glyph_code then
diff --git a/Master/texmf-dist/tex/context/base/spac-chr.mkiv b/Master/texmf-dist/tex/context/base/spac-chr.mkiv
index 54a25be34a8..f9dc6e16b5f 100644
--- a/Master/texmf-dist/tex/context/base/spac-chr.mkiv
+++ b/Master/texmf-dist/tex/context/base/spac-chr.mkiv
@@ -78,6 +78,8 @@
\let\zwnj\zerowidthnonjoiner
\let\zwj \zerowidthjoiner
+\chardef\optionalspace"1F % will be space unless before punctuation
+
% Shortcuts:
% unexpanded as otherwise we need to intercept / cleanup a lot
diff --git a/Master/texmf-dist/tex/context/base/status-files.pdf b/Master/texmf-dist/tex/context/base/status-files.pdf
index a4381c06d75..7efcee99719 100644
--- a/Master/texmf-dist/tex/context/base/status-files.pdf
+++ b/Master/texmf-dist/tex/context/base/status-files.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/context/base/status-lua.pdf b/Master/texmf-dist/tex/context/base/status-lua.pdf
index ad8475aedaa..ea3539ae7c5 100644
--- a/Master/texmf-dist/tex/context/base/status-lua.pdf
+++ b/Master/texmf-dist/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/context/base/strc-ref.lua b/Master/texmf-dist/tex/context/base/strc-ref.lua
index 0c8bb6e53e8..3f2c0608d2a 100644
--- a/Master/texmf-dist/tex/context/base/strc-ref.lua
+++ b/Master/texmf-dist/tex/context/base/strc-ref.lua
@@ -158,7 +158,7 @@ local function initializer() -- can we use a tobesaved as metatable for collecte
local r = data.references
local i = r.internal
if i then
- internals[i] = c
+ internals[i] = data
usedinternals[i] = r.used
end
end
diff --git a/Master/texmf-dist/tex/context/base/strc-ref.mkvi b/Master/texmf-dist/tex/context/base/strc-ref.mkvi
index 76d79b80221..359bb4a76ca 100644
--- a/Master/texmf-dist/tex/context/base/strc-ref.mkvi
+++ b/Master/texmf-dist/tex/context/base/strc-ref.mkvi
@@ -263,10 +263,11 @@
\lastdestinationattribute\attributeunsetvalue
\fi}
-\unexpanded\def\strc_references_direct_full#labels#text%
+\unexpanded\def\strc_references_direct_full_user#user#labels#text%
{\ifreferencing
\strc_references_start_destination_nodes
-\setnextinternalreference
+ \setnextinternalreference
+ \edef\m_strc_references_user{#user}%
\ctxcommand{setreferenceattribute("\s!full", "\referenceprefix","#labels",
{
references = {
@@ -280,6 +281,11 @@
entries = {
text = \!!bs#text\!!es
},
+ \ifx\m_strc_references_user\empty \else
+ userdata = {
+ \m_strc_references_user
+ }
+ \fi
},"\interactionparameter\c!focus")
}%
\strc_references_stop_destination_nodes
@@ -297,7 +303,10 @@
\prewordbreak % new
\fi}
-\let\dodirectfullreference\strc_references_direct_full % for at lua end
+\unexpanded\def\strc_references_direct_full
+ {\strc_references_direct_full_user\empty}
+
+\let\dodirectfullreference\strc_references_direct_full % for at lua end (no longer)
\def\strc_references_set_page_only_destination_box_attribute#cs#labels%
{\strc_references_set_page_only_destination_attribute{#labels}%
diff --git a/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv b/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv
index 3734e564768..a7a7ae50bc7 100644
--- a/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv
+++ b/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv
@@ -1255,12 +1255,29 @@
\fi
\dostoptagged} % right spot
+% \def\tabl_ntb_cell_finalize
+% {\doifnotinset\localwidth{\v!fit,\v!broad}% user set
+% {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax
+% \ifdim\localwidth>\scratchdimen
+% \tabl_ntb_set_aut\c_tabl_ntb_col{\the\dimexpr\localwidth}%
+% \fi}}
+
\def\tabl_ntb_cell_finalize
- {\doifnotinset\localwidth{\v!fit,\v!broad}% user set
- {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax
- \ifdim\localwidth>\scratchdimen
- \tabl_ntb_set_aut\c_tabl_ntb_col{\the\dimexpr\localwidth}%
- \fi}}
+ {\ifx\localwidth\v!fit
+ % nothing
+ \else\ifx\localwidth\v!broad
+ % nothing
+ \else\ifx\localwidth\empty
+ % nothing (safeguard)
+ \else
+ \tabl_ntb_cell_finalize_indeed
+ \fi\fi\fi}
+
+\def\tabl_ntb_cell_finalize_indeed
+ {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax
+ \ifdim\localwidth>\scratchdimen
+ \tabl_ntb_set_aut\c_tabl_ntb_col{\the\dimexpr\localwidth}%
+ \fi}
\def\tabl_ntb_table_stop
{\setbox\scratchbox\hbox
diff --git a/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv b/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv
index d4d22af9716..c25d61741f4 100644
--- a/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv
+++ b/Master/texmf-dist/tex/context/base/tabl-tbl.mkiv
@@ -1066,6 +1066,9 @@
\def\tabl_tabulate_insert_content
{\tabl_tabulate_insert_head
+ \ifcase\c_tabl_tabulate_repeathead \else
+ \tabulatenoalign{\penalty\zerocount}% added 7/5/2014 WS mail
+ \fi
\tabl_tabulate_insert_body
\tabl_tabulate_insert_foot
\tabl_tabulate_remove_funny_line}
diff --git a/Master/texmf-dist/tex/context/base/trac-deb.lua b/Master/texmf-dist/tex/context/base/trac-deb.lua
index af4f7c643a0..d52399bcf1f 100644
--- a/Master/texmf-dist/tex/context/base/trac-deb.lua
+++ b/Master/texmf-dist/tex/context/base/trac-deb.lua
@@ -130,7 +130,10 @@ function tracers.showlines(filename,linenumber,offset,luaerrorline)
local stop = "\\stopluacode"
local n = linenumber
for i=n,1,-1 do
- if find(lines[i],start) then
+ local line = lines[i]
+ if not line then
+ break
+ elseif find(line,start) then
n = i + luaerrorline - 1
if n <= linenumber then
linenumber = n
@@ -209,7 +212,7 @@ function tracers.printerror(specification)
report_nl()
if luaerrorline then
report("error on line %s in file %s:\n\n%s",linenumber,filename,lastluaerror)
--- report("error on line %s in file %s:\n\n%s",linenumber,filename,lasttexerror)
+ -- report("error on line %s in file %s:\n\n%s",linenumber,filename,lasttexerror)
else
report("error on line %s in file %s: %s",linenumber,filename,lasttexerror)
if tex.show_context then
diff --git a/Master/texmf-dist/tex/context/base/trac-log.lua b/Master/texmf-dist/tex/context/base/trac-log.lua
index 45cc550d491..72f271d9c3c 100644
--- a/Master/texmf-dist/tex/context/base/trac-log.lua
+++ b/Master/texmf-dist/tex/context/base/trac-log.lua
@@ -17,7 +17,7 @@ if not modules then modules = { } end modules ['trac-log'] = {
-- local texio_write_nl = texio.write_nl
-- local texio_write = texio.write
-- local io_write = io.write
-
+--
-- local write_nl = function(target,...)
-- if not io_write then
-- io_write = io.write
@@ -37,7 +37,7 @@ if not modules then modules = { } end modules ['trac-log'] = {
-- io_write(target,...)
-- end
-- end
-
+--
-- local write = function(target,...)
-- if not io_write then
-- io_write = io.write
@@ -54,7 +54,7 @@ if not modules then modules = { } end modules ['trac-log'] = {
-- io_write(target,...)
-- end
-- end
-
+--
-- texio.write = write
-- texio.write_nl = write_nl
--
diff --git a/Master/texmf-dist/tex/context/base/type-imp-cambria.mkiv b/Master/texmf-dist/tex/context/base/type-imp-cambria.mkiv
index 91288b6d0ac..9bfa2ee5c49 100644
--- a/Master/texmf-dist/tex/context/base/type-imp-cambria.mkiv
+++ b/Master/texmf-dist/tex/context/base/type-imp-cambria.mkiv
@@ -11,6 +11,10 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+%D We use Dejavu as it covers wider range of monospaced glyphs.
+
+\loadtypescriptfile[dejavu]
+
\starttypescriptcollection[cambria]
% microsoft: cambria.ttc cambriab.ttf cambriai.ttf cambriaz.ttf
@@ -60,13 +64,13 @@
\starttypescript [cambria,cambria-m,cambria-a]
% any
\definetypeface [cambria] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
- \definetypeface [cambria] [\s!tt] [\s!mono] [modern] [\s!default]
+ \definetypeface [cambria] [\s!tt] [\s!mono] [dejavu] [\s!default]
\definetypeface [cambria] [\s!mm] [\s!math] [\typescriptone] [\s!default]
\stoptypescript
\starttypescript [cambria-x,cambria-y]
% test x
\definetypeface [\typescriptone] [\s!rm] [\s!serif] [cambria] [\s!default]
- \definetypeface [\typescriptone] [\s!tt] [\s!mono] [modern] [\s!default]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default]
\definetypeface [\typescriptone] [\s!mm] [\s!math] [\typescriptone] [\s!default]
\stoptypescript
diff --git a/Master/texmf-dist/tex/context/base/type-imp-lato.mkiv b/Master/texmf-dist/tex/context/base/type-imp-lato.mkiv
new file mode 100644
index 00000000000..8fb8647fceb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/type-imp-lato.mkiv
@@ -0,0 +1,56 @@
+%D \module
+%D [ file=type-imp-lato,
+%D version=2014.05.02,
+%D title=\CONTEXT\ Typescript Macros,
+%D subtitle=Lato fonts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% hai : hair / lta : italic
+% lig : light / lta : italic
+% reg : regular / lta : italic
+% bol : bold / lta : italic
+% bla : black / lta : italic
+
+\loadtypescriptfile[dejavu]
+\loadtypescriptfile[xits]
+
+\starttypescriptcollection[lato]
+
+ \starttypescript [\s!sans] [lato] [\s!name]
+ \setups[\s!font:\s!fallback:\s!sans]
+ \definefontsynonym [\s!Sans] [\s!file:lato-reg] [\s!features=\s!default]
+ \definefontsynonym [\s!SansBold] [\s!file:lato-bol] [\s!features=\s!default]
+ \definefontsynonym [\s!SansItalic] [\s!file:lato-reglta] [\s!features=\s!default]
+ \definefontsynonym [\s!SansBoldItalic] [\s!file:lato-bollta] [\s!features=\s!default]
+ \stoptypescript
+
+ \starttypescript [\s!sans] [lato-light] [\s!name]
+ \setups[\s!font:\s!fallback:\s!sans]
+ \definefontsynonym [\s!Sans] [\s!file:lato-lig] [\s!features=\s!default]
+ \definefontsynonym [\s!SansBold] [\s!file:lato-reg] [\s!features=\s!default]
+ \definefontsynonym [\s!SansItalic] [\s!file:lato-liglta] [\s!features=\s!default]
+ \definefontsynonym [\s!SansBoldItalic] [\s!file:lato-reglta] [\s!features=\s!default]
+ \stoptypescript
+
+ \starttypescript [\s!sans] [lato-dark] [\s!name]
+ \setups[\s!font:\s!fallback:\s!sans]
+ \definefontsynonym [\s!Sans] [\s!file:lato-bol] [\s!features=\s!default]
+ \definefontsynonym [\s!SansBold] [\s!file:lato-bla] [\s!features=\s!default]
+ \definefontsynonym [\s!SansItalic] [\s!file:lato-bollta] [\s!features=\s!default]
+ \definefontsynonym [\s!SansBoldItalic] [\s!file:lato-blalta] [\s!features=\s!default]
+ \stoptypescript
+
+ \starttypescript[lato,lato-light,lato-dark]
+ \definetypeface [\typescriptone] [\s!ss] [\s!sans] [\typescriptone] [\s!default]
+ \definetypeface [\typescriptone] [\s!rm] [\s!serif] [dejavu] [\s!default]
+ \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default]
+ \definetypeface [\typescriptone] [\s!mm] [\s!math] [xits] [\s!default] [\s!rscale=1.2]
+ \stoptypescript
+
+\stoptypescriptcollection
diff --git a/Master/texmf-dist/tex/context/base/util-str.lua b/Master/texmf-dist/tex/context/base/util-str.lua
index 52c48badda8..5609cdf255d 100644
--- a/Master/texmf-dist/tex/context/base/util-str.lua
+++ b/Master/texmf-dist/tex/context/base/util-str.lua
@@ -284,6 +284,7 @@ end
-- octal %...o number
-- string %...s string number
-- float %...f number
+-- checked float %...F number
-- exponential %...e number
-- exponential %...E number
-- autofloat %...g number
@@ -526,7 +527,11 @@ end
local format_F = function(f)
n = n + 1
- return format("((a%s == 0 and '0') or (a%s == 1 and '1') or format('%%%sf',a%s))",n,n,f,n)
+ if not f or f == "" then
+ return format("(((a%s > -0.0000000005 and a%s < 0.0000000005) and '0') or (a%s == 1 and '1') or format('%%.9f',a%s))",n,n,n,n)
+ else
+ return format("((a%s == 0 and '0') or (a%s == 1 and '1') or format('%%%sf',a%s))",n,n,f,n)
+ end
end
local format_g = function(f)
diff --git a/Master/texmf-dist/tex/context/base/x-asciimath.lua b/Master/texmf-dist/tex/context/base/x-asciimath.lua
index 992c37eaebd..87f04b5ff7d 100644
--- a/Master/texmf-dist/tex/context/base/x-asciimath.lua
+++ b/Master/texmf-dist/tex/context/base/x-asciimath.lua
@@ -268,5 +268,7 @@ parser = Cs { "main",
}
-asciimath.reserved = reserved
-asciimath.convert = converted
+asciimath.reserved = reserved
+asciimath.convert = converted
+
+commands.convert = converted
diff --git a/Master/texmf-dist/tex/context/base/x-asciimath.mkiv b/Master/texmf-dist/tex/context/base/x-asciimath.mkiv
index b555115ffc3..fd385671a50 100644
--- a/Master/texmf-dist/tex/context/base/x-asciimath.mkiv
+++ b/Master/texmf-dist/tex/context/base/x-asciimath.mkiv
@@ -64,7 +64,8 @@
\writestatus{asciimath}{beware, this is an experimental (m4all only) module}
-\unexpanded\def\asciimath#1{\ctxmoduleasciimath{convert(\!!bs\detokenize{#1}\!!es,true)}}
+%unexpanded\def\asciimath#1{\ctxmoduleasciimath{convert(\!!bs\detokenize{#1}\!!es,true)}}
+\unexpanded\def\asciimath#1{\ctxcommand{convert(\!!bs\detokenize\expandafter{\normalexpanded{#1}}\!!es,true)}}
\protect
@@ -82,6 +83,7 @@
\asciimath{int_0^1 f(x)dx}
\asciimath{int^1_0 f(x)dx}
\asciimath{a//b}
+\asciimath{a//\alpha}
\asciimath{(a/b)/(d/c)}
\asciimath{((a*b))/(d/c)}
\asciimath{[[a,b],[c,d]]((n),(k))}
diff --git a/Master/texmf-dist/tex/context/base/x-mathml.lua b/Master/texmf-dist/tex/context/base/x-mathml.lua
index baf839ad8ae..15739eec76e 100644
--- a/Master/texmf-dist/tex/context/base/x-mathml.lua
+++ b/Master/texmf-dist/tex/context/base/x-mathml.lua
@@ -758,7 +758,7 @@ function mathml.mtable(root)
local framespacing = at.framespacing or "0pt"
local framespacing = at.framespacing or "-\\ruledlinewidth" -- make this an option
- context.bTABLE { frame = frametypes[frame or "none"] or "off", offset = framespacing }
+ context.bTABLE { frame = frametypes[frame or "none"] or "off", offset = framespacing, background = "" } -- todo: use xtables and definextable
for e in lxml.collected(root,"/(mml:mtr|mml:mlabeledtr)") do
context.bTR()
local at = e.at