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

sile-typesetter / sile / 7194809580

13 Dec 2023 11:53AM UTC coverage: 66.473% (+4.2%) from 62.266%
7194809580

Pull #1904

github

web-flow
Merge pull request #1914 from Omikhleia/refactor-ast-utilities-develop
Pull Request #1904: Merge develop into master (commit to next release being breaking)

186 of 346 new or added lines in 29 files covered. (53.76%)

211 existing lines in 18 files now uncovered.

10431 of 15692 relevant lines covered (66.47%)

5005.07 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)
×
NEW
28
  local position = { lno = lno, col = col, pos = pos }
×
NEW
29
  return SU.ast.createCommand(command, options, content, position)
×
30
end
31

32
function package:_init ()
×
33
  base._init(self)
×
34
  self:deprecatedExport("createCommand", self.createCommand)
×
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}
47
]]
×
48

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

© 2024 Coveralls, Inc