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

sile-typesetter / sile / 14390735465

10 Apr 2025 09:30PM UTC coverage: 34.559% (-31.7%) from 66.23%
14390735465

push

github

alerque
Merge tag 'v0.15.12' into develop

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

4064 existing lines in 73 files now uncovered.

6918 of 20018 relevant lines covered (34.56%)

2597.26 hits per line

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

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

4
local inputter = pl.class()
99✔
5
inputter.type = "inputter"
99✔
6
inputter._name = "base"
99✔
7

8
function inputter:_init (options)
99✔
9
   SU._avoid_base_class_use(self)
131✔
10
   self.options = options or {}
131✔
11
end
12

13
function inputter:classInit (options)
99✔
14
   options = pl.tablex.merge(options, SILE.input.options, true)
297✔
15
   local constructor, class
16
   if SILE.scratch.class_from_uses then
99✔
UNCOV
17
      constructor = SILE.scratch.class_from_uses
×
UNCOV
18
      class = constructor._name
×
19
   end
20
   class = SILE.input.class or class or options.class or "plain"
99✔
21
   options.class = nil -- don't pass already consumed class option to constructor
99✔
22
   constructor = self._docclass or constructor or SILE.require(class, "classes", true)
198✔
23
   -- Note SILE.documentState.documentClass is set by the instance's own :_post_init()
24
   constructor(options)
99✔
25
end
26

27
function inputter:requireClass (tree)
99✔
28
   local root = SILE.documentState.documentClass == nil
106✔
29
   if root then
106✔
30
      if tree.command ~= "sile" and tree.command ~= "document" then
99✔
UNCOV
31
         SU.error("This isn't a SILE document!")
×
32
      end
33
      self:classInit(tree.options or {})
99✔
34
      self:preamble()
99✔
35
   end
36
end
37

38
function inputter:process (doc)
99✔
39
   -- Input parsers can already return multiple ASTs, but so far we only process one
40
   local tree = self:parse(doc)[1]
210✔
41
   if SU.debugging("inputter") and SU.debugging("ast") then
210✔
42
      SU.debug("inputter", "Dumping AST tree before processing...\n")
×
UNCOV
43
      SU.dump(tree)
×
44
   end
45
   self:requireClass(tree)
105✔
46
   return SILE.process(tree)
105✔
47
end
48

49
function inputter:findInTree (tree, command)
99✔
UNCOV
50
   SU.deprecated("SILE.inputter:findInTree", "SU.ast.findInTree", "0.15.0", "0.17.0")
×
UNCOV
51
   return SU.ast.findInTree(tree, command)
×
52
end
53

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

78
function inputter:preamble ()
99✔
79
   process_ambles(SILE.input.preambles)
99✔
80
end
81

82
function inputter:postamble ()
99✔
83
   process_ambles(SILE.input.postambles)
99✔
84
end
85

86
return inputter
99✔
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