Strip HTML from post summary
This removes HTML, in addition to the Markdown stripping that was already happening. This fixes #83
This commit is contained in:
parent
2f683e783e
commit
54edb2562d
4
posts.go
4
posts.go
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/guregu/null"
|
"github.com/guregu/null"
|
||||||
"github.com/guregu/null/zero"
|
"github.com/guregu/null/zero"
|
||||||
"github.com/kylemcc/twitter-text-go/extract"
|
"github.com/kylemcc/twitter-text-go/extract"
|
||||||
|
"github.com/microcosm-cc/bluemonday"
|
||||||
stripmd "github.com/writeas/go-strip-markdown"
|
stripmd "github.com/writeas/go-strip-markdown"
|
||||||
"github.com/writeas/impart"
|
"github.com/writeas/impart"
|
||||||
"github.com/writeas/monday"
|
"github.com/writeas/monday"
|
||||||
|
@ -205,6 +206,9 @@ func (p Post) Summary() string {
|
||||||
if p.Content == "" {
|
if p.Content == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
// Strip out HTML
|
||||||
|
p.Content = bluemonday.StrictPolicy().Sanitize(p.Content)
|
||||||
|
// and Markdown
|
||||||
p.Content = stripmd.Strip(p.Content)
|
p.Content = stripmd.Strip(p.Content)
|
||||||
|
|
||||||
title := p.Title.String
|
title := p.Title.String
|
||||||
|
|
Loading…
Reference in New Issue