Formatting: Add strip_html_newlines() function - #11450
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
3d36f58 to
60920d2
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
SainathPoojary
left a comment
There was a problem hiding this comment.
The overall architecture is sound, using wp_html_split() is the correct WordPress API choice, the early-exit optimization is well placed. However, there is one confirmed correctness bug with real-world impact that must be fixed before this merges.
60920d2 to
77b27f6
Compare
… in specific HTML elements
… allowed list using regex word boundaries
77b27f6 to
b74bae5
Compare
Trac ticket: https://core.trac.wordpress.org/ticket/5678
This PR adds
strip_html_newlines()towp-includes/formatting.php, a function that strips unnecessary newlines from text nodes in fully marked-up HTML while preserving newlines insidepre,code,kbd,script, andstyleelements (maybe we can fix the hardcoding and think of something better later but keeping this simple for now)This is useful for cleaning up imported HTML content before it is processed by
wpautop(), which would otherwise convert superfluous newlines into unwanted<br />elements.Testing
Refreshing and inspired by the patch - https://core.trac.wordpress.org/attachment/ticket/5678/5678.r6633.diff
Props @hansengel