-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
autop: Correctly preserve attributed multi-line paragraphs in removep #15128
Conversation
@@ -502,3 +503,12 @@ test( 'that autop correctly adds a start and end tag when followed by a div', () | |||
|
|||
expect( autop( content ).trim() ).toBe( expected ); | |||
} ); | |||
|
|||
describe( 'removep', () => { | |||
test( 'preserves paragraphs with attributes', () => { |
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.
It's a bit scary that this is the only removep
test for such a huge pile of regular expressions.
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.
It's a bit scary that this is the only
removep
test for such a huge pile of regular expressions.
It is, yes. For historical context, the module originated as a direct port of the PHP implementation of autop
, including its tests. There is no removep
in PHP, so there are no tests. There was a previous removep
implementation in JavaScript from which this implementation was adapted, but it had no tests to port over.
I can plan to create a task issue to follow-up on adding more tests here.
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.
I can plan to create a task issue to follow-up on adding more tests here.
See #15152
Related: #9056 (comment)
This pull request seeks to resolve an issue where
removep
will wrongly remove a paragraph tag when it has attributes, if the paragraph spans multiple lines. As described in #9056 (comment), this occurs because the default behavior of.
in JavaScript regular expressions will not match newline characters.Before:
After:
Testing Instructions:
Ensure unit tests pass.
Verify that content is not mangled when multi-line paragraph in a classic block (i.e. in non-block-demarcated content).