mirror of
https://github.com/rystaf/mlmym.git
synced 2024-09-19 12:20:09 +00:00
escape html tags in markdown instead of removing them
This commit is contained in:
parent
fb219c0f00
commit
edd773c2fc
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -154,6 +155,8 @@ var funcMap = template.FuncMap{
|
||||||
body = re.ReplaceAllString(body, "\n***\n")
|
body = re.ReplaceAllString(body, "\n***\n")
|
||||||
// community bangs
|
// community bangs
|
||||||
body = RegReplace(body, `([^\[])!([a-zA-Z0-9_]+)@([a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+)`, `$1[!$2@$3](/c/$2@$3)`)
|
body = RegReplace(body, `([^\[])!([a-zA-Z0-9_]+)@([a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+)`, `$1[!$2@$3](/c/$2@$3)`)
|
||||||
|
// escape HTML tags
|
||||||
|
body = html.EscapeString(body)
|
||||||
if err := md.Convert([]byte(body), &buf); err != nil {
|
if err := md.Convert([]byte(body), &buf); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return template.HTML(body)
|
return template.HTML(body)
|
||||||
|
|
Loading…
Reference in a new issue