Author: richardbrucebaxter
Description:
I propose that mediawiki is upgraded to generate MathML and automatically embed hyperlinks for each mathematical symbol/operator. Note it was suggested I open this bugzilla report by a developer on the mediawiki IRC dev channel after showing them my initial request on the meta wiki (http://meta.wikimedia.org/w/index.php?title=Help_talk:Displaying_a_formula#Mediawiki_math_markup_interpretation_upgrade:_generate_MathML_.28not_PNG.29_and_automatically_embed_hyperlinks_for_each_symbol).
The following is an example of proposed wiki math code
<math>A[[simple equation#area]] = \pi r[[simple equation#radius]]^2 q[[some constant]] \cos(z)</math>
- Latex math [[wiki link]] tags are removed by the Math extension preprocessor
- MathML is generated by latexml
- user defined hyperlinks are readded to the generated MathML by the Math extension postprocessor
- hyperlinks are automatically added to all remaining mathematical operators/symbols by the Math extension postprocessor (which reside in its database of existing math symbols/operators; e.g. plain text file)
Relevant wiki hyperlinks are automatically generated for all standard mathematical symbols and operators eg " ", "=", "squared", "cos". If the user for example clicks on the hyperlink to z (which has not been explicitly defined by the user and does not reside in the Math extension database of mathematical symbols), the wiki (e.g. Wikipedia) returns "Variable is undefined, would you like to define it by editing this page?"
Note Firefox's MathML implementation (I am unsure about MathJax) requires either all math objects to be explicitly hyperlinked or none. The reason for this is that when hyperlinks are auto generated for math "sections" (eg square root, division), all the child objects in the section are by default linked to the section hyperlink (e.g. "b^2-4ac" in "\sqrt{b^2-4ac\ }"). This will be confusing for the user, so it is better that all math objects be explicitly hyperlinked, even if they must be directed to a new/edit page.
Although I am not a web programmer, I am happy to implement this myself in php if necessary. I must however report an issue in the existing mediawiki Math extension software that affects the latexml MathML option (it appears to be related to https://gerrit.wikimedia.org/r/#/c/135521). The only way I have been able to get the latexml MathML option working in the current version of the mediawiki Math extension (e.g. 11 August 2014) or the last stable version of the mediawiki Math extension (1.23.2) is to;
- first delete the mysql wiki database (drop database <db_name>;)
- then install mediawiki 1.22.9 (legacy) along with its corresponding version of the mediawiki Math extension (1.22.9).
a. ensure to tick "enable image uploads" (to prevent a bug that stops the default PNG generated formulae from being displayed)
b. create Math extension temporary folders
cd /var/www/html/mediawiki-xxx/images
mkdir math
mkdir tmp
sudo chown -R www-data:www-data *
c. run maintenance/update.php (to prevent a bug "A database query error has occurred. This may indicate a bug in the software")
d. install LaTeXML (http://www.formulasearchengine.com/node/3)
e. test that MathML is working; set $wgUseLaTeXML = true; $wgUseMathJax = true; $wgDefaultUserOptions['math'] = MW_MATH_LATEXML; in LocalSettings.php
- then install the current version of mediawiki (mediawiki-latest.tar.gz/11 August 2014 or mediawiki 1.23.2) along with its corresponding version of the mediawiki Math extension (Math.zip/11 August 2014 or 1.23.2).
I have attached a complete installation log for reference (mediaWikiMathExtensionMathMLinstallationLog-11August2014.txt). It would however be useful if someone could publish a formal workaround for this issue (for at least 1.23.2 stable); for example a .sql file containing the required mysql table updates.
I have also attached the mathML code of what I expect a final equation to look like on Wikipedia after the latex is preprocessed, rendered, and postprocessed (mathMLtestQuadraticEquation.html).
Thanks for your help.
Richard
mathMLtestQuadraticEquation.html
<!-- 1. original latex code -->
<!-- <math>x=\frac{-b\pm\sqrt{b^2-4ac\ }}{2a}.</math> -->
<!-- 2. proposed wikpedia latex code -->
<!-- <math>x=\frac{-b[[quadratic equation#linear coefficient]]\pm\sqrt{b^2-4a[[quadratic equation#quadratic coefficient]]c[[quadratic equation#constant]]\ }}{2a}.</math> -->
<!-- 3. proposed final wikpedia MathML output -->
<math>
<mrow>
<mi href="en.wikipedia.org/wiki/quadratic_equation#quadratic_root">x</mi>
<mo href="en.wikipedia.org/wiki/Equals_sign">=</mo>
<mfrac href="en.wikipedia.org/wiki/fraction">
<mrow>
<mo>−</mo>
<mi href="b" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/quadratic_equation#linear_coefficient">b</mi>
<mo href="±" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/Plus-minus_sign">±</mo>
<msqrt href="" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/Square_root">
<mrow>
<msup>
<mi href="b" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/quadratic_equation#linear_coefficient">b</mi>
<mn href="2" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/Square_number">2</mn>
</msup>
<mo href="−" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/Subtraction">−</mo>
<mn href="4" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/number">4</mn>
<mi href="a" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/quadratic_equation#quadratic_coefficient">a</mi>
<mi href="c" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/quadratic_equation#constant">c</mi>
</mrow>
</msqrt>
</mrow>
<mrow>
<mn href="2" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/number">2</mn>
<mi href="a" class="remarkup-link" target="_blank" rel="noreferrer">https://en.wikipedia.org/wiki/quadratic_equation#quadratic_coefficient">a</mi>
</mrow>
</mfrac>
</mrow>
</math>
Version: master
Severity: enhancement