diff options
author | Karl Berry <karl@freefriends.org> | 2015-05-11 21:37:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-05-11 21:37:36 +0000 |
commit | 0053a5222ec78ba41126c246eafd8cdb02f9a56a (patch) | |
tree | 22b38b1430bb1084ec8357362fc51d55ffd2fddb /Master/texmf-dist/tex/context | |
parent | c4e86cc3b89e06b5f6a6ea80c907cfa69a7231da (diff) |
context/11may15
git-svn-id: svn://tug.org/texlive/trunk@37341 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context')
45 files changed, 1454 insertions, 718 deletions
diff --git a/Master/texmf-dist/tex/context/base/back-exp.lua b/Master/texmf-dist/tex/context/base/back-exp.lua index 9e127cb095c..33b6aa1e8ea 100644 --- a/Master/texmf-dist/tex/context/base/back-exp.lua +++ b/Master/texmf-dist/tex/context/base/back-exp.lua @@ -68,6 +68,7 @@ local attributes = attributes local variables = interfaces.variables local v_yes = variables.yes local v_no = variables.no +local v_hidden = variables.hidden local implement = interfaces.implement @@ -202,6 +203,8 @@ local p_attribute = lpeg.replacer(attribentities) local p_stripper = lpeg.patterns.stripper local p_escaped = lpeg.patterns.xml.escaped +local f_tagid = formatters["%s-%04i"] + -- local alignmapping = { -- flushright = "right", -- middle = "center", @@ -1002,10 +1005,10 @@ end do - local automathrows = true directives.register("backend.export.math.autorows", function(v) automathrows = v end) - local automathapply = true directives.register("backend.export.math.autoapply", function(v) automathapply = v end) - local automathnumber = true directives.register("backend.export.math.autonumber", function(v) automathnumber = v end) - local automathstrip = true directives.register("backend.export.math.autostrip", function(v) automathstrip = v end) + local automathrows = true directives.register("export.math.autorows", function(v) automathrows = v end) + local automathapply = true directives.register("export.math.autoapply", function(v) automathapply = v end) + local automathnumber = true directives.register("export.math.autonumber", function(v) automathnumber = v end) + local automathstrip = true directives.register("export.math.autostrip", function(v) automathstrip = v end) local functions = mathematics.categories.functions @@ -1838,7 +1841,7 @@ do result[#result+1] = "</p>\n" end - local function emptytag(result,element,nature,di) -- currently only break but at some point + local function emptytag(result,embedded,element,nature,di) -- currently only break but at some point local a = di.attributes -- we might add detail etc if a then -- happens seldom if nature == "display" then @@ -1859,7 +1862,7 @@ do end end - local function begintag(result,element,nature,di,skip) + local function begintag(result,embedded,element,nature,di,skip) local index = di.n local fulltag = di.fulltag local specification = specifications[fulltag] or { } -- we can have a dummy @@ -1882,6 +1885,13 @@ do elseif skip then -- ignore else + + -- if embedded then + -- if element == "math" then + -- embedded[f_tagid(element,index)] = #result+1 + -- end + -- end + local n = 0 local r = { } -- delay this if detail then @@ -1991,7 +2001,7 @@ do end end - local function endtag(result,element,nature,di,skip) + local function endtag(result,embedded,element,nature,di,skip) if skip == "comment" then if show_comment then if nature == "display" and (inline == 0 or inline == 1) then @@ -2022,10 +2032,18 @@ do inline = inline - 1 result[#result+1] = f_end_inline(namespaced[element]) end + + -- if embedded then + -- if element == "math" then + -- local id = f_tagid(element,di.n) -- index) + -- local tx = concat(result,"",embedded[id],#result) + -- embedded[id] = "<?xml version='1.0' standalone='yes'?>" .. "\n" .. tx + -- end + -- end end end - local function flushtree(result,data,nature) + local function flushtree(result,embedded,data,nature) local nofdata = #data for i=1,nofdata do local di = data[i] @@ -2033,7 +2051,7 @@ do -- whatever else local content = di.content --- also optimize for content == "" : trace that first + -- also optimize for content == "" : trace that first if content then -- already has breaks local content = lpegmatch(p_entity,content) @@ -2057,23 +2075,23 @@ do if not element then -- skip elseif element == "break" then -- or element == "pagebreak" - emptytag(result,element,nature,di) + emptytag(result,embedded,element,nature,di) elseif element == "" or di.skip == "ignore" then -- skip else if di.before then - flushtree(result,di.before,nature) + flushtree(result,embedded,di.before,nature) end local natu = di.nature local skip = di.skip if di.breaknode then - emptytag(result,"break","display",di) + emptytag(result,embedded,"break","display",di) end - begintag(result,element,natu,di,skip) - flushtree(result,di.data,natu) - endtag(result,element,natu,di,skip) + begintag(result,embedded,element,natu,di,skip) + flushtree(result,embedded,di.data,natu) + endtag(result,embedded,element,natu,di,skip) if di.after then - flushtree(result,di.after,nature) + flushtree(result,embedded,di.after,nature) end end end @@ -2976,14 +2994,15 @@ local htmltemplate = [[ return concat(result,"\n\n") end - local function allcontent(tree) - local result = { } - flushtree(result,tree.data,"display") -- we need to collect images + local function allcontent(tree,embed) + local result = { } + local embedded = embed and { } + flushtree(result,embedded,tree.data,"display") -- we need to collect images result = concat(result) -- no need to lpeg .. fast enough result = gsub(result,"\n *\n","\n") result = gsub(result,"\n +([^< ])","\n%1") - return result + return result, embedded end -- local xhtmlpreamble = [[ @@ -3217,6 +3236,9 @@ local htmltemplate = [[ local addsuffix = file.addsuffix local joinfile = file.join + local embedfile = false directives.register("export.embed",function(v) embedfile = v end) + local embedmath = false + local function stopexport(v) starttiming(treehash) @@ -3359,9 +3381,39 @@ local htmltemplate = [[ end end - local result = allcontent(tree) + local result, embedded = allcontent(tree,embedmath) -- embedfile is for testing - local results = concat { + local attach = backends.nodeinjections.attachfile + + if embedfile and attach then + -- only for testing + attach { + data = concat{ wholepreamble(true), result }, + name = file.basename(xmlfilename), + registered = "export", + title = "raw xml export", + method = v_hidden, + mimetype = "application/mathml+xml", + } + end + -- if embedmath and attach then + -- local refs = { } + -- for k, v in sortedhash(embedded) do + -- attach { + -- data = v, + -- file = file.basename(k), + -- name = file.addsuffix(k,"xml"), + -- registered = k, + -- reference = k, + -- title = "xml export snippet: " .. k, + -- method = v_hidden, + -- mimetype = "application/mathml+xml", + -- } + -- refs[k] = 0 + -- end + -- end + + result = concat { wholepreamble(true), x_styles, -- adds to files result, @@ -3372,7 +3424,7 @@ local htmltemplate = [[ -- we're now ready for saving the result in the xml file report_export("saving xml data in %a",xmlfilename) - io.savedata(xmlfilename,results) + io.savedata(xmlfilename,result) report_export("saving css image definitions in %a",imagefilename) io.savedata(imagefilename,wrapups.allusedimages(basename)) @@ -3387,7 +3439,7 @@ local htmltemplate = [[ report_export("saving xhtml variant in %a",xhtmlfilename) - local xmltree = cleanxhtmltree(xml.convert(results)) + local xmltree = cleanxhtmltree(xml.convert(result)) xml.save(xmltree,xhtmlfilename) @@ -3465,8 +3517,6 @@ local htmltemplate = [[ end end - - local function startexport(v) if v and not exporting then report_export("enabling export to xml") @@ -3477,8 +3527,15 @@ local htmltemplate = [[ enableaction("math", "noads.handlers.tags") -- appendaction("finalizers","lists","builders.paragraphs.tag") -- enableaction("finalizers","builders.paragraphs.tag") - luatex.registerstopactions(function() stopexport(v) end) - exporting = true + luatex.registerstopactions(structurestags.finishexport) + exporting = v + end + end + + function structurestags.finishexport() + if exporting then + stopexport(exporting) + exporting = false end end @@ -3516,6 +3573,11 @@ implement { } implement { + name = "finishexport", + actions = structurestags.finishexport, +} + +implement { name = "settagitemgroup", actions = structurestags.setitemgroup, arguments = { "boolean", "integer", "string" } diff --git a/Master/texmf-dist/tex/context/base/back-exp.mkiv b/Master/texmf-dist/tex/context/base/back-exp.mkiv index bddb6de4d92..a4ebe38aafa 100644 --- a/Master/texmf-dist/tex/context/base/back-exp.mkiv +++ b/Master/texmf-dist/tex/context/base/back-exp.mkiv @@ -240,6 +240,12 @@ \doifsomething{\backendparameter\c!export}\dosynchronizeexport \to \everystarttext +% better (before pdf gets closed, so we can embed), but it needs testing: + +\appendtoks + \clf_finishexport +\to \everystoptext + \appendtoks \doifsomething{\backendparameter\c!export}\dosynchronizeexport % in case it is done inside \starttext \to \everysetupdocument diff --git a/Master/texmf-dist/tex/context/base/char-ini.lua b/Master/texmf-dist/tex/context/base/char-ini.lua index c6192cc9bc1..4559fa28c49 100644 --- a/Master/texmf-dist/tex/context/base/char-ini.lua +++ b/Master/texmf-dist/tex/context/base/char-ini.lua @@ -828,6 +828,9 @@ local categories = allocate() characters.categories = categories -- lazy table setmetatableindex(categories, function(t,u) if u then local c = data[u] c = c and c.category or u t[u] = c return c end end) +-- todo: overloads (these register directly in the tables as number and string) e.g. for greek +-- todo: for string do a numeric lookup in the table itself + local lccodes = allocate() characters.lccodes = lccodes -- lazy table local uccodes = allocate() characters.uccodes = uccodes -- lazy table local shcodes = allocate() characters.shcodes = shcodes -- lazy table diff --git a/Master/texmf-dist/tex/context/base/char-tex.lua b/Master/texmf-dist/tex/context/base/char-tex.lua index 62bb6a04107..2093c6d6c68 100644 --- a/Master/texmf-dist/tex/context/base/char-tex.lua +++ b/Master/texmf-dist/tex/context/base/char-tex.lua @@ -286,6 +286,13 @@ local commandmapping = allocate { texcharacters.commandmapping = commandmapping +local ligaturemapping = allocate { + ["''"] = "”", + ["``"] = "“", + ["--"] = "–", + ["---"] = "—", +} + -- local achar = R("az","AZ") + P("ı") + P("\\i") -- -- local spaces = P(" ")^0 @@ -355,6 +362,9 @@ local function toutfpattern() hash["{\\"..k.."}"] = v hash["{\\"..k.." }"] = v end + for k, v in next, ligaturemapping do + hash[k] = v + end untex = utfchartabletopattern(hash) / hash end return untex diff --git a/Master/texmf-dist/tex/context/base/char-utf.lua b/Master/texmf-dist/tex/context/base/char-utf.lua index 9ed861be097..381602ededb 100644 --- a/Master/texmf-dist/tex/context/base/char-utf.lua +++ b/Master/texmf-dist/tex/context/base/char-utf.lua @@ -478,11 +478,15 @@ function utffilters.addgrapheme(result,first,second) -- can be U+ 0x string or u end end -interfaces.implement { - name = "addgrapheme", - actions = utffilters.addgrapheme, - arguments = { "string", "string", "string" } -} +if interfaces then -- eventually this goes to char-ctx.lua + + interfaces.implement { + name = "addgrapheme", + actions = utffilters.addgrapheme, + arguments = { "string", "string", "string" } + } + +end -- -- diff --git a/Master/texmf-dist/tex/context/base/cont-new.mkiv b/Master/texmf-dist/tex/context/base/cont-new.mkiv index fc87c486305..7aaabd8b0bf 100644 --- a/Master/texmf-dist/tex/context/base/cont-new.mkiv +++ b/Master/texmf-dist/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.05.04 19:00} +\newcontextversion{2015.05.10 20:08} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/Master/texmf-dist/tex/context/base/context-version.pdf b/Master/texmf-dist/tex/context/base/context-version.pdf Binary files differindex 298f490b5d0..2c9b4c63eac 100644 --- a/Master/texmf-dist/tex/context/base/context-version.pdf +++ b/Master/texmf-dist/tex/context/base/context-version.pdf diff --git a/Master/texmf-dist/tex/context/base/context.mkiv b/Master/texmf-dist/tex/context/base/context.mkiv index 9a2ae1bde83..3b70cecc2aa 100644 --- a/Master/texmf-dist/tex/context/base/context.mkiv +++ b/Master/texmf-dist/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.05.04 19:00} +\edef\contextversion{2015.05.10 20:08} \edef\contextkind {beta} %D For those who want to use this: @@ -464,7 +464,7 @@ \loadmarkfile{anch-bar} %loadmarkfile{anch-snc} % when needed this one will be redone -\loadmarkfile{math-ini} +\loadmarkfile{math-ini} % way after font-pre ! \loadmarkfile{math-pln} \loadmarkfile{math-for} \loadmarkfile{math-def} % also saves some meanings diff --git a/Master/texmf-dist/tex/context/base/core-uti.lua b/Master/texmf-dist/tex/context/base/core-uti.lua index 346dec89e9e..a4b74768053 100644 --- a/Master/texmf-dist/tex/context/base/core-uti.lua +++ b/Master/texmf-dist/tex/context/base/core-uti.lua @@ -38,7 +38,7 @@ local report_passes = logs.reporter("job","passes") job = job or { } local job = job -job.version = 1.29 +job.version = 1.30 job.packversion = 1.02 -- some day we will implement loading of other jobs and then we need diff --git a/Master/texmf-dist/tex/context/base/font-odv.lua b/Master/texmf-dist/tex/context/base/font-odv.lua index ca1b9ddf0c8..2ef1aabe7ea 100644 --- a/Master/texmf-dist/tex/context/base/font-odv.lua +++ b/Master/texmf-dist/tex/context/base/font-odv.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['font-odv'] = { license = "see context related readme files" } +-- One day I'll speed this up ... char swapping and properties. + -- A few remarks: -- -- This code is a partial rewrite of the code that deals with devanagari. The data and logic @@ -155,18 +157,26 @@ replace_all_nbsp = function(head) -- delayed definition return replace_all_nbsp(head) end -local fontprocesses = fonts.hashes.processes local xprocesscharacters = nil -xprocesscharacters = function(head,font) - xprocesscharacters = nodes.handlers.nodepass - return xprocesscharacters(head,font) +if context then + xprocesscharacters = function(head,font) + xprocesscharacters = nodes.handlers.characters + return xprocesscharacters(head,font) + end +else + xprocesscharacters = function(head,font) + xprocesscharacters = nodes.handlers.nodepass -- generic + return xprocesscharacters(head,font) + end end local function processcharacters(head,font) return tonut(xprocesscharacters(tonode(head))) end +-- local fontprocesses = fonts.hashes.processes +-- -- function processcharacters(head,font) -- local processors = fontprocesses[font] -- for i=1,#processors do diff --git a/Master/texmf-dist/tex/context/base/lpdf-tag.lua b/Master/texmf-dist/tex/context/base/lpdf-tag.lua index dbe4d3f1ee7..79ccfe07596 100644 --- a/Master/texmf-dist/tex/context/base/lpdf-tag.lua +++ b/Master/texmf-dist/tex/context/base/lpdf-tag.lua @@ -90,9 +90,23 @@ local lasttaginchain = structurestags.lastinchain local usedmapping = { } --- local tagsplitter = structurestags.patterns.splitter +----- tagsplitter = structurestags.patterns.splitter -local add_ids = false -- true +-- local embeddedtags = false -- true will id all, for tracing +-- local f_tagid = formatters["%s-%04i"] +-- local embeddedfilelist = pdfarray() -- /AF crap +-- +-- directives.register("structures.tags.embedmath",function(v) +-- if not v then +-- -- only enable +-- elseif embeddedtags == true then +-- -- already all tagged +-- elseif embeddedtags then +-- embeddedtags.math = true +-- else +-- embeddedtags = { math = true } +-- end +-- end) -- function codeinjections.maptag(original,target,kind) -- mapping[original] = { target, kind or "inline" } @@ -110,7 +124,7 @@ local function finishstructure() } -- we need to split names into smaller parts (e.g. alphabetic or so) -- we already have code for that somewhere - if add_ids then + if #names > 0 then local kids = pdfdictionary { Limits = pdfarray { names[1], names[#names-1] }, Names = names, @@ -130,7 +144,7 @@ local function finishstructure() Type = pdfconstant("StructTreeRoot"), K = pdfreference(pdfflushobject(structure_kids)), ParentTree = pdfreference(pdfflushobject(parent_ref,parenttree)), - IDTree = (add_ids and pdfreference(pdfflushobject(idtree))) or nil, + IDTree = #names > 0 and pdfreference(pdfflushobject(idtree)) or nil, RoleMap = rolemap, } pdfflushobject(structure_ref,structuretree) @@ -140,6 +154,7 @@ local function finishstructure() Marked = pdfboolean(true), -- UserProperties = pdfboolean(true), -- Suspects = pdfboolean(true), + -- AF = #embeddedfilelist > 0 and pdfreference(pdfflushobject(embeddedfilelist)) or nil, } addtocatalog("MarkInfo",pdfreference(pdfflushobject(markinfo))) -- @@ -204,13 +219,31 @@ local function makeelement(fulltag,parent) -- usedmapping[tag] = true -- + -- specification.attribute is unique + -- + local id = nil + -- local af = nil + -- if embeddedtags then + -- local tagname = specification.tagname + -- local tagindex = specification.tagindex + -- if embeddedtags == true or embeddedtags[tagname] then + -- id = f_tagid(tagname,tagindex) + -- af = job.fileobjreferences.collected[id] + -- if af then + -- local r = pdfreference(af) + -- af = pdfarray { r } + -- -- embeddedfilelist[#embeddedfilelist+1] = r + -- end + -- end + -- end + -- local k = pdfarray() local r = pdfreserveobject() local t = usedlabels[tag] or tag local d = pdfdictionary { Type = pdf_struct_element, S = pdfconstant(t), - ID = (add_ids and fulltag) or nil, + ID = id, T = detail and detail or nil, P = parent.pref, Pg = pageref, @@ -218,15 +251,22 @@ local function makeelement(fulltag,parent) A = a and makeattribute(a) or nil, -- Alt = " Who cares ", -- ActualText = " Hi Hans ", + AF = af, } local s = pdfreference(pdfflushobject(d)) - if add_ids then - names[#names+1] = fulltag + if id then + names[#names+1] = id names[#names+1] = s end local kids = parent.kids kids[#kids+1] = s - local e = { tag = t, pref = s, kids = k, knum = r, pnum = pagenum } + local e = { + tag = t, + pref = s, + kids = k, + knum = r, + pnum = pagenum + } elements[fulltag] = e return e end diff --git a/Master/texmf-dist/tex/context/base/lpdf-wid.lua b/Master/texmf-dist/tex/context/base/lpdf-wid.lua index 895bbd3ffb2..22971c2b710 100644 --- a/Master/texmf-dist/tex/context/base/lpdf-wid.lua +++ b/Master/texmf-dist/tex/context/base/lpdf-wid.lua @@ -177,10 +177,27 @@ local function analyzetransparency(transparencyvalue) end -- Attachments +local nofattachments = 0 +local attachments = { } +local filestreams = { } +local referenced = { } +local ignorereferenced = true -- fuzzy pdf spec .. twice in attachment list, can become an option +local tobesavedobjrefs = utilities.storage.allocate() +local collectedobjrefs = utilities.storage.allocate() + +local fileobjreferences = { + collected = collectedobjrefs, + tobesaved = tobesavedobjrefs, +} + +job.fileobjreferences = fileobjreferences -local nofattachments, attachments, filestreams, referenced = 0, { }, { }, { } +local function initializer() + collectedobjrefs = job.fileobjreferences.collected or { } + tobesavedobjrefs = job.fileobjreferences.tobesaved or { } +end -local ignorereferenced = true -- fuzzy pdf spec .. twice in attachment list, can become an option +job.register('job.fileobjreferences.collected', tobesavedobjrefs, initializer) local function flushembeddedfiles() if next(filestreams) then @@ -209,6 +226,7 @@ function codeinjections.embedfile(specification) local hash = specification.hash or filename local keepdir = specification.keepdir -- can change local usedname = specification.usedname + local filetype = specification.filetype if filename == "" then filename = nil end @@ -246,11 +264,20 @@ function codeinjections.embedfile(specification) end end end - usedname = usedname ~= "" and usedname or filename + -- needs to cleaned up: + usedname = usedname ~= "" and usedname or filename or name local basename = keepdir == true and usedname or file.basename(usedname) -local basename = gsub(basename,"%./","") - local savename = file.addsuffix(name ~= "" and name or basename,"txt") -- else no valid file - local a = pdfdictionary { Type = pdfconstant("EmbeddedFile") } + local basename = gsub(basename,"%./","") + local savename = name ~= "" and name or basename + if not filetype or filetype == "" then + filetype = name and (filename and file.suffix(filename)) or "txt" + end + savename = file.addsuffix(savename,filetype) -- type is mandate for proper working in viewer + local mimetype = specification.mimetype + local a = pdfdictionary { + Type = pdfconstant("EmbeddedFile"), + Subtype = mimetype and mimetype ~= "" and pdfconstant(mimetype) or nil, + } local f if data then f = pdfflushstreamobject(data,a) @@ -265,6 +292,7 @@ local basename = gsub(basename,"%./","") UF = pdfstring(savename), EF = pdfdictionary { F = pdfreference(f) }, Desc = title ~= "" and pdfunicode(title) or nil, + -- AFRelationship = pdfconstant("Source"), -- some day maybe, not mandate } local r = pdfreference(pdfflushobject(d)) filestreams[hash] = r @@ -318,6 +346,10 @@ function nodeinjections.attachfile(specification) aref = codeinjections.embedfile(specification) attachments[registered] = aref end + local reference = specification.reference + if reference and aref then + tobesavedobjrefs[reference] = aref[1] + end if not aref then report_attachment("skipping attachment, registered %a",registered) -- already reported diff --git a/Master/texmf-dist/tex/context/base/lxml-ini.lua b/Master/texmf-dist/tex/context/base/lxml-ini.lua index 2f63c857f70..115403395e5 100644 --- a/Master/texmf-dist/tex/context/base/lxml-ini.lua +++ b/Master/texmf-dist/tex/context/base/lxml-ini.lua @@ -46,6 +46,7 @@ implement { name = "xmlattribute", actions = lxml.attribute, implement { name = "xmlattributedef", actions = lxml.attribute, arguments = { "string", "string", "string", "string" } } implement { name = "xmlchainatt", actions = lxml.chainattribute, arguments = { "string", "'/'", "string" } } implement { name = "xmlchainattdef", actions = lxml.chainattribute, arguments = { "string", "'/'", "string", "string" } } +implement { name = "xmlrefatt", actions = lxml.refatt, arguments = { "string", "string" } } implement { name = "xmlchecknamespace", actions = xml.checknamespace, arguments = { "lxmlid", "string", "string" } } implement { name = "xmlcommand", actions = lxml.command, arguments = { "string", "string", "string" } } implement { name = "xmlconcat", actions = lxml.concat, arguments = { "string", "string", "string" } } -- \detokenize{#3} @@ -92,7 +93,7 @@ implement { name = "xmlregisterns", actions = xml.registerns, implement { name = "xmlremapname", actions = xml.remapname, arguments = { "lxmlid", "string","string","string" } } implement { name = "xmlremapnamespace", actions = xml.renamespace, arguments = { "lxmlid", "string", "string" } } implement { name = "xmlsave", actions = lxml.save, arguments = { "string", "string" } } -implement { name = "xmlsetfunction", actions = lxml.setaction, arguments = { "string", "string", "string" } } +--------- { name = "xmlsetfunction", actions = lxml.setaction, arguments = { "string", "string", "string" } } implement { name = "xmlsetsetup", actions = lxml.setsetup, arguments = { "string", "string", "string" } } implement { name = "xmlsnippet", actions = lxml.snippet, arguments = { "string", "string" } } implement { name = "xmlstrip", actions = lxml.strip, arguments = { "string", "string" } } @@ -135,3 +136,7 @@ implement { name = "xmlsetcommandtonone", actions = lxml.setcommandtonone, implement { name = "xmlstarttiming", actions = function() statistics.starttiming(lxml) end } implement { name = "xmlstoptiming", actions = function() statistics.stoptiming (lxml) end } + +-- kind of special (3rd argument is a function) + +commands.xmlsetfunction = lxml.setaction diff --git a/Master/texmf-dist/tex/context/base/lxml-ini.mkiv b/Master/texmf-dist/tex/context/base/lxml-ini.mkiv index 5ef4245a236..fab644fdb27 100644 --- a/Master/texmf-dist/tex/context/base/lxml-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/lxml-ini.mkiv @@ -40,6 +40,7 @@ %def\xmlattributedef #1#2#3#4{\clf_xmlattributedef {#1}{#2}{#3}{#4}} %def\xmlchainatt #1#2{\clf_xmlchainatt {#1}{#2}} %def\xmlchainattdef #1#2#3{\clf_xmlchainattdef {#1}{#2}{#3}} +%def\xmlrefatt #1#2{\clf_xmlrefatt {#1}{#2}} %def\xmlchecknamespace #1#2#3{\clf_xmlchecknamespace {#1}{#2}{#3}} % element %def\xmlcommand #1#2#3{\clf_xmlcommand {#1}{#2}{#3}} \def\xmlconcat #1#2#3{\clf_xmlconcat {#1}{#2}{\detokenize{#3}}} @@ -110,6 +111,7 @@ \let\xmlattributedef \clf_xmlattributedef \let\xmlchainatt \clf_xmlchainatt \let\xmlchainattdef \clf_xmlchainattdef +\let\xmlrefatt \clf_xmlrefatt \let\xmlchecknamespace \clf_xmlchecknamespace \let\xmlcommand \clf_xmlcommand % \xmlconcat @@ -156,7 +158,7 @@ \let\xmlremapname \clf_xmlremapname % element \let\xmlremapnamespace \clf_xmlremapnamespace % document \let\xmlsave \clf_xmlsave -\let\xmlsetfunction \clf_xmlsetfunction +%let\xmlsetfunction \clf_xmlsetfunction \let\xmlsetsetup \clf_xmlsetsetup \let\xmlsnippet \clf_xmlsnippet \let\xmlstrip \clf_xmlstrip @@ -175,6 +177,10 @@ \def\xmlinfo #1{\hbox{\ttxx[\clf_xmlinfo{#1}]}} \def\xmlshow #1{\startpacked\ttx\xmlverbatim{#1}\stoppacked} +% we need to pass the last argument as function, so + +\def\xmlsetfunction#1#2#3{\ctxcommand{xmlsetfunction("#1",\!!bs#2\!!es,#3)}} + % goodie: \unexpanded\def\xmlprettyprint#1#2% diff --git a/Master/texmf-dist/tex/context/base/lxml-tex.lua b/Master/texmf-dist/tex/context/base/lxml-tex.lua index 9e540fe7c69..550a06a1855 100644 --- a/Master/texmf-dist/tex/context/base/lxml-tex.lua +++ b/Master/texmf-dist/tex/context/base/lxml-tex.lua @@ -1597,6 +1597,22 @@ function lxml.att(id,a,default) end end +function lxml.refatt(id,a) + local e = getid(id) + if e then + local at = e.at + if at then + local str = at[a] + if str and str ~= "" then + str = gsub(str,"^#+","") + if str ~= "" then + contextsprint(notcatcodes,str) + end + end + end + end +end + function lxml.name(id) -- or remapped name? -> lxml.info, combine local e = getid(id) if e then diff --git a/Master/texmf-dist/tex/context/base/m-visual.mkiv b/Master/texmf-dist/tex/context/base/m-visual.mkiv index 3c57691ec64..d502159669a 100644 --- a/Master/texmf-dist/tex/context/base/m-visual.mkiv +++ b/Master/texmf-dist/tex/context/base/m-visual.mkiv @@ -192,8 +192,8 @@ {\dimen0\zeropoint \getrandomcount\scratchcounter{3}{6}% \dorecurse\scratchcounter - {\getrandomdimen\scratchdimen{1em}{3em}% - \mathinner{\red\fakerule\scratchdimen}% + {\getrandomdimen\scratchdimen{0.5em}{1.5em}% + \mathord{\red\fakerule\scratchdimen}% \ifnum\recurselevel<\scratchcounter+\fi \advance\scratchdimen\dimen0}% =\mathinner{\red\fakerule\scratchdimen}} diff --git a/Master/texmf-dist/tex/context/base/math-fen.mkiv b/Master/texmf-dist/tex/context/base/math-fen.mkiv index 33afbf675ae..ee82d89d19b 100644 --- a/Master/texmf-dist/tex/context/base/math-fen.mkiv +++ b/Master/texmf-dist/tex/context/base/math-fen.mkiv @@ -131,6 +131,9 @@ \definemathfence [angle] [\c!left="27E8,\c!right="27E9] \definemathfence [doubleangle] [\c!left="27EA,\c!right="27EB] \definemathfence [solidus] [\c!left="2044,\c!right="2044] +\definemathfence [ceil] [\c!left="2308,\c!right="2309] +\definemathfence [floor] [\c!left="230A,\c!right="230B] + \definemathfence [nothing] \definemathfence [mirrored] % \v!mirrored @@ -158,6 +161,8 @@ \unexpanded\def\Ltriplebar {\math_fenced_fenced_start{triplebar}} \unexpanded\def\Rtriplebar {\math_fenced_fenced_stop{triplebar}} \unexpanded\def\Lsolidus {\math_fenced_fenced_start{solidus}} \unexpanded\def\Rsolidus {\math_fenced_fenced_stop{solidus}} \unexpanded\def\Lnothing {\math_fenced_fenced_start{nothing}} \unexpanded\def\Rnothing {\math_fenced_fenced_stop{nothing}} +\unexpanded\def\Lfloor {\math_fenced_fenced_start{floor}} \unexpanded\def\Rfloor {\math_fenced_fenced_stop{floor}} +\unexpanded\def\Lceil {\math_fenced_fenced_start{ceil}} \unexpanded\def\Rceil {\math_fenced_fenced_stop{ceil}} \unexpanded\def\Lparentmirrored {\math_fenced_fenced_stop{mirroredparenthesis}} \unexpanded\def\Rparentmirrored {\math_fenced_fenced_start{mirroredparenthesis}} \unexpanded\def\Lbracketmirrored {\math_fenced_fenced_stop{mirroredbracket}} \unexpanded\def\Rbracketmirrored {\math_fenced_fenced_start{mirroredbracket}} @@ -264,6 +269,11 @@ \expandafter\let\csname\??mathleft \meaning /\endcsname\Rsolidusmirrored \expandafter\let\csname\??mathleft \meaning .\endcsname\Rnothingmirrored +\expandafter\let\csname\??mathleft \meaning ⌊\endcsname\Lfloor +\expandafter\let\csname\??mathright\meaning ⌋\endcsname\Rfloor +\expandafter\let\csname\??mathleft \meaning ⌈\endcsname\Lceil +\expandafter\let\csname\??mathright\meaning ⌉\endcsname\Rceil + % todo paren parent \let\lbrack\lbracket @@ -278,6 +288,8 @@ %installmathfencepair \lbar \Lbar \rbar \Rbar \installmathfencepair \vert \Lbar \vert \Rbar \installmathfencepair \solidus \Lsolidus \solidus \Rsolidus +\installmathfencepair \lfloor \Lfloor \rfloor \Rfloor +\installmathfencepair \lceil \Lceil \rceil \Rceil \unexpanded\def\{{\mathortext\lbrace \letterleftbrace } % or maybe a chardef \unexpanded\def\}{\mathortext\rbrace \letterrightbrace } % or maybe a chardef diff --git a/Master/texmf-dist/tex/context/base/math-ini.lua b/Master/texmf-dist/tex/context/base/math-ini.lua index 88159e10746..e6a35c39ee7 100644 --- a/Master/texmf-dist/tex/context/base/math-ini.lua +++ b/Master/texmf-dist/tex/context/base/math-ini.lua @@ -655,24 +655,27 @@ local noffunctions = 1000 -- offset categories.functions = functions implement { - name = "taggedmathfunction", - arguments = { "string", "string", "string" }, - actions = function(tag,label,apply) - local delta = toboolean(apply) and 1000 or 0 - if toboolean(label) then - local n = functions[tag] - if not n then - noffunctions = noffunctions + 1 - functions[noffunctions] = tag - functions[tag] = noffunctions - texsetattribute(a_mathcategory,noffunctions + delta) - else - texsetattribute(a_mathcategory,n + delta) - end - context.mathlabeltext(tag) + name = "tagmfunctiontxt", + arguments = { "string", "conditional" }, + actions = function(tag,apply) + local delta = apply and 1000 or 0 + texsetattribute(a_mathcategory,1000 + delta) + end +} + +implement { + name = "tagmfunctionlab", + arguments = { "string", "conditional" }, + actions = function(tag,apply) + local delta = apply and 1000 or 0 + local n = functions[tag] + if not n then + noffunctions = noffunctions + 1 + functions[noffunctions] = tag + functions[tag] = noffunctions + texsetattribute(a_mathcategory,noffunctions + delta) else - texsetattribute(a_mathcategory,1000 + delta) - context(tag) + texsetattribute(a_mathcategory,n + delta) end end } diff --git a/Master/texmf-dist/tex/context/base/math-ini.mkiv b/Master/texmf-dist/tex/context/base/math-ini.mkiv index 2d6090c03b9..d18c66812c0 100644 --- a/Master/texmf-dist/tex/context/base/math-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/math-ini.mkiv @@ -184,12 +184,103 @@ \definemathematics[\v!default] % not needed, but nicer when nesting back to normal -% Normally this is applied to only one character. +% Now we redefine \type {\mathematics} and \type {\m}: + +\unexpanded\def\mathematics + {\doifelsenextoptionalcs\math_m_yes\math_m_nop} + +\def\math_m_yes[#1]#2% + {\relax + \ifmmode + #2% + \else + \normalstartimath + \edef\currentmathematics{#1}% check for valid + \the\everyswitchmathematics\relax + #2% + \normalstopimath + \fi} + +\def\math_m_nop#1% + {\relax + \ifmmode + #1% + \else + \normalstartimath + #1% + \normalstopimath + \fi} + +\let\m\mathematics + +\newmuskip\defaultthickmuskip \defaultthickmuskip 5mu plus 5mu +\newmuskip\defaultmedmuskip \defaultmedmuskip 4mu plus 2mu minus 4mu +\newmuskip\defaultthinmuskip \defaultthinmuskip 3mu + +\newmuskip\halfthickmuskip \halfthickmuskip 2.5mu plus 2.5mu +\newmuskip\halfmedmuskip \halfmedmuskip 2.0mu plus 1.0mu minus 2.0mu +\newmuskip\halfthinmuskip \halfthinmuskip 1.5mu + +\newcount \defaultrelpenalty \defaultrelpenalty 500 +\newcount \defaultbinoppenalty \defaultbinoppenalty 700 + + +\startsetups math:spacing:default + \thickmuskip \defaultthickmuskip + \medmuskip \defaultmedmuskip + \thinmuskip \defaultthinmuskip + \relpenalty \defaultrelpenalty + \binoppenalty \defaultbinoppenalty +\stopsetups + +\startsetups math:spacing:half + \thickmuskip \halfthickmuskip + \medmuskip \halfmedmuskip + \thinmuskip \halfthinmuskip + \relpenalty \defaultrelpenalty + \binoppenalty \defaultbinoppenalty +\stopsetups + +\startsetups math:spacing:tight + \ifcase\raggedstatus + \thickmuskip \halfthickmuskip + \medmuskip \halfmedmuskip + \thinmuskip \halfthinmuskip + \else + \thickmuskip 1\halfthickmuskip + \medmuskip 1\halfmedmuskip + \thinmuskip 1\halfthinmuskip + \fi + \relpenalty \defaultrelpenalty + \binoppenalty \maxdimen +\stopsetups + +\startsetups math:spacing:fixed + \ifcase\raggedstatus + \thickmuskip \halfthickmuskip + \medmuskip \halfmedmuskip + \thinmuskip \halfthinmuskip + \else + \thickmuskip 1\halfthickmuskip + \medmuskip 1\halfmedmuskip + \thinmuskip 1\halfthinmuskip + \fi + \relpenalty \maxdimen + \binoppenalty \maxdimen +\stopsetups + +% \dorecurse{80}{test \m[i:tight]{\red \fakeformula} test } + +\definemathematics[i:default][\c!setups=math:spacing:equal] +\definemathematics[i:half] [\c!setups=math:spacing:half] +\definemathematics[i:tight] [\c!setups=math:spacing:tight] +\definemathematics[i:fixed] [\c!setups=math:spacing:fixed] + +% Normally the next is applied to only one character. % % $ABC$ $\cal ABC$ $\mathaltcal ABC$ % todo: only in mmode - % these commands are semi-public but should not be used directly (lua names wil change) \unexpanded\def\math_set_attribute #1#2{\ifmmode\clf_setmathattribute{#1}{#2}\fi} @@ -476,13 +567,14 @@ \unexpanded\def\mathop {\normalmathop \bgroup - \let\rm\mf + % no: \let\rm\mf \let\nexttoken=} % this one too: \letvalue{\??mathcodecommand op}\mathop ? \unexpanded\def\normalmbox - {\normalhbox\bgroup\mf + {\normalhbox\bgroup + \usemathematicsstyleandcolor\c!textstyle\c!textcolor % new \dowithnextboxcs\math_mbox_finish\normalhbox} \def\math_mbox_finish @@ -524,19 +616,69 @@ \unexpanded\def\math_tags_mn#1{\begingroup\mathupright#1\endgroup} \unexpanded\def\math_tags_ms#1{\begingroup\mathupright#1\endgroup} -\unexpanded\def\mfunction #1{{\mathupright\math_tags_function{#1}}} -\unexpanded\def\mfunctionlabeltext#1{{\mathupright\math_tags_functionlabeltext{#1}}} - % Once this is stable we can store the number at the tex end which is % faster. Functions getnumbers >= 1000. -\expanded\def\math_tags_mathfunction_indeed #1{\clf_taggedmathfunction{#1}{false}{\ifconditional\c_apply_function true\else false\fi}} -\expanded\def\math_tags_mathfunctionlabeltext_indeed#1{\clf_taggedmathfunction{#1} {true}{\ifconditional\c_apply_function true\else false\fi}} +\setupmathematics + [\c!textstyle=, % rm ss etc i.e. known alternatives, otherwise math + \c!textcolor=, + \c!functionstyle=, % rm ss etc i.e. known alternatives, otherwise math + \c!functioncolor=] + +% \unexpanded\def\math_mfunction_styled +% {\edef\m_math_text_choice_face{\textstyleface\normalmathstyle}% +% \dowithnextbox +% {\mathop{\box\nextbox}}% +% \hbox\bgroup +% \usemathematicsstyleandcolor\c!functionstyle\c!functioncolor +% \m_math_text_choice_face +% \let\next} + +\unexpanded\def\math_mfunction_styled + {\begingroup + \usemathematicscolorparameter\c!functioncolor + \edef\p_functionstyle{\mathematicsparameter\c!functionstyle}% + \ifx\p_functionstyle\empty + \expandafter\math_mfunction_styled_none + \else\ifcsname\??alternativestyles\p_functionstyle\endcsname + \doubleexpandafter\math_mfunction_styled_text + \else + \doubleexpandafter\math_mfunction_styled_math + \fi\fi} -\expanded\def\math_tags_mo_indeed#1{\begingroup \attribute\mathcategoryattribute\plusone #1\endgroup} -\expanded\def\math_tags_mi_indeed#1{\begingroup \attribute\mathcategoryattribute\plustwo #1\endgroup} -\expanded\def\math_tags_mn_indeed#1{\begingroup\mathupright\attribute\mathcategoryattribute\plusthree#1\endgroup} -\expanded\def\math_tags_ms_indeed#1{\begingroup\mathupright\attribute\mathcategoryattribute\plusfour #1\endgroup} +\unexpanded\def\math_mfunction_styled_text#1% + {\mathoptext{\csname\??alternativestyles\p_functionstyle\endcsname#1}% + \endgroup} + +\unexpanded\def\math_mfunction_styled_math#1% + {\p_functionstyle + #1% + \endgroup} + +\unexpanded\def\math_mfunction_styled_none#1% + {\mathupright + #1% + \endgroup} + +\unexpanded\def\mfunction#1% + {\begingroup + \math_tags_mfunctiontxt{#1}\c_apply_function + \math_mfunction_styled{#1}% + \endgroup} + +\unexpanded\def\mfunctionlabeltext#1% + {\begingroup + \math_tags_mfunctionlab{#1}\c_apply_function + \math_mfunction_styled{\mathlabeltext{#1}}% + \endgroup} + +\let\math_tags_mfunctiontxt\gobbletwoarguments +\let\math_tags_mfunctionlab\gobbletwoarguments + +\unexpanded\def\math_tags_mo_indeed#1{\begingroup \attribute\mathcategoryattribute\plusone #1\endgroup} +\unexpanded\def\math_tags_mi_indeed#1{\begingroup \attribute\mathcategoryattribute\plustwo #1\endgroup} +\unexpanded\def\math_tags_mn_indeed#1{\begingroup\mathupright\attribute\mathcategoryattribute\plusthree#1\endgroup} +\unexpanded\def\math_tags_ms_indeed#1{\begingroup\mathupright\attribute\mathcategoryattribute\plusfour #1\endgroup} % todo: mathoptext \newconditional\c_apply_function @@ -551,12 +693,12 @@ \endgroup} \appendtoks - \let\math_tags_function \math_tags_mathfunction_indeed - \let\math_tags_functionlabeltext\math_tags_mathfunctionlabeltext_indeed - \let\math_tags_mo \math_tags_mo_indeed - \let\math_tags_mi \math_tags_mi_indeed - \let\math_tags_mn \math_tags_mn_indeed - \let\math_tags_ms \math_tags_ms_indeed + \let\math_tags_mfunctiontxt\clf_tagmfunctiontxt + \let\math_tags_mfunctionlab\clf_tagmfunctionlab + \let\math_tags_mo \math_tags_mo_indeed + \let\math_tags_mi \math_tags_mi_indeed + \let\math_tags_mn \math_tags_mn_indeed + \let\math_tags_ms \math_tags_ms_indeed \to \everyenableelements \appendtoks @@ -570,21 +712,21 @@ % \def\mlimitsfunction #1{\mathlimopcomm{{\mr#1}} % \def\mnolimitsfunction#1{\mathnolopcomm{{\mr#1}} -%D Taco posted this solution as response to a mail by Olivier, so let's integrate -%D it here. - -\def\currentmscaledstyle{rm} % will be plugged into the typeface text=ss option - -\unexpanded\def\math_function_style_opnolimits #1{\mathop{\mscaledtext{#1}}\nolimits} -\unexpanded\def\math_function_style_mfunction #1{\mscaledtext{\math_tags_function{#1}}} -\unexpanded\def\math_function_style_mfunctionlabeltext#1{\mscaledtext{\math_tags_functionlabeltext{#1}}} - -\unexpanded\def\setmathfunctionstyle#1% rm ss tt (can be made faster if needed) - {\doifsomething{#1} - {\def\currentmscaledstyle{#1}% - \let\mathopnolimits \math_function_style_opnolimits - \let\mfunction \math_function_style_mfunction - \let\mfunctionlabeltext\math_function_style_mfunctionlabeltext}} +% %D Taco posted this solution as response to a mail by Olivier, so let's integrate +% %D it here. +% +% \def\currentmscaledstyle{rm} % will be plugged into the typeface text=ss option +% +% \unexpanded\def\math_function_style_opnolimits #1{\mathop{\mscaledtext{#1}}\nolimits} +% \unexpanded\def\math_function_style_mfunction #1{\mscaledtext{\math_tags_function{#1}}} +% \unexpanded\def\math_function_style_mfunctionlabeltext#1{\mscaledtext{\math_tags_functionlabeltext{#1}}} +% +% \unexpanded\def\setmathfunctionstyle#1% rm ss tt (can be made faster if needed) +% {\doifsomething{#1} +% {\def\currentmscaledstyle{#1}% +% \let\mathopnolimits \math_function_style_opnolimits +% \let\mfunction \math_function_style_mfunction +% \let\mfunctionlabeltext\math_function_style_mfunctionlabeltext}} \unexpanded\def\mscaledtext#1% {\mathchoice @@ -593,6 +735,9 @@ {\hbox{\csname\currentmscaledstyle\endcsname\tfx #1}} {\hbox{\csname\currentmscaledstyle\endcsname\tfxx#1}}} +\unexpanded\def\setmathfunctionstyle#1% + {\setupmathematics[\c!functionstyle=#1]} % for old times sake + %D We can force the way functions are typeset by manipulating the text option: %D %D \starttyping @@ -1321,6 +1466,19 @@ \expandafter#3\else \expandafter#1\fi} +% \def\textstyleface#1% #1 is number (\normalmathstyle) +% {\ifcase\numexpr#1\relax +% \tf \or +% \tf \or +% \tf \or +% \tf \or +% \tfx \or +% \tfx \or +% \tfxx \or +% \tfxx \else +% \tf +% \fi} + \unexpanded\def\verbosemathstyle#1% #1 is number (\normalmathstyle) {{\normalexpanded{\relax\darkgray\ttxx[\number#1:\ifcase\numexpr#1\relax display\or % 0 diff --git a/Master/texmf-dist/tex/context/base/mult-def.mkiv b/Master/texmf-dist/tex/context/base/mult-def.mkiv index 607f76a167a..cea2a6a6a1d 100644 --- a/Master/texmf-dist/tex/context/base/mult-def.mkiv +++ b/Master/texmf-dist/tex/context/base/mult-def.mkiv @@ -34,6 +34,11 @@ % start todo in mult-def.lua: +\def\c!functionstyle {functionstyle} +\def\c!functioncolor {functioncolor} + +\def\v!extremestretch {extremestretch} + \def\v!alphabetic {alphabetic} \def\v!Alphabetic {Alphabetic} @@ -152,6 +157,7 @@ \def\c!etallimit {etallimit} \def\c!etaldisplay{etaldisplay} \def\c!etaltext {etaltext} +\def\c!etaloption {etaloption} \ifdefined\v!simplelist\else \def\v!simplelist{simplelist} \fi \ifdefined\v!sorting \else \def\v!sorting {sorting} \fi diff --git a/Master/texmf-dist/tex/context/base/mult-low.lua b/Master/texmf-dist/tex/context/base/mult-low.lua index 1ad0f9ebbda..9a05e59d994 100644 --- a/Master/texmf-dist/tex/context/base/mult-low.lua +++ b/Master/texmf-dist/tex/context/base/mult-low.lua @@ -102,7 +102,7 @@ return { "startproject", "stopproject", "project", "starttext", "stoptext", "startnotext", "stopnotext","startdocument", "stopdocument", "documentvariable", "setupdocument", "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule","setupmodule","currentmoduleparameter","moduleparameter", - "everystarttext", + "everystarttext", "everystoptext", -- "startTEXpage", "stopTEXpage", -- "startMPpage", "stopMPpage", -- already catched by nested lexer diff --git a/Master/texmf-dist/tex/context/base/publ-aut.lua b/Master/texmf-dist/tex/context/base/publ-aut.lua index 4ab8dd4bc93..4c95d002521 100644 --- a/Master/texmf-dist/tex/context/base/publ-aut.lua +++ b/Master/texmf-dist/tex/context/base/publ-aut.lua @@ -21,6 +21,7 @@ local formatters = string.formatters local P, S, C, V, Cs, Ct, Cg, Cf, Cc = lpeg.P, lpeg.S, lpeg.C, lpeg.V, lpeg.Cs, lpeg.Ct, lpeg.Cg, lpeg.Cf, lpeg.Cc local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns +local settings_to_hash = utilities.parsers.settings_to_hash local context = context ----- commands = commands @@ -42,6 +43,8 @@ local trace_hashing = false trackers.register("publications.authorhash", func local report = logs.reporter("publications","authors") local report_cite = logs.reporter("publications","cite") +local v_last = interfaces.variables.last + -- local function makesplitter(separator) -- return Ct { "start", -- start = (Cs((V("outer") + (1-separator))^1) + separator^1)^1, @@ -279,11 +282,18 @@ local function splitauthorstring(str) return { authors } -- we assume one author end + -- we could cache these too but it can become messy .. leave that for later - local authors = lpegmatch(andsplitter,str) - for i=1,#authors do + local authors = lpegmatch(andsplitter,str) + local nofauthors = #authors + for i=1,nofauthors do authors[i] = splitauthor(authors[i]) end + if nofauthors > 1 and authors[nofauthors].original == "others" then + -- only the last one is looked at + authors[nofauthors] = nil + authors.others = true + end return authors end @@ -396,8 +406,11 @@ local function btxauthor(dataset,tag,field,settings) return -- error end + local absmax = max local etallimit = tonumber(settings.etallimit) or 1000 local etaldisplay = tonumber(settings.etaldisplay) or etallimit + local etaloption = settings_to_hash(settings.etaloption or "") + local etallast = etaloption[v_last] local combiner = settings.combiner local symbol = settings.symbol local index = settings.index @@ -408,16 +421,22 @@ local function btxauthor(dataset,tag,field,settings) symbol = "." end local ctx_btxsetup = settings.kind == "cite" and ctx_btxciteauthorsetup or ctx_btxlistauthorsetup - if max > etallimit and etaldisplay < max then + if max > etallimit and (etaldisplay+(etallast and 1 or 0)) < max then max = etaldisplay + else + etallast = false end currentauthordata = split currentauthorsymbol = symbol - local function oneauthor(i) + local function oneauthor(i,last,justone) local author = split[i] if index then ctx_btxstartauthor(i,1,0) + elseif last then + ctx_btxstartauthor(i,1,0) + ctx_btxsetconcat(0) + ctx_btxsetauthorvariant(combiner) else local state = author.state or 0 ctx_btxstartauthor(i,max,state) @@ -445,9 +464,13 @@ local function btxauthor(dataset,tag,field,settings) ctx_btxsetjuniors() -- (concat(juniors," ")) end if not index and i == max then - local overflow = #split - max - if overflow > 0 then - ctx_btxsetoverflow(overflow) + if split.others then + ctx_btxsetoverflow(1) + else + local overflow = #split - max + if overflow > 0 then + ctx_btxsetoverflow(overflow) + end end end ctx_btxsetup(combiner) @@ -455,10 +478,15 @@ local function btxauthor(dataset,tag,field,settings) end if index then oneauthor(index) + elseif max == 1 then + oneauthor(1,false,true) else for i=1,max do oneauthor(i) end + if etallast then + oneauthor(absmax,true) + end end else report("ignored field %a of tag %a, used field %a is no author",field,tag,usedfield) @@ -483,6 +511,7 @@ implement { { "kind" }, { "etallimit" }, { "etaldisplay" }, + { "etaloption" }, { "symbol" }, } } @@ -564,23 +593,27 @@ publications.authorhashers = authorhashers -- todo: some hashing local function name(authors) - local n = #authors - if n == 0 then - return "" - end - local result = { } - local nofresult = 0 - for i=1,n do - local author = authors[i] - local surnames = author.surnames - if surnames and #surnames > 0 then - for j=1,#surnames do - nofresult = nofresult + 1 - result[nofresult] = surnames[j] + if type(authors) == "table" then + local n = #authors + if n == 0 then + return "" + end + local result = { } + local nofresult = 0 + for i=1,n do + local author = authors[i] + local surnames = author.surnames + if surnames and #surnames > 0 then + for j=1,#surnames do + nofresult = nofresult + 1 + result[nofresult] = surnames[j] + end end end + return concat(result," ") + else + return authors end - return concat(result," ") end table.setmetatableindex(authorhashers,function(t,k) @@ -589,86 +622,94 @@ table.setmetatableindex(authorhashers,function(t,k) end) authorhashers.normal = function(authors) - local n = #authors - if n == 0 then - return "" - end - local result = { } - local nofresult = 0 - for i=1,n do - local author = authors[i] - local vons = author.vons - local surnames = author.surnames - local firstnames = author.firstnames - local juniors = author.juniors - if vons and #vons > 0 then - for j=1,#vons do - nofresult = nofresult + 1 - result[nofresult] = vons[j] - end + if type(authors) == "table" then + local n = #authors + if n == 0 then + return "" end - if surnames and #surnames > 0 then - for j=1,#surnames do - nofresult = nofresult + 1 - result[nofresult] = surnames[j] + local result = { } + local nofresult = 0 + for i=1,n do + local author = authors[i] + local vons = author.vons + local surnames = author.surnames + local firstnames = author.firstnames + local juniors = author.juniors + if vons and #vons > 0 then + for j=1,#vons do + nofresult = nofresult + 1 + result[nofresult] = vons[j] + end end - end - if firstnames and #firstnames > 0 then - for j=1,#firstnames do - nofresult = nofresult + 1 - result[nofresult] = firstnames[j] + if surnames and #surnames > 0 then + for j=1,#surnames do + nofresult = nofresult + 1 + result[nofresult] = surnames[j] + end end - end - if juniors and #juniors > 0 then - for j=1,#juniors do - nofresult = nofresult + 1 - result[nofresult] = juniors[j] + if firstnames and #firstnames > 0 then + for j=1,#firstnames do + nofresult = nofresult + 1 + result[nofresult] = firstnames[j] + end + end + if juniors and #juniors > 0 then + for j=1,#juniors do + nofresult = nofresult + 1 + result[nofresult] = juniors[j] + end end end + return concat(result," ") + else + return authors end - return concat(result," ") end authorhashers.normalshort = function(authors) - local n = #authors - if n == 0 then - return "" - end - local result = { } - local nofresult = 0 - for i=1,n do - local author = authors[i] - local vons = author.vons - local surnames = author.surnames - local initials = author.initials - local juniors = author.juniors - if vons and #vons > 0 then - for j=1,#vons do - nofresult = nofresult + 1 - result[nofresult] = vons[j] - end + if type(authors) == "table" then + local n = #authors + if n == 0 then + return "" end - if surnames and #surnames > 0 then - for j=1,#surnames do - nofresult = nofresult + 1 - result[nofresult] = surnames[j] + local result = { } + local nofresult = 0 + for i=1,n do + local author = authors[i] + local vons = author.vons + local surnames = author.surnames + local initials = author.initials + local juniors = author.juniors + if vons and #vons > 0 then + for j=1,#vons do + nofresult = nofresult + 1 + result[nofresult] = vons[j] + end end - end - if initials and #initials > 0 then - initials = the_initials(initials) - for j=1,#initials do - nofresult = nofresult + 1 - result[nofresult] = initials[j] + if surnames and #surnames > 0 then + for j=1,#surnames do + nofresult = nofresult + 1 + result[nofresult] = surnames[j] + end end - end - if juniors and #juniors > 0 then - for j=1,#juniors do - nofresult = nofresult + 1 - result[nofresult] = juniors[j] + if initials and #initials > 0 then + initials = the_initials(initials) + for j=1,#initials do + nofresult = nofresult + 1 + result[nofresult] = initials[j] + end + end + if juniors and #juniors > 0 then + for j=1,#juniors do + nofresult = nofresult + 1 + result[nofresult] = juniors[j] + end end end + return concat(result," ") + else + return authors end - return concat(result," ") end authorhashers.normalinverted = authorhashers.normal @@ -684,41 +725,45 @@ authorhashers.short = function(authors) -- a short is a real dumb hardcodes kind of tag and we only support -- this one because some users might expect it, not because it makes -- sense - local n = #authors - if n == 0 then - return "unk" - elseif n == 1 then - local surnames = authors[1].surnames - if not surnames or #surnames == 0 then - return "err" - else - local s = surnames[1] - local c = lpegmatch(p_clean,s) - if s ~= c then - report_cite("name %a cleaned to %a for short construction",s,c) - end - return utfsub(c,1,3) - end - else - local t = { } - for i=1,n do - if i > 3 then - t[#t+1] = "+" -- indeed - break - end - local surnames = authors[i].surnames + if type(authors) == "table" then + local n = #authors + if n == 0 then + return "unk" + elseif n == 1 then + local surnames = authors[1].surnames if not surnames or #surnames == 0 then - t[#t+1] = "?" + return "err" else local s = surnames[1] local c = lpegmatch(p_clean,s) if s ~= c then report_cite("name %a cleaned to %a for short construction",s,c) end - t[#t+1] = utfsub(c,1,1) + return utfsub(c,1,3) end + else + local t = { } + for i=1,n do + if i > 3 then + t[#t+1] = "+" -- indeed + break + end + local surnames = authors[i].surnames + if not surnames or #surnames == 0 then + t[#t+1] = "?" + else + local s = surnames[1] + local c = lpegmatch(p_clean,s) + if s ~= c then + report_cite("name %a cleaned to %a for short construction",s,c) + end + t[#t+1] = utfsub(c,1,1) + end + end + return concat(t) end - return concat(t) + else + return utfsub(authors,1,4) end end diff --git a/Master/texmf-dist/tex/context/base/publ-dat.lua b/Master/texmf-dist/tex/context/base/publ-dat.lua index 494a13d3c35..1e651c45bcd 100644 --- a/Master/texmf-dist/tex/context/base/publ-dat.lua +++ b/Master/texmf-dist/tex/context/base/publ-dat.lua @@ -346,6 +346,12 @@ function publications.parenttag(dataset,tag) local entry = luadata[tag] if entry then combined[#combined+1] = tag + if combined[tag] then + report("error in combination, dataset %a, tag %a, parent %a, ignored %a",dataset,tag,combined[tag],parent) + else + report("combining, dataset %a, tag %a, parent %a",dataset,tag,parent) + current.combined[tag] = parent + end end end end @@ -382,6 +388,7 @@ function publications.new(name) -- used specifications }, suffixed = false, + combined = { }, } -- we delay details till we need it (maybe we just delay the -- individual fields but that is tricky as there can be some diff --git a/Master/texmf-dist/tex/context/base/publ-imp-apa.mkvi b/Master/texmf-dist/tex/context/base/publ-imp-apa.mkvi index 7cab4a131ac..d2eae8e9bf8 100644 --- a/Master/texmf-dist/tex/context/base/publ-imp-apa.mkvi +++ b/Master/texmf-dist/tex/context/base/publ-imp-apa.mkvi @@ -55,11 +55,12 @@ \c!margin=3.5\emwidth] \definebtx - [apa:list] + [apa:\s!list] [apa] [\c!otherstext={,\nobreakspace\textellipsis\space}, \c!etallimit=7, \c!etaldisplay=6, + \c!etaloption=last, \c!authorconversion=invertedshort, \c!separator:names:2={,\space}, % aka namesep - in this namespace \c!separator:names:3={,\nobreakspace\textampersand\space}, % comma separated list @@ -68,44 +69,49 @@ % First, we define a namespace for a few special fields \definebtx - [apa:list:author] - [apa:list] + [apa:\s!list:author] + [apa:\s!list] \definebtx - [apa:list:editor] - [apa:list:author] + [apa:\s!list:editor] + [apa:\s!list:author] \definebtx - [apa:list:suffix] - [apa:list] + [apa:\s!list:suffix] + [apa:\s!list] \definebtx - [apa:list:url] - [apa:list] + [apa:\s!list:url] + [apa:\s!list] \definebtx - [apa:list:doi] - [apa:list] + [apa:\s!list:doi] + [apa:\s!list] \definebtx - [apa:list:numbering] - [apa:list] + [apa:\s!list:\s!page] + [apa:\s!list] + [\c!pagecommand={\wordright}] \definebtx - [apa:list:numbering:num] - [apa:list:numbering] + [apa:\s!list:numbering] + [apa:\s!list] \definebtx - [apa:list:numbering:yes] - [apa:list:numbering:num] + [apa:\s!list:numbering:num] + [apa:\s!list:numbering] + [\c!stopper={.}, + \c!right={\space}] \definebtx - [apa:list:numbering:short] - [apa:list:numbering:num] + [apa:\s!list:numbering:short] + [apa:\s!list:numbering:num] + [\c!stopper=] \definebtx - [apa:list:numbering:bib] - [apa:list:numbering:num] + [apa:\s!list:numbering:tag] + [apa:\s!list:numbering:num] + [\c!stopper=] % Next, we define a namespace for each category @@ -116,143 +122,129 @@ %D \btxloadjournallist[journals.txt] % the jabref list %D \stoptyping - \definebtx - [apa:list:journal] + [apa:\s!list:journal] [\c!style=\v!italic] %command=\btxexpandedjournal] % btxabbreviatedjournal \definebtx - [apa:list:title] + [apa:\s!list:title] [\c!style=\v!italic, \c!command=\Word, \c!translate=\v!yes] \definebtx - [apa:list:title:article] - [apa:list:title] + [apa:\s!list:title:article] + [apa:\s!list:title] [\c!style=] % journal is set in italics \definebtx - [apa:list:title:magazine] - [apa:list:title] + [apa:\s!list:title:magazine] + [apa:\s!list:title] \definebtx - [apa:list:title:newspaper] - [apa:list:title] + [apa:\s!list:title:newspaper] + [apa:\s!list:title] \definebtx - [apa:list:title:periodical] - [apa:list:title] + [apa:\s!list:title:periodical] + [apa:\s!list:title] \definebtx - [apa:list:title:standard] - [apa:list:title] + [apa:\s!list:title:standard] + [apa:\s!list:title] \definebtx - [apa:list:title:book] - [apa:list:title] + [apa:\s!list:title:book] + [apa:\s!list:title] \definebtx - [apa:list:title:inbook] - [apa:list:title] + [apa:\s!list:title:inbook] + [apa:\s!list:title] \definebtx - [apa:list:title:incollection] - [apa:list:title] + [apa:\s!list:title:incollection] + [apa:\s!list:title] [\c!style=] % booktitle is set in italics \definebtx - [apa:list:title:proceedings] - [apa:list:title] + [apa:\s!list:title:proceedings] + [apa:\s!list:title] \definebtx - [apa:list:title:inproceedings] - [apa:list:title] + [apa:\s!list:title:inproceedings] + [apa:\s!list:title] [\c!style=] % booktitle is set in italics \definebtx - [apa:list:title:conference] - [apa:list:title] + [apa:\s!list:title:conference] + [apa:\s!list:title] [\c!style=] % booktitle is set in italics \definebtx - [apa:list:title:thesis] - [apa:list:title] + [apa:\s!list:title:thesis] + [apa:\s!list:title] \definebtx - [apa:list:title:phdthesis] - [apa:list:title] + [apa:\s!list:title:phdthesis] + [apa:\s!list:title] \definebtx - [apa:list:title:mastersthesis] - [apa:list:title] + [apa:\s!list:title:mastersthesis] + [apa:\s!list:title] \definebtx - [apa:list:title:booklet] - [apa:list:title] + [apa:\s!list:title:booklet] + [apa:\s!list:title] \definebtx - [apa:list:title:manual] - [apa:list:title] + [apa:\s!list:title:manual] + [apa:\s!list:title] \definebtx - [apa:list:title:techreport] - [apa:list:title] + [apa:\s!list:title:techreport] + [apa:\s!list:title] \definebtx - [apa:list:title:unpublished] - [apa:list:title] + [apa:\s!list:title:unpublished] + [apa:\s!list:title] \definebtx - [apa:list:title:patent] - [apa:list:title] + [apa:\s!list:title:patent] + [apa:\s!list:title] \definebtx - [apa:list:title:electronic] - [apa:list:title] + [apa:\s!list:title:electronic] + [apa:\s!list:title] \definebtx - [apa:list:title:music] - [apa:list:title] + [apa:\s!list:title:music] + [apa:\s!list:title] \definebtx - [apa:list:title:film] - [apa:list:title] + [apa:\s!list:title:film] + [apa:\s!list:title] \definebtx - [apa:list:title:other] - [apa:list:title] + [apa:\s!list:title:other] + [apa:\s!list:title] \definebtx - [apa:list:title:misc] - [apa:list:title] + [apa:\s!list:title:misc] + [apa:\s!list:title] \definebtx - [apa:list:title:literal] - [apa:list:title] + [apa:\s!list:title:literal] + [apa:\s!list:title] \definebtx - [apa:list:type] + [apa:\s!list:type] [\c!command=\Word] -% We define [page] settings in the apa namespace, inheriting the root -% settings, in order to eventually allow for modifications without touching -% root. - -\definebtx - [apa:\s!page] - [\s!page] - -\definebtx - [apa:\s!page:list] - [apa:\s!page] - [\c!pagecommand={\wordright}] - % Then define and set cite parameters. \definebtx - [apa:cite] + [apa:\s!cite] [apa] [\c!alternative=authoryear, \c!otherstext={,\space\btxlabeltext{apa:others}}, @@ -266,90 +258,87 @@ \c!separator:names:4={\space\btxlabeltext{apa:and}\space}] % not \textampersand \definebtx - [apa:cite:author] - [apa:cite] + [apa:\s!cite:author] + [apa:\s!cite] \definebtx - [apa:cite:authoryear] - [apa:cite:author] + [apa:\s!cite:authoryear] + [apa:\s!cite:author] [\c!left={(}, \c!right={)}, \c!inbetween={,\space}] \definebtx - [apa:cite:default] - [apa:cite:authoryear] + [apa:\s!cite:default] + [apa:\s!cite:authoryear] \definebtx - [apa:cite:authoryears] - [apa:cite:authoryear] + [apa:\s!cite:authoryears] + [apa:\s!cite:authoryear] [\c!left=, \c!right=, \c!inbetween={\space}] \definebtx - [apa:cite:authornum] - [apa:cite:author] + [apa:\s!cite:authornum] + [apa:\s!cite:author] [\c!left={(}, \c!right={)}] \definebtx - [apa:cite:authorref] - [apa:cite:authornum] - -\definebtx - [apa:cite:author:num] % todo - [apa:cite:authornum] - [\c!left={[}, + [apa:\s!cite:author:num] % todo + [apa:\s!cite:authornum] + [\c!left={\space[}, \c!right={]}] \definebtx - [apa:cite:author:year] % todo - [apa:cite] + [apa:\s!cite:author:year] % todo + [apa:\s!cite] \definebtx - [apa:cite:author:years] % todo - [apa:cite:authoryears] + [apa:\s!cite:author:years] % todo + [apa:\s!cite:authoryears] [\c!inbetween=, \c!left={\space(}, \c!right={)}] \definebtx - [apa:cite:year] - [apa:cite] + [apa:\s!cite:year] + [apa:\s!cite] [\c!separator:2={,\space}, % :0 and :1 - between items of a list \c!separator:3={,\space\btxlabeltext{apa:and}\space}, % not \textampersand \c!separator:4={\space\btxlabeltext{apa:and}\space}] % not \textampersand \definebtx - [apa:cite:title] - [apa:cite] + [apa:\s!cite:title] + [apa:\s!cite] [\c!separator:2={,\space}, % :0 and :1 - between items of a list \c!separator:3={,\space\btxlabeltext{apa:and}\space}, % not \textampersand \c!separator:4={\space\btxlabeltext{apa:and}\space}, % not \textampersand \c!command={\language[\currentbtxlanguage]}, % BAH + \c!sorttype=none, \c!style=\v!italic] \definebtx - [apa:cite:booktitle] - [apa:cite:title] + [apa:\s!cite:booktitle] + [apa:\s!cite:title] \definebtx - [apa:cite:tag] - [apa:cite] + [apa:\s!cite:tag] + [apa:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [apa:cite:index] - [apa:cite] + [apa:\s!cite:index] + [apa:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [apa:cite:page] - [apa:cite] + [apa:\s!cite:page] + [apa:\s!cite] [\c!left=, \c!right=, \c!separator:2={,\space}, % :0 and :1 - between items of a list @@ -357,36 +346,36 @@ \c!separator:4={\space\btxlabeltext{apa:and}\space}] % not \textampersand \definebtx - [apa:cite:pages] - [apa:cite:page] + [apa:\s!cite:pages] + [apa:\s!cite:page] \definebtx - [apa:cite:keywords] - [apa:cite] + [apa:\s!cite:keywords] + [apa:\s!cite] \definebtx - [apa:cite:short] - [apa:cite] + [apa:\s!cite:short] + [apa:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [apa:cite:category] - [apa:cite] + [apa:\s!cite:category] + [apa:\s!cite] \definebtx - [apa:cite:url] - [apa:cite] + [apa:\s!cite:url] + [apa:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [apa:cite:doi] - [apa:cite:url] + [apa:\s!cite:doi] + [apa:\s!cite:url] \definebtx - [apa:cite:num] - [apa:cite] + [apa:\s!cite:num] + [apa:\s!cite] [\c!left={[}, \c!right={]}, \c!separator:2={,}, % no space @@ -394,8 +383,8 @@ \c!separator:4=\btxparameter{\c!separator:2}] \definebtx - [apa:cite:textnum] - [apa:cite:num] + [apa:\s!cite:textnum] + [apa:\s!cite:num] [\c!left={Ref.\nbsp}, \c!right=, \c!separator:2={,\space}, @@ -403,8 +392,8 @@ \c!separator:4={\space\btxlabeltext{apa:and}\space}] \definebtx - [apa:cite:entry] - [apa:cite] + [apa:\s!cite:entry] + [apa:\s!cite] [\c!left=, \c!right=, \c!inbetween={\space}, @@ -483,7 +472,6 @@ \setupbtxlabeltext [fr] [apa:and=et, - apa:others={et al.}, apa:number={n\high{o}}, apa:edition={édition}, apa:Editor=Éditeur, @@ -749,9 +737,10 @@ } } \endgroup - \doif{\btxparameter{translate}}\v!yes { + % which namespace? + %\doif{\btxparameter{translate}}\v!yes { \texdefinition{btx:apa:translated-title}{#title} - } + %} \stoptexdefinition \starttexdefinition btx:apa:title diff --git a/Master/texmf-dist/tex/context/base/publ-imp-aps.mkvi b/Master/texmf-dist/tex/context/base/publ-imp-aps.mkvi index cd05fce7fad..11104a7eb5d 100644 --- a/Master/texmf-dist/tex/context/base/publ-imp-aps.mkvi +++ b/Master/texmf-dist/tex/context/base/publ-imp-aps.mkvi @@ -33,7 +33,7 @@ [aps] [\c!default=default, \c!specification=aps, - \c!otherstext={\space\btxlabeltext{aps:others}}, + \c!otherstext={\space{\it\btxlabeltext{aps:others}}}, \c!etallimit=10, \c!etaldisplay=\btxparameter\c!etallimit, %c!journalconversion=\v!normal, @@ -47,58 +47,61 @@ \definebtxrendering [aps] - [\c!specification=aps] + [\c!specification=aps, + \c!sorttype=\v!default, + \c!numbering=num] \setupbtxlist [aps] [\c!alternative=b] % spaces \definebtx - [aps:list] + [aps:\s!list] [aps] [\c!authorconversion=normalshort] \definebtx - [aps:list:author] - [aps:list] + [aps:\s!list:author] + [aps:\s!list] \definebtx - [aps:list:editor] - [aps:list:author] + [aps:\s!list:editor] + [aps:\s!list:author] \definebtx - [aps:list:suffix] - [aps:list] + [aps:\s!list:suffix] + [aps:\s!list] \definebtx - [aps:list:url] - [aps:list] + [aps:\s!list:url] + [aps:\s!list] \definebtx - [aps:list:doi] - [aps:list] + [aps:\s!list:doi] + [aps:\s!list] \definebtx - [aps:list:numbering] - [aps:list] + [aps:\s!list:\s!page] + [aps:\s!list] + [\c!left={\space}] \definebtx - [aps:list:numbering:num] - [aps:list:numbering] - [left={[}, - right={]}] + [aps:\s!list:numbering] + [aps:\s!list] \definebtx - [aps:list:numbering:yes] - [aps:list:numbering:num] + [aps:\s!list:numbering:num] + [aps:\s!list:numbering] + [left={[}, + right={]}] \definebtx - [aps:list:numbering:short] - [aps:list:numbering:num] + [aps:\s!list:numbering:short] + [aps:\s!list:numbering:num] \definebtx - [aps:list:numbering:bib] - [aps:list:numbering:num] + [aps:\s!list:numbering:tag] + [aps:\s!list:numbering:num] %D In order to be able to get journals expanded (or normalized or abbreviated) you need %D to load a list: @@ -110,217 +113,201 @@ % TODO \definebtx - [aps:list:journal] + [aps:\s!list:journal] [\c!style=\v!italic] %command=\btxexpandedjournal] % btxabbreviatedjournal \definebtx - [aps:list:volume] + [aps:\s!list:volume] [\c!style=\v!bold] \definebtx - [aps:list:title] + [aps:\s!list:title] [\c!style=\v!italic, \c!command=\Word] \definebtx - [aps:list:title:article] - [aps:list:title] + [aps:\s!list:title:article] + [aps:\s!list:title] [\c!style=] % journal is set in italics \definebtx - [aps:list:title:magazine] - [aps:list:title] + [aps:\s!list:title:magazine] + [aps:\s!list:title] \definebtx - [aps:list:title:newspaper] - [aps:list:title] + [aps:\s!list:title:newspaper] + [aps:\s!list:title] \definebtx - [aps:list:title:periodical] - [aps:list:title] + [aps:\s!list:title:periodical] + [aps:\s!list:title] \definebtx - [aps:list:title:standard] - [aps:list:title] + [aps:\s!list:title:standard] + [aps:\s!list:title] \definebtx - [aps:list:title:book] - [aps:list:title] + [aps:\s!list:title:book] + [aps:\s!list:title] \definebtx - [aps:list:title:inbook] - [aps:list:title] + [aps:\s!list:title:inbook] + [aps:\s!list:title] \definebtx - [aps:list:title:incollection] - [aps:list:title] + [aps:\s!list:title:incollection] + [aps:\s!list:title] [\c!style=] % booktitle is set in italics \definebtx - [aps:list:title:proceedings] - [aps:list:title] + [aps:\s!list:title:proceedings] + [aps:\s!list:title] \definebtx - [aps:list:title:inproceedings] - [aps:list:title] + [aps:\s!list:title:inproceedings] + [aps:\s!list:title] [\c!style=] % booktitle is set in italics \definebtx - [aps:list:title:conference] - [aps:list:title] + [aps:\s!list:title:conference] + [aps:\s!list:title] [\c!style=] % booktitle is set in italics \definebtx - [aps:list:title:thesis] - [aps:list:title] + [aps:\s!list:title:thesis] + [aps:\s!list:title] \definebtx - [aps:list:title:phdthesis] - [aps:list:title] + [aps:\s!list:title:phdthesis] + [aps:\s!list:title] \definebtx - [aps:list:title:mastersthesis] - [aps:list:title] + [aps:\s!list:title:mastersthesis] + [aps:\s!list:title] \definebtx - [aps:list:title:booklet] - [aps:list:title] + [aps:\s!list:title:booklet] + [aps:\s!list:title] \definebtx - [aps:list:title:manual] - [aps:list:title] + [aps:\s!list:title:manual] + [aps:\s!list:title] \definebtx - [aps:list:title:techreport] - [aps:list:title] + [aps:\s!list:title:techreport] + [aps:\s!list:title] \definebtx - [aps:list:title:unpublished] - [aps:list:title] + [aps:\s!list:title:unpublished] + [aps:\s!list:title] \definebtx - [aps:list:title:patent] - [aps:list:title] + [aps:\s!list:title:patent] + [aps:\s!list:title] \definebtx - [aps:list:title:electronic] - [aps:list:title] + [aps:\s!list:title:electronic] + [aps:\s!list:title] \definebtx - [aps:list:title:other] - [aps:list:title] + [aps:\s!list:title:other] + [aps:\s!list:title] \definebtx - [aps:list:title:misc] - [aps:list:title] + [aps:\s!list:title:misc] + [aps:\s!list:title] \definebtx - [aps:list:title:literal] - [aps:list:title] + [aps:\s!list:title:literal] + [aps:\s!list:title] \definebtx - [aps:list:type] + [aps:\s!list:type] [\c!command=\Word] -% We define [page] settings in the aps namespace, inheriting the root -% settings, in order to eventually allow for modifications without touching -% root. - -\definebtx - [aps:\s!page] - [\s!page] - -\definebtx - [aps:\s!page:list] - [aps:\s!page] - %[\c!pagecommand={\wordright}] - % Then define and set all cite parameters \definebtx - [aps:cite] + [aps:\s!cite] [aps] [\c!authorconversion=\v!name, \c!compress=\v!yes, \c!sorttype=normal] \definebtx - [aps:cite:author] - [aps:cite] + [aps:\s!cite:author] + [aps:\s!cite] \definebtx - [aps:cite:authoryear] - [aps:cite:author] + [aps:\s!cite:authoryear] + [aps:\s!cite:author] [\c!left={(}, \c!right={)}, \c!inbetween={,\space}] \definebtx - [aps:cite:authoryears] - [aps:cite:authoryear] + [aps:\s!cite:authoryears] + [aps:\s!cite:authoryear] [\c!left=, \c!right=, \c!inbetween={\space}] \definebtx - [aps:cite:authornum] - [aps:cite:author] + [aps:\s!cite:authornum] + [aps:\s!cite:author] [\c!left={(}, \c!right={)}] \definebtx - [aps:cite:authorref] - [aps:cite:authornum] - -\definebtx - [aps:cite:author:num] % todo - [aps:cite:authornum] - [\c!left={[}, + [aps:\s!cite:author:num] % todo + [aps:\s!cite:authornum] + [\c!left={\space[}, \c!right={]}] \definebtx - [aps:cite:author:year] % todo - [aps:cite:authoryear] + [aps:\s!cite:author:year] % todo + [aps:\s!cite:authoryear] [\c!left=, \c!right=] \definebtx - [aps:cite:author:years] % todo - [aps:cite:authoryears] + [aps:\s!cite:author:years] % todo + [aps:\s!cite:authoryears] [\c!inbetween=, \c!left={\space(}, \c!right={)}] \definebtx - [aps:cite:year] - [aps:cite] + [aps:\s!cite:year] + [aps:\s!cite] \definebtx - [aps:cite:title] - [aps:cite] + [aps:\s!cite:title] + [aps:\s!cite] [\c!command={\language[\currentbtxlanguage]}, % BAH + \c!sorttype=none, \c!style=\v!italic] \definebtx - [aps:cite:booktitle] - [aps:cite:title] + [aps:\s!cite:booktitle] + [aps:\s!cite:title] \definebtx - [aps:cite:tag] - [aps:cite] + [aps:\s!cite:tag] + [aps:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [aps:cite:index] - [aps:cite] + [aps:\s!cite:index] + [aps:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [aps:cite:page] - [aps:cite] + [aps:\s!cite:page] + [aps:\s!cite] [\c!left=, \c!right=, \c!separator:2={,\space}, % :0 and :1 - between items of a list @@ -328,38 +315,38 @@ \c!separator:4= {\space\btxlabeltext{aps:and}\space}] % not \textampersand \definebtx - [aps:cite:pages] - [aps:cite:page] + [aps:\s!cite:pages] + [aps:\s!cite:page] \definebtx - [aps:cite:keywords] - [aps:cite] + [aps:\s!cite:keywords] + [aps:\s!cite] [\c!left={(}, \c!right={)}] \definebtx - [aps:cite:short] - [aps:cite] + [aps:\s!cite:short] + [aps:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [aps:cite:category] - [aps:cite] + [aps:\s!cite:category] + [aps:\s!cite] \definebtx - [aps:cite:url] - [aps:cite] + [aps:\s!cite:url] + [aps:\s!cite] [\c!left={[}, \c!right={]}] \definebtx - [aps:cite:doi] - [aps:cite:url] + [aps:\s!cite:doi] + [aps:\s!cite:url] \definebtx - [aps:cite:num] - [aps:cite] + [aps:\s!cite:num] + [aps:\s!cite] [\c!left={[}, \c!right={]}, %\c!left=, % TODO: PRB uses superscript references... @@ -370,12 +357,12 @@ \c!separator:4=\btxparameter{\c!separator:2}] \definebtx - [aps:cite:default] - [aps:cite:num] + [aps:\s!cite:default] + [aps:\s!cite:num] \definebtx - [aps:cite:textnum] - [aps:cite:num] + [aps:\s!cite:textnum] + [aps:\s!cite:num] [\c!left={Ref.\nbsp}, \c!command=, \c!separator:2={,\space}, @@ -383,8 +370,8 @@ \c!separator:4={\space\btxlabeltext{aps:and}\space}] \definebtx - [aps:cite:entry] - [aps:cite] + [aps:\s!cite:entry] + [aps:\s!cite] [\c!left=, \c!right=, \c!inbetween={\space}, @@ -447,7 +434,6 @@ \setupbtxlabeltext [fr] [aps:and=et, - aps:others={et al.}, aps:number={n\high{o}}, aps:edition={édition}, aps:Editor=Éditeur, diff --git a/Master/texmf-dist/tex/context/base/publ-imp-author.mkvi b/Master/texmf-dist/tex/context/base/publ-imp-author.mkvi index 534d8ce0b29..7529c7aa970 100644 --- a/Master/texmf-dist/tex/context/base/publ-imp-author.mkvi +++ b/Master/texmf-dist/tex/context/base/publ-imp-author.mkvi @@ -32,9 +32,9 @@ \startsetups \s!btx:\s!cite:\s!author:concat \ifcase\currentbtxoverflow \btxparameter{\c!separator:names:\number\currentbtxconcat} - \else - %\btxparameter{\c!separator:names:2} - \fi + \else\ifnum\currentbtxauthorindex>\plusone + \btxparameter{\c!separator:names:2} + \fi\fi \stopsetups \startsetups \s!btx:\s!cite:\s!author:others @@ -172,9 +172,9 @@ \startsetups \s!btx:\s!list:\s!author:concat \ifcase\currentbtxoverflow \btxparameter{\c!separator:names:\number\currentbtxconcat} - \else + \else\ifnum\currentbtxauthorindex>\plusone \btxparameter{\c!separator:names:2} - \fi + \fi\fi \stopsetups \startsetups \s!btx:\s!list:\s!author:others diff --git a/Master/texmf-dist/tex/context/base/publ-imp-cite.mkvi b/Master/texmf-dist/tex/context/base/publ-imp-cite.mkvi index 6b09eaf01b1..7ce9ea0da6e 100644 --- a/Master/texmf-dist/tex/context/base/publ-imp-cite.mkvi +++ b/Master/texmf-dist/tex/context/base/publ-imp-cite.mkvi @@ -206,19 +206,6 @@ \startsetups \s!btx:\s!cite:authornum \fastsetup{\s!btx:\s!cite:normal} \stopsetups -\startsetups \s!btx:\s!cite:authorref - % what a crap ... no one will ever understand this module .. it makes no - % sense to have these tests, just let users set the right variant .. - \doifelse{\btxparameter\c!alternative} {authoryear} { - \fastsetup{\s!btx:\s!cite:authoryears} - } { - \doifelse {\btxparameter\c!alternative} {num} { - \fastsetup{\s!btx:\s!cite:authornum} - } { - \fastsetup{\s!btx:\s!cite:author} - } - } -\stopsetups \startsetups \s!btx:\s!cite:num \fastsetup{\s!btx:\s!cite:range} \stopsetups diff --git a/Master/texmf-dist/tex/context/base/publ-imp-default.mkvi b/Master/texmf-dist/tex/context/base/publ-imp-default.mkvi index e51955c704b..2fc58ef99c8 100644 --- a/Master/texmf-dist/tex/context/base/publ-imp-default.mkvi +++ b/Master/texmf-dist/tex/context/base/publ-imp-default.mkvi @@ -17,15 +17,16 @@ \startbtxrenderingdefinitions[\s!default] -% \definebtx [\s!default:\s!page ] [\s!page] -% \definebtx [\s!default:\s!cite ] [\s!cite] -% \definebtx [\s!default:\s!list ] [\s!list] -% \definebtx [\s!default:\s!author] [\s!author] +%?? \definebtx [\s!default:\s!page ] [\s!page] +%?? \definebtx [\s!default:\s!cite ] [\s!cite] +%?? \definebtx [\s!default:\s!list ] [\s!list] +%?? \definebtx [\s!default:\s!author] [\s!author] \definebtxrendering [\s!default] [\c!specification=\s!default, - \c!sorttype=\v!default] + \c!sorttype=\v!default, + \c!numbering=num] \definebtx [\s!default] @@ -50,19 +51,28 @@ \c!sorttype=normal, \c!authorconversion=\v!name] -% We define [page] settings in the default namespace, inheriting the root -% settings, in order to eventually allow for modifications without touching -% root. +% List variants, some having specific settings: \definebtx - [\s!default:\s!page] - [\s!page] + [\s!default:\s!list:\s!page] + [\s!default:\s!list] + [\c!left={\space}] \definebtx - [\s!default:\s!page:list] - [\s!default:\s!page] + [\s!default:\s!list:numbering] + [\s!default:\s!list] -% List variants, some having specific settings: +\definebtx + [\s!default:\s!list:numbering:num] + [\s!default:\s!list:numbering] + +\definebtx + [\s!default:\s!list:numbering:short] + [\s!default:\s!list:numbering:num] + +\definebtx + [\s!default:\s!list:numbering:tag] + [\s!default:\s!list:numbering:num] \definebtx [\s!default:\s!list:author] diff --git a/Master/texmf-dist/tex/context/base/publ-imp-list.mkvi b/Master/texmf-dist/tex/context/base/publ-imp-list.mkvi index 61432486b9b..d34e4bc24c9 100644 --- a/Master/texmf-dist/tex/context/base/publ-imp-list.mkvi +++ b/Master/texmf-dist/tex/context/base/publ-imp-list.mkvi @@ -71,9 +71,9 @@ \btxstopstyleandcolor \stopsetups -\startsetups[\s!btx:\s!list:\s!numbering:bib] - \btxstartstyleandcolor [\currentbtxspecification:\s!list:\s!numbering:bib] - \btxusecommand [\currentbtxspecification:\s!list:\s!numbering:bib] { +\startsetups[\s!btx:\s!list:\s!numbering:tag] + \btxstartstyleandcolor [\currentbtxspecification:\s!list:\s!numbering:tag] + \btxusecommand [\currentbtxspecification:\s!list:\s!numbering:tag] { \fastsetup{\s!btx:\s!list:\s!numbering} } \btxstopstyleandcolor diff --git a/Master/texmf-dist/tex/context/base/publ-ini.lua b/Master/texmf-dist/tex/context/base/publ-ini.lua index 30d0c890882..04a3f1cc116 100644 --- a/Master/texmf-dist/tex/context/base/publ-ini.lua +++ b/Master/texmf-dist/tex/context/base/publ-ini.lua @@ -115,6 +115,7 @@ local ctx_gobbletwoarguments = context.gobbletwoarguments local ctx_btxdirectlink = context.btxdirectlink local ctx_btxhandlelistentry = context.btxhandlelistentry local ctx_btxhandlelisttextentry = context.btxhandlelisttextentry +local ctx_btxhandlecombientry = context.btxhandlecombientry local ctx_btxchecklistentry = context.btxchecklistentry local ctx_btxchecklistcombi = context.btxchecklistcombi @@ -154,6 +155,8 @@ local ctx_btxstartsubcite = context.btxstartsubcite local ctx_btxstopsubcite = context.btxstopsubcite local ctx_btxstartlistentry = context.btxstartlistentry local ctx_btxstoplistentry = context.btxstoplistentry +local ctx_btxstartcombientry = context.btxstartcombientry +local ctx_btxstopcombientry = context.btxstopcombientry local ctx_btxlistsetup = context.btxlistsetup local ctx_btxflushauthor = context.btxflushauthor local ctx_btxsetnoflistentries = context.btxsetnoflistentries @@ -340,10 +343,10 @@ do local initialize = nil initialize = function(t) - usedentries = allocate { } - citetolist = allocate { } - listtocite = allocate { } - listtolist = allocate { } + usedentries = allocate { } + citetolist = allocate { } + listtocite = allocate { } + listtolist = allocate { } local names = { } local internals = structures.references.internals local p_collect = (C(R("09")^1) * Carg(1) / function(s,entry) listtocite[tonumber(s)] = entry end + P(1))^0 @@ -477,15 +480,16 @@ local findallused do local finder = publications.finder findallused = function(dataset,reference,internal) - local current = datasets[dataset] - local finder = publications.finder -- for the moment, not yet in all betas - local find = finder and finder(current,reference) - local tags = not find and settings_to_array(reference) - local todo = { } - local okay = { } -- only if mark - local set = usedentries[dataset] - local valid = current.luadata - local ordered = current.ordered + local current = datasets[dataset] + local finder = publications.finder -- for the moment, not yet in all betas + local find = finder and finder(current,reference) + local tags = not find and settings_to_array(reference) + local todo = { } + local okay = { } -- only if mark + local set = usedentries[dataset] + local valid = current.luadata + local ordered = current.ordered + local combined = current.combined if set then local registered = { } local function register(tag) @@ -495,6 +499,16 @@ local findallused do registered[tag] = true end local entry = set[tag] + if not entry then + local parent = combined[tag] + if parent then + entry = set[parent] + end + if entry then + report("using reference of parent %a for %a",parent,tag) + tag = parent + end + end if entry then -- only once in a list but at some point we can have more (if we -- decide to duplicate) @@ -533,22 +547,22 @@ local findallused do okay[#okay+1] = entry end todo[tag] = true + return tag end if reference == "*" then tags = { } for i=1,#ordered do local tag = ordered[i].tag - register(tag) + tag = register(tag) tags[#tags+1] = tag end elseif find then --- print("case 1.1") tags = { } for i=1,#ordered do local entry = ordered[i] if find(entry) then local tag = entry.tag - register(tag) + tag = register(tag) tags[#tags+1] = tag end end @@ -557,11 +571,11 @@ local findallused do reported[reference] = true end else --- print("case 1.2") for i=1,#tags do - local tag = tags[i] + local tag = tags[i] if valid[tag] then - register(tag) + tag = register(tag) + tags[i] = tag elseif not reported[tag] then reported[tag] = true report_cite("non-existent entry %a in %a",tag,dataset) @@ -570,12 +584,15 @@ local findallused do end else if find then --- print("case 2.1") tags = { } for i=1,#ordered do local entry = ordered[i] if find(entry) then - local tag = entry.tag + local tag = entry.tag + local parent = combined[tag] + if parent then + tag = parent + end tags[#tags+1] = tag todo[tag] = true end @@ -585,9 +602,13 @@ local findallused do reported[reference] = true end else --- print("case 2.2") for i=1,#tags do - local tag = tags[i] + local tag = tags[i] + local parent = combined[tag] + if parent then + tag = parent + tags[i] = tag + end if valid[tag] then todo[tag] = true elseif not reported[tag] then @@ -1060,9 +1081,11 @@ do local userdata = listentry.userdata local btxspc = userdata and userdata.btxspc if btxspc then - -- this will become a specification entry + -- we could act on the 3rd arg returned by getcasted but in general any string will do + -- so we deal with it in the author hashers ... maybe some day ... local author = getcasted(dataset,tag,field,specifications[btxspc]) - if type(author) == "table" then + local kind = type(author) + if kind == "table" or kind == "string" then if u then u = listentry.entries.text -- hm else @@ -1633,17 +1656,20 @@ do end end + + -- tag | listindex | reference | userdata | dataindex + local methods = { } lists.methods = methods methods[v_dataset] = function(dataset,rendering,keyword) - -- why only once unless criterium=all? local current = datasets[dataset] local luadata = current.luadata local list = rendering.list for tag, data in sortedhash(luadata) do if not keyword or validkeyword(dataset,tag,keyword) then - list[#list+1] = { tag, false, 0, false, false, data.index or 0} + local index = data.index or 0 + list[#list+1] = { tag, index, 0, false, index } end end end @@ -1666,7 +1692,7 @@ do local tag = u.btxref if tag and (not keyword or validkeyword(dataset,tag,keyword)) then local data = luadata[tag] - list[#list+1] = { tag, listindex, 0, u, u.btxint, data and data.index or 0 } + list[#list+1] = { tag, listindex, 0, u, data and data.index or 0 } end end end @@ -1700,6 +1726,7 @@ do if u then -- better check on metadata.kind == "btx" local set = u.btxset or v_default if set == dataset then +-- inspect(structures.references.internals[tonumber(u.btxint)]) local tag = u.btxref if not tag then -- problem @@ -1714,7 +1741,7 @@ do l[#l+1] = u.btxint else local data = luadata[tag] - local l = { tag, listindex, 0, u, u.btxint, data and data.index or 0 } + local l = { tag, listindex, 0, u, data and data.index or 0 } list[#list+1] = l traced[tag] = l end @@ -1722,7 +1749,7 @@ do done[tag] = section alldone[tag] = true local data = luadata[tag] - list[#list+1] = { tag, listindex, 0, u, u.btxint, data and data.index or 0 } + list[#list+1] = { tag, listindex, 0, u, data and data.index or 0 } end end if tag then @@ -1798,6 +1825,7 @@ do local current = datasets[dataset] local luadata = current.luadata local details = current.details + local combined = current.combined local newlist = { } local lastreferencenumber = groups[group] -- current.lastreferencenumber or 0 for i=1,#list do @@ -1819,31 +1847,55 @@ do else list = newlist end +-- local combined = { } + local newlist = { } +-- for i=1,#list do +-- local userdata = list[i][4] +-- if userdata then +-- local com = userdata.btxcom +-- if com then +-- com = settings_to_array(com) +-- for i=1,#com do +-- local c = com[i] +-- if not combined[c] then +-- report("ignoring list entry for tag %a due to combined usage in %a ",c,tag) +-- combined[c] = true +-- end +-- end +-- end +-- end +-- end + local tagtolistindex = { } + rendering.tagtolistindex = tagtolistindex for i=1,#list do local li = list[i] local tag = li[1] - local entry = luadata[tag] - if entry then - local detail = details[tag] - if detail then - local referencenumber = detail.referencenumber - if not referencenumber then - lastreferencenumber = lastreferencenumber + 1 - referencenumber = lastreferencenumber - detail.referencenumber = lastreferencenumber + if not combined[tag] then + local entry = luadata[tag] + if entry then + local detail = details[tag] + if detail then + local referencenumber = detail.referencenumber + if not referencenumber then + lastreferencenumber = lastreferencenumber + 1 + referencenumber = lastreferencenumber + detail.referencenumber = lastreferencenumber + end + li[3] = referencenumber + else + report("missing details for tag %a in dataset %a (enhanced: %s)",tag,dataset,current.enhanced and "yes" or "no") + -- weird, this shouldn't happen .. all have a detail + lastreferencenumber = lastreferencenumber + 1 + details[tag] = { referencenumber = lastreferencenumber } + li[3] = lastreferencenumber end - li[3] = referencenumber - else - report("missing details for tag %a in dataset %a (enhanced: %s)",tag,dataset,current.enhanced and "yes" or "no") - -- weird, this shouldn't happen .. all have a detail - lastreferencenumber = lastreferencenumber + 1 - details[tag] = { referencenumber = lastreferencenumber } - li[3] = lastreferencenumber + tagtolistindex[tag] = i end + newlist[#newlist+1] = li end end groups[group] = lastreferencenumber - rendering.list = list + rendering.list = newlist end function lists.fetchentries(dataset) @@ -1997,14 +2049,56 @@ do end end + function lists.combiinlist(dataset,tag) + local rendering = renderings[dataset] + local list = rendering.list + local toindex = rendering.tagtolistindex + return toindex and toindex[tag] + end + + function lists.flushcombi(dataset,tag) + local rendering = renderings[dataset] + local list = rendering.list + local toindex = rendering.tagtolistindex + local listindex = toindex and toindex[tag] + if listindex then + local li = list[listindex] + if li then + local data = datasets[dataset] + local luadata = data.luadata + local details = data.details + local tag = li[1] + local listindex = li[2] + local n = li[3] + local entry = luadata[tag] + local detail = details[tag] + ctx_btxstartcombientry() + ctx_btxsetcurrentlistindex(listindex) + ctx_btxsetcategory(entry.category or "unknown") + ctx_btxsettag(tag) + ctx_btxsetnumber(n) + local language = entry.language + if language then + ctx_btxsetlanguage(language) + end + local authorsuffix = detail.authorsuffix + if authorsuffix then + ctx_btxsetsuffix(authorsuffix) + end + ctx_btxhandlecombientry() + ctx_btxstopcombientry() + end + end + end + function lists.flushentry(dataset,i,textmode) local rendering = renderings[dataset] local list = rendering.list - local data = datasets[dataset] - local luadata = data.luadata - local details = data.details local li = list[i] if li then + local data = datasets[dataset] + local luadata = data.luadata + local details = data.details local tag = li[1] local listindex = li[2] local n = li[3] @@ -2025,17 +2119,6 @@ do if language then ctx_btxsetlanguage(language) end - local bl = li[5] - if bl and bl ~= "" then - ctx_btxsetbacklink(bl) - -- ctx_btxsetbacktrace(concat(li," ",5)) -- two numbers - else - -- nothing - end - local authorsuffix = detail.authorsuffix - if authorsuffix then - ctx_btxsetsuffix(authorsuffix) - end local userdata = li[4] if userdata then local b = userdata.btxbtx @@ -2046,6 +2129,14 @@ do if a then ctx_btxsetafter(a) end + local bl = userdata.btxint + if bl and bl ~= "" then + ctx_btxsetbacklink(bl) + end + end + local authorsuffix = detail.authorsuffix + if authorsuffix then + ctx_btxsetsuffix(authorsuffix) end rendering.userdata = userdata if textmode then @@ -2142,11 +2233,23 @@ do } implement { + name = "btxflushlistcombi", + actions = lists.flushcombi, + arguments = { "string", "string" } + } + + implement { name = "btxdoifelsesameasprevious", actions = { lists.sameasprevious, ctx_doifelse }, arguments = { "string", "integer", "string", "integer", "string" } } + implement { + name = "btxdoifelsecombiinlist", + actions = { lists.combiinlist, ctx_doifelse }, + arguments = { "string", "string" } + } + end do @@ -2391,7 +2494,7 @@ do tobemarked = specification.markentry and todo -- if not found or #found == 0 then - report("nothing found for %a",reference) + report("no entry %a found in dataset %a",reference,dataset) elseif not setup then report("invalid reference for %a",reference) else @@ -2402,6 +2505,7 @@ do local luadata = datasets[dataset].luadata for i=1,#found do local entry = found[i] +-- inspect(entry) local tag = entry.userdata.btxref local ldata = luadata[tag] local data = { @@ -2409,6 +2513,7 @@ do language = ldata.language, dataset = dataset, tag = tag, + combis = entry.userdata.btxcom, -- luadata = ldata, } setter(data,dataset,tag,entry) @@ -2455,6 +2560,10 @@ do if language then ctx_btxsetlanguage(language) end +local combis = entry.combis +if combis then + ctx_btxsetcombis(combis) +end if not getter(entry,last,nil,specification) then ctx_btxsetfirst("") -- (f_missing(tag)) end @@ -2816,8 +2925,10 @@ do else return false end - else + elseif ak and bk then return ak < bk + else + return false end end @@ -3109,7 +3220,14 @@ do end listvariants[v_yes] = listvariants.num - listvariants.bib = listvariants.num + + function listvariants.tag(dataset,block,tag,variant,listindex) + ctx_btxsetfirst(tag) + if trace_detail then + report("expanding %a list setup %a","tag",variant) + end + ctx_btxnumberingsetup(variant or "tag") + end function listvariants.short(dataset,block,tag,variant,listindex) local short = getdetail(dataset,tag,"shorthash") @@ -3154,3 +3272,32 @@ do end end + +-- a helper + +do + + -- local context = context + -- local lpegmatch = lpeg.match + local splitter = lpeg.tsplitat(":") + + interfaces.implement { + name = "checkinterfacechain", + arguments = { "string", "string" }, + actions = function(str,command) + local chain = lpegmatch(splitter,str) + if #chain > 0 then + local command = context[command] + local parent = "" + local child = chain[1] + command(child,parent) + for i=2,#chain do + parent = child + child = child .. ":" .. chain[i] + command(child,parent) + end + end + end + } + +end diff --git a/Master/texmf-dist/tex/context/base/publ-ini.mkiv b/Master/texmf-dist/tex/context/base/publ-ini.mkiv index 7270b5f4d18..6d57a233d02 100644 --- a/Master/texmf-dist/tex/context/base/publ-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/publ-ini.mkiv @@ -14,6 +14,8 @@ % TODO: s! vs v! for default and neutral key/values % todo: too many refs in list +% todo: no need for all these %'s + % todo: tagging % todo: we cannot use 'default' as this wipes metadata names (maybe no longer do that) % todo: \v!cite => \s!cite @@ -71,6 +73,7 @@ \def\s!btxbtx {btxbtx} \def\s!btxspc {btxspc} \def\s!btxlst {btxlst} +\def\s!btxcom {btxcom} \definelabelclass[btxlabel][2] @@ -147,11 +150,41 @@ \installswitchcommandhandler \??btx {btx} \??btx +% because we have lots of setups we provide a checker for sloppy users + +\unexpanded\def\btx_check_chain#1#2#3% + {\doifelsesomething{#3} + {\writestatus{btx #1}{defining\space"#2"\space as\space descendant\space of\space"#3"}% we're in definition regime (no space) + \definebtx[#2][#3]} + {\writestatus{btx #1}{defining\space"#2"}% + \definebtx[#2]}} + +% \unexpanded\def\btxcheckdefine#1#2{\doifelsecommandhandler\??btx{#1}\donothing{\btx_check_chain{define}{#1}{#2}}} +% \unexpanded\def\btxchecksetup #1#2{\doifelsecommandhandler\??btx{#1}\donothing{\btx_check_chain {setup}{#1}{#2}}} + +\unexpanded\def\btxcheckdefine#1{\doifelsecommandhandler\??btx{#1}\gobbleoneargument{\btx_check_chain{define}{#1}}} % {#2} +\unexpanded\def\btxchecksetup #1{\doifelsecommandhandler\??btx{#1}\gobbleoneargument{\btx_check_chain {setup}{#1}}} % {#2} + +% fpr the moment experimental: + +\unexpanded\def\btxenableautodefine + {\prependtoks + \clf_checkinterfacechain{\currentbtx}{btxcheckdefine}% + \to \everydefinebtx + \prependtoks + \ifnum\btxsetupmode=\doingrootsetupnamed + \clf_checkinterfacechain{\currentbtx}{btxchecksetup}% + \fi + \to \everysetupbtx + \let\btxenableautodefine\relax} + \appendtoks \ifnum\btxsetupmode=\doingrootsetuproot \publ_specification_set{\btxparameter\c!specification}% \else\ifnum\btxsetupmode=\doingrootsetupnamed - \publ_specification_set{\btxparameter\c!specification}% + \doifelsecommandhandler\??btx\currentbtx + {\publ_specification_set{\btxparameter\c!specification}}% + {}% maybe a warning \fi\fi \to \everysetupbtx @@ -590,7 +623,7 @@ \begingroup \setbtxlist % probably already set \btx_reset_page - \setbtxparameterset\s!page\s!list + \setbtxparameterset\s!list\s!page \btxparameter\c!pagecommand {\usebtxstyleandcolor\c!style\c!color \btxparameter\c!pageleft @@ -633,12 +666,15 @@ \publ_fast_setup\plusfour\s!list\currentbtxcategory \removeunwantedspaces \endgroup - \ifconditional\c_btx_list_pages - \btx_entry_inject_pages - \fi \ifx\currentbtxcombis\empty \else \btxrenderingparameter\c!separator - \processcommacommand[\currentbtxcombis]\btx_entry_inject_combi + % maybe move this loop to lua + \begingroup + \processcommacommand[\currentbtxcombis]\btx_entry_inject_combi + \endgroup + \fi + \ifconditional\c_btx_list_pages + \btx_entry_inject_pages \fi \ifconditional\c_btx_list_texts \currentbtxafter @@ -657,6 +693,15 @@ \ctxcommand{showbtxentry("\currentbtxdataset","\currentbtxtag")} \fi\fi} +\unexpanded\def\btxstartcombientry + {\begingroup} + +\unexpanded\def\btxstopcombientry + {\endgroup} + +\unexpanded\def\btxhandlecombientry + {\btx_reference_indeed} + \def\btx_entry_inject_combi#1% {\begingroup \def\currentbtxtag{#1}% @@ -665,6 +710,18 @@ \removeunwantedspaces \endgroup} +% uses reference when set + +% \def\btx_entry_inject_combi#1% +% {\begingroup +% \def\currentbtxtag{#1}% +% \ignorespaces +% \btxdoifelsecombiinlist\currentbtxdataset\currentbtxtag +% {\clf_btxflushlistcombi{\currentbtxdataset}{\currentbtxtag}} +% {\publ_fast_setup\plusfour\s!list\currentbtxcategory}% +% \removeunwantedspaces +% \endgroup} + \unexpanded\def\completebtxrendering{\dodoubleempty\publ_place_list_complete} \unexpanded\def\placebtxrendering {\dodoubleempty\publ_place_list_standard} @@ -709,8 +766,12 @@ \unexpanded\def\btxdoifelsesameasprevious {\btxdoifelsesameaspreviouschecked\v!doublesided} +\unexpanded\def\btxdoifelsecombiinlist#1#2% + {\clf_btxdoifelsecombiinlist{#1}{#2}} + \let\btxdoifsameaspreviouscheckedelse\btxdoifelsesameaspreviouschecked \let\btxdoifsameaspreviouselse \btxdoifelsesameasprevious +\let\btxdoifcombiinlistelse \btxdoifelsecombiinlist \def\publ_place_list_indeed#1[#2][#3]% {\begingroup @@ -920,6 +981,7 @@ \s!btxref=\currentbtxtag,% \s!btxspc=\currentbtxspecification,% \s!btxlst=\number\c_btx_list_reference,% check if needed + %\ifx\currentbtxcombis\empty\else\s!btxcom={\currentbtxcombis},\fi% \ifx\currentbtxbefore\empty\else\s!btxbtx={\currentbtxbefore},\fi% \ifx\currentbtxafter \empty\else\s!btxatx={\currentbtxafter },\fi% \ifx\currentbtxbacklink\currentbtxbacktrace\s!btxint=\currentbtxbacklink\else\s!btxbck=\currentbtxbacktrace\fi}% @@ -952,6 +1014,7 @@ [\c!type=\s!btx]% \c!location=\v!none [\ifx\currentbtxdataset\v!default\else\s!btxset=\currentbtxdataset,\fi% \s!btxref=\currentbtxtag,% + %\ifx\currentbtxcombis\empty\else\s!btxcom={\currentbtxcombis},\fi% \ifx\currentbtxbefore\empty\else\s!btxbtx={\currentbtxbefore},\fi% \ifx\currentbtxafter \empty\else\s!btxatx={\currentbtxafter },\fi% \s!btxint=\number\currentbtxbacklink @@ -968,8 +1031,11 @@ \appendtoks \edef\currentbtxnumbering{\btxrenderingparameter\c!numbering}% - \edef\p_numbering{\btxrenderingparameter\c!numbering}% link to headnumber - \ifx\p_numbering\v!no + \ifx\currentbtxnumbering\v!yes + \def\currentbtxnumbering{num}% convenient alias + \letbtxrenderingparameter\c!numbering\currentbtxnumbering + \letlistparameter\c!headnumber\v!always + \else\ifx\currentbtxnumbering\v!no \letlistparameter\c!headnumber\v!no \let\currentbtxnumbering\empty % \letlistparameter\c!textcommand\outdented % needed? we can use titlealign @@ -978,7 +1044,7 @@ \letlistparameter\c!numbercommand\firstofoneargument % for the moment, no doubling needed \else \letlistparameter\c!headnumber\v!always - \fi + \fi\fi \let\currentlistmethod\s!btx \to \everysetupbtxlistplacement @@ -1015,6 +1081,7 @@ kind {list}% etallimit {\btxparameter\c!etallimit}% etaldisplay {\btxparameter\c!etaldisplay}% + etaloption {\btxparameter\c!etaloption}% symbol {\btxparameter{\c!stopper:initials}}% }% \relax @@ -1040,6 +1107,7 @@ kind {cite}% etallimit {\btxparameter\c!etallimit}% etaldisplay {\btxparameter\c!etaldisplay}% + etaloption {\btxparameter\c!etaloption}% symbol {\btxparameter{\c!stopper:initials}}% }% \relax diff --git a/Master/texmf-dist/tex/context/base/publ-sor.lua b/Master/texmf-dist/tex/context/base/publ-sor.lua index c442e395395..ba353a9bcc4 100644 --- a/Master/texmf-dist/tex/context/base/publ-sor.lua +++ b/Master/texmf-dist/tex/context/base/publ-sor.lua @@ -26,6 +26,10 @@ local v_short = variables.short local v_default = variables.default local v_reference = variables.reference local v_dataset = variables.dataset +local v_list = variables.list +local v_index = variables.index +local v_cite = variables.cite +local v_used = variables.used local report = logs.reporter("publications","sorters") @@ -225,70 +229,140 @@ local function sortsequence(dataset,list,sorttype) end --- index : order in dataset --- order : order of citations --- short : alphabetic + suffix --- reference : order in list --- default : automatic sorter --- authoryear : sort order list - --- tag | listindex | 0 | u | u.btxint | data.index - -local sorters = { - [v_short] = function(dataset,rendering,list) -- should we store it - local shorts = rendering.shorts - local function compare(a,b) - local aa = a and a[1] - local bb = b and b[1] - if aa and bb then - aa, bb = shorts[aa], shorts[bb] - return aa and bb and aa < bb - else - return a[1] < b[1] +-- tag | listindex | reference | userdata | dataindex + +-- short : short + tag index +-- dataset : index + tag +-- list : list + index +-- reference : tag + index +-- used : reference + dataset +-- authoryear : complex sort + +local sorters = { } + +sorters[v_short] = function(dataset,rendering,list) -- should we store it + local shorts = rendering.shorts + local function compare(a,b) + if a and b then + local taga = a[1] + local tagb = b[1] + if taga and tagb then + local shorta = shorts[taga] + local shortb = shorts[tagb] + if shorta and shortb then + -- assumes ascii shorts ... no utf yet + return shorta < shortb + end + -- fall back on tag order + return taga < tagb + end + -- fall back on dataset order + local indexa = a[5] + local indexb = b[5] + if indexa and indexb then + return indexa < indexb + end + end + return false + end + sort(list,compare) +end + +sorters[v_dataset] = function(dataset,rendering,list) -- dataset index + local function compare(a,b) + if a and b then + local indexa = a[5] + local indexb = b[5] + if indexa and indexb then + return indexa < indexb + end + local taga = a[1] + local tagb = b[1] + if taga and tagb then + return taga < tagb end end - sort(list,compare) - end, - [v_reference] = function(dataset,rendering,list) -- tag - local function compare(a,b) - return a[1] < b[1] + return false + end + sort(list,compare) +end + +sorters[v_list] = function(dataset,rendering,list) -- list index (normally redundant) + local function compare(a,b) + if a and b then + local lista = a[2] + local listb = b[2] + if lista and listb then + return lista < listb + end + local indexa = a[5] + local indexb = b[5] + if indexa and indexb then + return indexa < indexb + end end - sort(list,compare) - end, - [v_dataset] = function(dataset,rendering,list) -- dataset index - local function compare(a,b) - local aa = a and a[6] - local bb = b and b[6] - if aa and bb then - return aa < bb - else - return a[1] < b[1] + return false + end + sort(list,compare) +end + +sorters[v_reference] = function(dataset,rendering,list) -- tag + local function compare(a,b) + if a and b then + local taga = a[1] + local tagb = b[1] + if taga and tagb then + return taga < tagb + end + local indexa = a[5] + local indexb = b[5] + if indexa and indexb then + return indexa < indexb end end - sort(list,compare) - end, - [v_default] = function(dataset,rendering,list,sorttype) - if sorttype == "" or sorttype == v_default then -- listorder - local function compare(a,b) - return a[2] < b[2] + return false + end + sort(list,compare) +end + +sorters[v_used] = function(dataset,rendering,list) -- tag + local function compare(a,b) + if a and b then + local referencea = a[2] + local referenceb = b[2] + if referencea and referenceb then + return referencea < referenceb end - sort(list,compare) - else - local valid = sortsequence(dataset,list,sorttype) -- field order - if valid and #valid > 0 then - -- hm, we have a complication here because a sortsequence doesn't know if there's a field - -- so there is no real catch possible here .., anyway, we add a index as last entry when no - -- one is set so that should be good enough (needs testing) - for i=1,#valid do - local v = valid[i] - valid[i] = list[v.index] - end - return valid + local indexa = a[5] + local indexb = b[5] + if indexa and indexb then + return indexa < indexb end end + return false end -} + sort(list,compare) +end + +sorters[v_default] = sorters[v_list] +sorters[""] = sorters[v_list] +sorters[v_cite] = sorters[v_list] +sorters[v_index] = sorters[v_dataset] + +local function anything(dataset,rendering,list,sorttype) + local valid = sortsequence(dataset,list,sorttype) -- field order + if valid and #valid > 0 then + -- hm, we have a complication here because a sortsequence doesn't know if there's a field + -- so there is no real catch possible here .., anyway, we add a index as last entry when no + -- one is set so that should be good enough (needs testing) + for i=1,#valid do + local v = valid[i] + valid[i] = list[v.index] + end + return valid + end +end -table.setmetatableindex(sorters,function(t,k) return t[v_default] end) +table.setmetatableindex(sorters,function(t,k) return anything end) publications.lists.sorters = sorters diff --git a/Master/texmf-dist/tex/context/base/spac-ali.mkiv b/Master/texmf-dist/tex/context/base/spac-ali.mkiv index 6686bce53a4..07d588ba7d5 100644 --- a/Master/texmf-dist/tex/context/base/spac-ali.mkiv +++ b/Master/texmf-dist/tex/context/base/spac-ali.mkiv @@ -207,6 +207,9 @@ \unexpanded\def\spac_align_set_stretch {\emergencystretch\bodyfontsize} +\unexpanded\def\spac_align_set_extreme_stretch + {\emergencystretch10\bodyfontsize} + % Vertical \newconstant\c_spac_align_state_vertical @@ -681,6 +684,7 @@ \setvalue{\??aligncommand\v!tolerant }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_tolerant}} \setvalue{\??aligncommand\v!verytolerant }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_very_tolerant}} \setvalue{\??aligncommand\v!stretch }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_stretch}} +\setvalue{\??aligncommand\v!extremestretch }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_extreme_stretch}} %D For Wolfgang: diff --git a/Master/texmf-dist/tex/context/base/status-files.pdf b/Master/texmf-dist/tex/context/base/status-files.pdf Binary files differindex b5850036794..a1f5582c450 100644 --- a/Master/texmf-dist/tex/context/base/status-files.pdf +++ b/Master/texmf-dist/tex/context/base/status-files.pdf diff --git a/Master/texmf-dist/tex/context/base/status-lua.pdf b/Master/texmf-dist/tex/context/base/status-lua.pdf Binary files differindex 2046da47ab4..7903adbdca5 100644 --- a/Master/texmf-dist/tex/context/base/status-lua.pdf +++ b/Master/texmf-dist/tex/context/base/status-lua.pdf diff --git a/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv b/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv index 2b6f3a3ecf6..fcf8ac31231 100644 --- a/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv +++ b/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv @@ -235,7 +235,7 @@ \installcorenamespace{naturaltablehei} \installcorenamespace{naturaltabledis} \installcorenamespace{naturaltableaut} -\installcorenamespace{naturaltablefwd} % forcedwidth +%installcorenamespace{naturaltablefwd} % forcedwidth \installcorenamespace{naturaltabletxt} \installcorenamespace{naturaltablespn} \installcorenamespace{naturaltableref} @@ -1459,6 +1459,8 @@ \tabl_ntb_set_aut\c_tabl_ntb_col{\the\dimexpr\localwidth}% \fi} +\let\tabl_ntb_preroll\relax + \def\tabl_ntb_table_stop {\forgetall % new, here see narrower-004.tex %\setbox\scratchbox\hbox @@ -1481,6 +1483,7 @@ \dorecurse\c_tabl_ntb_maximum_row {\tabl_ntb_let_hei\recurselevel\maxdimen}% \tabl_ntb_let_gal\zerocount +\tabl_ntb_preroll\relax \c_tabl_tbl_pass\plusone \let\tabl_ntb_pass\tabl_ntb_pass_one \let\tabl_ntb_cell_process\tabl_ntb_cell_process_a @@ -1822,38 +1825,52 @@ \fi \fi} -\def\tabl_ntb_cell_process_a_check_span_two_yes - {\iftightTBLcolspan - \donefalse - \else - \ifnum\scratchcounter>\plusone - \begingroup - \edef\p_width{\naturaltablelocalparameter\c!width}% - \csname\??naturaltablesqueeze\ifcsname\??naturaltablesqueeze\p_width\endcsname\p_width\fi\endcsname - \ifdone - \endgroup - \edef\p_option{\naturaltablelocalparameter\c!option}% - \ifx\p_option\v!tight\donefalse\else\donetrue\fi - \else - % a dimension - \endgroup - \donefalse - \fi - \else - \edef\p_option{\naturaltablelocalparameter\c!option}% - \ifx\p_option\v!tight\donefalse\else\donetrue\fi - \fi - \fi} +% \def\tabl_ntb_cell_process_a_check_span_two_yes +% {\iftightTBLcolspan +% \donefalse +% \else +% \ifnum\scratchcounter>\plusone +% \begingroup +% \edef\p_width{\naturaltablelocalparameter\c!width}% +% \csname\??naturaltablesqueeze\ifcsname\??naturaltablesqueeze\p_width\endcsname\p_width\fi\endcsname +% \ifdone +% \endgroup +% \edef\p_option{\naturaltablelocalparameter\c!option}% +% \ifx\p_option\v!tight\donefalse\else\donetrue\fi +% \else +% % a dimension +% \endgroup +% \donefalse +% \fi +% \else +% \edef\p_option{\naturaltablelocalparameter\c!option}% +% \ifx\p_option\v!tight\donefalse\else\donetrue\fi +% \fi +% \fi +% \ifdone +% \ifdim\tabl_ntb_get_wid\c_tabl_ntb_col<\wd\scratchbox +% \tabl_ntb_set_wid\c_tabl_ntb_col{\the\wd\scratchbox}% +% \fi +% \fi} +% \def\tabl_ntb_cell_process_a_check_span_two_nop +% {\ifnum\scratchcounter>\plusone +% \edef\p_width{\naturaltablelocalparameter\c!width}% +% \csname\??naturaltablesqueeze\ifcsname\??naturaltablesqueeze\p_width\endcsname\p_width\fi\endcsname +% \else +% \donetrue +% \fi +% \ifdone +% \ifdim\tabl_ntb_get_wid\c_tabl_ntb_col<\wd\scratchbox +% \tabl_ntb_set_wid\c_tabl_ntb_col{\the\wd\scratchbox}% +% \fi +% \fi} -% \let\tabl_ntb_cell_process_a_check_span_two_nop\donetrue +\let\tabl_ntb_cell_process_a_check_span_two_yes\relax \def\tabl_ntb_cell_process_a_check_span_two_nop - {\ifnum\scratchcounter>\plusone - \edef\p_width{\naturaltablelocalparameter\c!width}% - \csname\??naturaltablesqueeze\ifcsname\??naturaltablesqueeze\p_width\endcsname\p_width\fi\endcsname - \else - \donetrue + {\ifdim\tabl_ntb_get_wid\c_tabl_ntb_col<\wd\scratchbox + \tabl_ntb_set_wid\c_tabl_ntb_col{\the\wd\scratchbox}% \fi} \unexpanded\def\tabl_ntb_cell_process_a#1#2[#3]#4% grouping added ! ! ! @@ -1878,11 +1895,6 @@ \tabl_ntb_spn_doifelse\c_tabl_ntb_col \tabl_ntb_cell_process_a_check_span_two_yes \tabl_ntb_cell_process_a_check_span_two_nop - \ifdone - \ifdim\tabl_ntb_get_wid\c_tabl_ntb_col<\wd\scratchbox - \tabl_ntb_set_wid\c_tabl_ntb_col{\the\wd\scratchbox}% - \fi - \fi \fi \scratchcounter\numexpr\c_tabl_ntb_row+\plusone\relax \scratchdimen\tabl_ntb_get_hei\scratchcounter\relax diff --git a/Master/texmf-dist/tex/context/base/x-asciimath.lua b/Master/texmf-dist/tex/context/base/x-asciimath.lua index 6030be86c8f..932c9a1b470 100644 --- a/Master/texmf-dist/tex/context/base/x-asciimath.lua +++ b/Master/texmf-dist/tex/context/base/x-asciimath.lua @@ -38,7 +38,7 @@ end local type, rawget = type, rawget local concat, insert, remove = table.concat, table.insert, table.remove local rep, gmatch, gsub, find = string.rep, string.gmatch, string.gsub, string.find -local utfchar = utf.char +local utfchar, utfbyte = utf.char, utf.byte local lpegmatch, patterns = lpeg.match, lpeg.patterns local S, P, R, C, V, Cc, Ct, Cs, Carg = lpeg.S, lpeg.P, lpeg.R, lpeg.C, lpeg.V, lpeg.Cc, lpeg.Ct, lpeg.Cs, lpeg.Carg @@ -140,6 +140,7 @@ local reserved = { ["times"] = { true, "×" }, ["-:"] = { true, "÷" }, ["@"] = { true, "∘" }, + ["circ"] = { true, "∘" }, ["o+"] = { true, "⊕" }, ["ox"] = { true, "⊗" }, ["o."] = { true, "⊙" }, @@ -700,8 +701,29 @@ local reserved = { ["\\frac"] = { true, "frac" }, + -- now it gets real crazy, only these two: + + [">"] = { true, ">" }, + ["<"] = { true, "<" }, + } +for k, v in next, characters.data do + local name = v.mathname + if name and not reserved[name] then + reserved[name] = { true, utfchar(k) } + end + local spec = v.mathspec +-- if spec then +-- for i=1,#spec do +-- local name = spec[i].name +-- if name and not reserved[name] then +-- reserved[name] = { true, utfchar(k) } +-- end +-- end +-- end +end + local isbinary = { ["\\frac"] = true, ["\\root"] = true, @@ -889,13 +911,13 @@ local p_spaces = patterns.whitespace local p_utf_base = patterns.utf8character local p_utf = C(p_utf_base) -local p_entity = (P("&") * C((1-P(";"))^2) * P(";"))/ entities +-- local p_entity = (P("&") * C((1-P(";"))^2) * P(";"))/ entities -entities["gt"] = ">" -entities["lt"] = "<" -entities["amp"] = "&" -entities["dquot"] = '"' -entities["quot"] = "'" +-- entities["gt"] = ">" +-- entities["lt"] = "<" +-- entities["amp"] = "&" +-- entities["dquot"] = '"' +-- entities["quot"] = "'" local p_onechar = p_utf_base * P(-1) @@ -934,8 +956,10 @@ for k, v in sortedhash(reserved) do end for k, v in next, entities do - k_unicode[k] = v - k_unicode["\\"..k] = v + if not k_unicode[k] then + k_unicode[k] = v + k_unicode["\\"..k] = v + end end if not find(k,"[^[a-zA-Z]+$]") then @@ -1061,10 +1085,10 @@ local p_special = -- open | close :: {: | :} -local e_parser = Cs ( ( - p_entity + - p_utf_base -)^0 ) +-- local e_parser = Cs ( ( +-- p_entity + +-- p_utf_base +-- )^0 ) local u_parser = Cs ( ( @@ -1641,7 +1665,7 @@ local ctx_type = context and context.type or function() end local ctx_inleft = context and context.inleft or function() end local function convert(str,totex) - local entified = lpegmatch(e_parser,str) or str -- when used in text + local entified = str -- lpegmatch(e_parser,str) or str -- when used in text local unicoded = lpegmatch(u_parser,entified) or entified local texcoded = collapse(lpegmatch(a_parser,unicoded)) if trace_mapping then @@ -1795,7 +1819,7 @@ asciimath.cleanedup = cleanedup local function convert(str) if #str > 0 then - local entified = lpegmatch(e_parser,str) or str -- when used in text + local entified = str -- lpegmatch(e_parser,str) or str -- when used in text local unicoded = lpegmatch(u_parser,entified) or entified if lpegmatch(p_onechar,unicoded) then ctx_mathematics(unicoded) @@ -2063,3 +2087,5 @@ end function show.save(name) table.save(name ~= "" and name or "dummy.lua",collected) end + +-- inspect(sortedkeys(reserved)) diff --git a/Master/texmf-dist/tex/context/interface/cont-cs.xml b/Master/texmf-dist/tex/context/interface/cont-cs.xml index afaacb7098b..c798ea4a91a 100644 --- a/Master/texmf-dist/tex/context/interface/cont-cs.xml +++ b/Master/texmf-dist/tex/context/interface/cont-cs.xml @@ -7188,6 +7188,7 @@ <cd:constant type="tolerantni"/> <cd:constant type="velmitolerantni"/> <cd:constant type="natahnout"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-de.xml b/Master/texmf-dist/tex/context/interface/cont-de.xml index e9771d07a67..f40927b45d1 100644 --- a/Master/texmf-dist/tex/context/interface/cont-de.xml +++ b/Master/texmf-dist/tex/context/interface/cont-de.xml @@ -7188,6 +7188,7 @@ <cd:constant type="tolerant"/> <cd:constant type="sehrtolerant"/> <cd:constant type="strecken"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-en.xml b/Master/texmf-dist/tex/context/interface/cont-en.xml index f00215596ef..651292e7f0a 100644 --- a/Master/texmf-dist/tex/context/interface/cont-en.xml +++ b/Master/texmf-dist/tex/context/interface/cont-en.xml @@ -7188,6 +7188,7 @@ <cd:constant type="tolerant"/> <cd:constant type="verytolerant"/> <cd:constant type="stretch"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-fr.xml b/Master/texmf-dist/tex/context/interface/cont-fr.xml index 1cd7fa33a5f..30a89c059ad 100644 --- a/Master/texmf-dist/tex/context/interface/cont-fr.xml +++ b/Master/texmf-dist/tex/context/interface/cont-fr.xml @@ -7188,6 +7188,7 @@ <cd:constant type="tolerant"/> <cd:constant type="trestolerant"/> <cd:constant type="etire"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-it.xml b/Master/texmf-dist/tex/context/interface/cont-it.xml index d9fe0ac97d3..32d19e87f5e 100644 --- a/Master/texmf-dist/tex/context/interface/cont-it.xml +++ b/Master/texmf-dist/tex/context/interface/cont-it.xml @@ -7188,6 +7188,7 @@ <cd:constant type="tollerante"/> <cd:constant type="moltotollerante"/> <cd:constant type="dilata"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-nl.xml b/Master/texmf-dist/tex/context/interface/cont-nl.xml index 4bfad379829..6c49baccda6 100644 --- a/Master/texmf-dist/tex/context/interface/cont-nl.xml +++ b/Master/texmf-dist/tex/context/interface/cont-nl.xml @@ -7188,6 +7188,7 @@ <cd:constant type="soepel"/> <cd:constant type="zeersoepel"/> <cd:constant type="rek"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-pe.xml b/Master/texmf-dist/tex/context/interface/cont-pe.xml index 434a328e82b..bf7d65fd045 100644 --- a/Master/texmf-dist/tex/context/interface/cont-pe.xml +++ b/Master/texmf-dist/tex/context/interface/cont-pe.xml @@ -7188,6 +7188,7 @@ <cd:constant type="بردبار"/> <cd:constant type="خیلیبردبار"/> <cd:constant type="بکش"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> diff --git a/Master/texmf-dist/tex/context/interface/cont-ro.xml b/Master/texmf-dist/tex/context/interface/cont-ro.xml index 31ef5d920bd..b81c3bc7e58 100644 --- a/Master/texmf-dist/tex/context/interface/cont-ro.xml +++ b/Master/texmf-dist/tex/context/interface/cont-ro.xml @@ -7188,6 +7188,7 @@ <cd:constant type="tolerant"/> <cd:constant type="foartetolerant"/> <cd:constant type="dilatat"/> + <cd:constant type="extremestretch"/> <cd:constant type="lefttoright"/> <cd:constant type="righttoleft"/> </cd:keywords> |