Make WordPress Core


Ignore:
Timestamp:
02/07/2023 04:16:47 PM (19 months ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r55245 r55272  
    481481    $text = preg_replace( '|<br\s*/?>\s*<br\s*/?>|', "\n\n", $text );
    482482
    483     $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)';
     483    $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)';
    484484
    485485    // Add a double line break above block-level opening tags.
     
    569569    if ( $br ) {
    570570        // Replace newlines that shouldn't be touched with a placeholder.
    571         $text = preg_replace_callback( '/<(script|style|svg).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text );
     571        $text = preg_replace_callback( '/<(script|style|svg|math).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text );
    572572
    573573        // Normalize <br>
Note: See TracChangeset for help on using the changeset viewer.