package atom const ( InlineText = iota InlineXHTML InlineOther OutOfLine ) type Content interface { isContent() bool hasSRC() bool getType() string Check() error } // NewContent creates a new Content. It takes in an int contentType, a string // mediaType and an any content and returns a Content. // // If contentType is invalid, it returns nil. func NewContent(contentType int, mediaType string, content any) Content { switch contentType { case 0: if stringContent, ok := content.(string); ok { return newInlineTextContent(mediaType, stringContent) } return nil case 1: if xhtmlDivContent, ok := content.(*XHTMLDiv); ok { return newInlineXHTMLContent(mediaType, xhtmlDivContent) } return nil case 2: return newInlineOtherContent(mediaType, content) case 3: if stringContent, ok := content.(string); ok { return newOutOfLineContent(mediaType, stringContent) } return nil default: return nil } }