From f7c2910b07ca111942599d8e3dfc730bdbc912da Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Sun, 23 Jul 2023 23:19:49 -0400 Subject: [PATCH] fix community bangs --- routes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes.go b/routes.go index 7efd843..ad645f6 100644 --- a/routes.go +++ b/routes.go @@ -133,6 +133,8 @@ var funcMap = template.FuncMap{ var buf bytes.Buffer re := regexp.MustCompile(`\s---\s`) body = re.ReplaceAllString(body, "\n***\n") + // community bangs + body = RegReplace(body, `!([a-zA-Z0-9_]+)@([a-zA-Z0-9\.\-]+)`, `[!$1@$2](/c/$1@$2)`) if err := md.Convert([]byte(body), &buf); err != nil { fmt.Println(err) return template.HTML(body) @@ -164,8 +166,6 @@ var funcMap = template.FuncMap{ func LemmyLinkRewrite(input string, host string, lemmy_domain string) (body string) { body = input - // community bangs - body = RegReplace(body, `!([a-zA-Z0-9_]+)@([a-zA-Z0-9\.\-]+)([ \n\r]+|<\/p>)`, `!$1@$2 `) // localize community and user links body = RegReplace(body, `href="https:\/\/([a-zA-Z0-9\.\-]+)\/((c|u|comment|post)\/.*?)"`, `href="/$2@$1"`) // remove extra instance tag