atom/text.go

23 lines
418 B
Go
Raw Normal View History

2024-10-16 21:28:04 +02:00
package atom
2024-10-13 17:19:40 +02:00
import "html"
2024-10-13 17:19:40 +02:00
type Text interface {
2024-10-16 18:31:24 +02:00
isText() bool
2024-10-13 17:19:40 +02:00
Check() error
}
// NewText creates a new Text. It returns a Text.
func NewText(textType, content string) Text {
switch textType {
2024-10-15 20:03:09 +02:00
case "text", "":
return newPlainText(textType, content)
case "html":
return newPlainText(textType, html.UnescapeString(content))
case "xhtml":
return newXHTMLText(textType, content)
default:
return nil
}
}