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

Replace ' by "'" before parsing HTML #83

Merged
merged 1 commit into from
Jan 2, 2019
Merged

Conversation

dlax
Copy link
Contributor

@dlax dlax commented Jan 1, 2019

Beautiful will does not parse HTML entities like ' as we expect
and the previous logic of replacing this after HTML parsing occurred
did not produced expected results.

To illustrate this, we change data in "test_timeline" to include a
literal ' as it sometimes occur in data returned by Mastodon API.
New HTML content is:

<p>The computer can&apos;t tell you the emotional story [...] </p>

Beautiful will parse this as as:

<p>The computer can&amp;apost tell you the emotional story [...] </p>

which is not what we expect.

We fix this by replacing &apos; before HTML parsing by Beautiful.
Since test data in "test_timeline" got updated we also add an extra
assertion checking that part of the content with a literal "'" is
(still) properly rendered.

Beautiful will does not parse HTML entities like `&apos;` as we expect
and the previous logic of replacing this *after* HTML parsing occurred
did not produced expected results.

To illustrate this, we change data in "test_timeline" to include a
literal `&apos;` as it sometimes occur in data returned by Mastodon API.
New HTML content is:

    <p>The computer can&apos;t tell you the emotional story [...] </p>

Beautiful will parse this as as:

    <p>The computer can&amp;apost tell you the emotional story [...] </p>

which is not what we expect.

We fix this by replacing `&apos;` *before* HTML parsing by Beautiful.
Since test data in "test_timeline" got updated we also add an extra
assertion checking that part of the content with a literal "'" is
(still) properly rendered.
@ihabunek ihabunek merged commit fc57d26 into ihabunek:master Jan 2, 2019
@ihabunek
Copy link
Owner

ihabunek commented Jan 2, 2019

Thanks! I believe this also solves the issue in #72.

@dlax dlax deleted the apos branch January 2, 2019 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants