From b859917cf85177a96d3f0226f13618fe1593eb06 Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 22 Oct 2010 12:00:11 +0300 Subject: beta 2010.10.22 10:10 --- tex/context/base/cont-new.tex | 2 +- tex/context/base/context.tex | 2 +- tex/context/base/strc-reg.lua | 128 ++++++++++++++++------------ tex/context/base/strc-reg.mkiv | 2 +- tex/generic/context/luatex-fonts-merged.lua | 2 +- 5 files changed, 79 insertions(+), 57 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 117d1c356..c56403015 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.10.21 23:27} +\newcontextversion{2010.10.22 10:10} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 0301243fe..ffa707bd2 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.10.21 23:27} +\edef\contextversion{2010.10.22 10:10} %D For those who want to use this: diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua index 96b45022f..abab0959a 100644 --- a/tex/context/base/strc-reg.lua +++ b/tex/context/base/strc-reg.lua @@ -348,38 +348,53 @@ end local seeindex = 0 -local function crosslinkseewords(result) - -- hash words (potential see destinations) - local words = { } +-- meerdere loops, seewords, dan words, an seewords + +local function crosslinkseewords(result) -- all words + -- collect all seewords + local seewords = { } + for i=1,#result do + local data = result[i] + local seeword = data.seeword + if seeword then + local seetext = seeword.text + if seetext and not seewords[seetext] then + seeindex = seeindex + 1 + seewords[seetext] = seeindex + if trace_registers then + report_registers("see word %03i: %s",seeindex,seetext) + end + end + end + end + -- mark seeparents + local seeparents = { } for i=1,#result do local data = result[i] local word = data.list[1] word = word and word[1] if word then - words[word] = data - else - -- can't happen + local seeindex = seewords[word] + if seeindex then + seeparents[word] = data + data.references.seeparent = seeindex + if trace_registers then + report_registers("see parent %03i: %s",seeindex,word) + end + end end end - -- link seewords to words and tag destination + -- mark seewords and extend sort list for i=1,#result do local data = result[i] local seeword = data.seeword if seeword then local text = seeword.text if text then - local word = words[text] - if word then - local wr = word.references -- the referred word - local dr = data.references -- the see word - if wr.seeparent then - dr.seeindex = wr.seeparent - else - seeindex = seeindex + 1 - wr.seeparent = seeindex - dr.seeindex = seeindex - end - local s, d, w, l = { }, data.split, word.split, data.list + local seeparent = seeparents[text] + if seeparent then + local seeindex = seewords[text] + local s, d, w, l = { }, data.split, seeparent.split, data.list -- trick: we influence sorting by adding fake subentries for i=1,#d do s[#s+1] = d[i] -- parent @@ -391,6 +406,10 @@ local function crosslinkseewords(result) -- we also register a fake extra list entry so that the -- collapser works okay l[#l+1] = { text, "" } + data.references.seeindex = seeindex + if trace_registers then + report_registers("see crosslink %03i: %s",seeindex,text) + end end end end @@ -645,6 +664,13 @@ function registers.flush(data,options,prefixspec,pagespec) local data = sublist.data local d, n = 0, 0 context.startregistersection(sublist.tag) + for d=1,#data do + local entry = data[d] + if entry.metadata.kind == "see" then + local list = entry.list + list[#list] = nil + end + end while d < #data do d = d + 1 local entry = data[d] @@ -652,10 +678,6 @@ function registers.flush(data,options,prefixspec,pagespec) local metadata = entry.metadata local kind = metadata.kind local list = entry.list - if kind == "see" then - -- remove fake entry - list[#list] = nil - end for i=1,4 do -- max 4 if list[i] then e[i] = list[i][1] @@ -681,7 +703,7 @@ function registers.flush(data,options,prefixspec,pagespec) local processor = entry.processors and entry.processors[1] or "" if metadata then context.registerentry(processor,internal,seeparent,function() helpers.title(e[i],metadata) end) - else + else -- ? context.registerentry(processor,internal,seeindex,e[i]) end else @@ -698,22 +720,27 @@ function registers.flush(data,options,prefixspec,pagespec) while dd < #data do dd = dd + 1 local next = data[dd] - local el, nl = entry.list, next.list - if not equal(el,nl) then + if next and next.metadata.kind == "see" then dd = dd - 1 - --~ first = nil break - elseif next.references.lastrealpage then - pages[#pages+1] = first and { first, last or first } or { entry, entry } - pages[#pages+1] = { next, next } - first, last, prev = nil, nil, nil - elseif not first then - first, prev = next, next - elseif next.references.realpage - prev.references.realpage == 1 then -- 1 ? - last, prev = next, next else - pages[#pages+1] = { first, last or first } - first, last, prev = next, nil, next + local el, nl = entry.list, next.list + if not equal(el,nl) then + dd = dd - 1 + --~ first = nil + break + elseif next.references.lastrealpage then + pages[#pages+1] = first and { first, last or first } or { entry, entry } + pages[#pages+1] = { next, next } + first, last, prev = nil, nil, nil + elseif not first then + first, prev = next, next + elseif next.references.realpage - prev.references.realpage == 1 then -- 1 ? + last, prev = next, next + else + pages[#pages+1] = { first, last or first } + first, last, prev = next, nil, next + end end end if first then @@ -755,7 +782,7 @@ function registers.flush(data,options,prefixspec,pagespec) else d = d + 1 local next = data[d] - if not equal(entry.list,next.list) then + if next.metadata.kind == "see" or not equal(entry.list,next.list) then d = d - 1 break else @@ -766,35 +793,30 @@ function registers.flush(data,options,prefixspec,pagespec) end context.stopregisterpages() elseif kind == 'see' then - local t, lasttext = { }, "" + local t = { } while true do - local text = entry.seeword.text or "" - if text ~= "" and lasttext ~= text then - t[#t+1] = { - seeindex = entry.references.seeindex or "", - seetext = text, - processor = entry.processors and entry.processors[1] or "", - } - lasttext = text - end + t[#t+1] = entry if d == #data then break else d = d + 1 local next = data[d] - if next and next.metadata.kind == "see" then - entry = next - else + if next.metadata.kind ~= "see" or not equal(entry.list,next.list) then d = d - 1 break + else + entry = next end end end context.startregisterseewords() local n = #t for i=1,n do - local ti = t[i] - context.registerseeword(i,n,ti.processor,0,ti.seeindex,ti.seetext) + local entry = t[i] + local processor = entry.processors and entry.processors[1] or "" + local seeindex = entry.references.seeindex or "" + local seeword = entry.seeword.text or "" + context.registerseeword(i,n,processor,0,seeindex,seeword) end context.stopregisterseewords() end diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv index 900a49e9c..e7c643f28 100644 --- a/tex/context/base/strc-reg.mkiv +++ b/tex/context/base/strc-reg.mkiv @@ -686,7 +686,7 @@ \endgroup} \unexpanded\def\startregisterseewords - {\par + {\ifhmode\crlf\fi \begingroup \setfalse\registerpagedone \dostarttagged\t!registerpage\empty diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 6bf864ec1..45d048876 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 10/21/10 23:27:14 +-- merge date : 10/22/10 10:10:20 do -- begin closure to overcome local limits and interference -- cgit v1.2.3