2024-10-16 21:28:04 +02:00
|
|
|
package atom
|
2024-10-13 17:19:40 +02:00
|
|
|
|
2024-10-15 21:14:30 +02:00
|
|
|
const (
|
|
|
|
InlineText = iota
|
|
|
|
InlineXHTML
|
|
|
|
InlineOther
|
|
|
|
OutOfLine
|
|
|
|
)
|
|
|
|
|
2024-10-13 17:19:40 +02:00
|
|
|
type Content interface {
|
2024-10-15 19:32:14 +02:00
|
|
|
isContent() bool
|
|
|
|
hasSRC() bool
|
|
|
|
getType() string
|
2024-10-13 17:19:40 +02:00
|
|
|
Check() error
|
|
|
|
}
|
2024-10-15 21:14:30 +02:00
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// NewContent creates a new Content. It returns a Content and an error.
|
2024-10-19 14:12:51 +02:00
|
|
|
func NewContent(contentType int, mediaType string, content any) Content {
|
2024-10-15 21:14:30 +02:00
|
|
|
switch contentType {
|
|
|
|
case 0:
|
2024-10-19 14:12:51 +02:00
|
|
|
return newInlineTextContent(mediaType, content.(string))
|
2024-10-15 21:14:30 +02:00
|
|
|
case 1:
|
2024-10-19 14:12:51 +02:00
|
|
|
return newInlineXHTMLContent(mediaType, content.(*XHTMLDiv))
|
2024-10-15 21:14:30 +02:00
|
|
|
case 2:
|
|
|
|
return newInlineOtherContent(mediaType, content)
|
|
|
|
case 3:
|
2024-10-19 14:12:51 +02:00
|
|
|
return newOutOfLineContent(mediaType, content.(string))
|
2024-10-15 21:14:30 +02:00
|
|
|
default:
|
2024-10-19 14:12:51 +02:00
|
|
|
return nil
|
2024-10-15 21:14:30 +02:00
|
|
|
}
|
|
|
|
}
|