From 593a393bfc6d551c0e659c2d230d995136c49210 Mon Sep 17 00:00:00 2001 From: Peter Krautzberger Date: Fri, 4 Sep 2015 10:21:34 +0200 Subject: [PATCH 1/6] Improve RTL support in HTML-CSS Add CSS to prevent browser interference --- unpacked/extensions/MathML/mml3.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unpacked/extensions/MathML/mml3.js b/unpacked/extensions/MathML/mml3.js index 575953eea..e3a4eb3e1 100644 --- a/unpacked/extensions/MathML/mml3.js +++ b/unpacked/extensions/MathML/mml3.js @@ -121,6 +121,9 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { // No XSLT support. Do not change the content. MATHML.mml3XSLT = null; } + + // Tweak CSS to avoid some browsers rearranging HTML output + MathJax.Ajax.Styles(".MathJax span { direction: ltr !important; display: inline-block !important;}"); MathJax.Hub.Startup.signal.Post("MathML mml3.js Ready"); }); From 98a8deecf6228b8fb7c5ed4c0aba402756bc6a3d Mon Sep 17 00:00:00 2001 From: Peter Krautzberger Date: Wed, 9 Sep 2015 11:40:23 +0200 Subject: [PATCH 2/6] Update MathJax.js: add UA detection for MS Edge Cf. https://msdn.microsoft.com/en-us/library/hh869301.aspx --- unpacked/MathJax.js | 1 + 1 file changed, 1 insertion(+) diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 30ce40297..a8b6dbeb3 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -3090,6 +3090,7 @@ MathJax.Hub.Startup = { isMac: (navigator.platform.substr(0,3) === "Mac"), isPC: (navigator.platform.substr(0,3) === "Win"), isMSIE: ("ActiveXObject" in window && "clipboardData" in window), + isMsEdge: (!!AGENT.match(/Edge\//)), isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)), isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) && (!window.chrome || window.chrome.loadTimes == null)), From 2c79bd40909162b08672f735636b53017301d852 Mon Sep 17 00:00:00 2001 From: Peter Krautzberger Date: Wed, 9 Sep 2015 11:45:59 +0200 Subject: [PATCH 3/6] Update mml3.js Fixes #1252. * Add workaround for MS Edge bug. * Prettify xslt string. --- unpacked/extensions/MathML/mml3.js | 652 ++++++++++++++++++++++++++++- 1 file changed, 648 insertions(+), 4 deletions(-) diff --git a/unpacked/extensions/MathML/mml3.js b/unpacked/extensions/MathML/mml3.js index e3a4eb3e1..78678cd3d 100644 --- a/unpacked/extensions/MathML/mml3.js +++ b/unpacked/extensions/MathML/mml3.js @@ -72,17 +72,661 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { }); /* - * The following is taken from mml3mj.xsl - * (https://web-xslt.googlecode.com/svn/trunk/ctop/mml3mj.xsl) + * The following is derived from mml3mj.xsl + * (https://github.com/davidcarlisle/web-xslt/blob/master/ctop/mml3mj.xsl) * which is Copyright (c) David Carlisle 2008-2015. * It is used by permission of David Carlisle, who has agreed to allow it to * be released under the Apache License, Version 2.0. */ - var mml3Stylesheet = ' this[\'node-set\'] = function (x) { return x; })(][}{)(][}{\)(}{><top right 0decimalpoint decimalpoint.decimalpoint*0.1em0.15em0.2em0.15em0)(/\\:=top)'; + var BROWSER = MathJax.Hub.Browser; + var exslt = ''; + if (BROWSER.isMsEdge) { + exslt = 'urn:schemas-microsoft-com:xslt' + } else { + exslt = 'http://exslt.org/common'; + } + var mml3Stylesheet = + '' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + '' + + ' ' + + ' ltr' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + '' + + ' )' + + '' + + ' (' + + '' + + '' + + ' ]' + + '' + + '' + + ' [' + + '' + + '' + + ' }' + + '' + + '' + + ' {' + + '' + + '' + + ' ' + + '' + + ' )' + + '' + + ' (' + + '' + + '' + + ' ]' + + '' + + '' + + ' [' + + '' + + '' + + ' }' + + '' + + '' + + ' {' + + '' + + ' ' + + ' ' + + ' \' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ')' + + '(' + + '}' + + '{' + + '>' + + '<' + + '' + + '' + + '' + + ' top right' + + '' + + '' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' decimalpoint' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' decimalpoint' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' .' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' decimalpoint' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' *' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.1em' + + ' 0.15em' + + ' 0.2em' + + ' ' + + ' 0.15em' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' )' + + ' ' + + ' (' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' /' + + ' ' + + ' \' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' :' + + ' ' + + ' =' + + ' ' + + ' ' + + ' ' + + ' ' + + ' top' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' )' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ''; + /* * End of mml3mj.xsl material. */ - + var mml3; if (window.XSLTProcessor) { // standard method: just use an XSLTProcessor and parse the stylesheet From bbdbe19eda28f709c1afc9c41813598e933a7d53 Mon Sep 17 00:00:00 2001 From: Peter Krautzberger Date: Wed, 9 Sep 2015 17:33:59 +0200 Subject: [PATCH 4/6] update mml3.js Extend Microsoft Edge workaround to Internet Explorer. --- unpacked/extensions/MathML/mml3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/extensions/MathML/mml3.js b/unpacked/extensions/MathML/mml3.js index 78678cd3d..f14e3bff9 100644 --- a/unpacked/extensions/MathML/mml3.js +++ b/unpacked/extensions/MathML/mml3.js @@ -80,7 +80,7 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { */ var BROWSER = MathJax.Hub.Browser; var exslt = ''; - if (BROWSER.isMsEdge) { + if (BROWSER.isMsEdge || BROWSER.isMSIE) { exslt = 'urn:schemas-microsoft-com:xslt' } else { exslt = 'http://exslt.org/common'; From e172b049280b268680fa21b32c6384965f0d67b4 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 12 Sep 2015 13:23:29 -0400 Subject: [PATCH 5/6] Use less-aggressive CSS for ltr and inline-block, and do Edge check within the extension. --- unpacked/MathJax.js | 1 - unpacked/extensions/MathML/mml3.js | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index a8b6dbeb3..30ce40297 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -3090,7 +3090,6 @@ MathJax.Hub.Startup = { isMac: (navigator.platform.substr(0,3) === "Mac"), isPC: (navigator.platform.substr(0,3) === "Win"), isMSIE: ("ActiveXObject" in window && "clipboardData" in window), - isMsEdge: (!!AGENT.match(/Edge\//)), isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)), isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) && (!window.chrome || window.chrome.loadTimes == null)), diff --git a/unpacked/extensions/MathML/mml3.js b/unpacked/extensions/MathML/mml3.js index f14e3bff9..27eac324e 100644 --- a/unpacked/extensions/MathML/mml3.js +++ b/unpacked/extensions/MathML/mml3.js @@ -80,7 +80,7 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { */ var BROWSER = MathJax.Hub.Browser; var exslt = ''; - if (BROWSER.isMsEdge || BROWSER.isMSIE) { + if (!!navigator.userAgent.match(/ Edge\//) || BROWSER.isMSIE) { exslt = 'urn:schemas-microsoft-com:xslt' } else { exslt = 'http://exslt.org/common'; @@ -767,7 +767,16 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { } // Tweak CSS to avoid some browsers rearranging HTML output - MathJax.Ajax.Styles(".MathJax span { direction: ltr !important; display: inline-block !important;}"); + MathJax.Ajax.Styles({ + ".MathJax .mi, .MathJax .mo, .MathJax .mn, .MathJax .mtext": { + direction: "ltr", + display: "inline-block" + }, + ".MathJax .ms, .MathJax .mspace, .MathJax .mglyph": { + direction: "ltr", + display: "inline-block" + } + }); MathJax.Hub.Startup.signal.Post("MathML mml3.js Ready"); }); From 00af8c161ef8cad47c919691e499e30779c176a9 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 14 Sep 2015 06:57:01 -0400 Subject: [PATCH 6/6] Use isEdge for MSEdge detection --- unpacked/extensions/MathML/mml3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/extensions/MathML/mml3.js b/unpacked/extensions/MathML/mml3.js index 27eac324e..90a98f59b 100644 --- a/unpacked/extensions/MathML/mml3.js +++ b/unpacked/extensions/MathML/mml3.js @@ -80,7 +80,7 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { */ var BROWSER = MathJax.Hub.Browser; var exslt = ''; - if (!!navigator.userAgent.match(/ Edge\//) || BROWSER.isMSIE) { + if (BROWSER.isEdge || BROWSER.isMSIE) { exslt = 'urn:schemas-microsoft-com:xslt' } else { exslt = 'http://exslt.org/common';