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

sile-typesetter / sile / 4551497499

pending completion
4551497499

push

github

GitHub
Merge bbf07093e into 71e91a38f

122 of 122 new or added lines in 20 files covered. (100.0%)

11619 of 15603 relevant lines covered (74.47%)

6844.75 hits per line

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

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

5
class._initialized = false
167✔
6
class.deferredLegacyInit = {}
167✔
7
class.deferredInit = {}
167✔
8
class.pageTemplate = { frames = {}, firstContentFrame = nil }
167✔
9
class.defaultFrameset = {}
167✔
10
class.firstContentFrame = "page"
167✔
11
class.options = setmetatable({}, {
334✔
12
    _opts = {},
167✔
13
    __newindex = function (self, key, value)
14
      local opts = getmetatable(self)._opts
697✔
15
      if type(opts[key]) == "function" then
697✔
16
        opts[key](class, value)
368✔
17
      elseif type(value) == "function" then
513✔
18
        opts[key] = value
512✔
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
10✔
27
      if type(key) == "number" then return nil end
10✔
28
      local opt = getmetatable(self)._opts[key]
10✔
29
      if type(opt) == "function" then
10✔
30
        return opt(class)
10✔
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
  })
167✔
38
class.hooks = {
167✔
39
  newpage = {},
167✔
40
  endpage = {},
167✔
41
  finish = {},
167✔
42
}
167✔
43

44
class.packages = {}
167✔
45

46
function class:_init (options)
167✔
47
  SILE.scratch.half_initialized_class = self
167✔
48
  if self == options then options = {} end
167✔
49
  SILE.languageSupport.loadLanguage('und') -- preload for unlocalized fallbacks
167✔
50
  self:declareOptions()
167✔
51
  self:registerRawHandlers()
167✔
52
  self:declareSettings()
167✔
53
  self:registerCommands()
167✔
54
  self:setOptions(options)
167✔
55
  self:declareFrames(self.defaultFrameset)
167✔
56
  self:registerPostinit(function (self_)
334✔
57
      if type(self.firstContentFrame) == "string" then
167✔
58
        self_.pageTemplate.firstContentFrame = self_.pageTemplate.frames[self_.firstContentFrame]
167✔
59
      end
60
      local frame = self_:initialFrame()
167✔
61
      SILE.typesetter = SILE.typesetters.base(frame)
334✔
62
      SILE.typesetter:registerPageEndHook(function ()
334✔
63
        SU.debug("frames", function ()
434✔
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 ()
167✔
72
  self._initialized = true
167✔
73
  for i, func in ipairs(self.deferredInit) do
416✔
74
    func(self)
249✔
75
    self.deferredInit[i] = nil
249✔
76
  end
77
  SILE.scratch.half_initialized_class = nil
167✔
78
end
79

80
function class:setOptions (options)
167✔
81
  options = options or {}
167✔
82
  options.papersize = options.papersize or "a4"
167✔
83
  for option, value in pairs(options) do
352✔
84
    self.options[option] = value
185✔
85
  end
86
end
87

88
function class:declareOption (option, setter)
167✔
89
  rawset(getmetatable(self.options)._opts, option, nil)
512✔
90
  self.options[option] = setter
512✔
91
end
92

93
function class:declareOptions ()
167✔
94
  self:declareOption("class", function (_, name)
334✔
95
    if name then
×
96
      if self._legacy then
×
97
        self._name = name
×
98
      elseif name ~= self._name then
×
99
        SU.error("Cannot change class name after instantiation, derive a new class instead.")
×
100
      end
101
    end
102
    return self._name
×
103
  end)
104
  self:declareOption("papersize", function (_, size)
334✔
105
    if size then
167✔
106
      self.papersize = size
167✔
107
      SILE.documentState.paperSize = SILE.papersize(size)
334✔
108
      SILE.documentState.orgPaperSize = SILE.documentState.paperSize
167✔
109
      SILE.newFrame({
334✔
110
        id = "page",
111
        left = 0,
112
        top = 0,
113
        right = SILE.documentState.paperSize[1],
167✔
114
        bottom = SILE.documentState.paperSize[2]
167✔
115
      })
116
    end
117
    return self.papersize
167✔
118
  end)
119
end
120

121
function class.declareSettings (_)
167✔
122
  SILE.settings:declare({
167✔
123
    parameter = "current.parindent",
124
    type = "glue or nil",
125
    default = nil,
126
    help = "Glue at start of paragraph"
×
127
  })
128
  SILE.settings:declare({
167✔
129
    parameter = "current.hangIndent",
130
    type = "measurement or nil",
131
    default = nil,
132
    help = "Size of hanging indent"
×
133
  })
134
  SILE.settings:declare({
167✔
135
    parameter = "current.hangAfter",
136
    type = "integer or nil",
137
    default = nil,
138
    help = "Number of lines affected by handIndent"
×
139
  })
140
end
141

142
function class:loadPackage (packname, options)
167✔
143
  local pack = require(("packages.%s"):format(packname))
944✔
144
  if type(pack) == "table" and pack.type == "package" then -- new package
944✔
145
    self.packages[pack._name] = pack(options)
1,888✔
146
  else -- legacy package
147
    self:initPackage(pack, options)
×
148
  end
149
end
150

151
function class:initPackage (pack, options)
167✔
152
  SU.deprecated("class:initPackage(options)", "package(options)", "0.14.0", "0.16.0", [[
×
153
  This package appears to be a legacy format package. It returns a table
154
  an expects SILE to guess a bit about what to do. New packages inherit
155
  from the base class and have a constructor function (_init) that
156
  automatically handles setup.]])
×
157
  if type(pack) == "table" then
×
158
    if pack.exports then pl.tablex.update(self, pack.exports) end
×
159
    if type(pack.declareSettings) == "function" then
×
160
      pack.declareSettings(self)
×
161
    end
162
    if type(pack.registerRawHandlers) == "function" then
×
163
      pack.registerRawHandlers(self)
×
164
    end
165
    if type(pack.registerCommands) == "function" then
×
166
      pack.registerCommands(self)
×
167
    end
168
    if type(pack.init) == "function" then
×
169
      self:registerPostinit(pack.init, options)
×
170
    end
171
  end
172
end
173

174
function class:registerLegacyPostinit (func, options)
167✔
175
  if self._initialized then return func(self, options) end
×
176
  table.insert(self.deferredLegacyInit, function (_)
×
177
      func(self, options)
×
178
    end)
179
end
180

181
function class:registerPostinit (func, options)
167✔
182
  if self._initialized then return func(self, options) end
272✔
183
  table.insert(self.deferredInit, function (_)
498✔
184
      func(self, options)
249✔
185
    end)
186
end
187

188
function class:registerHook (category, func)
167✔
189
  for _, func_ in ipairs(self.hooks[category]) do
753✔
190
    if func_ == func then
246✔
191
      return
1✔
192
      --[[ See https://github.com/sile-typesetter/sile/issues/1531
193
      return SU.warn("Attempted to set the same function hook twice, probably unintended, skipping.")
194
      -- If the same function signature is already set a package is probably being
195
      -- re-initialized. Ditch the first instance of the hook so that it runs in
196
      -- the order of last initialization.
197
      self.hooks[category][_] = nil
198
      ]]
199
    end
200
  end
201
  table.insert(self.hooks[category], func)
507✔
202
end
203

204
function class:runHooks (category, options)
167✔
205
  for _, func in ipairs(self.hooks[category]) do
940✔
206
    SU.debug("classhooks", "Running hook from", category, options and "with options " .. #options)
494✔
207
    func(self, options)
494✔
208
  end
209
end
210

211
function class.registerCommand (_, name, func, help, pack)
167✔
212
  SILE.Commands[name] = func
17,344✔
213
  if not pack then
17,344✔
214
    local where = debug.getinfo(2).source
17,329✔
215
    pack = where:match("(%w+).lua")
17,329✔
216
  end
217
  --if not help and not pack:match(".sil") then SU.error("Could not define command '"..name.."' (in package "..pack..") - no help text" ) end
218
  SILE.Help[name] = {
17,344✔
219
    description = help,
17,344✔
220
    where = pack
17,344✔
221
  }
17,344✔
222
end
223

224
function class.registerRawHandler (_, format, callback)
167✔
225
  SILE.rawHandlers[format] = callback
171✔
226
end
227

228
function class:registerRawHandlers ()
167✔
229

230
  self:registerRawHandler("text", function (_, content)
334✔
231
    SILE.settings:temporarily(function()
2✔
232
      SILE.settings:set("typesetter.parseppattern", "\n")
1✔
233
      SILE.settings:set("typesetter.obeyspaces", true)
1✔
234
      SILE.typesetter:typeset(content[1])
1✔
235
    end)
236
  end)
237

238
end
239

240
local function packOptions (options)
241
  local relevant = pl.tablex.copy(options)
146✔
242
  relevant.src = nil
146✔
243
  relevant.format = nil
146✔
244
  relevant.module = nil
146✔
245
  relevant.require = nil
146✔
246
  return relevant
146✔
247
end
248

249
function class:registerCommands ()
167✔
250

251
  local function replaceProcessBy(replacement, tree)
252
    if type(tree) ~= "table" then return tree end
175✔
253
    local ret = pl.tablex.deepcopy(tree)
106✔
254
    if tree.command == "process" then
106✔
255
      return replacement
7✔
256
    else
257
      for i, child in ipairs(tree) do
231✔
258
        ret[i] = replaceProcessBy(replacement, child)
264✔
259
      end
260
      return ret
99✔
261
    end
262
  end
263

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

296
  -- A utility function that allows SILE.call() to be used as a noop wrapper.
297
  self:registerCommand("noop", function (_, content)
334✔
298
    SILE.process(content)
×
299
  end)
300

301
  -- The document (SIL) or sile (XML) command is always the sigular leaf at the
302
  -- top level of our AST. The work you might expect to see happen here is
303
  -- actually handled by SILE.inputter:classInit() before we get here, so these
304
  -- are just pass through functions. Theoretically, this could be a useful
305
  -- point to hook into-especially for included documents.
306
  self:registerCommand("document", function (_, content)
334✔
307
    SILE.process(content)
×
308
  end)
309
  self:registerCommand("sile", function (_, content)
334✔
310
    SILE.process(content)
×
311
  end)
312

313
  self:registerCommand("comment", function (_, _)
334✔
314
  end, "Ignores any text within this command's body.")
167✔
315

316
  self:registerCommand("process", function ()
334✔
317
    SU.error("Encountered unsubstituted \\process.")
×
318
  end, "Within a macro definition, processes the contents of the macro body.")
167✔
319

320
  self:registerCommand("script", function (options, content)
334✔
321
    local packopts = packOptions(options)
37✔
322
    if SU.hasContent(content) then
74✔
323
      return SILE.processString(content[1], options.format or "lua", nil, packopts)
33✔
324
    elseif options.src then
4✔
325
      return SILE.require(options.src)
4✔
326
    else
327
      SU.error("\\script function requires inline content or a src file path")
×
328
      return SILE.processString(content[1], options.format or "lua", nil, packopts)
×
329
    end
330
  end, "Runs lua code. The code may be supplied either inline or using src=...")
167✔
331

332
  self:registerCommand("include", function (options, content)
334✔
333
    local packopts = packOptions(options)
1✔
334
    if SU.hasContent(content) then
2✔
335
      local doc = SU.contentToString(content)
×
336
      return SILE.processString(doc, options.format, nil, packopts)
×
337
    elseif options.src then
1✔
338
      return SILE.processFile(options.src, options.format, packopts)
1✔
339
    else
340
      SU.error("\\include function requires inline content or a src file path")
×
341
    end
342
  end, "Includes a content file for processing.")
167✔
343

344
  self:registerCommand("lua", function (options, content)
334✔
345
    local packopts = packOptions(options)
3✔
346
    if SU.hasContent(content) then
6✔
347
      local doc = SU.contentToString(content)
3✔
348
      return SILE.processString(doc, "lua", nil, packopts)
3✔
349
    elseif options.src then
×
350
      return SILE.processFile(options.src, "lua", packopts)
×
351
    elseif options.require then
×
352
      local module = SU.required(options, "require", "lua")
×
353
      return require(module)
×
354
    else
355
      SU.error("\\lua function requires inline content or a src file path or a require module name")
×
356
    end
357
  end, "Run Lua code. The code may be supplied either inline, using require=... for a Lua module, or using src=... for a file path")
167✔
358

359
  self:registerCommand("sil", function (options, content)
334✔
360
    local packopts = packOptions(options)
×
361
    if SU.hasContent(content) then
×
362
      local doc = SU.contentToString(content)
×
363
      return SILE.processString(doc, "sil")
×
364
    elseif options.src then
×
365
      return SILE.processFile(options.src, "sil", packopts)
×
366
    else
367
      SU.error("\\sil function requires inline content or a src file path")
×
368
    end
369
  end, "Process sil content. The content may be supplied either inline or using src=...")
167✔
370

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

383
  self:registerCommand("use", function (options, content)
334✔
384
    local packopts = packOptions(options)
105✔
385
    if content[1] and string.len(content[1]) > 0 then
105✔
386
      local doc = SU.contentToString(content)
×
387
      SILE.processString(doc, "lua", nil, packopts)
×
388
    else
389
      if options.src then
105✔
390
        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.")
×
391
        SILE.processFile(options.src, "lua", packopts)
×
392
      else
393
        local module = SU.required(options, "module", "use")
105✔
394
        SILE.use(module, packopts)
105✔
395
      end
396
    end
397
  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.")
272✔
398

399
  self:registerCommand("raw", function (options, content)
334✔
400
    local rawtype = SU.required(options, "type", "raw")
4✔
401
    local handler = SILE.rawHandlers[rawtype]
4✔
402
    if not handler then SU.error("No inline handler for '"..rawtype.."'") end
4✔
403
    handler(options, content)
4✔
404
  end, "Invoke a raw passthrough handler")
171✔
405

406
  self:registerCommand("pagetemplate", function (options, content)
334✔
407
    SILE.typesetter:pushState()
8✔
408
    SILE.documentState.thisPageTemplate = { frames = {} }
8✔
409
    SILE.process(content)
8✔
410
    SILE.documentState.thisPageTemplate.firstContentFrame = SILE.getFrame(options["first-content-frame"])
16✔
411
    SILE.typesetter:initFrame(SILE.documentState.thisPageTemplate.firstContentFrame)
8✔
412
    SILE.typesetter:popState()
8✔
413
  end, "Defines a new page template for the current page and sets the typesetter to use it.")
175✔
414

415
  self:registerCommand("frame", function (options, _)
334✔
416
    SILE.documentState.thisPageTemplate.frames[options.id] = SILE.newFrame(options)
62✔
417
  end, "Declares (or re-declares) a frame on this page.")
198✔
418

419
  self:registerCommand("penalty", function (options, _)
334✔
420
    if SU.boolean(options.vertical, false) and not SILE.typesetter:vmode() then
551✔
421
      SILE.typesetter:leaveHmode()
4✔
422
    end
423
    if SILE.typesetter:vmode() then
526✔
424
      SILE.typesetter:pushVpenalty({ penalty = tonumber(options.penalty) })
428✔
425
    else
426
      SILE.typesetter:pushPenalty({ penalty = tonumber(options.penalty) })
49✔
427
    end
428
  end, "Inserts a penalty node. Option is penalty= for the size of the penalty.")
430✔
429

430
  self:registerCommand("discretionary", function (options, _)
334✔
431
    local discretionary = SILE.nodefactory.discretionary({})
2✔
432
    if options.prebreak then
2✔
433
      local hbox = SILE.typesetter:makeHbox({ options.prebreak })
2✔
434
      discretionary.prebreak = { hbox }
2✔
435
    end
436
    if options.postbreak then
2✔
437
      local hbox = SILE.typesetter:makeHbox({ options.postbreak })
×
438
      discretionary.postbreak = { hbox }
×
439
    end
440
    if options.replacement then
2✔
441
      local hbox = SILE.typesetter:makeHbox({ options.replacement })
2✔
442
      discretionary.replacement = { hbox }
2✔
443
    end
444
    table.insert(SILE.typesetter.state.nodes, discretionary)
2✔
445
  end, "Inserts a discretionary node.")
169✔
446

447
  self:registerCommand("glue", function (options, _)
334✔
448
    local width = SU.cast("length", options.width):absolute()
104✔
449
    SILE.typesetter:pushGlue(width)
52✔
450
  end, "Inserts a glue node. The width option denotes the glue dimension.")
219✔
451

452
  self:registerCommand("kern", function (options, _)
334✔
453
    local width = SU.cast("length", options.width):absolute()
148✔
454
    SILE.typesetter:pushHorizontal(SILE.nodefactory.kern(width))
148✔
455
  end, "Inserts a glue node. The width option denotes the glue dimension.")
241✔
456

457
  self:registerCommand("skip", function (options, _)
334✔
458
    options.discardable = SU.boolean(options.discardable, false)
58✔
459
    options.height = SILE.length(options.height):absolute()
87✔
460
    SILE.typesetter:leaveHmode()
29✔
461
    if options.discardable then
29✔
462
      SILE.typesetter:pushVglue(options)
×
463
    else
464
      SILE.typesetter:pushExplicitVglue(options)
29✔
465
    end
466
  end, "Inserts vertical skip. The height options denotes the skip dimension.")
196✔
467

468
  self:registerCommand("par", function (_, _)
334✔
469
    SILE.typesetter:endline()
290✔
470
  end, "Ends the current paragraph.")
457✔
471

472
end
473

474
function class:initialFrame ()
167✔
475
  SILE.documentState.thisPageTemplate = pl.tablex.deepcopy(self.pageTemplate)
446✔
476
  SILE.frames = { page = SILE.frames.page }
223✔
477
  for k, v in pairs(SILE.documentState.thisPageTemplate.frames) do
971✔
478
    SILE.frames[k] = v
748✔
479
  end
480
  if not SILE.documentState.thisPageTemplate.firstContentFrame then
223✔
481
    SILE.documentState.thisPageTemplate.firstContentFrame = SILE.frames[self.firstContentFrame]
×
482
  end
483
  SILE.documentState.thisPageTemplate.firstContentFrame:invalidate()
223✔
484
  return SILE.documentState.thisPageTemplate.firstContentFrame
223✔
485
end
486

487
function class:declareFrame (id, spec)
167✔
488
  spec.id = id
550✔
489
  if spec.solve then
550✔
490
    self.pageTemplate.frames[id] = spec
×
491
  else
492
    self.pageTemplate.frames[id] = SILE.newFrame(spec)
1,100✔
493
  end
494
  --   next = spec.next,
495
  --   left = spec.left and fW(spec.left),
496
  --   right = spec.right and fW(spec.right),
497
  --   top = spec.top and fH(spec.top),
498
  --   bottom = spec.bottom and fH(spec.bottom),
499
  --   height = spec.height and fH(spec.height),
500
  --   width = spec.width and fH(spec.width),
501
  --   id = id
502
  -- })
503
end
504

505
function class:declareFrames (specs)
167✔
506
  if specs then
167✔
507
    for k, v in pairs(specs) do self:declareFrame(k, v) end
1,235✔
508
  end
509
end
510

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

537
-- WARNING: not called as class method
538
function class.endPar (typesetter)
167✔
539
  typesetter:pushVglue(SILE.settings:get("document.parskip"))
1,588✔
540
  if SILE.settings:get("current.hangIndent") then
1,588✔
541
    SILE.settings:set("current.hangIndent", nil)
4✔
542
    SILE.settings:set("linebreak.hangIndent", nil)
4✔
543
  end
544
  if SILE.settings:get("current.hangAfter") then
1,588✔
545
    SILE.settings:set("current.hangAfter", nil)
4✔
546
    SILE.settings:set("linebreak.hangAfter", nil)
4✔
547
  end
548
end
549

550
function class:newPage ()
167✔
551
  SILE.outputter:newPage()
56✔
552
  self:runHooks("newpage")
56✔
553
  -- Any other output-routiney things will be done here by inheritors
554
  return self:initialFrame()
56✔
555
end
556

557
function class:endPage ()
167✔
558
  SILE.typesetter.frame:leave(SILE.typesetter)
223✔
559
  self:runHooks("endpage")
223✔
560
  -- I'm trying to call up a new frame here, don't cause a page break in the current one
561
  -- SILE.typesetter:leaveHmode()
562
  -- Any other output-routiney things will be done here by inheritors
563
end
564

565
function class:finish ()
167✔
566
  SILE.inputter:postamble()
167✔
567
  SILE.call("vfill")
167✔
568
  while not SILE.typesetter:isQueueEmpty() do
668✔
569
    SILE.call("supereject")
167✔
570
    SILE.typesetter:leaveHmode(true)
167✔
571
    SILE.typesetter:buildPage()
167✔
572
    if not SILE.typesetter:isQueueEmpty() then
334✔
573
      SILE.typesetter:initNextFrame()
5✔
574
    end
575
  end
576
  SILE.typesetter:runHooks("pageend") -- normally run by the typesetter
167✔
577
  self:endPage()
167✔
578
    if SILE.typesetter then
167✔
579
      assert(SILE.typesetter:isQueueEmpty(), "queues not empty")
334✔
580
    end
581
  SILE.outputter:finish()
167✔
582
  self:runHooks("finish")
167✔
583
end
584

585
return class
167✔
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