Page MenuHomePhabricator

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

Assigned To
Authored By
SalixAlba
Dec 16 2024, 4:54 PM
Referenced Files
F99032989: image.png
Tue, Aug 18, 8:12 PM
F97369956: grafik.png
Thu, Aug 6, 2:04 PM
F74699282: Screenshot 2026-03-31 at 16.40.05.png
Mar 31 2026, 3:54 PM
F74699250: Screenshot 2026-03-31 at 16.46.15.png
Mar 31 2026, 3:54 PM
F74699204: Screenshot 2026-03-31 at 16.45.04.png
Mar 31 2026, 3:54 PM
F74059323: Screenshot 2026-03-28 at 18.02.47.png
Mar 28 2026, 5:06 PM
F72208262: image.png
Feb 20 2026, 3:59 PM
F63003528: image.png
Jul 5 2025, 3:34 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 (745×305 px, 8 KB)

What should have happened instead?:

In SVG mode renders as

image.png (562×90 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

Details

Related Objects

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 (229×277 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 (1,543×863 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.

Hello,

I added also T375238 as a parent task. I think this is also the problem seen in the picture

image.png (1,333×650 px, 71 KB)

The picuture is gereated from https://de.wikipedia.org/w/index.php?title=Integralrechnung&oldid=259297415 And I used MathJax for rendering.

The code is:

Stammfunktionen und der Hauptsatz der Differential- und Integralrechnung

{{Hauptartikel|Fundamentalsatz der Analysis}}Die Integration ist eine nicht-eindeutige Umkehrung der Differentiation. Um dies zu präzisieren, wird der Begriff der [[Stammfunktion]] benötigt: Ist <math>f</math> eine Funktion, so heißt eine Funktion <math>F</math> eine ''Stammfunktion'' von <math>f</math>, wenn die [[Differentialrechnung|Ableitung]] von <math>F</math> gleich <math>f</math> ist:
: <math>F' = f</math>

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.

@Christian1985 This explains the situation pretty well I think. From within the Math extension, I don't think anything can be done about it. I was thinking maybe the problem vanishes once we switch to parsoid parsing and created https://de.wikipedia.beta.wmcloud.org/wiki/T382267 where I can not reproduce the problem. See https://www.mediawiki.org/wiki/Parsoid/Parser_Unification maybe @cscott has more insights

Hello,

I added also T375238 as a parent task. I think this is also the problem seen in the picture

image.png (1,333×650 px, 71 KB)

The picuture is gereated from https://de.wikipedia.org/w/index.php?title=Integralrechnung&oldid=259297415 And I used MathJax for rendering.

The code is:

Stammfunktionen und der Hauptsatz der Differential- und Integralrechnung

{{Hauptartikel|Fundamentalsatz der Analysis}}Die Integration ist eine nicht-eindeutige Umkehrung der Differentiation. Um dies zu präzisieren, wird der Begriff der [[Stammfunktion]] benötigt: Ist <math>f</math> eine Funktion, so heißt eine Funktion <math>F</math> eine ''Stammfunktion'' von <math>f</math>, wenn die [[Differentialrechnung|Ableitung]] von <math>F</math> gleich <math>f</math> ist:
: <math>F' = f</math>

@Physikerwelt , what do you mean by "This does not seem to be related to MathJax"? The rendering in the picture in the quoted message is MathJax and the output is ugly as hell. With standard svg the page looks much better.

I think it works by accident for the images generated by the SVG rendering mode. https://www.mediawiki.org/wiki/Help:Formatting/de links to the https://phabricator.wikimedia.org/T309778 . I think that's the problem to be solved here.

Change #1262984 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] Hide native MathML from RemexHTML

https://gerrit.wikimedia.org/r/1262984

Screenshot 2026-03-28 at 18.02.47.png (574×284 px, 22 KB)

the proposed patch fixes the problem. However, it uses strip marker which have been the source for many problems in connection with other extensions that modify them, so that they are not found when they should be expended.

Change #1262984 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Hide native MathML from RemexHTML

https://gerrit.wikimedia.org/r/1262984

Physikerwelt claimed this task.

It works on testwiki

Screenshot 2026-03-31 at 16.45.04.png (2,476×1,242 px, 355 KB)
and not in beta
Screenshot 2026-03-31 at 16.46.15.png (2,066×1,582 px, 203 KB)
unless in preview mode
Screenshot 2026-03-31 at 16.40.05.png (1,186×632 px, 106 KB)
. I am guessing this might be related to the use of parsoid parsing, but it's just a guess. The main problem seems to be resolved with the rollout of wmf.22 However, the current workaround is not an elegant solution thus I suggest to keep T420668 open.

Hello @Physikerwelt ,

should this bug be fixed for now? Using client side MathJax. The layout of the page https://de.wikipedia.org/w/index.php?title=K%C3%A4hler-Einstein-Mannigfaltigkeit&oldid=269053772 is still broken.

grafik.png (1,465×791 px, 130 KB)

Physikerwelt added a subscriber: Krinkle.

This is a new bug that only occurs when you render the page with Parsoid. When rendering without Parsoid, it works. Can you check if you have Parsoid rendering disabled in your settings?

Hello @Physikerwelt ,

what is Pardoid? What do I have to do to deactivate it? Do I have to open a new ticket?

My settings

image.png (1,443×384 px, 59 KB)

what is Parsoid? What do I have to do to deactivate it?

Hi, see https://www.mediawiki.org/wiki/Help:Extension:ParserMigration for options - either via your user preferences/settings, or by passing the parameter useparsoid=0 in the URL/web address.