fix community bangs. fixes #44

This commit is contained in:
Ryan Stafford 2023-07-24 00:24:29 -04:00
parent dd4f76a393
commit 1858f1aec0

View file

@ -134,7 +134,7 @@ var funcMap = template.FuncMap{
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)`)
body = RegReplace(body, `([^\[])!([a-zA-Z0-9_]+)@([a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+)`, `$1[!$2@$3](/c/$2@$3)`)
if err := md.Convert([]byte(body), &buf); err != nil {
fmt.Println(err)
return template.HTML(body)