Make WordPress Core

Changeset 55272

Timestamp:
02/07/2023 04:16:47 PM (18 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.

Location:
trunk
Files:
2 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).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text );
    572572
    573573        // Normalize <br>
  • trunk/tests/phpunit/tests/formatting/wpAutop.php

    r53687 r55272  
    106106
    107107    /**
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
    108165     * wpautop() Should not add <p> and <br/> around <source> and <track>
    109166     *
     
    309366            'area',
    310367            'address',
    311             'math',
    312368            'style',
    313369            'p',
Note: See TracChangeset for help on using the changeset viewer.