From f64d3c2d5726a0a905d0b71921a788a839139013 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Wed, 28 Feb 2018 23:23:16 -0800 Subject: [PATCH] failure is an option --- quad/quad/wrap.rkt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quad/quad/wrap.rkt b/quad/quad/wrap.rkt index 2897a59d..6aed4378 100644 --- a/quad/quad/wrap.rkt +++ b/quad/quad/wrap.rkt @@ -70,6 +70,7 @@ (define x (q #f #\x)) (define zwx (q (list 'size (pt 0 0)) #\z)) +(define hyph (q #f #\-)) (define a (q #f #\a)) (define b (q #f #\b)) (define c (q #f #\c)) @@ -79,7 +80,7 @@ [(start end) (pt 0 0)] [else (pt 1 1)]))) #\space)) (define br (q (list 'size (pt 0 0)) #\newline)) -(define optional-break? (λ (q) (and (quad? q) (memv (car (elems q)) '(#\space))))) +(define optional-break? (λ (q) (and (quad? q) (memv (car (elems q)) '(#\space #\-))))) (define (linewrap xs size [debug #f]) (wrap xs size debug @@ -118,6 +119,11 @@ (check-equal? (linewrap (list sp sp x sp sp) 2) (list x)) (check-equal? (linewrap (list sp sp x sp sp x sp) 1) (list x 'lb x))) + + (test-case + "hyphens" + (check-equal? (linewrap (list x x hyph x x) 4) (list x x hyph 'lb x x))) + (test-case "zero width nonbreakers" (check-equal? (linewrap (list sp zwx) 2) (list zwx))