From cad5dc4387fb225cb81567a0835c11b56a8b6d6f Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 24 Nov 2019 22:54:55 -0500 Subject: [PATCH] auto fixup twitter citations --- markitzero.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/markitzero.go b/markitzero.go index 2115d32..464de15 100644 --- a/markitzero.go +++ b/markitzero.go @@ -28,7 +28,8 @@ var re_bolder = regexp.MustCompile(`(^|\W)\*\*((?s:.*?))\*\*($|\W)`) var re_italicer = regexp.MustCompile(`(^|\W)\*((?s:.*?))\*($|\W)`) var re_bigcoder = regexp.MustCompile("```(.*)\n?((?s:.*?))\n?```\n?") var re_coder = regexp.MustCompile("`([^`]*)`") -var re_quoter = regexp.MustCompile(`(?m:^> (.*)(\n-(.*))?\n?)`) +var re_quoter = regexp.MustCompile(`(?m:^> (.*)(\n- ?(.*))?\n?)`) +var re_reciter = regexp.MustCompile(`()https://twitter.com/([^/]+)/.*?()`) var re_link = regexp.MustCompile(`.?.?https?://[^\s"]+[\w/)!]`) var re_zerolink = regexp.MustCompile(`\[([^]]*)\]\(([^)]*\)?)\)`) var re_imgfix = regexp.MustCompile(`]*)>`) @@ -78,6 +79,7 @@ func markitzero(s string) string { s = re_bolder.ReplaceAllString(s, "$1$2$3") s = re_italicer.ReplaceAllString(s, "$1$2$3") s = re_quoter.ReplaceAllString(s, "
$1
$3

") + s = re_reciter.ReplaceAllString(s, "$1$2$3") s = strings.Replace(s, "\n---\n", "


", -1) s = re_lister.ReplaceAllStringFunc(s, func(m string) string {