Skip to content

Commit

Permalink
Merge 1521b32 into 84771ae
Browse files Browse the repository at this point in the history
  • Loading branch information
jodros committed Dec 27, 2023
2 parents 84771ae + 1521b32 commit f1c689b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/folio/init.lua
Expand Up @@ -7,6 +7,8 @@ function package.incrementFolio (_)
SILE.scratch.counters.folio.value = SILE.scratch.counters.folio.value + 1
end

local isFolioFrame

function package:outputFolio (frame)
if not frame then frame = "folio" end
local folio = self.class.packages.counters:formatCounter(SILE.scratch.counters.folio)
Expand All @@ -18,8 +20,9 @@ function package:outputFolio (frame)
SILE.scratch.counters.folio.off = false
end
else
local folioFrame = SILE.getFrame(frame)
if (folioFrame) then
local success, folioFrame = pcall(SILE.getFrame(frame))
isFolioFrame = success
if success then
SILE.typesetNaturally(folioFrame, function ()
SILE.settings:pushState()
-- Restore the settings to the top of the queue, which should be the document #986
Expand Down Expand Up @@ -48,7 +51,7 @@ function package:_init (options)
self:loadPackage("counters")
SILE.scratch.counters.folio = { value = 1, display = "arabic" }
self.class:registerHook("newpage", function() self:incrementFolio() end)
self.class:registerHook("endpage", function () self:outputFolio(options and options.frame) end)
self.class:registerHook("endpage", function () if isFolioFrame then self:outputFolio(options and options.frame) end end)
self:export("outputFolio", self.outputFolio)
end

Expand Down

0 comments on commit f1c689b

Please sign in to comment.