diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-12-31 21:15:05 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-12-31 21:15:05 +0100 |
commit | 2e0731c0e1b16577a3cc394aad3e0734560d60c6 (patch) | |
tree | f57431d4eaa68b0502b54b3cce5244002f20cecd /tex | |
parent | f3d55cd2bd81fbf44a74e44686fc7b4675bce31f (diff) | |
download | context-2e0731c0e1b16577a3cc394aad3e0734560d60c6.tar.gz |
2014-12-31 20:44:00
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4385 -> 4385 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/publ-aut.lua | 201 | ||||
-rw-r--r-- | tex/context/base/publ-dat.lua | 17 | ||||
-rw-r--r-- | tex/context/base/publ-ini.lua | 43 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24873 -> 24868 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 345975 -> 356725 bytes | |||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
9 files changed, 228 insertions, 39 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index ed1b174c8..e642b5be1 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.12.31 16:52} +\newcontextversion{2014.12.31 20:42} %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 Binary files differindex c9fef1602..5b1834d62 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index f8c1bd0be..abac94514 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.12.31 16:52} +\edef\contextversion{2014.12.31 20:42} \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 ea86e702a..01b41c167 100644 --- a/tex/context/base/publ-aut.lua +++ b/tex/context/base/publ-aut.lua @@ -458,14 +458,97 @@ end -- first : key author editor publisher title journal volume number pages -- second: year suffix title month day journal volume number -local function indexer(dataset,list,method) - local current = datasets[dataset] - local luadata = current.luadata - local details = current.details - local result = { } - local splitted = newsplitter(splitter) -- saves mem - local snippets = { } -- saves mem - local field = "author" -- todo +-- local function indexer(dataset,list,method) +-- local current = datasets[dataset] +-- local luadata = current.luadata +-- local details = current.details +-- local result = { } +-- local splitted = newsplitter(splitter) -- saves mem +-- local snippets = { } -- saves mem +-- local field = "author" -- todo +-- for i=1,#list do +-- -- either { tag, tag, ... } or { { tag, index }, { tag, index } } +-- local li = list[i] +-- local tag = type(li) == "string" and li or li[1] +-- local index = tostring(i) +-- local entry = luadata[tag] +-- if entry then +-- local value = getcasted(current,tag,field) or "" +-- local mainkey = writer(value,snippets) +-- local detail = details[tag] +-- result[i] = { +-- index = i, +-- split = { +-- splitted[entry.key or "" ], +-- splitted[strip(mainkey) ], +-- splitted[entry.year or "9998"], +-- splitted[detail.suffix or " " ], +-- splitted[entry.month or "13" ], +-- splitted[entry.day or "32" ], +-- splitted[strip(entry.journal or "" )], +-- splitted[strip(entry.volume or "" )], +-- splitted[strip(entry.number or "" )], +-- splitted[strip(entry.title or "" )], +-- splitted[entry.pages or "" ], +-- splitted[index], +-- }, +-- } +-- else +-- result[i] = { +-- index = i, +-- split = { +-- splitted[""], -- key +-- splitted[""], -- mainkey +-- splitted["9999"], -- year +-- splitted[" "], -- suffix +-- splitted["14"], -- month +-- splitted["33"], -- day +-- splitted[""], -- journal +-- splitted[""], -- volume +-- splitted[""], -- number +-- splitted[""], -- title +-- splitted[""], -- pages +-- splitted[index], -- index +-- }, +-- } +-- end +-- end +-- return result +-- end + +-- if needed we can optimize this one: chekc if it's detail or something else +-- and use direct access, but in practice it's fast enough + +local template = [[ +local type, tostring = type, tostring + +local writers = publications.writers +local datasets = publications.datasets +local getter = publications.getfaster -- (current,data,details,field,categories,types) +local strip = sorters.strip +local splitter = sorters.splitters.utf + +local function newsplitter(splitter) + return table.setmetatableindex({},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) +end + +return function(dataset,list,method) -- indexer + local current = datasets[dataset] + local luadata = current.luadata + local details = current.details + local specification = publications.currentspecification + local categories = specification.categories + local types = specification.types + local splitted = newsplitter(splitter) -- saves mem + local snippets = { } -- saves mem + local result = { } + +%helpers% + for i=1,#list do -- either { tag, tag, ... } or { { tag, index }, { tag, index } } local li = list[i] @@ -473,23 +556,14 @@ local function indexer(dataset,list,method) local index = tostring(i) local entry = luadata[tag] if entry then - local value = getcasted(current,tag,field) or "" - local mainkey = writer(value,snippets) local detail = details[tag] result[i] = { index = i, split = { - splitted[entry.key or "" ], - splitted[strip(mainkey) ], - splitted[entry.year or "9998"], - splitted[detail.suffix or " " ], - splitted[entry.month or "13" ], - splitted[entry.day or "32" ], - splitted[strip(entry.journal or "" )], - splitted[strip(entry.volume or "" )], - splitted[strip(entry.number or "" )], - splitted[strip(entry.title or "" )], - splitted[entry.pages or "" ], + splitted[entry.key or ""], + +%getters% + splitted[index], }, } @@ -497,24 +571,85 @@ local function indexer(dataset,list,method) result[i] = { index = i, split = { - splitted[""], -- key - splitted[""], -- mainkey - splitted["9999"], -- year - splitted[" "], -- suffix - splitted["14"], -- month - splitted["33"], -- day - splitted[""], -- journal - splitted[""], -- volume - splitted[""], -- number - splitted[""], -- title - splitted[""], -- pages - splitted[index], -- index + splitted[""], + +%unknowns% + + splitted[index], }, } end end return result end +]] + +local f_getter = formatters["splitted[strip(getter(current,entry,detail,%q,categories,types) or %q)], -- %s"] +local f_writer = formatters["splitted[strip(writer_%s(getter(current,entry,detail,%q,categories,types) or %q,snippets))], -- %s"] +local f_helper = formatters["local writer_%s = writers[%q] -- %s: %s"] +local f_value = formatters["splitted[%q], -- %s"] + +local function indexer(dataset,list,method) + local writers = publications.writers + local specification = publications.currentspecification + ----- categories = specification.categories + local types = specification.types + + local getters = { } + local unknowns = { } + local helpers = { } + + local sequence = { + -- always key first (or should that be made explicit) + { field = "author", default = "", unknown = "" }, + { field = "year", default = "9998", unknown = "9999" }, + { field = "suffix", default = " ", unknown = " " }, + { field = "month", default = "13", unknown = "14" }, + { field = "day", default = "32", unknown = "33" }, + { field = "journal", default = "", unknown = "" }, + { field = "volume", default = "", unknown = "" }, + { field = "number", default = "", unknown = "" }, + { field = "title", default = "", unknown = "" }, + { field = "pages", default = "", unknown = "" }, + -- always index last (to catch duplicates) + } + + for i=1,#sequence do + local step = sequence[i] + local field = step.field or "?" + local default = step.default or "" + local unknown = step.unknown or "" + local fldtype = types[field] + local writer = fldtype and writers[fldtype] + if writer then + local h = #helpers + 1 + getters[i] = f_writer(h,field,default,field) + helpers[h] = f_helper(h,fldtype,field,fldtype) + else + getters[i] = f_getter(field,default,field) + end + unknowns[i] = f_value(unknown,field) + end + + local code = utilities.templates.replace(template, { + helpers = concat(helpers, "\n"), + getters = concat(getters, "\n"), + unknowns = concat(unknowns,"\n"), + }) + + -- print(code) + + local action, error = loadstring(code) + if type(action) == "function" then + action = action() + end + if type(action) == "function" then + return action(dataset,list,method) or { } + else + return { } + end + +end -- local function sorted(dataset,list) -- experimental -- local valid = indexer(dataset,list,sorttype) diff --git a/tex/context/base/publ-dat.lua b/tex/context/base/publ-dat.lua index f022f6ade..dcaabb015 100644 --- a/tex/context/base/publ-dat.lua +++ b/tex/context/base/publ-dat.lua @@ -1040,6 +1040,15 @@ do return lpegmatch(keywordsplitter,str) end + + writers.keyword = function(k) + if type(k) == "table" then + return concat(p,";") + else + return k + end + end + local pagessplitter = lpeg.splitat(P("-")^1) casters.pagenumber = function(str) @@ -1047,4 +1056,12 @@ do return first and last and { first, last } or str end + writers.pagenumber = function(p) + if type(p) == "table" then + return concat(p,"-") + else + return p + end + end + end diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 43cc37fc2..120957034 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -174,15 +174,17 @@ function commands.registerbtxlistvariant(name,parent) registeredlistvariants[name] = parent or "" end -local specifications = publications.specifications -local currentspecification = specifications[false] -local ignoredfields = { } +local specifications = publications.specifications +local currentspecification = specifications[false] +local ignoredfields = { } +publications.currentspecification = currentspecification local function setspecification(name) currentspecification = specifications[name] if trace then report("setting specification %a",type(name) == "string" and name or "anything") end + publications.currentspecification = currentspecification end publications.setspecification = setspecification @@ -695,6 +697,40 @@ local function getcasted(dataset,tag,field,specification) end end +local function getfaster(current,data,details,field,categories,types) + local category = data.category + local catspec = categories[category] + if not catspec then + return false + end + local fields = catspec.fields + if fields then + local sets = catspec.sets + if sets then + local set = sets[field] + if set then + for i=1,#set do + local field = set[i] + local value = fields[field] and data[field] -- redundant check + if value then + local kind = types[field] + return detailed[kind][value], field, kind + end + end + end + end + local value = fields[field] and data[field] -- redundant check + if value then + local kind = types[field] + return detailed[kind][value] + end + end + if details then + local kind = types[field] + return details[field] + end +end + local function getdirect(dataset,data,field,catspec) -- no field check, no dataset check local catspec = (catspec or currentspecification).categories[data.category] if not catspec then @@ -720,6 +756,7 @@ local function getdirect(dataset,data,field,catspec) -- no field check, no datas end publications.getcasted = getcasted +publications.getfaster = getfaster publications.getdirect = getdirect function commands.btxsingularorplural(dataset,tag,name) diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 85959a730..6ded1f9a4 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex a62ccd5b5..bb67d0ed5 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 6500989cc..3d5443875 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 : 12/31/14 16:52:11 +-- merge date : 12/31/14 20:42:33 do -- begin closure to overcome local limits and interference |