From cb041850f424644937c8b494c64c066bbe5f2069 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 21 Sep 2012 07:37:30 -0600 Subject: [PATCH] scribble: decode a lone ` as a left "curly quote" Also, add 'lsquo as allowed content. Omitting the ` conversion in the first place was over-conservative. There's a backward-compatibility issue with this addition (i.e., a document might contain a backquote in a decoded context that is meant to be rendered as a backquote), but the potential problems seem minor. --- collects/scribble/core.rkt | 1 + collects/scribble/decode.rkt | 5 +++-- collects/scribble/latex-render.rkt | 1 + collects/scribble/text-render.rkt | 1 + collects/scribblings/scribble/core.scrbl | 2 +- collects/scribblings/scribble/decode.scrbl | 2 ++ collects/tests/scribble/docs/decode.scrbl | 4 ++++ collects/tests/scribble/docs/decode.txt | 2 ++ 8 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 collects/tests/scribble/docs/decode.scrbl create mode 100644 collects/tests/scribble/docs/decode.txt diff --git a/collects/scribble/core.rkt b/collects/scribble/core.rkt index 74c0eaa17a..966e560653 100644 --- a/collects/scribble/core.rkt +++ b/collects/scribble/core.rkt @@ -107,6 +107,7 @@ [ldquo . #t] [rdquo . #t] [rsquo . #t] + [lsquo . #t] [prime . #t] [rarr . #t] [larr . #t] diff --git a/collects/scribble/decode.rkt b/collects/scribble/decode.rkt index 363aa7197b..193072037c 100644 --- a/collects/scribble/decode.rkt +++ b/collects/scribble/decode.rkt @@ -105,7 +105,7 @@ (define (decode-string s) - (define pattern #rx"(---|--|``|''|')") + (define pattern #rx"(---|--|``|''|'|`)") (let loop ([start 0]) (cond [(regexp-match-positions pattern s start) @@ -117,7 +117,8 @@ [(string=? the-match "--") 'ndash] [(string=? the-match "``") 'ldquo] [(string=? the-match "''") 'rdquo] - [(string=? the-match "'") 'rsquo]) + [(string=? the-match "'") 'rsquo] + [(string=? the-match "`") 'lsquo]) (loop (cdar m))))] ;; Common case: nothing to decode, so don't copy strings. ;; Assume that the input is already interned. diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index e9f145c07d..160ec47d73 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -729,6 +729,7 @@ [(ldquo) "{``}"] [(rdquo) "{''}"] [(rsquo) "{'}"] + [(lsquo) "{`}"] [(prime) "$'$"] [(rarr) "$\\rightarrow$"] [(larr) "$\\leftarrow$"] diff --git a/collects/scribble/text-render.rkt b/collects/scribble/text-render.rkt index e4650a5a1b..082b876359 100644 --- a/collects/scribble/text-render.rkt +++ b/collects/scribble/text-render.rkt @@ -162,6 +162,7 @@ [(ndash) "\U2013"] [(ldquo) "\U201C"] [(rdquo) "\U201D"] + [(lsquo) "\U2018"] [(rsquo) "\U2019"] [(lang) ">"] [(rang) "<"] diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl index 2be4e7bbe5..205922edce 100644 --- a/collects/scribblings/scribble/core.scrbl +++ b/collects/scribblings/scribble/core.scrbl @@ -137,7 +137,7 @@ A @deftech{block} is either a @techlink{table}, an @item{A symbol content is either @racket['mdash], @racket['ndash], @racket['ldquo], - @racket['lsquo], @racket['rsquo], @racket['larr], + @racket['lsquo], @racket['rdquo], @racket['rsquo], @racket['larr], @racket['rarr], or @racket['prime]; it is rendered as the corresponding HTML entity (even for Latex output).} diff --git a/collects/scribblings/scribble/decode.scrbl b/collects/scribblings/scribble/decode.scrbl index a2a9260ae4..25e9cfaf21 100644 --- a/collects/scribblings/scribble/decode.scrbl +++ b/collects/scribblings/scribble/decode.scrbl @@ -28,6 +28,8 @@ makes just a few special text conversions: @item{@litchar{'}: converted to @racket['rsquo], which is a fancy apostrophe: '} + @item{@litchar{`}: converted to @racket['lsquo], which is a fancy quote: `} + ] Some functions @deftech{decode} a sequence of @racket[_pre-flow] or diff --git a/collects/tests/scribble/docs/decode.scrbl b/collects/tests/scribble/docs/decode.scrbl new file mode 100644 index 0000000000..271cc19628 --- /dev/null +++ b/collects/tests/scribble/docs/decode.scrbl @@ -0,0 +1,4 @@ +#lang scribble/base + +``To make your so--so document look `pretty,' use fancy quotes,'' he +said---with practically audible quotes. diff --git a/collects/tests/scribble/docs/decode.txt b/collects/tests/scribble/docs/decode.txt new file mode 100644 index 0000000000..c666d56a25 --- /dev/null +++ b/collects/tests/scribble/docs/decode.txt @@ -0,0 +1,2 @@ +“To make your so–so document look ‘pretty,’ use fancy quotes,” he +said—with practically audible quotes.