diff --git a/collects/scribble/markdown-render.rkt b/collects/scribble/markdown-render.rkt index 5fdb8c63..bfaf1506 100644 --- a/collects/scribble/markdown-render.rkt +++ b/collects/scribble/markdown-render.rkt @@ -18,6 +18,7 @@ (define table-ticks-depth (make-parameter 0)) (define phrase-ticks-depth (make-parameter 0)) +(define note-depth (make-parameter 0)) (define (render-mixin %) (class % @@ -140,14 +141,19 @@ (render-flow d part ht #f))))))) (define/override (render-paragraph p part ri) + (define (write-note) + (write-string (make-string (note-depth) #\>)) + (unless (zero? (note-depth)) + (write-string " "))) (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) " ")) (define lines (wrap-line (string-trim to-wrap) (- 72 (current-indent)))) + (write-note) (write-string (car lines)) (for ([line (in-list (cdr lines))]) - (newline) (indent) (write-string line)) + (newline) (indent) (write-note) (write-string line)) (newline) null) @@ -207,7 +213,12 @@ (define/override (render-nested-flow i part ri starting-item?) (define s (nested-flow-style i)) (unless (memq 'decorative (style-properties s)) - (super render-nested-flow i part ri starting-item?))) + (define note? (equal? (style-name s) "refcontent")) + (when note? + (note-depth (add1 (note-depth)))) + (begin0 (super render-nested-flow i part ri starting-item?) + (when note? + (note-depth (sub1 (note-depth))))))) (define/override (render-other i part ht) (cond diff --git a/collects/tests/scribble/markdown-docs/example.md b/collects/tests/scribble/markdown-docs/example.md index 2330735b..c5851792 100644 --- a/collects/tests/scribble/markdown-docs/example.md +++ b/collects/tests/scribble/markdown-docs/example.md @@ -43,3 +43,7 @@ The end. Returns a new mutable string of length `k` where each position in the string is initialized with the character `char` + +> Note: This is a note. Let’s make it long enough that the markdown output +> will have to line-wrap, to make sure the > mark starts each line +> properly. diff --git a/collects/tests/scribble/markdown-docs/example.scrbl b/collects/tests/scribble/markdown-docs/example.scrbl index 8041df2e..6776e22c 100644 --- a/collects/tests/scribble/markdown-docs/example.scrbl +++ b/collects/tests/scribble/markdown-docs/example.scrbl @@ -52,3 +52,7 @@ Returns a new mutable string of length @racket[k] where each position in the string is initialized with the character @racket[char] } + +@margin-note{Note: This is a note. Let's make it long enough that the +markdown output will have to line-wrap, to make sure the > mark starts +each line properly.}