summaryrefslogtreecommitdiff
path: root/tex/context/base/bibl-tra.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/bibl-tra.lua')
-rw-r--r--tex/context/base/bibl-tra.lua84
1 files changed, 22 insertions, 62 deletions
diff --git a/tex/context/base/bibl-tra.lua b/tex/context/base/bibl-tra.lua
index 39eae3bcd..6a7016023 100644
--- a/tex/context/base/bibl-tra.lua
+++ b/tex/context/base/bibl-tra.lua
@@ -6,41 +6,26 @@ if not modules then modules = { } end modules ['bibl-tra'] = {
license = "see context related readme files"
}
--- also see bibl-tra-new !
-
-local match, gmatch, format, concat, sort = string.match, string.gmatch, string.format, table.concat, table.sort
-
bibtex = bibtex or { }
local bibtex = bibtex
bibtex.hacks = bibtex.hacks or { }
local hacks = bibtex.hacks
+local match, gmatch, format, concat, sort = string.match, string.gmatch, string.format, table.concat, table.sort
+local variables, constants = interfaces.variables, interfaces.constants
+
local trace_bibtex = false trackers.register("publications.bibtex", function(v) trace_bibtex = v end)
local report_tex = logs.reporter("publications","tex")
-local context = context
-local structures = structures
+local context, structures = context, structures
-local references = structures.references
-local sections = structures.sections
+local references = structures.references
+local sections = structures.sections
-local variables = interfaces.variables
-
-local v_short = variables.short
-local v_cite = variables.cite
-local v_default = variables.default
-local v_reference = variables.default
-
-local list = { }
-local done = { }
-local alldone = { }
-local used = { }
-local registered = { }
-local ordered = { }
-local shorts = { }
-local mode = 0
+local list, done, alldone, used, registered, ordered = { }, { }, { }, { }, { }, { }
+local mode = 0
local template = utilities.strings.striplong([[
\citation{*}
@@ -69,17 +54,12 @@ function hacks.process(settings)
end
end
-function hacks.register(tag,short)
- if not short or short == "" then
- short = tag
- end
+function hacks.register(str)
if trace_bibtex then
- report_tex("registering bibtex entry %a with shortcut %a",tag,short)
+ report_tex("registering bibtex entry %a",str)
end
- local top = #registered + 1
- registered[top] = tag
- ordered [tag] = top
- shorts [tag] = short
+ registered[#registered+1] = str
+ ordered[str] = #registered
end
function hacks.nofregistered()
@@ -110,38 +90,19 @@ function hacks.add(str,listindex)
end
end
+local function compare(a,b) -- quite some checking for non-nil
+ local aa, bb = a and a[1], b and b[1]
+ if aa and bb then
+ local oa, ob = ordered[aa], ordered[bb]
+ return oa and ob and oa < ob
+ end
+ return false
+end
+
function hacks.flush(sortvariant)
- local compare -- quite some checking for non-nil
- if sortvariant == "" or sortvariant == v_cite or sortvariant == v_default then
+ if sortvariant == "" or sortvariant == variables.cite or sortvariant == "default" then
-- order is cite order i.e. same as list
- elseif sortvariant == v_short then
- compare = function(a,b)
- local aa, bb = a and a[1], b and b[1]
- if aa and bb then
- local oa, ob = shorts[aa], shorts[bb]
- return oa and ob and oa < ob
- end
- return false
- end
- elseif sortvariant == v_reference then
- compare = function(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
else
- compare = function(a,b)
- local aa, bb = a and a[1], b and b[1]
- if aa and bb then
- local oa, ob = ordered[aa], ordered[bb]
- return oa and ob and oa < ob
- end
- return false
- end
- end
- if compare then
sort(list,compare)
end
for i=1,#list do
@@ -274,7 +235,6 @@ function hacks.resolve(prefix,block,reference) -- maybe already feed it split
if c[3] then
context.dowithbibtexnumrefrange(#collected,i,prefix,c[1],c[2],c[3],c[4])
else
--- print(#collected,i,prefix,c[1],c[2])
context.dowithbibtexnumref(#collected,i,prefix,c[1],c[2])
end
end