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

sile-typesetter / sile / 14502192980

16 Apr 2025 08:26PM UTC coverage: 57.267% (-5.4%) from 62.627%
14502192980

push

github

alerque
chore(packages): Remove unused package interdependency, url doesn't need verbatim

Reported-by: Omikhleia <didier.willis@gmail.com>

12352 of 21569 relevant lines covered (57.27%)

871.56 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")
4✔
2

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

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

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

33
   self:registerCommand("footnote:separator", function (_, content)
8✔
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, _)
8✔
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)
8✔
50
      SILE.call("footnotemark")
1✔
51
      local opts = SILE.scratch.insertions.classes.footnote or {}
1✔
52
      local frame = opts.insertInto and SILE.getFrame(opts.insertInto.frame)
1✔
53
      local oldGetTargetLength = SILE.typesetter.getTargetLength
1✔
54
      local oldFrame = SILE.typesetter.frame
1✔
55
      SILE.typesetter.getTargetLength = function ()
1✔
56
         return SILE.types.length(0xFFFFFF)
4✔
57
      end
58
      SILE.settings:pushState()
1✔
59
      -- Restore the settings to the top of the queue, which should be the document #986
60
      SILE.settings:toplevelState()
1✔
61
      SILE.typesetter:initFrame(frame)
1✔
62
      -- Reset settings the document may have but should not be applied to footnotes
63
      -- See also same resets in folio package
64
      for _, v in ipairs({
6✔
65
         "current.hangAfter",
66
         "current.hangIndent",
67
         "linebreak.hangAfter",
68
         "linebreak.hangIndent",
69
      }) do
1✔
70
         SILE.settings:set(v, SILE.settings.defaults[v])
4✔
71
      end
72
      -- Apply the font before boxing, so relative baselineskip applies #1027
73
      local material
74
      SILE.call("footnote:font", {}, function ()
2✔
75
         material = SILE.call("vbox", {}, function ()
2✔
76
            SILE.call("footnote:atstart", options)
1✔
77
            SILE.call("footnote:counter", options)
1✔
78
            SILE.process(content)
1✔
79
         end)
80
      end)
81
      SILE.settings:popState()
1✔
82
      SILE.typesetter.getTargetLength = oldGetTargetLength
1✔
83
      SILE.typesetter.frame = oldFrame
1✔
84
      self.class:insert("footnote", material)
1✔
85
      SILE.scratch.counters.footnote.value = SILE.scratch.counters.footnote.value + 1
1✔
86
   end)
87

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

97
   self:registerCommand("footnote:atstart", function (_, _) end)
5✔
98

99
   self:registerCommand("footnote:counter", function (_, _)
8✔
100
      SILE.call("noindent")
1✔
101
      SILE.typesetter:typeset(self.class.packages.counters:formatCounter(SILE.scratch.counters.footnote) .. ".")
2✔
102
      SILE.call("qquad")
1✔
103
   end)
104
end
105

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

111
Usually, a document class is responsible for automatically loading this package.
112
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.
113
By default, it uses, respectively, the \code{footnotes} and \code{content} frames, which are assumed to be present in the default standard layout.
114

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

119
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

© 2025 Coveralls, Inc