Last modified: 2014-10-11 16:37:38 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T73748, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 71748 - Display MathML when MathPlayer is installed
Display MathML when MathPlayer is installed
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Math (Other open bugs)
master
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 65341 71912
  Show dependency treegraph
 
Reported: 2014-10-07 16:56 UTC by Frédéric Wang
Modified: 2014-10-11 16:37 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Frédéric Wang 2014-10-07 16:56:20 UTC
Currently, we use CSS hacks to choose between MathML or SVG/PNG. We will need to load an additional Javascript file after page load to show the MathML when MathPlayer is detected (using the user agent string).
Comment 1 physikerwelt 2014-10-07 17:13:28 UTC
Is there a sample HTML page that detects MathPlayer via JavaScript?
Comment 2 Frédéric Wang 2014-10-07 17:18:20 UTC
Searching MathPlayer in the user agent string should be enough to detect MathPlayer:

https://github.com/brucemiller/LaTeXML/blob/master/lib/LaTeXML/resources/javascript/LaTeXML-maybeMathjax.js#L12

There are also other hacks to force MathPlayer to load (see the MathJax source). Since we are immediately putting MathML in the page source, that should not be necessary, I guess.
Comment 3 physikerwelt 2014-10-07 17:21:29 UTC
A great. Maybe we should provide a standalone JavaScript function hasMathML support that can be used by different projects... What do you think?
Comment 4 Frédéric Wang 2014-10-07 17:28:08 UTC
Unfortunately, this kind of things is not always reliable (for example recent version of IE claims to be "Gecko" and Opera dropped MathML and switched from "Presto" to "Blink"). Moreover this depends on what you mean by "MathML is supported"

See https://developer.mozilla.org/en-US/docs/Web/MathML/Authoring#Fallback_for_Browsers_without_MathML_support for some suggestions.

However, if "MathPlayer" is in the user agent string then there is a strong probability that MathPlayer is installed and so that the user wants MathML to be displayed. So that sounds fine to just check the user agent string in that particular case.
Comment 5 physikerwelt 2014-10-07 18:07:50 UTC
What do you think is the problem with this approach:
  function hasMathMLSupport() {
  var div = document.createElement("div"), box;
  div.innerHTML = "<math><mspace height='23px' width='77px'/></math>";
  document.body.appendChild(div);
  box = div.firstChild.firstChild.getBoundingClientRect();
  document.body.removeChild(div);
  return Math.abs(box.height - 23) <= 1  && Math.abs(box.width - 77) <= 1;
  }

Independent of the actual implementation of hasMathMLSupport() I think we should create such a function that can be updated depending on the latests changes in the browser jungle.
Comment 6 Frédéric Wang 2014-10-07 18:12:14 UTC
Strictly speaking, this only detects whether the height/width attributes of <mspace/> are supported (which does not necessarily mean that the support is "good enough", whatever it means). I'm not sure it works with MathPlayer, but we can always do the UA sniffing in the MathPlayer case.
Comment 7 Frédéric Wang 2014-10-07 18:16:03 UTC
Also this requires a DOM to be used and might be affected by the surrounding context, might be too strict (only 1px error is tolerated) or not enough (there is not 100% guarantee that a browser will not give the right size. For example I notice that IE boxes for unknown elements sometimes have non-zero size)
Comment 8 Gerrit Notification Bot 2014-10-10 10:42:07 UTC
Change 165997 had a related patch set uploaded by Frédéric Wang:
Display MathML when MathPlayer is installed

https://gerrit.wikimedia.org/r/165997
Comment 9 Gerrit Notification Bot 2014-10-10 18:25:03 UTC
Change 165997 merged by jenkins-bot:
Display MathML when MathPlayer is installed

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links