commit 5dee0e0570613733691863734ba757fd9414bdb2
parent 00e49d4c9eb289a5ef10122b179b245e83b512aa
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Tue, 7 Apr 2009 18:57:15 +0000
preserve space with scribble/comment-reader
svn: r14446
original commit: de3d090f1a710336445d843359a3ece804c205e3
Diffstat:
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/collects/scribble/comment-reader.ss b/collects/scribble/comment-reader.ss
@@ -12,7 +12,7 @@
(define (*read-syntax src [port (current-input-port)])
(parameterize ([current-readtable (make-comment-readtable)])
(read-syntax/recursive src port)))
-
+
(define (make-comment-readtable #:readtable [rt (current-readtable)])
(make-readtable rt
#\; 'terminating-macro
@@ -35,13 +35,36 @@
`(code:comment
(unsyntax
(t
- ,@(let loop ()
- (let ([c (read-char port)])
- (cond
- [(or (eof-object? c)
- (char=? c #\newline))
- null]
- [(char=? c #\@)
- (cons (recur) (loop))]
- [else (cons (string c)
- (loop))]))))))))
+ ,@(append-strings
+ (let loop ()
+ (let ([c (read-char port)])
+ (cond
+ [(or (eof-object? c)
+ (char=? c #\newline))
+ null]
+ [(char=? c #\@)
+ (cons (recur) (loop))]
+ [else
+ (cons (string c)
+ (loop))]))))))))
+
+ (define (append-strings l)
+ (let loop ([l l][s null])
+ (cond
+ [(null? l) (if (null? s)
+ null
+ (list (apply string-append (reverse s))))]
+ [(and (equal? " " (car l))
+ (pair? s)
+ (equal? " " (car s)))
+ (append (loop null s)
+ (cons ''nbsp
+ (loop (cdr l) null)))]
+ [(string? (car l))
+ (loop (cdr l) (cons (car l) s))]
+ [else
+ (append (loop null s)
+ (cons
+ (car l)
+ (loop (cdr l) null)))]))))
+
diff --git a/collects/scribble/scheme.ss b/collects/scribble/scheme.ss
@@ -338,7 +338,7 @@
(if (paragraph? v)
(map (lambda (v)
(let ([v (no-fancy-chars v)])
- (if (string? v)
+ (if (or (string? v) (symbol? v))
(out v comment-color)
(out v #f))))
(paragraph-content v))