Index: trunk/extensions/Math/modules/MathJax-custom/extensions/TeX/texvc.js |
— | — | @@ -23,27 +23,23 @@ |
24 | 24 | this.previewClass = MathJax.Hub.config.preRemoveClass; |
25 | 25 | this.configured = true; |
26 | 26 | } |
27 | | - var span, i; |
28 | | - if ((!element || element == document.body) && mathJax.span) { // dirty hack |
29 | | - span = mathJax.span; |
30 | | - i = mathJax.spanIndex; |
31 | | - } |
32 | | - else { |
33 | | - if (typeof(element) === "string") {element = document.getElementById(element)} |
34 | | - if (!element) {element = this.config.element || document.body} |
35 | | - span = element.getElementsByTagName("span"); |
36 | | - i = span.length-1; |
37 | | - } |
38 | | - for (; i >= 0; i--) |
39 | | - if (span[i].className === "tex") this.ConvertMath(span[i]) |
| 27 | + var that = this; |
| 28 | + $('span.tex, img.tex', element || document).each(function(i, span) { |
| 29 | + that.ConvertMath(span); |
| 30 | + }); |
40 | 31 | }, |
41 | 32 | |
42 | 33 | ConvertMath: function (node) { |
43 | 34 | var parent = node.parentNode, |
44 | 35 | mode = parent.tagName === "DD" && parent.firstChild === parent.lastChild ? "; mode=display" : "", |
| 36 | + tex; |
| 37 | + if (node.nodeName == 'IMG') { |
| 38 | + tex = node.alt; |
| 39 | + } else { |
45 | 40 | tex = node.innerHTML.substring(node.innerHTML[0]=='$',node.innerHTML.length-(node.innerHTML[node.innerHTML.length-1]=='$')); |
| 41 | + tex = tex.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/ /g," "); |
| 42 | + } |
46 | 43 | |
47 | | - tex = tex.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/ /g," "); |
48 | 44 | tex = tex.replace(/\\iiint([^!]*)!\\!\\!\\!\\!.*\\subset\\!\\supset/g,"\\iiint$1mkern-2.5em\\subset\\!\\supset").replace(/\\iint([^!]*)!\\!\\!\\!\\!\\!\\!\\!\\!\\!\\!(.*)\\subset\\!\\supset/g,"\\iint$1mkern-1.65em$2\\subset\\!\\!\\supset").replace(/\\int\\!\\!\\!(\\!)+\\int\\!\\!\\!(\\!)+\\int([^!]*)!\\!\\!\\!\\!.*\\bigcirc(\\,)*/g,"\\iiint$3mkern-2.5em\\subset\\!\\supset").replace(/\\int\\!\\!\\!(\\!)+\\int([^!]*)!\\!\\!\\!\\!\\!\\!\\!\\!(.*)\\bigcirc(\\,)*/g,"\\iint$2mkern-1.65em$3\\subset\\!\\!\\supset"); |
49 | 45 | if (mode === "") { |
50 | 46 | tex = tex.replace(/ *\\scriptstyle(\W)/g,"\\textstyle$1").replace(/ *\\scriptscriptstyle(\W)/g,"\\scriptstyle$1"); |
Index: trunk/extensions/Math/modules/ext.math.mathjax.enabler.js |
— | — | @@ -44,26 +44,18 @@ |
45 | 45 | if (this.loaded) |
46 | 46 | return true; |
47 | 47 | |
48 | | - var span = element.getElementsByTagName("span"), i; |
49 | | - for (i = span.length-1; i >= 0; i--) { |
50 | | - if (span[i].className === "tex") { |
51 | | -// this.span = span; |
52 | | -// this.spanIndex = i; |
| 48 | + // create configuration element |
| 49 | + var config = 'mathJax.Config();'; |
| 50 | + var script = document.createElement( 'script' ); |
| 51 | + script.setAttribute( 'type', 'text/x-mathjax-config' ); |
| 52 | + if ( window.opera ) script.innerHTML = config; else script.text = config; |
| 53 | + document.getElementsByTagName('head')[0].appendChild( script ); |
53 | 54 | |
54 | | - // create configuration element |
55 | | - var config = 'mathJax.Config();'; |
56 | | - var script = document.createElement( 'script' ); |
57 | | - script.setAttribute( 'type', 'text/x-mathjax-config' ); |
58 | | - if ( window.opera ) script.innerHTML = config; else script.text = config; |
59 | | - document.getElementsByTagName('head')[0].appendChild( script ); |
| 55 | + // create startup element |
| 56 | + mediaWiki.loader.load('ext.math.mathjax'); |
60 | 57 | |
61 | | - // create startup element |
62 | | - mediaWiki.loader.load('ext.math.mathjax'); |
| 58 | + this.loaded = true; |
63 | 59 | |
64 | | - this.loaded = true; |
65 | | - break; |
66 | | - } |
67 | | - } |
68 | 60 | return false; |
69 | 61 | } |
70 | 62 | |