@@ -88,6 +88,13 @@ function typesetter.declareSettings (_)
8888 help = " Whether to ignore paragraph initial spaces" ,
8989 })
9090
91+ SILE .settings :declare ({
92+ parameter = " typesetter.brokenpenalty" ,
93+ type = " integer" ,
94+ default = 100 ,
95+ help = " Penalty to be applied to broken (hyphenated) lines" ,
96+ })
97+
9198 SILE .settings :declare ({
9299 parameter = " typesetter.orphanpenalty" ,
93100 type = " integer" ,
@@ -647,6 +654,8 @@ function typesetter:boxUpNodes ()
647654 pageBreakPenalty = SILE .settings :get (" typesetter.widowpenalty" )
648655 elseif # lines > 1 and index == (# lines - 1 ) then
649656 pageBreakPenalty = SILE .settings :get (" typesetter.orphanpenalty" )
657+ elseif line .is_broken then
658+ pageBreakPenalty = SILE .settings :get (" typesetter.brokenpenalty" )
650659 end
651660 vboxes [# vboxes + 1 ] = self :leadingFor (vbox , self .state .previousVbox )
652661 vboxes [# vboxes + 1 ] = vbox
@@ -1255,12 +1264,16 @@ function typesetter:breakpointsToLines (breakpoints)
12551264 SU .debug (" typesetter" , " Skipping a line containing only discardable nodes" )
12561265 linestart = point .position + 1
12571266 else
1267+ local is_broken = false
12581268 if slice [# slice ].is_discretionary then
12591269 -- The line ends, with a discretionary:
12601270 -- repeat it on the next line, so as to account for a potential postbreak.
12611271 linestart = point .position
12621272 -- And mark it as used as prebreak for now.
12631273 slice [# slice ]:markAsPrebreak ()
1274+ -- We'll want a "brokenpenalty" eventually (if not an orphan or widow)
1275+ -- to discourage page breaking after this line.
1276+ is_broken = true
12641277 else
12651278 linestart = point .position + 1
12661279 end
@@ -1282,7 +1295,7 @@ function typesetter:breakpointsToLines (breakpoints)
12821295 slice = self :_reboxLiners (slice )
12831296 end
12841297
1285- local thisLine = { ratio = ratio , nodes = slice }
1298+ local thisLine = { ratio = ratio , nodes = slice , is_broken = is_broken }
12861299 lines [# lines + 1 ] = thisLine
12871300 end
12881301 end
0 commit comments