diff options
-rw-r--r-- | tex/context/base/back-exp.lua | 95 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4384 -> 4394 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/lpdf-tag.lua | 13 | ||||
-rw-r--r-- | tex/context/base/mult-def.mkiv | 4 | ||||
-rw-r--r-- | tex/context/base/publ-aut.lua | 68 | ||||
-rw-r--r-- | tex/context/base/publ-ini.lua | 109 | ||||
-rw-r--r-- | tex/context/base/publ-ini.mkiv | 67 | ||||
-rw-r--r-- | tex/context/base/spac-ver.lua | 30 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24725 -> 24724 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 333473 -> 333416 bytes | |||
-rw-r--r-- | tex/context/base/strc-tag.lua | 49 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
14 files changed, 277 insertions, 164 deletions
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 5c8a994d6..950b9dc8c 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -163,8 +163,9 @@ local noftextblocks = 0 local attributehash = { } -- to be considered: set the values at the tex end local hyphencode = 0xAD local hyphen = utfchar(0xAD) -- todo: also emdash etc -local colonsplitter = lpeg.splitat(":") -local dashsplitter = lpeg.splitat("-") +local tagsplitter = structurestags.patterns.splitter +----- colonsplitter = lpeg.splitat(":") +----- dashsplitter = lpeg.splitat("-") local threshold = 65536 local indexing = false local keephyphens = false @@ -296,15 +297,6 @@ local function attribute(key,value) end end --- local P, C, Cc = lpeg.P, lpeg.C, lpeg.Cc --- --- local dash, colon = P("-"), P(":") --- --- local precolon, predash, rest = P((1-colon)^1), P((1-dash )^1), P(1)^1 --- --- local tagsplitter = C(precolon) * colon * C(predash) * dash * C(rest) + --- C(predash) * dash * Cc(nil) * C(rest) - local listdata = { } -- maybe do this otherwise function wrapups.hashlistdata() @@ -1589,13 +1581,7 @@ do local registered = structures.sections.registered local f_level = formatters[' level="%s"'] - local function section(result,element,detail,n,fulltag,di) - - local r = registered[detail] - if r then - result[#result+1] = f_level(r.level) - end - + local function resolve(result,element,detail,n,fulltag,di) local data = listdata[fulltag] if data then extras.addreference(result,data.references) @@ -1607,7 +1593,7 @@ do local di = data[i] if di then local ft = di.fulltag - if ft and section(result,element,detail,n,ft,di) then + if ft and resolve(result,element,detail,n,ft,di) then return true end end @@ -1616,26 +1602,16 @@ do end end - extras.section = section - - function extras.float(result,element,detail,n,fulltag,di) - local data = listdata[fulltag] - if data then - extras.addreference(result,data.references) - return true - else - local data = di.data - if data then - for i=1,#data do - local di = data[i] - if di and section(result,element,detail,n,di.fulltag,di) then - return true - end - end - end + function extras.section(result,element,detail,n,fulltag,di) + local r = registered[detail] + if r then + result[#result+1] = f_level(r.level) end + resolve(result,element,detail,n,fulltag,di) end + extras.float = resolve + -- todo: internal is already hashed function structurestags.setlist(tag,n) @@ -1892,7 +1868,8 @@ do local r = { } -- delay this if detail then n = n + 1 - r[n] = f_detail(detail) + -- r[n] = f_detail(detail) + r[n] = f_detail(gsub(detail,"[^A-Za-z0-9]+","-")) end if indexing and index then n = n + 1 @@ -2270,11 +2247,13 @@ end -- collector code local function push(fulltag,depth) - local tag, n = lpegmatch(dashsplitter,fulltag) - local tg, detail = lpegmatch(colonsplitter,tag) + -- local tag, n = lpegmatch(dashsplitter,fulltag) + -- local tg, detail = lpegmatch(colonsplitter,tag) + local tg, detail, n = lpegmatch(tagsplitter,fulltag) local element, nature if detail then - local pd = properties[tag] + -- local pd = properties[tag] -- does this really happen? element-detail + local pd = properties[tg.."<"..detail] local pt = properties[tg] element = pd and pd.export or pt and pt.export or tg nature = pd and pd.nature or pt and pt.nature or defaultnature @@ -2471,8 +2450,7 @@ local function collectresults(head,list,pat,pap) -- is last used (we also have c for n in traverse_nodes(head) do local id = getid(n) -- 14: image, 8: literal (mp) if id == glyph_code then - local at = getattr(n,a_tagged) -or pat + local at = getattr(n,a_tagged) or pat if not at then -- we need to tag the pagebody stuff as being valid skippable -- @@ -2488,8 +2466,7 @@ or pat local tl = taglist[at] pushcontent() currentnesting = tl - currentparagraph = getattr(n,a_taggedpar) -or pap + currentparagraph = getattr(n,a_taggedpar) or pap currentattribute = at last = at pushentry(currentnesting) @@ -2507,8 +2484,7 @@ or pap -- we can consider tagging the pars (lines) in the parbuilder but then we loose some -- information unless we inject a special node (but even then we can run into nesting -- issues) - local ap = getattr(n,a_taggedpar) -or pap + local ap = getattr(n,a_taggedpar) or pap if ap ~= currentparagraph then pushcontent(currentparagraph,ap) pushentry(currentnesting) @@ -2589,8 +2565,7 @@ or pap if ca == 0 then -- skip this one ... already converted special character (node-acc) elseif ca then - local a = getattr(n,a_tagged) -or pat + local a = getattr(n,a_tagged) or pat if a then local c = specialspaces[ca] if last ~= a then @@ -2600,15 +2575,13 @@ or pat end pushcontent() currentnesting = tl - currentparagraph = getattr(n,a_taggedpar) -or pap + currentparagraph = getattr(n,a_taggedpar) or pap currentattribute = a last = a pushentry(currentnesting) -- no reference check (see above) elseif last then - local ap = getattr(n,a_taggedpar) -or pap + local ap = getattr(n,a_taggedpar) or pap if ap ~= currentparagraph then pushcontent(currentparagraph,ap) pushentry(currentnesting) @@ -2634,8 +2607,7 @@ or pap local spec = getfield(n,"spec") if getfield(spec,"width") > threshold then if last and not somespace[currentcontent[nofcurrentcontent]] then - local a = getattr(n,a_tagged) -or pat + local a = getattr(n,a_tagged) or pat if a == last then if trace_export then report_export("%w<!-- injecting spacing 5a -->",currentdepth) @@ -2662,8 +2634,7 @@ or pat end elseif subtype == spaceskip_code or subtype == xspaceskip_code then if not somespace[currentcontent[nofcurrentcontent]] then - local a = getattr(n,a_tagged) -or pat + local a = getattr(n,a_tagged) or pat if a == last then if trace_export then report_export("%w<!-- injecting spacing 7 (stay in element) -->",currentdepth) @@ -2692,8 +2663,7 @@ or pat nofcurrentcontent = nofcurrentcontent - 1 end elseif not somespace[r] then - local a = getattr(n,a_tagged) -or pat + local a = getattr(n,a_tagged) or pat if a == last then if trace_export then report_export("%w<!-- injecting spacing 1 (end of line, stay in element) -->",currentdepth) @@ -2723,8 +2693,7 @@ or pat elseif id == hlist_code or id == vlist_code then local ai = getattr(n,a_image) if ai then - local at = getattr(n,a_tagged) -or pat + local at = getattr(n,a_tagged) or pat if nofcurrentcontent > 0 then pushcontent() pushentry(currentnesting) -- ?? @@ -2739,8 +2708,7 @@ or pat -- we need to determine an end-of-line local list = getlist(n) if list then -local at = getattr(n,a_tagged) -or pat + local at = getattr(n,a_tagged) or pat collectresults(list,n,at) end end @@ -2753,8 +2721,7 @@ or pat end if kern > limit then if last and not somespace[currentcontent[nofcurrentcontent]] then - local a = getattr(n,a_tagged) -or pat + local a = getattr(n,a_tagged) or pat if a == last then if not somespace[currentcontent[nofcurrentcontent]] then if trace_export then diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index d6f5c73e2..d6088c3e9 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2014.10.21 10:09} +\newcontextversion{2014.10.22 13:59} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 1cef09675..63e011c3a 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 9ee9bc90f..b98e3b123 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2014.10.21 10:09} +\edef\contextversion{2014.10.22 13:59} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/lpdf-tag.lua b/tex/context/base/lpdf-tag.lua index 77c5776e2..678a57edd 100644 --- a/tex/context/base/lpdf-tag.lua +++ b/tex/context/base/lpdf-tag.lua @@ -90,8 +90,9 @@ local lasttaginchain = structurestags.lastinchain local usedmapping = { } -local colonsplitter = lpeg.splitat(":") -local dashsplitter = lpeg.splitat("-") +local tagsplitter = structurestags.patterns.splitter +----- colonsplitter = lpeg.splitat(":") +----- dashsplitter = lpeg.splitat("-") local add_ids = false -- true @@ -192,8 +193,9 @@ local function makeattribute(t) end local function makeelement(fulltag,parent,attr) - local tag, n = lpegmatch(dashsplitter,fulltag) - local tg, detail = lpegmatch(colonsplitter,tag) + local tg, detail, n = lpegmatch(tagsplitter,fulltag) + -- local tag, n = lpegmatch(dashsplitter,fulltag) + -- local tg, detail = lpegmatch(colonsplitter,tag) if tg == "ignore" then return false elseif tg == "mstackertop" or tg == "mstackerbot" or tg == "mstackermid"then @@ -226,7 +228,8 @@ local function makeelement(fulltag,parent,attr) end local kids = parent.kids kids[#kids+1] = s - local e = { tag = tag, pref = s, kids = k, knum = r, pnum = pagenum } +-- local e = { tag = tag, pref = s, kids = k, knum = r, pnum = pagenum } + local e = { tag = detail and (tg .. "<" .. detail) or tg, pref = s, kids = k, knum = r, pnum = pagenum } elements[fulltag] = e return e end diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv index 51173d09f..4693513b0 100644 --- a/tex/context/base/mult-def.mkiv +++ b/tex/context/base/mult-def.mkiv @@ -100,6 +100,10 @@ \def\v!long {long} \def\v!box {box} +\def\v!noline {noline} +\def\v!noheight {noheight} +\def\v!nodepth {nodepth} + \def\v!bookmark {bookmark} \def\v!vfenced {vfenced} diff --git a/tex/context/base/publ-aut.lua b/tex/context/base/publ-aut.lua index fdd17f34b..a14176b24 100644 --- a/tex/context/base/publ-aut.lua +++ b/tex/context/base/publ-aut.lua @@ -16,7 +16,7 @@ local lpeg = lpeg local context = context local chardata = characters.data -local tostring = tostring +local type, next, tostring = type, next, tostring local concat = table.concat local utfchar = utf.char local formatters = string.formatters @@ -404,6 +404,9 @@ local function writer(key,snippets) if not key then return "" end + if type(key) == "string" then + return key + end local n = #key if n == 0 then return "" @@ -443,6 +446,28 @@ local function newsplitter(splitter) end) end + +-- First sorting key: +-- A. key= if present takes precedence +-- B. author= if present takes second precedence (when key= is absent) +-- C. editor= if present takes third precedence (when key= and author= are absent) +-- D. publisher= if present (in absence of key=, author= and editor=) +-- E. title= if present (but only in absence of key=, author=, editor= and publisher=) +-- F. journal= if present +-- G. volume= if present +-- H. number= if present +-- I. pages= if present +-- K. if all else fails, ? (APA specifies using "Anonymous" ONLY when specifically listed as such in the publication!) + +-- Second sorting key: +-- A. year= if present, takes precedence, otherwise treat "n.d." as most recent. +-- B. suffix (same first key and same year) +-- What about "n.d."? Here, it would be reasonable to second sort by +-- title= (lower precedence than the first key above) +-- C. month= +-- D. day= +-- E. journal=, followed by volume=, followed by number= + local function byauthor(dataset,list,method) local luadata = datasets[dataset].luadata local details = datasets[dataset].details @@ -455,30 +480,43 @@ local function byauthor(dataset,list,method) local tag = type(li) == "string" and li or li[1] local entry = luadata[tag] local detail = details[tag] + local index = tostring(i) if entry and detail then + local mainkey = writer(detail.author or detail.editor or entry.publisher or entry.title or "",snippets) + -- we could store the mainkey in details for tracing result[i] = { index = i, split = { - splitted[strip(writer(detail.author or detail.editor or "",snippets))], - splitted[entry.year or "9998"], - splitted[detail.suffix or " "], - splitted[strip(entry.journal or "")], - splitted[strip(entry.title or "")], - splitted[entry.pages or ""], - splitted[tostring(i)], + splitted[entry.key or "" ], + splitted[strip(mainkey) ], + splitted[entry.year or "9998"], + splitted[detail.suffix or " " ], + splitted[entry.month or "13" ], + splitted[entry.day or "32" ], + splitted[strip(entry.journal or "" )], + splitted[strip(entry.volume or "" )], + splitted[strip(entry.number or "" )], + splitted[strip(entry.title or "" )], + splitted[entry.pages or "" ], + splitted[index], }, } else result[i] = { index = i, split = { - splitted[""], - splitted["9999"], - splitted[" "], - splitted[""], - splitted[""], - splitted[""], - splitted[tostring(i)], + splitted[""], -- key + splitted[""], -- mainkey + splitted["9999"], -- year + splitted[" "], -- suffix + splitted["14"], -- month + splitted["33"], -- day + splitted[""], -- journal + splitted[""], -- volume + splitted[""], -- number + splitted[""], -- title + splitted[""], -- pages + splitted[index], -- index }, } end diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 82510960f..2f6bb5dca 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -1469,47 +1469,53 @@ function lists.flushentries(dataset,textmode) end end -function lists.flushentry(specification) - local tag = specification.reference - if not tag or tag == "" then - return - end - -- - local dataset = specification.dataset or "" -- standard - -- local mark = specification.markentry ~= false - -- local internal = specification.internal or "" - -- - local prefix, rest = lpegmatch(prefixsplitter,tag) - if rest then - dataset = prefix - else - rest = tag - end - -- - -- if trace_cite then - -- report_cite("mark, dataset: %s, tags: %s",dataset or "-",rest) - -- end - -- - local reference = publications.parenttag(dataset,rest) - local found, todo, list = findallused(dataset,reference,internal) - local valid = { } - if list and #list > 0 then - local luadata = datasets[dataset].luadata - for i=1,#list do - local tag = list[i] - if luadata[tag] then - valid[#valid+1] = { tag, 0, 0 } -- datasets[dataset].details.number - end - end - end - if #valid > 0 then - local rendering = renderings[dataset] - rendering.list = valid - lists.flushentries(dataset,true) - else - ctx_btxmissing(tag) - end -end +-- function lists.flushentry(specification) +-- local tag = specification.reference +-- if not tag or tag == "" then +-- return +-- end +-- -- +-- local dataset = specification.dataset or "" -- standard +-- -- local mark = specification.markentry ~= false +-- -- local internal = specification.internal or "" +-- -- +-- local prefix, rest = lpegmatch(prefixsplitter,tag) +-- if rest then +-- dataset = prefix +-- else +-- rest = tag +-- end +-- -- +-- -- if trace_cite then +-- -- report_cite("mark, dataset: %s, tags: %s",dataset or "-",rest) +-- -- end +-- -- +-- local reference = publications.parenttag(dataset,rest) +-- local found, todo, list = findallused(dataset,reference,internal) +-- local valid = { } +-- if list and #list > 0 then +-- local luadata = datasets[dataset].luadata +-- for i=1,#list do +-- local tag = list[i] +-- if luadata[tag] then +-- valid[#valid+1] = { tag, 0, 0 } -- datasets[dataset].details.number +-- end +-- end +-- end +-- if #valid > 0 then +-- local rendering = renderings[dataset] +-- rendering.list = valid +-- lists.flushentries(dataset,true) +-- else +-- ctx_btxmissing(tag) +-- end +-- local mark = true +-- tobemarked = mark and todo +-- if found and tobemarked then +-- flushmarked(dataset,list) +-- commands.flushmarked() -- here (could also be done in caller) +-- end +-- end local function getuserdata(dataset,key) local rendering = renderings[dataset] @@ -1863,6 +1869,27 @@ function citevariants.default(dataset,reference,mark,compress,variant,internal) processcite(dataset,reference,mark,compress,variant,internal,setters[variant],getters[variant]) end +-- entry + +do + + local function setter(dataset,tag,entry,internal) + return { + tag = tag, + internal = internal, + } + end + + local function getter(first,last) -- last not used + ctx_btxsetfirst(first.tag) + end + + function citevariants.entry(dataset,reference,mark,compress,variant,internal) + processcite(dataset,reference,mark,false,"entry",internal,setter,getter) + end + +end + -- short do diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index a58ea8eac..c4137ea6b 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -1148,36 +1148,57 @@ %D In-text entries: -\unexpanded\def\placecitation - {\dodoubleempty\publ_place_citation} +% \unexpanded\def\placecitation +% {\dodoubleempty\publ_place_citation} +% +% \unexpanded\def\publ_place_citation +% {\ifsecondargument +% \expandafter\publ_place_citation_two +% \else\iffirstargument +% \doubleexpandafter\publ_place_citation_one +% \else +% \doubleexpandafter\publ_place_citation_zero +% \fi\fi} +% +% \unexpanded\def\publ_place_citation_one[#1][#2]% +% {\publ_place_citation_two[\currentbtxrendering][#1]} +% +% \unexpanded\def\publ_place_citation_two[#1][#2]% +% {\dontleavehmode +% \begingroup +% \startbtxrendering[#1]% +% \btx_set_rendering_alternative +% \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% +% \uselanguageparameter\btxdatasetparameter % new +% \ctxcommand{btxflushlistentry{ dataset = "\currentbtxdataset", reference = \!!bs#2\!!es }}% +% \btxcitereference % we need a proper setup +% \stopbtxrendering +% \endgroup} +% +% \unexpanded\def\publ_place_citation_zero[#1][#2]% +% {\btxmissing{??}} +% +% \let\btxhandlelisttextentry\btx_entry_inject -\unexpanded\def\publ_place_citation - {\ifsecondargument - \expandafter\publ_place_citation_two - \else\iffirstargument - \doubleexpandafter\publ_place_citation_one - \else - \doubleexpandafter\publ_place_citation_zero - \fi\fi} +\unexpanded\def\placecitation{\citation[entry]} % [#1] -\unexpanded\def\publ_place_citation_one[#1][#2]% - {\publ_place_citation_two[\currentbtxrendering][#1]} -\unexpanded\def\publ_place_citation_two[#1][#2]% +\unexpanded\def\btxhandleciteentry {\dontleavehmode \begingroup - \startbtxrendering[#1]% - \btx_set_rendering_alternative - \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% - \uselanguageparameter\btxdatasetparameter % new - \ctxcommand{btxflushlistentry{ dataset = "\currentbtxdataset", reference = \!!bs#2\!!es }}% - \stopbtxrendering + %\edef\currentbtxalternative{apa}% \btxlistvariantparameter\c!alternative}% + \btx_set_rendering_alternative + \btxcitereference + \btx_entry_inject \endgroup} -\unexpanded\def\publ_place_citation_zero[#1][#2]% - {\btxmissing{??}} - -\let\btxhandlelisttextentry\btx_entry_inject +\startsetups \s!btx:\s!cite:entry + \ifx\currentbtxfirst\empty + \fastsetup{\s!btx:\s!cite:\s!unknown} + \else + \btxhandleciteentry + \fi +\stopsetups %D Registers diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index 52c1e4845..b21f90beb 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -332,11 +332,19 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is t[#t+1] = formatters["auto: snapht %p snapdp %p"](snapht,snapdp) end end - local h = height or getfield(current,"height") - local d = depth or getfield(current,"depth") - local hr, dr, ch, cd, br = method.hfraction or 1, method.dfraction or 1, h, d, method.bfraction or 0 - local tlines, blines = method.tlines or 1, method.blines or 1 - local done, plusht, plusdp = false, snapht, snapdp + + local h = (method.noheight and 0) or height or getfield(current,"height") + local d = (method.nodepth and 0) or depth or getfield(current,"depth") + local hr = method.hfraction or 1 + local dr = method.dfraction or 1 + local br = method.bfraction or 0 + local ch = h + local cd = d + local tlines = method.tlines or 1 + local blines = method.blines or 1 + local done = false + local plusht = snapht + local plusdp = snapdp local snaphtdp = snapht + snapdp if method.box then @@ -367,13 +375,15 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is end end if method.halfline then -- extra halfline - plusht, plusdp = plusht + snaphtdp/2, plusdp + snaphtdp/2 + plusht = plusht + snaphtdp/2 + plusdp = plusdp + snaphtdp/2 if t then t[#t+1] = formatters["halfline: plusht %p plusdp %p"](plusht,plusdp) end end if method.line then -- extra line - plusht, plusdp = plusht + snaphtdp, plusdp + snaphtdp + plusht = plusht + snaphtdp + plusdp = plusdp + snaphtdp if t then t[#t+1] = formatters["line: plusht %p plusdp %p"](plusht,plusdp) end @@ -535,6 +545,12 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is t[#t+1] = formatters["final height: %p -> %p"](h,ch) t[#t+1] = formatters["final depth: %p -> %p"](d,cd) end +-- todo: +-- +-- if h < 0 or d < 0 then +-- h = 0 +-- d = 0 +-- end if t then report_snapper("trace: %s type %s\n\t%\n\tt",where,nodecodes[getid(current)],t) end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 4ba540ee0..ba3367114 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 2258b43f0..fc5109686 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua index 0cb00ec51..659c20d34 100644 --- a/tex/context/base/strc-tag.lua +++ b/tex/context/base/strc-tag.lua @@ -11,10 +11,11 @@ if not modules then modules = { } end modules ['strc-tag'] = { local type = type local insert, remove, unpack, concat = table.insert, table.remove, table.unpack, table.concat local gsub, find, topattern, format = string.gsub, string.find, string.topattern, string.format -local lpegmatch, P, S, C = lpeg.match, lpeg.P, lpeg.S, lpeg.C +local lpegmatch, P, S, C, Cc = lpeg.match, lpeg.P, lpeg.S, lpeg.C, lpeg.Cc local texattribute = tex.attribute local allocate = utilities.storage.allocate local settings_to_hash = utilities.parsers.settings_to_hash +local setmetatableindex = table.setmetatableindex local trace_tags = false trackers.register("structures.tags", function(v) trace_tags = v end) @@ -38,14 +39,27 @@ local enabled = false local tagdata = { } -- used in export local tagmetadata = { } -- used in export local tagcontext = { } +local tagpatterns = { } local tags = structures.tags tags.taglist = taglist -- can best be hidden tags.labels = labels tags.data = tagdata tags.metadata = tagmetadata +tags.patterns = tagpatterns tags.userproperties = userproperties -- used in backend +-- Tags are internally stored as: +-- +-- tag<detail>number> +-- tag<detail>number> + +local p_splitter = C((1-S("<>"))^1) + * ( P("<")^-1 * C((1-P(">"))^1) + Cc(false)) + * P(">") + * C(P(1)^1) +tagpatterns.splitter = p_splitter + local properties = allocate { document = { pdf = "Div", nature = "display" }, @@ -185,6 +199,22 @@ local properties = allocate { combinationcaption = { pdf = "Span", nature = "mixed" }, } +local patterns_nop = setmetatableindex(function(t,tag) + local v = "^" .. tag .. ">" + t[tag] = v + return v +end) + +local patterns_yes = setmetatableindex(function(t,tag) + local v = setmetatableindex(function(t,detail) + local v = "^" .. tag .. "<" .. detail .. ">" + t[detail] = v + return v + end) + t[tag] = v + return v +end) + function tags.detailedtag(tag,detail,attribute) if not attribute then attribute = texattribute[a_tagged] @@ -194,9 +224,13 @@ function tags.detailedtag(tag,detail,attribute) if tl then local pattern if detail and detail ~= "" then - pattern = "^" .. tag .. ":".. detail .. "%-" + -- pattern = "^" .. tag .. ":" .. detail .. "%-" + -- pattern = "^" .. tag .. "<" .. detail .. ">" + pattern = patterns_yes[tag][detail] else - pattern = "^" .. tag .. "%-" + -- pattern = "^" .. tag .. "%-" + -- pattern = "^" .. tag .. ">" + pattern = patterns_nop[tag] end for i=#tl,1,-1 do local tli = tl[i] @@ -281,14 +315,16 @@ function tags.start(tag,specification,props) local fulltag = label ~= "" and label or tag labels[tag] = fulltag if detail and detail ~= "" then - fulltag = fulltag .. ":" .. detail + -- fulltag = fulltag .. ":" .. detail + fulltag = fulltag .. "<" .. detail end -- local t = #taglist + 1 local n = (ids[fulltag] or 0) + 1 ids[fulltag] = n lasttags[tag] = n - local completetag = fulltag .. "-" .. n +-- local completetag = fulltag .. "-" .. n + local completetag = fulltag .. ">" .. n nstack = nstack + 1 chain[nstack] = completetag stack[nstack] = t @@ -369,7 +405,8 @@ end function tags.getid(tag,detail) if detail and detail ~= "" then - return ids[tag .. ":" .. detail] or "?" + -- return ids[tag .. ":" .. detail] or "?" + return ids[tag .. "<" .. detail] or "?" else return ids[tag] or "?" end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 5809d2cbb..8e4d17de1 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 10/21/14 10:09:02 +-- merge date : 10/22/14 13:59:38 do -- begin closure to overcome local limits and interference |