# mathjax/MathJax

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.

# MathJax can't find its script tag in XHTML if XHTML tags use an explicit prefix #1016

Closed
opened this issue Jan 22, 2015 · 10 comments

Projects
None yet
3 participants

### sdh4 commented Jan 22, 2015

 If I create an xhtml page that uses explicit prefixes on the html tags, MathJax's code for finding its 
Member

### pkra commented Jan 22, 2015

 I cannot reproduce this. Are you serving the xhtml file with the correct mimetype?

Member

### dpvc commented Jan 22, 2015

 I can reproduce it (on a local document with extension .xhtml) in Firefox, though it works as expected in Safari and Chrome. I haven't tried IE. Yes, having namespaces on those element can be problematic. It's not actually the script tags that are the problem (since these are created without namespaces by the tex2jax preprocessor, and so will be found by getElementsByTagName()), it is the document head that is the problem (MathJax isn't even getting to the place where it looks for the script tags). I guess MathJax could use document.head when available and look it up otherwise (conveniently, document.head is set in Firefox even with the namespaces).
Member

### dpvc commented Jan 22, 2015

 OK, I see, finding its own script tag is what you mean. Yes, that is also a problem. I'll think about that further.

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Jan 22, 2015

 Use document.head when available, and look up scripts via namespace i… 
…f not found without it. Resolves issue mathjax#1016.
 2376351 
Member

### dpvc commented Jan 22, 2015

 The issue1016 branch of my fork of MathJax includes the work-arounds that I suggest above.

Author

### sdh4 commented Jan 22, 2015

 This is not quite yet solving it for me, at least not on files served through the web server. My server, or the various transformations therein, put a  at the top of the document. So when document.getElementsByTagName("head")[0] on line 3041 gives a null, the fall-through creates HEAD from document.childNodes[0]. Unfortunately, document.childNodes[0] is the , not the actual HEAD tag or any other meaningful tag, so namespaceURI is null and the problem is not solved. Possible fixes: hardwire the namespaceuri to the xhtml namespace "http://www.w3.org/1999/xhtml", and/or Use the routine from line 644 to find the head

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Jan 22, 2015

 Handle head properly in another location when looking for script tags… 
…. Issue mathjax#1016.
 6465686 
Member

### dpvc commented Jan 22, 2015

 Oops, I thought I had caught them all. See if the change I just made to the issue1016 branch takes care of it for you.
Author

### sdh4 commented Jan 22, 2015

 Yes, it does. Works great! Thanks for the quick responses!
Member

### dpvc commented Jan 22, 2015

 Glad it worked. Thanks for helping diagnose the problem, and checking the fixes. I'll merge into the v2.5 candidate soon.

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Jan 24, 2015

 Merge branch 'issue1016' into develop. Issue mathjax#1016. 
 20e1e01 `
Member

### dpvc commented Jan 24, 2015

 ==> Merged.

Member

### dpvc commented Jan 24, 2015

 It turns out the test suite can't be used to test this issue, due to the way that MathJax is injected into the page.

### dpvc added Fixed v2.5 and removed Merged labels Jan 30, 2015

to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.