Add newInlineXHTMLContent
This commit is contained in:
parent
d96e2c61bb
commit
15b74c2675
@ -1,6 +1,10 @@
|
||||
package atomfeed
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type InlineXHTMLContent struct {
|
||||
*CommonAttributes
|
||||
@ -8,6 +12,18 @@ type InlineXHTMLContent struct {
|
||||
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) hasSRC() bool { return false }
|
||||
|
Loading…
x
Reference in New Issue
Block a user