fix: whitespaces parsing inside normalizer#704
Merged
kacperzolkiewski merged 6 commits intoJul 17, 2026
Conversation
kacperzolkiewski
marked this pull request as ready for review
July 16, 2026 10:54
kacperzolkiewski
marked this pull request as draft
July 16, 2026 10:54
2 tasks
Contributor
There was a problem hiding this comment.
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.
kacperzolkiewski
marked this pull request as ready for review
July 16, 2026 11:17
hejsztynx
approved these changes
Jul 16, 2026
hejsztynx
left a comment
Collaborator
There was a problem hiding this comment.
Works great! Just left some minor comments.
Co-authored-by: Krystian Sienkiewicz <146986839+hejsztynx@users.noreply.github.com>
exploIF
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 valuebutton for example:And see if the output html is the same.
Screenshots / Videos
Screen.Recording.2026-07-16.at.12.48.12.mov
Compatibility
Checklist