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

sile-typesetter / sile / 9324025270

31 May 2024 08:35PM UTC coverage: 66.168% (-8.0%) from 74.124%
9324025270

push

github

web-flow
Merge 235329972 into 70ff5c335

1753 of 2583 new or added lines in 108 files covered. (67.87%)

1498 existing lines in 74 files now uncovered.

11404 of 17235 relevant lines covered (66.17%)

2956.13 hits per line

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

62.75
/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
]]
77✔
10

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

15
inputter._docclass = nil
77✔
16

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

21
function inputter:classInit (options)
77✔
22
   options = pl.tablex.merge(options, SILE.input.options, true)
231✔
23
   local constructor, class
24
   if SILE.scratch.class_from_uses then
77✔
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"
77✔
29
   options.class = nil -- don't pass already consumed class option to constructor
77✔
30
   constructor = self._docclass or constructor or SILE.require(class, "classes", true)
154✔
31
   if constructor.id then
77✔
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)
154✔
35
end
36

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

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

55
function inputter.findInTree (_, tree, command)
77✔
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
154✔
UNCOV
62
      if type(amble) == "string" then
×
63
         SILE.processFile(amble)
×
64
      elseif type(amble) == "function" then
×
65
         SU.warn(
×
66
            "Passing functions as pre/postambles is not officially sactioned and may go away without being marked as a breaking change."
67
         )
UNCOV
68
         amble()
×
69
      elseif type(amble) == "table" then
×
70
         local options = {}
×
71
         if amble.pack then
×
72
            amble, options = amble.pack, amble.options
×
73
         end
UNCOV
74
         if amble.type == "package" then
×
NEW
75
            local class = SILE.documentState.documentClass
×
NEW
76
            class:loadPackage(amble, options)
×
77
         else
UNCOV
78
            SILE.documentState.documentClass:initPackage(amble, options)
×
79
         end
80
      end
81
   end
82
end
83

84
function inputter.preamble (_)
77✔
85
   process_ambles(SILE.input.preambles)
77✔
86
end
87

88
function inputter.postamble (_)
77✔
89
   process_ambles(SILE.input.postambles)
77✔
90
end
91

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