diff --git a/collects/scribble/core.rkt b/collects/scribble/core.rkt index 45e227fc7f..74c0eaa17a 100644 --- a/collects/scribble/core.rkt +++ b/collects/scribble/core.rkt @@ -584,16 +584,28 @@ (content->port op (part-relative-element-content c ri) renderer sec ri)] [else (content->port op c)])])) +(define (simple-content->string c) + ;; `content->string' is commonly used on a list containing a single string + (cond + [(string? c) c] + [(and (pair? c) + (string? (car c)) + (null? (cdr c))) + (car c)] + [else #f])) + (define content->string (case-lambda [(c) - (define op (open-output-string)) - (content->port op c) - (get-output-string op)] + (or (simple-content->string c) + (let ([op (open-output-string)]) + (content->port op c) + (get-output-string op)))] [(c renderer sec ri) - (define op (open-output-string)) - (content->port op c renderer sec ri) - (get-output-string op)])) + (or (simple-content->string c) + (let ([op (open-output-string)]) + (content->port op c renderer sec ri) + (get-output-string op)))])) (define (aux-element? e) diff --git a/collects/scribble/decode.rkt b/collects/scribble/decode.rkt index d28e61bd1f..9ea5224f18 100644 --- a/collects/scribble/decode.rkt +++ b/collects/scribble/decode.rkt @@ -109,8 +109,9 @@ [(string=? the-match "'") 'rsquo]) (loop (cdar m))))] ;; Common case: nothing to decode, so don't copy strings. + ;; Assume that the input is already interned. [(= start 0) - (list (datum-intern-literal s))] + (list s)] [else (list (datum-intern-literal (substring s start)))])))