diff --git a/decode.rkt b/decode.rkt index 32d1720..e8b2be9 100644 --- a/decode.rkt +++ b/decode.rkt @@ -121,9 +121,9 @@ (define quotes '((#px"(?<=\\w)'(?=\\w)" "’") ; apostrophe - (#px"(?thing properly (define+provide/contract (wrap-hanging-quotes nx - #:single-prepend [single-pp 'squo] - #:double-prepend [double-pp 'dquo]) + #:single-prepend [single-pp '(squo)] + #:double-prepend [double-pp '(dquo)]) ((txexpr?) (#:single-prepend list? #:double-prepend list?) . ->* . txexpr?) (define two-or-more-char-string? (λ(i) (and (string? i) (>= (len i) 2)))) @@ -192,9 +192,9 @@ [(str-first . in? . '("\"" "“")) ;; can wrap with any inline tag ;; so that linebreak detection etc still works - `(,double-pp ,(->string #\“) ,str-rest)] + `(,@double-pp ,(->string #\“) ,str-rest)] [(str-first . in? . '("\'" "‘")) - `(,single-pp ,(->string #\‘) ,str-rest)] + `(,@single-pp ,(->string #\‘) ,str-rest)] [else tcs])] [(? txexpr? nx) (wrap-hanging-quotes nx)] [else (car elements)])]) diff --git a/tests/tests-decode.rkt b/tests/tests-decode.rkt index 81b4ce0..4f1db5f 100644 --- a/tests/tests-decode.rkt +++ b/tests/tests-decode.rkt @@ -6,7 +6,7 @@ (check-equal? (smart-dashes "I had --- maybe 13 -- 20 --- hob-nobs.") "I had—maybe 13–20—hob-nobs.") (check-equal? (smart-quotes "\"Why,\" she could've asked, \"are we in O‘ahu watching 'Mame'?\"") "“Why,” she could’ve asked, “are we in O‘ahu watching ‘Mame’?”") - +(check-equal? (smart-quotes "\"\'Impossible.\' Yes.\"") "“‘Impossible.’ Yes.”") ;; todo: make some tougher tests, it gets flaky with edge cases @@ -23,6 +23,7 @@ (check-equal? (wrap-hanging-quotes '(p "'Hi' there")) '(p (squo "‘" "Hi' there"))) (check-equal? (wrap-hanging-quotes '(p "'Hi' there") #:single-prepend '(foo ((bar "ino")))) '(p (foo ((bar "ino")) "‘" "Hi' there"))) + ;; make sure txexpr without elements passes through unscathed (check-equal? (wrap-hanging-quotes '(div ((style "height:2em")))) '(div ((style "height:2em"))))