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

sile-typesetter / sile / 14860011647

06 May 2025 12:44PM UTC coverage: 67.057% (+32.5%) from 34.559%
14860011647

push

github

alerque
chore(typesetters): Fixup access to class from typesetter functions

7 of 7 new or added lines in 2 files covered. (100.0%)

1344 existing lines in 103 files now uncovered.

14880 of 22190 relevant lines covered (67.06%)

11549.16 hits per line

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

79.59
/packages/cropmarks/init.lua
1
local base = require("packages.base")
1✔
2

3
local package = pl.class(base)
1✔
4
package._name = "cropmarks"
1✔
5

6
local outcounter = 1
1✔
7

8
local function outputMarks (self)
9
   local page = SILE.getFrame("page")
2✔
10
   -- Length of crop mark bars
11
   local cropsz = 20
2✔
12
   -- Ensure the crop marks stay outside the bleed area
13
   local offset = math.max(10, SILE.documentState.bleed / 2)
2✔
14

15
   SILE.outputter:drawRule(page:left() - offset, page:top(), -cropsz, 0.5)
8✔
16
   SILE.outputter:drawRule(page:left(), page:top() - offset, 0.5, -cropsz)
8✔
17
   SILE.outputter:drawRule(page:right() + offset, page:top(), cropsz, 0.5)
8✔
18
   SILE.outputter:drawRule(page:right(), page:top() - offset, 0.5, -cropsz)
8✔
19
   SILE.outputter:drawRule(page:left() - offset, page:bottom(), -cropsz, 0.5)
8✔
20
   SILE.outputter:drawRule(page:left(), page:bottom() + offset, 0.5, cropsz)
8✔
21
   SILE.outputter:drawRule(page:right() + offset, page:bottom(), cropsz, 0.5)
8✔
22
   SILE.outputter:drawRule(page:right(), page:bottom() + offset, 0.5, cropsz)
8✔
23

24
   local hbox, hlist = SILE.typesetter:makeHbox(function ()
4✔
25
      self.settings:temporarily(function ()
4✔
26
         SILE.call("noindent")
2✔
27
         SILE.call("font", { size = "6pt" })
2✔
28
         if self.commands:exists("crop:header") then
6✔
29
            -- Deprecation shim:
30
            -- If user redefined this command, still use it with a warning...
31
            SU.deprecated("crop:header", "cropmarks:header", "0.15.0", "0.16.0")
×
32
         else
33
            SILE.call("cropmarks:header")
2✔
34
         end
35
      end)
36
   end)
37
   if #hlist > 0 then
2✔
38
      SU.error("Migrating content is forbidden in crop header")
×
39
   end
40

41
   SILE.typesetter.frame.state.cursorX = page:left() + offset
6✔
42
   SILE.typesetter.frame.state.cursorY = page:top() - offset - 4
8✔
43
   outcounter = outcounter + 1
2✔
44

45
   if hbox then
2✔
46
      for i = 1, #hbox.value do
18✔
47
         hbox.value[i]:outputYourself(SILE.typesetter, { ratio = 1 })
16✔
48
      end
49
   end
50
end
51

52
function package:_init ()
1✔
53
   base._init(self)
1✔
54
   self:loadPackage("date")
1✔
55
end
56

57
function package:registerCommands ()
1✔
58
   self.commands:register("cropmarks:header", function (_, _)
3✔
59
      local info = SILE.input.filenames[1]
×
60
         .. " - "
×
61
         .. self.class.packages.date:date({ format = "%x %X" })
×
62
         .. " - "
×
63
         .. outcounter
×
64
      SILE.typesetter:typeset(info)
×
65
   end)
66

67
   self.commands:register("cropmarks:setup", function (_, _)
3✔
68
      self.class:registerHook("endpage", function ()
2✔
69
         return outputMarks(self)
2✔
70
      end)
71
   end)
72

73
   self.commands:register("crop:setup", function (_, _)
3✔
UNCOV
74
      SU.deprecated("crop:setup", "cropmarks:setup", "0.15.10", "0.17.0")
×
UNCOV
75
      SILE.call("cropmarks:setup")
×
76
   end)
77
end
78

79
package.documentation = [[
80
\begin{document}
81
When preparing a document for printing, you may be asked by the printer add crop marks.
82
This means that you need to output the document on a slightly larger page size than your target paper and add crop marks to show where the paper sheet should be trimmed down to the correct size.
83

84
Actual paper size, true page content area and bleed/trim area can all be set via class options.
85

86
This package provides the \autodoc:command{\cropmarks:setup} command which should be run early in your document file.
87
It places crop marks around the true page content.
88
The crop marks are guaranteed to stay outside the bleed/trim area, when defined.
89
It also adds a header at the top of the page with the filename, date and output sheet number.
90
You can customize this header by redefining \autodoc:command{\cropmarks:header}.
91
\end{document}
92
]]
1✔
93

94
return package
1✔
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