mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 16:37:19 -04:00
Strip HTML tags and render plain-text content only
This commit is contained in:
@@ -11,9 +11,14 @@ import (
|
||||
|
||||
"github.com/alecthomas/chroma/quick"
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
bf "gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
var (
|
||||
stripper = bluemonday.StrictPolicy()
|
||||
)
|
||||
|
||||
type Fragment struct {
|
||||
Token string
|
||||
Pre string
|
||||
@@ -247,10 +252,10 @@ func NewElement(node *bf.Node) Element {
|
||||
}
|
||||
case bf.HTMLBlock:
|
||||
return Element{
|
||||
Pre: "\n",
|
||||
Post: "\n",
|
||||
Pre: "",
|
||||
Post: "",
|
||||
Fragments: []Fragment{{
|
||||
Token: string(node.Literal),
|
||||
Token: strings.TrimSpace(stripper.Sanitize(string(node.Literal))) + "\n",
|
||||
Style: HTMLBlock,
|
||||
}},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user