From 11620c88a569cbab66c50271f7cc41a4e99973ff Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 18 Jan 2014 14:40:15 +0200 Subject: beta 2014.01.18 13:23 --- tex/context/base/buff-ver.mkiv | 4 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4083 -> 4086 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/publ-aut.lua | 1 + tex/context/base/publ-dat.lua | 18 +- tex/context/base/publ-imp-apa.mkiv | 2 +- tex/context/base/publ-ini.lua | 300 +++++++++++---------- tex/context/base/publ-ini.mkiv | 7 +- tex/context/base/publ-tra.lua | 1 + tex/context/base/status-files.pdf | Bin 24779 -> 24785 bytes tex/context/base/status-lua.pdf | Bin 229284 -> 229057 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 13 files changed, 190 insertions(+), 149 deletions(-) (limited to 'tex') diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index bdde5df9d..6c4fb6fc1 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -758,8 +758,9 @@ \buff_verbatim_setup_line_numbering \buff_verbatim_initialize_typing_one \buff_verbatim_initialize_typing_two - \beginofverbatimlines \dostarttagged\t!verbatimblock{#1}% + \beginofverbatimlines + \dostarttagged\t!verbatimlines\empty \ctxcommand{typebuffer { name = "#2", strip = "\typingparameter\c!strip", @@ -772,6 +773,7 @@ }}% \dostoptagged \endofverbatimlines + \dostoptagged \stoppacked \typingparameter\c!after} diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index e142a9fc0..0e5cda579 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.17 22:09} +\newcontextversion{2014.01.18 13:23} %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 8e513604e..39af93301 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 0f06c39ce..b3743bbe3 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.17 22:09} +\edef\contextversion{2014.01.18 13:23} \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 985f70eae..12256f74e 100644 --- a/tex/context/base/publ-aut.lua +++ b/tex/context/base/publ-aut.lua @@ -11,6 +11,7 @@ if not characters then dofile(resolvers.findfile("char-ini.lua")) end +local context = context local chardata = characters.data local tostring = tostring diff --git a/tex/context/base/publ-dat.lua b/tex/context/base/publ-dat.lua index b1bf34265..049b97ad5 100644 --- a/tex/context/base/publ-dat.lua +++ b/tex/context/base/publ-dat.lua @@ -115,9 +115,13 @@ function publications.markasupdated(name) end setmetatableindex(datasets,function(t,k) - local v = publications.new(k) - datasets[k] = v - return v + if type(k) == "table" then + return k -- so we can use this accessor as checker + else + local v = publications.new(k) + datasets[k] = v + return v + end end) -- we apply some normalization @@ -259,6 +263,7 @@ local bibtotable = (space + forget + shortcut/do_shortcut + definition/do_defini -- converttoxml -> dataset.xmldata from dataset.luadata function publications.loadbibdata(dataset,content,source,kind) + dataset = datasets[dataset] statistics.starttiming(publications) publicationsstats.nofbytes = publicationsstats.nofbytes + #content dataset.nofbytes = dataset.nofbytes + #content @@ -286,6 +291,7 @@ local cleaner_2 = Cs ( ( local compact = false -- can be a directive but then we also need to deal with newlines ... not now function publications.converttoxml(dataset,nice) -- we have fields ! + dataset = datasets[dataset] local luadata = dataset and dataset.luadata if luadata then statistics.starttiming(publications) @@ -357,6 +363,7 @@ local loaders = publications.loaders or { } publications.loaders = loaders function loaders.bib(dataset,filename,kind) + dataset = datasets[dataset] local data = io.loaddata(filename) or "" if data == "" then report("empty file %a, nothing loaded",filename) @@ -367,6 +374,7 @@ function loaders.bib(dataset,filename,kind) end function loaders.lua(dataset,filename) -- if filename is a table we load that one + dataset = datasets[dataset] if type(dataset) == "table" then dataset = datasets[dataset] end @@ -383,6 +391,7 @@ function loaders.lua(dataset,filename) -- if filename is a table we load that on end function loaders.xml(dataset,filename) + dataset = datasets[dataset] local luadata = dataset.luadata local root = xml.load(filename) for entry in xmlcollected(root,"/bibtex/entry") do @@ -417,6 +426,7 @@ setmetatableindex(loaders,function(t,filetype) end) function publications.load(dataset,filename,kind) + dataset = datasets[dataset] statistics.starttiming(publications) local files = settings_to_array(filename) for i=1,#files do @@ -438,12 +448,14 @@ function publications.load(dataset,filename,kind) end end statistics.stoptiming(publications) + return dataset end local checked = function(s,d) d[s] = (d[s] or 0) + 1 end local checktex = ( (1-P("\\"))^1 + P("\\") * ((C(R("az","AZ")^1) * Carg(1))/checked))^0 function publications.analyze(dataset) + dataset = datasets[dataset] local data = dataset.luadata local categories = { } local fields = { } diff --git a/tex/context/base/publ-imp-apa.mkiv b/tex/context/base/publ-imp-apa.mkiv index 327daa986..2db044cbf 100644 --- a/tex/context/base/publ-imp-apa.mkiv +++ b/tex/context/base/publ-imp-apa.mkiv @@ -312,8 +312,8 @@ \btxcomma\btxflush{chapter} } \btxsetup{btx:apa:common:pages:pages} - \btxperiod } + \btxperiod } } } diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index afdc1b76a..e8061a33b 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -21,8 +21,6 @@ local lpegmatch = lpeg.match local report = logs.reporter("publications") local trace = false trackers.register("publications", function(v) trace = v end) -local context = context - local datasets = publications.datasets local variables = interfaces.variables @@ -52,6 +50,23 @@ local logspushtarget = logs.pushtarget local logspoptarget = logs.poptarget local csname_id = token.csname_id +local context = context + +local ctx_btxlistparameter = context.btxlistparameter +local ctx_btxcitevariantparameter = context.btxcitevariantparameter +local ctx_btxlistvariantparameter = context.btxlistvariantparameter +local ctx_btxdomarkcitation = context.btxdomarkcitation +local ctx_setvalue = context.setvalue +local ctx_firstoftwoarguments = context.firstoftwoarguments +local ctx_secondoftwoarguments = context.secondoftwoarguments +local ctx_firstofoneargument = context.firstofoneargument +local ctx_gobbleoneargument = context.gobbleoneargument +local ctx_btxdirectlink = context.btxdirectlink +local ctx_btxhandlelistentry = context.btxhandlelistentry +local ctx_btxchecklistentry = context.btxchecklistentry +local ctx_dodirectfullreference = context.dodirectfullreference +local ctx_directsetup = context.directsetup + statistics.register("publications load time", function() local publicationsstats = publications.statistics local nofbytes = publicationsstats.nofbytes @@ -403,11 +418,11 @@ function commands.btxdoifelse(name,tag,field) local data = dataset.luadata[tag] local value = data and data[field] if value and value ~= "" then - context.firstoftwoarguments() + ctx_firstoftwoarguments() return end end - context.secondoftwoarguments() + ctx_secondoftwoarguments() end function commands.btxdoif(name,tag,field) @@ -416,11 +431,11 @@ function commands.btxdoif(name,tag,field) local data = dataset.luadata[tag] local value = data and data[field] if value and value ~= "" then - context.firstofoneargument() + ctx_firstofoneargument() return end end - context.gobbleoneargument() + ctx_gobbleoneargument() end function commands.btxdoifnot(name,tag,field) @@ -429,11 +444,11 @@ function commands.btxdoifnot(name,tag,field) local data = dataset.luadata[tag] local value = data and data[field] if value and value ~= "" then - context.gobbleoneargument() + ctx_gobbleoneargument() return end end - context.firstofoneargument() + ctx_firstofoneargument() end -- -- alternative approach: keep data at the tex end @@ -445,12 +460,12 @@ function publications.listconcat(t) if n > 1 then if n > 2 then for i=2,n-1 do - context.btxlistparameter("sep") + ctx_btxlistparameter("sep") context(t[i]) end - context.btxlistparameter("finalsep") + ctx_btxlistparameter("finalsep") else - context.btxlistparameter("lastsep") + ctx_btxlistparameter("lastsep") end context(t[n]) end @@ -464,12 +479,12 @@ function publications.citeconcat(t) if n > 1 then if n > 2 then for i=2,n-1 do - context.btxcitevariantparameter("sep") + ctx_btxcitevariantparameter("sep") context(t[i]) end - context.btxcitevariantparameter("finalsep") + ctx_btxcitevariantparameter("finalsep") else - context.btxcitevariantparameter("lastsep") + ctx_btxcitevariantparameter("lastsep") end context(t[n]) end @@ -484,105 +499,105 @@ function publications.singularorplural(singular,plural) 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] = string.formatters["\\bibmaybeinteractive{%s}{%s}"](data.year[year[i]],year[i]) - end - end - context.setvalue("currentbibyear",concat(year,",")) - if author == "" then - context.setvalue("currentbibauthor","") - else -- needs checking - local authors = settings_to_array(author) -- {{}{}},{{}{}} - local nofauthors = #authors - if nofauthors == 1 then - if interaction then - author = string.formatters["\\bibmaybeinteractive{%s}{%s}"](data.name,author) - end - context.setvalue("currentbibauthor",author) - else - limit = limit or nofauthors - if interaction then - for i=1,#authors do - authors[i] = string.formatters["\\bibmaybeinteractive{%s}{%s}"](data.name,authors[i]) - end - end - if limit == 1 then - context.setvalue("currentbibauthor",authors[1] .. "\\bibalternative{otherstext}") - elseif limit == 2 and nofauthors == 2 then - context.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}" - context.setvalue("currentbibauthor",concat(authors,"",1,limit+1)) - else - authors[limit-1] = authors[limit-1] .. "\\bibalternative{andtext}" - context.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 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 local patterns = { "publ-imp-%s.mkiv", "publ-imp-%s.tex" } @@ -719,6 +734,11 @@ function lists.collectentries(specification) end end end + elseif method == v_dataset then + dataset = datasets[dataset] + for tag, data in table.sortedhash(dataset.luadata) do + list[#list+1] = { tag } + end end end @@ -775,16 +795,16 @@ function lists.flushentries(dataset,sortvariant) sort(list,compare) end for i=1,#list do - context.setvalue("currentbtxindex",i) - context.btxhandlelistentry(list[i][1]) -- we can pass i here too ... more efficient to avoid the setvalue + ctx_setvalue("currentbtxindex",i) + ctx_btxhandlelistentry(list[i][1]) -- we can pass i here too ... more efficient to avoid the setvalue end end function lists.fetchentries(dataset) local list = renderings[dataset].list for i=1,#list do - context.setvalue("currentbtxindex",i) - context.btxchecklistentry(list[i][1]) + ctx_setvalue("currentbtxindex",i) + ctx_btxchecklistentry(list[i][1]) end end @@ -921,17 +941,17 @@ function lists.resolve(dataset,reference) -- maybe already feed it split for i=1,nofcollected do local c = collected[i] if i == nofcollected then - context.btxlistvariantparameter("lastpubsep") + ctx_btxlistvariantparameter("lastpubsep") elseif i > 1 then - context.btxlistvariantparameter("pubsep") + ctx_btxlistvariantparameter("pubsep") end if #c == 3 then -- a range (3 is first or last) - context.btxdirectlink(f_reference(dataset,c[1],c[2]),c[3]) + ctx_btxdirectlink(f_reference(dataset,c[1],c[2]),c[3]) else local f, l = c[2], c[2] - context.btxdirectlink(f_reference(dataset,f[1],f[2]),f[3]) + ctx_btxdirectlink(f_reference(dataset,f[1],f[2]),f[3]) context.endash() -- to do - context.btxdirectlink(f_reference(dataset,l[4],l[5]),l[6]) + ctx_btxdirectlink(f_reference(dataset,l[4],l[5]),l[6]) end end else @@ -948,7 +968,7 @@ function commands.btxreference(dataset,block,tag,data) local ref = f_reference(dataset,block,tag) if not done[ref] then done[ref] = true - context.dodirectfullreference(ref,data) + ctx_dodirectfullreference(ref,data) end end @@ -958,7 +978,7 @@ function commands.btxdestination(dataset,block,tag,data) local ref = f_destination(dataset,block,tag) if not done[ref] then done[ref] = true - context.dodirectfullreference(ref,data) + ctx_dodirectfullreference(ref,data) end end @@ -1020,25 +1040,25 @@ function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,setup) -- vari else rest = tag end - context.setvalue("currentbtxdataset",dataset) + ctx_setvalue("currentbtxdataset",dataset) local tags = settings_to_array(rest) if #tags > 0 then if sorttype and sorttype ~= "" then tags = sortedtags(dataset,tags,sorttype) end - context.btxcitevariantparameter(v_left) + ctx_btxcitevariantparameter(v_left) for i=1,#tags do local tag = tags[i] - context.setvalue("currentbtxtag",tag) + ctx_setvalue("currentbtxtag",tag) if i > 1 then - context.btxcitevariantparameter(v_middle) + ctx_btxcitevariantparameter(v_middle) end if mark ~= false then - context.dobtxmarkcitation(dataset,tag) + ctx_btxdomarkcitation(dataset,tag) end - context.formatted.directsetup(setup) -- cite can become alternative + ctx_directsetup(setup) -- cite can become alternative end - context.btxcitevariantparameter(v_right) + ctx_btxcitevariantparameter(v_right) else -- error end @@ -1052,10 +1072,10 @@ function commands.btxhandlenocite(dataset,tag,mark) else rest = tag end - context.setvalue("currentbtxdataset",dataset) + ctx_setvalue("currentbtxdataset",dataset) local tags = settings_to_array(rest) for i=1,#tags do - context.dobtxmarkcitation(dataset,tags[i]) + ctx_btxdomarkcitation(dataset,tags[i]) end end end @@ -1162,7 +1182,7 @@ end function citevariants.authornum(dataset,tags) local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors publications.citeconcat(order) - context.btxcitevariantparameter(v_inbetween) + ctx_btxcitevariantparameter(v_inbetween) lists.resolve(dataset,tags) -- left/right ? end @@ -1179,7 +1199,7 @@ function citevariants.page(dataset,tags) -- nothing elseif type(pages) == "table" then context(pages[1]) - context.btxcitevariantparameter(v_inbetween) + ctx_btxcitevariantparameter(v_inbetween) context(pages[2]) else context(pages) @@ -1206,10 +1226,10 @@ publications.listvariants = listvariants -- if sorttype and sorttype ~= "" then -- tags = sortedtags(dataset,tags,sorttype) -- end --- context.setvalue("currentbtxtag",tag) --- context.btxlistvariantparameter(v_left) --- context.formatted.directsetup(setup) --- context.btxlistvariantparameter(v_right) +-- ctx_setvalue("currentbtxtag",tag) +-- ctx_btxlistvariantparameter(v_left) +-- ctx_directsetup(setup) +-- ctx_btxlistvariantparameter(v_right) -- end function commands.btxlistvariant(dataset,block,tags,variant,listindex) @@ -1224,7 +1244,7 @@ function listvariants.default(dataset,block,tags,variant) end function listvariants.num(dataset,block,tags,variant,listindex) - context.btxdirectlink(f_destination(dataset,block,tags),listindex) -- not okay yet + ctx_btxdirectlink(f_destination(dataset,block,tags),listindex) -- not okay yet end function listvariants.short(dataset,block,tags,variant,listindex) diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index 92dffdce3..3de7c5033 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -14,6 +14,8 @@ % todo: we cannot use 'default' as this wipes metadata names (maybe no longer do that) % todo: \v!cite => \s!cite % todo: interface with (ml)bibtex (export -> call -> import) +% todo: check if 'all' etc are ok ... either use list or use other criterium +% todo: maybe use description instead of list % \definecolor[btx:field] [darkred] % \definecolor[btx:crossref][darkblue] @@ -294,6 +296,9 @@ \fi \to \everysetupbtxlistplacement +% use description instead of list ... more flexible .. but then not via +% a real description in the tuc but directly + \def\publ_place_list_indeed {\startbtxrendering[\currentbtxrendering]% \directsetup{\btxrenderingparameter\c!setups}% @@ -552,7 +557,7 @@ \def\publ_cite_indeed#1#2% {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}} -\def\dobtxmarkcitation#1#2% called from lua end +\def\btxdomarkcitation#1#2% called from lua end {\iftrialtypesetting \else \writedatatolist[btx][btxset=#1,btxref=#2]% \c!location=\v!here \fi} diff --git a/tex/context/base/publ-tra.lua b/tex/context/base/publ-tra.lua index 708795727..90bae67e9 100644 --- a/tex/context/base/publ-tra.lua +++ b/tex/context/base/publ-tra.lua @@ -11,6 +11,7 @@ local sortedhash = table.sortedhash local tracers = { } publications.tracers = tracers +local context = context local NC, NR, bold = context.NC, context.NR, context.bold publications.tracers.fields = table.sorted { diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index bc2385de2..2daf3dee7 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index fc3a4d4df..23966b542 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 42eee2723..e85e075a6 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/17/14 22:09:11 +-- merge date : 01/18/14 13:23:27 do -- begin closure to overcome local limits and interference -- cgit v1.2.3