atom/text.go

24 lines
464 B
Go
Raw Normal View History

2024-10-13 17:19:40 +02:00
package atomfeed
import (
"fmt"
)
2024-10-13 17:19:40 +02:00
type Text interface {
Check() error
IsText() bool
}
func NewText(textType, content string) (Text, error) {
switch textType {
case "text", "html":
return &PlainText{Type: textType, Text: content}, nil
case "xhtml":
return &XHTMLText{Type: textType, XHTMLDiv: content}, nil
case "":
return &PlainText{Type: "text", Text: content}, nil
default:
return nil, fmt.Errorf("%v is not a valid text type", textType)
}
}