diff options
41 files changed, 1026 insertions, 545 deletions
diff --git a/metapost/context/base/mp-base.mpiv b/metapost/context/base/mp-base.mpiv index 0b655ef47..94379050b 100644 --- a/metapost/context/base/mp-base.mpiv +++ b/metapost/context/base/mp-base.mpiv @@ -714,10 +714,10 @@ enddef ; def pen_pickup_ primary q = currentpen := q ; - pen_lft :=xpart penoffset down of currentpen ; - pen_rt :=xpart penoffset up of currentpen ; - pen_top :=ypart penoffset left of currentpen ; - pen_bot :=ypart penoffset right of currentpen ; + pen_lft := xpart penoffset down of currentpen ; + pen_rt := xpart penoffset up of currentpen ; + pen_top := ypart penoffset left of currentpen ; + pen_bot := ypart penoffset right of currentpen ; path currentpen_path ; enddef ; @@ -733,7 +733,8 @@ vardef savepen = pen_count_ enddef ; -def clearpen = currentpen:=nullpen; +def clearpen = + currentpen := nullpen; pen_lft := pen_rt := pen_top := pen_bot := 0 ; path currentpen_path ; enddef ; diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index b53110bb1..371723271 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -540,6 +540,7 @@ function scripts.context.run(ctxdata,filename) local a_profile = getargument("profile") local a_batchmode = getargument("batchmode") local a_nonstopmode = getargument("nonstopmode") + local a_scollmode = getargument("scrollmode") local a_once = getargument("once") local a_synctex = getargument("synctex") local a_backend = getargument("backend") @@ -549,7 +550,7 @@ function scripts.context.run(ctxdata,filename) local a_jithash = getargument("jithash") local a_texformat = getargument("texformat") -- - a_batchmode = (a_batchmode and "batchmode") or (a_nonstopmode and "nonstopmode") or nil + a_batchmode = (a_batchmode and "batchmode") or (a_nonstopmode and "nonstopmode") or (a_scrollmode and "scrollmode") or nil a_synctex = check_synctex(a_synctex) -- for i=1,#filelist do diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 8679aefb1..cd8b6cc4e 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -437,7 +437,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true --- original size: 29808, stripped down to: 16182 +-- original size: 29983, stripped down to: 16202 if not modules then modules={} end modules ['l-lpeg']={ version=1.001, @@ -474,7 +474,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=crlf+S("\r\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -496,8 +496,8 @@ patterns.utfbom_32_le=utfbom_32_le patterns.utfbom_16_be=utfbom_16_be patterns.utfbom_16_le=utfbom_16_le patterns.utfbom_8=utfbom_8 -patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") -patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") +patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") +patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") patterns.utf8one=R("\000\127") patterns.utf8two=R("\194\223")*utf8next patterns.utf8three=R("\224\239")*utf8next*utf8next @@ -7180,7 +7180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 25607, stripped down to: 16617 +-- original size: 25613, stripped down to: 16617 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -16875,8 +16875,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 694558 --- stripped bytes : 246497 +-- original bytes : 694739 +-- stripped bytes : 246658 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 8679aefb1..cd8b6cc4e 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -437,7 +437,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true --- original size: 29808, stripped down to: 16182 +-- original size: 29983, stripped down to: 16202 if not modules then modules={} end modules ['l-lpeg']={ version=1.001, @@ -474,7 +474,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=crlf+S("\r\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -496,8 +496,8 @@ patterns.utfbom_32_le=utfbom_32_le patterns.utfbom_16_be=utfbom_16_be patterns.utfbom_16_le=utfbom_16_le patterns.utfbom_8=utfbom_8 -patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") -patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") +patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") +patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") patterns.utf8one=R("\000\127") patterns.utf8two=R("\194\223")*utf8next patterns.utf8three=R("\224\239")*utf8next*utf8next @@ -7180,7 +7180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 25607, stripped down to: 16617 +-- original size: 25613, stripped down to: 16617 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -16875,8 +16875,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 694558 --- stripped bytes : 246497 +-- original bytes : 694739 +-- stripped bytes : 246658 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 8679aefb1..cd8b6cc4e 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -437,7 +437,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true --- original size: 29808, stripped down to: 16182 +-- original size: 29983, stripped down to: 16202 if not modules then modules={} end modules ['l-lpeg']={ version=1.001, @@ -474,7 +474,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=crlf+S("\r\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -496,8 +496,8 @@ patterns.utfbom_32_le=utfbom_32_le patterns.utfbom_16_be=utfbom_16_be patterns.utfbom_16_le=utfbom_16_le patterns.utfbom_8=utfbom_8 -patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") -patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") +patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") +patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") patterns.utf8one=R("\000\127") patterns.utf8two=R("\194\223")*utf8next patterns.utf8three=R("\224\239")*utf8next*utf8next @@ -7180,7 +7180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 25607, stripped down to: 16617 +-- original size: 25613, stripped down to: 16617 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -16875,8 +16875,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 694558 --- stripped bytes : 246497 +-- original bytes : 694739 +-- stripped bytes : 246658 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 8679aefb1..cd8b6cc4e 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -437,7 +437,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true --- original size: 29808, stripped down to: 16182 +-- original size: 29983, stripped down to: 16202 if not modules then modules={} end modules ['l-lpeg']={ version=1.001, @@ -474,7 +474,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=crlf+S("\r\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -496,8 +496,8 @@ patterns.utfbom_32_le=utfbom_32_le patterns.utfbom_16_be=utfbom_16_be patterns.utfbom_16_le=utfbom_16_le patterns.utfbom_8=utfbom_8 -patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") -patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") +patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") +patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") patterns.utf8one=R("\000\127") patterns.utf8two=R("\194\223")*utf8next patterns.utf8three=R("\224\239")*utf8next*utf8next @@ -7180,7 +7180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 25607, stripped down to: 16617 +-- original size: 25613, stripped down to: 16617 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -16875,8 +16875,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 694558 --- stripped bytes : 246497 +-- original bytes : 694739 +-- stripped bytes : 246658 -- end library merge diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index a6dffe816..93aaab8b1 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.05.13 00:04} +\newcontextversion{2014.05.15 19:52} %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 46eb10bf8..3b0bb257a 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 16f45aac2..dcda516f2 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.05.13 00:04} +\edef\contextversion{2014.05.15 19:52} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/data-tex.lua b/tex/context/base/data-tex.lua index f5c986d77..04c5ef469 100644 --- a/tex/context/base/data-tex.lua +++ b/tex/context/base/data-tex.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['data-tex'] = { license = "see context related readme files" } -local char = string.char +local char, find = string.char, string.find local insert, remove = table.insert, table.remove local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) @@ -15,10 +15,11 @@ local report_tex = logs.reporter("resolvers","tex") local resolvers = resolvers -local sequencers = utilities.sequencers -local methodhandler = resolvers.methodhandler -local splitlines = string.splitlines -local utffiletype = utf.filetype +local sequencers = utilities.sequencers +local methodhandler = resolvers.methodhandler +local splitlines = string.splitlines +local utffiletype = utf.filetype +local setmetatableindex = table.setmetatableindex -- local fileprocessor = nil -- local lineprocessor = nil @@ -99,10 +100,11 @@ function helpers.textopener(tag,filename,filehandle,coding) end logs.show_open(filename) insert(inputstack,filename) - return { + local currentline, noflines = 0, noflines + local t = { filename = filename, noflines = noflines, - currentline = 0, + -- currentline = 0, close = function() if trace_locating then report_tex("%a closer: %a closed",tag,filename) @@ -113,12 +115,12 @@ function helpers.textopener(tag,filename,filehandle,coding) end, reader = function(self) self = self or t - local currentline, noflines = self.currentline, self.noflines + -- local currentline, noflines = self.currentline, self.noflines if currentline >= noflines then return nil else currentline = currentline + 1 - self.currentline = currentline + -- self.currentline = currentline local content = lines[currentline] if not content then return nil @@ -137,6 +139,14 @@ function helpers.textopener(tag,filename,filehandle,coding) end end } + setmetatableindex(t,function(t,k) + if k == "currentline" then + return currentline + else + -- no such key + end + end) + return t end function resolvers.findtexfile(filename,filetype) diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 392aa58b1..d89c52996 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -1619,3 +1619,7 @@ end -- interfacing commands.setfigurelookuporder = figures.setorder + +-- + +figures.images = images diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 6feb7089c..666af2103 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -107,7 +107,8 @@ local uppercase = R("AZ") local underscore = P("_") local hexdigit = digit + lowercase + uppercase local cr, lf, crlf = P("\r"), P("\n"), P("\r\n") -local newline = crlf + S("\r\n") -- cr + lf +----- newline = crlf + S("\r\n") -- cr + lf +local newline = P("\r") * (P("\n") + P(true)) + P("\n") local escaped = P("\\") * anything local squote = P("'") local dquote = P('"') @@ -141,8 +142,8 @@ patterns.utfbom_16_be = utfbom_16_be patterns.utfbom_16_le = utfbom_16_le patterns.utfbom_8 = utfbom_8 -patterns.utf_16_be_nl = P("\000\r\000\n") + P("\000\r") + P("\000\n") -patterns.utf_16_le_nl = P("\r\000\n\000") + P("\r\000") + P("\n\000") +patterns.utf_16_be_nl = P("\000\r\000\n") + P("\000\r") + P("\000\n") -- P("\000\r") * (P("\000\n") + P(true)) + P("\000\n") +patterns.utf_16_le_nl = P("\r\000\n\000") + P("\r\000") + P("\n\000") -- P("\r\000") * (P("\n\000") + P(true)) + P("\n\000") patterns.utf8one = R("\000\127") patterns.utf8two = R("\194\223") * utf8next diff --git a/tex/context/base/lpdf-grp.lua b/tex/context/base/lpdf-grp.lua index befe52c76..b3cc7ce1f 100644 --- a/tex/context/base/lpdf-grp.lua +++ b/tex/context/base/lpdf-grp.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['lpdf-grp'] = { license = "see context related readme files" } -local format, gsub = string.format, string.gsub +local formatters, gsub = string.formatters, string.gsub local concat = table.concat local round = math.round @@ -236,7 +236,7 @@ function img.package(image) -- see lpdf-u3d ** local height = boundingbox[4] local xform = img.scan { attr = resources(), - stream = format("%F 0 0 %F 0 0 cm /%s Do",width,height,imagetag), + stream = formatters["%F 0 0 %F 0 0 cm /%s Do"](width,height,imagetag), bbox = { 0, 0, width/factor, height/factor }, } img.immediatewrite(xform) diff --git a/tex/context/base/lpdf-u3d.lua b/tex/context/base/lpdf-u3d.lua index f0fca0762..c9f4a0369 100644 --- a/tex/context/base/lpdf-u3d.lua +++ b/tex/context/base/lpdf-u3d.lua @@ -18,7 +18,7 @@ if not modules then modules = { } end modules ['lpdf-u3d'] = { -- it makes sense to add the same activation code as with swf. local tonumber = tonumber -local format, find = string.format, string.find +local formatters, find = string.formatters, string.find local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs local backends, lpdf = backends, lpdf @@ -428,13 +428,13 @@ local function insert3d(spec) -- width, height, factor, display, controls, label local preview = checkedkey(param,"preview","string") if preview then activationdict.A = pdfconstant("XA") - local tag = format("%s:%s:%s",label,stream,preview) + local tag = formatters["%s:%s:%s"](label,stream,preview) local ref = stored_pr[tag] if not ref then local figure = img.immediatewrite { filename = preview, - width = width, - height = height + width = width, + height = height } ref = figure.objnum stored_pr[tag] = ref @@ -461,7 +461,7 @@ local function insert3d(spec) -- width, height, factor, display, controls, label }, ProcSet = pdfarray { pdfconstant("PDF"), pdfconstant("ImageC") }, } - local pwd = pdfflushstreamobject(format("q /GS gs %F 0 0 %F 0 0 cm /IM Do Q",factor*width,factor*height),pw) + local pwd = pdfflushstreamobject(formatters["q /GS gs %F 0 0 %F 0 0 cm /IM Do Q"](factor*width,factor*height),pw) annot.AP = pdfdictionary { N = pdfreference(pwd) } diff --git a/tex/context/base/m-pipemode.mkiv b/tex/context/base/m-pipemode.mkiv new file mode 100644 index 000000000..e96394c43 --- /dev/null +++ b/tex/context/base/m-pipemode.mkiv @@ -0,0 +1,7 @@ +% For Mojca: context --global m-pipemode.mkiv + +\disabledirectives[system.errorcontext] + +\starttext + +\let\stoptext\relax diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii index 0c4dae5b6..9e7ecd930 100644 --- a/tex/context/base/mult-de.mkii +++ b/tex/context/base/mult-de.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{datei} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{ersteseite} \setinterfaceconstant{focus}{focus} diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index fc2b932c2..bd8b36185 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -6643,6 +6643,9 @@ return { ["lastpubsep"]={ ["en"]="lastpubsep", }, + ["finalpubsep"]={ + ["en"]="finalpubsep", + }, ["refcommand"]={ ["en"]="refcommand", }, diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii index 00861c3be..bf72af384 100644 --- a/tex/context/base/mult-en.mkii +++ b/tex/context/base/mult-en.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{file} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{firstpage} \setinterfaceconstant{focus}{focus} diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii index 9afe371c2..e1129848f 100644 --- a/tex/context/base/mult-fr.mkii +++ b/tex/context/base/mult-fr.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{fichier} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{premierepage} \setinterfaceconstant{focus}{focus} diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii index 802cb840c..5646a212e 100644 --- a/tex/context/base/mult-it.mkii +++ b/tex/context/base/mult-it.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{file} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{primapagina} \setinterfaceconstant{focus}{focus} diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii index 015f58ff1..aa376c39a 100644 --- a/tex/context/base/mult-nl.mkii +++ b/tex/context/base/mult-nl.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{file} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{eerstepagina} \setinterfaceconstant{focus}{focus} diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii index 999b16cf5..16871bb62 100644 --- a/tex/context/base/mult-pe.mkii +++ b/tex/context/base/mult-pe.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{پرونده} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{صفحهاول} \setinterfaceconstant{focus}{تمرکز} diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii index f577eabda..d01822944 100644 --- a/tex/context/base/mult-ro.mkii +++ b/tex/context/base/mult-ro.mkii @@ -701,6 +701,7 @@ \setinterfaceconstant{file}{fisier} \setinterfaceconstant{filtercommand}{filtercommand} \setinterfaceconstant{finalnamesep}{finalnamesep} +\setinterfaceconstant{finalpubsep}{finalpubsep} \setinterfaceconstant{firstnamesep}{firstnamesep} \setinterfaceconstant{firstpage}{primapagina} \setinterfaceconstant{focus}{focus} diff --git a/tex/context/base/publ-imp-cite.mkiv b/tex/context/base/publ-imp-cite.mkiv index d64c2132c..dcec866a3 100644 --- a/tex/context/base/publ-imp-cite.mkiv +++ b/tex/context/base/publ-imp-cite.mkiv @@ -11,64 +11,122 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\startsetups btx:cite:author - \btxcitevariant{author} -\stopsetups +\unprotect -\startsetups btx:cite:authoryear - \btxcitevariant{authoryear} -\stopsetups +% The null case: -\startsetups btx:cite:authoryears - \btxcitevariant{authoryears} +\startsetups \s!btx:\s!cite:none + % dummy \stopsetups -% \startsetups btx:cite:authornum -% \btxcitevariant{author} -% \btxcitevariantparameter\c!inbetween -% \btxcitevariant{num} -% \stopsetups +% This saves keying: -\startsetups btx:cite:authornum - \btxcitevariant{authornum} +\startsetups \s!btx:\s!cite:common:default + \ifx\currentbtxsecond\empty + \currentbtxfirst + \else + \currentbtxfirst + \btxcitevariantparameter\v!inbetween + \currentbtxsecond + \fi \stopsetups -\startsetups btx:cite:year - \btxcitevariant{year} +\startsetups \s!btx:\s!cite:concat + \ifcase\currentbtxconcat \or \or + \btxcitevariantparameter\c!pubsep + \or + \btxcitevariantparameter\c!finalpubsep + \or + \btxcitevariantparameter\c!lastpubsep + \fi \stopsetups -\startsetups btx:cite:short - \btxcitevariant{short} +\startsetups \s!btx:\s!cite:common + \directsetup{\s!btx:\s!cite:concat} + \ifconditional\btxinteractive + \goto { + \directsetup{\s!btx:\s!cite:common:default} + } [ + internal(\currentbtxinternal) + ] + \else + \directsetup{\s!btx:\s!cite:common:default} + \fi \stopsetups -\startsetups btx:cite:serial - \btxcitevariant{serial} +\startsetups \s!btx:\s!cite:variant + \directsetup{\s!btx:\s!cite:concat} + \ifconditional\btxinteractive + \goto { + \directsetup{\s!btx:\s!cite:common:\currentbtxcitevariant} + } [ + internal(\currentbtxinternal) + ] + \else + \directsetup{\s!btx:\s!cite:common:\currentbtxcitevariant} + \fi \stopsetups -\startsetups btx:cite:key - \currentbtxtag % \btxcitevariant{tag} -\stopsetups +% author lists: -\startsetups btx:cite:doi - todo: \btxcitevariant{doi} +\startsetups \s!btx:\s!cite:common:author + \currentbtxfirst \stopsetups - -\startsetups btx:cite:url - todo: \btxcitevariant{url} +\startsetups \s!btx:\s!cite:common:authoryear + \currentbtxfirst,\space(\currentbtxsecond) \stopsetups - -\startsetups btx:cite:type - \btxcitevariant{category} +\startsetups \s!btx:\s!cite:common:authoryears + \currentbtxfirst,\space\currentbtxsecond \stopsetups - -\startsetups btx:cite:page - \btxcitevariant{page} +\startsetups \s!btx:\s!cite:common:authornum + \currentbtxfirst\space[\currentbtxsecond] \stopsetups -\startsetups btx:cite:none - % dummy +\startsetups \s!btx:\s!cite:author + \directsetup{\s!btx:\s!cite:variant} +\stopsetups +\startsetups \s!btx:\s!cite:authoryear + \directsetup{\s!btx:\s!cite:variant} +\stopsetups +\startsetups \s!btx:\s!cite:authoryears + \directsetup{\s!btx:\s!cite:variant} +\stopsetups +\startsetups \s!btx:\s!cite:authornum + \directsetup{\s!btx:\s!cite:variant} \stopsetups -\startsetups btx:cite:num - \btxcitevariant{num} +\startsetups \s!btx:\s!cite:year + \directsetup{\s!btx:\s!cite:common} \stopsetups +\startsetups \s!btx:\s!cite:short + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:serial + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:tag + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:key + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:doi + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:url + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:category + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:type + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:num + \directsetup{\s!btx:\s!cite:common} +\stopsetups +\startsetups \s!btx:\s!cite:page + \directsetup{\s!btx:\s!cite:common} +\stopsetups + +\protect diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index afe3697c1..8190ddfc2 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -6,7 +6,9 @@ if not modules then modules = { } end modules ['publ-ini'] = { license = "see context related readme files" } --- for the moment here +-- we could store the destinations in the user list entries + +-- will move: local lpegmatch = lpeg.match local P, C, Ct, Cs = lpeg.P, lpeg.C, lpeg.Ct, lpeg.Cs @@ -41,9 +43,9 @@ end -- use: for rest in gmatch(reference,"[^, ]+") do -local next, rawget, type = next, rawget, type +local next, rawget, type, tostring, tonumber = next, rawget, type, tostring, tonumber local match, gmatch, format, gsub = string.match, string.gmatch, string.format, string.gsub -local concat, sort = table.concat, table.sort +local concat, sort, tohash = table.concat, table.sort, table.tohash local utfsub = utf.sub local formatters = string.formatters local allocate = utilities.storage.allocate @@ -52,8 +54,14 @@ local sortedkeys, sortedhash = table.sortedkeys, table.sortedhash local lpegmatch = lpeg.match local P, C, Ct = lpeg.P, lpeg.C, lpeg.Ct -local report = logs.reporter("publications") -local trace = false trackers.register("publications", function(v) trace = v end) +local report = logs.reporter("publications") +local report_cite = logs.reporter("publications","cite") +local report_reference = logs.reporter("publications","reference") + +local trace = false trackers.register("publications", function(v) trace = v end) +local trace_cite = false trackers.register("publications.cite", function(v) trace_cite = v end) +local trace_missing = false trackers.register("publications.cite.missing", function(v) trace_missing = v end) +local trace_references = false trackers.register("publications.cite.references", function(v) trace_references = v end) local datasets = publications.datasets @@ -91,6 +99,8 @@ local sortcomparer = sorters.comparers.basic -- (a,b) local sortstripper = sorters.strip local sortsplitter = sorters.splitters.utf +local settings_to_array = utilities.parsers.settings_to_array + local context = context local ctx_btxlistparameter = context.btxlistparameter @@ -105,8 +115,16 @@ 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 +----- ctx_dodirectfullreference = context.dodirectfullreference +local ctx_btxsetreference = context.btxsetreference local ctx_directsetup = context.directsetup +local ctx_btxmissing = context.btxmissing + +local ctx_btxcitesetup = context.btxcitesetup +local ctx_btxsetfirst = context.btxsetfirst +local ctx_btxsetsecond = context.btxsetsecond +local ctx_btxsetinternal = context.btxsetinternal +local ctx_btxsetconcat = context.btxsetconcat statistics.register("publications load time", function() local publicationsstats = publications.statistics @@ -249,6 +267,183 @@ if not publications.authors then initializer() -- for now, runtime loaded end +local usedentries = { } +local initialized = false + +-- { +-- ["metadata"]=1, +-- ["references"]={ +-- ["block"]="bodypart", +-- ["internal"]=2, +-- ["realpage"]=1, +-- ["section"]=0, +-- }, +-- ["userdata"]={ +-- ["btxref"]="Cleveland1985", +-- ["btxset"]="standard", +-- }, +-- }, + +table.setmetatableindex(usedentries,function(t,k) + if not initialized then + usedentries = { } + local internals = structures.references.internals + for i=1,#internals do + local entry = internals[i] + local metadata = entry.metadata + if metadata.kind == "full" then + local userdata = entry.userdata + if userdata then + local set = userdata.btxset + if set then + local tag = userdata.btxref + local s = usedentries[set] + if s then + local u = s[tag] + if u then + u[#u+1] = entry + else + u = { entry } + s[tag] = u + end + else + usedentries[set] = { [tag] = { entry } } + end + end + end + end + end + return usedentries[k] + end +end) + +-- local subsets = nil +-- local block = tex.count.btxblock +-- local collected = references.collected +-- local prefix = nil -- todo: dataset ? +-- if prefix and prefix ~= "" then +-- subsets = { collected[prefix] or collected[""] } +-- else +-- local components = references.productdata.components +-- local subset = collected[""] +-- if subset then +-- subsets = { subset } +-- else +-- subsets = { } +-- end +-- for i=1,#components do +-- local subset = collected[components[i]] +-- if subset then +-- subsets[#subsets+1] = subset +-- end +-- end +-- end +-- if #subsets == 0 then +-- subsets = { collected[""] } +-- end +-- local list = type(reference) == "string" and settings_to_array(reference) or reference +-- local todo = table.tohash(list) +-- if #subsets > 0 then +-- local result, nofresult, done = { }, 0, { } +-- for i=1,#subsets do +-- local subset = subsets[i] +-- for i=1,#list do +-- local rest = list[i] +-- local blk, tag, found = block, nil, nil +-- if block then +-- tag = f_destination(dataset,blk,rest) +-- found = subset[tag] +-- if not found then +-- for i=block-1,1,-1 do +-- tag = f_destination(dataset,i,rest) +-- found = subset[tag] +-- if found then +-- blk = i +-- break +-- end +-- end +-- end +-- end +-- if not found then +-- blk = "*" +-- tag = f_destination(dataset,blk,rest) +-- found = subset[tag] +-- end +-- if found then +-- local entries = found.entries +-- if entries then +-- local current = tonumber(entries.text) -- todo: no ranges when no tonumber +-- if current and not done[current] then +-- nofresult = nofresult + 1 +-- result[nofresult] = { blk, rest, current, found.references.internal } +-- done[current] = true +-- end +-- end +-- end +-- end +-- end + +local function findallused(dataset,reference,block,section) + local tags = settings_to_array(reference) + local todo = { } + local okay = { } -- only if mark + local set = usedentries[dataset] + if set then + for i=1,#tags do + local tag = tags[i] + local entry = set[tag] + if entry then + -- only once in a list + if #entry == 1 then + entry = entry[1] + else + -- find best match + entry = entry[1] -- for now + end + okay[#okay+1] = entry + end + todo[tag] = true + end + else + for i=1,#tags do + todo[tags[i]] = true + end + end + return okay, todo, tags +end + +local function flushcollected(flush,nofcollected) + if nofcollected > 0 then + flush(1,1) + if nofcollected > 2 then + for i=2,nofcollected-1 do + flush(i,2) + end + flush(nofcollected,3) + elseif nofcollected > 1 then + flush(nofcollected,4) + end + end +end + +local function markcite(dataset,tag) + if trace_cite then + report_cite("mark, dataset: %s, tag: %s",dataset,tag) + end + ctx_btxdomarkcitation(dataset,tag) +end + +local function flushmarked(dataset,list,todo) + if todo then + for i=1,#list do + local tag = list[i] + if todo[tag] then + markcite(dataset,tag) + end + end + end +end + -- basic access local function getfield(dataset,tag,name) @@ -344,10 +539,10 @@ function publications.enhance(dataset) -- for the moment split runs (maybe publi if type(tags) == "table" then sort(tags) for i=1,#tags do --- details[tags[i]].short = short .. numbertochar(i) -local detail = details[tags[i]] -detail.short = short -detail.suffix = numbertochar(i) + -- details[tags[i]].short = short .. numbertochar(i) + local detail = details[tags[i]] + detail.short = short + detail.suffix = numbertochar(i) end else details[tags].short = short @@ -402,9 +597,9 @@ end -- rendering of fields (maybe multiple manipulators) -local manipulation = utilities.parsers.manipulation -local manipulators = utilities.parsers.manipulators - +-- local manipulation = utilities.parsers.manipulation +-- local manipulators = utilities.parsers.manipulators +-- -- local function checked(field) -- local m, f = lpegmatch(manipulation,field) -- if m then @@ -415,6 +610,7 @@ local manipulators = utilities.parsers.manipulators -- end local manipulation = Ct((C((1-P("->"))^1) * P("->"))^1) * C(P(1)^0) +local manipulators = utilities.parsers.manipulators local function checked(field) local m, f = lpegmatch(manipulation,field) @@ -443,7 +639,6 @@ function commands.btxflush(name,tag,field) local manipulator, field = checked(field) local value = fields[field] if type(value) == "string" then - -- context(manipulator and manipulator(value) or value) context(manipulator and manipulated(manipulator,value) or value) return end @@ -451,7 +646,6 @@ function commands.btxflush(name,tag,field) if details then local value = details[field] if type(value) == "string" then - -- context(manipulator and manipulator(value) or value) context(manipulator and manipulated(manipulator,value) or value) return end @@ -473,7 +667,6 @@ function commands.btxdetail(name,tag,field) local manipulator, field = checked(field) local value = details[field] if type(value) == "string" then - -- context(manipulator and manipulator(value) or value) context(manipulator and manipulated(manipulator,value) or value) else report("unknown detail %a of tag %a in dataset %a",field,tag,name) @@ -494,7 +687,6 @@ function commands.btxfield(name,tag,field) local manipulator, field = checked(field) local value = fields[field] if type(value) == "string" then - -- context(manipulator and manipulator(value) or value) context(manipulator and manipulated(manipulator,value) or value) else report("unknown field %a of tag %a in dataset %a",field,tag,name) @@ -550,44 +742,6 @@ end -- -- alternative approach: keep data at the tex end -function publications.listconcat(t) - local n = #t - if n > 0 then - context(t[1]) - if n > 1 then - if n > 2 then - for i=2,n-1 do - ctx_btxlistparameter("sep") - context(t[i]) - end - ctx_btxlistparameter("finalsep") - else - ctx_btxlistparameter("lastsep") - end - context(t[n]) - end - end -end - -function publications.citeconcat(t) - local n = #t - if n > 0 then - context(t[1]) - if n > 1 then - if n > 2 then - for i=2,n-1 do - ctx_btxcitevariantparameter("sep") - context(t[i]) - end - ctx_btxcitevariantparameter("finalsep") - else - ctx_btxcitevariantparameter("lastsep") - end - context(t[n]) - end - end -end - function publications.singularorplural(singular,plural) if lastconcatsize and lastconcatsize > 1 then context(plural) @@ -596,106 +750,6 @@ 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] = 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" } local function failure(name) @@ -788,8 +842,6 @@ local function validkeyword(dataset,tag,keyword) end local kw = dt.keyword if kw then --- inspect(keyword) --- inspect(kw) for k in next, keyword do if kw[k] then return true @@ -804,12 +856,10 @@ function lists.collectentries(specification) return end local rendering = renderings[dataset] --- specification.names = "btx" local method = rendering.method if method == v_none then return end --- method=v_local -------------------- local result = structures.lists.filter(specification) -- local keyword = specification.keyword @@ -987,158 +1037,38 @@ local function compare(a,b) return aa and bb and aa < bb end --- maybe hash subsets --- how efficient is this? old leftovers? - -- rendering ? +-- todo: nicer refs + local f_reference = formatters["r:%s:%s:%s"] -- dataset, instance (block), tag local f_destination = formatters["d:%s:%s:%s"] -- dataset, instance (block), tag - -function lists.resolve(dataset,reference) -- maybe already feed it split - -- needs checking (the prefix in relation to components) - local subsets = nil - local block = tex.count.btxblock - local collected = references.collected - local prefix = nil -- todo: dataset ? - if prefix and prefix ~= "" then - subsets = { collected[prefix] or collected[""] } - else - local components = references.productdata.components - local subset = collected[""] - if subset then - subsets = { subset } - else - subsets = { } - end - for i=1,#components do - local subset = collected[components[i]] - if subset then - subsets[#subsets+1] = subset - end - end - end --- inspect(subsets) - if #subsets > 0 then - local result, nofresult, done = { }, 0, { } - for i=1,#subsets do - local subset = subsets[i] - for rest in gmatch(reference,"[^, ]+") do - local blk, tag, found = block, nil, nil - if block then - tag = f_destination(dataset,blk,rest) - found = subset[tag] - if not found then - for i=block-1,1,-1 do - tag = f_destination(dataset,blk,rest) --- tag = i .. ":" .. rest - found = subset[tag] - if found then - blk = i - break - end - end - end - end - if not found then - blk = "*" - tag = f_destination(dataset,blk,rest) - found = subset[tag] - end - if found then - local current = tonumber(found.entries and found.entries.text) -- tonumber needed - if current and not done[current] then - nofresult = nofresult + 1 - result[nofresult] = { blk, rest, current } - done[current] = true - end - end - end - end - local first, last, firsti, lasti, firstr, lastr - local collected, nofcollected = { }, 0 - for i=1,nofresult do - local r = result[i] - local current = r[3] - if not first then - first, last, firsti, lasti, firstr, lastr = current, current, i, i, r, r - elseif current == last + 1 then - last, lasti, lastr = current, i, r - else - if last > first + 1 then - nofcollected = nofcollected + 1 - collected[nofcollected] = { firstr, lastr } - else - nofcollected = nofcollected + 1 - collected[nofcollected] = firstr - if last > first then - nofcollected = nofcollected + 1 - collected[nofcollected] = lastr - end - end - first, last, firsti, lasti, firstr, lastr = current, current, i, i, r, r - end - end - if first and last then - if last > first + 1 then - nofcollected = nofcollected + 1 - collected[nofcollected] = { firstr, lastr } - else - nofcollected = nofcollected + 1 - collected[nofcollected] = firstr - if last > first then - nofcollected = nofcollected + 1 - collected[nofcollected] = lastr - end - end - end - if nofcollected > 0 then --- inspect(reference) --- inspect(result) --- inspect(collected) - for i=1,nofcollected do - local c = collected[i] - if i == nofcollected then - ctx_btxlistvariantparameter("lastpubsep") - elseif i > 1 then - ctx_btxlistvariantparameter("pubsep") - end - if #c == 3 then -- a range (3 is first or last) - ctx_btxdirectlink(f_reference(dataset,c[1],c[2]),c[3]) - else - local f, l = c[2], c[2] - ctx_btxdirectlink(f_reference(dataset,f[1],f[2]),f[3]) - context.endash() -- to do - ctx_btxdirectlink(f_reference(dataset,l[4],l[5]),l[6]) - end - end - else - context("[btx error 1]") - end - else - context("[btx error 2]") - end -end +local f_listentry = formatters["d:%s:%s:%s"] -- dataset, instance (block), tag +local f_internal = formatters["internal(%s)"] -- dataset, instance (block), tag local done = { } function commands.btxreference(dataset,block,tag,data) - local ref = f_reference(dataset,block,tag) + local ref = f_reference(dataset,block,tag) -- we just need a unique key if not done[ref] then + if trace_references then + report_reference("link: %s",ref) + end done[ref] = true --- context("<%s>",data) - ctx_dodirectfullreference(ref,data) + ctx_btxsetreference(dataset,tag,ref,data) end end local done = { } function commands.btxdestination(dataset,block,tag,data) - local ref = f_destination(dataset,block,tag) + local ref = f_destination(dataset,block,tag) -- we just need a unique key if not done[ref] then + if trace_references then + report_reference("link: %s",ref) + end done[ref] = true --- context("<<%s>>",data) - ctx_dodirectfullreference(ref,data) + ctx_btxsetreference(dataset,tag,ref,data) end end @@ -1184,40 +1114,28 @@ local function sortedtags(dataset,list,sorttype) end end --- todo: standard : current +-- if sorttype and sorttype ~= "" then +-- tags = sortedtags(dataset,tags,sorttype) +-- end -local prefixsplitter = lpeg.splitat("::") --- num is special +local prefixsplitter = lpeg.splitat("::") -function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,setup) -- variant for tracing +function commands.btxhandlecite(dataset,tag,mark,variant,sorttype,compress) local prefix, rest = lpegmatch(prefixsplitter,tag) if rest then dataset = prefix else rest = tag end - 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 - ctx_btxcitevariantparameter(v_left) - for i=1,#tags do - local tag = tags[i] - ctx_setvalue("currentbtxtag",tag) - if i > 1 then - ctx_btxcitevariantparameter(v_middle) - end - if mark ~= false then - ctx_btxdomarkcitation(dataset,tag) - end - ctx_directsetup(setup) -- cite can become alternative + local action = citevariants[variant] + if action then + if trace_cite then + report_cite("inject, dataset: %s, tag: %s, variant: %s, compressed",dataset or "-",rest,variant) end - ctx_btxcitevariantparameter(v_right) - else - -- error + ctx_setvalue("currentbtxdataset",dataset) +-- print(variant,sorttype,compress) + action(dataset,rest,mark ~= false,compress,variant) end end @@ -1231,34 +1149,289 @@ function commands.btxhandlenocite(dataset,tag,mark) end ctx_setvalue("currentbtxdataset",dataset) local tags = settings_to_array(rest) + if trace_cite then + report_cite("mark, dataset: %s, tags: % | t",dataset or "-",tags) + end for i=1,#tags do - ctx_btxdomarkcitation(dataset,tags[i]) + markcite(dataset,tags[i]) end end end function commands.btxcitevariant(dataset,block,tags,variant) - local action = citevariants[variant] or citevariants.default + local action = citevariants[variant] if action then action(dataset,tags,variant) end end -function citevariants.default(dataset,tags,variant) - local content = getfield(dataset,tags,variant) - if content then - context(content) +-- sorter + +local function compresslist(source,key) + local first, last, firstr, lastr + local target, noftarget, tags = { }, 0, { } + local function flushrange() + noftarget = noftarget + 1 + if last > first + 1 then + target[noftarget] = { + first = firstr, + last = lastr, + tags = tags, + } + else + target[noftarget] = firstr + if last > first then + noftarget = noftarget + 1 + target[noftarget] = lastr + end + end + tags = { } + end + for i=1,#source do + local entry = source[i] + local current = entry[key] + if not first then + first, last, firstr, lastr = current, current, entry, entry + elseif current == last + 1 then + last, lastr = current, entry + else + flushrange() + first, last, firstr, lastr = current, current, entry, entry + end + tags[#tags+1] = entry.tag + end + if first and last then + flushrange() + end + return target +end + +-- local source = { +-- { tag = "one", internal = 1, value = "foo", page = 1 }, +-- { tag = "two", internal = 2, value = "bar", page = 2 }, +-- { tag = "three", internal = 3, value = "gnu", page = 3 }, +-- } +-- +-- local target = compresslist(source,"page") + +function citevariants.default(dataset,reference,mark,compress,variant,setup) + local found, todo, list = findallused(dataset,reference) + if found then + local valid = { } + for i=1,#found do + local entry = found[i] + local tag = entry.userdata.btxref + local value = getfield(dataset,tag,variant) + if value then + valid[#valid+1] = { tag, entry.references.internal, value } + end + end + local function flush(i,state) + local data = valid[i] + if mark then + local tag = data[1] + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(data[2]) + ctx_btxsetconcat(state) + ctx_btxsetfirst(data[3]) + ctx_btxcitesetup(setup or variant) + end + flushcollected(flush,#valid) + if mark and #valid == #found then + mark = false + end + end + if mark then + flushmarked(dataset,list,todo) end end +table.setmetatableindex(citevariants,function(t,k) + local v = t.default + t[k] = v + return v +end) + +function citevariants.short(dataset,reference,mark,compress) + local found, todo, list = findallused(dataset,reference) + if found then + local valid = { } + for i=1,#found do + local entry = found[i] + local tag = entry.userdata.btxref + local short = getdetail(dataset,tag,"short") + if short then + valid[#valid+1] = { tag, entry.references.internal, short, getdetail(dataset,tag,"suffix") } + end + end + local function flush(i,state) + local data = valid[i] + local short = data[3] + local suffix = data[4] + if mark then + local tag = data[1] + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(data[2]) + ctx_btxsetconcat(state) + if suffix then + ctx_btxsetfirst(short .. suffix) + else + ctx_btxsetfirst(short) + end + ctx_btxcitesetup("short") + end + flushcollected(flush,#valid) + if mark and #valid == #found then + mark = false + end + end + if mark then + flushmarked(dataset,list,todo) + end +end + +-- no compress + +function citevariants.page(dataset,reference,mark,compress) + local found, todo, list = findallused(dataset,reference) + if found then + local valid = { } + for i=1,#found do + local entry = found[i] + local tag = entry.userdata.btxref + local pages = getdetail(dataset,tag,"pages") + if pages then + valid[#valid+1] = { tag, entry.references.internal, pages } + end + end + local function flush(i,state) + local data = valid[i] + local pages = data[3] + if mark then + local tag = data[1] + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(data[2]) + ctx_btxsetconcat(state) + if type(pages) == "table" then + ctx_btxsetfirst(pages[1]) + ctx_btxsetsecond(pages[2]) + else + ctx_btxsetfirst(pages) + end + ctx_btxcitesetup("page") + end + flushcollected(flush,#valid) + if mark and #valid == #found then + mark = false + end + end + if mark then + flushmarked(dataset,list,todo) + end +end + +-- compress: 1-4, 5, 8-10 + +-- local source = { +-- { tag = "one", internal = 1, value = "foo", page = 1 }, +-- { tag = "two", internal = 2, value = "bar", page = 2 }, +-- { tag = "three", internal = 3, value = "gnu", page = 3 }, +-- } +-- +-- local target = compress(source,"page") + +function citevariants.num(dataset,reference,mark,compress) + local found, todo, list = findallused(dataset,reference) + if found then + if compress then + local source = { } + for i=1,#found do + local entry = found[i] + local text = entry.entries.text + local key = tonumber(text) + if not key then + source = false + break + end + source[i] = { + tag = entry.userdata.btxref, + internal = entry.references.internal, + text = text, + sortkey = key, + } + end + if source then + local target = compresslist(source,"sortkey") + local function flush(i,state) + local entry = target[i] + local first = entry.first + if first then + if mark then + local tags = entry.tags + for i=1,#tags do + local tag = tags[i] + markcite(dataset,tag) + todo[tag] = false + end + end + ctx_btxsetinternal(first.internal) + ctx_btxsetfirst(first.text) + ctx_btxsetsecond(entry.last.text) + else + if mark then + local tag = entry.tag + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(entry.internal) + ctx_btxsetfirst(entry.text) + end + ctx_btxsetconcat(state) + ctx_btxcitesetup("num") + end + flushcollected(flush,#target) + return + else + -- fall through + end + end + local function flush(i,state) + local entry = found[i] + if mark then + local tag = entry.userdata.btxref + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(entry.references.internal) + ctx_btxsetconcat(state) + ctx_btxsetfirst(entry.entries.text) + ctx_btxcitesetup("num") + end + flushcollected(flush,#found) + end + if mark then + flushmarked(dataset,list,todo) + end +end + +function citevariants.type (dataset,reference,mark,compress) return citevariants.default(dataset,reference,mark,compress,"category","type") end -- synonyms +function citevariants.key (dataset,reference,mark,compress) return citevariants.default(dataset,reference,mark,compress,"tag","key") end -- synonyms +function citevariants.serial(dataset,reference,mark,compress) return citevariants.default(dataset,reference,mark,compress,"index","serial") end -- synonyms + -- todo : sort -- todo : choose between publications or commands namespace -- todo : use details.author -- todo : sort details.author -local function collectauthoryears(dataset,tags) +local function collectauthoryears(dataset,tag) local luadata = datasets[dataset].luadata - local list = settings_to_array(tags) + local list = settings_to_array(tag) local found = { } local result = { } local order = { } @@ -1312,79 +1485,82 @@ end -- todo: we loop at the tex end .. why not here -- \cite[{hh,afo},kvm] --- maybe we will move this tex anyway - -function citevariants.author(dataset,tags) - local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors - publications.citeconcat(order) -end - -local function authorandyear(dataset,tags,formatter) - local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors - for i=1,#result do - local r = result[i] - order[i] = formatter(r.author,r.years) -- reuse order +function citevariants.author(dataset,reference,mark,compress) + local found, todo, list = findallused(dataset,reference) + if found then + local function flush(i,state) + local entry = found[i] + local tag = entry.userdata.btxref + if mark then + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(entry.references.internal) + ctx_btxsetconcat(state) + ctx_btxsetfirst(getfield(dataset,tag,"author")) -- todo: reformat + ctx_btxcitesetup("author") + end + flushcollected(flush,#found) end - publications.citeconcat(order) -end - -function citevariants.authoryear(dataset,tags) - authorandyear(dataset,tags,formatters["%s (%, t)"]) -end - -function citevariants.authoryears(dataset,tags) - authorandyear(dataset,tags,formatters["%s, %, t"]) -end - -function citevariants.authornum(dataset,tags) - local result, order = collectauthoryears(dataset,tags,method,what) -- we can have a collectauthors - publications.citeconcat(order) - ctx_btxcitevariantparameter(v_inbetween) - lists.resolve(dataset,tags) -- left/right ? -end - --- function citevariants.short(dataset,tags) --- local short = getdetail(dataset,tags,"short") --- if short then --- context(short) --- end --- end - -function citevariants.short(dataset,tags) - local short = getdetail(dataset,tags,"short") - local suffix = getdetail(dataset,tags,"suffix") - if suffix then - context(short .. suffix) - elseif short then - context(short) + if mark then + flushmarked(dataset,list,todo) end end -function citevariants.page(dataset,tags) - local pages = getdetail(dataset,tags,"pages") - if not pages then - -- nothing - elseif type(pages) == "table" then - context(pages[1]) - ctx_btxcitevariantparameter(v_inbetween) - context(pages[2]) - else - context(pages) +function citevariants.authornum(dataset,reference,mark,compress) + local found, todo, list = findallused(dataset,reference) + if found then + local function flush(i,state) + local entry = found[i] + local tag = entry.userdata.btxref + if mark then + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(entry.references.internal) + ctx_btxsetconcat(state) + ctx_btxsetfirst(getfield(dataset,tag,"author")) -- todo: reformat + ctx_btxsetsecond(entry.entries.text) + ctx_btxcitesetup("authornum") + end + flushcollected(flush,#found) + end + if mark then + flushmarked(dataset,list,todo) end end -function citevariants.serial(dataset,tags) -- the traditional fieldname is "serial" and not "index" - local index = getfield(dataset,tags,"index") - if index then - context(index) +-- local result, order = collectauthoryears(dataset,tag) -- we can have a collectauthors + +local function authorandyear(dataset,reference,mark,compress,setup) + local found, todo, list = findallused(dataset,reference) + if found then + local function flush(i,state) + local entry = found[i] + local tag = entry.userdata.btxref + if mark then + markcite(dataset,tag) + todo[tag] = false + end + ctx_btxsetinternal(entry.references.internal) + ctx_btxsetconcat(state) + ctx_btxsetfirst(getfield(dataset,tag,"author")) -- todo: reformat + ctx_btxsetsecond(getfield(dataset,tag,"year")) + ctx_btxcitesetup(setup) + end + flushcollected(flush,#found) + end + if mark then + flushmarked(dataset,list,todo) end end --- num is somewhat special as it can be more and we need to deal with ranges here +function citevariants.authoryear(dataset,reference,mark,compress) + authorandyear(dataset,reference,mark,compress,"authoryear") +end -function citevariants.num(dataset,tags) --- ctx_btxdirectlink(f_destination(dataset,block,tags),listindex) -- not okay yet - lists.resolve(dataset,tags) +function citevariants.authoryears(dataset,reference,mark,compress) + authorandyear(dataset,reference,mark,compress,"authoryears") end -- List variants @@ -1394,7 +1570,7 @@ publications.listvariants = listvariants -- function commands.btxhandlelist(dataset,block,tag,variant,setup) -- if sorttype and sorttype ~= "" then --- tags = sortedtags(dataset,tags,sorttype) +-- tag = sortedtags(dataset,tag,sorttype) -- end -- ctx_setvalue("currentbtxtag",tag) -- ctx_btxlistvariantparameter(v_left) @@ -1402,34 +1578,171 @@ publications.listvariants = listvariants -- ctx_btxlistvariantparameter(v_right) -- end -function commands.btxlistvariant(dataset,block,tags,variant,listindex) +function commands.btxlistvariant(dataset,block,tag,variant,listindex) local action = listvariants[variant] or listvariants.default if action then - action(dataset,block,tags,variant,tonumber(listindex) or 0) + action(dataset,block,tag,variant,tonumber(listindex) or 0) end end -function listvariants.default(dataset,block,tags,variant) +function listvariants.default(dataset,block,tag,variant) context("?") end -function listvariants.num(dataset,block,tags,variant,listindex) - ctx_btxdirectlink(f_destination(dataset,block,tags),listindex) -- not okay yet +function listvariants.num(dataset,block,tag,variant,listindex) + local lst = f_listentry(dataset,block,tag) + local ref = f_reference(dataset,block,tag) + if trace_references then + report_reference("list: %s",lst) + end + -- todo + ctx_btxdirectlink(ref,listindex) -- a goto end --- function listvariants.short(dataset,block,tags,variant,listindex) --- local short = getdetail(dataset,tags,variant,variant) --- if short then --- context(short) --- end --- end - -function listvariants.short(dataset,block,tags,variant,listindex) - local short = getdetail(dataset,tags,"short","short") - local suffix = getdetail(dataset,tags,"suffix","suffix") +function listvariants.short(dataset,block,tag,variant,listindex) + local short = getdetail(dataset,tag,"short","short") + local suffix = getdetail(dataset,tag,"suffix","suffix") if suffix then context(short .. suffix) elseif short then context(short) 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 + +-- function publications.citeconcat(t) +-- local n = #t +-- if n > 0 then +-- context(t[1]) +-- if n > 1 then +-- if n > 2 then +-- for i=2,n-1 do +-- ctx_btxcitevariantparameter("sep") +-- context(t[i]) +-- end +-- ctx_btxcitevariantparameter("finalsep") +-- else +-- ctx_btxcitevariantparameter("lastsep") +-- end +-- context(t[n]) +-- end +-- end +-- end + +-- function publications.listconcat(t) +-- local n = #t +-- if n > 0 then +-- context(t[1]) +-- if n > 1 then +-- if n > 2 then +-- for i=2,n-1 do +-- ctx_btxlistparameter("sep") +-- context(t[i]) +-- end +-- ctx_btxlistparameter("finalsep") +-- else +-- ctx_btxlistparameter("lastsep") +-- end +-- context(t[n]) +-- end +-- end +-- end diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index d3cdd1fd3..45cc7325a 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -15,6 +15,7 @@ % 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: \the\everysetupbtxciteplacement probably too often % \definecolor[btx:field] [darkred] % \definecolor[btx:crossref][darkblue] @@ -44,7 +45,8 @@ \unprotect -\def\s!btx{btx} +\def\s!btx {btx} +\def\s!cite {cite} \def\v!btxlist{btxlist} % a dedicated construction mechanism @@ -428,7 +430,8 @@ keyword = "\btxrenderingparameter\c!keyword", }}% % next we analyze the width - \ifx\btx_reference_inject_indeed\relax \else + \ifx\btx_reference_inject_indeed\relax + \else \edef\p_width{\btxrenderingparameter\c!width}% \ifx\p_width\v!auto \scratchcounter\btxcounter @@ -558,38 +561,44 @@ % \btxflushauthor[inverted]{author} % \btxflushauthor[invertedshort]{author} -% Interaction +% Interaction: only list \newconditional\btxinteractive -\unexpanded\def\btxdoifelseinteraction - {\iflocation - \edef\p_interaction{\btxcitevariantparameter\c!interaction}% - \ifx\p_interaction\v!stop - \doubleexpandafter\secondoftwoarguments - \else - \doubleexpandafter\firstoftwoarguments - \fi - \else - \expandafter\secondoftwoarguments - \fi} +\unexpanded\def\btxdoifelseinteraction{\secondoftwoarguments} \appendtoks \iflocation \edef\p_interaction{\btxlistvariantparameter\c!interaction}% \ifx\p_interaction\v!stop - \let\doifelsebtxinteractionelse\secondoftwoarguments + \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \else - \let\doifelsebtxinteractionelse\firstoftwoarguments + \let\btxdoifelseinteraction\firstoftwoarguments \settrue\btxinteractive \fi \else - \let\doifelsebtxinteractionelse\secondoftwoarguments + \let\btxdoifelseinteraction\secondoftwoarguments \setfalse\btxinteractive \fi \to \everysetupbtxlistplacement +\appendtoks + \iflocation + \edef\p_interaction{\btxcitevariantparameter\c!interaction}% + \ifx\p_interaction\v!stop + \let\btxdoifelseinteraction\secondoftwoarguments + \setfalse\btxinteractive + \else + \let\btxdoifelseinteraction\firstoftwoarguments + \settrue\btxinteractive + \fi + \else + \let\btxdoifelseinteraction\secondoftwoarguments + \setfalse\btxinteractive + \fi +\to \everysetupbtxciteplacement + % bib -> btx \unexpanded\def\btxgotolink#1[#2]{\doifreferencefoundelse{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}} @@ -651,15 +660,21 @@ % \iftrialtypesetting \else % \processcommacommand[\currentbtxtag]{\publ_cite_indeed\currentbtxrendering}% % \fi} +% +% \def\publ_cite_indeed#1#2% +% {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}} -\def\publ_cite_indeed#1#2% - {\expanded{\writedatatolist[btx][btxset=#1,btxref=#2]}} - -\def\btxdomarkcitation#1#2% called from lua end - {\iftrialtypesetting \else - \writedatatolist[btx][btxset=#1,btxref=#2]% \c!location=\v!here +\unexpanded\def\btxdomarkcitation % called from lua end + {\iftrialtypesetting + \expandafter\gobbletwoarguments + \else + \expandafter\publ_cite_mark_citation \fi} +\def\publ_cite_mark_citation#1#2% called from lua end + {\dontleavehmode + \writedatatolist[btx][btxset=#1,btxref=#2]} % \c!location=\v!here + %D \macros{cite,nocite,citation,nocitation,usecitation} %D %D The inline \type {\cite} command creates a (often) short reference to a publication @@ -687,6 +702,7 @@ {\letinteractionparameter\c!style\empty \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% \edef\currentbtxcitetag{#1}% + \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} @@ -723,39 +739,37 @@ \def\publ_cite_tags_variants_indeed#1% {\letinteractionparameter\c!style\empty \edef\currentbtxcitevariant{#1}% + \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} \newconditional\btxcitecompress \def\publ_cite_variant - {\edef\p_compress{\btxcitevariantparameter\c!compress}% - % \ifx\p_compress\v!no - % \setfalse\btxcitecompress - % \else - % \settrue\btxcitecompress - % \fi - \begingroup + {\begingroup \settrue\c_publ_cite_write \publ_cite_handle_variant_indeed[\currentbtxcitetag]} \unexpanded\def\publ_cite_handle_variant#1% {\begingroup - \the\everysetupbtxciteplacement \edef\currentbtxcitevariant{#1}% + \the\everysetupbtxciteplacement \dosingleargument\publ_cite_handle_variant_indeed} \def\publ_cite_handle_variant_indeed[#1]% {\usebtxcitevariantstyleandcolor\c!style\c!color \letbtxcitevariantparameter\c!alternative\currentbtxcitevariant + \btxcitevariantparameter\v!left + \edef\p_compress{\btxcitevariantparameter\c!compress}% \ctxcommand{btxhandlecite(% "\currentbtxdataset",% "#1",% \iftrialtypesetting false\else true\fi,% "\currentbtxcitevariant",% "\btxcitevariantparameter\c!sorttype",% - "\btxcitevariantparameter\c!setups"% + \ifx\p_compress\v!no false\else true\fi% )}% + \btxcitevariantparameter\v!right \endgroup} \unexpanded\def\btxcitation @@ -778,6 +792,9 @@ \ctxcommand{btxhandlenocite("\currentbtxdataset","#1",true)}% \fi} +\unexpanded\def\btxmissing#1% + {{\tttf<#1>}} + %D Compatibility: \let\cite \btxcite @@ -788,9 +805,31 @@ %D Cite helpers: +\newconstant\currentbtxconcat + \unexpanded\def\btxcitevariant#1% {\ctxcommand{btxcitevariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","#1")}} +\unexpanded\def\btxcitereset + {\let\currentbtxfirst \empty + \let\currentbtxsecond \empty + \let\currentbtxinternal\empty + \setconstant\currentbtxconcat\zerocount} + +\btxcitereset + +\unexpanded\def\btxcitesetup#1% + {\directsetup{btx:cite:#1}% + \btxcitereset} + +\unexpanded\def\btxsetfirst {\def\currentbtxfirst} +\unexpanded\def\btxsetsecond {\def\currentbtxsecond} +\unexpanded\def\btxsetinternal{\def\currentbtxinternal} +\unexpanded\def\btxsetconcat#1{\setconstant\currentbtxconcat#1\relax} + +\unexpanded\def\btxsetreference#1#2% #3#4% + {\strc_references_direct_full_user{btxset="#1",btxref="#2"}} + %D List helpers: \def\currentbtxindex{0} @@ -842,9 +881,11 @@ \c!otherstext={ et al.}, \c!pubsep={, }, \c!lastpubsep={ and }, + \c!finalpubsep={ and }, \c!compress=\v!no, \c!inbetween={ }, \c!left=, + \c!middle=, \c!right=] \definebtxcitevariant @@ -869,52 +910,70 @@ \definebtxcitevariant [authornum] [author] - [\c!left={[}, - \c!right={]}] + [num:\c!left={[}, + num:\c!right={]}, + num:\c!middle={, }] \definebtxcitevariant [year] [\c!left={(}, + \c!middle={, }, \c!right={)}] \definebtxcitevariant - [key] + [tag] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant + [key] + [tag] + +\definebtxcitevariant [serial] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant [page] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant [short] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant - [type] + [category] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant + [type] + [category] + +\definebtxcitevariant [doi] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant [url] [\c!left={[}, + \c!middle={, }, \c!right={]}] \definebtxcitevariant [page] [\c!left=, + \c!middle={, }, \c!right=, \c!inbetween=\endash] diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex bf8fea46e..b9aff479b 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 bff2e9dc7..110046752 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 0c8bb6e53..3f2c0608d 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -158,7 +158,7 @@ local function initializer() -- can we use a tobesaved as metatable for collecte local r = data.references local i = r.internal if i then - internals[i] = c + internals[i] = data usedinternals[i] = r.used end end diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index 76d79b802..359bb4a76 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -263,10 +263,11 @@ \lastdestinationattribute\attributeunsetvalue \fi} -\unexpanded\def\strc_references_direct_full#labels#text% +\unexpanded\def\strc_references_direct_full_user#user#labels#text% {\ifreferencing \strc_references_start_destination_nodes -\setnextinternalreference + \setnextinternalreference + \edef\m_strc_references_user{#user}% \ctxcommand{setreferenceattribute("\s!full", "\referenceprefix","#labels", { references = { @@ -280,6 +281,11 @@ entries = { text = \!!bs#text\!!es }, + \ifx\m_strc_references_user\empty \else + userdata = { + \m_strc_references_user + } + \fi },"\interactionparameter\c!focus") }% \strc_references_stop_destination_nodes @@ -297,7 +303,10 @@ \prewordbreak % new \fi} -\let\dodirectfullreference\strc_references_direct_full % for at lua end +\unexpanded\def\strc_references_direct_full + {\strc_references_direct_full_user\empty} + +\let\dodirectfullreference\strc_references_direct_full % for at lua end (no longer) \def\strc_references_set_page_only_destination_box_attribute#cs#labels% {\strc_references_set_page_only_destination_attribute{#labels}% diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua index af4f7c643..5a8bdabd3 100644 --- a/tex/context/base/trac-deb.lua +++ b/tex/context/base/trac-deb.lua @@ -209,7 +209,7 @@ function tracers.printerror(specification) report_nl() if luaerrorline then report("error on line %s in file %s:\n\n%s",linenumber,filename,lastluaerror) --- report("error on line %s in file %s:\n\n%s",linenumber,filename,lasttexerror) + -- report("error on line %s in file %s:\n\n%s",linenumber,filename,lasttexerror) else report("error on line %s in file %s: %s",linenumber,filename,lasttexerror) if tex.show_context then diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua index 45cc550d4..72f271d9c 100644 --- a/tex/context/base/trac-log.lua +++ b/tex/context/base/trac-log.lua @@ -17,7 +17,7 @@ if not modules then modules = { } end modules ['trac-log'] = { -- local texio_write_nl = texio.write_nl -- local texio_write = texio.write -- local io_write = io.write - +-- -- local write_nl = function(target,...) -- if not io_write then -- io_write = io.write @@ -37,7 +37,7 @@ if not modules then modules = { } end modules ['trac-log'] = { -- io_write(target,...) -- end -- end - +-- -- local write = function(target,...) -- if not io_write then -- io_write = io.write @@ -54,7 +54,7 @@ if not modules then modules = { } end modules ['trac-log'] = { -- io_write(target,...) -- end -- end - +-- -- texio.write = write -- texio.write_nl = write_nl -- diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml index 0a0b9b9a6..7053ceed7 100644 --- a/tex/context/interface/keys-cs.xml +++ b/tex/context/interface/keys-cs.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='soubor'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='prvnistranka'/> <cd:constant name='focus' value='zaostreni'/> diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml index 28b21b915..7164db6e3 100644 --- a/tex/context/interface/keys-de.xml +++ b/tex/context/interface/keys-de.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='datei'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='ersteseite'/> <cd:constant name='focus' value='focus'/> diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml index da433cdee..354b86d65 100644 --- a/tex/context/interface/keys-en.xml +++ b/tex/context/interface/keys-en.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='file'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='firstpage'/> <cd:constant name='focus' value='focus'/> diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml index 6a8eaa9c5..0e4f9e516 100644 --- a/tex/context/interface/keys-fr.xml +++ b/tex/context/interface/keys-fr.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='fichier'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='premierepage'/> <cd:constant name='focus' value='focus'/> diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index c7c996318..afc33eb22 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='file'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='primapagina'/> <cd:constant name='focus' value='focus'/> diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index c87088a09..9abfe5d7a 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='file'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='eerstepagina'/> <cd:constant name='focus' value='focus'/> diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml index 8e4d412d5..517c41ed0 100644 --- a/tex/context/interface/keys-pe.xml +++ b/tex/context/interface/keys-pe.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='پرونده'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='صفحهاول'/> <cd:constant name='focus' value='تمرکز'/> diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml index f9ef01b9f..b7f5b2e19 100644 --- a/tex/context/interface/keys-ro.xml +++ b/tex/context/interface/keys-ro.xml @@ -707,6 +707,7 @@ <cd:constant name='file' value='fisier'/> <cd:constant name='filtercommand' value='filtercommand'/> <cd:constant name='finalnamesep' value='finalnamesep'/> + <cd:constant name='finalpubsep' value='finalpubsep'/> <cd:constant name='firstnamesep' value='firstnamesep'/> <cd:constant name='firstpage' value='primapagina'/> <cd:constant name='focus' value='focus'/> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index ee0c00e82..51d861af4 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 : 05/13/14 00:04:28 +-- merge date : 05/15/14 19:52:15 do -- begin closure to overcome local limits and interference @@ -125,7 +125,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=crlf+S("\r\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -147,8 +147,8 @@ patterns.utfbom_32_le=utfbom_32_le patterns.utfbom_16_be=utfbom_16_be patterns.utfbom_16_le=utfbom_16_le patterns.utfbom_8=utfbom_8 -patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") -patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") +patterns.utf_16_be_nl=P("\000\r\000\n")+P("\000\r")+P("\000\n") +patterns.utf_16_le_nl=P("\r\000\n\000")+P("\r\000")+P("\n\000") patterns.utf8one=R("\000\127") patterns.utf8two=R("\194\223")*utf8next patterns.utf8three=R("\224\239")*utf8next*utf8next |