diff --git a/packages/folio/init.lua b/packages/folio/init.lua index 85e4c00e7c..61e342c19a 100644 --- a/packages/folio/init.lua +++ b/packages/folio/init.lua @@ -18,8 +18,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 @@ -48,7 +49,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