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

sile-typesetter / sile / 9432254829

08 Jun 2024 11:20PM UTC coverage: 60.675% (+3.5%) from 57.223%
9432254829

push

github

alerque
fix(build): Bundle all assets in source distribution

...even when configured for doing a static binary build with embedded
assets. They don't get installed, but they should be in the dist file in
case the good folks building want to configure it a different way.

10441 of 17208 relevant lines covered (60.68%)

1913.98 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

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

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

9
if not SILE.scratch.headers then
×
10
   SILE.scratch.headers = {}
×
11
end
12

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

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

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

179
local _twocolumns
180
local _gutterwidth
181

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

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

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

236
function class:setOptions (options)
×
237
   options.twocolumns = options.twocolumns or false
×
238
   options.gutter = options.gutter or "3%pw"
×
239
   plain.setOptions(self, options)
×
240
end
241

242
function class:registerCommands ()
×
243
   plain.registerCommands(self)
×
244

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

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

259
   self:registerCommand("chapter", function (options, content)
×
260
      local ch = options.id:match("%d+")
×
261
      SILE.call("bible:chapter-head", options, { "Chapter " .. ch })
×
262
      SILE.call("save-chapter-number", options, { options.id })
×
263
      SILE.process(content)
×
264
   end)
265

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

299
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

© 2025 Coveralls, Inc