From 2f56c76f41718b6e6f8e946704f3d0f7ddd1fa19 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 26 May 2019 11:15:25 -0700 Subject: [PATCH] no bang --- quad/quadwriter/core.rkt | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/quad/quadwriter/core.rkt b/quad/quadwriter/core.rkt index c547146a..6449cedd 100644 --- a/quad/quadwriter/core.rkt +++ b/quad/quadwriter/core.rkt @@ -226,18 +226,17 @@ (define hung-word-sublists (match word-sublists [(list sublists ... (list prev-qs ... last-q)) - (define last-char-str (regexp-match #rx"[.,!’-]$" (car (quad-elems last-q)))) + (define last-char-str (regexp-match #rx"[.,:;’-]$" (car (quad-elems last-q)))) (match last-char-str [#false word-sublists] - [_ - (define hanger-q (struct-copy quad last-q - [elems null] - [size (let ([p (make-size-promise last-q (car last-char-str))]) - (delay - (match-define (list x y) (force p)) - (pt (- x) y)))])) - (define last-sublist (append prev-qs (list last-q hanger-q))) - (append sublists (list last-sublist))])])) + [_ (define hanger-q (struct-copy quad last-q + [elems null] + [size (let ([p (make-size-promise last-q (car last-char-str))]) + (delay + (match-define (list x y) (force p)) + (pt (- x) y)))])) + (define last-sublist (append prev-qs (list last-q hanger-q))) + (append sublists (list last-sublist))])])) (define word-width (sum-of-widths hung-word-sublists)) (define word-space-width (sum-of-widths word-space-sublists)) (define empty-hspace (- line-width @@ -591,15 +590,15 @@ (define ((page-finish-wrap page-quad path) cols q0 q page-idx) (define elems (match (quad-ref (car cols) 'footer-display "true") - [(or "false" "none") (from-parent cols 'nw)] - [_ - (define-values (dir name _) (split-path (path-replace-extension path #""))) - (define footer (struct-copy quad q:footer - [attrs (let ([h (hash-copy (quad-attrs q:footer))]) - (hash-set! h 'page-number page-idx) - (hash-set! h 'doc-title (string-titlecase (path->string name))) - h)])) - (cons footer (from-parent cols 'nw))])) + [(or "false" "none") (from-parent cols 'nw)] + [_ + (define-values (dir name _) (split-path (path-replace-extension path #""))) + (define footer (struct-copy quad q:footer + [attrs (let ([h (hash-copy (quad-attrs q:footer))]) + (hash-set! h 'page-number page-idx) + (hash-set! h 'doc-title (string-titlecase (path->string name))) + h)])) + (cons footer (from-parent cols 'nw))])) (list (struct-copy quad page-quad [elems elems]))) (define (page-wrap qs width [page-quad q:page])