atom/xhtmlText.go

30 lines
647 B
Go
Raw Normal View History

2024-10-16 21:28:04 +02:00
package atom
2024-10-13 17:19:40 +02:00
2024-10-15 16:02:13 +02:00
import (
"errors"
2024-10-17 18:12:23 +02:00
"fmt"
2024-10-15 16:02:13 +02:00
)
2024-10-13 17:19:40 +02:00
type XHTMLText struct {
*CommonAttributes
Type string `xml:"type,attr"` // Must be xhtml
2024-10-15 16:02:13 +02:00
XHTMLDiv XHTMLDiv
2024-10-13 17:19:40 +02:00
}
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-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" {
return errors.New("type attribute of xhtml text must be xhtml")
}
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
}