summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-03-05 00:48:46 +0000
committerKarl Berry <karl@freefriends.org>2020-03-05 00:48:46 +0000
commitf210bce174e1f2f05305ab03e88e120a1cbfc4da (patch)
tree5c4e2ad096b5c745e859516ac3196fa0864292d5 /Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
parent35fd641a3546acc0c62e0aa7f134888e36da30d4 (diff)
context (from cont-tmf.zip of Feb 17 16:00, size 116339406)
git-svn-id: svn://tug.org/texlive/trunk@54086 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua37
1 files changed, 30 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
index ee1b245b99b..9b3a77e741f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua
@@ -45,10 +45,21 @@ pages.collected = collected
pages.tobesaved = tobesaved
pages.nofpages = 0
+-- utilitydata.structures.counters.collected.realpage[1]
+
local function initializer()
collected = pages.collected
tobesaved = pages.tobesaved
- pages.nofpages = #collected
+ -- tricky, with pageinjection we can have holes
+ -- pages.nofpages = #collected
+ -- pages.nofpages = table.count(collected) -- could be a helper
+ local n = 0
+ for k in next, collected do
+ if k > n then
+ n = k
+ end
+ end
+ pages.nofpages = n
end
job.register('structures.pages.collected', tobesaved, initializer)
@@ -172,18 +183,18 @@ function pages.analyze(entry,pagespecification)
if not sectiondata then
return pagedata, false, "no sectiondata"
end
- local no = variables.no
+ local v_no = variables.no
-- local preferences
- if pagespecification and pagespecification.prefix == no then
+ if pagespecification and pagespecification.prefix == v_no then
return pagedata, false, "current spec blocks prefix"
end
-- stored preferences
- -- if entry.prefix == no then
+ -- if entry.prefix == v_no then
-- return pagedata, false, "entry blocks prefix"
-- end
-- stored page state
pagespecification = pagedata.prefixdata
- if pagespecification and pagespecification.prefix == no then
+ if pagespecification and pagespecification.prefix == v_no then
return pagedata, false, "pagedata blocks prefix"
end
-- final verdict
@@ -258,11 +269,18 @@ function helpers.analyze(entry,specification)
return entry, sectiondata, "okay"
end
-function helpers.prefix(data,prefixspec)
+function helpers.prefix(data,prefixspec,nosuffix)
if data then
local _, prefixdata, status = helpers.analyze(data,prefixspec)
if prefixdata then
- sections.typesetnumber(prefixdata,"prefix",prefixspec or false,data.prefixdata or false,prefixdata or false)
+ if nosuffix and prefixspec then
+ local connector = prefixspec.connector
+ prefixspec.connector = nil
+ sections.typesetnumber(prefixdata,"prefix",prefixspec or false,data.prefixdata or false,prefixdata or false)
+ prefixspec.connector = connector
+ else
+ sections.typesetnumber(prefixdata,"prefix",prefixspec or false,data.prefixdata or false,prefixdata or false)
+ end
end
end
end
@@ -305,6 +323,11 @@ function pages.in_body(n)
return texgetcount("pagebodymode") > 0
end
+function pages.fraction(n)
+ local lastpage = texgetcount("lastpageno") -- can be cached
+ return lastpage > 1 and (texgetcount("realpageno")-1)/(lastpage-1) or 1
+end
+
-- move to strc-pag.lua
function counters.analyze(name,counterspecification)