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.
This commit is contained in:
Matthew Flatt 2012-09-21 07:37:30 -06:00
parent c75c0d9946
commit cb041850f4
8 changed files with 15 additions and 3 deletions

View File

@ -107,6 +107,7 @@
[ldquo . #t]
[rdquo . #t]
[rsquo . #t]
[lsquo . #t]
[prime . #t]
[rarr . #t]
[larr . #t]

View File

@ -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.

View File

@ -729,6 +729,7 @@
[(ldquo) "{``}"]
[(rdquo) "{''}"]
[(rsquo) "{'}"]
[(lsquo) "{`}"]
[(prime) "$'$"]
[(rarr) "$\\rightarrow$"]
[(larr) "$\\leftarrow$"]

View File

@ -162,6 +162,7 @@
[(ndash) "\U2013"]
[(ldquo) "\U201C"]
[(rdquo) "\U201D"]
[(lsquo) "\U2018"]
[(rsquo) "\U2019"]
[(lang) ">"]
[(rang) "<"]

View File

@ -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).}

View File

@ -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

View File

@ -0,0 +1,4 @@
#lang scribble/base
``To make your so--so document look `pretty,' use fancy quotes,'' he
said---with practically audible quotes.

View File

@ -0,0 +1,2 @@
“To make your soso document look pretty, use fancy quotes,” he
said—with practically audible quotes.