Repository navigation
fix: normalizer adding empty list items for whitespace around blocks - #830
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
This branch has not been deployed
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
Fixes #829.
When a list item contains block children separated by whitespace, the HTML normalizer turns each whitespace run into its own empty list item. This is the shape CommonMark renderers produce for loose lists (
<li>\n<p>a</p>\n</li>), and it is common in pretty-printed HTML. WithuseHtmlNormalizerenabled (the default), a two-item list gets four extra empty list items.flush_li_buffer(C) andflushLiBuffer(web port) only skipped an empty buffer. They now also skip a whitespace-only buffer, the same checkflush_inline_palready uses for inter-block whitespace. Intentionally empty<li></li>items are still emitted, as covered byEmptyListItems.Impacts the HTML normalizer on iOS, Android (shared
cpp/parser/GumboNormalizer.c) and web (src/web/normalization/htmlNormalizer.ts).Test Plan
cd cpp && cmake -B build && cmake --build build && ctest --test-dir build:InterBlockWhitespacehas two new cases. Without the fix it fails with<ul><li>\n</li><li>a</li><li>\n</li><li>\n</li><li>b</li><li>\n</li></ul>; with the fix all 15 tests pass.yarn jest --selectProjects web src/web/__tests__/htmlNormalizer.test.ts: the same two cases fail without the fix (2 failed, 425 passed) and pass with it (427 passed).Screenshots / Videos
Not applicable. The change is covered by the normalizer unit tests.
Compatibility
Checklist