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

sile-typesetter / sile / 14908152066

08 May 2025 01:49PM UTC coverage: 61.309% (-5.7%) from 67.057%
14908152066

push

github

alerque
chore(registries): Touchup command registry deprecation shims

1 of 2 new or added lines in 2 files covered. (50.0%)

1379 existing lines in 46 files now uncovered.

13556 of 22111 relevant lines covered (61.31%)

11834.23 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

UNCOV
6
local background = {}
×
7

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

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

UNCOV
39
function package:registerCommands ()
×
UNCOV
40
   self.commands:register("background", function (options, _)
×
UNCOV
41
      if SU.boolean(options.disable, false) then
×
42
         -- This option is certainly better than enforcing a white color.
43
         background.bg = nil
×
44
         return
×
45
      end
UNCOV
46
      local allpages = SU.boolean(options.allpages, true)
×
UNCOV
47
      background.allpages = allpages
×
UNCOV
48
      local color = options.color and SILE.types.color(options.color)
×
UNCOV
49
      local src = options.src
×
UNCOV
50
      if src then
×
51
         background.bg = src and SILE.resolveFile(src) or SU.error("Couldn't find file " .. src)
×
UNCOV
52
      elseif color then
×
UNCOV
53
         background.bg = color
×
54
      else
55
         SU.error("background requires a color or an image src parameter")
×
56
      end
UNCOV
57
      outputBackground()
×
UNCOV
58
   end, "Output a solid background color <color> or an image <src> on pages after initialization.")
×
59
end
60

61
package.documentation = [[
62
\begin{document}
63
\use[module=packages.background]
64
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.
65

66
The package provides a \autodoc:command{\background} command which requires one of the following parameters:
67
\begin{itemize}
68
\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.}
69
\item{\autodoc:parameter{src=<file>} sets the background of the current and all following pages to the specified image. The latter will be scaled to the target dimension.}
70
\end{itemize}
71

72
The background extends to the page trim area (“page bleed”) if the latter is defined.
73
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.
74
If setting only the current page background different from the default is desired, an extra parameter \autodoc:parameter{allpages=false} can be passed.
75

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

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

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