Render italic and bold in Markdown.

Scribble => Markdown
  @bold{text}    **text**
@italic{text}     _text_

original commit: 00a5bf63b1819f324ea41b91ce8ee288e1dc7ff5
This commit is contained in:
Greg Hendershott 2012-12-12 21:54:48 -05:00 committed by Matthew Flatt
parent cdc89f9685
commit 98e3fa52d8
2 changed files with 18 additions and 12 deletions

View File

@ -176,14 +176,13 @@
(if (target-url? p) p #f)))
(define url (and targ (target-url-addr targ)))
(begin0
(cond [url
(define new-i
(match (element-content i)
[(list (? string? s))
(element (element-style i)
(list (format "[~a](~a)" s url)))]
[else i]))
(super render-content new-i part ri)]
(cond [url (define new-i
(match (element-content i)
[(list (? string? s))
(element (element-style i)
(list (format "[~a](~a)" s url)))]
[else i]))
(super render-content new-i part ri)]
[(and (element? i)
(let ([s (element-style i)])
(or (eq? 'hspace s)
@ -191,8 +190,15 @@
(eq? 'hspace (style-name s))))))
(parameterize ([current-preserve-spaces #t])
(super render-content i part ri))]
[else
(super render-content i part ri)])
[else (define style (and (element? i) (element-style i)))
(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?
(phrase-ticks-depth (sub1 (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/)
Italic. \_Just underlines\_.
_Italic_. \_Just underlines\_.
Bold. \*Just asterisks.\*
**Bold**. \*Just asterisks.\*
“Dobule quoted”. Single quoted.