summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/back-exp.lua1
-rw-r--r--tex/context/base/back-ini.lua6
-rw-r--r--tex/context/base/back-ini.mkiv6
-rw-r--r--tex/context/base/back-u3d.mkiv2
-rw-r--r--tex/context/base/char-ini.lua42
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4062 -> 4061 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/lxml-tex.lua6
-rw-r--r--tex/context/base/mult-def.mkiv2
-rw-r--r--tex/context/base/mult-fun.lua1
-rw-r--r--tex/context/base/mult-low.lua1
-rw-r--r--tex/context/base/node-acc.lua12
-rw-r--r--tex/context/base/node-typ.lua2
-rw-r--r--tex/context/base/publ-imp-cite.mkiv153
-rw-r--r--tex/context/base/publ-ini.lua879
-rw-r--r--tex/context/base/publ-ini.mkiv91
-rw-r--r--tex/context/base/spac-chr.lua14
-rw-r--r--tex/context/base/spac-chr.mkiv2
-rw-r--r--tex/context/base/status-files.pdfbin24587 -> 24620 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin243446 -> 243695 bytes
-rw-r--r--tex/context/base/trac-deb.lua5
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
23 files changed, 706 insertions, 525 deletions
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua
index 79538eb72..44c2cd539 100644
--- a/tex/context/base/back-exp.lua
+++ b/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/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua
index e2dabd91e..c1f973a0c 100644
--- a/tex/context/base/back-ini.lua
+++ b/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/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv
index de4ba6138..c3bc78ae6 100644
--- a/tex/context/base/back-ini.mkiv
+++ b/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/tex/context/base/back-u3d.mkiv b/tex/context/base/back-u3d.mkiv
index 89d26ee41..297dd5545 100644
--- a/tex/context/base/back-u3d.mkiv
+++ b/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/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua
index 1cfeb0596..7dc381031 100644
--- a/tex/context/base/char-ini.lua
+++ b/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
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 93aaab8b1..47289ebe9 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2014.05.15 19:52}
+\newcontextversion{2014.05.16 20:08}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 3b0bb257a..145596d8c 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index dcda516f2..50a8e6259 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -28,7 +28,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2014.05.15 19:52}
+\edef\contextversion{2014.05.16 20:08}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index adeee20c3..0c58a47cc 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -354,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
@@ -1185,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/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index f6548c75b..321f06154 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -99,6 +99,8 @@
\def\s!decimal {decimal}
\def\s!binary {binary}
+\def\s!internal {internal}
+
\def\s!current {current}
\def\s!rel {rel}
diff --git a/tex/context/base/mult-fun.lua b/tex/context/base/mult-fun.lua
index 0f5bd8ace..846a50ddf 100644
--- a/tex/context/base/mult-fun.lua
+++ b/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/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index a52fd1ddc..dda4e5aad 100644
--- a/tex/context/base/mult-low.lua
+++ b/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"] = {
--
diff --git a/tex/context/base/node-acc.lua b/tex/context/base/node-acc.lua
index 59fa031bf..e684aeb7b 100644
--- a/tex/context/base/node-acc.lua
+++ b/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/tex/context/base/node-typ.lua b/tex/context/base/node-typ.lua
index 4c33e3199..f1aacf25a 100644
--- a/tex/context/base/node-typ.lua
+++ b/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/tex/context/base/publ-imp-cite.mkiv b/tex/context/base/publ-imp-cite.mkiv
index dcec866a3..3d227d736 100644
--- a/tex/context/base/publ-imp-cite.mkiv
+++ b/tex/context/base/publ-imp-cite.mkiv
@@ -21,7 +21,7 @@
% This saves keying:
-\startsetups \s!btx:\s!cite:common:default
+\startsetups \s!btx:\s!cite:common:normal
\ifx\currentbtxsecond\empty
\currentbtxfirst
\else
@@ -31,6 +31,16 @@
\fi
\stopsetups
+\startsetups \s!btx:\s!cite:common:range
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\c!range
+ \currentbtxsecond
+ \fi
+\stopsetups
+
\startsetups \s!btx:\s!cite:concat
\ifcase\currentbtxconcat \or \or
\btxcitevariantparameter\c!pubsep
@@ -41,92 +51,169 @@
\fi
\stopsetups
-\startsetups \s!btx:\s!cite:common
+% \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 {
- \directsetup{\s!btx:\s!cite:common:default}
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\v!inbetween
+ \currentbtxsecond
+ \fi
} [
- internal(\currentbtxinternal)
+ \s!internal(\currentbtxinternal)
]
\else
- \directsetup{\s!btx:\s!cite:common:default}
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\v!inbetween
+ \currentbtxsecond
+ \fi
\fi
\stopsetups
-\startsetups \s!btx:\s!cite:variant
+% \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 {
- \directsetup{\s!btx:\s!cite:common:\currentbtxcitevariant}
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\c!range
+ \currentbtxsecond
+ \fi
} [
- internal(\currentbtxinternal)
+ \s!internal(\currentbtxinternal)
]
\else
- \directsetup{\s!btx:\s!cite:common:\currentbtxcitevariant}
+ \ifx\currentbtxsecond\empty
+ \currentbtxfirst
+ \else
+ \currentbtxfirst
+ \btxcitevariantparameter\c!range
+ \currentbtxsecond
+ \fi
\fi
\stopsetups
-% author lists:
+\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 \s!btx:\s!cite:common:author
- \currentbtxfirst
+% author lists: can be less
+
+\startsetups \s!btx:\s!cite:render:author
+ \directsetup{\s!btx:\s!cite:common:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:render:authoryear
+ \directsetup{\s!btx:\s!cite:common:normal}
+\stopsetups
+\startsetups \s!btx:\s!cite:render:authoryears
+ \directsetup{\s!btx:\s!cite:common:normal}
\stopsetups
-\startsetups \s!btx:\s!cite:common:authoryear
- \currentbtxfirst,\space(\currentbtxsecond)
+\startsetups \s!btx:\s!cite:render:authornum
+ \directsetup{\s!btx:\s!cite:common:normal}
+\stopsetups
+
+\startsetups \s!btx:\s!cite:author:num
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
-\startsetups \s!btx:\s!cite:common:authoryears
- \currentbtxfirst,\space\currentbtxsecond
+\startsetups \s!btx:\s!cite:author:year
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
-\startsetups \s!btx:\s!cite:common:authornum
- \currentbtxfirst\space[\currentbtxsecond]
+\startsetups \s!btx:\s!cite:author:years
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
\startsetups \s!btx:\s!cite:author
- \directsetup{\s!btx:\s!cite:variant}
+ \directsetup{\s!btx:\s!cite:render:variant}
\stopsetups
\startsetups \s!btx:\s!cite:authoryear
- \directsetup{\s!btx:\s!cite:variant}
+ \directsetup{\s!btx:\s!cite:render:variant}
\stopsetups
\startsetups \s!btx:\s!cite:authoryears
- \directsetup{\s!btx:\s!cite:variant}
+ \directsetup{\s!btx:\s!cite:render:variant}
\stopsetups
\startsetups \s!btx:\s!cite:authornum
- \directsetup{\s!btx:\s!cite:variant}
+ \directsetup{\s!btx:\s!cite:render:variant}
\stopsetups
\startsetups \s!btx:\s!cite:year
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
\startsetups \s!btx:\s!cite:short
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:serial
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
\startsetups \s!btx:\s!cite:tag
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:key
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:doi
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:url
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:category
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:type
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\startsetups \s!btx:\s!cite:num
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:range}
\stopsetups
\startsetups \s!btx:\s!cite:page
- \directsetup{\s!btx:\s!cite:common}
+ \directsetup{\s!btx:\s!cite:render:normal}
\stopsetups
\protect
diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua
index 8190ddfc2..ea54a4add 100644
--- a/tex/context/base/publ-ini.lua
+++ b/tex/context/base/publ-ini.lua
@@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['publ-ini'] = {
-- 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)))
@@ -51,6 +51,7 @@ 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
@@ -125,6 +126,8 @@ 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
@@ -284,7 +287,7 @@ local initialized = false
-- },
-- },
-table.setmetatableindex(usedentries,function(t,k)
+setmetatableindex(usedentries,function(t,k)
if not initialized then
usedentries = { }
local internals = structures.references.internals
@@ -785,7 +788,7 @@ local sections = structures.sections
local renderings = { } --- per dataset
-table.setmetatableindex(renderings,function(t,k)
+setmetatableindex(renderings,function(t,k)
local v = {
list = { },
done = { },
@@ -1118,10 +1121,17 @@ end
-- tags = sortedtags(dataset,tags,sorttype)
-- end
-
local prefixsplitter = lpeg.splitat("::")
-function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,compress)
+-- function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,compress)
+function commands.btxhandlecite(specification)
+ local dataset = specification.dataset
+ local tag = specification.reference
+ local mark = specification.markentry ~= false
+ local variant = specification.variant
+ local sorttype = specification.sorttype
+ local compress = specification.compress
+ --
local prefix, rest = lpegmatch(prefixsplitter,tag)
if rest then
dataset = prefix
@@ -1134,7 +1144,6 @@ function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,compress)
report_cite("inject, dataset: %s, tag: %s, variant: %s, compressed",dataset or "-",rest,variant)
end
ctx_setvalue("currentbtxdataset",dataset)
--- print(variant,sorttype,compress)
action(dataset,rest,mark ~= false,compress,variant)
end
end
@@ -1167,9 +1176,17 @@ end
-- sorter
-local function compresslist(source,key)
+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
+ 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
@@ -1189,7 +1206,7 @@ local function compresslist(source,key)
end
for i=1,#source do
local entry = source[i]
- local current = entry[key]
+ local current = entry.sortkey
if not first then
first, last, firstr, lastr = current, current, entry, entry
elseif current == last + 1 then
@@ -1212,35 +1229,96 @@ end
-- { tag = "three", internal = 3, value = "gnu", page = 3 },
-- }
--
--- local target = compresslist(source,"page")
+-- local target = compresslist(source)
-function citevariants.default(dataset,reference,mark,compress,variant,setup)
+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)
local found, todo, list = findallused(dataset,reference)
- if found then
- local valid = { }
+ 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 value = getfield(dataset,tag,variant)
- if value then
- valid[#valid+1] = { tag, entry.references.internal, value }
+ 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
- local function flush(i,state)
- local data = valid[i]
- if mark then
- local tag = data[1]
- markcite(dataset,tag)
- todo[tag] = false
+ 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
+ if mark then
+ local tags = entry.tags
+ for i=1,#tags do
+ local tag = tags[i]
+ markcite(dataset,tag)
+ todo[tag] = false
+ end
+ end
+ 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
+ if mark then
+ local tag = entry.tag
+ markcite(dataset,tag)
+ todo[tag] = false
+ end
+ 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
- ctx_btxsetinternal(data[2])
- ctx_btxsetconcat(state)
- ctx_btxsetfirst(data[3])
- ctx_btxcitesetup(setup or variant)
- end
- flushcollected(flush,#valid)
- if mark and #valid == #found then
- mark = false
+ flushcollected(flush,#target)
+ else
+ local function flush(i,state)
+ local entry = source[i]
+ local tag = entry.tag
+ if mark then
+ markcite(dataset,tag)
+ todo[tag] = false
+ end
+ 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
end
if mark then
@@ -1248,319 +1326,380 @@ function citevariants.default(dataset,reference,mark,compress,variant,setup)
end
end
-table.setmetatableindex(citevariants,function(t,k)
+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
+
+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.short(dataset,reference,mark,compress)
- local found, todo, list = findallused(dataset,reference)
- if found then
- local valid = { }
- for i=1,#found do
- local entry = found[i]
- local tag = entry.userdata.btxref
- local short = getdetail(dataset,tag,"short")
- if short then
- valid[#valid+1] = { tag, entry.references.internal, short, getdetail(dataset,tag,"suffix") }
- end
- end
- local function flush(i,state)
- local data = valid[i]
- local short = data[3]
- local suffix = data[4]
- if mark then
- local tag = data[1]
- markcite(dataset,tag)
- todo[tag] = false
- end
- ctx_btxsetinternal(data[2])
- ctx_btxsetconcat(state)
- if suffix then
- ctx_btxsetfirst(short .. suffix)
- else
- ctx_btxsetfirst(short)
- end
- ctx_btxcitesetup("short")
- end
- flushcollected(flush,#valid)
- if mark and #valid == #found then
- mark = false
+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
- end
- if mark then
- flushmarked(dataset,list,todo)
+ return true
end
end
--- no compress
+function citevariants.short(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,false,"short",setter,getter)
+end
-function citevariants.page(dataset,reference,mark,compress)
- local found, todo, list = findallused(dataset,reference)
- if found then
- local valid = { }
- for i=1,#found do
- local entry = found[i]
- local tag = entry.userdata.btxref
- local pages = getdetail(dataset,tag,"pages")
- if pages then
- valid[#valid+1] = { tag, entry.references.internal, pages }
- end
- end
- local function flush(i,state)
- local data = valid[i]
- local pages = data[3]
- if mark then
- local tag = data[1]
- markcite(dataset,tag)
- todo[tag] = false
- end
- ctx_btxsetinternal(data[2])
- ctx_btxsetconcat(state)
- if type(pages) == "table" then
- ctx_btxsetfirst(pages[1])
- ctx_btxsetsecond(pages[2])
- else
- ctx_btxsetfirst(pages)
- end
- ctx_btxcitesetup("page")
- end
- flushcollected(flush,#valid)
- if mark and #valid == #found then
- mark = false
+-- 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
- end
- if mark then
- flushmarked(dataset,list,todo)
+ return true
end
end
--- compress: 1-4, 5, 8-10
+function citevariants.page(dataset,reference,mark,compress)
+ processcite(dataset,reference,mark,compress,"page",setter,getter)
+end
--- 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 = compress(source,"page")
+-- 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)
- local found, todo, list = findallused(dataset,reference)
- if found then
- if compress then
- local source = { }
- for i=1,#found do
- local entry = found[i]
- local text = entry.entries.text
- local key = tonumber(text)
- if not key then
- source = false
- break
- end
- source[i] = {
- tag = entry.userdata.btxref,
- internal = entry.references.internal,
- text = text,
- sortkey = key,
- }
- end
- if source then
- local target = compresslist(source,"sortkey")
- local function flush(i,state)
- local entry = target[i]
- local first = entry.first
- if first then
- if mark then
- local tags = entry.tags
- for i=1,#tags do
- local tag = tags[i]
- markcite(dataset,tag)
- todo[tag] = false
- end
- end
- ctx_btxsetinternal(first.internal)
- ctx_btxsetfirst(first.text)
- ctx_btxsetsecond(entry.last.text)
- else
- if mark then
- local tag = entry.tag
- markcite(dataset,tag)
- todo[tag] = false
- end
- ctx_btxsetinternal(entry.internal)
- ctx_btxsetfirst(entry.text)
- end
- ctx_btxsetconcat(state)
- ctx_btxcitesetup("num")
- end
- flushcollected(flush,#target)
- return
- else
- -- fall through
- end
- end
- local function flush(i,state)
- local entry = found[i]
- if mark then
- local tag = entry.userdata.btxref
- markcite(dataset,tag)
- todo[tag] = false
- end
- ctx_btxsetinternal(entry.references.internal)
- ctx_btxsetconcat(state)
- ctx_btxsetfirst(entry.entries.text)
- ctx_btxcitesetup("num")
- end
- flushcollected(flush,#found)
- end
- if mark then
- flushmarked(dataset,list,todo)
- end
+ 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
-function citevariants.type (dataset,reference,mark,compress) return citevariants.default(dataset,reference,mark,compress,"category","type") end -- synonyms
-function citevariants.key (dataset,reference,mark,compress) return citevariants.default(dataset,reference,mark,compress,"tag","key") end -- synonyms
-function citevariants.serial(dataset,reference,mark,compress) return citevariants.default(dataset,reference,mark,compress,"index","serial") end -- synonyms
+-- 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,tag)
- local luadata = datasets[dataset].luadata
- local list = settings_to_array(tag)
- 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
- end
+ 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
- result[i] = { author = author, years = yrs }
end
- return result, order
+ -- todo: add letters (should we then tag all?)
+ return result
end
--- (name, name and name) .. how names? how sorted?
--- todo: we loop at the tex end .. why not here
--- \cite[{hh,afo},kvm]
-
-function citevariants.author(dataset,reference,mark,compress)
- local found, todo, list = findallused(dataset,reference)
- if found then
- local function flush(i,state)
- local entry = found[i]
- local tag = entry.userdata.btxref
- if mark then
- markcite(dataset,tag)
- todo[tag] = false
+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_btxsetinternal(entry.references.internal)
- ctx_btxsetconcat(state)
- ctx_btxsetfirst(getfield(dataset,tag,"author")) -- todo: reformat
- ctx_btxcitesetup("author")
+ ctx_btxsetfirst(entry[key] or f_missing(entry.tag))
end
- flushcollected(flush,#found)
+ ctx_btxsetconcat(state)
+ ctx_btxcitesetup(setup)
end
- if mark then
- flushmarked(dataset,list,todo)
+ ctx_btxstartsubcite(setup)
+ flushcollected(flush,#target)
+ ctx_btxstopsubcite()
+end
+
+local function authorsingle(entry,key,setup)
+ ctx_btxstartsubcite(setup)
+ ctx_btxsetfirst(entry[key] or f_missing(entry.tag))
+ ctx_btxcitesetup(setup)
+ ctx_btxstopsubcite()
+end
+
+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
+
+-- 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 = lpegmatch(numberonly,text)
+ }
+end
+
+local function getter(first,last)
+ authorgetter(first,last,"num","author:num")
+ return true
+end
+
+local function compressor(found)
+ return authorcompressor(found,"num")
end
function citevariants.authornum(dataset,reference,mark,compress)
- local found, todo, list = findallused(dataset,reference)
- if found then
- local function flush(i,state)
- local entry = found[i]
- local tag = entry.userdata.btxref
- if mark then
- markcite(dataset,tag)
- todo[tag] = false
- end
- ctx_btxsetinternal(entry.references.internal)
- ctx_btxsetconcat(state)
- ctx_btxsetfirst(getfield(dataset,tag,"author")) -- todo: reformat
- ctx_btxsetsecond(entry.entries.text)
- ctx_btxcitesetup("authornum")
- end
- flushcollected(flush,#found)
- end
- if mark then
- flushmarked(dataset,list,todo)
- end
+ processcite(dataset,reference,mark,compress,"authornum",setter,getter,compressor)
end
--- local result, order = collectauthoryears(dataset,tag) -- we can have a collectauthors
+-- authoryear | authoryears
-local function authorandyear(dataset,reference,mark,compress,setup)
- local found, todo, list = findallused(dataset,reference)
- if found then
- local function flush(i,state)
- local entry = found[i]
- local tag = entry.userdata.btxref
- if mark then
- markcite(dataset,tag)
- todo[tag] = false
- end
- ctx_btxsetinternal(entry.references.internal)
- ctx_btxsetconcat(state)
- ctx_btxsetfirst(getfield(dataset,tag,"author")) -- todo: reformat
- ctx_btxsetsecond(getfield(dataset,tag,"year"))
- ctx_btxcitesetup(setup)
- end
- flushcollected(flush,#found)
- end
- if mark then
- flushmarked(dataset,list,todo)
- end
+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 = lpegmatch(numberonly,year)
+ }
+end
+
+local function getter(first,last)
+ authorgetter(first,last,"year","author:year")
+ return true
+end
+
+local function compressor(found)
+ return authorcompressor(found,"year")
end
function citevariants.authoryear(dataset,reference,mark,compress)
- authorandyear(dataset,reference,mark,compress,"authoryear")
+ processcite(dataset,reference,mark,compress,"authoryear",setter,getter,compressor)
+end
+
+local function getter(first,last)
+ authorgetter(first,last,"year","author:years")
+ return true
end
function citevariants.authoryears(dataset,reference,mark,compress)
- authorandyear(dataset,reference,mark,compress,"authoryears")
+ processcite(dataset,reference,mark,compress,"authoryears",setter,getter,compressor)
end
-- List variants
@@ -1568,16 +1707,6 @@ end
local listvariants = { }
publications.listvariants = listvariants
--- function commands.btxhandlelist(dataset,block,tag,variant,setup)
--- if sorttype and sorttype ~= "" then
--- tag = sortedtags(dataset,tag,sorttype)
--- end
--- ctx_setvalue("currentbtxtag",tag)
--- ctx_btxlistvariantparameter(v_left)
--- ctx_directsetup(setup)
--- ctx_btxlistvariantparameter(v_right)
--- end
-
function commands.btxlistvariant(dataset,block,tag,variant,listindex)
local action = listvariants[variant] or listvariants.default
if action then
@@ -1608,141 +1737,3 @@ function listvariants.short(dataset,block,tag,variant,listindex)
context(short)
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
-
--- 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.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
diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv
index 45cc7325a..ab20d2fd9 100644
--- a/tex/context/base/publ-ini.mkiv
+++ b/tex/context/base/publ-ini.mkiv
@@ -45,6 +45,8 @@
\unprotect
+\startcontextdefinitioncode
+
\def\s!btx {btx}
\def\s!cite {cite}
\def\v!btxlist{btxlist}
@@ -720,12 +722,18 @@
\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}%
@@ -733,7 +741,17 @@
\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%
@@ -761,14 +779,22 @@
\letbtxcitevariantparameter\c!alternative\currentbtxcitevariant
\btxcitevariantparameter\v!left
\edef\p_compress{\btxcitevariantparameter\c!compress}%
- \ctxcommand{btxhandlecite(%
- "\currentbtxdataset",%
- "#1",%
- \iftrialtypesetting false\else true\fi,%
- "\currentbtxcitevariant",%
- "\btxcitevariantparameter\c!sorttype",%
- \ifx\p_compress\v!no false\else true\fi%
- )}%
+% \ctxcommand{btxhandlecite(%
+% "\currentbtxdataset",%
+% "#1",%
+% \iftrialtypesetting false\else true\fi,%
+% "\currentbtxcitevariant",%
+% "\btxcitevariantparameter\c!sorttype",%
+% \ifx\p_compress\v!yes true\else false\fi%
+% )}%
+ \ctxcommand{btxhandlecite{%
+ dataset = "\currentbtxdataset",%
+ reference = "#1",%
+ markentry = \iftrialtypesetting false\else true\fi,%
+ variant = "\currentbtxcitevariant",%
+ sorttype = "\btxcitevariantparameter\c!sorttype",%
+ compress = \ifx\p_compress\v!yes true\else false\fi,%
+ }}%
\btxcitevariantparameter\v!right
\endgroup}
@@ -830,6 +856,16 @@
\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:
\def\currentbtxindex{0}
@@ -855,6 +891,8 @@
\loadbtxdefinitionfile[\btxrenderingparameter\c!alternative]
\to \everysetupbtxrendering
+\stopcontextdefinitioncode
+
%D Defaults:
\setupbtxrendering
@@ -884,6 +922,7 @@
\c!finalpubsep={ and },
\c!compress=\v!no,
\c!inbetween={ },
+ \c!range=\endash,
\c!left=,
\c!middle=,
\c!right=]
@@ -896,6 +935,11 @@
\c!right={)}]
\definebtxcitevariant
+ [authornum]
+ [author]
+ [\c!inbetween={ }]
+
+\definebtxcitevariant
[authoryear]
[\c!compress=\v!yes,
\c!inbetween={, },
@@ -908,16 +952,27 @@
[authoryear]
\definebtxcitevariant
+ [author:num]
[authornum]
- [author]
- [num:\c!left={[},
- num:\c!right={]},
- num:\c!middle={, }]
+ [\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={, },
+ \c!middle={, }, % is middle used?
\c!right={)}]
\definebtxcitevariant
@@ -974,13 +1029,11 @@
[page]
[\c!left=,
\c!middle={, },
- \c!right=,
- \c!inbetween=\endash]
+ \c!right=]
\definebtxcitevariant
[num]
[\c!compress=\v!yes,
- \c!inbetween={--},
\c!left={[},
\c!middle={, },
\c!right={]}]
diff --git a/tex/context/base/spac-chr.lua b/tex/context/base/spac-chr.lua
index 1abba350a..5b3a15478 100644
--- a/tex/context/base/spac-chr.lua
+++ b/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/tex/context/base/spac-chr.mkiv b/tex/context/base/spac-chr.mkiv
index 54a25be34..f9dc6e16b 100644
--- a/tex/context/base/spac-chr.mkiv
+++ b/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/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index b9aff479b..87359fbfc 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 110046752..1206b6e33 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua
index 5a8bdabd3..d52399bcf 100644
--- a/tex/context/base/trac-deb.lua
+++ b/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
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 51d861af4..70a395d7b 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 05/15/14 19:52:15
+-- merge date : 05/16/14 20:08:26
do -- begin closure to overcome local limits and interference