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

sile-typesetter / sile / 9400953783

06 Jun 2024 12:32PM UTC coverage: 62.819% (-11.3%) from 74.124%
9400953783

push

github

alerque
Merge branch 'develop'

1752 of 2644 new or added lines in 109 files covered. (66.26%)

2019 existing lines in 84 files now uncovered.

10830 of 17240 relevant lines covered (62.82%)

3306.33 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
]]
99✔
10

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

15
inputter._docclass = nil
99✔
16

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

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

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

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

55
function inputter.findInTree (_, tree, command)
99✔
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
198✔
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 (_)
99✔
85
   process_ambles(SILE.input.preambles)
99✔
86
end
87

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

92
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