Skip to content

Commit

Permalink
fix(typesetter): Skip lines containing only discardables without igno…
Browse files Browse the repository at this point in the history
…ring next lines
  • Loading branch information
Omikhleia authored and Didier Willis committed Apr 8, 2023
1 parent 5bc372a commit 13f9b06
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions typesetters/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -718,35 +718,44 @@ function typesetter:breakpointsToLines (breakpoints)
local point = breakpoints[i]
if point.position ~= 0 then
local slice = {}
local seenHbox = 0
-- local toss = 1
local seenNonDiscardable = false
for j = linestart, point.position do
slice[#slice+1] = nodes[j]
if nodes[j] then
-- toss = 0
if nodes[j].is_box or nodes[j].is_discretionary then seenHbox = 1 end
if not nodes[j].discardable then
seenNonDiscardable = true
end
end
end
if seenHbox == 0 then break end

-- If the line ends with a discretionary, repeat it on the next line,
-- so as to account for a potential postbreak.
if slice[#slice].is_discretionary then
linestart = point.position
else
if not seenNonDiscardable then
-- Slip lines containing only discardable nodes (e.g. glues).
SU.debug("typesetter", "Skipping a line containing only discardable nodes")
linestart = point.position + 1
end
else
-- If the line ends with a discretionary, repeat it on the next line,
-- so as to account for a potential postbreak.
if slice[#slice].is_discretionary then
linestart = point.position
else
linestart = point.position + 1
end

-- Then only we can add some extra margin glue...
local mrg = self:getMargins()
self:addrlskip(slice, mrg, point.left, point.right)
-- Then only we can add some extra margin glue...
local mrg = self:getMargins()
self:addrlskip(slice, mrg, point.left, point.right)

-- And compute the line...
local ratio = self:computeLineRatio(point.width, slice)
local thisLine = { ratio = ratio, nodes = slice }
lines[#lines+1] = thisLine
-- And compute the line...
local ratio = self:computeLineRatio(point.width, slice)
local thisLine = { ratio = ratio, nodes = slice }
lines[#lines+1] = thisLine
end
end
end
if linestart < #nodes then
-- Abnormal, but warn so that one has a chance to check which bits
-- are misssing at output.
SU.warn("Internal typesetter error " .. (#nodes - linestart) .. " skipped nodes")
end
--self.state.nodes = nodes.slice(linestart+1,nodes.length)
return lines
end
Expand Down

0 comments on commit 13f9b06

Please sign in to comment.