summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-pag.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-pag.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-pag.lua77
1 files changed, 47 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-pag.lua b/Master/texmf-dist/tex/context/base/strc-pag.lua
index bce8a2c3a4e..460d4ff008e 100644
--- a/Master/texmf-dist/tex/context/base/strc-pag.lua
+++ b/Master/texmf-dist/tex/context/base/strc-pag.lua
@@ -8,26 +8,29 @@ if not modules then modules = { } end modules ['strc-pag'] = {
local texcount, format = tex.count, string.format
-local ctxcatcodes = tex.ctxcatcodes
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
-local trace_pages = false trackers.register("structures.pages", function(v) trace_pages = v end)
+local trace_pages = false trackers.register("structures.pages", function(v) trace_pages = v end)
-local report_pages = logs.reporter("structure","pages")
+local report_pages = logs.reporter("structure","pages")
-local structures = structures
+local structures = structures
-local helpers = structures.helpers
-local sections = structures.sections
-local pages = structures.pages
-local processors = structures.processors
-local sets = structures.sets
-local counters = structures.counters
+local helpers = structures.helpers
+local sections = structures.sections
+local pages = structures.pages
+local sets = structures.sets
+local counters = structures.counters
-local counterdata = counters.data
+local counterdata = counters.data
-local variables = interfaces.variables
-local context = context
+local variables = interfaces.variables
+local context = context
+
+local processors = typesetters.processors
+local applyprocessor = processors.apply
+local startapplyprocessor = processors.startapply
+local stopapplyprocessor = processors.stopapply
-- storage
@@ -52,8 +55,8 @@ function pages.save(prefixdata,numberdata)
report_pages("saving page %s.%s",realpage,userpage)
end
local data = {
- number = userpage,
- block = sections.currentblock(),
+ number = userpage,
+ block = sections.currentblock(),
prefixdata = prefixdata and helpers.simplify(prefixdata),
numberdata = numberdata and helpers.simplify(numberdata),
}
@@ -91,17 +94,19 @@ function pages.number(realdata,pagespec)
local starter = (pagespec and pagespec.starter ~= "" and pagespec.starter ) or (numberspec and numberspec.starter ~= "" and numberspec.starter ) or ""
local stopper = (pagespec and pagespec.stopper ~= "" and pagespec.stopper ) or (numberspec and numberspec.stopper ~= "" and numberspec.stopper ) or ""
if starter ~= "" then
- processors.sprint(ctxcatcodes,starter)
+ applyprocessor(starter)
end
if conversion ~= "" then
context.convertnumber(conversion,userpage)
else
if conversionset == "" then conversionset = "default" end
local theconversion = sets.get("structure:conversions",block,conversionset,1,"numbers") -- to be checked: 1
- processors.sprint(ctxcatcodes,theconversion,convertnumber,userpage)
+ local data = startapplyprocessor(theconversion)
+ context.convertnumber(data or "number",userpage)
+ stopapplyprocessor()
end
if stopper ~= "" then
- processors.sprint(ctxcatcodes,stopper)
+ applyprocessors(stopper)
end
end
@@ -116,17 +121,29 @@ function pages.analyze(entry,pagespecification)
if not references then
return false, false, "no references"
end
- local realpage = references.realpage
- if not realpage then
- return false, false, "no realpage"
+ local pagedata = references.pagedata -- sometimes resolved (external)
+ if not pagedata then
+ local realpage = references.realpage
+ if realpage then
+ pagedata = collected[realpage]
+ else
+ return false, false, "no realpage"
+ end
end
- local pagedata = collected[realpage]
if not pagedata then
return false, false, "no pagedata"
end
- local section = references.section
- if not section then
- return pagedata, false, "no section"
+ local sectiondata = references.sectiondata -- sometimes resolved (external)
+ if not sectiondata then
+ local section = references.section
+ if section then
+ sectiondata = sections.collected[section]
+ else
+ return pagedata, false, "no section"
+ end
+ end
+ if not sectiondata then
+ return pagedata, false, "no sectiondata"
end
local no = variables.no
-- local preferences
@@ -134,16 +151,16 @@ function pages.analyze(entry,pagespecification)
return pagedata, false, "current spec blocks prefix"
end
-- stored preferences
---~ if entry.prefix == no then
---~ return pagedata, false, "entry blocks prefix"
---~ end
+ -- if entry.prefix == no then
+ -- return pagedata, false, "entry blocks prefix"
+ -- end
-- stored page state
pagespecification = pagedata.prefixdata
if pagespecification and pagespecification.prefix == no then
return pagedata, false, "pagedata blocks prefix"
end
-- final verdict
- return pagedata, sections.collected[references.section], "okay"
+ return pagedata, sectiondata, "okay"
end
function helpers.page(data,pagespec)
@@ -271,7 +288,7 @@ function counters.analyze(name,counterspecification)
return cd, sectiondata, "okay"
end
-function counters.prefixedconverted(name,prefixspec,numberspec)
+function sections.prefixedconverted(name,prefixspec,numberspec)
local cd, prefixdata, result = counters.analyze(name,prefixspec)
if cd then
if prefixdata then