diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-syn.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-syn.lua | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-syn.lua b/Master/texmf-dist/tex/context/base/strc-syn.lua index d9b7b9a572e..d6f38c2c7f6 100644 --- a/Master/texmf-dist/tex/context/base/strc-syn.lua +++ b/Master/texmf-dist/tex/context/base/strc-syn.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['str-syn'] = { version = 1.001, - comment = "companion to str-syn.tex", + comment = "companion to str-syn.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" @@ -24,7 +24,9 @@ local function initializer() end local function finalizer() - tobesaved.hash = nil + for entry, data in next, tobesaved do + data.hash = nil + end end job.register('joblists.collected', joblists.tobesaved, initializer, finalizer) @@ -56,8 +58,18 @@ end function joblists.register(class,kind,spec) local data = allocate(class) data.metadata.kind = kind -- runtime, not saved in format (yet) - data.entries[#data.entries+1] = spec - data.hash[spec.definition.tag or ""] = spec + if not data.hash[spec.definition.tag or ""] then + data.entries[#data.entries+1] = spec + data.hash[spec.definition.tag or ""] = spec + end +end + +function joblists.registerused(class,tag) + local data = allocate(class) + local dht = data.hash[tag] + if dht then + dht.definition.used = true + end end function joblists.synonym(class,tag) @@ -80,9 +92,7 @@ function joblists.meaning(class,tag) end end -function joblists.compare(a,b) - return sorters.comparers.basic(a.split,b.split) -end +joblists.compare = sorters.comparers.basic -- (a,b) function joblists.filter(data,options) local result = { } @@ -124,7 +134,7 @@ function joblists.finalize(data,options) local split = { } for k=1,#result do local v = result[k] - local entry, tag = sorters.firstofsplit(v.split) + local entry, tag = sorters.firstofsplit(v) local s = split[entry] -- keeps track of change if not s then s = { tag = tag, data = { } } @@ -137,19 +147,21 @@ end function joblists.flush(data,options) -- maybe pass the settings differently local kind = data.metadata.kind -- hack, will be done better - texsprint(ctxcatcodes,format("\\start%soutput",kind)) +--~ texsprint(ctxcatcodes,format("\\start%soutput",kind)) local result = data.result - for k, letter in ipairs(table.sortedkeys(result)) do + local sorted = table.sortedkeys(result) + for k=1,#sorted do + local letter = sorted[k] local sublist = result[letter] local data = sublist.data - texsprint(ctxcatcodes,format("\\start%ssection{%s}",kind,sublist.tag)) +--~ texsprint(ctxcatcodes,format("\\start%ssection{%s}",kind,sublist.tag)) for d=1,#data do local entry = data[d].definition - texsprint(ctxcatcodes,format("\\%sentry{%s}{%s}{%s}",kind,d,entry.synonym,entry.meaning)) + texsprint(ctxcatcodes,format("\\%sentry{%s}{%s}{%s}{%s}",kind,d,entry.tag,entry.synonym,entry.meaning or "")) end - texsprint(ctxcatcodes,format("\\stop%ssection",kind)) +--~ texsprint(ctxcatcodes,format("\\stop%ssection",kind)) end - texsprint(ctxcatcodes,format("\\stop%soutput",kind)) +--~ texsprint(ctxcatcodes,format("\\stop%soutput",kind)) -- for now, maybe at some point we will do a multipass or so data.result = nil data.metadata.sorted = false @@ -158,6 +170,8 @@ end function joblists.analysed(class,options) local data = joblists.collected[class] if data and data.entries then + options = options or { } + sorters.setlanguage(options.language) joblists.filter(data,options) -- filters entries to result joblists.prepare(data,options) -- adds split table parallel to list table joblists.sort(data,options) -- sorts entries in result |