Comments (6)
While we're at it, in checkMathML, we might want to update the detection in checkMathML(). Here is a super-nasty version that also includes basic font detection to make sure FireFox has adequate fonts to display radicals and other stretchy symbols:
var isGecko = 0;
function init(){
var msg, warnings = new Array();
if (document.getElementById==null){
alert("This webpage requires a recent browser such as Mozilla Firefox");
return null;
}
if (checkForMathML && (msg = checkMathML())) warnings.push(msg);
if (checkForMathML && isGecko>0 && (msg = AMcheckTeX())) warnings.push(msg);
if (warnings.length>0) displayWarnings(warnings);
if (!noMathML) initSymbols();
return true;
}
function checkMathML(){
if (navigator.product && navigator.product=='Gecko' && !navigator.userAgent.toLowerCase().match(/webkit/)) {
var rv = navigator.userAgent.toLowerCase().match(/rv:\s*([\d\.]+)/);
if (rv!=null) {
rv = rv[1].split('.');
if (rv.length<3) { rv[2] = 0;}
if (rv.length<2) { rv[1] = 0;}
}
if (rv!=null && 10000*rv[0]+100*rv[1]+1*rv[2]>=10100) {
isGecko = 10000*rv[0]+100*rv[1]+1*rv[2];
noMathML = null;
} else {
noMathML = true;
}
}
else if (navigator.appName.slice(0,9)=="Microsoft") {
version = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (version >= 10) {
noMathML = true;
} else {
try {
var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
noMathML = null;
} catch (e) {
noMathML = true;
}
}
} else noMathML = true;
if (noMathML && notifyIfNoMathML) {
var msg = "To view the ASCIIMathML notation use Internet Explorer + MathPlayer or Mozilla Firefox 2.0 or later.";
if (alertIfNoMathML)
alert(msg);
else return msg;
}
}
function AMBBoxFor(s) {
document.getElementById("hidden").innerHTML =
'<nobr><span class="typeset"><span class="scale">'+s+'</span></span></nobr>';
var bbox = {w: document.getElementById("hidden").offsetWidth, h: document.getElementById("hidden").offsetHeight};
document.getElementById("hidden").innerHTML = '';
return bbox;
}
//check for TeX font based on approach from jsMath
function AMcheckTeX() {
hiddendiv = document.createElement("div");
hiddendiv.style.visibility = "hidden";
hiddendiv.id = "hidden";
document.body.appendChild(hiddendiv);
if (isGecko<10900) { //Mozilla 1.8 could use cmex fonts; Mozilla 1.9 only works well with STIX
wh = AMBBoxFor('<span style="font-family: STIXgeneral, cmex10, serif"></span>');
} else {
wh = AMBBoxFor('<span style="font-family: STIXgeneral, serif"></span>');
}
wh2 = AMBBoxFor('<span style="font-family: serif"></span>');
nofonts = (wh.w==wh2.w && wh.h==wh2.h);
if (nofonts) {
noMathML = true;
} else {
noMathML = false;
}
if (noMathML && notifyIfNoMathML) {
var msg = "To view the ASCIIMathML notation, install STIX fonts, available at stixfonts.org";
if (alertIfNoMathML)
alert(msg);
else return msg;
}
}
from asciimathml.
Note that Firefox can use fonts other than STIXGeneral and cmex10 for stretchy characters, so you might be limiting your users unnecessarily.
Also, you might want to use an ID for your hidden element that includes something unique to AsciiMath, so that it doesn't conflict with other potential ID's in the page. For example "AM_hidden" or "AsciiMath_hidden". Just "hidden" is too generic, and the page might already include an element with that ID.
from asciimathml.
Will make the ID change.
Do you have a suggestion for the font issue? The main goal was to avoid issues where the square roots weren't extending over expressions properly due to font issues. In my case, where I fall back to mimetex images, some false negatives on the MathML check isn't a huge deal. Clearly the better solution is to use MathJax, but if anyone is going to use AsciiMath standalone, I'd like it work correctly.
from asciimathml.
You might be able to check whether a stretchy element has actually stretched. For example, you might be able to use
<math>
<mo stretchy="true" id="AM_test_paren">(</mo>
<mpadded height="200%" id="AM_test_padded">
<mo stretchy="false">(</mo>
</mpadded>
</math>
has the AM_test_paren
element of height greater than that of AM_test_padded
. I'm not sure if this works or not, but it might be worth a try, as it makes no assumptions about the fonts used by Firefox (which have changed over time).
from asciimathml.
OK, it looks like Firefox doesn't stretch to fit the <mpadded>
element as it should. So you can compare the scrollHeights
of AM_test_paren1
and AM_test_paren2
to see if the first is larger than the second in
<math displaystyle="true">
<mo stretchy="true" id="AM_test_paren1">(</mo>
<mfrac><mo id="AM_test_paren2">(</mo><mo>)</mo></mfrac>
</math>
See if that works.
from asciimathml.
I'll give it a try. In the meantime, since stix and the tex fonts have been the official recommended fonts for MathML by Firefox, I don't feel too bad limiting the check to those two.
-------- Original message --------
From: "Davide P. Cervone" [email protected]
Date:03/17/2014 1:43 PM (GMT-08:00)
To: mathjax/asciimathml [email protected]
Cc: David [email protected]
Subject: Re: [asciimathml] IE9 (#1)
OK, it looks like Firefox doesn't stretch to fit the element as it should. So you can compare the scrollHeights of AM_test_paren1 and AM_test_paren2 to see if the first is larger than the second in
( ()See if that works.
—
Reply to this email directly or view it on GitHub.
from asciimathml.
Related Issues (20)
- Inconsistent whitespace sensitivity with numbers HOT 3
- Test environment 'collapses' multiple kinds of whitespace into one HOT 1
- Support more geometry symbols HOT 1
- Support physical units HOT 2
- Vec() crashes updater HOT 1
- An exception occurs when using parseMath!The attribute "mathvariant" is incorrect! HOT 1
- TextMate grammar
- Add ≢ HOT 2
- Support for \mathscr.
- Formal grammar is incomplete
- Add support for ⊈
- support for mathjax 3 HOT 1
- Make comma `,` escapable without making it a text `","` HOT 2
- Please add `∼` (tilde operator) and `≁` (not tilde) HOT 2
- Thousands separator not documented HOT 2
- AsciiMath render intermittently not triggering in dropdown menu on iOS Safari HOT 1
- MathML-Core support shipped by default in chromium 109 HOT 2
- Convert asciimath JavaScript output to PDF
- Fraction bars aren't rendered as text HOT 2
- hyperlinks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciimathml.