summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cldf-ini.lua4
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4434 -> 4441 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/data-ini.lua41
-rw-r--r--tex/context/base/data-pre.lua11
-rw-r--r--tex/context/base/data-res.lua98
-rw-r--r--tex/context/base/file-job.lua38
-rw-r--r--tex/context/base/grph-inc.lua10
-rw-r--r--tex/context/base/lpdf-tag.lua35
-rw-r--r--tex/context/base/math-ini.mkiv2
-rw-r--r--tex/context/base/status-files.pdfbin24921 -> 24898 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin326542 -> 326823 bytes
-rw-r--r--tex/context/base/strc-ref.mkvi80
-rw-r--r--tex/context/base/strc-tag.lua89
-rw-r--r--tex/context/base/strc-tag.mkiv34
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
17 files changed, 276 insertions, 172 deletions
diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua
index 0a0f71266..ff466586f 100644
--- a/tex/context/base/cldf-ini.lua
+++ b/tex/context/base/cldf-ini.lua
@@ -28,6 +28,10 @@ if not modules then modules = { } end modules ['cldf-ini'] = {
-- the the differences between the lua and luajit hashers can lead to quite a slowdown
-- in some cases.
+-- context(lpeg.match(lpeg.patterns.texescape,"${}"))
+-- context(string.formatters["%!tex!"]("${}"))
+-- context("%!tex!","${}")
+
local tex = tex
context = context or { }
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 0845e92fd..5f68b1cc4 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.07.25 12:57}
+\newcontextversion{2014.07.26 10:44}
%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 a7b446132..476aaed38 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 831a76c7f..95e44f1bd 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.07.25 12:57}
+\edef\contextversion{2014.07.26 10:44}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/data-ini.lua b/tex/context/base/data-ini.lua
index ab5668c0b..c74ff2e04 100644
--- a/tex/context/base/data-ini.lua
+++ b/tex/context/base/data-ini.lua
@@ -233,6 +233,7 @@ resolvers.prefixes = prefixes
local resolved = { }
local abstract = { }
+local dynamic = { }
function resolvers.resetresolve(str)
resolved, abstract = { }, { }
@@ -261,15 +262,20 @@ function resolvers.unresolve(str)
return abstract[str] or str
end
+function resolvers.setdynamic(str)
+ dynamic[str] = true
+end
+
-- home:xx;selfautoparent:xx;
-local pattern = Cs((C(R("az")^2) * P(":") * C((1-S(" \"\';,"))^1) / _resolve_ + P(1))^0)
+local pattern = Cs((C(R("az")^2) * P(":") * C((1-S(" \"\';,"))^1) / _resolve_ + P(1))^0)
-local prefix = C(R("az")^2) * P(":")
-local target = C((1-S(" \"\';,"))^1)
-local notarget = (#S(";,") + P(-1)) * Cc("")
+local prefix = C(R("az")^2) * P(":")
+local target = C((1-S(" \"\';,"))^1)
+local notarget = (#S(";,") + P(-1)) * Cc("")
-local pattern = Cs(((prefix * (target + notarget)) / _resolve_ + P(1))^0)
+local p_resolve = Cs(((prefix * (target + notarget)) / _resolve_ + P(1))^0)
+local p_simple = prefix * P(-1)
local function resolve(str) -- use schemes, this one is then for the commandline only
if type(str) == "table" then
@@ -278,15 +284,28 @@ local function resolve(str) -- use schemes, this one is then for the commandline
res[i] = resolve(str[i])
end
return res
- else
- local res = resolved[str]
- if not res then
- res = lpegmatch(pattern,str)
- resolved[str] = res
- abstract[res] = str
+ end
+ -- already resolved
+ local res = resolved[str]
+ if res then
+ return res
+ end
+ -- simple resolving of (dynamic) methods
+ local simple = lpegmatch(p_simple,str)
+ local action = prefixes[simple]
+ if action then
+ local res = action(res)
+ if not dynamic[simple] then
+ resolved[simple] = res
+ abstract[res] = simple
end
return res
end
+ -- more extensive resolving (multiple too)
+ res = lpegmatch(p_resolve,str)
+ resolved[str] = res
+ abstract[res] = str
+ return res
end
resolvers.resolve = resolve
diff --git a/tex/context/base/data-pre.lua b/tex/context/base/data-pre.lua
index edfe53dab..ae4477ac6 100644
--- a/tex/context/base/data-pre.lua
+++ b/tex/context/base/data-pre.lua
@@ -113,3 +113,14 @@ prefixes.kpse = prefixes.locate
prefixes.full = prefixes.locate
prefixes.file = prefixes.filename
prefixes.path = prefixes.pathname
+
+prefixes.jobfile = function(str)
+ local path = resolvers.stackpath() or "."
+ if str and str ~= "" then
+ return cleanpath(joinpath(path,str))
+ else
+ return cleanpath(path)
+ end
+end
+
+resolvers.setdynamic("jobfile")
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index 69bdc508c..b3ec90898 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -18,7 +18,7 @@ if not modules then modules = { } end modules ['data-res'] = {
-- todo: cache:/// home:/// selfautoparent:/// (sometime end 2012)
local gsub, find, lower, upper, match, gmatch = string.gsub, string.find, string.lower, string.upper, string.match, string.gmatch
-local concat, insert, sortedkeys, sortedhash = table.concat, table.insert, table.sortedkeys, table.sortedhash
+local concat, insert, remove, sortedkeys, sortedhash = table.concat, table.insert, table.remove, table.sortedkeys, table.sortedhash
local next, type, rawget = next, type, rawget
local os = os
@@ -49,6 +49,7 @@ local luasuffixes = utilities.lua.suffixes
local trace_locating = false trackers .register("resolvers.locating", function(v) trace_locating = v end)
local trace_detail = false trackers .register("resolvers.details", function(v) trace_detail = v end)
local trace_expansions = false trackers .register("resolvers.expansions", function(v) trace_expansions = v end)
+local trace_paths = false trackers .register("resolvers.paths", function(v) trace_paths = v end)
local resolve_otherwise = true directives.register("resolvers.otherwise", function(v) resolve_otherwise = v end)
local report_resolving = logs.reporter("resolvers","resolving")
@@ -251,6 +252,7 @@ function resolvers.newinstance() -- todo: all vars will become lowercase and alp
savelists = true,
pattern = nil, -- lists
force_suffixes = true,
+ pathstack = { },
}
setmetatableindex(variables,function(t,k)
@@ -697,6 +699,35 @@ function resolvers.unexpandedpath(str)
return joinpath(resolvers.unexpandedpathlist(str))
end
+function resolvers.pushpath(name)
+ local pathstack = instance.pathstack
+ local lastpath = pathstack[#pathstack]
+ local pluspath = filedirname(name)
+ if lastpath then
+ lastpath = collapsepath(filejoin(lastpath,pluspath))
+ else
+ lastpath = collapsepath(pluspath)
+ end
+ insert(pathstack,lastpath)
+ if trace_paths then
+ report_resolving("pushing path %a",lastpath)
+ end
+end
+
+function resolvers.poppath()
+ local pathstack = instance.pathstack
+ if trace_paths and #pathstack > 0 then
+ report_resolving("popping path %a",pathstack[#pathstack])
+ end
+ remove(pathstack)
+end
+
+function resolvers.stackpath()
+ local pathstack = instance.pathstack
+ local currentpath = pathstack[#pathstack]
+ return currentpath ~= "" and currentpath or nil
+end
+
local done = { }
function resolvers.resetextrapath()
@@ -769,49 +800,6 @@ function resolvers.registerextrapath(paths,subpaths)
end
end
--- local function made_list(instance,list,extra_too)
--- if not extra_too then
--- return list
--- end
--- local ep = instance.extra_paths
--- if not ep or #ep == 0 then
--- return list
--- end
--- local done, new, newn = { }, { }, 0
--- -- honour . .. ../.. but only when at the start
--- for k=1,#list do
--- local v = list[k]
--- if not done[v] then
--- if find(v,"^[%.%/]$") then
--- done[v] = true
--- newn = newn + 1
--- new[newn] = v
--- else
--- break
--- end
--- end
--- end
--- -- first the extra paths
--- for k=1,#ep do
--- local v = ep[k]
--- if not done[v] then
--- done[v] = true
--- newn = newn + 1
--- new[newn] = v
--- end
--- end
--- -- next the formal paths
--- for k=1,#list do
--- local v = list[k]
--- if not done[v] then
--- done[v] = true
--- newn = newn + 1
--- new[newn] = v
--- end
--- end
--- return new
--- end
-
local function made_list(instance,list,extra_too)
local done, new, newn = { }, { }, 0
-- honour . .. ../.. but only when at the start
@@ -930,8 +918,8 @@ end
-- name | name/name
-local function collect_files(names)
- local filelist = { }
+local function collect_files(names) -- potential files .. sort of too much when asking for just one file
+ local filelist = { } -- but we need it for pattern matching later on
local noffiles = 0
local function check(hash,root,pathname,path,name)
if not pathname or find(path,pathname) then
@@ -965,7 +953,7 @@ local function collect_files(names)
local content = hashname and instance.files[hashname]
if content then
if trace_detail then
- report_resolving("deep checking %a, base %a, pattern %a",blobpath,basename,pathname)
+ report_resolving("deep checking %a, base %a, pattern %a",hashname,basename,pathname)
end
local path, name = lookup(content,basename)
if path then
@@ -1193,7 +1181,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
local method = "intree"
if pathlist and #pathlist > 0 then
-- list search
- local filelist = collect_files(wantedfiles)
+ local filelist = collect_files(wantedfiles) -- okay, a bit over the top when we just look relative to the current path
local dirlist = { }
if filelist then
for i=1,#filelist do
@@ -1201,7 +1189,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
end
end
if trace_detail then
- report_resolving("checking filename %a",filename)
+ report_resolving("checking filename %a in tree",filename)
end
local result = { }
-- pathlist : resolved
@@ -1257,7 +1245,14 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
local pname = gsub(pathname,"%.%*$",'')
if not find(pname,"*",1,true) then
if can_be_dir(pname) then
- -- quick root scan first
+ -- hm, rather useless as we don't go deeper and if we would we could also
+ -- auto generate the file database .. however, we need this for extra paths
+ -- that are not hashed (like sources on my machine) .. so, this is slightly
+ -- out of order but at least fast (anbd we seldom end up here, only when a file
+ -- is not already found
+ if trace_detail then
+ report_resolving("quick root scan for %a",pname)
+ end
for k=1,#wantedfiles do
local w = wantedfiles[k]
local fname = check_subpath(filejoin(pname,w))
@@ -1271,6 +1266,9 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
end
if not done and doscan then
-- collect files in path (and cache the result)
+ if trace_detail then
+ report_resolving("scanning filesystem for %a",pname)
+ end
local files = resolvers.simplescanfiles(pname,false,true)
for k=1,#wantedfiles do
local w = wantedfiles[k]
diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua
index 85fa996de..3b67057e0 100644
--- a/tex/context/base/file-job.lua
+++ b/tex/context/base/file-job.lua
@@ -165,6 +165,11 @@ end
--
+local typestack = { }
+local currenttype = v_text
+
+--
+
local action = function(name,foundname) input(foundname) end
local failure = function(name,foundname) report_jobfiles("unknown %s file %a","tex",name) end
@@ -241,6 +246,7 @@ local suffixes = {
local function useanyfile(name,onlyonce)
local s = suffixes[suffixonly(name)]
+ context(function() resolvers.pushpath(name) end)
if s then
-- s(removesuffix(name),onlyonce)
s(name,onlyonce) -- so, first with suffix, then without
@@ -248,6 +254,7 @@ local function useanyfile(name,onlyonce)
usetexfile(name,onlyonce) -- e.g. ctx file
-- resolvers.readfilename(name)
end
+ context(resolvers.poppath)
end
commands.useanyfile = useanyfile
@@ -344,14 +351,6 @@ function commands.processfilenone(name)
-- skip file
end
---
-
-local typestack = { }
-local pathstack = { }
-
-local currenttype = v_text
-local currentpath = "."
-
local tree = { type = "text", name = "", branches = { } }
local treestack = { }
local top = tree.branches
@@ -442,14 +441,18 @@ local context_processfilemany = context.processfilemany
local context_processfileonce = context.processfileonce
local context_processfilenone = context.processfilenone
+-- we need a plug in the nested loaded, push pop pseudo current dir
+
local function processfilecommon(name,action)
- if not hasscheme(name) then
- local path = dirname(name)
- if path ~= "" then
- registerextrapath(path)
- report_jobfiles("adding search path %a",path)
- end
- end
+ -- experiment, might go away
+-- if not hasscheme(name) then
+-- local path = dirname(name)
+-- if path ~= "" then
+-- registerextrapath(path)
+-- report_jobfiles("adding search path %a",path)
+-- end
+-- end
+ -- till here
action(name)
end
@@ -554,7 +557,7 @@ function jobresolvers.currentcomponent () return topofstack(v_component ) end
function jobresolvers.currentenvironment() return topofstack(v_environment) end
local done = { }
-local tolerant = false -- too messy, mkii user with the wrong sructure should adapt
+local tolerant = false -- too messy, mkii user with the wrong structure should adapt
local function process(what,name)
local depth = #typestack
@@ -639,9 +642,7 @@ local stop = {
local function gotonextlevel(what,name) -- todo: something with suffix name
insert(stacks[what],name)
insert(typestack,currenttype)
- insert(pathstack,currentpath)
currenttype = what
- currentpath = dirname(name)
pushtree(what,name)
if start[what] then
start[what]()
@@ -653,7 +654,6 @@ local function gotopreviouslevel(what)
stop[what]()
end
poptree()
- currentpath = remove(pathstack) or "."
currenttype = remove(typestack) or v_text
remove(stacks[what]) -- not currenttype ... weak recovery
-- context.endinput() -- does not work
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 9ee5c6199..d42d8b225 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -60,6 +60,8 @@ local images = img
local hasscheme = url.hasscheme
local urlhashed = url.hashed
+local resolveprefix = resolvers.resolve
+
local texgetbox = tex.getbox
local texsetbox = tex.setbox
@@ -869,7 +871,7 @@ local function locate(request) -- name, format, cache
else
-- type given
for i=1,#figure_paths do
- local path = figure_paths[i]
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
local check = path .. "/" .. askedname
-- we pass 'true' as it can be an url as well, as the type
-- is given we don't waste much time
@@ -935,7 +937,7 @@ local function locate(request) -- name, format, cache
-- local name = file.replacesuffix(askedbase,suffix)
local name = file.replacesuffix(askedname,suffix)
for i=1,#figure_paths do
- local path = figure_paths[i]
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
local check = path .. "/" .. name
local isfile = internalschemes[urlhashed(check).scheme]
if not isfile then
@@ -963,7 +965,7 @@ local function locate(request) -- name, format, cache
report_inclusion("unknown format, using path strategy")
end
for i=1,#figure_paths do
- local path = figure_paths[i]
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
for j=1,#figures_order do
local format = figures_order[j]
local list = figures_formats[format].list or { format }
@@ -1588,7 +1590,7 @@ local function bases_find(basename,askedlabel)
if base[2] == nil then
-- no yet located
for i=1,#figure_paths do
- local path = figure_paths[i]
+ local path = resolveprefix(figure_paths[i]) -- we resolve (e.g. jobfile:)
local xmlfile = path .. "/" .. basename
if io.exists(xmlfile) then
base[2] = xmlfile
diff --git a/tex/context/base/lpdf-tag.lua b/tex/context/base/lpdf-tag.lua
index 22d20784e..5f0d35b53 100644
--- a/tex/context/base/lpdf-tag.lua
+++ b/tex/context/base/lpdf-tag.lua
@@ -8,8 +8,9 @@ if not modules then modules = { } end modules ['lpdf-tag'] = {
local next = next
local format, match, concat = string.format, string.match, table.concat
-local lpegmatch = lpeg.match
+local lpegmatch, P, S, C = lpeg.match, lpeg.P, lpeg.S, lpeg.C
local utfchar = utf.char
+local settings_to_hash = utilities.parsers.settings_to_hash
local trace_tags = false trackers.register("structures.tags", function(v) trace_tags = v end)
@@ -78,9 +79,14 @@ local root = { pref = pdfreference(structure_ref), kids = structu
local tree = { }
local elements = { }
local names = pdfarray()
-local taglist = structures.tags.taglist
-local usedlabels = structures.tags.labels
-local properties = structures.tags.properties
+
+local structurestags = structures.tags
+local taglist = structurestags.taglist
+local usedlabels = structurestags.labels
+local properties = structurestags.properties
+local userdata = structurestags.userdata
+local lasttaginchain = structurestags.lastinchain
+
local usedmapping = { }
local colonsplitter = lpeg.splitat(":")
@@ -164,10 +170,30 @@ end
-- here we can flush and free elements that are finished
+local userproperties = structurestags.userproperties
+local pdf_userproperties = pdfconstant("UserProperties")
+
+local function makeattribute(t)
+ if t and next(t) then
+ local properties = pdfarray()
+ for k, v in next, t do
+ properties[#properties+1] = pdfdictionary {
+ N = pdfunicode(k),
+ V = pdfunicode(v),
+ }
+ end
+ return pdfdictionary {
+ O = pdf_userproperties,
+ P = properties,
+ }
+ end
+end
+
local function makeelement(fulltag,parent)
local tag, n = lpegmatch(dashsplitter,fulltag)
local tg, detail = lpegmatch(colonsplitter,tag)
local k, r = pdfarray(), pdfreserveobject()
+ local a = userproperties[fulltag]
usedmapping[tg] = true
tg = usedlabels[tg] or tg
local d = pdfdictionary {
@@ -178,6 +204,7 @@ local function makeelement(fulltag,parent)
P = parent.pref,
Pg = pageref,
K = pdfreference(r),
+ A = a and makeattribute(a) or nil,
-- Alt = " Who cares ",
-- ActualText = " Hi Hans ",
}
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index adf252d95..2d3d3bf6c 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -26,6 +26,8 @@
%D restore a changed mathstyle so best avoid that one. However, there are cases where
%D we really need to use such grouping.
+% mathop applied to characters centers it vertically
+
\unprotect
%D We move these definitions into the format:
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 0241ba073..899355d50 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 e54405486..72dfed895 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-ref.mkvi b/tex/context/base/strc-ref.mkvi
index 715459172..b2ecc823f 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -1080,12 +1080,6 @@
\fi
\endgroup}
-% \def\strc_references_by_reference_page_state#unknown#before#current#after% obsolete
-% {\ifcase\referencepagestate#unknown\or#current\or#before\or#after\or#before\or#after\else#unknown\fi}
-%
-% \def\strc_references_by_reference_page_state#unknown#same#previous#next#above#below% not needed
-% {\ifcase\referencepagestate#unknown\or#same\or#previous\or#next\or#above\or#below\else#unknown\fi}
-
\unexpanded\def\doifcheckedpagestate#label% #preceding#backward#current#foreward#following#otherwise%
{\doifreferencefoundelse{#label}\strc_references_handle_page_state_yes\strc_references_handle_page_state_nop}
@@ -1111,74 +1105,54 @@
\symbol[\ifcase\referencepagedetail\v!somewhere\or\v!nowhere\or\v!previous\or\v!next\or\v!previous\or\v!next\else\v!somewhere\fi]}%
\egroup}
-% \unexpanded\def\somewhere#backward#foreward#dummy[#label]% #dummy gobbles space around #foreward
-% {\doifreferencefoundelse{#label}%
-% {\markreferencepage
-% \ifcase\referencepagedetail
-% #label\or % unknown
-% \or % same
-% \goto{#backward}[#label]\or % previous
-% \goto{#foreward}[#label]\or % next
-% \goto{#backward}[#label]\or % above
-% \goto{#foreward}[#label]\else % below
-% #label\fi}%
-% {[#label]}}
+%D Hereafter the \type {\ignorespaces} binds the state node to next character (more likely
+%D than a preceding one) and one can always add an explicit space.
\unexpanded\def\somewhere#backward#foreward#dummy[#label]% #dummy gobbles space around #foreward
{\doifcheckedpagestate{#label}%
{\goto{#backward}[#label]}%
{\goto{#backward}[#label]}%
- {}%
+ {\ignorespaces}%
{\goto{#foreward}[#label]}%
{\goto{#foreward}[#label]}%
{#label}}%
-% \unexpanded\def\someplace#preceding#backward#current#foreward#following#dummy[#label]% #dummy gobbles space around #foreward
-% {\doifreferencefoundelse{#label}%
-% {\markreferencepage
-% \ifcase\referencepagedetail
-% #label\or % unknown
-% \doifsomething {#current}{\goto {#current}[#label]}\or % same
-% \doifsomething{#preceding}{\goto{#preceding}[#label]}\or % previous
-% \doifsomething{#following}{\goto{#following}[#label]}\or % next
-% \doifsomething {#backward}{\goto {#backward}[#label]}\or % above
-% \doifsomething {#foreward}{\goto {#foreward}[#label]}\else % below
-% #label\fi}%
-% {[#label]}}
-
\unexpanded\def\someplace#preceding#backward#current#foreward#following#dummy[#label]% #dummy gobbles space around #foreward
{\doifcheckedpagestate{#label}%
- {\doifsomething{#preceding}{\goto{#preceding}[#label]}}%
- {\doifsomething {#backward}{\goto {#backward}[#label]}}%
- {\doifsomething {#current}{\goto {#current}[#label]}}%
- {\doifsomething {#foreward}{\goto {#foreward}[#label]}}%
- {\doifsomething{#following}{\goto{#following}[#label]}}%
+ {\doifelsenothing{#preceding}{\goto{#preceding}[#label]}\ignorespaces}%
+ {\doifelsenothing {#backward}{\goto {#backward}[#label]}\ignorespaces}%
+ {\doifelsenothing {#current}{\goto {#current}[#label]}\ignorespaces}%
+ {\doifelsenothing {#foreward}{\goto {#foreward}[#label]}\ignorespaces}%
+ {\doifelsenothing{#following}{\goto{#following}[#label]}\ignorespaces}%
{#label}}
-% \unexpanded\def\atpage[#label]% todo
-% {\doifreferencefoundelse{#label}% kind of inefficient as \goto also analyzes
-% {\markreferencepage
-% \ifcase\referencepagedetail
-% \goto{\labeltexts\v!page\dummyreference}[#label]\or % unknown
-% \or % same
-% \goto{\labeltext \v!precedingpage }[#label]\or % previous
-% \goto{\labeltext \v!followingpage }[#label]\or % next
-% \goto{\labeltext \v!hencefore }[#label]\or % above
-% \goto{\labeltext \v!hereafter }[#label]\else % below
-% \goto{\labeltexts\v!page\dummyreference}[#label]\fi}%
-% {[#label]}}
-
\unexpanded\def\atpage[#label]% todo
{\doifcheckedpagestate{#label}%
{\goto{\labeltext \v!precedingpage }[#label]}%
{\goto{\labeltext \v!hencefore }[#label]}%
- {}%
+ {\ignorespaces}%
{\goto{\labeltext \v!hereafter }[#label]}%
{\goto{\labeltext \v!followingpage }[#label]}%
{\goto{\labeltexts\v!page\dummyreference}[#label]}}
-%D The other alternatives just conform their names: only the
-%D label, only the text, or the label and the text.
+% Someone requested this but in retrospect didn't need it so we keep it as example.
+% Beware: a node is injected which is why we add ignorespaces!
+%
+% \unexpanded\def\strc_references_conditional#action#text[#condition]#dummy[#label]%
+% {\doifcheckedpagestate{#label}%
+% {\doifelse{#condition}\v!precedingpage{#action{#text}[#label]}\ignorespaces}%
+% {\doifelse{#condition}\v!hencefore {#action{#text}[#label]}\ignorespaces}%
+% {\doifelse{#condition}\v!current {#action{#text}[#label]}\ignorespaces}%
+% {\doifelse{#condition}\v!hereafter {#action{#text}[#label]}\ignorespaces}%
+% {\doifelse{#condition}\v!followingpage{#action{#text}[#label]}\ignorespaces}%
+% {#label}}
+%
+% \unexpanded\def\conditionalat {\strc_references_conditional\at}
+% \unexpanded\def\conditionalin {\strc_references_conditional\in}
+% \unexpanded\def\conditionalabout{\strc_references_conditional\about}
+
+%D The other alternatives just conform their names: only the label, only the text, or the
+%D label and the text.
% \dounknownreference -> \dummyreference
diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua
index e368eae37..30dd19ea3 100644
--- a/tex/context/base/strc-tag.lua
+++ b/tex/context/base/strc-tag.lua
@@ -8,9 +8,10 @@ if not modules then modules = { } end modules ['strc-tag'] = {
-- This is rather experimental code.
+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 = lpeg.match
+local lpegmatch, P, S, C = lpeg.match, lpeg.P, lpeg.S, lpeg.C
local texattribute = tex.attribute
local allocate = utilities.storage.allocate
local settings_to_hash = utilities.parsers.settings_to_hash
@@ -26,23 +27,26 @@ local a_tagged = attributes.private('tagged')
local unsetvalue = attributes.unsetvalue
local codeinjections = backends.codeinjections
-local taglist = allocate()
-local properties = allocate()
-local labels = allocate()
-local stack = { }
-local chain = { }
-local ids = { }
-local enabled = false
-local tagdata = { } -- used in export
-local tagmetadata = { } -- used in export
-
-local tags = structures.tags
-tags.taglist = taglist -- can best be hidden
-tags.labels = labels
-tags.data = tagdata
-tags.metadata = tagmetadata
-
-local properties = allocate {
+local taglist = allocate()
+local properties = allocate()
+local userproperties = allocate()
+local labels = allocate()
+local stack = { }
+local chain = { }
+local ids = { }
+local enabled = false
+local tagdata = { } -- used in export
+local tagmetadata = { } -- used in export
+local tagcontext = { }
+
+local tags = structures.tags
+tags.taglist = taglist -- can best be hidden
+tags.labels = labels
+tags.data = tagdata
+tags.metadata = tagmetadata
+tags.userproperties = userproperties -- used in backend
+
+local properties = allocate {
document = { pdf = "Div", nature = "display" },
@@ -244,14 +248,6 @@ function tags.start(tag,specification)
enabled = true
end
--
---~ labels[tag] = label ~= "" and label or tag
---~ local fulltag
---~ if detail and detail ~= "" then
---~ fulltag = tag .. ":" .. detail
---~ else
---~ fulltag = tag
---~ end
- --
local fulltag = label ~= "" and label or tag
labels[tag] = fulltag
if detail and detail ~= "" then
@@ -266,6 +262,9 @@ function tags.start(tag,specification)
nstack = nstack + 1
chain[nstack] = completetag
stack[nstack] = t
+ --
+ tagcontext[tag] = completetag
+ --
-- a copy as we can add key values for alt and actualtext if needed:
taglist[t] = { unpack(chain,1,nstack) }
--
@@ -319,10 +318,44 @@ function tags.last(tag)
return lasttags[tag] -- or false
end
-function tags.lastinchain()
- return chain[nstack]
+function tags.lastinchain(tag)
+ if tag and tag ~= "" then
+ return tagcontext[tag]
+ else
+ return chain[nstack]
+ end
+end
+
+local strip = C((1-S(":-"))^1)
+
+commands.getelementtag = function()
+ local fulltag = chain[nstack]
+ if fulltag then
+ context(lpegmatch(strip,fulltag))
+ end
+end
+
+function tags.setuserproperties(tag,list)
+ if list then
+ tag = tagcontext[tag]
+ else
+ tag, list = chain[nstack], tag
+ end
+ if tag then
+ local l = settings_to_hash(list)
+ local p = userproperties[tag]
+ if p then
+ for k, v in next, l do
+ p[k] = v
+ end
+ else
+ userproperties[tag] = l
+ end
+ end
end
+commands.setelementuserproperties = tags.setuserproperties
+
function structures.atlocation(str)
local location = gsub(concat(taglist[texattribute[a_tagged]],"-"),"%-%d+","")
return find(location,topattern(str)) ~= nil
diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv
index 7e15be4a3..83eb3c142 100644
--- a/tex/context/base/strc-tag.mkiv
+++ b/tex/context/base/strc-tag.mkiv
@@ -239,6 +239,38 @@
{\let\dostarttagged\strc_tags_start_nop
\let\dostoptagged \strc_tags_stop_nop}
+% for luigi (beware: fully expandable):
+
+\def\strc_tags_get_element_tag_yes{\ctxcommand{getelementtag()}}
+\let\strc_tags_get_element_tag_nop\donothing
+
+\unexpanded\def\strc_tags_setup_element_user_properties_yes
+ {\dodoubleempty\strc_tags_setup_element_user_properties_indeed}
+
+\unexpanded\def\strc_tags_setup_element_user_properties_nop
+ {\dodoubleempty\strc_tags_setup_element_user_properties_indeed_nop}
+
+\def\strc_tags_setup_element_user_properties_indeed
+ {\iftrialtypesetting
+ \expandafter \strc_tags_setup_element_user_properties_indeed_nop
+ \else\ifsecondargument
+ \doubleexpandafter\strc_tags_setup_element_user_properties_indeed_two
+ \else
+ \doubleexpandafter\strc_tags_setup_element_user_properties_indeed_one
+ \fi\fi}
+
+\def\strc_tags_setup_element_user_properties_indeed_nop[#1][#2]{}
+\def\strc_tags_setup_element_user_properties_indeed_one[#1][#2]{\ctxcommand{setelementuserproperties(\!!bs#1\!!es)}}
+\def\strc_tags_setup_element_user_properties_indeed_two[#1][#2]{\ctxcommand{setelementuserproperties("#1",\!!bs#2\!!es)}}
+
+\unexpanded\def\strc_tags_enable_properties
+ {\let\getelementtag \strc_tags_get_element_tag_yes
+ \let\setupelementuserproperties\strc_tags_setup_element_user_properties_yes}
+
+\unexpanded\def\strc_tags_disable_properties
+ {\let\getelementtag \strc_tags_get_element_tag_nop
+ \let\setupelementuserproperties\strc_tags_setup_element_user_properties_nop}
+
%D The triggers:
\newtoks\everyenableelements
@@ -246,11 +278,13 @@
\appendtoks
\strc_tags_enable_elements
+ \strc_tags_enable_properties
\doifelse{\taggingparameter\c!method}\v!auto\strc_tags_enable\strc_tags_disable
\to \everyenableelements
\appendtoks
\strc_tags_disable_elements
+ \strc_tags_disable_properties
\strc_tags_disable
\to \everydisableelements
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 9eab657a1..cab6c4abe 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 : 07/25/14 12:57:26
+-- merge date : 07/26/14 10:44:39
do -- begin closure to overcome local limits and interference