hyphenate & merge-adjacent

main
Matthew Butterick 10 years ago
parent 1dd58b2f5f
commit c45ed05ace

@ -8,4 +8,8 @@
(check-equal? (input->nested-blocks (input #f (block #f "1" (column-break) "2")))
(list (list (list (list (quad 'word '#hash() '("1")))) (list (list (quad 'word '#hash() '("2")))))))
(check-equal? (list (list (list (list (quad 'word '#hash() '("1"))))) (list (list (list (quad 'word '#hash() '("2"))))))
(input->nested-blocks (input #f (block #f "1" (page-break) "2"))))
(input->nested-blocks (input #f (block #f "1" (page-break) "2"))))
(check-equal? (merge-adjacent-within (line #f (word #f "b") (word #f "a") (word #f "r"))) (line #f (word #f "bar")))
(check-equal? (hyphenate-quad-except-last-word (line #f "snowman" "snowman")) (line #f "snow\u00ADman" "snowman"))

@ -26,13 +26,16 @@
[else (values multipages multicolumns blocks (cons q block-acc))])))
(reverse (cons-reverse (cons-reverse ((inst cons-reverse Quad Block-Type) b bs) mcs) mps)))
(provide merge-adjacent-within)
(define/typed (merge-adjacent-within q)
(Quad . -> . Quad)
(quad (quad-name q) (quad-attrs q) (join-quads (cast (quad-list q) (Listof Quad)))))
(provide hyphenate-quad-except-last-word)
(define/typed (hyphenate-quad-except-last-word q)
(Quad . -> . Quad)
(log-quad-debug "last word will not be hyphenated")
(define-values (first-quads last-quad) (split-last (quad-list q)))
(quad (quad-name q) (quad-attrs q) (snoc (map hyphenate-quad first-quads) last-quad)))
(define-values (first-quads last-quad) ((inst split-last QuadListItem) (quad-list q)))
(quad (quad-name q) (quad-attrs q) (snoc ((inst map QuadListItem QuadListItem) hyphenate-quad first-quads) last-quad)))

Loading…
Cancel
Save