mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55272 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -104,6 +104,63 @@ PS. Not yet subscribed for update notifications? <a href="%1$s" title="Subscri
|
||||
$this->assertSame( "<p>$str</p>", trim( wpautop( $str ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* wpautop() Should add <p> around inline "<math>" elements.
|
||||
*
|
||||
* @ticket 13340
|
||||
*/
|
||||
public function test_wrap_inline_math_elements() {
|
||||
$str = '<math><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow></math>';
|
||||
|
||||
$this->assertSame( "<p>$str</p>", trim( wpautop( $str ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* wpautop() Should not add <br> inside block "<math>" elements.
|
||||
*
|
||||
* @ticket 13340
|
||||
*/
|
||||
public function test_skip_block_math_elements() {
|
||||
$str = '<math display="block">
|
||||
<mtable>
|
||||
<mtr>
|
||||
<mtd>
|
||||
<msup><mrow><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>)</mo></mrow><mn>2</mn></msup>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mo>=</mo>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<msup><mi>c</mi><mn>2</mn></msup>
|
||||
<mo>+</mo><mn>4</mn><mo>⋅</mo>
|
||||
<mo>(</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>a</mi><mi>b</mi><mo>)</mo>
|
||||
</mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd>
|
||||
<msup><mi>a</mi><mn>2</mn></msup>
|
||||
<mo>+</mo><mn>2</mn><mi>a</mi><mi>b</mi><mo>+</mo>
|
||||
<msup><mi>b</mi><mn>2</mn></msup>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<mo>=</mo>
|
||||
</mtd>
|
||||
<mtd>
|
||||
<msup><mi>c</mi><mn>2</mn></msup>
|
||||
<mo>+</mo><mn>2</mn><mi>a</mi><mi>b</mi>
|
||||
</mtd>
|
||||
</mtr>
|
||||
<mtr>
|
||||
<mtd><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mtd>
|
||||
<mtd><mo>=</mo></mtd>
|
||||
<mtd><msup><mi>c</mi><mn>2</mn></msup></mtd>
|
||||
</mtr>
|
||||
</mtable>
|
||||
</math>';
|
||||
|
||||
$this->assertSame( "<p>$str</p>", trim( wpautop( $str ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* wpautop() Should not add <p> and <br/> around <source> and <track>
|
||||
*
|
||||
@@ -308,7 +365,6 @@ Paragraph two.';
|
||||
'map',
|
||||
'area',
|
||||
'address',
|
||||
'math',
|
||||
'style',
|
||||
'p',
|
||||
'h1',
|
||||
|
||||
Reference in New Issue
Block a user