34 lines
715 B
Go
34 lines
715 B
Go
package atom
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
InlineText = iota
|
|
InlineXHTML
|
|
InlineOther
|
|
OutOfLine
|
|
)
|
|
|
|
type Content interface {
|
|
isContent() bool
|
|
hasSRC() bool
|
|
getType() string
|
|
Check() error
|
|
}
|
|
|
|
// NewContent creates a new Content. It returns a Content and an error.
|
|
func NewContent(contentType int, mediaType string, content any) (Content, error) {
|
|
switch contentType {
|
|
case 0:
|
|
return newInlineTextContent(mediaType, content)
|
|
case 1:
|
|
return newInlineXHTMLContent(mediaType, content)
|
|
case 2:
|
|
return newInlineOtherContent(mediaType, content)
|
|
case 3:
|
|
return newOutOfLineContent(mediaType, content)
|
|
default:
|
|
return nil, fmt.Errorf("error creating new content: %v is not a valid text type", contentType)
|
|
}
|
|
}
|