jenkins-bot has submitted this change and it was merged. Change subject: (bug 35188) Do not poison the tex formula with markup ......................................................................
(bug 35188) Do not poison the tex formula with markup We move the block/inline styling (aka display vs textstyle) markup into a filter used just before rendering. This way the 'used' formula will not suddenly contain styling information that wasn't part of the original formula. Change-Id: Ie0c308c31d38581e556dc73109879c7a3d365121 --- M modules/MathJax/extensions/wiki2jax.js 1 file changed, 13 insertions(+), 4 deletions(-) Approvals: Physikerwelt: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/MathJax/extensions/wiki2jax.js b/modules/MathJax/extensions/wiki2jax.js index 606ac75..baf6536 100644 --- a/modules/MathJax/extensions/wiki2jax.js +++ b/modules/MathJax/extensions/wiki2jax.js @@ -20,12 +20,23 @@ if (this.config.Augment) {MathJax.Hub.Insert(this,this.config.Augment)} this.previewClass = MathJax.Hub.config.preRemoveClass; + this.setupPrefilter(); this.configured = true; } var that = this; $('span.tex, img.tex', element || document).each(function(i, span) { that.ConvertMath(span); }); + }, + + setupPrefilter: function() { // used to fix a number of common wiki math hacks + MathJax.Hub.Register.StartupHook("TeX Jax Ready", function() { + MathJax.InputJax.TeX.prefilterHooks.Add( function(data) { + data.math = data.math.replace(/^\s*\\scriptstyle(\W)/,"\\textstyle$1").replace(/^\s*\\scriptscriptstyle(\W)/,"\\scriptstyle$1"); + if (data.script.type.match(/(;|\s|\n)mode\s*=\s*display-nobreak(;|\s|\n|$)/) != null) + data.math = "\\displaystyle " + data.math; + }); + }); }, ConvertMath: function (node) { @@ -40,10 +51,8 @@ } tex = tex.replace(/\\iiint([^!]*)!\\!\\!\\!\\!.*\\subset\\!\\supset/g,"\\iiint$1mkern-2.5em\\subset\\!\\supset").replace(/\\iint([^!]*)!\\!\\!\\!\\!\\!\\!\\!\\!\\!\\!(.*)\\subset\\!\\supset/g,"\\iint$1mkern-1.65em$2\\subset\\!\\!\\supset").replace(/\\int\\!\\!\\!(\\!)+\\int\\!\\!\\!(\\!)+\\int([^!]*)!\\!\\!\\!\\!.*\\bigcirc(\\,)*/g,"\\iiint$3mkern-2.5em\\subset\\!\\supset").replace(/\\int\\!\\!\\!(\\!)+\\int([^!]*)!\\!\\!\\!\\!\\!\\!\\!\\!(.*)\\bigcirc(\\,)*/g,"\\iint$2mkern-1.65em$3\\subset\\!\\!\\supset"); - if (mode === "") { - tex = tex.replace(/ *\\scriptstyle(\W)/g,"\\textstyle$1").replace(/ *\\scriptscriptstyle(\W)/g,"\\scriptstyle$1"); - if (parent.firstChild === node) tex = "\\displaystyle "+tex; - } + + if (mode === "" && parent.firstChild === node) mode = "; mode=display-nobreak"; var script = document.createElement("script"); script.type = "math/tex" + mode; -- To view, visit https://gerrit.wikimedia.org/r/23079 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie0c308c31d38581e556dc73109879c7a3d365121 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Cjucovschi <jucovs...@gmail.com> Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de> Gerrit-Reviewer: Ross Andrews <ross.andr...@gmail.com> Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits