• 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/cropmarks/init.lua
UNCOV
1
local base = require("packages.base")
×
2

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

UNCOV
6
local outcounter = 1
×
7

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

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

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

NEW
42
   SILE.typesetter.frame.state.cursorX = page:left() + offset
×
NEW
43
   SILE.typesetter.frame.state.cursorY = page:top() - offset - 4
×
UNCOV
44
   outcounter = outcounter + 1
×
45

UNCOV
46
   if hbox then
×
UNCOV
47
      for i = 1, #hbox.value do
×
UNCOV
48
         hbox.value[i]:outputYourself(SILE.typesetter, { ratio = 1 })
×
49
      end
50
   end
51
end
52

UNCOV
53
function package:_init ()
×
UNCOV
54
   base._init(self)
×
UNCOV
55
   self:loadPackage("date")
×
56
end
57

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

NEW
68
   self:registerCommand("cropmarks:setup", function (_, _)
×
NEW
69
      self.class:registerHook("endpage", outputMarks)
×
70
   end)
71

NEW
72
   self:registerCommand("crop:setup", function (_, _)
×
NEW
73
      SU.deprecated("crop:setup", "cropmarks:setup", "0.15.10", "0.17.0")
×
NEW
74
      SILE.call("cropmarks:setup")
×
75
   end)
76
end
77

78
package.documentation = [[
79
\begin{document}
80
When preparing a document for printing, you may be asked by the printer add crop marks.
81
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.
82

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

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

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