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

sile-typesetter / sile / 8288578143

14 Mar 2024 09:39PM UTC coverage: 64.155% (-10.6%) from 74.718%
8288578143

Pull #1904

github

alerque
chore(core): Fixup ec6ed657 which didn't shim old pack styles properly
Pull Request #1904: Merge develop into master (commit to next release being breaking)

1648 of 2421 new or added lines in 107 files covered. (68.07%)

1843 existing lines in 77 files now uncovered.

10515 of 16390 relevant lines covered (64.15%)

3306.56 hits per line

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

64.0
/inputters/base.lua
1
--- SILE inputter class.
2
-- @interfaces inputters
3

4
local _deprecated = [[
5
  You appear to be using a document class '%s' programmed for SILE <= v0.12.5.
6
  This system was refactored in v0.13.0 and the shims trying to make it
7
  work temporarily without refactoring your classes have been removed
8
  in v0.14.0. Please see v0.13.0 release notes for help.
9
]]
92✔
10

11
local inputter = pl.class()
92✔
12
inputter.type = "inputter"
92✔
13
inputter._name = "base"
92✔
14

15
inputter._docclass = nil
92✔
16

17
function inputter:_init (options)
92✔
18
  self.options = options or {}
124✔
19
end
20

21
function inputter:classInit (options)
92✔
22
  options = pl.tablex.merge(options, SILE.input.options, true)
276✔
23
  local constructor, class
24
  if SILE.scratch.class_from_uses then
92✔
25
    constructor = SILE.scratch.class_from_uses
×
26
    class = constructor._name
×
27
  end
28
  class = SILE.input.class or class or options.class or "plain"
92✔
29
  options.class = nil -- don't pass already consumed class option to constructor
92✔
30
  constructor = self._docclass or constructor or SILE.require(class, "classes", true)
184✔
31
  if constructor.id then
92✔
32
    SU.deprecated("std.object", "pl.class", "0.13.0", "0.14.0", string.format(_deprecated, constructor.id))
×
33
  end
34
  SILE.documentState.documentClass = constructor(options)
184✔
35
end
36

37
function inputter:requireClass (tree)
92✔
38
  local root = SILE.documentState.documentClass == nil
99✔
39
  if root then
99✔
40
    if tree.command ~= "sile" and tree.command ~= "document" then
92✔
41
      SU.error("This isn't a SILE document!")
×
42
    end
43
    self:classInit(tree.options or {})
92✔
44
    self:preamble()
92✔
45
  end
46
end
47

48
function inputter:process (doc)
92✔
49
  -- Input parsers can already return multiple ASTs, but so far we only process one
50
  local tree = self:parse(doc)[1]
196✔
51
  self:requireClass(tree)
98✔
52
  return SILE.process(tree)
98✔
53
end
54

55
function inputter.findInTree (_, tree, command)
92✔
NEW
56
  SU.deprecated("SILE.inputter:findInTree", "SU.ast.findInTree", "0.15.0", "0.17.0")
×
NEW
57
  return SU.ast.findInTree(tree, command)
×
58
end
59

60
local function process_ambles (ambles)
61
  for _, amble in ipairs(ambles) do
184✔
UNCOV
62
    if type(amble) == "string" then
×
63
      SILE.processFile(amble)
×
64
    elseif type(amble) == "function" then
×
65
      SU.warn("Passing functions as pre/postambles is not officially sactioned and may go away without being marked as a breaking change.")
×
66
      amble()
×
67
    elseif type(amble) == "table" then
×
68
      local options = {}
×
69
      if amble.pack then amble, options = amble.pack, amble.options end
×
70
      if amble.type == "package" then
×
NEW
71
        local class = SILE.documentState.documentClass
×
NEW
72
        class:loadPackage(amble, options)
×
73
      else
UNCOV
74
        SILE.documentState.documentClass:initPackage(amble, options)
×
75
      end
76
    end
77
  end
78
end
79

80
function inputter.preamble (_)
92✔
81
  process_ambles(SILE.input.preambles)
92✔
82
end
83

84
function inputter.postamble (_)
92✔
85
  process_ambles(SILE.input.postambles)
92✔
86
end
87

88
return inputter
92✔
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