2024-10-16 21:28:04 +02:00
|
|
|
package atom
|
2024-10-13 17:19:40 +02:00
|
|
|
|
2024-10-19 14:12:51 +02:00
|
|
|
import "html"
|
2024-10-15 15:36:11 +02:00
|
|
|
|
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
|
|
|
|
}
|
2024-10-15 15:36:11 +02:00
|
|
|
|
2025-01-24 23:06:32 +01:00
|
|
|
// NewText creates a new Text. It takes in the strings textType and content and
|
|
|
|
// returns a Text.
|
|
|
|
//
|
|
|
|
// If textType is invalid it returns nil.
|
2024-10-19 14:12:51 +02:00
|
|
|
func NewText(textType, content string) Text {
|
2024-10-15 15:36:11 +02:00
|
|
|
switch textType {
|
2024-10-15 20:03:09 +02:00
|
|
|
case "text", "":
|
2024-10-19 12:28:09 +02:00
|
|
|
return newPlainText(textType, content)
|
2024-10-15 16:01:40 +02:00
|
|
|
case "html":
|
2024-10-19 12:28:09 +02:00
|
|
|
return newPlainText(textType, html.UnescapeString(content))
|
2024-10-15 15:36:11 +02:00
|
|
|
case "xhtml":
|
2024-10-19 12:28:09 +02:00
|
|
|
return newXHTMLText(textType, content)
|
2024-10-15 15:36:11 +02:00
|
|
|
default:
|
2024-10-19 14:12:51 +02:00
|
|
|
return nil
|
2024-10-15 15:36:11 +02:00
|
|
|
}
|
|
|
|
}
|