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

sile-typesetter / sile / 9507147410

13 Jun 2024 09:40PM UTC coverage: 50.521% (-18.7%) from 69.177%
9507147410

push

github

web-flow
Merge pull request #2062 from alerque/plug-fluent-leak

Link document.language setting more closely with Fluent locale

15 of 15 new or added lines in 3 files covered. (100.0%)

3244 existing lines in 65 files now uncovered.

8586 of 16995 relevant lines covered (50.52%)

4659.09 hits per line

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

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

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

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

10
function package:outputFolio (frame)
4✔
11
   if not frame then
4✔
12
      frame = "folio"
4✔
13
   end
14
   local folio = self.class.packages.counters:formatCounter(SILE.scratch.counters.folio)
4✔
15
   if not SILE.quiet then
4✔
16
      io.stderr:write("[" .. folio .. "] ")
4✔
17
   end
18
   if SILE.scratch.counters.folio.off then
4✔
19
      if SILE.scratch.counters.folio.off == 2 then
1✔
UNCOV
20
         SILE.scratch.counters.folio.off = false
×
21
      end
22
   else
23
      local folioFrame = SILE.getFrame(frame)
3✔
24
      if folioFrame then
3✔
25
         SILE.typesetNaturally(folioFrame, function ()
6✔
26
            SILE.settings:pushState()
3✔
27
            -- Restore the settings to the top of the queue, which should be the document #986
28
            SILE.settings:toplevelState()
3✔
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({
18✔
33
               "current.hangAfter",
34
               "current.hangIndent",
35
               "linebreak.hangAfter",
36
               "linebreak.hangIndent",
37
            }) do
3✔
38
               SILE.settings:set(v, SILE.settings.defaults[v])
12✔
39
            end
40

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

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

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

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

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

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

79
   self:registerCommand("foliostyle", function (_, content)
8✔
80
      SILE.call("center", {}, content)
3✔
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
]]
4✔
108

109
return package
4✔
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