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

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

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

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

8
local inputter = pl.class()
181✔
9
inputter.type = "inputter"
181✔
10
inputter._name = "base"
181✔
11

12
inputter._docclass = nil
181✔
13

14
function inputter:_init (options)
181✔
15
   if options then
251✔
16
      self.options = options
37✔
17
   end
18
end
19

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

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

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

54
-- Just a simple one-level find. We're not reimplementing XPath here.
55
function inputter.findInTree (_, tree, command)
181✔
NEW
56
   for i = 1, #tree do
×
NEW
57
      if type(tree[i]) == "table" and tree[i].command == command then
×
NEW
58
         return tree[i]
×
59
      end
60
   end
61
end
62

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

86
function inputter.preamble (_)
181✔
87
   process_ambles(SILE.input.preambles)
181✔
88
end
89

90
function inputter.postamble (_)
181✔
91
   process_ambles(SILE.input.postambles)
181✔
92
end
93

94
return inputter
181✔
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