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

sile-typesetter / sile / 6713098919

31 Oct 2023 10:21PM UTC coverage: 52.831% (-21.8%) from 74.636%
6713098919

push

github

web-flow
Merge d0a2a1ee9 into b185d4972

45 of 45 new or added lines in 3 files covered. (100.0%)

8173 of 15470 relevant lines covered (52.83%)

6562.28 hits per line

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

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

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

6
local outputBackground = function (color)
7
  local page = SILE.getFrame("page")
×
8
  local backgroundColor = SILE.color(color)
×
9
  SILE.outputter:pushColor(backgroundColor)
×
10
  SILE.outputter:drawRule(page:left(), page:top(), page:right(), page:bottom())
×
11
  SILE.outputter:popColor()
×
12
end
13

14
function package:_init ()
×
15
  base._init(self)
×
16
  self:loadPackage("color")
×
17
end
18

19
function package:registerCommands ()
×
20

21
  self:registerCommand("background", function (options, _)
×
22
    options.color = options.color or "white"
×
23
    options.allpages = options.allpages or true
×
24
    outputBackground(options.color)
×
25
    if options.allpages and options.allpages ~= "false" then
×
26
      local oldNewPage = SILE.documentState.documentClass.newPage
×
27
      SILE.documentState.documentClass.newPage = function (self_)
×
28
        local page = oldNewPage(self_)
×
29
        outputBackground(options.color)
×
30
        return page
×
31
      end
32
    end
33
  end, "Draws a solid background color <color> on pages after initialization.")
×
34

35
end
36

37
package.documentation = [[
38
\begin{document}
39
\use[module=packages.background]
40
The \autodoc:package{background} package allows you to set the color of the canvas background (by drawing a solid color block the full size of the page on page initialization).
41
The package provides a \autodoc:command{\background} command which requires at least one parameter, \autodoc:parameter{color=<color specification>}, and sets the background of the current and all following pages to that color.
42
If you want to set only the current page background different from the default, use the parameter \autodoc:parameter{allpages=false}.
43
The color specification in the same as specified in the \autodoc:package{color} package.
44

45
\background[color=#e9d8ba,allpages=false]
46

47
So, for example, \autodoc:command{\background[color=#e9d8ba,allpages=false]} will set a sepia tone background on the current page.
48
\end{document}
49
]]
×
50

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

© 2025 Coveralls, Inc