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

sile-typesetter / sile / 9304049654

30 May 2024 02:12PM UTC coverage: 60.021% (-14.7%) from 74.707%
9304049654

push

github

web-flow
Merge 1a26b4f22 into a1fd105f8

6743 of 12900 new or added lines in 186 files covered. (52.27%)

347 existing lines in 49 files now uncovered.

10311 of 17179 relevant lines covered (60.02%)

3307.34 hits per line

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

0.0
/packages/inputfilter/init.lua
UNCOV
1
local base = require("packages.base")
×
2

UNCOV
3
local package = pl.class(base)
×
UNCOV
4
package._name = "inputfilter"
×
5

UNCOV
6
function package:transformContent (content, transformFunction, extraArgs)
×
NEW
7
   local newContent = {}
×
NEW
8
   for k, v in SU.sortedpairs(content) do
×
NEW
9
      if type(k) == "number" then
×
NEW
10
         if type(v) == "string" then
×
NEW
11
            local transformed = transformFunction(v, content, extraArgs)
×
NEW
12
            if type(transformed) == "table" then
×
NEW
13
               for i = 1, #transformed do
×
NEW
14
                  newContent[#newContent + 1] = transformed[i]
×
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
NEW
23
         newContent[k] = v
×
24
      end
25
   end
NEW
26
   return newContent
×
27
end
28

UNCOV
29
function package.createCommand (_, pos, col, lno, command, options, content)
×
NEW
30
   local position = { lno = lno, col = col, pos = pos }
×
NEW
31
   return SU.ast.createCommand(command, options, content, position)
×
32
end
33

UNCOV
34
function package:_init ()
×
NEW
35
   base._init(self)
×
NEW
36
   self:deprecatedExport("createCommand", self.createCommand)
×
NEW
37
   self:deprecatedExport("transformContent", self.transformContent)
×
38
end
39

40
package.documentation = [[
41
\begin{document}
42
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.
43
It does this by allowing you to rewrite the abstract syntax tree representing the document.
44

45
Loading \autodoc:package{inputfilter} into your class with \code{class:loadPackage("inputfilter")} provides you with two new Lua functions: \code{transformContent} and \code{createCommand}.
46
\code{transformContent} takes a content tree and applies a transformation function to the text within it.
47
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.
48
\end{document}
UNCOV
49
]]
×
50

UNCOV
51
return package
×
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

© 2026 Coveralls, Inc