bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 58fab5c3a660607c74aeeb8b3044d9c31e7ef5a7
parent 3f1ebb95659c1887b79fafd3e0adc657e76430f9
Author: Greg Hendershott <greghendershott@gmail.com>
Date:   Wed, 27 Mar 2013 10:08:05 -0400

Combine adjacent code spans into one.

These result from something like

    @racket[(x y)]

being treated by Scribble as multiple RktXXX items rather than one. As
a result the Markdown emitted was:

    `(``x`` ``y``)`

But obviously instead we want:

    `(x y)`

Kludgosity alert: Although it would probably be more-correct to
consolidate the RktXXX items at the Scribble structure level, I don't
easily see how. `@racket` is baking in the concept of Racket
lexing (classifying text as various kinds of Racket elements). This is
handy when the render will be HTML or Latek, and is benignly N/A when
it will be plain text. But it's a bit square-peg/round-hole when the
render will be Markdown. Rather than attempt to "un-lex" the Scribble
structures (I'm having trouble seeing how), I'm handling it
"after-the-fact" -- adjusting the generated Markdown text.

If anyone thinks the preceding is an elaborate rationalization for an
ugly kludge, I wouldn't argue, but I would need some help
understanding the preferable way to go about it.

original commit: 59bba2d197a42448d21c7f899d197b890adc7c9e

Diffstat:
Mcollects/scribble/markdown-render.rkt | 12+++++++++++-
Mcollects/tests/scribble/markdown-docs/example.md | 2+-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/collects/scribble/markdown-render.rkt b/collects/scribble/markdown-render.rkt @@ -160,7 +160,17 @@ (define o (open-output-string)) (parameterize ([current-output-port o]) (super render-paragraph p part ri)) - (define to-wrap (regexp-replace* #rx"\n" (get-output-string o) " ")) + ;; 1. Remove newlines so we can re-wrap the text. + ;; + ;; 2. Combine adjacent code spans into one. These result from + ;; something like @racket[(x y)] being treated as multiple + ;; RktXXX items rather than one. (Although it would be + ;; more-correct to handle them at that level, I don't easily see + ;; how. As a result I'm handling it after-the-fact, at the + ;; text/Markdown stage.) + (define to-wrap (regexp-replaces (get-output-string o) + '([#rx"\n" " "] ;1 + [#rx"``" ""]))) ;2 (define lines (wrap-line (string-trim to-wrap) (- 72 (current-indent)))) (write-note) (write-string (car lines)) diff --git a/collects/tests/scribble/markdown-docs/example.md b/collects/tests/scribble/markdown-docs/example.md @@ -66,7 +66,7 @@ Example of a defproc: Returns a new mutable string of length `k` where each position in the string is initialized with the character `char` -Blah blah `(``or/c`` ``string?`` ``bytes?``)`. +Blah blah `(or/c string? bytes?)`. Example of Scribble `examples`: