diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index b2362a04..e2103098 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -202,11 +202,11 @@ (itemization-flows t))))) (define/override (render-other i part ht) - (list (cond - [(string? i) i] - [(eq? i 'mdash) `(span " " ndash " ")] - [(symbol? i) i] - [else (format "~s" i)]))) + (cond + [(string? i) (list i)] + [(eq? i 'mdash) `(" " ndash " ")] + [(symbol? i) (list i)] + [else (list (format "~s" i))])) ;; ---------------------------------------- diff --git a/collects/scribble/scheme.ss b/collects/scribble/scheme.ss index 847ca7cf..453a1964 100644 --- a/collects/scribble/scheme.ss +++ b/collects/scribble/scheme.ss @@ -123,6 +123,16 @@ c) (loop (cdr l) (cons (car l) prev))))])))))) + (define (literalize-spaces i) + (let ([m (regexp-match-positions #rx" +" i)]) + (if m + (make-element + #f + (list (literalize-spaces (substring i 0 (caar m))) + (make-element 'hspace + (list (substring i (caar m) (cdar m)))) + (literalize-spaces (substring i (cdar m))))) + i))) (define (loop init-line! quote-depth) (lambda (c) (cond @@ -258,7 +268,7 @@ [vd (make-link-element "schemevaluelink" (list s) vtag)] [else s]))))) - s) + (literalize-spaces s)) (cond [(positive? quote-depth) value-color] [(or (number? (syntax-e c)) diff --git a/collects/scribblings/scribble/reader.scrbl b/collects/scribblings/scribble/reader.scrbl index da0bab39..2221a917 100644 --- a/collects/scribblings/scribble/reader.scrbl +++ b/collects/scribblings/scribble/reader.scrbl @@ -5,7 +5,7 @@ @title[#:tag "reader"]{Scribble Reader} -The Scribble @|at|-reader is designed to be a convenient facility for +The Scribble @|at|-reader is designed to be a convenient facility for using free-form text in Scheme code, where ``@at'' is chosen as one of the least-used characters in Scheme code. @@ -247,7 +247,7 @@ have special meanings, but only in a few contexts. As described above, the text turns to a sequence of string arguments for the resulting form. Spaces at the beginning of lines are discarded (but see the information about indentation below), and newlines turn to -individual @scheme["\n"] strings. (Spcaces are preserved on a +individual @scheme["\n"] strings. (Spaces are preserved on a single-line text.) As part of trying to do the ``right thing,'' an empty line at the beginning and at the end are discarded, so: diff --git a/collects/scribblings/scribble/struct.scrbl b/collects/scribblings/scribble/struct.scrbl index 4a22cb21..5f209b9a 100644 --- a/collects/scribblings/scribble/struct.scrbl +++ b/collects/scribblings/scribble/struct.scrbl @@ -45,7 +45,14 @@ A single document is reprsented as a @defterm{part}: @itemize{ @item{A string element is included in the result - document verbatim.} + document verbatim, except for space, and + unless the element's style is + @scheme['hspace]. In a style other than + @scheme['hspace], consecutive spaces in the + output may be collapsed togther or replaced + with a line break. In the style + @scheme['hspace], all text is converted to + uncollapsable spaces.} @item{A symbol element is either @scheme['mdash], @scheme['ndash], @scheme['ldquo],