Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE9 #1

Closed
drlippman opened this issue Mar 5, 2014 · 6 comments
Closed

IE9 #1

drlippman opened this issue Mar 5, 2014 · 6 comments

Comments

@drlippman
Copy link
Contributor

The IE detection line

var isIE = document.createElementNS==null;

should probably be updated, since IE9 does have the createElementNS function, and MathPlayer still works in IE9 (it does not, yet, work in IE10+, and at this point I'm doubtful it will happen)

While feature detection is usually better, in this case it might be safer to just use

var isIE = (navigator.appName.slice(0,9)=="Microsoft");
@drlippman
Copy link
Contributor Author

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">&#xEFE8;</span>');
    } else {
        wh = AMBBoxFor('<span style="font-family: STIXgeneral, serif">&#xEFE8;</span>');
    }
    wh2 = AMBBoxFor('<span style="font-family: serif">&#xEFE8;</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;
        }
}

@dpvc
Copy link

dpvc commented Mar 17, 2014

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.

@drlippman
Copy link
Contributor Author

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.  

@dpvc
Copy link

dpvc commented Mar 17, 2014

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).

@dpvc
Copy link

dpvc commented Mar 17, 2014

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.

@drlippman
Copy link
Contributor Author

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" notifications@github.com
Date:03/17/2014 1:43 PM (GMT-08:00)
To: mathjax/asciimathml asciimathml@noreply.github.com
Cc: David drlippman@yahoo.com
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.

GerHobbelt pushed a commit to GerHobbelt/asciimathml that referenced this issue Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants