Copy post parsing funcs to posts pkg

This commit is contained in:
Matt Baer
2021-04-13 23:49:59 -04:00
parent 95a3a717ed
commit fd1559928a
4 changed files with 174 additions and 16 deletions
+7
View File
@@ -3,6 +3,7 @@ package posts
import (
"github.com/microcosm-cc/bluemonday"
"github.com/writeas/saturday"
"html"
"regexp"
"strings"
"unicode"
@@ -61,3 +62,9 @@ func ApplyBasicMarkdown(data []byte) string {
return outHTML
}
// StripHTMLWithoutEscaping strips HTML tags with bluemonday's StrictPolicy, then unescapes the HTML
// entities added in by sanitizing the content.
func StripHTMLWithoutEscaping(content string) string {
return html.UnescapeString(bluemonday.StrictPolicy().Sanitize(content))
}