summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2014-01-19 18:00:16 +0200
committerMarius <mariausol@gmail.com>2014-01-19 18:00:16 +0200
commit7dcecfee460bf9abee52a52597fd16c44c292ff9 (patch)
tree318fcb1e3fdae506e6189beb7c10b42acc3c8274
parent2cfd594ab60ba445bc2efac7a2eac2d6df23f3b9 (diff)
downloadcontext-7dcecfee460bf9abee52a52597fd16c44c292ff9.tar.gz
beta 2014.01.19 16:44
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4083 -> 4085 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/publ-aut.lua132
-rw-r--r--tex/context/base/publ-ini.lua28
-rw-r--r--tex/context/base/status-files.pdfbin24795 -> 24797 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin229198 -> 229081 bytes
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
8 files changed, 125 insertions, 41 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 3c2859c98..2f5668663 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.01.19 00:10}
+\newcontextversion{2014.01.19 16:44}
%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 6d5db6f4a..12b8b4672 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 90d9cb30e..85f99f501 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.01.19 00:10}
+\edef\contextversion{2014.01.19 16:44}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/publ-aut.lua b/tex/context/base/publ-aut.lua
index 92069245b..0fc2670c4 100644
--- a/tex/context/base/publ-aut.lua
+++ b/tex/context/base/publ-aut.lua
@@ -99,6 +99,7 @@ local function splitauthorstring(str)
if not detail then
local firstnames, vons, surnames, initials, juniors
local split = lpegmatch(commasplitter,author)
+-- inspect(split)
local n = #split
if n == 1 then
-- First von Last
@@ -121,7 +122,7 @@ local function splitauthorstring(str)
vons[#vons+1], i = w, i + 1
end
end
- if i < n then
+ if i <= n then
while i <= n do
surnames[#surnames+1], i = words[i], i + 1
end
@@ -456,52 +457,121 @@ local strip = sorters.strip
local splitter = sorters.splitters.utf
local sort = sorters.sort
-function authors.sorted(dataset,list,sorttype) -- experimental
- local luadata = datasets[dataset].details -- details
- local valid = { }
+-- function authors.preparedsort(dataset,list,sorttype)
+-- local luadata = datasets[dataset].luadata
+-- local details = datasets[dataset].details
+-- local valid = { }
+-- for i=1,#list do
+-- local tag = list[i]
+-- local entry = luadata[tag]
+-- local detail = details[tag]
+-- local suffix = tostring(i)
+-- local split = nil
+-- if entry and detail then
+-- local key = detail[sorttype]
+-- local year = entry.year or 9998
+-- if key then
+-- split = { }
+-- local n = #key
+-- if n > 0 then
+-- -- least efficient
+-- for i=1,n do
+-- local k = key[i]
+-- local vons = k.vons
+-- local surs = k.surnames
+-- local vons = vons and concat(vons," ")
+-- local surs = surs and concat(surs," ") or ""
+-- local assembled = (vons and #vons > 0 and vons .. " " .. surs) or surs
+-- split[i] = splitter(strip(assembled),true)
+-- end
+-- split[n+1] = splitter(year,true)
+-- split[n+2] = splitter(suffix,true)
+-- else
+-- -- medium efficient
+-- local k = key[1]
+-- local vons = k.vons
+-- local surs = k.surnames
+-- local vons = vons and concat(vons," ")
+-- local surs = surs and concat(surs," ") or ""
+-- local assembled = ((vons and #vons > 0 and vons .. " " .. surs) or surs) .. ":" .. year .. ":" ..suffix
+-- split = splitter(strip(assembled),true)
+-- end
+-- else
+-- -- efficient fallback
+-- split = splitter(year .. ":" .. suffix,true)
+-- end
+-- else
+-- -- efficient fallback
+-- split = splitter("9999:" .. suffix,true)
+-- end
+-- valid[i] = {
+-- index = i,
+-- split = split,
+-- }
+-- end
+-- return valid
+-- end
+
+function authors.preparedsort(dataset,list,sorttype)
+ local luadata = datasets[dataset].luadata
+ local details = datasets[dataset].details
+ local valid = { }
+ local splitted = { }
+ table.setmetatableindex(splitted,function(t,k) -- could be done in the sorter but seldom that many shared
+ local v = splitter(k,true) -- in other cases
+ t[k] = v
+ return v
+ end)
for i=1,#list do
- local tag = list[i]
- local entry = luadata[tag]
- if entry then
- local key = entry[sorttype]
- local suf = tostring(i)
- local split
+ local tag = list[i]
+ local entry = luadata[tag]
+ local detail = details[tag]
+ local suffix = tostring(i)
+ if entry and detail then
+ local key = detail[sorttype]
+ local year = entry.year or "9998"
if key then
- split = { }
local n = #key
- if n > 0 then
- -- least efficient
- for i=1,n do
- local k = key[i]
- local vons = k.vons
- local surs = k.surnames
- local vons = vons and concat(vons," ")
- local surs = surs and concat(surs," ") or ""
- local assembled = (vons and #vons > 0 and vons .. " " .. surs) or surs
- split[i] = splitter(strip(assembled),true)
- end
- split[n+1] = splitter(suf)
- else
- -- medium efficient
- local k = key[1]
+ local split = { }
+ for i=1,n do
+ local k = key[i]
local vons = k.vons
local surs = k.surnames
local vons = vons and concat(vons," ")
local surs = surs and concat(surs," ") or ""
local assembled = (vons and #vons > 0 and vons .. " " .. surs) or surs
- split = splitter(strip(assembled..":"..suf),true)
+ split[i] = splitted[strip(assembled)]
end
+ split[n+1] = splitted[year]
+ split[n+2] = splitted[suffix]
+ valid[i] = {
+ index = i,
+ split = split,
+ }
else
- -- efficient fallback
- split = splitter(suf,true)
+ valid[i] = {
+ index = i,
+ split = {
+ splitted[year],
+ splitted[suffix],
+ }
+ }
end
+ else
valid[i] = {
index = i,
- split = split,
+ split = {
+ splitted["9999"],
+ splitted[suffix],
+ },
}
end
end
- -- inspect(valid)
+ return valid
+end
+
+function authors.sorted(dataset,list,sorttype) -- experimental
+ local valid = authors.preparedsort(dataset,list,sorttype)
if #valid == 0 or #valid ~= #list then
return list
else
diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua
index e8061a33b..ff5963173 100644
--- a/tex/context/base/publ-ini.lua
+++ b/tex/context/base/publ-ini.lua
@@ -42,6 +42,7 @@ local v_cite = variables.cite
local v_default = variables.default
local v_reference = variables.default
local v_dataset = variables.dataset
+local v_author = variables.author or "author"
local numbertochar = converters.characters
@@ -745,7 +746,7 @@ end
lists.sorters = {
[v_short] = function(dataset,rendering,list)
local shorts = rendering.shorts
- return function(a,b)
+ local function compare(a,b)
local aa, bb = a and a[1], b and b[1]
if aa and bb then
aa, bb = shorts[aa], shorts[bb]
@@ -753,18 +754,20 @@ lists.sorters = {
end
return false
end
+ sort(list,compare)
end,
[v_reference] = function(dataset,rendering,list)
- return function(a,b)
+ local function compare(a,b)
local aa, bb = a and a[1], b and b[1]
if aa and bb then
return aa and bb and aa < bb
end
return false
end
+ sort(list,compare)
end,
[v_dataset] = function(dataset,rendering,list)
- return function(a,b)
+ local function compare(a,b)
local aa, bb = a and a[1], b and b[1]
if aa and bb then
aa, bb = list[aa].index or 0, list[bb].index or 0
@@ -772,10 +775,11 @@ lists.sorters = {
end
return false
end
+ sort(list,compare)
end,
[v_default] = function(dataset,rendering,list) -- not really needed
local ordered = rendering.ordered
- return function(a,b)
+ local function compare(a,b)
local aa, bb = a and a[1], b and b[1]
if aa and bb then
aa, bb = ordered[aa], ordered[bb]
@@ -783,6 +787,19 @@ lists.sorters = {
end
return false
end
+ sort(list,compare)
+ end,
+ [v_author] = function(dataset,rendering,list)
+ local valid = publications.authors.preparedsort(dataset,list,v_author)
+ if #valid == 0 or #valid ~= #list then
+ -- nothing to sort
+ else
+ -- if needed we can wrap compare and use the list directly but this is cleaner
+ sort(valid,sorters.comparers.basic)
+ for i=1,#valid do
+ list[i] = valid[i].index
+ end
+ end
end,
}
@@ -791,9 +808,6 @@ function lists.flushentries(dataset,sortvariant)
local list = rendering.list
local compare = lists.sorters[sortvariant] or lists.sorters[v_default]
compare = type(compare) == "function" and compare(dataset,rendering,list)
- if compare then
- sort(list,compare)
- 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
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 118cfa85b..6d6b10a19 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 aaf1a3fe1..c54deb19a 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index ea6a3a34e..b30adf315 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 : 01/19/14 00:10:42
+-- merge date : 01/19/14 16:44:51
do -- begin closure to overcome local limits and interference