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

sile-typesetter / sile / 6612577550

23 Oct 2023 11:26AM UTC coverage: 74.31% (+0.2%) from 74.132%
6612577550

push

github

alerque
feat(classes): Add landscape option to base class (#1892)

Co-authored-by: Caleb Maclennan <caleb@alerque.com>

17 of 17 new or added lines in 3 files covered. (100.0%)

11732 of 15788 relevant lines covered (74.31%)

6981.7 hits per line

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

80.86
/classes/base.lua
1
local class = pl.class()
173✔
2
class.type = "class"
173✔
3
class._name = "base"
173✔
4

5
class._initialized = false
173✔
6
class.deferredLegacyInit = {}
173✔
7
class.deferredInit = {}
173✔
8
class.pageTemplate = { frames = {}, firstContentFrame = nil }
173✔
9
class.defaultFrameset = {}
173✔
10
class.firstContentFrame = "page"
173✔
11
class.options = setmetatable({}, {
346✔
12
    _opts = {},
173✔
13
    __newindex = function (self, key, value)
14
      local opts = getmetatable(self)._opts
1,067✔
15
      if type(opts[key]) == "function" then
1,067✔
16
        opts[key](class, value)
726✔
17
      elseif type(value) == "function" then
704✔
18
        opts[key] = value
703✔
19
      elseif type(key) == "number" then
1✔
20
        return nil
1✔
21
      else
22
        SU.error("Attempted to set an undeclared class option '" .. key .. "'")
×
23
      end
24
    end,
25
    __index = function (self, key)
26
      if key == "super" then return nil end
184✔
27
      if type(key) == "number" then return nil end
184✔
28
      local opt = getmetatable(self)._opts[key]
184✔
29
      if type(opt) == "function" then
184✔
30
        return opt(class)
184✔
31
      elseif opt then
×
32
        return opt
×
33
      else
34
        SU.error("Attempted to get an undeclared class option '" .. key .. "'")
×
35
      end
36
    end
37
  })
173✔
38
class.hooks = {
173✔
39
  newpage = {},
173✔
40
  endpage = {},
173✔
41
  finish = {},
173✔
42
}
173✔
43

44
class.packages = {}
173✔
45

46
function class:_init (options)
173✔
47
  SILE.scratch.half_initialized_class = self
173✔
48
  if self == options then options = {} end
173✔
49
  SILE.languageSupport.loadLanguage('und') -- preload for unlocalized fallbacks
173✔
50
  self:declareOptions()
173✔
51
  self:registerRawHandlers()
173✔
52
  self:declareSettings()
173✔
53
  self:registerCommands()
173✔
54
  self:setOptions(options)
173✔
55
  self:declareFrames(self.defaultFrameset)
173✔
56
  self:registerPostinit(function (self_)
346✔
57
      if type(self.firstContentFrame) == "string" then
173✔
58
        self_.pageTemplate.firstContentFrame = self_.pageTemplate.frames[self_.firstContentFrame]
173✔
59
      end
60
      local frame = self_:initialFrame()
173✔
61
      SILE.typesetter = SILE.typesetters.base(frame)
346✔
62
      SILE.typesetter:registerPageEndHook(function ()
346✔
63
        SU.debug("frames", function ()
448✔
64
          for _, v in pairs(SILE.frames) do SILE.outputter:debugFrame(v) end
×
65
          return "Drew debug outlines around frames"
×
66
        end)
67
      end)
68
    end)
69
end
70

71
function class:_post_init ()
173✔
72
  self._initialized = true
173✔
73
  for i, func in ipairs(self.deferredInit) do
428✔
74
    func(self)
255✔
75
    self.deferredInit[i] = nil
255✔
76
  end
77
  SILE.scratch.half_initialized_class = nil
173✔
78
end
79

80
function class:setOptions (options)
173✔
81
  options = options or {}
173✔
82
  -- Classes that add options with dependencies should explicitly handle them, then exempt them from furthur processing.
83
  -- The landscape option is handled explicitly before papersize, then the "rest" of options that are not interdependent.
84
  self.options.landscape = SU.boolean(options.landscape, false)
346✔
85
  options.landscape = nil
173✔
86
  self.options.papersize = options.papersize or "a4"
173✔
87
  options.papersize = nil
173✔
88
  for option, value in pairs(options) do
191✔
89
    self.options[option] = value
18✔
90
  end
91
end
92

93
function class:declareOption (option, setter)
173✔
94
  rawset(getmetatable(self.options)._opts, option, nil)
703✔
95
  self.options[option] = setter
703✔
96
end
97

98
function class:declareOptions ()
173✔
99
  self:declareOption("class", function (_, name)
346✔
100
    if name then
×
101
      if self._legacy then
×
102
        self._name = name
×
103
      elseif name ~= self._name then
×
104
        SU.error("Cannot change class name after instantiation, derive a new class instead.")
×
105
      end
106
    end
107
    return self._name
×
108
  end)
109
  self:declareOption("landscape", function(_, landscape)
346✔
110
    if landscape then
347✔
111
      self.landscape = landscape
1✔
112
    end
113
    return self.landscape
347✔
114
  end)
115
  self:declareOption("papersize", function (_, size)
346✔
116
    if size then
173✔
117
      self.papersize = size
173✔
118
      SILE.documentState.paperSize = SILE.papersize(size, self.options.landscape)
519✔
119
      SILE.documentState.orgPaperSize = SILE.documentState.paperSize
173✔
120
      SILE.newFrame({
346✔
121
        id = "page",
122
        left = 0,
123
        top = 0,
124
        right = SILE.documentState.paperSize[1],
173✔
125
        bottom = SILE.documentState.paperSize[2]
173✔
126
      })
127
    end
128
    return self.papersize
173✔
129
  end)
130
end
131

132
function class.declareSettings (_)
173✔
133
  SILE.settings:declare({
173✔
134
    parameter = "current.parindent",
135
    type = "glue or nil",
136
    default = nil,
137
    help = "Glue at start of paragraph"
×
138
  })
139
  SILE.settings:declare({
173✔
140
    parameter = "current.hangIndent",
141
    type = "measurement or nil",
142
    default = nil,
143
    help = "Size of hanging indent"
×
144
  })
145
  SILE.settings:declare({
173✔
146
    parameter = "current.hangAfter",
147
    type = "integer or nil",
148
    default = nil,
149
    help = "Number of lines affected by handIndent"
×
150
  })
151
end
152

153
function class:loadPackage (packname, options)
173✔
154
  local pack = require(("packages.%s"):format(packname))
964✔
155
  if type(pack) == "table" and pack.type == "package" then -- new package
964✔
156
    self.packages[pack._name] = pack(options)
1,928✔
157
  else -- legacy package
158
    self:initPackage(pack, options)
×
159
  end
160
end
161

162
function class:initPackage (pack, options)
173✔
163
  SU.deprecated("class:initPackage(options)", "package(options)", "0.14.0", "0.16.0", [[
×
164
  This package appears to be a legacy format package. It returns a table
165
  an expects SILE to guess a bit about what to do. New packages inherit
166
  from the base class and have a constructor function (_init) that
167
  automatically handles setup.]])
×
168
  if type(pack) == "table" then
×
169
    if pack.exports then pl.tablex.update(self, pack.exports) end
×
170
    if type(pack.declareSettings) == "function" then
×
171
      pack.declareSettings(self)
×
172
    end
173
    if type(pack.registerRawHandlers) == "function" then
×
174
      pack.registerRawHandlers(self)
×
175
    end
176
    if type(pack.registerCommands) == "function" then
×
177
      pack.registerCommands(self)
×
178
    end
179
    if type(pack.init) == "function" then
×
180
      self:registerPostinit(pack.init, options)
×
181
    end
182
  end
183
end
184

185
function class:registerLegacyPostinit (func, options)
173✔
186
  if self._initialized then return func(self, options) end
×
187
  table.insert(self.deferredLegacyInit, function (_)
×
188
      func(self, options)
×
189
    end)
190
end
191

192
function class:registerPostinit (func, options)
173✔
193
  if self._initialized then return func(self, options) end
278✔
194
  table.insert(self.deferredInit, function (_)
510✔
195
      func(self, options)
255✔
196
    end)
197
end
198

199
function class:registerHook (category, func)
173✔
200
  for _, func_ in ipairs(self.hooks[category]) do
765✔
201
    if func_ == func then
246✔
202
      return
1✔
203
      --[[ See https://github.com/sile-typesetter/sile/issues/1531
204
      return SU.warn("Attempted to set the same function hook twice, probably unintended, skipping.")
205
      -- If the same function signature is already set a package is probably being
206
      -- re-initialized. Ditch the first instance of the hook so that it runs in
207
      -- the order of last initialization.
208
      self.hooks[category][_] = nil
209
      ]]
210
    end
211
  end
212
  table.insert(self.hooks[category], func)
519✔
213
end
214

215
function class:runHooks (category, options)
173✔
216
  for _, func in ipairs(self.hooks[category]) do
962✔
217
    SU.debug("classhooks", "Running hook from", category, options and "with options " .. #options)
502✔
218
    func(self, options)
502✔
219
  end
220
end
221

222
function class.registerCommand (_, name, func, help, pack)
173✔
223
  SILE.Commands[name] = func
17,876✔
224
  if not pack then
17,876✔
225
    local where = debug.getinfo(2).source
17,861✔
226
    pack = where:match("(%w+).lua")
17,861✔
227
  end
228
  --if not help and not pack:match(".sil") then SU.error("Could not define command '"..name.."' (in package "..pack..") - no help text" ) end
229
  SILE.Help[name] = {
17,876✔
230
    description = help,
17,876✔
231
    where = pack
17,876✔
232
  }
17,876✔
233
end
234

235
function class.registerRawHandler (_, format, callback)
173✔
236
  SILE.rawHandlers[format] = callback
177✔
237
end
238

239
function class:registerRawHandlers ()
173✔
240

241
  self:registerRawHandler("text", function (_, content)
346✔
242
    SILE.settings:temporarily(function()
2✔
243
      SILE.settings:set("typesetter.parseppattern", "\n")
1✔
244
      SILE.settings:set("typesetter.obeyspaces", true)
1✔
245
      SILE.typesetter:typeset(content[1])
1✔
246
    end)
247
  end)
248

249
end
250

251
local function packOptions (options)
252
  local relevant = pl.tablex.copy(options)
147✔
253
  relevant.src = nil
147✔
254
  relevant.format = nil
147✔
255
  relevant.module = nil
147✔
256
  relevant.require = nil
147✔
257
  return relevant
147✔
258
end
259

260
function class:registerCommands ()
173✔
261

262
  local function replaceProcessBy(replacement, tree)
263
    if type(tree) ~= "table" then return tree end
175✔
264
    local ret = pl.tablex.deepcopy(tree)
106✔
265
    if tree.command == "process" then
106✔
266
      return replacement
7✔
267
    else
268
      for i, child in ipairs(tree) do
231✔
269
        ret[i] = replaceProcessBy(replacement, child)
264✔
270
      end
271
      return ret
99✔
272
    end
273
  end
274

275
  self:registerCommand("define", function (options, content)
346✔
276
    SU.required(options, "command", "defining command")
15✔
277
    if type(content) == "function" then
15✔
278
      -- A macro defined as a function can take no argument, so we register
279
      -- it as-is.
280
      self:registerCommand(options["command"], content)
×
281
      return
×
282
    elseif options.command == "process" then
15✔
283
      SU.warn("Did you mean to re-definine the `\\process` macro? That probably won't go well.")
×
284
    end
285
    self:registerCommand(options["command"], function (_, inner_content)
30✔
286
      SU.debug("macros", "Processing macro \\" .. options["command"])
43✔
287
      local macroArg
288
      if type(inner_content) == "function" then
43✔
289
        macroArg = inner_content
2✔
290
      elseif type(inner_content) == "table" then
41✔
291
        macroArg = pl.tablex.copy(inner_content)
78✔
292
        macroArg.command = nil
39✔
293
        macroArg.id = nil
39✔
294
      elseif inner_content == nil then
2✔
295
        macroArg = {}
2✔
296
      else
297
        SU.error("Unhandled content type " .. type(inner_content) .. " passed to macro \\" .. options["command"], true)
×
298
      end
299
      -- Replace every occurrence of \process in `content` (the macro
300
      -- body) with `macroArg`, then have SILE go through the new `content`.
301
      local newContent = replaceProcessBy(macroArg, content)
43✔
302
      SILE.process(newContent)
43✔
303
      SU.debug("macros", "Finished processing \\" .. options["command"])
43✔
304
    end, options.help, SILE.currentlyProcessingFile)
58✔
305
  end, "Define a new macro. \\define[command=example]{ ... \\process }")
188✔
306

307
  -- A utility function that allows SILE.call() to be used as a noop wrapper.
308
  self:registerCommand("noop", function (_, content)
346✔
309
    SILE.process(content)
1✔
310
  end)
311

312
  -- The document (SIL) or sile (XML) command is always the sigular leaf at the
313
  -- top level of our AST. The work you might expect to see happen here is
314
  -- actually handled by SILE.inputter:classInit() before we get here, so these
315
  -- are just pass through functions. Theoretically, this could be a useful
316
  -- point to hook into-especially for included documents.
317
  self:registerCommand("document", function (_, content)
346✔
318
    SILE.process(content)
×
319
  end)
320
  self:registerCommand("sile", function (_, content)
346✔
321
    SILE.process(content)
×
322
  end)
323

324
  self:registerCommand("comment", function (_, _)
346✔
325
  end, "Ignores any text within this command's body.")
173✔
326

327
  self:registerCommand("process", function ()
346✔
328
    SU.error("Encountered unsubstituted \\process.")
×
329
  end, "Within a macro definition, processes the contents of the macro body.")
173✔
330

331
  self:registerCommand("script", function (options, content)
346✔
332
    local packopts = packOptions(options)
38✔
333
    if SU.hasContent(content) then
76✔
334
      return SILE.processString(content[1], options.format or "lua", nil, packopts)
33✔
335
    elseif options.src then
5✔
336
      return SILE.require(options.src)
5✔
337
    else
338
      SU.error("\\script function requires inline content or a src file path")
×
339
      return SILE.processString(content[1], options.format or "lua", nil, packopts)
×
340
    end
341
  end, "Runs lua code. The code may be supplied either inline or using src=...")
173✔
342

343
  self:registerCommand("include", function (options, content)
346✔
344
    local packopts = packOptions(options)
1✔
345
    if SU.hasContent(content) then
2✔
346
      local doc = SU.contentToString(content)
×
347
      return SILE.processString(doc, options.format, nil, packopts)
×
348
    elseif options.src then
1✔
349
      return SILE.processFile(options.src, options.format, packopts)
1✔
350
    else
351
      SU.error("\\include function requires inline content or a src file path")
×
352
    end
353
  end, "Includes a content file for processing.")
173✔
354

355
  self:registerCommand("lua", function (options, content)
346✔
356
    local packopts = packOptions(options)
3✔
357
    if SU.hasContent(content) then
6✔
358
      local doc = SU.contentToString(content)
3✔
359
      return SILE.processString(doc, "lua", nil, packopts)
3✔
360
    elseif options.src then
×
361
      return SILE.processFile(options.src, "lua", packopts)
×
362
    elseif options.require then
×
363
      local module = SU.required(options, "require", "lua")
×
364
      return require(module)
×
365
    else
366
      SU.error("\\lua function requires inline content or a src file path or a require module name")
×
367
    end
368
  end, "Run Lua code. The code may be supplied either inline, using require=... for a Lua module, or using src=... for a file path")
173✔
369

370
  self:registerCommand("sil", function (options, content)
346✔
371
    local packopts = packOptions(options)
×
372
    if SU.hasContent(content) then
×
373
      local doc = SU.contentToString(content)
×
374
      return SILE.processString(doc, "sil")
×
375
    elseif options.src then
×
376
      return SILE.processFile(options.src, "sil", packopts)
×
377
    else
378
      SU.error("\\sil function requires inline content or a src file path")
×
379
    end
380
  end, "Process sil content. The content may be supplied either inline or using src=...")
173✔
381

382
  self:registerCommand("xml", function (options, content)
346✔
383
    local packopts = packOptions(options)
×
384
    if SU.hasContent(content) then
×
385
      local doc = SU.contentToString(content)
×
386
      return SILE.processString(doc, "xml", nil, packopts)
×
387
    elseif options.src then
×
388
      return SILE.processFile(options.src, "xml", packopts)
×
389
    else
390
      SU.error("\\xml function requires inline content or a src file path")
×
391
    end
392
  end, "Process xml content. The content may be supplied either inline or using src=...")
173✔
393

394
  self:registerCommand("use", function (options, content)
346✔
395
    local packopts = packOptions(options)
105✔
396
    if content[1] and string.len(content[1]) > 0 then
105✔
397
      local doc = SU.contentToString(content)
×
398
      SILE.processString(doc, "lua", nil, packopts)
×
399
    else
400
      if options.src then
105✔
401
        SU.warn("Use of 'src' with \\use is discouraged because some of it's path handling\n  will eventually be deprecated. Use 'module' instead when possible.")
×
402
        SILE.processFile(options.src, "lua", packopts)
×
403
      else
404
        local module = SU.required(options, "module", "use")
105✔
405
        SILE.use(module, packopts)
105✔
406
      end
407
    end
408
  end, "Load and initialize a SILE module (can be a package, a shaper, a typesetter, or whatever). Use module=... to specif what to load or include module code inline.")
278✔
409

410
  self:registerCommand("raw", function (options, content)
346✔
411
    local rawtype = SU.required(options, "type", "raw")
4✔
412
    local handler = SILE.rawHandlers[rawtype]
4✔
413
    if not handler then SU.error("No inline handler for '"..rawtype.."'") end
4✔
414
    handler(options, content)
4✔
415
  end, "Invoke a raw passthrough handler")
177✔
416

417
  self:registerCommand("pagetemplate", function (options, content)
346✔
418
    SILE.typesetter:pushState()
8✔
419
    SILE.documentState.thisPageTemplate = { frames = {} }
8✔
420
    SILE.process(content)
8✔
421
    SILE.documentState.thisPageTemplate.firstContentFrame = SILE.getFrame(options["first-content-frame"])
16✔
422
    SILE.typesetter:initFrame(SILE.documentState.thisPageTemplate.firstContentFrame)
8✔
423
    SILE.typesetter:popState()
8✔
424
  end, "Defines a new page template for the current page and sets the typesetter to use it.")
181✔
425

426
  self:registerCommand("frame", function (options, _)
346✔
427
    SILE.documentState.thisPageTemplate.frames[options.id] = SILE.newFrame(options)
62✔
428
  end, "Declares (or re-declares) a frame on this page.")
204✔
429

430
  self:registerCommand("penalty", function (options, _)
346✔
431
    if SU.boolean(options.vertical, false) and not SILE.typesetter:vmode() then
581✔
432
      SILE.typesetter:leaveHmode()
4✔
433
    end
434
    if SILE.typesetter:vmode() then
556✔
435
      SILE.typesetter:pushVpenalty({ penalty = tonumber(options.penalty) })
442✔
436
    else
437
      SILE.typesetter:pushPenalty({ penalty = tonumber(options.penalty) })
57✔
438
    end
439
  end, "Inserts a penalty node. Option is penalty= for the size of the penalty.")
451✔
440

441
  self:registerCommand("discretionary", function (options, _)
346✔
442
    local discretionary = SILE.nodefactory.discretionary({})
74✔
443
    if options.prebreak then
74✔
444
      local hbox = SILE.typesetter:makeHbox({ options.prebreak })
74✔
445
      discretionary.prebreak = { hbox }
74✔
446
    end
447
    if options.postbreak then
74✔
448
      local hbox = SILE.typesetter:makeHbox({ options.postbreak })
48✔
449
      discretionary.postbreak = { hbox }
48✔
450
    end
451
    if options.replacement then
74✔
452
      local hbox = SILE.typesetter:makeHbox({ options.replacement })
50✔
453
      discretionary.replacement = { hbox }
50✔
454
    end
455
    table.insert(SILE.typesetter.state.nodes, discretionary)
74✔
456
  end, "Inserts a discretionary node.")
247✔
457

458
  self:registerCommand("glue", function (options, _)
346✔
459
    local width = SU.cast("length", options.width):absolute()
106✔
460
    SILE.typesetter:pushGlue(width)
53✔
461
  end, "Inserts a glue node. The width option denotes the glue dimension.")
226✔
462

463
  self:registerCommand("kern", function (options, _)
346✔
464
    local width = SU.cast("length", options.width):absolute()
150✔
465
    SILE.typesetter:pushHorizontal(SILE.nodefactory.kern(width))
150✔
466
  end, "Inserts a glue node. The width option denotes the glue dimension.")
248✔
467

468
  self:registerCommand("skip", function (options, _)
346✔
469
    options.discardable = SU.boolean(options.discardable, false)
58✔
470
    options.height = SILE.length(options.height):absolute()
87✔
471
    SILE.typesetter:leaveHmode()
29✔
472
    if options.discardable then
29✔
473
      SILE.typesetter:pushVglue(options)
×
474
    else
475
      SILE.typesetter:pushExplicitVglue(options)
29✔
476
    end
477
  end, "Inserts vertical skip. The height options denotes the skip dimension.")
202✔
478

479
  self:registerCommand("par", function (_, _)
346✔
480
    SILE.typesetter:endline()
290✔
481
  end, "Ends the current paragraph.")
463✔
482

483
end
484

485
function class:initialFrame ()
173✔
486
  SILE.documentState.thisPageTemplate = pl.tablex.deepcopy(self.pageTemplate)
460✔
487
  SILE.frames = { page = SILE.frames.page }
230✔
488
  for k, v in pairs(SILE.documentState.thisPageTemplate.frames) do
999✔
489
    SILE.frames[k] = v
769✔
490
  end
491
  if not SILE.documentState.thisPageTemplate.firstContentFrame then
230✔
492
    SILE.documentState.thisPageTemplate.firstContentFrame = SILE.frames[self.firstContentFrame]
×
493
  end
494
  SILE.documentState.thisPageTemplate.firstContentFrame:invalidate()
230✔
495
  return SILE.documentState.thisPageTemplate.firstContentFrame
230✔
496
end
497

498
function class:declareFrame (id, spec)
173✔
499
  spec.id = id
568✔
500
  if spec.solve then
568✔
501
    self.pageTemplate.frames[id] = spec
×
502
  else
503
    self.pageTemplate.frames[id] = SILE.newFrame(spec)
1,136✔
504
  end
505
  --   next = spec.next,
506
  --   left = spec.left and fW(spec.left),
507
  --   right = spec.right and fW(spec.right),
508
  --   top = spec.top and fH(spec.top),
509
  --   bottom = spec.bottom and fH(spec.bottom),
510
  --   height = spec.height and fH(spec.height),
511
  --   width = spec.width and fH(spec.width),
512
  --   id = id
513
  -- })
514
end
515

516
function class:declareFrames (specs)
173✔
517
  if specs then
173✔
518
    for k, v in pairs(specs) do self:declareFrame(k, v) end
1,277✔
519
  end
520
end
521

522
-- WARNING: not called as class method
523
function class.newPar (typesetter)
173✔
524
  local parindent = SILE.settings:get("current.parindent") or SILE.settings:get("document.parindent")
1,654✔
525
  -- See https://github.com/sile-typesetter/sile/issues/1361
526
  -- The parindent *cannot* be pushed non-absolutized, as it may be evaluated
527
  -- outside the (possibly temporary) setting scope where it was used for line
528
  -- breaking.
529
  -- Early absolutization can be problematic sometimes, but here we do not
530
  -- really have the choice.
531
  -- As of problematic cases, consider a parindent that would be defined in a
532
  -- frame-related unit (%lw, %fw, etc.). If a frame break occurs and the next
533
  -- frame has a different width, the parindent won't be re-evaluated in that
534
  -- new frame context. However, defining a parindent in such a unit is quite
535
  -- unlikely. And anyway pushback() has plenty of other issues.
536
  typesetter:pushGlue(parindent:absolute())
1,654✔
537
  SILE.settings:set("current.parindent", nil)
827✔
538
  local hangIndent = SILE.settings:get("current.hangIndent")
827✔
539
  if hangIndent then
827✔
540
    SILE.settings:set("linebreak.hangIndent", hangIndent)
5✔
541
  end
542
  local hangAfter = SILE.settings:get("current.hangAfter")
827✔
543
  if hangAfter then
827✔
544
    SILE.settings:set("linebreak.hangAfter", hangAfter)
5✔
545
  end
546
end
547

548
-- WARNING: not called as class method
549
function class.endPar (typesetter)
173✔
550
  typesetter:pushVglue(SILE.settings:get("document.parskip"))
1,616✔
551
  if SILE.settings:get("current.hangIndent") then
1,616✔
552
    SILE.settings:set("current.hangIndent", nil)
4✔
553
    SILE.settings:set("linebreak.hangIndent", nil)
4✔
554
  end
555
  if SILE.settings:get("current.hangAfter") then
1,616✔
556
    SILE.settings:set("current.hangAfter", nil)
4✔
557
    SILE.settings:set("linebreak.hangAfter", nil)
4✔
558
  end
559
end
560

561
function class:newPage ()
173✔
562
  SILE.outputter:newPage()
57✔
563
  self:runHooks("newpage")
57✔
564
  -- Any other output-routiney things will be done here by inheritors
565
  return self:initialFrame()
57✔
566
end
567

568
function class:endPage ()
173✔
569
  SILE.typesetter.frame:leave(SILE.typesetter)
230✔
570
  self:runHooks("endpage")
230✔
571
  -- I'm trying to call up a new frame here, don't cause a page break in the current one
572
  -- SILE.typesetter:leaveHmode()
573
  -- Any other output-routiney things will be done here by inheritors
574
end
575

576
function class:finish ()
173✔
577
  SILE.inputter:postamble()
173✔
578
  SILE.call("vfill")
173✔
579
  while not SILE.typesetter:isQueueEmpty() do
692✔
580
    SILE.call("supereject")
173✔
581
    SILE.typesetter:leaveHmode(true)
173✔
582
    SILE.typesetter:buildPage()
173✔
583
    if not SILE.typesetter:isQueueEmpty() then
346✔
584
      SILE.typesetter:initNextFrame()
5✔
585
    end
586
  end
587
  SILE.typesetter:runHooks("pageend") -- normally run by the typesetter
173✔
588
  self:endPage()
173✔
589
  if SILE.typesetter and not SILE.typesetter:isQueueEmpty() then
346✔
590
    SU.error("Queues are not empty as expected after ending last page", true)
×
591
  end
592
  SILE.outputter:finish()
173✔
593
  self:runHooks("finish")
173✔
594
end
595

596
return class
173✔
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