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

sile-typesetter / sile / 11645827362

02 Nov 2024 09:08PM UTC coverage: 54.19% (-15.2%) from 69.34%
11645827362

push

github

web-flow
Merge pull request #2151 from Omikhleia/math-more-fixes-and-features

Math more fixes and features

103 of 208 new or added lines in 4 files covered. (49.52%)

2652 existing lines in 91 files now uncovered.

9816 of 18114 relevant lines covered (54.19%)

671.83 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")
18✔
2

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

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

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

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

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

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

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

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

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

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

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