From f210bce174e1f2f05305ab03e88e120a1cbfc4da Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 5 Mar 2020 00:48:46 +0000 Subject: 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 --- .../texmf-dist/tex/context/base/mkiv/strc-pag.lua | 37 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua') 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) -- cgit v1.2.3