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

sile-typesetter / sile / 14384044172

10 Apr 2025 03:07PM UTC coverage: 40.142% (+10.8%) from 29.317%
14384044172

push

github

alerque
Merge branch 'cairo-is-still-in-egypt'

3 of 51 new or added lines in 3 files covered. (5.88%)

302 existing lines in 20 files now uncovered.

6876 of 17129 relevant lines covered (40.14%)

2601.39 hits per line

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

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

UNCOV
4
local plain = require("classes.plain")
×
5

UNCOV
6
local class = pl.class(plain)
×
UNCOV
7
class._name = "bible"
×
8

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

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

UNCOV
52
function class:twoColumnMaster ()
×
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

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

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

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

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

UNCOV
238
function class:registerCommands ()
×
UNCOV
239
   plain.registerCommands(self)
×
240

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

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

UNCOV
255
   self:registerCommand("chapter", function (options, content)
×
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

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

UNCOV
295
return class
×
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