summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2014-03-24 00:52:00 +0100
committerHans Hagen <pragma@wxs.nl>2014-03-24 00:52:00 +0100
commit752a8cf2ff8a794c0a3b4f109f8568a897cc58fc (patch)
treec0010f2bdaa26cf0576491a04b2d6aeb1d5a0669
parentc70b2e466bbb07e976f8684d56ae4e5398169e7d (diff)
downloadcontext-752a8cf2ff8a794c0a3b4f109f8568a897cc58fc.tar.gz
beta 2014.03.24 00:52
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4082 -> 4077 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/font-ini.mkvi4
-rw-r--r--tex/context/base/lpdf-ano.lua426
-rw-r--r--tex/context/base/lpdf-fld.lua3
-rw-r--r--tex/context/base/lpdf-ini.lua10
-rw-r--r--tex/context/base/lpdf-mov.lua9
-rw-r--r--tex/context/base/lpdf-wid.lua7
-rw-r--r--tex/context/base/luat-run.lua2
-rw-r--r--tex/context/base/publ-ini.lua22
-rw-r--r--tex/context/base/status-files.pdfbin24618 -> 24645 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin241486 -> 241082 bytes
-rw-r--r--tex/context/base/strc-lst.lua21
-rw-r--r--tex/context/base/strc-ref.lua631
-rw-r--r--tex/context/base/strc-ref.mkvi4
-rw-r--r--tex/context/base/syst-aux.mkiv14
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
18 files changed, 584 insertions, 575 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index d764ff352..4a1c45b49 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.03.22 15:31}
+\newcontextversion{2014.03.24 00:52}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 4263371c0..80ab7a524 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index d5a722525..aade5078a 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.03.22 15:31}
+\edef\contextversion{2014.03.24 00:52}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi
index cc850b9af..c1e6d9390 100644
--- a/tex/context/base/font-ini.mkvi
+++ b/tex/context/base/font-ini.mkvi
@@ -2405,7 +2405,7 @@
% \ifmmode
% \scriptstyle
% \else
-% \let\fontface4%
+% \let\fontface\!!plusfour
% \let\fontalternative#alternative%
% \font_helpers_synchronize_font
% \fi
@@ -2416,7 +2416,7 @@
% \ifmmode
% \scriptscriptstyle
% \else
-% \let\fontface5%
+% \let\fontface\!!plusfive
% \let\fontalternative#alternative%
% \font_helpers_synchronize_font
% \fi
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 45b0e8e9c..3706ff983 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['lpdf-ano'] = {
-- todo: /AA << WC << ... >> >> : WillClose actions etc
--- internal references are indicated by a number (and turned into aut:<number>)
+-- internal references are indicated by a number (and turned into <autoprefix><number>)
-- we only flush internal destinations that are referred
local next, tostring, tonumber, rawget = next, tostring, tonumber, rawget
@@ -25,12 +25,15 @@ local trace_references = false trackers.register("references.references"
local trace_destinations = false trackers.register("references.destinations", function(v) trace_destinations = v end)
local trace_bookmarks = false trackers.register("references.bookmarks", function(v) trace_bookmarks = v end)
+local log_destinations = false directives.register("destinations.log", function(v) log_destinations = v end)
+
local report_reference = logs.reporter("backend","references")
local report_destination = logs.reporter("backend","destinations")
local report_bookmark = logs.reporter("backend","bookmarks")
local variables = interfaces.variables
-local constants = interfaces.constants
+local v_auto = variables.auto
+local v_page = variables.page
local factor = number.dimenfactors.bp
@@ -54,6 +57,7 @@ local bookmarks = structures.bookmarks
local flaginternals = references.flaginternals
local usedinternals = references.usedinternals
+local usedviews = references.usedviews
local runners = references.runners
local specials = references.specials
@@ -100,7 +104,46 @@ local pdf_t = pdfconstant("T")
local pdf_fit = pdfconstant("Fit")
local pdf_named = pdfconstant("Named")
-local pdf_border = pdfarray { 0, 0, 0 }
+local autoprefix = "#"
+
+-- Bah, I hate this kind of features .. anyway, as we have delayed resolving we
+-- only support a document-wide setup and it has to be set before the first one
+-- is used. Also, we default to a non-intrusive gray and the outline is kept
+-- thin without dashing lines. This is as far as I'm prepared to go. This way
+-- it can also be used as a debug feature.
+
+local pdf_border_style = pdfarray { 0, 0, 0 } -- radius radius linewidth
+local pdf_border_color = nil
+local set_border = false
+
+function pdfborder()
+ border_set = true
+ return pdf_border_style, pdf_border_color
+end
+
+lpdf.border = pdfborder
+
+directives.register("references.border",function(v)
+ if v and not set_border then
+ if type(v) == "string" then
+ local m = attributes.list[attributes.private('color')] or { }
+ local c = m and m[v]
+ local v = c and attributes.colors.value(c)
+ if v then
+ local r, g, b = v[3], v[4], v[5]
+ -- if r == g and g == b then
+ -- pdf_border_color = pdfarray { r } -- reduced, not not ... bugged viewers
+ -- else
+ pdf_border_color = pdfarray { r, g, b } -- always rgb
+ -- end
+ end
+ end
+ if not pdf_border_color then
+ pdf_border_color = pdfarray { .6, .6, .6 } -- no reduce to { 0.6 } as there are buggy viewers out there
+ end
+ pdf_border_style = pdfarray { 0, 0, .5 } -- < 0.5 is not show by acrobat (at least not in my version)
+ end
+end)
-- the used and flag code here is somewhat messy in the sense
-- that it belongs in strc-ref but at the same time depends on
@@ -109,8 +152,6 @@ local pdf_border = pdfarray { 0, 0, 0 }
-- the caching is somewhat memory intense on the one hand but
-- it saves many small temporary tables so it might pay off
-local destinationviews = { } -- prevent messages
-
local pagedestinations = allocate()
local pagereferences = allocate() -- annots are cached themselves
@@ -165,6 +206,29 @@ lpdf.registerdestination = pdfregisterdestination
local maxslice = 32 -- could be made configureable ... 64 is also ok
+luatex.registerstopactions(function()
+ if log_destinations and next(destinations) then
+ local logsnewline = logs.newline
+ local log_destinations = logs.reporter("system","references")
+ local log_destination = logs.reporter("destination")
+ logs.pushtarget("logfile")
+ logsnewline()
+ log_destinations("start used destinations")
+ logsnewline()
+ local n = 0
+ for destination, pagenumber in table.sortedhash(destinations) do
+ log_destination("% 4i : %-5s : %s",pagenumber,usedviews[destination] or defaultview,destination)
+ n = n + 1
+ end
+ logsnewline()
+ log_destinations("stop used destinations")
+ logsnewline()
+ logs.poptarget()
+ report_destination("%s destinations saved in log file",n)
+ end
+end)
+
+
local function pdfnametree(destinations)
local slices = { }
local sorted = table.sortedkeys(destinations)
@@ -179,8 +243,9 @@ local function pdfnametree(destinations)
local names = pdfarray { }
for j=i,amount do
local destination = sorted[j]
+ local pagenumber = destinations[destination]
names[#names+1] = destination
- names[#names+1] = pdfreference(destinations[destination])
+ names[#names+1] = pdfreference(pagenumber)
end
local first = sorted[i]
local last = sorted[amount]
@@ -236,9 +301,11 @@ end
local function pdfdestinationspecification()
if next(destinations) then -- safeguard
local r = pdfnametree(destinations)
--- pdfaddtocatalog("Dests",r)
+ -- pdfaddtocatalog("Dests",r)
pdfaddtonames("Dests",r)
- destinations = nil
+ if not log_destinations then
+ destinations = nil
+ end
end
end
@@ -258,56 +325,43 @@ local f_fith = formatters["<< /D [ %i 0 R /FitH %0.3F ] >>"]
local f_fitv = formatters["<< /D [ %i 0 R /FitV %0.3F ] >>"]
local f_fitbh = formatters["<< /D [ %i 0 R /FitBH %0.3F ] >>"]
local f_fitbv = formatters["<< /D [ %i 0 R /FitBV %0.3F ] >>"]
-local f_fitr = formatters["<< /D [ %i 0 R /FitR [%0.3F %0.3F %0.3F %0.3F ] ] >>"]
+local f_fitr = formatters["<< /D [ %i 0 R /FitR [ %0.3F %0.3F %0.3F %0.3F ] ] >>"]
--- nicer is to create dictionaries and set properties but overkill
---
--- local d_xyz = pdfdictionary {
--- D = pdfarray {
--- pdfreference(0),
--- pdfconstant("XYZ"),
--- 0,
--- 0,
--- pdfnull(),
--- }
--- }
---
--- local function xyz(r,width,height,depth) -- same
--- local llx, lly = pdfrectangle(width,height,depth)
--- d_xyz.D[1][1] = r
--- d_xyz.D[3] = llx
--- d_xyz.D[4] = lly
--- return d_xyz()
--- end
+local v_standard = variables.standard
+local v_frame = variables.frame
+local v_width = variables.width
+local v_minwidth = variables.minwidth
+local v_height = variables.height
+local v_minheight = variables.minheight
+local v_fit = variables.fit
+local v_tight = variables.tight
+
+-- nicer is to create dictionaries and set properties but it's a bit overkill
local destinationactions = {
- xyz = function(r,width,height,depth)
- local llx, lly = pdfrectangle(width,height,depth)
- return f_xyz(r,llx,lly)
- end,
- fitr = function(r,width,height,depth)
- return f_fitr(r,pdfrectangle(width,height,depth))
- end,
- fith = function(r) return f_fith (r,getvpos*factor) end,
- fitbh = function(r) return f_fitbh(r,getvpos*factor) end,
- fitv = function(r) return f_fitv (r,gethpos*factor) end,
- fitbv = function(r) return f_fitbv(r,gethpos*factor) end,
- fit = f_fit,
- fitb = f_fitb,
+ [v_standard] = function(r,w,h,d) return f_xyz (r,pdfrectangle(w,h,d)) end, -- local left,top with zoom (0 in our case)
+ [v_frame] = function(r,w,h,d) return f_fitr (r,pdfrectangle(w,h,d)) end, -- fit rectangle in window
+ [v_width] = function(r,w,h,d) return f_fith (r, gethpos() *factor) end, -- top coordinate, fit width of page in window
+ [v_minwidth] = function(r,w,h,d) return f_fitbh(r, gethpos() *factor) end, -- top coordinate, fit width of content in window
+ [v_height] = function(r,w,h,d) return f_fitv (r,(getvpos()+h)*factor) end, -- left coordinate, fit height of page in window
+ [v_minheight] = function(r,w,h,d) return f_fitbv(r,(getvpos()+h)*factor) end, -- left coordinate, fit height of content in window
+ [v_fit] = f_fit, -- fit page in window
+ [v_tight] = f_fitb, -- fit content in window
}
local mapping = {
- xyz = "xyz", [variables.standard] = "xyz",
- fitr = "fitr", [variables.frame] = "fitr",
- fith = "fith", [variables.width] = "fith",
- fitbh = "fitbh", [variables.minwidth] = "fitbh",
- fitv = "fitv", [variables.height] = "fitv",
- fitbv = "fitbv", [variables.minheight] = "fitbv",
- fit = "fit", [variables.fit] = "fit",
- fitb = "fitb",
+ [v_standard] = v_standard, xyz = v_standard,
+ [v_frame] = v_frame, fitr = v_frame,
+ [v_width] = v_width, fith = v_width,
+ [v_minwidth] = v_minwidth, fitbh = v_minwidth,
+ [v_height] = v_height, fitv = v_height,
+ [v_minheight] = v_minheight, fitbv = v_minheight,
+ [v_fit] = v_fit, fit = v_fit,
+ [v_tight] = v_tight, fitb = v_tight,
}
-local defaultaction = destinationactions.fit
+local defaultview = v_fit
+local defaultaction = destinationactions[defaultview]
-- A complication is that we need to use named destinations when we have views so we
-- end up with a mix. A previous versions just output multiple destinations but not
@@ -323,7 +377,7 @@ end)
local function flushdestination(width,height,depth,names,view)
local r = pdfpagereference(texgetcount("realpageno"))
- if view == "fit" then
+ if view == defaultview then
r = pagedestinations[r]
else
local action = view and destinationactions[view] or defaultaction
@@ -339,38 +393,40 @@ end
function nodeinjections.destination(width,height,depth,names,view)
-- todo check if begin end node / was comment
- if view then
- view = mapping[view] or "fit"
- else
- view = "fit"
- end
+ view = view and mapping[view] or defaultview
if trace_destinations then
report_destination("width %p, height %p, depth %p, names %|t, view %a",width,height,depth,names,view)
end
- local noview = view ~= "fit"
+ local method = references.innermethod
+ local noview = view == defaultview
local doview = false
+ -- we could save some aut's by using a name when given but it doesn't pay off apart
+ -- from making the code messy and tracing hard .. we only save some destinations
+ -- which we already share anyway
for n=1,#names do
local name = names[n]
- if not destinationviews[name] then
- destinationviews[name] = not noview
- if type(name) == "number" then
- local u = usedinternals[name]
- if u then
- if not noview then
- flaginternals[name] = view
- end
- if references.innermethod ~= "auto" or u ~= true then
- names[n] = "aut:" .. name
- doview = true
- else
- names[n] = false
- end
- else
- names[n] = false
- end
+ if usedviews[name] then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ if noview then
+ usedviews[name] = view
+ names[n] = false
+ elseif method == v_page then
+ usedviews[name] = view
+ names[n] = false
else
- doview = true
+ local used = usedinternals[name]
+ if used and used ~= defaultview then
+ usedviews[name] = view
+ names[n] = autoprefix .. name
+ doview = true
+ end
end
+ elseif method == v_page then
+ usedviews[name] = view
+ else
+ usedviews[name] = view
+ doview = true
end
end
if doview then
@@ -378,83 +434,84 @@ function nodeinjections.destination(width,height,depth,names,view)
end
end
-local function somedestination(destination,page)
- if type(destination) == "number" then
- flaginternals[destination] = true
- if references.innermethod == "auto" and usedinternals[destination] == true then
- return pagereferences[page]
- else
- return pdfdictionary { -- can be cached
+-- we could share dictionaries ... todo
+
+local function somedestination(destination,internal,page)
+ if references.innermethod ~= v_page then
+ if type(destination) == "number" then
+ if not internal then
+ internal = destination
+ end
+ destination = nil
+ end
+ if internal then
+ local used = usedinternals[internal]
+ if used == defaultview or used == true then
+ return pagereferences[page]
+ end
+ flaginternals[internal] = true -- to be sure
+ if type(destination) ~= "string" then
+ destination = autoprefix .. internal
+ end
+ return pdfdictionary {
S = pdf_goto,
- D = "aut:" .. destination,
+ D = destination,
}
- end
- else
- if references.innermethod == "auto" and destinationviews[destination] == true then
- return pagereferences[page] -- we use a simple one but the destination is there
- else
- return pdfdictionary { -- can be cached
+ elseif destination then
+ return pdfdictionary {
S = pdf_goto,
D = destination,
}
end
end
+ return pagereferences[page]
end
-- annotations
-local function pdflink(url,filename,destination,page,actions)
- if filename and filename ~= "" then
- if file.basename(filename) == tex.jobname then
- return false
- else
- filename = file.addsuffix(filename,"pdf")
- end
+local pdflink = somedestination
+
+local function pdffilelink(filename,destination,page,actions)
+ if not filename or filename == "" or file.basename(filename) == tex.jobname then
+ return false
end
- if url and url ~= "" then
- if filename and filename ~= "" then
- if destination and destination ~= "" then
- url = file.join(url,filename).."#"..destination
- else
- url = file.join(url,filename)
- end
- end
- return pdfdictionary {
- S = pdf_uri,
- URI = url,
- }
- elseif filename and filename ~= "" then
- -- no page ?
- if destination == "" then
- destination = nil
- end
- if not destination and page then
- destination = pdfarray { page - 1, pdf_fit }
- end
- return pdfdictionary {
- S = pdf_gotor, -- can also be pdf_launch
- F = filename,
- D = destination or defaultdestination, -- D is mandate
- NewWindow = (actions.newwindow and true) or nil,
- }
- elseif destination and destination ~= "" then
- return somedestination(destination,page)
+ filename = file.addsuffix(filename,"pdf")
+ if not destination or destination == "" then
+ destination = pdfarray { (page or 0) - 1, pdf_fit }
end
- return pagereferences[page] -- we use a simple one but the destination is there
+ return pdfdictionary {
+ S = pdf_gotor, -- can also be pdf_launch
+ F = filename,
+ D = destination or defaultdestination, -- D is mandate
+ NewWindow = actions.newwindow and true or nil,
+ }
+end
+
+local function pdfurllink(url,destination,page)
+ if not url or url == "" then
+ return false
+ end
+ if destination and destination ~= "" then
+ url = file.join(url,filename).."#"..destination
+ else
+ url = file.join(url,filename)
+ end
+ return pdfdictionary {
+ S = pdf_uri,
+ URI = url,
+ }
end
local function pdflaunch(program,parameters)
- if program and program ~= "" then
- local d = pdfdictionary {
- S = pdf_launch,
- F = program,
- D = ".",
- }
- if parameters and parameters ~= "" then
- d.P = parameters
- end
- return d
+ if not program or program == "" then
+ return false
end
+ return pdfdictionary {
+ S = pdf_launch,
+ F = program,
+ D = ".",
+ P = parameters ~= "" and parameters or nil
+ }
end
local function pdfjavascript(name,arguments)
@@ -467,10 +524,6 @@ local function pdfjavascript(name,arguments)
end
end
-lpdf.link = pdflink
-lpdf.launch = pdflaunch
-lpdf.javascript = pdfjavascript
-
local function pdfaction(actions)
local nofactions = #actions
if nofactions > 0 then
@@ -506,9 +559,11 @@ function codeinjections.prerollreference(actions) -- share can become option
if actions then
local main, n = pdfaction(actions)
if main then
- main = pdfdictionary {
+ local bs, bc = pdfborder()
+ main = pdfdictionary {
Subtype = pdf_link,
- Border = pdf_border,
+ Border = bs,
+ C = bc,
H = (not actions.highlight and pdf_n) or nil,
A = pdfshareobjectreference(main),
F = 4, -- print (mandate in pdf/a)
@@ -544,7 +599,7 @@ local nofused = 0
local nofspecial = 0
local share = true
-local f_annot = formatters["<< /Type /Annot %s /Rect [%0.3F %0.3F %0.3F %0.3F] >>"]
+local f_annot = formatters["<< /Type /Annot %s /Rect [ %0.3F %0.3F %0.3F %0.3F ] >>"]
directives.register("refences.sharelinks", function(v) share = v end)
@@ -630,8 +685,8 @@ end)
runners["inner"] = function(var,actions)
local internal = false
- local method = references.innermethod
- if method == "names" or method == "auto" then
+ local inner = nil
+ if references.innermethod == v_auto then
local vi = var.i
if vi then
local vir = vi.references
@@ -640,25 +695,25 @@ runners["inner"] = function(var,actions)
local reference = vir.reference
if reference and reference ~= "" then
var.inner = reference
- else
- internal = vir.internal
- if internal then
- var.inner = internal
- flaginternals[internal] = true
+ local prefix = var.p
+ if prefix and prefix ~= "" then
+ var.prefix = prefix
+ inner = prefix .. ":" .. reference
+ else
+ inner = reference
end
end
+ internal = vir.internal
+ if internal then
+-- var.inner = internal
+ flaginternals[internal] = true
+ end
end
end
else
var.inner = nil
end
- local prefix = var.p
- local inner = var.inner
- if not internal and inner and prefix and prefix ~= "" then
- -- no prefix with e.g. components
- inner = prefix .. ":" .. inner
- end
- return pdflink(nil,nil,inner,var.r,actions)
+ return pdflink(inner,internal,var.r)
end
runners["inner with arguments"] = function(var,actions)
@@ -668,12 +723,15 @@ end
runners["outer"] = function(var,actions)
local file, url = references.checkedfileorurl(var.outer,var.outer)
- return pdflink(url,file,var.arguments,nil,actions)
+ if file then
+ return pdffilelink(file,var.arguments,nil,actions)
+ elseif url then
+ return pdfurllink(url,var.arguments,nil,actions)
+ end
end
runners["outer with inner"] = function(var,actions)
- local file = references.checkedfile(var.outer) -- was var.f but fails ... why
- return pdflink(nil,file,var.inner,var.r,actions)
+ return pdffilelink(references.checkedfile(var.outer),var.inner,var.r,actions)
end
runners["special outer with operation"] = function(var,actions)
@@ -722,21 +780,7 @@ function specials.internal(var,actions) -- better resolve in strc-ref
report_reference("no internal reference %a",i)
else
flaginternals[i] = true
- local method = references.innermethod
- if method == "names" then
- -- named
- return pdflink(nil,nil,i,v.references.realpage,actions)
- elseif method == "auto" then
- -- named
- if usedinternals[i] == true then
- return pdflink(nil,nil,nil,v.references.realpage,actions)
- else
- return pdflink(nil,nil,i,v.references.realpage,actions)
- end
- else
- -- page
- return pdflink(nil,nil,nil,v.references.realpage,actions)
- end
+ return pdflink(nil,i,v.references.realpage)
end
end
@@ -749,8 +793,7 @@ local pages = references.pages
function specials.page(var,actions)
local file = var.f
if file then
- file = references.checkedfile(file)
- return pdflink(nil,file,nil,var.operation,actions)
+ return pdffilelink(references.checkedfile(file),nil,var.operation,actions)
else
local p = var.r
if not p then -- todo: call special from reference code
@@ -760,29 +803,24 @@ function specials.page(var,actions)
else
p = references.realpageofpage(tonumber(p))
end
- -- if p then
- -- var.r = p
- -- end
end
- return pdflink(nil,nil,nil,p or var.operation,actions)
+ return pdflink(nil,nil,p or var.operation)
end
end
function specials.realpage(var,actions)
local file = var.f
if file then
- file = references.checkedfile(file)
- return pdflink(nil,file,nil,var.operation,actions)
+ return pdffilelink(references.checkedfile(file),nil,var.operation,actions)
else
- return pdflink(nil,nil,nil,var.operation,actions)
+ return pdflink(nil,nil,var.operation)
end
end
function specials.userpage(var,actions)
local file = var.f
if file then
- file = references.checkedfile(file)
- return pdflink(nil,file,nil,var.operation,actions)
+ return pdffilelink(references.checkedfile(file),nil,var.operation,actions)
else
local p = var.r
if not p then -- todo: call special from reference code
@@ -794,7 +832,7 @@ function specials.userpage(var,actions)
-- var.r = p
-- end
end
- return pdflink(nil,nil,nil,p or var.operation,actions)
+ return pdflink(nil,nil,p or var.operation)
end
end
@@ -802,7 +840,7 @@ function specials.deltapage(var,actions)
local p = tonumber(var.operation)
if p then
p = references.checkedrealpage(p + texgetcount("realpageno"))
- return pdflink(nil,nil,nil,p,actions)
+ return pdflink(nil,nil,p)
end
end
@@ -842,18 +880,20 @@ function specials.order(var,actions) -- references.specials !
end
function specials.url(var,actions)
- local url = references.checkedurl(var.operation)
- return pdflink(url,nil,var.arguments,nil,actions)
+ return pdfurllink(references.checkedurl(var.operation),var.arguments,nil,actions)
end
function specials.file(var,actions)
- local file = references.checkedfile(var.operation)
- return pdflink(nil,file,var.arguments,nil,actions)
+ return pdffilelink(references.checkedfile(var.operation),var.arguments,nil,actions)
end
function specials.fileorurl(var,actions)
local file, url = references.checkedfileorurl(var.operation,var.operation)
- return pdflink(url,file,var.arguments,nil,actions)
+ if file then
+ return pdffilelink(file,var.arguments,nil,actions)
+ elseif url then
+ return pdfurllink(url,var.arguments,nil,actions)
+ end
end
function specials.program(var,content)
@@ -1011,7 +1051,7 @@ local function build(levels,start,parent,method)
Parent = parent,
Prev = prev and pdfreference(prev),
}
- entry.Dest = somedestination(reference.internal,reference.realpage)
+ entry.Dest = somedestination(reference.internal,reference.internal,reference.realpage)
if not first then first, last = child, child end
prev = child
last = prev
diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua
index fc5a11c43..414562ad5 100644
--- a/tex/context/base/lpdf-fld.lua
+++ b/tex/context/base/lpdf-fld.lua
@@ -619,9 +619,6 @@ local function todingbat(n)
end
end
--- local zero_bc = pdfarray { 0, 0, 0 }
--- local zero_bg = pdfarray { 1, 1, 1 }
-
local function fieldrendering(specification)
local bvalue = tonumber(specification.backgroundcolorvalue)
local fvalue = tonumber(specification.framecolorvalue)
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index 34825698c..c79f3bf62 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -61,12 +61,12 @@ if pdf.getpos then
pdfhasmatrix = pdf.hasmatrix
else
if pdf.h then
- function pdfgetpos () return pdf.h, pdf.v end
- function pdfgethpos() return pdf.h end
- function pdfgetvpos() return pdf.v end
+ pdfgetpos = function() return pdf.h, pdf.v end
+ pdfgethpos = function() return pdf.h end
+ pdfgetvpos = function() return pdf.v end
end
- function pdfhasmatrix() return false end
- function pdfgetmatrix() return 1, 0, 0, 1, 0, 0 end
+ pdfhasmatrix = function() return false end
+ pdfgetmatrix = function() return 1, 0, 0, 1, 0, 0 end
end
codeinjections.getpos = pdfgetpos lpdf.getpos = pdfgetpos
diff --git a/tex/context/base/lpdf-mov.lua b/tex/context/base/lpdf-mov.lua
index fd3e89722..87375e4ce 100644
--- a/tex/context/base/lpdf-mov.lua
+++ b/tex/context/base/lpdf-mov.lua
@@ -14,6 +14,7 @@ local nodeinjections = backends.pdf.nodeinjections
local pdfconstant = lpdf.constant
local pdfdictionary = lpdf.dictionary
local pdfarray = lpdf.array
+local pdfborder = lpdf.border
local write_node = node.write
function nodeinjections.insertmovie(specification)
@@ -30,9 +31,11 @@ function nodeinjections.insertmovie(specification)
ShowControls = (specification.controls and true) or false,
Mode = (specification["repeat"] and pdfconstant("Repeat")) or nil,
}
+ local bs, bc = pdfborder()
local action = pdfdictionary {
Subtype = pdfconstant("Movie"),
- Border = pdfarray { 0, 0, 0 },
+ Border = bs,
+ C = bc,
T = format("movie %s",specification.label),
Movie = moviedict,
A = controldict,
@@ -50,9 +53,11 @@ function nodeinjections.insertsound(specification)
local sounddict = pdfdictionary {
F = soundclip.filename
}
+ local bs, bc = pdfborder()
local action = pdfdictionary {
Subtype = pdfconstant("Movie"),
- Border = pdfarray { 0, 0, 0 },
+ Border = bs,
+ C = bc,
T = format("sound %s",specification.label),
Movie = sounddict,
A = controldict,
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index 39f2f690c..81ad58f52 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -50,6 +50,7 @@ local pdfreserveobject = lpdf.reserveobject
local pdfpagereference = lpdf.pagereference
local pdfshareobjectreference = lpdf.shareobjectreference
local pdfaction = lpdf.action
+local pdfborder = lpdf.border
local pdftransparencyvalue = lpdf.transparencyvalue
local pdfcolorvalues = lpdf.colorvalues
@@ -57,8 +58,6 @@ local pdfcolorvalues = lpdf.colorvalues
local hpack_node = node.hpack
local write_node = node.write -- test context(...) instead
-local pdf_border = pdfarray { 0, 0, 0 } -- can be shared
-
-- symbols
local presets = { } -- xforms
@@ -515,11 +514,13 @@ local function insertrenderingwindow(specification)
OP = 0,
AN = pdfreference(r),
}
+ local bs, bc = pdfborder()
local d = pdfdictionary {
Subtype = pdfconstant("Screen"),
P = pdfreference(pdfpagereference(page)),
A = a, -- needed in order to make the annotation clickable (i.e. don't bark)
- Border = pdf_border,
+ Border = bs,
+ C = bc,
AA = actions,
}
local width = specification.width or 0
diff --git a/tex/context/base/luat-run.lua b/tex/context/base/luat-run.lua
index ab4b3463c..607c3528a 100644
--- a/tex/context/base/luat-run.lua
+++ b/tex/context/base/luat-run.lua
@@ -178,7 +178,7 @@ local register = callbacks.register
local level = 0
local total = 0
local stack = { }
-local all = true
+local all = false
local function report_start(left,name)
if not left then
diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua
index 6bf6714da..e25c57e29 100644
--- a/tex/context/base/publ-ini.lua
+++ b/tex/context/base/publ-ini.lua
@@ -120,13 +120,17 @@ statistics.register("publications load time", function()
end)
luatex.registerstopactions(function()
- logspushtarget("logfile")
- logsnewline()
- report("start used btx commands")
- logsnewline()
+ local done = false
local undefined = csname_id("undefined*crap")
for name, dataset in sortedhash(datasets) do
for command, n in sortedhash(dataset.commands) do
+ if not done then
+ logspushtarget("logfile")
+ logsnewline()
+ report("start used btx commands")
+ logsnewline()
+ done = true
+ end
local c = csname_id(command)
if c and c ~= undefined then
report("%-20s %-20s % 5i %s",name,command,n,"known")
@@ -140,10 +144,12 @@ luatex.registerstopactions(function()
end
end
end
- logsnewline()
- report("stop used btxcommands")
- logsnewline()
- logspoptarget()
+ if done then
+ logsnewline()
+ report("stop used btx commands")
+ logsnewline()
+ logspoptarget()
+ end
end)
-- multipass, we need to sort because hashing is random per run and not per
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index ae1fb5fec..cfc733f8d 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index ba896a1f9..179e1f9ec 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index 6ad491be2..16160e273 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -132,10 +132,15 @@ end
local function finalizer()
local flaginternals = references.flaginternals
+ local usedviews = references.usedviews
for i=1,#tobesaved do
local r = tobesaved[i].references
- if r and flaginternals[r.internal] then
- r.used = true
+ if r then
+ local i = r.internal
+ local f = flaginternals[i]
+ if f then
+ r.used = usedviews[i] or true
+ end
end
end
end
@@ -151,11 +156,11 @@ end
-- we could use t (as hash key) in order to check for dup entries
-function lists.addto(t)
+function lists.addto(t) -- maybe more more here (saves parsing at the tex end)
local m = t.metadata
local u = t.userdata
if u and type(u) == "string" then
- t.userdata = helpers.touserdata(u) -- nicer at the tex end
+ t.userdata = helpers.touserdata(u)
end
local numberdata = t.numberdata
local group = numberdata and numberdata.group
@@ -170,6 +175,10 @@ function lists.addto(t)
numberdata.numbers = cached[groupindex].numberdata.numbers
end
end
+ local setcomponent = references.setcomponent
+ if setcomponent then
+ setcomponent(t) -- can be inlined
+ end
local r = t.references
local i = r and r.internal or 0 -- brrr
local p = pushed[i]
@@ -179,10 +188,6 @@ function lists.addto(t)
pushed[i] = p
r.listindex = p
end
- local setcomponent = references.setcomponent
- if setcomponent then
- setcomponent(t) -- might move to the tex end
- end
if group then
groupindices[name][group] = p
end
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 9cf8382be..4a7404e96 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -16,7 +16,7 @@ if not modules then modules = { } end modules ['strc-ref'] = {
local format, find, gmatch, match, strip = string.format, string.find, string.gmatch, string.match, string.strip
local floor = math.floor
-local rawget, tonumber = rawget, tonumber
+local rawget, tonumber, type = rawget, tonumber, type
local lpegmatch = lpeg.match
local insert, remove, copytable = table.insert, table.remove, table.copy
local formatters = string.formatters
@@ -44,7 +44,13 @@ local report_importing = logs.reporter("references","importing")
local report_empty = logs.reporter("references","empty")
local variables = interfaces.variables
-local constants = interfaces.constants
+local v_default = variables.default
+local v_url = variables.url
+local v_file = variables.file
+local v_unknown = variables.unknown
+local v_page = variables.page
+local v_auto = variables.auto
+
local context = context
local commands = commands
@@ -52,11 +58,6 @@ local texgetcount = tex.getcount
local texsetcount = tex.setcount
local texconditionals = tex.conditionals
-local v_default = variables.default
-local v_url = variables.url
-local v_file = variables.file
-local v_unknown = variables.unknown
-local v_yes = variables.yes
local productcomponent = resolvers.jobs.productcomponent
local justacomponent = resolvers.jobs.justacomponent
@@ -93,6 +94,7 @@ local tobereferred = allocate()
local referred = allocate()
local usedinternals = allocate()
local flaginternals = allocate()
+local usedviews = allocate()
references.derived = derived
references.specials = specials
@@ -107,6 +109,7 @@ references.tobereferred = tobereferred
references.referred = referred
references.usedinternals = usedinternals
references.flaginternals = flaginternals
+references.usedviews = usedviews
local splitreference = references.splitreference
local splitprefix = references.splitcomponent -- replaces: references.splitprefix
@@ -115,6 +118,22 @@ local componentsplitter = references.componentsplitter
local currentreference = nil
+local txtcatcodes = catcodes.numbers.txtcatcodes -- or just use "txtcatcodes"
+local context_delayed = context.delayed
+
+local ctx_pushcatcodes = context.pushcatcodes
+local ctx_popcatcodes = context.popcatcodes
+local ctx_dofinishsomereference = context.dofinishsomereference
+local ctx_dofromurldescription = context.dofromurldescription
+local ctx_dofromurlliteral = context.dofromurlliteral
+local ctx_dofromfiledescription = context.dofromfiledescription
+local ctx_dofromfileliteral = context.dofromfileliteral
+local ctx_expandreferenceoperation = context.expandreferenceoperation
+local ctx_expandreferencearguments = context.expandreferencearguments
+local ctx_getreferencestructureprefix = context.getreferencestructureprefix
+local ctx_convertnumber = context.convertnumber
+local ctx_emptyreference = context.emptyreference
+
storage.register("structures/references/defined", references.defined, "structures.references.defined")
local initializers = { }
@@ -134,12 +153,32 @@ local function initializer() -- can we use a tobesaved as metatable for collecte
for i=1,#initializers do
initializers[i](tobesaved,collected)
end
+ for prefix, list in next, collected do
+ for tag, data in next, list do
+ local r = data.references
+ local i = r.internal
+ if i then
+ internals[i] = c
+ usedinternals[i] = r.used
+ end
+ end
+ end
end
local function finalizer()
for i=1,#finalizers do
finalizers[i](tobesaved)
end
+ for prefix, list in next, tobesaved do
+ for tag, data in next, list do
+ local r = data.references
+ local i = r.internal
+ local f = flaginternals[i]
+ if f then
+ r.used = usedviews[i] or true
+ end
+ end
+ end
end
job.register('structures.references.collected', tobesaved, initializer, finalizer)
@@ -220,8 +259,6 @@ local function referredpage(n)
return texgetcount("realpageno")
end
--- setmetatableindex(referred,function(t,k) return referredpage(k) end )
-
references.referredpage = referredpage
function references.registerpage(n) -- called in the backend code
@@ -276,6 +313,9 @@ local function setcomponent(data)
local references = data and data.references
if references then
references.component = component
+ if references.referenceprefix == component then
+ references.referenceprefix = nil
+ end
end
return component
end
@@ -296,21 +336,6 @@ function references.set(kind,prefix,tag,data)
tobesaved[prefix] = pd
end
local n = 0
- -- for ref in gmatch(tag,"[^,]+") do
- -- if ref ~= "" then
- -- if check_duplicates and pd[ref] then
- -- if prefix and prefix ~= "" then
- -- report_references("redundant reference %a in namespace %a",ref,prefix)
- -- else
- -- report_references("redundant reference %a",ref)
- -- end
- -- else
- -- n = n + 1
- -- pd[ref] = data
- -- context.dofinishsomereference(kind,prefix,ref)
- -- end
- -- end
- -- end
local function action(ref)
if ref == "" then
-- skip
@@ -323,7 +348,7 @@ function references.set(kind,prefix,tag,data)
else
n = n + 1
pd[ref] = data
- context.dofinishsomereference(kind,prefix,ref)
+ ctx_dofinishsomereference(kind,prefix,ref)
end
end
process_settings(tag,action)
@@ -341,99 +366,59 @@ commands.enhancereference = references.enhance
-- -- -- related to strc-ini.lua -- -- --
-references.resolvers = references.resolvers or { }
-local resolvers = references.resolvers
-
-local function getfromlist(var)
- local vi = var.i
- if vi then
- vi = vi[3] or lists.collected[vi[2]]
- if vi then
- local r = vi.references and vi.references
- if r then
- r = r.realpage
- end
- if not r then
- r = vi.pagedata and vi.pagedata
- if r then
- r = r.realpage
- end
- end
- var.i = vi
- var.r = r or 1
- else
- var.i = nil
- var.r = 1
- end
- else
- var.i = nil
- var.r = 1
- end
-end
-
--- resolvers.section = getfromlist
--- resolvers.float = getfromlist
--- resolvers.description = getfromlist
--- resolvers.formula = getfromlist
--- resolvers.note = getfromlist
-
-setmetatableindex(resolvers,function(t,k)
- local v = getfromlist
- resolvers[k] = v
- return v
-end)
-
-function resolvers.reference(var)
- local vi = var.i[2] -- check
- if vi then
- var.i = vi
- var.r = (vi.references and vi.references.realpage) or (vi.pagedata and vi.pagedata.realpage) or 1
- else
- var.i = nil
- var.r = 1
- end
-end
-
local function register_from_lists(collected,derived,pages,sections)
- local g = derived[""] if not g then g = { } derived[""] = g end -- global
+ local derived_g = derived[""] -- global
+ if not derived_g then
+ derived_g = { }
+ derived[""] = derived_g
+ end
for i=1,#collected do
- local entry = collected[i]
- local m, r = entry.metadata, entry.references
- if m and r then
- local reference = r.reference or ""
- local prefix = r.referenceprefix or ""
- local component = r.component and r.component or ""
- if reference ~= "" then
- local kind, realpage = m.kind, r.realpage
- if kind and realpage then
- local d = derived[prefix]
- if not d then
- d = { }
- derived[prefix] = d
- end
- local c = derived[component]
- if not c then
- c = { }
- derived[component] = c
- end
- local t = { kind, i, entry }
- -- for s in gmatch(reference,"%s*([^,]+)") do
- -- if trace_referencing then
- -- report_references("list entry %a provides %a reference %a on realpage %a",i,kind,s,realpage)
- -- end
- -- c[s] = c[s] or t -- share them
- -- d[s] = d[s] or t -- share them
- -- g[s] = g[s] or t -- first wins
- -- end
- local function action(s)
- if trace_referencing then
- report_references("list entry %a provides %a reference %a on realpage %a",i,kind,s,realpage)
+ local entry = collected[i]
+ local metadata = entry.metadata
+ if metadata then
+ local kind = metadata.kind
+ if kind then
+ local references = entry.references
+ if references then
+ local reference = references.reference
+ if reference and reference ~= "" then
+ local realpage = references.realpage
+ if realpage then
+ local prefix = references.referenceprefix
+ local component = references.component
+ local derived_p = nil
+ local derived_c = nil
+ if prefix and prefix ~= "" then
+ derived_p = derived[prefix]
+ if not derived_p then
+ derived_p = { }
+ derived[prefix] = derived_p
+ end
+ end
+ if component and component ~= "" and component ~= prefix then
+ derived_c = derived[component]
+ if not derived_c then
+ derived_c = { }
+ derived[component] = derived_c
+ end
+ end
+ local function action(s)
+ if trace_referencing then
+ report_references("list entry %a provides %a reference %a on realpage %a",i,kind,s,realpage)
+ end
+ if derived_p and not derived_p[s] then
+ derived_p[s] = entry
+ end
+ if derived_c and not derived_c[s] then
+ derived_c[s] = entry
+ end
+ if not derived_g[s] then
+ derived_g[s] = entry -- first wins
+ end
+ end
+ process_settings(reference,action)
end
- c[s] = c[s] or t -- share them
- d[s] = d[s] or t -- share them
- g[s] = g[s] or t -- first wins
end
- process_settings(reference,action)
end
end
end
@@ -456,10 +441,6 @@ function references.urls.define(name,url,file,description)
end
end
-local ctx_pushcatcodes = context.pushcatcodes
-local ctx_popcatcodes = context.popcatcodes
-local txtcatcodes = catcodes.numbers.txtcatcodes -- or just use "txtcatcodes"
-
function references.urls.get(name)
local u = urls[name]
if u then
@@ -643,21 +624,21 @@ function commands.from(name)
if u then
local url, file, description = u[1], u[2], u[3]
if description ~= "" then
- context.dofromurldescription(description)
+ ctx_dofromurldescription(description)
-- ok
elseif file and file ~= "" then
- context.dofromurlliteral(url .. "/" .. file)
+ ctx_dofromurlliteral(url .. "/" .. file)
else
- context.dofromurlliteral(url)
+ ctx_dofromurlliteral(url)
end
else
local f = files[name]
if f then
local file, description = f[1], f[2]
if description ~= "" then
- context.dofromfiledescription(description)
+ ctx_dofromfiledescription(description)
else
- context.dofromfileliteral(file)
+ ctx_dofromfileliteral(file)
end
end
end
@@ -768,9 +749,6 @@ function commands.setreferencearguments(k,v)
references.currentset[k].arguments = v
end
-local ctx_expandreferenceoperation = context.expandreferenceoperation
-local ctx_expandreferencearguments = context.expandreferencearguments
-
function references.expandcurrent() -- todo: two booleans: o_has_tex& a_has_tex
local currentset = references.currentset
if currentset and currentset.has_tex then
@@ -864,7 +842,7 @@ end
local externalfiles = { }
-table.setmetatableindex(externalfiles, function(t,k)
+setmetatableindex(externalfiles, function(t,k)
local v = files[k]
if not v then
v = { k, k }
@@ -873,7 +851,7 @@ table.setmetatableindex(externalfiles, function(t,k)
return v
end)
-table.setmetatableindex(externals,function(t,k) -- either or not automatically
+setmetatableindex(externals, function(t,k) -- either or not automatically
local filename = externalfiles[k][1] -- filename
local fullname = file.replacesuffix(filename,"tuc")
if lfs.isfile(fullname) then -- todo: use other locator
@@ -960,22 +938,6 @@ local function loadproductreferences(productname,componentname,utilitydata)
ptarget = { }
productreferences[prefix] = ptarget
end
- -- for s in gmatch(reference,"%s*([^,]+)") do
- -- if ptarget then
- -- if trace_importing then
- -- report_importing("registering %s reference, kind %a, name %a, prefix %a, reference %a",
- -- "product",kind,productname,prefix,s)
- -- end
- -- ptarget[s] = ptarget[s] or entry
- -- end
- -- if ctarget then
- -- if trace_importing then
- -- report_importing("registering %s reference, kind %a, name %a, prefix %a, referenc %a",
- -- "component",kind,productname,prefix,s)
- -- end
- -- ctarget[s] = ctarget[s] or entry
- -- end
- -- end
local function action(s)
if ptarget then
if trace_importing then
@@ -1212,114 +1174,105 @@ local function identify_arguments(set,var,i)
return var
end
-local function identify_inner(set,var,prefix,collected,derived,tobesaved)
+-- needs checking: if we don't do too much (redundant) checking now
+-- inner ... we could move the prefix logic into the parser so that we have 'm for each entry
+-- foo:bar -> foo == prefix (first we try the global one)
+-- -:bar -> ignore prefix
+
+local function finish_inner(var,p,i)
+ var.kind = "inner"
+ var.i = i
+ var.p = p
+ var.r = (i.references and i.references.realpage) or (i.pagedata and i.pagedata.realpage) or 1
+ return var
+end
+
+local function identify_inner(set,var,prefix,collected,derived)
local inner = var.inner
- local outer = var.outer
- -- inner ... we could move the prefix logic into the parser so that we have 'm for each entry
- -- foo:bar -> foo == prefix (first we try the global one)
- -- -:bar -> ignore prefix
- local p, i = prefix, nil
- local splitprefix, splitinner
-- the next test is a safeguard when references are auto loaded from outer
- if inner then
- splitprefix, splitinner = lpegmatch(prefixsplitter,inner)
+ if not inner or inner == "" then
+ return false
end
- -- these are taken from other anonymous references
+ local splitprefix, splitinner = lpegmatch(prefixsplitter,inner)
if splitprefix and splitinner then
+ -- we check for a prefix:reference instance in the regular set of collected
+ -- references; a special case is -: which forces a lookup in the global list
if splitprefix == "-" then
- i = collected[""]
- i = i and i[splitinner]
+ local i = collected[""]
if i then
- p = ""
- end
- else
- i = collected[splitprefix]
- i = i and i[splitinner]
- if i then
- p = splitprefix
+ i = i[splitinner]
+ if i then
+ return finish_inner(var,"",i)
+ end
end
end
- end
- -- todo: strict here
- if not i then
- i = collected[prefix]
- i = i and i[inner]
+ local i = collected[splitprefix]
if i then
- p = prefix
- end
- end
- if not i and prefix ~= "" then
- i = collected[""]
- i = i and i[inner]
- if i then
- p = ""
+ i = i[splitinner]
+ if i then
+ return finish_inner(var,splitprefix,i)
+ end
end
- end
- if i then
- var.i = { "reference", i }
- resolvers.reference(var)
- var.kind = "inner"
- var.p = p
- elseif derived then
- -- these are taken from other data structures (like lists)
- if splitprefix and splitinner then
+ if derived then
+ -- next we look for a reference in the regular set of collected references
+ -- using the prefix that is active at this moment (so we overload the given
+ -- these are taken from other data structures (like lists)
if splitprefix == "-" then
- i = derived[""]
- i = i and i[splitinner]
+ local i = derived[""]
if i then
- p = ""
+ i = i[splitinner]
+ if i then
+ return finish_inner(var,"",i)
+ end
end
- else
- i = derived[splitprefix]
- i = i and i[splitinner]
+ end
+ local i = derived[splitprefix]
+ if i then
+ i = i[splitinner]
if i then
- p = splitprefix
+ return finish_inner(var,splitprefix,i)
end
end
end
- if not i then
- i = derived[prefix]
- i = i and i[inner]
- if i then
- p = prefix
- end
+ end
+ -- we now ignore the split prefix and treat the whole inner as a potential
+ -- referenice into the global list
+ local i = collected[prefix]
+ if i then
+ i = i[inner]
+ if i then
+ return finish_inner(var,prefix,i)
end
- if not i and prefix ~= "" then
- i = derived[""]
- i = i and i[inner]
+ end
+ if not i and derived then
+ -- and if not found we look in the derived references
+ local i = derived[prefix]
+ if i then
+ i = i[inner]
if i then
- p = ""
+ return finish_inner(var,prefix,i)
end
end
+ end
+ return false
+end
+
+local function unprefixed_inner(set,var,prefix,collected,derived,tobesaved)
+ local inner = var.inner
+ local s = specials[inner]
+ if s then
+ var.kind = "special"
+ else
+ local i = (collected and collected[""] and collected[""][inner]) or
+ (derived and derived [""] and derived [""][inner]) or
+ (tobesaved and tobesaved[""] and tobesaved[""][inner])
if i then
var.kind = "inner"
- var.i = i
- var.p = p
- local ri = resolvers[i[1]]
- if ri then
- ri(var)
- else
- -- can't happen as we catch it with a metatable now
- report_references("unknown inner resolver for %a",i[1])
- end
+ var.p = ""
+ var.i = i
+ var.r = (i.references and i.references.realpage) or (i.pagedata and i.pagedata.realpage) or 1
else
- -- no prefixes here
- local s = specials[inner]
- if s then
- var.kind = "special"
- else
- i = (collected and collected[""] and collected[""][inner]) or
- (derived and derived [""] and derived [""][inner]) or
- (tobesaved and tobesaved[""] and tobesaved[""][inner])
- if i then
- var.kind = "inner"
- var.i = { "reference", i }
- resolvers.reference(var)
- var.p = ""
- else
- var.error = "unknown inner or special"
- end
- end
+ var.error = "unknown inner or special"
end
end
return var
@@ -1330,9 +1283,8 @@ local function identify_outer(set,var,i)
local inner = var.inner
local external = externals[outer]
if external then
- local v = copytable(var)
- v = identify_inner(set,v,nil,external)
- if v.i and not v.error then
+ local v = identify_inner(set,var,nil,external)
+ if v then
v.kind = "outer with inner"
set.external = true
if trace_identifying then
@@ -1340,9 +1292,8 @@ local function identify_outer(set,var,i)
end
return v
end
- v = copytable(var)
- local v = identify_inner(set,v,v.outer,external)
- if v.i and not v.error then
+ local v = identify_inner(set,var,var.outer,external)
+ if v then
v.kind = "outer with inner"
set.external = true
if trace_identifying then
@@ -1353,8 +1304,8 @@ local function identify_outer(set,var,i)
end
local external = productdata.componentreferences[outer]
if external then
- local v = identify_inner(set,copytable(var),nil,external)
- if v.i and not v.error then
+ local v = identify_inner(set,var,nil,external)
+ if v then
v.kind = "outer with inner"
set.external = true
if trace_identifying then
@@ -1427,57 +1378,62 @@ local function identify_outer(set,var,i)
return var
end
+-- todo: avoid copy
+
local function identify_inner_or_outer(set,var,i)
-- here we fall back on product data
local inner = var.inner
if inner and inner ~= "" then
- local v = identify_inner(set,copytable(var),set.prefix,collected,derived,tobesaved)
- if v.i and not v.error then
- v.kind = "inner" -- check this
+
+ -- first we look up in collected and derived using the current prefix
+
+ local prefix = set.prefix
+
+ local v = identify_inner(set,var,set.prefix,collected,derived)
+ if v then
if trace_identifying then
report_identify_outer(set,v,i,"4a")
end
return v
end
- -- these get auto prefixes but are loaded in the document so they are
- -- internal .. we also set the realpage (for samepage analysis)
+ -- nest we look at each component (but we can omit the already consulted one
local components = job.structure.components
if components then
- for i=1,#components do
- local component = components[i]
- local data = collected[component]
- local vi = data and data[inner]
- if vi then
--- var = copytable(var)
--- var.kind = "inner"
--- var.i = vi
--- var.p = component
--- runners.inner(var.r = vi.references.realpage
--- if trace_identifying then
--- report_identify_outer(set,var,i,"4x")
--- end
--- return var
-local v = identify_inner(set,copytable(var),component,collected) -- is copy needed ?
-if v.i and not v.error then
- v.kind = "inner"
- if trace_identifying then
- report_identify_outer(set,var,i,"4x")
- end
- return v
-end
+ for c=1,#components do
+ local component = components[c]
+ if component ~= prefix then
+ local v = identify_inner(set,var,component,collected,derived)
+ if v then
+ if trace_identifying then
+ report_identify_outer(set,var,i,"4b")
+ end
+ return v
+ end
end
end
end
+ -- as a last resort we will consult the global lists
+
+ local v = unprefixed_inner(set,var,"",collected,derived,tobesaved)
+ if v then
+ if trace_identifying then
+ report_identify_outer(set,v,i,"4c")
+ end
+ return v
+ end
+
+ -- not it gets bad ... we need to look in external files ... keep in mind that
+ -- we can best use explicit references for this ... we might issue a warning
+
local componentreferences = productdata.componentreferences
local productreferences = productdata.productreferences
local components = productdata.components
if components and componentreferences then
- -- for component, data in next, productdata.componentreferences do -- better do this in order of processing:
- for i=1,#components do
- local component = components[i]
+ for c=1,#components do
+ local component = components[c]
local data = componentreferences[component]
if data then
local d = data[""]
@@ -1488,7 +1444,7 @@ end
var.kind = "outer with inner"
set.external = true
if trace_identifying then
- report_identify_outer(set,var,i,"4b")
+ report_identify_outer(set,var,i,"4d")
end
return var
end
@@ -1508,7 +1464,7 @@ end
var.kind = "outer with inner"
set.external = true
if trace_identifying then
- report_identify_outer(set,var,i,"4c")
+ report_identify_outer(set,var,i,"4e")
end
return var
end
@@ -1523,7 +1479,7 @@ end
var.kind = "outer with inner"
set.external = true
if trace_identifying then
- report_identify_outer(set,var,i,"4d")
+ report_identify_outer(set,var,i,"4f")
end
return var
end
@@ -1534,30 +1490,18 @@ end
var.error = "no inner"
end
if trace_identifying then
- report_identify_outer(set,var,i,"4e")
+ report_identify_outer(set,var,i,"4g")
end
return var
end
--- local function identify_inner_or_outer(set,var,i)
--- -- we might consider first checking with a prefix prepended and then without
--- -- which is better for fig:oeps
--- local var = do_identify_inner_or_outer(set,var,i)
--- if var.error then
--- local prefix = set.prefix
--- if prefix and prefix ~= "" then
--- var.inner = prefix .. ':' .. var.inner
--- var.error = nil
--- return do_identify_inner_or_outer(set,var,i)
--- end
--- end
--- return var
--- end
-
local function identify_inner_component(set,var,i)
-- we're in a product (maybe ignore when same as component)
local component = var.component
- identify_inner(set,var,component,collected,derived,tobesaved)
+ local v = identify_inner(set,var,component,collected,derived)
+ if not v then
+ var.error = "unknown inner in component"
+ end
if trace_identifying then
report_identify_outer(set,var,i,"5a")
end
@@ -1697,17 +1641,15 @@ luatex.registerstopactions(references.reportproblems)
-- can make files smaller without sacrificing external references. Some of
-- the housekeeping happens the backend side.
-local innermethod = "auto" -- was "names"
+local innermethod = v_auto -- only page|auto now
local defaultinnermethod = defaultinnermethod
-references.innermethod = innermethod -- don't mess with this one directly
+references.innermethod = innermethod -- don't mess with this one directly
function references.setinnermethod(m)
- if m then
- if m == "page" or m == "mixed" or m == "names" or m == "auto" then
- innermethod = m
- elseif m == true or m == v_yes then
- innermethod = "page"
- end
+ if toboolean(m) or m == v_page then
+ innermethod = v_page
+ else
+ innermethod = v_auto
end
references.innermethod = innermethod
function references.setinnermethod()
@@ -1719,7 +1661,7 @@ function references.getinnermethod()
return innermethod or defaultinnermethod
end
-directives.register("references.linkmethod", function(v) -- page mixed names
+directives.register("references.linkmethod", function(v) -- page auto
references.setinnermethod(v)
end)
@@ -1729,7 +1671,7 @@ local destinationattributes = { }
local function setinternalreference(prefix,tag,internal,view) -- needs checking
local destination = unsetvalue
- if innermethod ~= "page" then
+ if innermethod == v_auto then
local t, tn = { }, 0 -- maybe add to current
if tag then
if prefix and prefix ~= "" then
@@ -1749,7 +1691,7 @@ local function setinternalreference(prefix,tag,internal,view) -- needs checking
end
-- ugly .. later we decide to ignore it when we have a real one
-- but for testing we might want to see them all
- if internal and (innermethod == "names" or innermethod == "auto") then -- mixed or page
+ if internal then
tn = tn + 1
t[tn] = internal -- when number it's internal
end
@@ -1820,10 +1762,22 @@ end
references.getcurrentprefixspec = getcurrentprefixspec
function commands.getcurrentprefixspec(default)
- context.getreferencestructureprefix(getcurrentprefixspec(default))
+ ctx_getreferencestructureprefix(getcurrentprefixspec(default))
end
-function references.filter(name,...) -- number page title ...
+local genericfilters = { }
+local userfilters = { }
+local textfilters = { }
+local fullfilters = { }
+local sectionfilters = { }
+
+filters.generic = genericfilters
+filters.user = userfilters
+filters.text = textfilters
+filters.full = fullfilters
+filters.section = sectionfilters
+
+local function filterreference(name,...) -- number page title ...
local data = currentreference and currentreference.i -- maybe we should take realpage from here
if data then
if name == "realpage" then
@@ -1832,8 +1786,8 @@ function references.filter(name,...) -- number page title ...
else -- assumes data is table
local kind = type(data) == "table" and data.metadata and data.metadata.kind
if kind then
- local filter = filters[kind] or filters.generic
- filter = filter and (filter[name] or filter.unknown or filters.generic[name] or filters.generic.unknown)
+ local filter = filters[kind] or genericfilters
+ filter = filter and (filter[name] or filter.unknown or genericfilters[name] or genericfilters.unknown)
if filter then
if trace_referencing then
report_references("name %a, kind %a, using dedicated filter",name,kind)
@@ -1853,18 +1807,24 @@ function references.filter(name,...) -- number page title ...
end
end
-function references.filterdefault()
- return references.filter("default",getcurrentprefixspec(v_default))
+local function filterreferencedefault()
+ return filterreference("default",getcurrentprefixspec(v_default))
end
+references.filter = filterreference
+references.filterdefault = filterreferencedefault
+
+commands.filterreference = filterreference
+commands.filterdefaultreference = filterreferencedefault
+
function commands.currentreferencedefault(tag)
- if not tag then tag = "default" end
- references.filter(tag,context.delayed(getcurrentprefixspec(tag)))
+ if not tag then
+ tag = "default"
+ end
+ filterreference(tag,context_delayed(getcurrentprefixspec(tag)))
end
-filters.generic = { }
-
-function filters.generic.title(data)
+function genericfilters.title(data)
if data then
local titledata = data.titledata or data.useddata
if titledata then
@@ -1873,7 +1833,7 @@ function filters.generic.title(data)
end
end
-function filters.generic.text(data)
+function genericfilters.text(data)
if data then
local entries = data.entries or data.useddata
if entries then
@@ -1882,7 +1842,7 @@ function filters.generic.text(data)
end
end
-function filters.generic.number(data,what,prefixspec) -- todo: spec and then no stopper
+function genericfilters.number(data,what,prefixspec) -- todo: spec and then no stopper
if data then
numberdata = lists.reordered(data) -- data.numberdata
if numberdata then
@@ -1897,16 +1857,16 @@ function filters.generic.number(data,what,prefixspec) -- todo: spec and then no
end
end
-filters.generic.default = filters.generic.text
+genericfilters.default = genericfilters.text
-function filters.generic.page(data,prefixspec,pagespec)
+function genericfilters.page(data,prefixspec,pagespec)
local pagedata = data.pagedata
if pagedata then
local number, conversion = pagedata.number, pagedata.conversion
if not number then
-- error
elseif conversion then
- context.convertnumber(conversion,number)
+ ctx_convertnumber(conversion,number)
else
context(number)
end
@@ -1915,14 +1875,12 @@ function filters.generic.page(data,prefixspec,pagespec)
end
end
-filters.user = { }
-
-function filters.user.unknown(data,name)
+function userfilters.unknown(data,name)
if data then
local userdata = data.userdata
local userkind = userdata and userdata.kind
if userkind then
- local filter = filters[userkind] or filters.generic
+ local filter = filters[userkind] or genericfilters
filter = filter and (filter[name] or filter.unknown)
if filter then
filter(data,name)
@@ -1936,9 +1894,7 @@ function filters.user.unknown(data,name)
end
end
-filters.text = { }
-
-function filters.text.title(data)
+function textfilters.title(data)
helpers.title(data.entries.text or "?",data.metadata)
end
@@ -1948,18 +1904,14 @@ end
-- helpers.title(data.entries.text or "?",data.metadata)
-- end
-function filters.text.page(data,prefixspec,pagespec)
+function textfilters.page(data,prefixspec,pagespec)
helpers.prefixpage(data,prefixspec,pagespec)
end
-filters.full = { }
-
-filters.full.title = filters.text.title
-filters.full.page = filters.text.page
+fullfilters.title = textfilters.title
+fullfilters.page = textfilters.page
-filters.section = { }
-
-function filters.section.number(data,what,prefixspec)
+function sectionfilters.number(data,what,prefixspec)
if data then
local numberdata = data.numberdata
if not numberdata then
@@ -1971,7 +1923,7 @@ function filters.section.number(data,what,prefixspec)
local references = data.references
if trace_empty then
report_empty("reference %a has a hidden number",references.reference)
- context.emptyreference() -- maybe an option
+ ctx_emptyreference() -- maybe an option
end
else
sections.typesetnumber(numberdata,"number",prefixspec,numberdata)
@@ -1979,18 +1931,18 @@ function filters.section.number(data,what,prefixspec)
end
end
-filters.section.title = filters.generic.title
-filters.section.page = filters.generic.page
-filters.section.default = filters.section.number
+sectionfilters.title = genericfilters.title
+sectionfilters.page = genericfilters.page
+sectionfilters.default = sectionfilters.number
--- filters.note = { default = filters.generic.number }
--- filters.formula = { default = filters.generic.number }
--- filters.float = { default = filters.generic.number }
--- filters.description = { default = filters.generic.number }
--- filters.item = { default = filters.generic.number }
+-- filters.note = { default = genericfilters.number }
+-- filters.formula = { default = genericfilters.number }
+-- filters.float = { default = genericfilters.number }
+-- filters.description = { default = genericfilters.number }
+-- filters.item = { default = genericfilters.number }
setmetatableindex(filters, function(t,k) -- beware, test with rawget
- local v = { default = filters.generic.number } -- not copy as it might be extended differently
+ local v = { default = genericfilters.number } -- not copy as it might be extended differently
t[k] = v
return v
end)
@@ -2246,9 +2198,6 @@ end
-- needs a better split ^^^
-commands.filterreference = references.filter
-commands.filterdefaultreference = references.filterdefault
-
-- done differently now:
function references.export(usedname) end
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index 4696c61da..cd307cc65 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -193,12 +193,12 @@
\globallet\currentreferencecoding\s!tex
\fi
% beware, the structures.references.set writes a
- % \setnextinternalreference
+\setnextinternalreference
\strc_references_start_destination_nodes
\ctxcommand{setreferenceattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels",
{
references = {
- % internal = \nextinternalreference, % no need for an internal as we have an explicit
+internal = \nextinternalreference,
block = "\currentsectionblock",
section = structures.sections.currentid(),
},
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 876044240..308e4b6fc 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -128,10 +128,16 @@
\newif\if!!doned \newif\if!!donee \newif\if!!donef
\def\!!zerocount {0} % alongside \zerocount
-\def\!!minusone {-1} % alongside \minusone
-\def\!!plusone {1} % alongside \plusone
-\def\!!plustwo {2} % alongside \plustwo
-\def\!!plusthree {3} % alongside \plusthree
+\def\!!minusone {-1} % ...
+\def\!!plusone {1} % ...
+\def\!!plustwo {2} % ...
+\def\!!plusthree {3} % ...
+\def\!!plusfour {4} % ...
+\def\!!plusfive {5} % ...
+\def\!!plussix {6} % ...
+\def\!!plusseven {7} % ...
+\def\!!pluseight {8} % ...
+\def\!!plusnine {9} % alongside \plusnine
\setnewconstant \uprotationangle 0
\setnewconstant\rightrotationangle 90
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 655aedf5e..fb0710b1c 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 : 03/22/14 15:31:38
+-- merge date : 03/24/14 00:52:15
do -- begin closure to overcome local limits and interference