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

sile-typesetter / sile / 7232859119

16 Dec 2023 03:49PM UTC coverage: 66.878% (-7.7%) from 74.62%
7232859119

push

github

web-flow
Merge 05d75c2a3 into 8686730e4

0 of 4 new or added lines in 1 file covered. (0.0%)

1201 existing lines in 56 files now uncovered.

10550 of 15775 relevant lines covered (66.88%)

3347.52 hits per line

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

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

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

44
class.packages = {}
71✔
45

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

80
function class:setOptions (options)
71✔
81
  options = options or {}
71✔
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)
142✔
85
  options.landscape = nil
71✔
86
  self.options.papersize = options.papersize or "a4"
71✔
87
  options.papersize = nil
71✔
88
  for option, value in pairs(options) do
76✔
89
    self.options[option] = value
5✔
90
  end
91
end
92

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

98
function class:declareOptions ()
71✔
99
  self:declareOption("class", function (_, name)
142✔
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)
142✔
110
    if landscape then
142✔
111
      self.landscape = landscape
1✔
112
    end
113
    return self.landscape
142✔
114
  end)
115
  self:declareOption("papersize", function (_, size)
142✔
116
    if size then
71✔
117
      self.papersize = size
71✔
118
      SILE.documentState.paperSize = SILE.papersize(size, self.options.landscape)
213✔
119
      SILE.documentState.orgPaperSize = SILE.documentState.paperSize
71✔
120
      SILE.newFrame({
142✔
121
        id = "page",
122
        left = 0,
123
        top = 0,
124
        right = SILE.documentState.paperSize[1],
71✔
125
        bottom = SILE.documentState.paperSize[2]
71✔
126
      })
127
    end
128
    return self.papersize
71✔
129
  end)
130
end
131

132
function class.declareSettings (_)
71✔
133
  SILE.settings:declare({
71✔
134
    parameter = "current.parindent",
135
    type = "glue or nil",
136
    default = nil,
137
    help = "Glue at start of paragraph"
×
138
  })
139
  SILE.settings:declare({
71✔
140
    parameter = "current.hangIndent",
141
    type = "measurement or nil",
142
    default = nil,
143
    help = "Size of hanging indent"
×
144
  })
145
  SILE.settings:declare({
71✔
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)
71✔
154
  local pack = require(("packages.%s"):format(packname))
386✔
155
  if type(pack) == "table" and pack.type == "package" then -- new package
386✔
156
    self.packages[pack._name] = pack(options)
772✔
157
  else -- legacy package
158
    self:initPackage(pack, options)
×
159
  end
160
end
161

162
function class:initPackage (pack, options)
71✔
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)
71✔
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)
71✔
193
  if self._initialized then return func(self, options) end
110✔
194
  table.insert(self.deferredInit, function (_)
206✔
195
      func(self, options)
103✔
196
    end)
197
end
198

199
function class:registerHook (category, func)
71✔
200
  for _, func_ in ipairs(self.hooks[category]) do
310✔
201
    if func_ == func then
98✔
UNCOV
202
      return
×
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)
212✔
213
end
214

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

222
function class.registerCommand (_, name, func, help, pack)
71✔
223
  SILE.Commands[name] = func
7,321✔
224
  if not pack then
7,321✔
225
    local where = debug.getinfo(2).source
7,318✔
226
    pack = where:match("(%w+).lua")
7,318✔
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] = {
7,321✔
230
    description = help,
7,321✔
231
    where = pack
7,321✔
232
  }
7,321✔
233
end
234

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

239
function class:registerRawHandlers ()
71✔
240

241
  self:registerRawHandler("text", function (_, content)
142✔
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)
72✔
253
  relevant.src = nil
72✔
254
  relevant.format = nil
72✔
255
  relevant.module = nil
72✔
256
  relevant.require = nil
72✔
257
  return relevant
72✔
258
end
259

260
function class:registerCommands ()
71✔
261

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

275
  self:registerCommand("define", function (options, content)
142✔
276
    SU.required(options, "command", "defining command")
3✔
277
    if type(content) == "function" then
3✔
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
3✔
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)
6✔
286
      SU.debug("macros", "Processing macro \\" .. options["command"])
5✔
287
      local macroArg
288
      if type(inner_content) == "function" then
5✔
UNCOV
289
        macroArg = inner_content
×
290
      elseif type(inner_content) == "table" then
5✔
291
        macroArg = pl.tablex.copy(inner_content)
10✔
292
        macroArg.command = nil
5✔
293
        macroArg.id = nil
5✔
UNCOV
294
      elseif inner_content == nil then
×
UNCOV
295
        macroArg = {}
×
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)
5✔
302
      SILE.process(newContent)
5✔
303
      SU.debug("macros", "Finished processing \\" .. options["command"])
5✔
304
    end, options.help, SILE.currentlyProcessingFile)
8✔
305
  end, "Define a new macro. \\define[command=example]{ ... \\process }")
74✔
306

307
  -- A utility function that allows SILE.call() to be used as a noop wrapper.
308
  self:registerCommand("noop", function (_, content)
142✔
UNCOV
309
    SILE.process(content)
×
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)
142✔
318
    SILE.process(content)
×
319
  end)
320
  self:registerCommand("sile", function (_, content)
142✔
321
    SILE.process(content)
×
322
  end)
323

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

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

331
  self:registerCommand("script", function (options, content)
142✔
332
    local packopts = packOptions(options)
21✔
333
    if SU.hasContent(content) then
42✔
334
      return SILE.processString(content[1], options.format or "lua", nil, packopts)
19✔
335
    elseif options.src then
2✔
336
      return SILE.require(options.src)
2✔
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=...")
71✔
342

343
  self:registerCommand("include", function (options, content)
142✔
UNCOV
344
    local packopts = packOptions(options)
×
UNCOV
345
    if SU.hasContent(content) then
×
346
      local doc = SU.contentToString(content)
×
347
      return SILE.processString(doc, options.format, nil, packopts)
×
UNCOV
348
    elseif options.src then
×
UNCOV
349
      return SILE.processFile(options.src, options.format, packopts)
×
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.")
71✔
354

355
  self:registerCommand("lua", function (options, content)
142✔
356
    local packopts = packOptions(options)
1✔
357
    if SU.hasContent(content) then
2✔
358
      local doc = SU.contentToString(content)
1✔
359
      return SILE.processString(doc, "lua", nil, packopts)
1✔
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")
71✔
369

370
  self:registerCommand("sil", function (options, content)
142✔
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=...")
71✔
381

382
  self:registerCommand("xml", function (options, content)
142✔
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=...")
71✔
393

394
  self:registerCommand("use", function (options, content)
142✔
395
    local packopts = packOptions(options)
50✔
396
    if content[1] and string.len(content[1]) > 0 then
50✔
397
      local doc = SU.contentToString(content)
×
398
      SILE.processString(doc, "lua", nil, packopts)
×
399
    else
400
      if options.src then
50✔
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")
50✔
405
        SILE.use(module, packopts)
50✔
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.")
121✔
409

410
  self:registerCommand("raw", function (options, content)
142✔
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")
75✔
416

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

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

430
  self:registerCommand("penalty", function (options, _)
142✔
431
    if SU.boolean(options.vertical, false) and not SILE.typesetter:vmode() then
277✔
432
      SILE.typesetter:leaveHmode()
3✔
433
    end
434
    if SILE.typesetter:vmode() then
264✔
435
      SILE.typesetter:pushVpenalty({ penalty = tonumber(options.penalty) })
200✔
436
    else
437
      SILE.typesetter:pushPenalty({ penalty = tonumber(options.penalty) })
32✔
438
    end
439
  end, "Inserts a penalty node. Option is penalty= for the size of the penalty.")
203✔
440

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

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

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

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

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

483
end
484

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

498
function class:declareFrame (id, spec)
71✔
499
  spec.id = id
230✔
500
  if spec.solve then
230✔
501
    self.pageTemplate.frames[id] = spec
×
502
  else
503
    self.pageTemplate.frames[id] = SILE.newFrame(spec)
460✔
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)
71✔
517
  if specs then
71✔
518
    for k, v in pairs(specs) do self:declareFrame(k, v) end
521✔
519
  end
520
end
521

522
-- WARNING: not called as class method
523
function class.newPar (typesetter)
71✔
524
  local parindent = SILE.settings:get("current.parindent") or SILE.settings:get("document.parindent")
858✔
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())
858✔
537
  SILE.settings:set("current.parindent", nil)
429✔
538
  local hangIndent = SILE.settings:get("current.hangIndent")
429✔
539
  if hangIndent then
429✔
540
    SILE.settings:set("linebreak.hangIndent", hangIndent)
4✔
541
  end
542
  local hangAfter = SILE.settings:get("current.hangAfter")
429✔
543
  if hangAfter then
429✔
544
    SILE.settings:set("linebreak.hangAfter", hangAfter)
4✔
545
  end
546
end
547

548
-- WARNING: not called as class method
549
function class.endPar (typesetter)
71✔
550
  typesetter:pushVglue(SILE.settings:get("document.parskip"))
938✔
551
  if SILE.settings:get("current.hangIndent") then
938✔
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
938✔
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 ()
71✔
562
  SILE.outputter:newPage()
27✔
563
  self:runHooks("newpage")
27✔
564
  -- Any other output-routiney things will be done here by inheritors
565
  return self:initialFrame()
27✔
566
end
567

568
function class:endPage ()
71✔
569
  SILE.typesetter.frame:leave(SILE.typesetter)
98✔
570
  self:runHooks("endpage")
98✔
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 ()
71✔
577
  SILE.inputter:postamble()
71✔
578
  SILE.call("vfill")
71✔
579
  while not SILE.typesetter:isQueueEmpty() do
284✔
580
    SILE.call("supereject")
71✔
581
    SILE.typesetter:leaveHmode(true)
71✔
582
    SILE.typesetter:buildPage()
71✔
583
    if not SILE.typesetter:isQueueEmpty() then
142✔
584
      SILE.typesetter:initNextFrame()
2✔
585
    end
586
  end
587
  SILE.typesetter:runHooks("pageend") -- normally run by the typesetter
71✔
588
  self:endPage()
71✔
589
  if SILE.typesetter and not SILE.typesetter:isQueueEmpty() then
142✔
590
    SU.error("Queues are not empty as expected after ending last page", true)
×
591
  end
592
  SILE.outputter:finish()
71✔
593
  self:runHooks("finish")
71✔
594
end
595

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