microoptimization to avoid the more expensive regex

This commit is contained in:
Ted Unangst 2020-01-25 19:11:58 -05:00
parent 2b211ca480
commit 942025be9b
1 changed files with 7 additions and 3 deletions

View File

@ -75,10 +75,14 @@ func markitzero(s string) string {
s = string(buf) s = string(buf)
// mark it zero // mark it zero
s = re_link.ReplaceAllStringFunc(s, linkreplacer) if strings.Contains(s, "http") {
s = re_link.ReplaceAllStringFunc(s, linkreplacer)
}
s = re_zerolink.ReplaceAllString(s, `<a href="$2">$1</a>`) s = re_zerolink.ReplaceAllString(s, `<a href="$2">$1</a>`)
s = re_bolder.ReplaceAllString(s, "$1<b>$2</b>$3") if strings.Contains(s, "*") {
s = re_italicer.ReplaceAllString(s, "$1<i>$2</i>$3") s = re_bolder.ReplaceAllString(s, "$1<b>$2</b>$3")
s = re_italicer.ReplaceAllString(s, "$1<i>$2</i>$3")
}
s = re_quoter.ReplaceAllString(s, "<blockquote>$1<br><cite>$3</cite></blockquote><p>") s = re_quoter.ReplaceAllString(s, "<blockquote>$1<br><cite>$3</cite></blockquote><p>")
s = re_reciter.ReplaceAllString(s, "$1$2$3") s = re_reciter.ReplaceAllString(s, "$1$2$3")
s = strings.Replace(s, "\n---\n", "<hr><p>", -1) s = strings.Replace(s, "\n---\n", "<hr><p>", -1)