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

sile-typesetter / sile / 8288578143

14 Mar 2024 09:39PM UTC coverage: 64.155% (-10.6%) from 74.718%
8288578143

Pull #1904

github

alerque
chore(core): Fixup ec6ed657 which didn't shim old pack styles properly
Pull Request #1904: Merge develop into master (commit to next release being breaking)

1648 of 2421 new or added lines in 107 files covered. (68.07%)

1843 existing lines in 77 files now uncovered.

10515 of 16390 relevant lines covered (64.15%)

3306.56 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)
×
UNCOV
7
  local newContent = {}
×
UNCOV
8
  for k, v in SU.sortedpairs(content) do
×
UNCOV
9
    if type(k) == "number" then
×
UNCOV
10
      if type(v) == "string" then
×
UNCOV
11
        local transformed = transformFunction(v, content, extraArgs)
×
UNCOV
12
        if type(transformed) == "table" then
×
UNCOV
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
UNCOV
21
      newContent[k] = v
×
22
    end
23
  end
UNCOV
24
  return newContent
×
25
end
26

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

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

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

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

UNCOV
49
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