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

sile-typesetter / sile / 10722271004

05 Sep 2024 02:19PM UTC coverage: 62.464% (+22.2%) from 40.279%
10722271004

push

github

alerque
chore(tooling): Update build-time error messages with current argument suggestion

10895 of 17442 relevant lines covered (62.46%)

5172.6 hits per line

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

87.88
/packages/footnotes/init.lua
1
local base = require("packages.base")
7✔
2

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

6
function package:_init (options)
7✔
7
   base._init(self)
7✔
8
   self:loadPackage("counters")
7✔
9
   self:loadPackage("raiselower")
7✔
10
   self:loadPackage("insertions")
7✔
11
   if not SILE.scratch.counters.footnotes then
7✔
12
      SILE.scratch.counters.footnote = { value = 1, display = "arabic" }
7✔
13
   end
14
   options = options or {}
7✔
15
   self.class:initInsertionClass("footnote", {
14✔
16
      insertInto = options.insertInto or "footnotes",
7✔
17
      stealFrom = options.stealFrom or { "content" },
7✔
18
      maxHeight = SILE.types.length("75%ph"),
14✔
19
      topBox = SILE.types.node.vglue("2ex"),
14✔
20
      interInsertionSkip = SILE.types.length("1ex"),
14✔
21
   })
22
end
23

24
function package:registerCommands ()
7✔
25
   self:registerCommand("footnotemark", function (_, _)
14✔
26
      SILE.call("raise", { height = "0.7ex" }, function ()
6✔
27
         SILE.call("font", { size = "1.5ex" }, function ()
6✔
28
            SILE.typesetter:typeset(self.class.packages.counters:formatCounter(SILE.scratch.counters.footnote))
6✔
29
         end)
30
      end)
31
   end)
32

33
   self:registerCommand("footnote:separator", function (_, content)
14✔
34
      SILE.settings:pushState()
×
35
      local material = SILE.call("vbox", {}, content)
×
36
      SILE.scratch.insertions.classes.footnote.topBox = material
×
37
      SILE.settings:popState()
×
38
   end)
39

40
   self:registerCommand("footnote:options", function (options, _)
14✔
41
      if options["maxHeight"] then
×
42
         SILE.scratch.insertions.classes.footnote.maxHeight = SILE.types.length(options["maxHeight"])
×
43
      end
44
      if options["interInsertionSkip"] then
×
45
         SILE.scratch.insertions.classes.footnote.interInsertionSkip = SILE.types.length(options["interInsertionSkip"])
×
46
      end
47
   end)
48

49
   self:registerCommand("footnote", function (options, content)
14✔
50
      SILE.call("footnotemark")
3✔
51
      local opts = SILE.scratch.insertions.classes.footnote or {}
3✔
52
      local frame = opts.insertInto and SILE.getFrame(opts.insertInto.frame)
3✔
53
      local oldGetTargetLength = SILE.typesetter.getTargetLength
3✔
54
      local oldFrame = SILE.typesetter.frame
3✔
55
      SILE.typesetter.getTargetLength = function ()
3✔
56
         return SILE.types.length(0xFFFFFF)
4✔
57
      end
58
      SILE.settings:pushState()
3✔
59
      -- Restore the settings to the top of the queue, which should be the document #986
60
      SILE.settings:toplevelState()
3✔
61
      SILE.typesetter:initFrame(frame)
3✔
62

63
      -- Reset settings the document may have but should not be applied to footnotes
64
      -- See also same resets in folio package
65
      for _, v in ipairs({
18✔
66
         "current.hangAfter",
67
         "current.hangIndent",
68
         "linebreak.hangAfter",
69
         "linebreak.hangIndent",
70
      }) do
3✔
71
         SILE.settings:set(v, SILE.settings.defaults[v])
12✔
72
      end
73

74
      -- Apply the font before boxing, so relative baselineskip applies #1027
75
      local material
76
      SILE.call("footnote:font", {}, function ()
6✔
77
         material = SILE.call("vbox", {}, function ()
6✔
78
            SILE.call("footnote:atstart", options)
3✔
79
            SILE.call("footnote:counter", options)
3✔
80
            SILE.process(content)
3✔
81
         end)
82
      end)
83
      SILE.settings:popState()
3✔
84
      SILE.typesetter.getTargetLength = oldGetTargetLength
3✔
85
      SILE.typesetter.frame = oldFrame
3✔
86
      self.class:insert("footnote", material)
3✔
87
      SILE.scratch.counters.footnote.value = SILE.scratch.counters.footnote.value + 1
3✔
88
   end)
89

90
   self:registerCommand("footnote:font", function (_, content)
14✔
91
      -- The footnote frame has is settings reset to the toplevel state, so if one does
92
      -- something relative (as below), it is expected to be the main value from the
93
      -- document.
94
      SILE.call("font", { size = SILE.settings:get("font.size") * 0.9 }, function ()
9✔
95
         SILE.process(content)
3✔
96
      end)
97
   end)
98

99
   self:registerCommand("footnote:atstart", function (_, _) end)
10✔
100

101
   self:registerCommand("footnote:counter", function (_, _)
14✔
102
      SILE.call("noindent")
3✔
103
      SILE.typesetter:typeset(self.class.packages.counters:formatCounter(SILE.scratch.counters.footnote) .. ".")
6✔
104
      SILE.call("qquad")
3✔
105
   end)
106
end
107

108
package.documentation = [[
109
\begin{document}
110
The \autodoc:package{footnotes} package allows you to add footnotes to text with the \autodoc:command{\footnote} command.
111
Other commands provided by the package, not described here, take care of formatting the footnotes.
112

113
Usually, a document class is responsible for automatically loading this package.
114
Minimally, upon initialization, it needs a frame identifier for the the footnotes, and one or more frame(s) which will be reduced as the footnotes take place.
115
By default, it uses, respectively, the \code{footnotes} and \code{content} frames, which are assumed to be present in the default standard layout.
116

117
For the record, it internally relies on the \autodoc:package{insertions} package and tells it which frame should receive the footnotes that are typeset.
118
\end{document}
119
]]
7✔
120

121
return package
7✔
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