• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.83
/packages/folio/init.lua
1
local base = require("packages.base")
181✔
2

3
local package = pl.class(base)
181✔
4
package._name = "folio"
181✔
5

6
function package.incrementFolio (_)
181✔
7
   SILE.scratch.counters.folio.value = SILE.scratch.counters.folio.value + 1
55✔
8
end
9

10
function package:outputFolio (frame)
181✔
11
   if not frame then
236✔
12
      frame = "folio"
236✔
13
   end
14
   local folio = self.class.packages.counters:formatCounter(SILE.scratch.counters.folio)
236✔
15
   if not SILE.quiet then
236✔
16
      io.stderr:write("[" .. folio .. "] ")
236✔
17
   end
18
   if SILE.scratch.counters.folio.off then
236✔
19
      if SILE.scratch.counters.folio.off == 2 then
147✔
20
         SILE.scratch.counters.folio.off = false
4✔
21
      end
22
   else
23
      local folioFrame = SILE.getFrame(frame)
89✔
24
      if folioFrame then
89✔
25
         SILE.typesetNaturally(folioFrame, function ()
176✔
26
            SILE.settings:pushState()
88✔
27
            -- Restore the settings to the top of the queue, which should be the document #986
28
            SILE.settings:toplevelState()
88✔
29

30
            -- Reset settings the document may have but should not be applied to footnotes
31
            -- See also same resets in footnote package
32
            for _, v in ipairs({
528✔
33
               "current.hangAfter",
34
               "current.hangIndent",
35
               "linebreak.hangAfter",
36
               "linebreak.hangIndent",
37
            }) do
88✔
38
               SILE.settings:set(v, SILE.settings.defaults[v])
352✔
39
            end
40

41
            SILE.call("foliostyle", {}, { folio })
88✔
42
            SILE.typesetter:leaveHmode()
88✔
43
            SILE.settings:popState()
88✔
44
         end)
45
      end
46
   end
47
end
48

49
function package:_init (options)
181✔
50
   base._init(self)
181✔
51
   self:loadPackage("counters")
181✔
52
   SILE.scratch.counters.folio = { value = 1, display = "arabic" }
181✔
53
   self.class:registerHook("newpage", function ()
362✔
54
      self:incrementFolio()
55✔
55
   end)
56
   self.class:registerHook("endpage", function ()
362✔
57
      self:outputFolio(options and options.frame)
236✔
58
   end)
59
   self:export("outputFolio", self.outputFolio)
181✔
60
end
61

62
function package:registerCommands ()
181✔
63
   self:registerCommand("folios", function (_, _)
362✔
NEW
64
      SILE.scratch.counters.folio.off = false
×
65
   end)
66

67
   self:registerCommand("nofolios", function (_, _)
362✔
68
      SILE.scratch.counters.folio.off = true
117✔
69
   end)
70

71
   self:registerCommand("nofoliothispage", function (_, _)
362✔
72
      SILE.scratch.counters.folio.off = 2
7✔
73
   end)
74

75
   self:registerCommand("nofoliosthispage", function (_, _)
362✔
NEW
76
      SU.deprecated("nofoliosthispage", "nofoliothispage", "0.12.1", "0.14.0")
×
77
   end, "Deprecated")
181✔
78

79
   self:registerCommand("foliostyle", function (_, content)
362✔
80
      SILE.call("center", {}, content)
88✔
81
   end)
82
end
83

84
package.documentation = [[
85
\begin{document}
86
The \autodoc:package{folio} package (which is automatically loaded by the \autodoc:class{plain} class, and therefore by nearly every SILE class) controls the output of folios—the old-time typesetter word for page numbers.
87

88
It provides four commands to users:
89

90
\begin{itemize}
91
\item{\autodoc:command{\nofolios}: turns page numbers off.}
92
\item{\autodoc:command{\nofoliothispage}: turns page numbers off for one page, then on again afterward.}
93
\item{\autodoc:command{\folios}: turns page numbers back on.}
94
\item{\autodoc:command{\foliostyle}: a command you can override to style the page numbers. By default, they are centered on the page.}
95
\end{itemize}
96

97
If, for instance, you want to set page numbers in a different font you can redefine the command like so:
98

99
\begin[type=autodoc:codeblock]{raw}
100
\define[command=foliostyle]{\center{\font[family=Albertus]{\process}}}
101
\end{raw}
102

103
If you want to put page numbers on the left side of even pages and the right side of odd pages, there are a couple of ways you can do that.
104
The complicated way is to define a command in Lua which inspects the page number and then sets the number ragged left or ragged right appropriately.
105
The easy way is just to put your folio frame where you want it on the master page.
106
\end{document}
107
]]
181✔
108

109
return package
181✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc