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

sile-typesetter / sile / 11169993653

03 Oct 2024 09:26PM UTC coverage: 63.103% (+29.9%) from 33.23%
11169993653

push

github

web-flow
Merge pull request #2113 from Omikhleia/fix-ast-differences

46 of 57 new or added lines in 5 files covered. (80.7%)

88 existing lines in 10 files now uncovered.

11286 of 17885 relevant lines covered (63.1%)

3626.41 hits per line

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

61.11
/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
]]
97✔
10

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

15
inputter._docclass = nil
97✔
16

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

21
function inputter:classInit (options)
97✔
22
   options = pl.tablex.merge(options, SILE.input.options, true)
291✔
23
   local constructor, class
24
   if SILE.scratch.class_from_uses then
97✔
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"
97✔
29
   options.class = nil -- don't pass already consumed class option to constructor
97✔
30
   constructor = self._docclass or constructor or SILE.require(class, "classes", true)
194✔
31
   if constructor.id then
97✔
32
      SU.deprecated("std.object", "pl.class", "0.13.0", "0.14.0", string.format(_deprecated, constructor.id))
×
33
   end
34
   -- Note SILE.documentState.documentClass is set by the instance's own :_post_init()
35
   constructor(options)
97✔
36
end
37

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

49
function inputter:process (doc)
97✔
50
   -- Input parsers can already return multiple ASTs, but so far we only process one
51
   local tree = self:parse(doc)[1]
206✔
52
   if SU.debugging("inputter") and SU.debugging("ast") then
206✔
NEW
53
      SU.debug("inputter", "Dumping AST tree before processing...\n")
×
NEW
54
      SU.dump(tree)
×
55
   end
56
   self:requireClass(tree)
103✔
57
   return SILE.process(tree)
103✔
58
end
59

60
function inputter.findInTree (_, tree, command)
97✔
61
   SU.deprecated("SILE.inputter:findInTree", "SU.ast.findInTree", "0.15.0", "0.17.0")
×
62
   return SU.ast.findInTree(tree, command)
×
63
end
64

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

89
function inputter.preamble (_)
97✔
90
   process_ambles(SILE.input.preambles)
97✔
91
end
92

93
function inputter.postamble (_)
97✔
94
   process_ambles(SILE.input.postambles)
97✔
95
end
96

97
return inputter
97✔
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