26 lines
505 B
Go
26 lines
505 B
Go
package atom
|
|
|
|
import (
|
|
"fmt"
|
|
"html"
|
|
)
|
|
|
|
type Text interface {
|
|
isText() bool
|
|
Check() error
|
|
}
|
|
|
|
// NewText creates a new Text. It returns a Text and an error.
|
|
func NewText(textType, content string) (Text, error) {
|
|
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, fmt.Errorf("%v is not a valid text type", textType)
|
|
}
|
|
}
|