From b2fb194bc1a340c006241d61917e8eebc8d2fcc5 Mon Sep 17 00:00:00 2001 From: joedolson Date: Tue, 7 Feb 2023 16:18:22 +0000 Subject: [PATCH] Formatting: Treat `math` elements as block-level elements. The `math` element can be displayed either as a block or inline element. If `wpautop` only treats it as an inline element, it will break multiline elements by inserting `br` elements. Treating the element as a block element means that the editor won't break common normative usages of the `math` element. Prevent `math` elements from having internal elements split up with `br` elements, disrupting formatting. Props nicholaswilson, wojtek.szkutnik, hakre, conner_bw, ericlewis, hughie.molloy, SteelWagstaff, ryokuhi, joedolson, bgoewert, adamsilverstein, joedolson. Fixes #13340. Built from https://develop.svn.wordpress.org/trunk@55272 git-svn-id: http://core.svn.wordpress.org/trunk@54805 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index fc3770cfaf..2cc27ad069 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -480,7 +480,7 @@ function wpautop( $text, $br = true ) { // Change multiple
's into two line breaks, which will turn into paragraphs. $text = preg_replace( '|\s*|', "\n\n", $text ); - $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; + $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; // Add a double line break above block-level opening tags. $text = preg_replace( '!(<' . $allblocks . '[\s/>])!', "\n\n$1", $text ); @@ -568,7 +568,7 @@ function wpautop( $text, $br = true ) { // Optionally insert line breaks. if ( $br ) { // Replace newlines that shouldn't be touched with a placeholder. - $text = preg_replace_callback( '/<(script|style|svg).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text ); + $text = preg_replace_callback( '/<(script|style|svg|math).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text ); // Normalize
$text = str_replace( array( '
', '
' ), '
', $text ); diff --git a/wp-includes/version.php b/wp-includes/version.php index b97228733c..856ff45a59 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55271'; +$wp_version = '6.2-alpha-55272'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.