A lax Web news feed parser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

149 lines
4.4 KiB

Empty entry:
input: >
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<entry>Bogus text</entry>
</feed>
output:
format: atom
version: '1.0'
lang: en
Entry identifier:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<id>ook</id>
</entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- id: 'ook'
Entry language:
input: >
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<entry xml:lang="fr">
<id>ook</id>
</entry>
<entry>
<id>eek</id>
</entry>
</feed>
output:
format: atom
version: '1.0'
lang: en
entries:
- id: 'ook'
lang: fr
- id: eek
lang: en
Entry link:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<link rel="alternate" href="http://example.com/"/>
</entry>
<entry>
<link rel="alternate" type="application/xhtml+xml" href="http://example.net/"/>
<link rel="alternate" type="text/html" href="http://example.com/"/>
</entry>
<entry>
<link rel="alternate" type="image/svg+xml" href="http://example.net/"/>
<link rel="alternate" href="http://example.com/"/>
</entry>
<entry>
<link type="image/svg+xml" href="http://example.com/"/>
</entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- link: 'http://example.com/'
- link: 'http://example.com/'
- link: 'http://example.com/'
- link: 'http://example.com/'
Related link:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<link rel="related" href="http://example.com/"/>
</entry>
<entry>
<link rel="related" type="application/xhtml+xml" href="http://example.net/"/>
<link rel="related" type="text/html" href="http://example.com/"/>
</entry>
<entry>
<link rel="related" type="image/svg+xml" href="http://example.net/"/>
<link rel="related" href="http://example.com/"/>
</entry>
<entry>
<link rel="related" type="image/svg+xml" href="http://example.com/"/>
</entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- relatedLink: 'http://example.com/'
- relatedLink: 'http://example.com/'
- relatedLink: 'http://example.com/'
- relatedLink: 'http://example.com/'
Creation and update dates:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<published>2020-01-01T00:00:00Z</published>
<published>2020-03-03T00:00:00Z</published>
<updated>2020-03-03T00:00:00Z</updated>
<updated>2020-04-01T00:00:00Z</updated>
</entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- dateCreated: '2020-01-01T00:00:00Z'
dateModified: '2020-04-01T00:00:00Z'
Entry title:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry><title type="html" xml:base="http://example.com/">HTML title</title></entry>
<entry><title>Plain title</title></entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- title: {html: 'HTML title', htmlBase: 'http://example.com/'}
- title: 'Plain title'
Content and summary:
input: >
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<content>Plain content</content>
<summary>Plain summary</summary>
</entry>
<entry>
<content>Plain content</content>
</entry>
<entry>
<summary>Plain summary</summary>
</entry>
</feed>
output:
format: atom
version: '1.0'
entries:
- content: 'Plain content'
summary: 'Plain summary'
- content: 'Plain content'
- summary: 'Plain summary'