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

sile-typesetter / sile / 8288578143

14 Mar 2024 09:39PM UTC coverage: 64.155% (-10.6%) from 74.718%
8288578143

Pull #1904

github

alerque
chore(core): Fixup ec6ed657 which didn't shim old pack styles properly
Pull Request #1904: Merge develop into master (commit to next release being breaking)

1648 of 2421 new or added lines in 107 files covered. (68.07%)

1843 existing lines in 77 files now uncovered.

10515 of 16390 relevant lines covered (64.15%)

3306.56 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(background.bg,
×
NEW
13
      pagea:left() - offset, pagea:top() - offset,
×
NEW
14
      pagea:width() + 2 * offset, pagea:height() + 2 * offset)
×
NEW
15
  elseif background.bg then
×
NEW
16
    SILE.outputter:pushColor(background.bg)
×
NEW
17
    SILE.outputter:drawRule(
×
NEW
18
      pagea:left() - offset, pagea:top() - offset,
×
NEW
19
      pagea:width() + 2 * offset, pagea:height() + 2 * offset)
×
NEW
20
    SILE.outputter:popColor()
×
21
  end
NEW
22
  if not background.allpages then
×
NEW
23
    background.bg = nil
×
24
  end
25
end
26

UNCOV
27
function package:_init ()
×
UNCOV
28
  base._init(self)
×
NEW
29
  self.class:registerHook("newpage", outputBackground)
×
30
end
31

UNCOV
32
function package:registerCommands ()
×
33

UNCOV
34
  self:registerCommand("background", function (options, _)
×
NEW
35
    if SU.boolean(options.disable, false) then
×
36
      -- This option is certainly better than enforcing a white color.
NEW
37
      background.bg = nil
×
NEW
38
      return
×
39
    end
40

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

55
end
56

57
package.documentation = [[
58
\begin{document}
59
\use[module=packages.background]
60
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.
61

62
The package provides a \autodoc:command{\background} command which requires one of the following parameters:
63
\begin{itemize}
64
\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.}
65
\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.}
66
\end{itemize}
67

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

72
\background[color=#e9d8ba,allpages=false]
73

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

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