Index: jsmath/web/plugins/tex2math.js =================================================================== RCS file: /usr/local/cvsroot/jsmath/web/plugins/tex2math.js,v diff -u -r1.1 -r1.2 --- jsmath/web/plugins/tex2math.js 11 Sep 2006 05:42:07 -0000 1.1 +++ jsmath/web/plugins/tex2math.js 22 Jun 2007 07:31:21 -0000 1.2 @@ -200,17 +200,17 @@ } else { switch (match) { case '\\(': - if (this.search.end == null || - (this.search.end != '$' && this.search.end != '$$') && + if ((this.search.end == null || + (this.search.end != '$' && this.search.end != '$$')) && this.processSlashParens) { this.ScanMark('span',element,'\\)'); } break; case '\\[': - if (this.search.end == null || - (this.search.end != '$' && this.search.end != '$$') && - this.processSlashBrackets) { + if ((this.search.end == null || + (this.search.end != '$' && this.search.end != '$$')) && + this.processSlashBrackets) { this.ScanMark('div',element,'\\]'); } break; @@ -232,6 +232,7 @@ if (this.search.end == null && this.fixEscapedDollars) { element.nodeValue = element.nodeValue.substr(0,index) + element.nodeValue.substr(index+1); + this.pattern.lastIndex--; } break; } @@ -249,7 +250,9 @@ this.search.close = element; this.search.clength = match.length; this.search.cpos = this.pattern.lastIndex; - this.search.matched = 1; + if (match == this.inLineOpen || match == this.displayOpen) { + element = this.EncloseMath(element); + } else {this.search.matched = 1} } else if (match == this.inLineOpen) { if (this.search.matched) {element = this.EncloseMath(element)} this.ScanMark('span',element,this.inLineClose); @@ -279,8 +282,7 @@ * SPAN or DIV element marked as CLASS="math". */ EncloseMath: function (element) { - if (this.callback) {if (!this.callback()) {return null}} - var search = this.search; + var search = this.search; search.end = null; var close = search.close; if (search.cpos == close.length) {close = close.nextSibling} else {close = close.splitText(search.cpos)} @@ -337,14 +339,8 @@ tag.className = "math"; text = text.replace(//g,'>'); if (type == 'div') { - tag.className = ""; - tag.style.width = "100%"; tag.style.margin = jsMath.tex2math.margin; - tag.style.display = "inline-block"; + tag.className = "tex2math_div"; text = '\\displaystyle{'+text+'}'; - if (jsMath.tex2math.center) { - tag.style.textAlign = "center"; - text = ''+text+'' - } } tag.innerHTML = text; return tag; @@ -353,28 +349,20 @@ /*******************************************************************/ Init: function () { - - if (this.inited || !jsMath.browser) return + if (!jsMath.browser && document.all && !window.opera) { + jsMath.browser = 'MSIE'; + jsMath.platform = (navigator.platform.match(/Mac/) ? "mac" : + navigator.platform.match(/Win/) ? "pc" : "unix"); + } + if (this.inited || !jsMath.browser) return; /* * MSIE can't handle the DIV's properly, so we need to do it by * hand. Look up the style for typeset math to see if the user * has changed it, and get whether it is centered or indented * so we can mirror that using a SPAN */ - if (jsMath.browser == 'MSIE' && navigator.platform == 'Win32') { - this.createMathTag = this.MSIEcreateMathTag; - this.margin = ""; this.center = 0; - for (var i = 0; i < jsMath.document.styleSheets.length; i++) { - var rules = jsMath.document.styleSheets[i].cssRules; - if (!rules) {rules = jsMath.document.styleSheets[i].rules} - for (var j = 0; j < rules.length; j++) { - if (rules[j].selectorText.toLowerCase() == 'div.typeset') { - if (rules[j].style.margin != "") {this.margin = rules[j].style.margin} - this.center = (rules[j].style.textAlign == 'center'); - } - } - } - } + if (jsMath.browser == 'MSIE' && jsMath.platform == 'pc') + {this.createMathTag = this.MSIEcreateMathTag} this.inited = 1; },