feat: normalizer preserves text alignment styles#702
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes HTML normalization so that text-align styling is preserved across normalization passes (preventing textAlignment loss in downstream rendering), and adds regression tests to ensure consistent behavior across the web and Gumbo-based normalizers.
Changes:
- Add canonical emission of
style="text-align: ..."for specific block tags (p,ul/ol,h1–h6) when the input contains a validtext-alignvalue. - Preserve alignment when blockquote content is flattened into
<p>nodes. - Add matching test coverage in both the web Jest suite and the C++ Gumbo parser tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/web/normalization/htmlNormalizer.ts | Emits canonical text-align style for alignable tags and carries alignment through blockquote flattening. |
| src/web/tests/htmlNormalizer.test.ts | Adds Jest test matrix covering valid/invalid alignment values, tag eligibility, and blockquote flattening behavior. |
| cpp/parser/GumboNormalizer.c | Adds alignment parsing/canonicalization and propagates alignment during blockquote flattening in the native normalizer. |
| cpp/tests/GumboParserTest.cpp | Adds native regression tests mirroring the web normalizer alignment expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kacperzolkiewski
approved these changes
Jul 16, 2026
Collaborator
There was a problem hiding this comment.
Alignment Looks and works properly.
But I found out some issue with spacing between paragraphs when using normalizer on iOS:
Edit: created fix for that issue: #704
Screen.Recording.2026-07-16.at.11.27.28.mov
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
HTML normalizer did not preserve
textAlignmentstyling attributes, sotextAlignmentwas lost on re-normalization.Test Plan
When you used this html in the
Set input's valuein the example app before the fix, the text alignment was lostVideos
Before:
Screen.Recording.2026-07-15.at.16.32.11.mov
After:
The text alignment is preserved
Screen.Recording.2026-07-15.at.16.26.16.mov
Compatibility
Checklist