• 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

93.55
/packages/inputfilter/init.lua
1
local base = require("packages.base")
1✔
2

3
local package = pl.class(base)
1✔
4
package._name = "inputfilter"
1✔
5

6
function package:transformContent (content, transformFunction, extraArgs)
1✔
7
   local newContent = {}
2✔
8
   for k, v in SU.sortedpairs(content) do
18✔
9
      if type(k) == "number" then
14✔
10
         if type(v) == "string" then
2✔
11
            local transformed = transformFunction(v, content, extraArgs)
2✔
12
            if type(transformed) == "table" then
2✔
13
               for i = 1, #transformed do
44✔
14
                  newContent[#newContent + 1] = transformed[i]
42✔
15
               end
16
            else
NEW
17
               newContent[#newContent + 1] = transformed
×
18
            end
19
         else
NEW
20
            newContent[#newContent + 1] = self:transformContent(v, transformFunction, extraArgs)
×
21
         end
22
      else
23
         newContent[k] = v
12✔
24
      end
25
   end
26
   return newContent
2✔
27
end
28

29
function package.createCommand (_, pos, col, lno, command, options, content)
1✔
30
   local result = { content }
22✔
31
   result.col = col
22✔
32
   result.lno = lno
22✔
33
   result.pos = pos
22✔
34
   result.options = options
22✔
35
   result.command = command
22✔
36
   result.id = "command"
22✔
37
   return result
22✔
38
end
39

40
function package:_init ()
1✔
41
   base._init(self)
1✔
42
   self:deprecatedExport("createCommand", self.createCommand)
1✔
43
   self:deprecatedExport("transformContent", self.transformContent)
1✔
44
end
45

46
package.documentation = [[
47
\begin{document}
48
The \autodoc:package{inputfilter} package provides ways for class authors to transform the input of a SILE document after it is parsed but before it is processed.
49
It does this by allowing you to rewrite the abstract syntax tree representing the document.
50

51
Loading \autodoc:package{inputfilter} into your class with \code{class:loadPackage("inputfilter")} provides you with two new Lua functions: \code{transformContent} and \code{createCommand}.
52
\code{transformContent} takes a content tree and applies a transformation function to the text within it.
53
See \url{https://sile-typesetter.org/examples/inputfilter.sil} for a simple example, and \url{https://sile-typesetter.org/examples/chordmode.sil} for a more complete one.
54
\end{document}
55
]]
1✔
56

57
return package
1✔
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