Add newInlineXHTMLContent

This commit is contained in:
Jason Streifling 2024-10-15 20:53:01 +02:00
parent d96e2c61bb
commit 15b74c2675

View File

@ -1,6 +1,10 @@
package atomfeed package atomfeed
import "errors" import (
"errors"
"fmt"
"reflect"
)
type InlineXHTMLContent struct { type InlineXHTMLContent struct {
*CommonAttributes *CommonAttributes
@ -8,6 +12,18 @@ type InlineXHTMLContent struct {
XHTMLDiv string `xml:"xhtmldiv"` XHTMLDiv string `xml:"xhtmldiv"`
} }
func newInlineXHTMLContent(mediaType string, content any) (*InlineXHTMLContent, error) {
if mediaType != "xhtml" {
return nil, fmt.Errorf("media type %v incompatible with inline xhtml content", mediaType)
}
if reflect.TypeOf(content).Kind() != reflect.String {
return nil, fmt.Errorf("content type %T incompatible with inline xhtml content", content)
}
return &InlineXHTMLContent{Type: mediaType, XHTMLDiv: content.(string)}, nil
}
func (i *InlineXHTMLContent) isContent() bool { return true } func (i *InlineXHTMLContent) isContent() bool { return true }
func (i *InlineXHTMLContent) hasSRC() bool { return false } func (i *InlineXHTMLContent) hasSRC() bool { return false }