summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua106
1 files changed, 36 insertions, 70 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
index 0453640ca00..649465a6ada 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-tag.lua
@@ -15,6 +15,7 @@ local type, next = type, next
local insert, remove, unpack, concat, merge = table.insert, table.remove, table.unpack, table.concat, table.merge
local find, topattern, format = string.find, string.topattern, string.format
local lpegmatch, P, S, C, Cc = lpeg.match, lpeg.P, lpeg.S, lpeg.C, lpeg.Cc
+local texattribute = tex.attribute
local allocate = utilities.storage.allocate
local settings_to_hash = utilities.parsers.settings_to_hash
local setmetatableindex = table.setmetatableindex
@@ -23,44 +24,34 @@ local trace_tags = false trackers.register("structures.tags", function(v) trace
local report_tags = logs.reporter("structure","tags")
-local attributes = attributes
-local structures = structures
-local implement = interfaces.implement
-
-local a_tagged = attributes.private('tagged')
-
-local unsetvalue = attributes.unsetvalue
-local codeinjections = backends.codeinjections
-
-local texgetattribute = tex.getattribute
-local texsetattribute = tex.setattribute
-
-local taglist = allocate() -- access by attribute
-local specifications = allocate() -- access by fulltag
-local labels = allocate()
-local stack = { }
-local chain = { }
-local ids = { }
-local enabled = false
-local tagcontext = { }
-local tagpatterns = { }
-local lasttags = { }
-local stacksize = 0
-local metadata = nil -- applied to the next element
-local documentdata = { }
-local extradata = false
-
-local tags = structures.tags
-tags.taglist = taglist -- can best be hidden
-tags.labels = labels
-tags.patterns = tagpatterns
-tags.specifications = specifications
-
-function tags.current()
- if stacksize > 0 then
- return stack[stacksize] -- maybe copy or proxy
- end
-end
+local attributes = attributes
+local structures = structures
+local implement = interfaces.implement
+
+local a_tagged = attributes.private('tagged')
+
+local unsetvalue = attributes.unsetvalue
+local codeinjections = backends.codeinjections
+
+local taglist = allocate() -- access by attribute
+local specifications = allocate() -- access by fulltag
+local labels = allocate()
+local stack = { }
+local chain = { }
+local ids = { }
+local enabled = false
+local tagcontext = { }
+local tagpatterns = { }
+local lasttags = { }
+local stacksize = 0
+local metadata = nil -- applied to the next element
+local documentdata = { }
+
+local tags = structures.tags
+tags.taglist = taglist -- can best be hidden
+tags.labels = labels
+tags.patterns = tagpatterns
+tags.specifications = specifications
-- Tags are internally stored as:
--
@@ -135,7 +126,6 @@ local properties = allocate { -- todo: more "record = true" to improve forma
listcontent = { pdf = "P", nature = "mixed" },
listdata = { pdf = "P", nature = "mixed" },
listpage = { pdf = "Reference", nature = "mixed" },
- listtext = { pdf = "Span", nature = "inline" },
delimitedblock = { pdf = "BlockQuote", nature = "display" },
delimited = { pdf = "Quote", nature = "inline" },
@@ -167,11 +157,9 @@ local properties = allocate { -- todo: more "record = true" to improve forma
subformula = { pdf = "Div", nature = "display" },
link = { pdf = "Link", nature = "inline" },
- reference = { pdf = "Span", nature = "inline" },
margintextblock = { pdf = "Span", nature = "inline" },
margintext = { pdf = "Span", nature = "inline" },
- marginanchor = { pdf = "Span", nature = "inline" },
math = { pdf = "Div", nature = "inline" }, -- no display
mn = { pdf = "Span", nature = "mixed" },
@@ -216,14 +204,6 @@ local properties = allocate { -- todo: more "record = true" to improve forma
combinationpair = { pdf = "Span", nature = "display" },
combinationcontent = { pdf = "Span", nature = "mixed" },
combinationcaption = { pdf = "Span", nature = "mixed" },
-
- publications = { pdf = "Div", nature = "display" },
- publication = { pdf = "Div", nature = "mixed" },
- pubfld = { pdf = "Span", nature = "inline" },
-
- block = { pdf = "Div", nature = "display" },
- userdata = { pdf = "Div", nature = "display" },
-
}
tags.properties = properties
@@ -235,7 +215,7 @@ local patterns = setmetatableindex(function(t,tag)
end)
function tags.locatedtag(tag)
- local attribute = texgetattribute(a_tagged)
+ local attribute = texattribute[a_tagged]
if attribute >= 0 then
local specification = taglist[attribute]
if specification then
@@ -255,7 +235,7 @@ function tags.locatedtag(tag)
end
function structures.atlocation(str)
- local specification = taglist[texgetattribute(a_tagged)]
+ local specification = taglist[texattribute[a_tagged]]
if specification then
if list then
local taglist = specification.taglist
@@ -307,20 +287,6 @@ function tags.getmetadata()
return documentdata or { }
end
-function tags.registerextradata(name,serializer)
- if type(serializer) == "function" then
- if extradata then
- extradata[name] = serializer
- else
- extradata = { [name] = serializer }
- end
- end
-end
-
-function tags.getextradata()
- return extradata
-end
-
function tags.start(tag,specification)
if not enabled then
codeinjections.enabletags()
@@ -383,7 +349,7 @@ function tags.start(tag,specification)
specification.metadata = documentdata
end
--
- texsetattribute(a_tagged,attribute)
+ texattribute[a_tagged] = attribute
return attribute
end
@@ -398,7 +364,7 @@ function tags.restart(attribute)
taglist[attribute] = { taglist = { unpack(chain,1,stacksize) } }
end
stack[stacksize] = attribute
- texsetattribute(a_tagged,attribute)
+ texattribute[a_tagged] = attribute
return attribute
end
@@ -408,12 +374,12 @@ function tags.stop()
end
local t = stack[stacksize]
if not t then
- if trace_tags then
+ -- if trace_tags then
report_tags("ignoring end tag, previous chain: %s",stacksize > 0 and concat(chain," ",1,stacksize) or "none")
- end
+ -- end
t = unsetvalue
end
- texsetattribute(a_tagged,t)
+ texattribute[a_tagged] = t
return t
end