26 lines
512 B
Go
26 lines
512 B
Go
package atom
|
|
|
|
import "html"
|
|
|
|
type Text interface {
|
|
isText() bool
|
|
Check() error
|
|
}
|
|
|
|
// NewText creates a new Text. It takes in the strings textType and content and
|
|
// returns a Text.
|
|
//
|
|
// If textType is invalid it returns nil.
|
|
func NewText(textType, content string) Text {
|
|
switch textType {
|
|
case "text", "":
|
|
return newPlainText(textType, content)
|
|
case "html":
|
|
return newPlainText(textType, html.UnescapeString(content))
|
|
case "xhtml":
|
|
return newXHTMLText(textType, content)
|
|
default:
|
|
return nil
|
|
}
|
|
}
|