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

sile-typesetter / sile / 14860011647

06 May 2025 12:44PM UTC coverage: 67.057% (+32.5%) from 34.559%
14860011647

push

github

alerque
chore(typesetters): Fixup access to class from typesetter functions

7 of 7 new or added lines in 2 files covered. (100.0%)

1344 existing lines in 103 files now uncovered.

14880 of 22190 relevant lines covered (67.06%)

11549.16 hits per line

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

73.98
/classes/bible.lua
1
--- bible document class.
2
-- @use classes.bible
3

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

6
local class = pl.class(plain)
1✔
7
class._name = "bible"
1✔
8

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

36
function class:singleColumnMaster ()
1✔
37
   self:defineMaster({
2✔
38
      id = "right",
39
      firstContentFrame = self.firstContentFrame,
1✔
40
      frames = self.defaultFrameset,
1✔
41
   })
42
   self:loadPackage("twoside", {
1✔
43
      oddPageMaster = "right",
44
      evenPageMaster = "left",
45
   })
46
   self:loadPackage("footnotes", {
2✔
47
      insertInto = "footnotes",
48
      stealFrom = { "content" },
1✔
49
   })
50
end
51

52
function class:twoColumnMaster ()
1✔
53
   self.firstContentFrame = "contentA"
×
54
   self:defineMaster({
×
55
      id = "right",
56
      firstContentFrame = "contentA",
57
      frames = {
×
58
         title = {
×
59
            left = "left(contentA)",
60
            right = "right(contentB)",
61
            top = "11.6%ph",
62
            height = "0",
63
            bottom = "top(contentA)",
64
         },
65
         contentA = {
×
66
            left = "8.3%pw",
67
            right = "left(gutter)",
68
            top = "bottom(title)",
69
            bottom = "top(footnotesA)",
70
            next = "contentB",
71
            balanced = true,
72
         },
73
         contentB = {
×
74
            left = "right(gutter)",
75
            width = "width(contentA)",
76
            right = "86%pw",
77
            top = "bottom(title)",
78
            bottom = "top(footnotesB)",
79
            balanced = true,
80
         },
81
         gutter = {
×
82
            left = "right(contentA)",
83
            right = "left(contentB)",
84
            width = self.options.gutter,
85
         },
86
         folio = {
×
87
            left = "left(contentA)",
88
            right = "right(contentB)",
89
            top = "bottom(footnotesB)+3%ph",
90
            bottom = "bottom(footnotesB)+5%ph",
91
         },
92
         runningHead = {
×
93
            left = "left(contentA)",
94
            right = "right(contentB)",
95
            top = "top(contentA)-8%ph",
96
            bottom = "top(contentA)-3%ph",
97
         },
98
         footnotesA = {
×
99
            left = "left(contentA)",
100
            right = "right(contentA)",
101
            height = "0",
102
            bottom = "83.3%ph",
103
         },
104
         footnotesB = {
×
105
            left = "left(contentB)",
106
            right = "right(contentB)",
107
            height = "0",
108
            bottom = "83.3%ph",
109
         },
110
      },
111
   })
112
   self:defineMaster({
×
113
      id = "left",
114
      firstContentFrame = "contentA",
115
      frames = {
×
116
         title = {
×
117
            left = "left(contentA)",
118
            right = "right(contentB)",
119
            top = "11.6%ph",
120
            height = "0",
121
            bottom = "top(contentA)",
122
         },
123
         contentA = {
×
124
            left = "14%pw",
125
            right = "left(gutter)",
126
            top = "bottom(title)",
127
            bottom = "top(footnotesA)",
128
            next = "contentB",
129
            balanced = true,
130
         },
131
         contentB = {
×
132
            left = "right(gutter)",
133
            width = "width(contentA)",
134
            right = "91.7%pw",
135
            top = "bottom(title)",
136
            bottom = "top(footnotesB)",
137
            balanced = true,
138
         },
139
         gutter = {
×
140
            left = "right(contentA)",
141
            right = "left(contentB)",
142
            width = self.options.gutter,
143
         },
144
         folio = {
×
145
            left = "left(contentA)",
146
            right = "right(contentB)",
147
            top = "bottom(footnotesB)+3%ph",
148
            bottom = "bottom(footnotesB)+5%ph",
149
         },
150
         runningHead = {
×
151
            left = "left(contentA)",
152
            right = "right(contentB)",
153
            top = "top(contentA)-8%ph",
154
            bottom = "top(contentA)-3%ph",
155
         },
156
         footnotesA = {
×
157
            left = "left(contentA)",
158
            right = "right(contentA)",
159
            height = "0",
160
            bottom = "83.3%ph",
161
         },
162
         footnotesB = {
×
163
            left = "left(contentB)",
164
            right = "right(contentB)",
165
            height = "0",
166
            bottom = "83.3%ph",
167
         },
168
      },
169
   })
170
   -- Later we'll have an option for two fn frames
171
   self:loadPackage("footnotes", { insertInto = "footnotesB", stealFrom = { "contentB" } })
×
172
   -- self:loadPackage("balanced-frames")
173
end
174

175
local _twocolumns
176
local _gutterwidth
177

178
function class:_init (options)
1✔
179
   plain._init(self, options)
1✔
180
   self:loadPackage("masters")
1✔
181
   self:loadPackage("infonode")
1✔
182
   self:loadPackage("chapterverse")
1✔
183
   self:registerPostinit(function (self_)
2✔
184
      if self_.options.twocolumns then
2✔
185
         self_:twoColumnMaster()
×
186
         self.settings:set("linebreak.tolerance", 9000)
×
187
      else
188
         self_:singleColumnMaster()
1✔
189
      end
190
   end)
191
end
192

193
function class:endPage ()
1✔
194
   if self:oddPage() and SILE.scratch.headers.right then
4✔
195
      SILE.typesetNaturally(SILE.getFrame("runningHead"), function ()
2✔
196
         self.settings:set("current.parindent", SILE.types.node.glue())
3✔
197
         self.settings:set("document.lskip", SILE.types.node.glue())
3✔
198
         self.settings:set("document.rskip", SILE.types.node.glue())
3✔
199
         -- self.settings:set("typesetter.parfillskip", SILE.types.node.glue())
200
         SILE.process(SILE.scratch.headers.right)
1✔
201
         SILE.call("par")
1✔
202
      end)
203
   elseif not (self:oddPage()) and SILE.scratch.headers.left then
2✔
204
      SILE.typesetNaturally(SILE.getFrame("runningHead"), function ()
2✔
205
         self.settings:set("current.parindent", SILE.types.node.glue())
3✔
206
         self.settings:set("document.lskip", SILE.types.node.glue())
3✔
207
         self.settings:set("document.rskip", SILE.types.node.glue())
3✔
208
         -- self.settings:set("typesetter.parfillskip", SILE.types.node.glue())
209
         SILE.process(SILE.scratch.headers.left)
1✔
210
         SILE.call("par")
1✔
211
      end)
212
   end
213
   return plain.endPage(self)
2✔
214
end
215

216
function class:declareOptions ()
1✔
217
   plain.declareOptions(self)
1✔
218
   self:declareOption("twocolumns", function (_, value)
2✔
219
      if value then
1✔
220
         _twocolumns = value
×
221
      end
222
      return _twocolumns
1✔
223
   end)
224
   self:declareOption("gutter", function (_, value)
2✔
UNCOV
225
      if value then
×
UNCOV
226
         _gutterwidth = value
×
227
      end
UNCOV
228
      return _gutterwidth
×
229
   end)
230
end
231

232
function class:setOptions (options)
1✔
233
   options.twocolumns = options.twocolumns or false
1✔
234
   options.gutter = options.gutter or "3%pw"
1✔
235
   plain.setOptions(self, options)
1✔
236
end
237

238
function class:registerCommands ()
1✔
239
   plain.registerCommands(self)
1✔
240

241
   self:registerCommand("left-running-head", function (_, content)
2✔
242
      local closure = self.settings:wrap()
6✔
243
      SILE.scratch.headers.left = function ()
3✔
244
         closure(content)
1✔
245
      end
246
   end, "Text to appear on the top of the left page")
4✔
247

248
   self:registerCommand("right-running-head", function (_, content)
2✔
249
      local closure = self.settings:wrap()
6✔
250
      SILE.scratch.headers.right = function ()
3✔
251
         closure(content)
1✔
252
      end
253
   end, "Text to appear on the top of the right page")
4✔
254

255
   self:registerCommand("chapter", function (options, content)
2✔
256
      local ch = options.id:match("%d+")
×
257
      SILE.call("bible:chapter-head", options, { "Chapter " .. ch })
×
258
      SILE.call("save-chapter-number", options, { options.id })
×
259
      SILE.process(content)
×
260
   end)
261

262
   self:registerCommand("verse-number", function (options, content)
2✔
263
      SILE.call("indent")
3✔
264
      SILE.call("bible:verse-number", options, content)
3✔
265
      SILE.call("save-verse-number", options, content)
3✔
266
      SILE.call("left-running-head", {}, function ()
6✔
267
         self.settings:temporarily(function ()
2✔
268
            self.settings:set("document.lskip", SILE.types.node.glue())
3✔
269
            self.settings:set("document.rskip", SILE.types.node.glue())
3✔
270
            -- self.settings:set("typesetter.parfillskip", SILE.types.node.glue())
271
            SILE.call("font", { size = "10pt", family = "Gentium" }, function ()
2✔
272
               SILE.call("first-reference")
1✔
273
               SILE.call("hfill")
1✔
274
               SILE.call("font", { style = "italic" }, SILE.scratch.theChapter)
1✔
275
            end)
276
            SILE.typesetter:leaveHmode()
1✔
277
         end)
278
      end)
279
      SILE.call("right-running-head", {}, function ()
6✔
280
         self.settings:temporarily(function ()
2✔
281
            self.settings:set("document.lskip", SILE.types.node.glue())
3✔
282
            self.settings:set("document.rskip", SILE.types.node.glue())
3✔
283
            self.settings:set("typesetter.parfillskip", SILE.types.node.glue())
3✔
284
            SILE.call("font", { size = "10pt", family = "Gentium" }, function ()
2✔
285
               -- SILE.call("font", { style = "italic" }, SILE.scratch.theChapter)
286
               SILE.call("hfill")
1✔
287
               SILE.call("last-reference")
1✔
288
            end)
289
            SILE.typesetter:leaveHmode()
1✔
290
         end)
291
      end)
292
   end)
293
end
294

295
return class
1✔
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