Add missing tags to openImpliesClose for open <p> elements - #2493
Add missing tags to openImpliesClose for open <p> elements#2493FirmaSpring wants to merge 1 commit into
Conversation
Per the WHATWG HTML parsing spec, the list of start tags whose start implies the end of an open <p> element includes center, dialog, dir, hgroup, menu, search and summary. These entries were missing from the openImpliesClose map, so htmlparser2 nested these elements inside an open <p> instead of closing it, diverging from browser behavior. Add the seven missing entries and a regression test asserting that an open <p> is closed before <hgroup> opens. All 188 tests pass (vitest run). Co-authored-by: FirmamentalSpring <287222957+FirmaSpring@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe parser now implicitly closes an open ChangesHTML implicit close handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized parser change adds the missing implicit paragraph-closing behavior and includes regression coverage; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| src/Parser.ts | Adds seven standards-aligned entries to the existing HTML-mode implicit-close map without introducing a new parsing path. |
| src/Parser.spec.ts | Adds a focused callback-order regression test for implicit paragraph closure before <hgroup>. |
Reviews (1): Last reviewed commit: "Add missing tags to openImpliesClose for..." | Re-trigger Greptile
Problem
Per the WHATWG HTML parsing spec (https://html.spec.whatwg.org/multipage/syntax.html#optional-tags), the list of start tags whose start implies the end of an open
<p>element includescenter,dialog,dir,hgroup,menu,searchandsummary. These entries are missing from theopenImpliesClosemap insrc/Parser.ts, so htmlparser2 nests these elements inside an open<p>instead of closing it, diverging from browser behavior. For example, parsing<p>text<menu>item</menu>keeps the<menu>inside the paragraph.Fix
Add the seven missing entries to
openImpliesClose:<p>Verification
src/Parser.spec.tsasserting that an open<p>is implicitly closed before<hgroup>opens.vitest run: 7 test files, 188 tests passed (including the new regression test).Co-authored-by: FirmamentalSpring 287222957+FirmaSpring@users.noreply.github.com
Summary by CodeRabbit
Bug Fixes
Tests
<hgroup>element begins.