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

sile-typesetter / sile / 14335207249

08 Apr 2025 01:46PM UTC coverage: 60.462% (+0.9%) from 59.535%
14335207249

push

github

web-flow
Merge pull request #2257 from alerque/lintery

98 of 147 new or added lines in 46 files covered. (66.67%)

1 existing line in 1 file now uncovered.

13061 of 21602 relevant lines covered (60.46%)

4611.17 hits per line

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

0.0
/outputters/debug.lua
1
local base = require("outputters.base")
×
2

3
local cursorX = 0
×
4
local cursorY = 0
×
5

6
local started = false
×
7

8
local lastFont
9
local outfile
10

11
local _round = SU.debug_round
×
12

13
local outputter = pl.class(base)
×
14
outputter._name = "debug"
×
15
outputter.extension = "debug"
×
16

17
-- The outputter init can't actually initialize output (as logical as it might
18
-- have seemed) because that requires a page size which we don't know yet.
19
-- function outputter:_init () end
20

21
function outputter:_ensureInit ()
×
22
   if not started then
×
23
      started = true -- keep this before self:_writeline or it will be a race condition!
×
24
      local fname = self:getOutputFilename()
×
25
      outfile = fname == "-" and io.stdout or io.open(fname, "w+")
×
26
      if SILE.documentState.paperSize then
×
27
         self:_writeline("Set paper size ", SILE.documentState.paperSize[1], SILE.documentState.paperSize[2])
×
28
      end
29
      self:_writeline("Begin page")
×
30
   end
31
end
32

33
function outputter:_writeline (...)
×
34
   self:_ensureInit()
×
35
   local args = pl.utils.pack(...)
×
36
   for i = 1, #args do
×
37
      outfile:write(args[i])
×
38
      if i < #args then
×
39
         outfile:write("\t")
×
40
      end
41
   end
42
   outfile:write("\n")
×
43
end
44

45
function outputter:newPage ()
×
46
   self:_writeline("New page")
×
47
end
48

49
function outputter:abort ()
×
50
   if started then
×
51
      self:_writeline("Aborted")
×
52
      outfile:close()
×
53
      started = false
×
54
   end
55
end
56

57
function outputter:finish ()
×
58
   if SILE.status.unsupported then
×
59
      self:_writeline("UNSUPPORTED")
×
60
   end
61
   self:_writeline("End page")
×
62
   self:runHooks("prefinish")
×
63
   self:_writeline("Finish")
×
64
   outfile:close()
×
65
   started = false
×
66
end
67

NEW
68
function outputter:getCursor ()
×
69
   return cursorX, cursorY
×
70
end
71

72
function outputter:setCursor (x, y, relative)
×
73
   x = SU.cast("number", x)
×
74
   y = SU.cast("number", y)
×
75
   local oldx, oldy = self:getCursor()
×
76
   local offset = relative and { x = cursorX, y = cursorY } or { x = 0, y = 0 }
×
77
   cursorX = offset.x + x
×
78
   cursorY = offset.y - y
×
79
   if _round(oldx) ~= _round(cursorX) then
×
80
      self:_writeline("Mx ", _round(x))
×
81
   end
82
   if _round(oldy) ~= _round(cursorY) then
×
83
      self:_writeline("My ", _round(y))
×
84
   end
85
end
86

87
function outputter:setColor (color)
×
88
   if color.r then
×
89
      self:_writeline("Set color", tostring(color))
×
90
   elseif color.c then
×
91
      self:_writeline("Set color", tostring(color))
×
92
   elseif color.l then
×
93
      self:_writeline("Set color", tostring(color))
×
94
   end
95
end
96

97
function outputter:pushColor (color)
×
98
   if color.r then
×
99
      self:_writeline("Push color", tostring(color))
×
100
   elseif color.c then
×
101
      self:_writeline("Push color (CMYK)", tostring(color))
×
102
   elseif color.l then
×
103
      self:_writeline("Push color (grayscale)", tostring(color))
×
104
   end
105
end
106

107
function outputter:popColor ()
×
108
   self:_writeline("Pop color")
×
109
end
110

111
function outputter:drawHbox (value, width)
×
112
   if not value.glyphString then
×
113
      return
×
114
   end
115
   width = SU.cast("number", width)
×
116
   local buf
117
   if value.complex then
×
118
      local cluster = {}
×
119
      for i = 1, #value.items do
×
120
         local item = value.items[i]
×
121
         cluster[#cluster + 1] = item.gid
×
122
         -- For the sake of terseness we're only dumping non-zero values
123
         if item.glyphAdvance ~= 0 then
×
124
            cluster[#cluster + 1] = "a=" .. _round(item.glyphAdvance)
×
125
         end
126
         if item.x_offset then
×
127
            cluster[#cluster + 1] = "x=" .. _round(item.x_offset)
×
128
         end
129
         if item.y_offset then
×
130
            cluster[#cluster + 1] = "y=" .. _round(item.y_offset)
×
131
         end
132
         self:setCursor(item.width, 0, true)
×
133
      end
134
      buf = table.concat(cluster, " ")
×
135
   else
136
      buf = table.concat(value.glyphString, " ") .. " w=" .. _round(width)
×
137
   end
138
   self:_writeline("T", buf, "(" .. tostring(value.text) .. ")")
×
139
end
140

141
function outputter:setFont (options)
×
142
   local font = SILE.font._key(options)
×
143
   if lastFont ~= font then
×
144
      self:_writeline("Set font ", font)
×
145
      lastFont = font
×
146
   end
147
end
148

149
function outputter:drawImage (src, x, y, width, height)
×
150
   x = SU.cast("number", x)
×
151
   y = SU.cast("number", y)
×
152
   width = SU.cast("number", width)
×
153
   height = SU.cast("number", height)
×
154
   self:_writeline("Draw image", src, _round(x), _round(y), _round(width), _round(height))
×
155
end
156

NEW
157
function outputter:getImageSize (src, pageno)
×
158
   local pdf = require("justenoughlibtexpdf")
×
159
   local llx, lly, urx, ury, xresol, yresol = pdf.imagebbox(src, pageno)
×
160
   return (urx - llx), (ury - lly), xresol, yresol
×
161
end
162

163
function outputter:drawSVG (figure, _, x, y, width, height, scalefactor)
×
164
   x = SU.cast("number", x)
×
165
   y = SU.cast("number", y)
×
166
   width = SU.cast("number", width)
×
167
   height = SU.cast("number", height)
×
168
   self:_writeline("Draw SVG", _round(x), _round(y), _round(width), _round(height), figure, scalefactor)
×
169
end
170

171
function outputter:drawRule (x, y, width, depth)
×
172
   x = SU.cast("number", x)
×
173
   y = SU.cast("number", y)
×
174
   width = SU.cast("number", width)
×
175
   depth = SU.cast("number", depth)
×
176
   self:_writeline("Draw line", _round(x), _round(y), _round(width), _round(depth))
×
177
end
178

179
function outputter:setLinkAnchor (name, x, y)
×
180
   self:_writeline("Setting link anchor", name, x, y)
×
181
end
182

183
function outputter:beginLink (dest, opts)
×
184
   self:_writeline("Beginning a link", dest, opts)
×
185
end
186

187
function outputter:endLink (dest, opts, x0, y0, x1, y1)
×
188
   self:_writeline("Ending a link", dest, opts, x0, y0, x1, y1)
×
189
end
190

191
function outputter:setBookmark (dest, title, level)
×
192
   self:_writeline("Setting bookmark", dest, title, level)
×
193
end
194

195
function outputter:setMetadata (key, value)
×
196
   self:_writeline("Set metadata", key, value)
×
197
end
198

199
function outputter:drawRaw (literal)
×
200
   self:_writeline("Draw raw", literal)
×
201
end
202

203
return outputter
×
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