Page MenuHomePhabricator

Determine block mode vs. inline mode properly for MathJax
Closed, ResolvedPublic

Description

In all these formulas

\bigwedge_x
\bigvee_x
\sum_{0\le i\le m\atop 0<j<n}P(i,j)

the PNG shows the subscript below the symbol, while MathJax puts them in the lower left corner. Consistency would be nice, but not necessary.


Version: unspecified
Severity: minor
URL: http://leuksman.com/mw/index.php/Block_vs._inline

Details

Reference
bz35188

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:16 AM
bzimport added a project: Math.
bzimport set Reference to bz35188.
bzimport added a subscriber: Unknown Object (MLST).

Created attachment 10325
the png version

Attached:

d516e253331adc958db85ac9bd720017.png (48×145 px, 1 KB)

Created attachment 10326
the mathjax version

They look similar to me. What browser and version do you have, might be browser specific issue ?

Attached:

Screen_Shot_2012-03-25_at_22.13.48.png (57×136 px, 8 KB)

I found out where the problem is:

While texvc renders every formula in block mode ($$), MathJax is able to render both for block mode and inline mode ($). But the configuration for this in MathJax/extensions/wiki2jax.js is not ideal. Have a look at the ConvertMath function. Block mode is only chosen for formulas directly inside a <DD> with only one child, i. e. when a formula is indented using colons. This will fail when formulas are wrapped inside a span (see bug 35191). Furthermore formulas which form there own paragraph should be treated as block, too. Currently there is some code to insert \displaystyle etc. to do this.

I created a test page on http://leuksman.com/mw/index.php/Block_vs._inline. This shows that it actually looks as expected, but a cleaner code would be nice.

Perhaps some code like

if ( $formula.closest( 'p, div, dd' ).text() === $formula.text() ) {
$$-mode
} else {
$-mode
}

works, but I didn't test this.

Nageh said something about this that is relevant when he detailed his changes: https://en.wikipedia.org/wiki/User_talk:Nageh#MathJax_integration_into_stock_MediaWiki

Heuristic detection of inline vs. display maths. Heuristic used: parent HTML element is "DD" and maths element is the only child, then interpret as "display maths", otherwise as "inline maths". Also, if the maths element is classified as "inline maths" but the element is the first child in the parent "DD", precede the maths with "\displaystyle": this effectively treats the maths as a display-style formula but without the newline of ordinary display maths formulas. See ConvertMath() function in User:Nageh/mathJax/config/TeX-AMS-texvc_HTML.js.

  • Bug 36062 has been marked as a duplicate of this bug. ***

From bug 36062:
The added \displaystyle also appears on [right click]-Show Math As-TeX Commands, which might be confusing for users.

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

I've not done the oiint part yet, we will have to add that later.

https://gerrit.wikimedia.org/r/23079 (Gerrit Change Ie0c308c31d38581e556dc73109879c7a3d365121) | change APPROVED and MERGED [by jenkins-bot]

Gerrit patch got merged, can this bug report get closed as RESOLVED FIXED or is there anything else to do?

Tested with

Formula <math>\bigwedge_x</math> in text.

Here comes a formula:

<math>\bigwedge_x</math>

Here comes an indented formula:

:<math>\bigwedge_x</math>

Everything looks as it should.