@ -68,14 +68,17 @@
( define ( hard-break? x ) ( and ( hard-break-func x ) ( not ( no-break-func x ) ) ) )
( define ( soft-break? x ) ( and ( soft-break-func x ) ( not ( no-break-func x ) ) ) )
; takes quads in wrap, triggering quad, and wrap idx; returns list containing wrap (and maybe other things)
( define ( finish-wrap qs previous-wrap-ender wrap-idx [ wrap-triggering-q ( car qs ) ] )
( define ( finish-wrap qs previous-wrap-ender wrap-idx [ wrap-triggering-q ( car qs ) ] [ fn-qs null ] )
;; reverse because quads accumulated in reverse
;; wrap-triggering-q is ordinarily the last accumulated q
;; unless it's the last wrap, in which case it's #f
;; but we capture it separately because it's likely to get trimmed away by `nonprinting-at-end?`
;; note: we don't trim `soft-break?` or `hard-break?` because that's an orthogonal consideration
;; for instance, a hyphen is `soft-break?` but shouldn't be trimmed.
( finish-wrap-func ( reverse ( dropf qs nonprinting-at-end? ) ) previous-wrap-ender wrap-triggering-q wrap-idx ) )
( define has-footnotes? ( pair? footnote-qs ) )
( apply finish-wrap-func
( reverse ( dropf qs nonprinting-at-end? ) ) previous-wrap-ender wrap-triggering-q wrap-idx
( if has-footnotes? ( list fn-qs ) null ) ) )
( wrap-proc qs
max-distance
debug
@ -151,7 +154,7 @@
[ else
( debug-report ' would-overflow-hard-without-captured-break )
( values next-wrap-tail qs ) ] ) )
( loop ( cons ( finish-wrap next-wrap-qs previous-wrap-ender wrap-idx ) wraps )
( loop ( cons ( finish-wrap next-wrap-qs previous-wrap-ender wrap-idx ( car next-wrap-qs ) footnote-next-wrap ) wraps )
( wrap-count wrap-idx q )
null
null
@ -159,12 +162,12 @@
( car next-wrap-qs )
other-qs
footnote-qs
footnote-next-wrap
null ; reset footnote-next-wrap
footnote-wraps
footnote-dist
0 ; reset footnote-dist
max-distance ) ]
[ else ; finish the wrap & reset the line without consuming a quad
( loop ( cons ( finish-wrap next-wrap-head previous-wrap-ender wrap-idx ) wraps )
( loop ( cons ( finish-wrap next-wrap-head previous-wrap-ender wrap-idx ( car next-wrap-head ) footnote-next-wrap ) wraps )
( wrap-count wrap-idx q )
null
next-wrap-tail
@ -172,9 +175,9 @@
( car next-wrap-head )
qs
footnote-qs
footnote-next-wrap
null ; reset footnote-next-wrap
footnote-wraps
footnote-dist
0 ; reset footnote-dist
max-distance ) ] ) )
( with-handlers ( [ symbol? ( λ ( exn ) ( handle-hard-overflow ) ) ] )
( let-values ( [ ( max-distance footnote-next-wrap footnote-qs )
@ -605,3 +608,4 @@
( check-equal? ( linewrap2 ( list x x x sp x x ) 2 ) ( list ( q x x ) lbr ( q x ) lbr ( q x x ) ) )
( check-equal? ( linewrap2 ( list x x x sp x x ) 3 ) ( list ( q x x x ) lbr ( q x x ) ) ) ) ) )