Skip to content

fix: whitespaces parsing inside normalizer#704

Merged
kacperzolkiewski merged 6 commits into
mainfrom
@kacperzolkiewski/fix-whitespaces-parsing
Jul 17, 2026
Merged

fix: whitespaces parsing inside normalizer#704
kacperzolkiewski merged 6 commits into
mainfrom
@kacperzolkiewski/fix-whitespaces-parsing

Conversation

@kacperzolkiewski

@kacperzolkiewski kacperzolkiewski commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes whitespaces parsing between tags in normaliser.

Test Plan

Insert some external html into example mobile/web app by Set input's value button for example:

<p>Asdasd</p>
<p>Asdasd</p>
<p>Asdasd</p>

And see if the output html is the same.

Screenshots / Videos

Screen.Recording.2026-07-16.at.12.48.12.mov

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@kacperzolkiewski
kacperzolkiewski marked this pull request as ready for review July 16, 2026 10:54
Copilot AI review requested due to automatic review settings July 16, 2026 10:54
@kacperzolkiewski
kacperzolkiewski marked this pull request as draft July 16, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an HTML normalization issue where whitespace-only text nodes between block elements (e.g., pretty-printed \n between <p> tags) could be treated as meaningful inline content, leading to empty paragraphs and later extra <br>s during serialization.

Changes:

  • Add “whitespace-only buffer” detection and discard inter-block whitespace during inline paragraph flushing.
  • Adjust <br> handling in mixed inline/block runs to avoid generating empty paragraphs from layout whitespace.
  • Add regression tests for inter-block whitespace normalization in both the web (TS) and native (C++) paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/web/normalization/htmlNormalizer.ts Discards whitespace-only buffered inline content to prevent empty <p> output and extra <br>s.
src/web/__tests__/htmlNormalizer.test.ts Adds regression coverage for pretty-printed inter-block whitespace cases.
cpp/tests/GumboParserTest.cpp Adds equivalent regression coverage for the C/C++ normalizer path.
cpp/parser/GumboNormalizer.c Implements whitespace-only detection and attempts to discard inter-block whitespace during normalization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cpp/parser/GumboNormalizer.c Outdated
Comment thread cpp/parser/GumboNormalizer.c
@kacperzolkiewski
kacperzolkiewski marked this pull request as ready for review July 16, 2026 11:17

@hejsztynx hejsztynx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Just left some minor comments.

Comment thread src/web/normalization/htmlNormalizer.ts Outdated
Comment thread cpp/parser/GumboNormalizer.c Outdated
@kacperzolkiewski
kacperzolkiewski merged commit c4390c7 into main Jul 17, 2026
9 checks passed
@kacperzolkiewski
kacperzolkiewski deleted the @kacperzolkiewski/fix-whitespaces-parsing branch July 17, 2026 11:32
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.

4 participants