Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atom summary/content is order-dependent #262

Open
lemon24 opened this issue Nov 15, 2021 · 0 comments
Open

Atom summary/content is order-dependent #262

lemon24 opened this issue Nov 15, 2021 · 0 comments

Comments

@lemon24
Copy link
Owner

lemon24 commented Nov 15, 2021

Seems like a feedparser issue: kurtmckee/feedparser#59

Repro:

import reader, io, feedparser

feed_bytes = b"""\
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <entry>
        <id>one</id>
        <summary>summary-one</summary>
        <content type="html">content-one</content>
    </entry>
    <entry>
        <id>two</id>
        <content type="html">content-two</content>
        <summary>summary-two</summary>
    </entry>
</feed>
"""

parser = reader._parser.default_parser().get_parser_by_mime_type('application/atom+xml')

feed, entries = parser('url', io.BytesIO(feed_bytes))
for entry in entries:
    print(entry.id)
    print(' ', 'summary', entry.summary)
    print(' ', 'content')
    for content in entry.content:
        print('   ', content)

print()

for entry in feedparser.parse(io.BytesIO(feed_bytes)).entries:
    print(entry.id)
    print(' ', 'summary', entry.summary)
    print(' ', 'content')
    for content in entry.content:
        print('   ', content)

Output:

one
  summary summary-one
  content
    Content(value='content-one', type='text/html', language=None)
two
  summary content-two
  content
    Content(value='content-two', type='text/html', language=None)
    Content(value='summary-two', type='text/plain', language=None)

one
  summary summary-one
  content
    {'type': 'text/html', 'language': None, 'base': '', 'value': 'content-one'}
two
  summary content-two
  content
    {'type': 'text/html', 'language': None, 'base': '', 'value': 'content-two'}
    {'type': 'text/plain', 'language': None, 'base': '', 'value': 'summary-two'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant