Page MenuHomePhabricator

Math block inside a {{blockquote}} render in display style in MathML and Client side MathJax
Open, HighPublicBUG REPORT

Assigned To
None
Authored By
SalixAlba
Dec 16 2024, 4:54 PM
Referenced Files
F63003528: image.png
Jul 5 2025, 3:34 PM
F62900464: image.png
Jul 4 2025, 11:54 PM
F58024163: image.png
Dec 16 2024, 4:54 PM
F58024160: image.png
Dec 16 2024, 4:54 PM

Description

Steps to replicate the issue (include links if applicable):

  • Set Math formatting mode to Client-side MathJax or MathML modes.
  • Enter {{blockquote|'''Prop''' <math>A</math> implies <math>B</math> ocassionally. }}

What happens?:

Renders as

image.png (305×745 px, 8 KB)

What should have happened instead?:

In SVG mode renders as

image.png (90×562 px, 7 KB)

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Chrome.

Example at https://en.wikipedia.beta.wmflabs.org/wiki/T382267

Event Timeline

This is possibly related to T377657, but Blockquote is a more common case. The same bug occurs if either {{blockquote}} or <blockquote> is used.

The parser is inserting <p> inside the <blockquote> and the <math> element isn't ending up inside those. It works as expected if you insert the <p> yourself.

Besides <blockquote> elements, floating divs (e.g. images) in the same paragraph also trigger this problem: <math>A</math> implies <math>B</math> ocassionally. <div style="display:float">

Even if the <math> tag is outside the <blockquote> we still get the same behaviour. The example

For the group <math>G=C_m</math> given <blockquote>m=5</blockquote>

Renders as

image.png (277×229 px, 7 KB)

This example is simplified from https://en.wikipedia.org/w/index.php?title=Group_cohomology&oldid=1293195916#Basic_examples
where an editor has used block quotes to format display equations.

This is quite a big problem, initial check indicates it might affect 474 main space articles on en-wiki.

I don't have an idea why this happens, or what could be done from within the Math extension to improve the situation.

I though as much, alas it is enough to block T271001 as rendering on many pages is substandard. Worse example I've seen is from https://en.wikipedia.org/wiki/Optical_metric

image.png (863×1 px, 65 KB)

Here a parenthesised expression is broken over multiple lines.

@SalixAlba I don't see anything on Optical metric, which version of Chrome are you using? It seems it is a browser bug. If so, shouldn't it be reported upstream?

SalixAlba raised the priority of this task from Medium to High.Jul 14 2025, 11:14 PM

I'm pretty sure its not my browser set up. You need to get down to the Electrodynamics in media residing in curved space-times section.

The wikitext

The fundamental quantity of electrodynamics is the potential 1-form <math>\boldsymbol{A},</math> from which the field strength tensor is the 2-form <math display="inline">\boldsymbol{F} = d \boldsymbol{A}.</math> From the nilpotency of the exterior derivative one immediately has the homogeneous Maxwell equations <blockquote><math>d \boldsymbol{F} = 0,</math></blockquote>

Gets converted to

<p>
The fundamental quantity of electrodynamics is the potential 1-form </p>
<math class="mwe-math-element mwe-math-element-inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow data-mjx-texclass="ORD"><mstyle displaystyle="true" scriptlevel="0"><mrow data-mjx-texclass="ORD"><mi>𝑨</mi></mrow><mo>,</mo></mstyle></mrow></math>
<p> from which the field strength tensor is the 2-form </p>

Note how closing </p> elements have been added. If you remove the <blockquote> element. The wikitext is converted to

<p>The fundamental quantity of electrodynamics is the potential 1-form <math class="mwe-math-element mwe-math-element-inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow data-mjx-texclass="ORD"><mstyle displaystyle="true" scriptlevel="0"><mrow data-mjx-texclass="ORD"><mi>𝑨</mi></mrow><mo>,</mo></mstyle></mrow></math> from which the field strength tensor is the 2-form <math class="mwe-math-element mwe-math-element-inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow data-mjx-texclass="ORD"><mstyle displaystyle="false" scriptlevel="0"><mrow data-mjx-texclass="ORD"><mi>𝑭</mi></mrow><mo stretchy="false">=</mo><mi>d</mi><mrow data-mjx-texclass="ORD"><mi>𝑨</mi></mrow><mo stretchy="false">.</mo></mstyle></mrow></math> From the nilpotency of the exterior derivative one immediately has the homogeneous Maxwell equations 
</p>

With no closing </p> before the <math> tag.

I think this happens before it get to the maths parser which is why its hard to fix.

You need Math formatting mode set to Client-side MathJax or MathML modes to see the problem.

Its a bit hacky but if we see

</p>
<math class="mwe-math-element mwe-math-element-inline">
...
</math>
<p>

Then it might be safe to conclude that the </p> and <p> are spurious. You need the mwe-math-element-inline class to know its an inline formula.