First implementation of an atom feed
This commit is contained in:
23
plainText.go
Normal file
23
plainText.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package atomfeed
|
||||
|
||||
import "errors"
|
||||
|
||||
type PlainText struct {
|
||||
*CommonAttributes
|
||||
Type string `xml:"type,attr,omitempty"` // Must be text or html
|
||||
Text string `xml:"text"`
|
||||
}
|
||||
|
||||
func (p *PlainText) IsText() bool { return true }
|
||||
|
||||
func (p *PlainText) Check() error {
|
||||
if p.Type != "" && p.Type != "text" && p.Type != "html" {
|
||||
return errors.New("type attribute of plain text must be text or html if not omitted")
|
||||
}
|
||||
|
||||
if p.Text == "" {
|
||||
return errors.New("text element of plain text empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user