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

Ensure valid whitespace is not trimmed when html parsing mode is used #1689

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

rh101
Copy link
Contributor

@rh101 rh101 commented Feb 16, 2024

Describe your changes

Consider the following input:

<p>This is a sentence with a link        <a href="">Click me</a>&nbsp;and      some more text.</p>

or

<p>This is a sentence with a link&nbsp;<a href="">Click me</a>&nbsp;and some more text.</p>

The correct output should be:

This is a sentence with a link Click me and some more text.

What is actually being produced is the following:

This is a sentence with a linkClick meand some more text.

This is only an issue now that the leading and trailing whitespace trimming is enabled, but only affects HTML style parsing, since HTML has &emsp; and &nbsp;, which both insert spaces into the text. Those spaces end up being trimmed, when they should not be.

The fix in this PR will only disable trailing whitespace trimming if and only if html mode is enabled, so it will not have any affect in any other scenario. This fixes the issue with &emsp; and &nbsp;, ensuring the spaces generated by them are part of the output.

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

@rh101 rh101 changed the title Ensure valid whitespace is not trimmed when html mode is enabled Ensure valid whitespace is not trimmed when html parsin mode is used Feb 16, 2024
@rh101 rh101 changed the title Ensure valid whitespace is not trimmed when html parsin mode is used Ensure valid whitespace is not trimmed when html parsing mode is used Feb 16, 2024
@halx99 halx99 merged commit bd9877d into axmolengine:dev Feb 16, 2024
9 checks passed
@rh101 rh101 deleted the fix-space-trimming branch February 16, 2024 13:45
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.

2 participants