2024-10-16 21:28:04 +02:00
|
|
|
package atom
|
2024-10-13 17:19:40 +02:00
|
|
|
|
2024-10-19 12:28:09 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
2024-10-15 16:02:13 +02:00
|
|
|
|
2024-10-13 17:19:40 +02:00
|
|
|
type XHTMLText struct {
|
|
|
|
*CommonAttributes
|
2024-10-17 19:44:27 +02:00
|
|
|
XHTMLDiv *XHTMLDiv
|
2024-10-13 17:19:40 +02:00
|
|
|
Type string `xml:"type,attr"` // Must be xhtml
|
|
|
|
}
|
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// isText checks whether the XHTMLText is a Text. It returns a bool.
|
2024-10-16 18:31:24 +02:00
|
|
|
func (x *XHTMLText) isText() bool { return true }
|
2024-10-13 17:19:40 +02:00
|
|
|
|
2024-10-19 14:12:51 +02:00
|
|
|
// newPlainText creates a new PlainText. It returns a *PlainText.
|
|
|
|
func newXHTMLText(textType, content string) *XHTMLText {
|
2024-10-19 12:28:09 +02:00
|
|
|
return &XHTMLText{
|
2024-10-19 14:52:19 +02:00
|
|
|
CommonAttributes: newCommonAttributes(),
|
|
|
|
Type: textType,
|
|
|
|
XHTMLDiv: NewXHTMLDiv(content),
|
2024-10-19 14:12:51 +02:00
|
|
|
}
|
2024-10-19 12:28:09 +02:00
|
|
|
}
|
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// Check checks the XHTMLText for incompatibilities with RFC4287. It returns an
|
|
|
|
// error.
|
2024-10-13 17:19:40 +02:00
|
|
|
func (x *XHTMLText) Check() error {
|
|
|
|
if x.Type != "xhtml" {
|
2024-10-18 19:04:08 +02:00
|
|
|
return fmt.Errorf("type attribute of xhtml text %v must be xhtml", x)
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-17 18:12:23 +02:00
|
|
|
if err := x.XHTMLDiv.Check(); err != nil {
|
|
|
|
return fmt.Errorf("xhtml div element %v of xhtml text %v: %v", x.XHTMLDiv, x, err)
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|