Extension:Math/Roadmap

From mediawiki.org

The Math extension (or, more broadly, the rendering of the <math> tag) has a long history. It has been modified by a number of different people with different goals, different ideas, and different programming styles, using different underlying technologies. As a result, this extension's design and documentation are somewhat chaotic.

The aim of this page is to develop a consistent proposal for the future development of this extension. If you are interested in helping, you may edit this page directly, leave a comment on the discussion page or our Math community group.

Quick and dirty syntax update strategy[edit]

The aim of this update-strategy is to get rid of the texvcjs modifications as soon as possible, accepting some temporary errors. Other changes will be deferred to a later date, so they can be discussed and prepared in detail without risking that, if we encounter problems during this discussion and preparation phase, syntax workarounds for mhchem continue to grow and become unmanageable.

Theoretically, the texvcjs modifications also enable the use of non-standard notation for conventional equations, exaggerated example: using a code that looks like:

<mAth let's put some="comment here displAy="block >a=\sqrt[\begin{align}[did you know that \exp=\frac{1}{2}? & be careful adding other stuff, it might break the layout]\\b^2\\&\\\end{align}+c^2]</MaTH >

however this is not needed and usually not done, because the conventional notation works.

Step 1 Part A: Remove problematic texvc redefinitions[edit]

Remove only non-standard texvc redefinitions that cannot be easily absorbed by including the texvc package, which is roughly equivalent to a LaTeX-header like Extension:Math/TeX-header. Those problematic redefinitions are

Current syntax Suggested replacement Comment Status
$ \$ redefinition would involve changing the character code In progress In progress with User:Texvc2LaTeXBot
% \% redefinition would involve changing the character code In progress In progress with User:Texvc2LaTeXBot
\and \land causes normal align environment to fail In progress In progress with User:Texvc2LaTeXBot
\or \lor see [1]; causes teubner to fail In progress In progress with User:Texvc2LaTeXBot
\pagecolor remove not needed and not working anymore Yes Done manually
\part \partial acceptable if the document doesn't use sectioning with \part. In progress In progress with User:Texvc2LaTeXBot
\ang \angle this only conflicts with siunitx package. In progress In progress with User:Texvc2LaTeXBot
\C \Complex conflicts with puenc.def e.g. from hyperref package In progress In progress with User:Texvc2LaTeXBot
\H \mathbb{H} conflicts with text command \H{0} which is ő. In progress In progress with User:Texvc2LaTeXBot
\bold \mathbf In progress In progress with User:Texvc2LaTeXBot
\Bbb \mathbb In progress In progress with User:Texvc2LaTeXBot

Since we do not have a live database of all mathematical equations and their origin we rely on the xml dumps.

Step 1 Part B: Investigate and remove strange errors[edit]

Investigate and remove strange errors like <chem>^3 [X]</chem> resulting in Failed to parse (Conversion error. Server ("https://wikimedia.org/api/rest_") reported: "Cannot get mml. TeX parse error: Extra close brace or missing open brace"): {\displaystyle {\ce {^3 [X]}}} which are not triggered by texvcjs(?), but some other modification / interaction with MediaWiki??? Needs help

Step 1 Part C: Manual fixing of mhchem syntax[edit]

  • N Not done Compare the rendering of all equations in the xml dumps using texvc+legacy mhchem to up-to-date mhchem, for those using \ce seems hopeless, just changing legacy=true to legacy=false e.g. <chem>Co3+</chem>:
legacy=false legacy=true
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="\ce{Co3+}"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="normal">C</mi> <mi mathvariant="normal">o</mi> </mrow> <msub> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mpadded width="0"> <mphantom> <mi>X</mi> </mphantom> </mpadded> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mpadded height="0"> <mn>3</mn> </mpadded> </mrow> </mrow> </msub> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mpadded width="0"> <mphantom> <mi>X</mi> </mphantom> </mpadded> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mo>+</mo> </mrow> </msup> </mrow> </math>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="\ce{Co3+}"> <msubsup> <mtext>Co</mtext> <mrow class="MJX-TeXAtom-ORD"> <mn>3</mn> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mo>+</mo> </mrow> </msubsup> </math>
  • Otherwise: Go through all mhchem equations in the xml dumps manually and remove known problems. In progress In progress Full list of mhchem: w:de:Benutzer:Debenben/mhchem
  • If the correct syntax causes an error, just use some other workaround e.g. using math tags which doesn't cause errors during the update and put them in a list to be revisited after the update

Step 1 Part D: Wikidata replacements[edit]

Search the math and chem at Wikidata which doesn't have a recombined XML dump file and doesn't use the same tags(?)

Step 1 Part E: Remove problematic texvc macros from visual formula editor[edit]

see phab:T197842

  • Remove \and and \or from visual formula editor help dialogue and autocompletion for the other problematic commands.Yes Done
  • Add warining categories for mhchem.Yes Done

Step 2[edit]

Wait for a new XML dump and check that most of the problematic syntax is gone.

Step 3[edit]

  • Remove problematic texvcjs modifications in production.
  • Make unescaped $ % and \or macros an error

Step 4[edit]

  • Go through the error categories of all MediaWiki projects to find equations that have slipped through the regression test and cause errors.
  • Revisit the list of mhchem-workarounds where the correct syntax wasn't possible before.

Step 5[edit]

  • Change legacy=true to legacy=false in the config for mhchem.
  • Allow $ with correct behavior for mhchem syntax

Further long term strategic goals[edit]

Discuss and implement other changes like

  • deprecate and remove further non-standard texvc syntax
  • clean up problems with tags (ineffective inline styles, self-closing math tags, ce tags)
  • support unicode based input
  • add (more) semantic macros
  • support referencing (\label, \tag, \eqref...)
  • support wikilinks (\href)
  • create a viable distinction of inline and block formulae
  • rethink <math> <math chem> and <chem> redundancy
  • rethink and update the documentation pages

Syntax changes and tag problems that should be addressed after texvcjs modifications are gone:

Current syntax Suggest replacement comment
‎<ce>...‎</ce> ‎<chem>...‎</chem> The more descriptive tag name should be used task T155125
:‎<math>...‎</math> <math display="block">...</math> Very controversial (task T111712), break well used established convention
:‎<math>...‎</math> <math block>...</math> Also very controversial (task T111712), a shorter syntax as an alternative to display="block"
<math display="inline">...</math> ‎<math>...‎</math> Also very controversial (task T111712) change making the math tags without parameter use \textstyle by default
<math chem>...</math> ‎<math>...‎</math> Don't require an additional parameter for mhchem. Whether mhchem is used or not can be easily deduced from the LaTeX code
{{NumBlk|1=:|2=<math>\begin{align}...\end{align}</math>|3={{EquationRef|1}}}} <math align>...</math> Just an idea: With this synax the align environment would behave like in LaTeX and would not need to be redefined, so it would get numbered automatically and it is ensured that it cannot be used within inline equations.
{{NumBlk|1=:|2=<math>...</math>|3={{EquationRef|2}}}} <math equation>...</math> Just an idea: Same as above for equation environment.
‎<math /> error This does not make sense and should result in an error
<math blabla>...</math> error This also does not make sense and should be an error
<math style="color:red;">...</math> <span style="color:red;"><math>...</math></span> The left example does not work any more and should become an error. Some styles like color should be inherited from the surrounding text.