-
Notifications
You must be signed in to change notification settings - Fork 0
Change default list item rendering to skip paragraph tags (breaking change) #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: nadar <3417221+nadar@users.noreply.github.com>
nadar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we need to enable this new behavior by default
- therefore rename the method/property, as skip is then not appropritae
- adjust the existing tests if needed due to this change
- add a changelog.md because its bc break and users need to know how to restore the original behavior
Co-authored-by: nadar <3417221+nadar@users.noreply.github.com>
Done in commit 55faebc:
Users can restore previous behavior with: $parser->setWrapParagraphsInListItems(true); |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 29 34 +5
===========================================
Files 3 3
Lines 92 104 +12
===========================================
+ Hits 92 104 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nadar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot rename the changelog.md to upgrade.md and it would be changes from 1.x to 2.x
Co-authored-by: nadar <3417221+nadar@users.noreply.github.com>
Problem
When ProseMirror/TipTap generates HTML from JSON, list items automatically contain paragraph tags, resulting in output like:
This makes styling difficult as the extra
<p>tags inside<li>elements are often undesirable. The expected output for simple list items should be:Solution
This PR changes the default behavior to render list items without paragraph tags for cleaner HTML output. Users who need the previous behavior can opt-in using the
setWrapParagraphsInListItems(true)method.Breaking Change - Version 2.x
The default rendering behavior has changed from version 1.x to 2.x:
<ul><li><p>text</p></li></ul>(paragraphs wrapped in list items)<ul><li>text</li></ul>(clean list items by default)Migration Guide
If you need to restore the version 1.x behavior with paragraph tags in list items:
See
UPGRADE.mdfor complete upgrade details from 1.x to 2.x.Key Features
setWrapParagraphsInListItems(true)to restore previous behaviorImplementation Details
The solution tracks parent node context during rendering to determine when a paragraph is inside a list item. By default, paragraphs inside list items are rendered without
<p>tags. Users can enable wrapping by callingsetWrapParagraphsInListItems(true).Paragraphs outside of lists continue to render with
<p>tags as expected, ensuring that only list items are affected by this option.Testing
ListTest.php) with 7 test methods covering:UPGRADE.mddocumenting the breaking change and upgrade path from 1.x to 2.xFixes the issue where list styling was difficult due to unwanted paragraph tags in list items.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.