Treat html differently from text in text constructs
This commit is contained in:
parent
2d1d95502f
commit
2cbc604d85
5
text.go
5
text.go
@ -2,6 +2,7 @@ package atomfeed
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Text interface {
|
type Text interface {
|
||||||
@ -11,8 +12,10 @@ type Text interface {
|
|||||||
|
|
||||||
func NewText(textType, content string) (Text, error) {
|
func NewText(textType, content string) (Text, error) {
|
||||||
switch textType {
|
switch textType {
|
||||||
case "text", "html":
|
case "text":
|
||||||
return &PlainText{Type: textType, Text: content}, nil
|
return &PlainText{Type: textType, Text: content}, nil
|
||||||
|
case "html":
|
||||||
|
return &PlainText{Type: textType, Text: html.EscapeString(content)}, nil
|
||||||
case "xhtml":
|
case "xhtml":
|
||||||
return &XHTMLText{Type: textType, XHTMLDiv: content}, nil
|
return &XHTMLText{Type: textType, XHTMLDiv: content}, nil
|
||||||
case "":
|
case "":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user