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

sile-typesetter / sile / 14700559992

28 Apr 2025 04:55AM UTC coverage: 31.768% (+2.7%) from 29.023%
14700559992

push

github

web-flow
chore(deps): Bump DeterminateSystems/nix-installer-action from 16 to 17 (#2277)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

6399 of 20143 relevant lines covered (31.77%)

4269.96 hits per line

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

62.42
/classes/book.lua
1
--- book document class.
2
-- @use classes.book
3

4
local plain = require("classes.plain")
33✔
5

6
local class = pl.class(plain)
33✔
7
class._name = "book"
33✔
8

9
class.defaultFrameset = {
33✔
10
   content = {
33✔
11
      left = "8.3%pw",
12
      right = "86%pw",
13
      top = "11.6%ph",
14
      bottom = "top(footnotes)",
15
   },
33✔
16
   folio = {
33✔
17
      left = "left(content)",
18
      right = "right(content)",
19
      top = "bottom(footnotes)+3%ph",
20
      bottom = "bottom(footnotes)+5%ph",
21
   },
33✔
22
   runningHead = {
33✔
23
      left = "left(content)",
24
      right = "right(content)",
25
      top = "top(content)-8%ph",
26
      bottom = "top(content)-3%ph",
27
   },
33✔
28
   footnotes = {
33✔
29
      left = "left(content)",
30
      right = "right(content)",
31
      height = "0",
32
      bottom = "83.3%ph",
33
   },
33✔
34
}
33✔
35

36
function class:_init (options)
33✔
37
   plain._init(self, options)
33✔
38
   self:loadPackage("counters")
33✔
39
   self:loadPackage("masters", {
66✔
40
      {
41
         id = "right",
42
         firstContentFrame = self.firstContentFrame,
33✔
43
         frames = self.defaultFrameset,
33✔
44
      },
33✔
45
   })
46
   self:loadPackage("twoside", {
33✔
47
      oddPageMaster = "right",
48
      evenPageMaster = "left",
49
   })
50
   self:loadPackage("tableofcontents")
33✔
51
   self:loadPackage("footnotes", {
66✔
52
      insertInto = "footnotes",
53
      stealFrom = { "content" },
33✔
54
   })
55
end
56

57
function class:endPage ()
33✔
58
   if not SILE.scratch.headers.skipthispage then
69✔
59
      if self:oddPage() and SILE.scratch.headers.right then
132✔
60
         SILE.typesetNaturally(SILE.getFrame("runningHead"), function ()
2✔
61
            SILE.settings:toplevelState()
1✔
62
            SILE.settings:set("current.parindent", SILE.types.node.glue())
2✔
63
            SILE.settings:set("document.lskip", SILE.types.node.glue())
2✔
64
            SILE.settings:set("document.rskip", SILE.types.node.glue())
2✔
65
            -- SILE.settings:set("typesetter.parfillskip", SILE.types.node.glue())
66
            SILE.process(SILE.scratch.headers.right)
1✔
67
            SILE.call("par")
1✔
68
         end)
69
      elseif not self:oddPage() and SILE.scratch.headers.left then
130✔
70
         SILE.typesetNaturally(SILE.getFrame("runningHead"), function ()
×
71
            SILE.settings:toplevelState()
×
72
            SILE.settings:set("current.parindent", SILE.types.node.glue())
×
73
            SILE.settings:set("document.lskip", SILE.types.node.glue())
×
74
            SILE.settings:set("document.rskip", SILE.types.node.glue())
×
75
            -- SILE.settings:set("typesetter.parfillskip", SILE.types.node.glue())
76
            SILE.process(SILE.scratch.headers.left)
×
77
            SILE.call("par")
×
78
         end)
79
      end
80
   end
81
   SILE.scratch.headers.skipthispage = false
69✔
82
   return plain.endPage(self)
69✔
83
end
84

85
function class:finish ()
33✔
86
   local ret = plain.finish(self)
33✔
87
   return ret
33✔
88
end
89

90
function class:registerCommands ()
33✔
91
   plain.registerCommands(self)
33✔
92

93
   self:registerCommand("left-running-head", function (_, content)
66✔
94
      local closure = SILE.settings:wrap()
4✔
95
      SILE.scratch.headers.left = function ()
4✔
96
         closure(content)
×
97
      end
98
   end, "Text to appear on the top of the left page")
37✔
99

100
   self:registerCommand("right-running-head", function (_, content)
66✔
101
      local closure = SILE.settings:wrap()
1✔
102
      SILE.scratch.headers.right = function ()
1✔
103
         closure(content)
1✔
104
      end
105
   end, "Text to appear on the top of the right page")
34✔
106

107
   self:registerCommand("book:sectioning", function (options, content)
66✔
108
      local level = SU.required(options, "level", "book:sectioning")
4✔
109
      local number
110
      if SU.boolean(options.numbering, true) then
8✔
111
         SILE.call("increment-multilevel-counter", { id = "sectioning", level = level })
4✔
112
         number = self.packages.counters:formatMultilevelCounter(self:getMultilevelCounter("sectioning"))
12✔
113
      end
114
      if SU.boolean(options.toc, true) then
8✔
115
         SILE.call("tocentry", { level = level, number = number }, SU.ast.subContent(content))
8✔
116
      end
117
      if SU.boolean(options.numbering, true) then
8✔
118
         if options.msg then
4✔
119
            SILE.call("fluent", { number = number }, { options.msg })
8✔
120
         else
121
            SILE.call("show-multilevel-counter", { id = "sectioning" })
×
122
         end
123
      end
124
   end)
125

126
   self:registerCommand("book:chapter:post", function (_, _)
66✔
127
      SILE.call("par")
3✔
128
      SILE.call("noindent")
3✔
129
   end)
130

131
   self:registerCommand("book:section:post", function (_, _)
66✔
132
      SILE.process({ " " })
×
133
   end)
134

135
   self:registerCommand("book:subsection:post", function (_, _)
66✔
136
      SILE.process({ " " })
×
137
   end)
138

139
   self:registerCommand("book:left-running-head-font", function (_, content)
66✔
140
      SILE.call("font", { size = "9pt" }, content)
×
141
   end)
142

143
   self:registerCommand("book:right-running-head-font", function (_, content)
66✔
144
      SILE.call("font", { size = "9pt", style = "Italic" }, content)
×
145
   end)
146

147
   self:registerCommand("chapter", function (options, content)
66✔
148
      SILE.call("par")
4✔
149
      SILE.call("open-spread", { double = false })
4✔
150
      SILE.call("noindent")
4✔
151
      SILE.scratch.headers.right = nil
4✔
152
      SILE.call("set-counter", { id = "footnote", value = 1 })
4✔
153
      SILE.call("book:chapterfont", {}, function ()
8✔
154
         SILE.call("book:sectioning", {
8✔
155
            numbering = options.numbering,
4✔
156
            toc = options.toc,
4✔
157
            level = 1,
158
            msg = "book-chapter-title",
159
         }, content)
4✔
160
      end)
161
      local lang = SILE.settings:get("document.language")
4✔
162
      local postcmd = "book:chapter:post"
4✔
163
      if SILE.Commands[postcmd .. ":" .. lang] then
4✔
164
         postcmd = postcmd .. ":" .. lang
1✔
165
      end
166
      SILE.call("nofoliothispage")
4✔
167
      SILE.call(postcmd)
4✔
168
      SILE.call("book:chapterfont", {}, content)
4✔
169
      SILE.call("left-running-head", {}, function ()
8✔
170
         SILE.settings:temporarily(function ()
×
171
            SILE.call("book:left-running-head-font", {}, content)
×
172
         end)
173
      end)
174
      SILE.call("novbreak")
4✔
175
      SILE.call("par")
4✔
176
      SILE.call("novbreak")
4✔
177
      SILE.call("bigskip")
4✔
178
      SILE.call("novbreak")
4✔
179
      -- English typography (notably) expects the first paragraph under a section
180
      -- not to be indented. Frenchies, don't use this class :)
181
      SILE.call("noindent")
4✔
182
   end, "Begin a new chapter")
37✔
183

184
   self:registerCommand("section", function (options, content)
66✔
185
      SILE.call("par")
×
186
      SILE.call("noindent")
×
187
      SILE.call("bigskip")
×
188
      SILE.call("goodbreak")
×
189
      SILE.call("book:sectionfont", {}, function ()
×
190
         SILE.call("book:sectioning", {
×
191
            numbering = options.numbering,
192
            toc = options.toc,
193
            level = 2,
194
         }, content)
×
195
         local lang = SILE.settings:get("document.language")
×
196
         local postcmd = "book:section:post"
×
197
         if SILE.Commands[postcmd .. ":" .. lang] then
×
198
            postcmd = postcmd .. ":" .. lang
×
199
         end
200
         SILE.call(postcmd)
×
201
         SILE.process(content)
×
202
      end)
203
      if not SILE.scratch.counters.folio.off then
×
204
         SILE.call("right-running-head", {}, function ()
×
205
            SILE.call("book:right-running-head-font", {}, function ()
×
206
               SILE.call("raggedleft", {}, function ()
×
207
                  SILE.settings:temporarily(function ()
×
208
                     if SU.boolean(options.numbering, true) then
×
209
                        SILE.call("show-multilevel-counter", { id = "sectioning", level = 2 })
×
210
                        SILE.typesetter:typeset(" ")
×
211
                     end
212
                     SILE.process(content)
×
213
                  end)
214
               end)
215
            end)
216
         end)
217
      end
218
      SILE.call("par")
×
219
      SILE.call("novbreak")
×
220
      SILE.call("smallskip")
×
221
      SILE.call("novbreak")
×
222
      -- English typography (notably) expects the first paragraph under a section
223
      -- not to be indented. Frenchies, don't use this class :)
224
      SILE.call("noindent")
×
225
   end, "Begin a new section")
33✔
226

227
   self:registerCommand("subsection", function (options, content)
66✔
228
      SILE.call("par")
×
229
      SILE.call("noindent")
×
230
      SILE.call("medskip")
×
231
      SILE.call("goodbreak")
×
232
      SILE.call("book:subsectionfont", {}, function ()
×
233
         SILE.call("book:sectioning", {
×
234
            numbering = options.numbering,
235
            toc = options.toc,
236
            level = 3,
237
         }, content)
×
238
         local lang = SILE.settings:get("document.language")
×
239
         local postcmd = "book:subsection:post"
×
240
         if SILE.Commands[postcmd .. ":" .. lang] then
×
241
            postcmd = postcmd .. ":" .. lang
×
242
         end
243
         SILE.call(postcmd)
×
244
         SILE.process(content)
×
245
      end)
246
      SILE.call("par")
×
247
      SILE.call("novbreak")
×
248
      SILE.call("smallskip")
×
249
      SILE.call("novbreak")
×
250
      -- English typography (notably) expects the first paragraph under a section
251
      -- not to be indented. Frenchies, don't use this class :)
252
      SILE.call("noindent")
×
253
   end, "Begin a new subsection")
33✔
254

255
   self:registerCommand("book:chapterfont", function (_, content)
66✔
256
      SILE.call("font", { weight = 800, size = "22pt" }, content)
8✔
257
   end)
258

259
   self:registerCommand("book:sectionfont", function (_, content)
66✔
260
      SILE.call("font", { weight = 800, size = "15pt" }, content)
×
261
   end)
262

263
   self:registerCommand("book:subsectionfont", function (_, content)
66✔
264
      SILE.call("font", { weight = 800, size = "12pt" }, content)
×
265
   end)
266
end
267

268
return class
33✔
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