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

Improve space normalization when pretty-printing #1798

Closed
jhy opened this issue Jun 24, 2022 · 0 comments
Closed

Improve space normalization when pretty-printing #1798

jhy opened this issue Jun 24, 2022 · 0 comments
Assignees
Milestone

Comments

@jhy
Copy link
Owner

jhy commented Jun 24, 2022

When pretty-printing, newlines and trailing spaces could be better handled.

Two cases as examples:

<div>
·Text
</div>

(with · representing a space), is currently emitted as:

<div>
··Text·
</div>

As the textnode value is "·Text\n", and then when pre-printing, that gets indented (now two leading spaces but should only be one if the indent level is set to one); and then the trailing newline gets normalized to a space.

Similarly,

<div>
 <p>One
 <p>Two
</div>

Gets emitted as

<div>
 <p>One·</p>
 <p>Two·</p>
</div>

As the trailing newline in the textnode is normalized to a space, when it could actually be trimmed (as it is the last text in a block tag and therefore not important whitespace for text flow).

This would fix the underlying issue found in #1663.

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