[wp-trac] [WordPress Trac] #64609: HTML API: set_modifiable_text() ignores leading newlines in PRE, LISTING, TEXTAREA
WordPress Trac
noreply at wordpress.org
Thu Feb 26 15:13:07 UTC 2026
#64609: HTML API: set_modifiable_text() ignores leading newlines in PRE, LISTING,
TEXTAREA
--------------------------------------+-------------------------
Reporter: jonsurrell | Owner: jonsurrell
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 7.0
Component: HTML API | Version: 6.7
Severity: minor | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+-------------------------
Comment (by ozgursar):
== Patch Testing Report
Patch Tested: https://github.com/WordPress/wordpress-develop/pull/11062
=== Environment
- WordPress: 7.0-beta1-61709-src
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 145.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.4
- MU Plugins: None activated
- Plugins:
* Code Snippets 3.9.5
* Test Reports 1.2.1
=== Steps taken
1. Add the following test snippet via `functions.php` or `Code Snippets
plugin` to create a shortcode
{{{
add_shortcode( 'patch_test_64609', function() {
$out = '';
// textarea via WP_HTML_Processor
$p = WP_HTML_Processor::create_fragment( '<textarea></textarea>' );
$p->next_token();
$p->set_modifiable_text( "\nAFTER NEWLINE" );
$out .= $p->get_updated_html();
// pre and listing via WP_HTML_Tag_Processor directly
foreach ( [ 'pre', 'listing' ] as $tag ) {
$p = new WP_HTML_Tag_Processor( "<$tag>existing text</$tag>" );
$p->next_tag( $tag );
$p->next_token();
$p->set_modifiable_text( "\nAFTER NEWLINE" );
$out .= $p->get_updated_html();
}
return $out;
} );
}}}
2. Add the shortcode `[patch_test_64609]` to any page/post and view the
generated HTML
3. ✅ Patch is solving the problem
=== Expected result
- For the `TEXTAREA` element `\n` is working as expected.
- For `PRE` and `LISTING` elements there is no change (as also expected by
comment #4)
=== Screenshots/Screencast with results
Before
[[Image(https://i.imgur.com/bkkCAm3.png)]]
After
[[Image(https://i.imgur.com/fQcNNQh.png)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64609#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list