Treat html differently from text in text constructs

This commit is contained in:
Jason Streifling 2024-10-15 16:01:40 +02:00
parent 2d1d95502f
commit 2cbc604d85

View File

@ -2,6 +2,7 @@ package atomfeed
import (
"fmt"
"html"
)
type Text interface {
@ -11,8 +12,10 @@ type Text interface {
func NewText(textType, content string) (Text, error) {
switch textType {
case "text", "html":
case "text":
return &PlainText{Type: textType, Text: content}, nil
case "html":
return &PlainText{Type: textType, Text: html.EscapeString(content)}, nil
case "xhtml":
return &XHTMLText{Type: textType, XHTMLDiv: content}, nil
case "":