mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-28 14:51:41 +00:00
Compare commits
1 Commits
6c3f6605de
...
84920cc4cf
Author | SHA1 | Date | |
---|---|---|---|
|
84920cc4cf |
@ -47,8 +47,6 @@ type atomLinks []atomLink
|
|||||||
func (a *atomText) Text() string {
|
func (a *atomText) Text() string {
|
||||||
if a.Type == "html" {
|
if a.Type == "html" {
|
||||||
return htmlutil.ExtractText(a.Data)
|
return htmlutil.ExtractText(a.Data)
|
||||||
} else if a.Type == "xhtml" {
|
|
||||||
return htmlutil.ExtractText(a.XML)
|
|
||||||
}
|
}
|
||||||
return a.Data
|
return a.Data
|
||||||
}
|
}
|
||||||
|
@ -94,44 +94,6 @@ func TestAtomHTMLTitle(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAtomXHTMLTitle(t *testing.T) {
|
|
||||||
feed, _ := Parse(strings.NewReader(`
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
||||||
<entry><title type="xhtml">say <code>what</code>?</entry>
|
|
||||||
</feed>
|
|
||||||
`))
|
|
||||||
have := feed.Items[0].Title
|
|
||||||
want := "say what?"
|
|
||||||
if !reflect.DeepEqual(want, have) {
|
|
||||||
t.Logf("want: %#v", want)
|
|
||||||
t.Logf("have: %#v", have)
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAtomXHTMLNestedTitle(t *testing.T) {
|
|
||||||
feed, _ := Parse(strings.NewReader(`
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
||||||
<entry>
|
|
||||||
<title type="xhtml">
|
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<a href="https://example.com">Link to Example</a>
|
|
||||||
</div>
|
|
||||||
</title>
|
|
||||||
</entry>
|
|
||||||
</feed>
|
|
||||||
`))
|
|
||||||
have := feed.Items[0].Title
|
|
||||||
want := "Link to Example"
|
|
||||||
if !reflect.DeepEqual(want, have) {
|
|
||||||
t.Logf("want: %#v", want)
|
|
||||||
t.Logf("have: %#v", have)
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAtomImageLink(t *testing.T) {
|
func TestAtomImageLink(t *testing.T) {
|
||||||
feed, _ := Parse(strings.NewReader(`
|
feed, _ := Parse(strings.NewReader(`
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user