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

sile-typesetter / sile / 9400954821

06 Jun 2024 11:12AM UTC coverage: 61.625% (-11.6%) from 73.209%
9400954821

push

github

web-flow
Merge pull request #2041 from alerque/keep-space-after-envs

2 of 30 new or added lines in 2 files covered. (6.67%)

1933 existing lines in 67 files now uncovered.

10613 of 17222 relevant lines covered (61.62%)

2870.98 hits per line

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

0.0
/pagebuilders/grid.lua
UNCOV
1
local base = require("pagebuilders.base")
×
2

UNCOV
3
local pagebuilder = pl.class(base)
×
UNCOV
4
pagebuilder._name = "grid"
×
5

UNCOV
6
function pagebuilder:_init ()
×
7
   base._init(self)
×
8
end
9

UNCOV
10
function pagebuilder.findBestBreak (_, options)
×
UNCOV
11
   local vboxlist = SU.required(options, "vboxlist", "in findBestBreak")
×
UNCOV
12
   local target = SU.required(options, "target", "in findBestBreak")
×
UNCOV
13
   local i = 0
×
UNCOV
14
   local totalHeight = SILE.types.length()
×
UNCOV
15
   local bestBreak = 0
×
UNCOV
16
   SU.debug(
×
17
      "pagebuilder",
18
      "Page builder for frame",
UNCOV
19
      SILE.typesetter.frame.id,
×
20
      "called with",
UNCOV
21
      #vboxlist,
×
22
      "nodes,",
23
      target
24
   )
UNCOV
25
   if SU.debugging("vboxes") then
×
26
      for j, box in ipairs(vboxlist) do
×
27
         SU.debug("vboxes", function ()
×
28
            return (j == i and " >" or "  ") .. j .. ": " .. box
×
29
         end)
30
      end
31
   end
UNCOV
32
   while i < #vboxlist do
×
UNCOV
33
      i = i + 1
×
UNCOV
34
      if not vboxlist[i].is_vglue then
×
UNCOV
35
         i = i - 1
×
36
         break
37
      end
38
   end
UNCOV
39
   while i < #vboxlist do
×
UNCOV
40
      i = i + 1
×
UNCOV
41
      local node = vboxlist[i]
×
UNCOV
42
      SU.debug("pagebuilder", "Dealing with VBox", node)
×
UNCOV
43
      if node.is_vbox then
×
UNCOV
44
         totalHeight = totalHeight + node.height:absolute() + node.depth:absolute()
×
UNCOV
45
      elseif node.is_vglue then
×
UNCOV
46
         totalHeight = totalHeight + node.height:absolute()
×
UNCOV
47
      elseif node.is_insertion then
×
48
         -- TODO: refactor as hook and without side effects!
49
         target = SILE.insertions.processInsertion(vboxlist, i, totalHeight, target)
×
50
         node = vboxlist[i]
×
51
      end
UNCOV
52
      local left = target - totalHeight
×
UNCOV
53
      local _left = left:tonumber()
×
UNCOV
54
      SU.debug("pagebuilder", "I have", left, "left")
×
UNCOV
55
      SU.debug("pagebuilder", "totalHeight", totalHeight, "with target", target)
×
UNCOV
56
      local badness = 0
×
UNCOV
57
      if _left < 0 then
×
UNCOV
58
         badness = 1000000
×
59
      end
UNCOV
60
      if node.is_penalty then
×
UNCOV
61
         if node.penalty < -3000 then
×
UNCOV
62
            badness = 100000
×
63
         else
UNCOV
64
            badness = -_left * _left - node.penalty
×
65
         end
66
      end
UNCOV
67
      if badness > 0 then
×
UNCOV
68
         local onepage = {}
×
UNCOV
69
         for j = 1, bestBreak do
×
UNCOV
70
            onepage[j] = table.remove(vboxlist, 1)
×
71
         end
UNCOV
72
         while #onepage > 1 and onepage[#onepage].discardable do
×
73
            onepage[#onepage] = nil
×
74
         end
UNCOV
75
         return onepage, 1000
×
76
      end
UNCOV
77
      bestBreak = i
×
78
   end
UNCOV
79
   return false, false
×
80
end
81

UNCOV
82
return pagebuilder
×
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