Skip to content

Commit

Permalink
fix: Include type for OPML subscriptions
Browse files Browse the repository at this point in the history
As per [OPML 2.0 specification]:

> Each sub-element of the body of the OPML document is a node of type rss or an outline element that contains nodes of type rss.

> Required attributes: type, text, xmlUrl.

[OPML 2.0 specification]: http://opml.org/spec2.opml#subscriptionLists
  • Loading branch information
jtojnar committed Dec 20, 2023
1 parent d906677 commit baab73d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/reader/opml/opml.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ type opmlOutline struct {
Outlines opmlOutlineCollection `xml:"outline,omitempty"`
}

func (outline opmlOutline) MarshalXML() ([]byte, error) {
type opmlOutlineXml opmlOutline

outlineType := ""
if IsSubscription(outline) {
outlineType = "rss"
}

return xml.Marshal(struct {
opmlOutlineXml
Type string `xml:"type,attr,omitempty"`
}{
opmlOutlineXml: opmlOutlineXml(outline),
Type: outlineType,
})
}

func (o *opmlOutline) IsSubscription() bool {
return strings.TrimSpace(o.FeedURL) != ""
}
Expand Down

0 comments on commit baab73d

Please # to comment.