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

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

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

76.8
/classes/bible.lua
1
local plain = require("classes.plain")
1✔
2

3
local class = pl.class(plain)
1✔
4
class._name = "bible"
1✔
5

6
if not SILE.scratch.headers then
1✔
7
   SILE.scratch.headers = {}
1✔
8
end
9

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

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

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

176
local _twocolumns
177
local _gutterwidth
178

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

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

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

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

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

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

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

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

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

296
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

© 2026 Coveralls, Inc