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

sile-typesetter / sile / 9324025270

31 May 2024 08:35PM UTC coverage: 66.168% (-8.0%) from 74.124%
9324025270

push

github

web-flow
Merge 235329972 into 70ff5c335

1753 of 2583 new or added lines in 108 files covered. (67.87%)

1498 existing lines in 74 files now uncovered.

11404 of 17235 relevant lines covered (66.17%)

2956.13 hits per line

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

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

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

NEW
6
local background = {}
×
7

8
local outputBackground = function ()
NEW
9
   local pagea = SILE.getFrame("page")
×
NEW
10
   local offset = SILE.documentState.bleed / 2
×
NEW
11
   if type(background.bg) == "string" then
×
NEW
12
      SILE.outputter:drawImage(
×
NEW
13
         background.bg,
×
NEW
14
         pagea:left() - offset,
×
NEW
15
         pagea:top() - offset,
×
NEW
16
         pagea:width() + 2 * offset,
×
NEW
17
         pagea:height() + 2 * offset
×
18
      )
NEW
19
   elseif background.bg then
×
NEW
20
      SILE.outputter:pushColor(background.bg)
×
NEW
21
      SILE.outputter:drawRule(
×
NEW
22
         pagea:left() - offset,
×
NEW
23
         pagea:top() - offset,
×
NEW
24
         pagea:width() + 2 * offset,
×
NEW
25
         pagea:height() + 2 * offset
×
26
      )
NEW
27
      SILE.outputter:popColor()
×
28
   end
NEW
29
   if not background.allpages then
×
NEW
30
      background.bg = nil
×
31
   end
32
end
33

UNCOV
34
function package:_init ()
×
UNCOV
35
   base._init(self)
×
NEW
36
   self.class:registerHook("newpage", outputBackground)
×
37
end
38

UNCOV
39
function package:registerCommands ()
×
UNCOV
40
   self:registerCommand("background", function (options, _)
×
NEW
41
      if SU.boolean(options.disable, false) then
×
42
         -- This option is certainly better than enforcing a white color.
NEW
43
         background.bg = nil
×
NEW
44
         return
×
45
      end
46

NEW
47
      local allpages = SU.boolean(options.allpages, true)
×
NEW
48
      background.allpages = allpages
×
NEW
49
      local color = options.color and SILE.types.color(options.color)
×
NEW
50
      local src = options.src
×
NEW
51
      if src then
×
NEW
52
         background.bg = src and SILE.resolveFile(src) or SU.error("Couldn't find file " .. src)
×
NEW
53
      elseif color then
×
NEW
54
         background.bg = color
×
55
      else
NEW
56
         SU.error("background requires a color or an image src parameter")
×
57
      end
NEW
58
      outputBackground()
×
NEW
59
   end, "Output a solid background color <color> or an image <src> on pages after initialization.")
×
60
end
61

62
package.documentation = [[
63
\begin{document}
64
\use[module=packages.background]
65
As its name implies, the \autodoc:package{background} package allows you to set the color of the page canvas background or to use a background image extending to the full page width and height.
66

67
The package provides a \autodoc:command{\background} command which requires one of the following parameters:
68
\begin{itemize}
69
\item{\autodoc:parameter{color=<color specification>} sets the background of the current and all following pages to that color. The color specification has the same syntax as specified in the \autodoc:package{color} package.}
70
\item{\autodoc:parameter{src=<file>} sets the backgound of the current and all following pages to the specified image. The latter will be scaled to the target dimension.}
71
\end{itemize}
72

73
The background extends to the page trim area (“page bleed”) if the latter is defined.
74
This is to ensure that it indeed “bleeds” off the sides of the page, so as to avoid thin white lignes on an otherwise full color page when the paper sheet is cut to dimension but some pages are trimmed slightly more than others.
75
If setting only the current page background different from the default is desired, an extra parameter \autodoc:parameter{allpages=false} can be passed.
76

77
\background[color=#e9d8ba,allpages=false]
78

79
So, for example, \autodoc:command{\background[color=#e9d8ba,allpages=false]} will set a sepia tone background on the current page.
80
The \autodoc:parameter{disable=true} parameter allows disabling the background on the following pages.
81
It may be useful when \autodoc:parameter{allpages} is active from a previous invocation.
82
\end{document}
UNCOV
83
]]
×
84

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