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

sile-typesetter / sile / 9428435077

08 Jun 2024 11:35AM UTC coverage: 64.56% (-9.9%) from 74.46%
9428435077

push

github

web-flow
Merge pull request #2047 from alerque/end-pars

23 of 46 new or added lines in 5 files covered. (50.0%)

1684 existing lines in 60 files now uncovered.

11145 of 17263 relevant lines covered (64.56%)

4562.45 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:registerCommand("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
46

UNCOV
47
      local allpages = SU.boolean(options.allpages, true)
×
UNCOV
48
      background.allpages = allpages
×
UNCOV
49
      local color = options.color and SILE.types.color(options.color)
×
UNCOV
50
      local src = options.src
×
UNCOV
51
      if src then
×
52
         background.bg = src and SILE.resolveFile(src) or SU.error("Couldn't find file " .. src)
×
UNCOV
53
      elseif color then
×
UNCOV
54
         background.bg = color
×
55
      else
56
         SU.error("background requires a color or an image src parameter")
×
57
      end
UNCOV
58
      outputBackground()
×
UNCOV
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

© 2025 Coveralls, Inc