Render italic and bold in Markdown.

Scribble => Markdown
  @bold{text}    **text**
@italic{text}     _text_
This commit is contained in:
Greg Hendershott 2012-12-12 21:54:48 -05:00 committed by Matthew Flatt
parent dd5b999c64
commit 00a5bf63b1
2 changed files with 18 additions and 12 deletions

View File

@ -176,8 +176,7 @@
(if (target-url? p) p #f))) (if (target-url? p) p #f)))
(define url (and targ (target-url-addr targ))) (define url (and targ (target-url-addr targ)))
(begin0 (begin0
(cond [url (cond [url (define new-i
(define new-i
(match (element-content i) (match (element-content i)
[(list (? string? s)) [(list (? string? s))
(element (element-style i) (element (element-style i)
@ -191,8 +190,15 @@
(eq? 'hspace (style-name s)))))) (eq? 'hspace (style-name s))))))
(parameterize ([current-preserve-spaces #t]) (parameterize ([current-preserve-spaces #t])
(super render-content i part ri))] (super render-content i part ri))]
[else [else (define style (and (element? i) (element-style i)))
(super render-content i part ri)]) (define bold? (eq? style 'bold))
(define italic? (eq? style 'italic))
(cond [bold? (display "**")]
[italic? (display "_")])
(begin0
(super render-content i part ri)
(cond [bold? (display "**")]
[italic? (display "_")]))])
(when tick? (when tick?
(phrase-ticks-depth (sub1 (phrase-ticks-depth))) (phrase-ticks-depth (sub1 (phrase-ticks-depth)))
(when (zero? (phrase-ticks-depth)) (when (zero? (phrase-ticks-depth))

View File

@ -10,9 +10,9 @@
[I am a hyperlink to Racket.](http://www.racket-lang.org/) [I am a hyperlink to Racket.](http://www.racket-lang.org/)
Italic. \_Just underlines\_. _Italic_. \_Just underlines\_.
Bold. \*Just asterisks.\* **Bold**. \*Just asterisks.\*
“Dobule quoted”. Single quoted. “Dobule quoted”. Single quoted.