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

sile-typesetter / sile / 6915746301

18 Nov 2023 07:02PM UTC coverage: 56.433% (-12.3%) from 68.751%
6915746301

push

github

web-flow
Merge 8b3fdc301 into f64e235fa

8729 of 15468 relevant lines covered (56.43%)

932.75 hits per line

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

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

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

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

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

38
function package:_init ()
×
39
  base._init(self)
×
40
  self:deprecatedExport("createCommand", self.createCommand)
×
41
  self:deprecatedExport("transformContent", self.transformContent)
×
42
end
43

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

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

55
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

© 2025 Coveralls, Inc