HTML API: Preserve leading newlines in PRE, TEXTAREA#24
HTML API: Preserve leading newlines in PRE, TEXTAREA#24
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements HTML standard-compliant handling of leading newlines in PRE, TEXTAREA, and LISTING elements. According to the HTML specification, these elements ignore their first leading newline as an authoring convenience, but subsequent newlines are significant and must be preserved.
Changes:
- Added serialization logic to restore stripped leading newlines in PRE and LISTING elements when serializing text nodes
- Added serialization logic to prepend a newline to TEXTAREA content to preserve any subsequent newlines
- Added comprehensive test coverage for PRE and TEXTAREA elements with single and double leading newlines
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php | Adds test cases for leading newline handling in PRE and TEXTAREA elements, including edge cases with multiple text nodes and double leading newlines |
| src/wp-includes/html-api/class-wp-html-processor.php | Implements serialization logic to restore stripped leading newlines in PRE/LISTING text nodes and prepend newlines to TEXTAREA content |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php:3
- This import statement for 'assertNotEmpty' is added but never used in the file. It should be removed.
* Unit tests covering WP_HTML_Processor serialization functionality.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add serialize + normalize tests Add more PRE tests Fix newlines disappearing inside PRE,TEXTAREA elements Handline PRE,LISTING lints Simpler fix Remove overly-specific tests Add LISTING tests Add explanatory comment lints Remove accidental import
4e5a7d4 to
d130c92
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
According to the HTML standard, a leading newline will be removed from PRE, TEXTAREA, LISTING elements.
Preserve those newlines.