From c191622652759b5c71035cf2f33bded4b1ea27bf Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 8 May 2019 13:08:29 -0400 Subject: [PATCH] `code` and ```code block``` support --- docs/manual.txt | 6 +++++- fun.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/manual.txt b/docs/manual.txt index af30199..4328ed5 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -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. diff --git a/fun.go b/fun.go index 2003b4e..aabd918 100644 --- a/fun.go +++ b/fun.go @@ -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$2$3") s = re_italicer.ReplaceAllString(s, "$1$2$3") + s = re_bigcoder.ReplaceAllString(s, "
$1
") + s = re_coder.ReplaceAllString(s, "$1") return s }