1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-16 18:01:37 +00:00

Add better support of Atom text constructs

- Note that Miniflux does not render entry title with HTML tags as of now
- Omit XHTML div element because it should not be part of the content
This commit is contained in:
Frédéric Guillot 2021-03-19 21:49:35 -07:00 committed by fguillot
parent 96f3e888cf
commit c8c1f05328
2 changed files with 190 additions and 86 deletions

View file

@ -221,19 +221,33 @@ func (a *atom10Entry) entryCommentsURL() string {
}
type atom10Text struct {
Type string `xml:"type,attr"`
CharData string `xml:",chardata"`
InnerXML string `xml:",innerxml"`
Type string `xml:"type,attr"`
CharData string `xml:",chardata"`
InnerXML string `xml:",innerxml"`
XHTMLRootElement atomXHTMLRootElement `xml:"http://www.w3.org/1999/xhtml div"`
}
func (a *atom10Text) String() string {
var content string
if a.Type == "xhtml" {
switch {
case strings.HasPrefix(a.InnerXML, `<![CDATA[`):
content = a.CharData
case a.Type == "", a.Type == "text", a.Type == "text/plain":
content = a.InnerXML
} else {
case a.Type == "xhtml":
if a.XHTMLRootElement.InnerXML != "" {
content = a.XHTMLRootElement.InnerXML
} else {
content = a.InnerXML
}
default:
content = a.CharData
}
return strings.TrimSpace(content)
}
type atomXHTMLRootElement struct {
InnerXML string `xml:",innerxml"`
}