`code` and ```code block``` support

This commit is contained in:
Ted Unangst 2019-05-08 13:08:29 -04:00
parent f1b4c45088
commit c191622652
2 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,11 @@ Instructions for running of the honk.
-- posting
Should work as expected. Supports **bold** and *italics*.
Should work as expected.
Limited markdown support:
**bold** and *italics*
`code` and ```code block```
Large images are rescaled and reduced.

4
fun.go
View File

@ -156,10 +156,14 @@ func herdofemus(noise string) []Emu {
var re_bolder = regexp.MustCompile(`(^|\W)\*\*([\w\s,.!?']+)\*\*($|\W)`)
var re_italicer = regexp.MustCompile(`(^|\W)\*([\w\s,.!?']+)\*($|\W)`)
var re_bigcoder = regexp.MustCompile("```((?s:.*?))```")
var re_coder = regexp.MustCompile("`(.*?)`")
func markitzero(s string) string {
s = re_bolder.ReplaceAllString(s, "$1<b>$2</b>$3")
s = re_italicer.ReplaceAllString(s, "$1<i>$2</i>$3")
s = re_bigcoder.ReplaceAllString(s, "<pre><code>$1</code></pre>")
s = re_coder.ReplaceAllString(s, "<code>$1</code>")
return s
}