--- loncom/html/adm/jsMath/plugins/tex2math.js 2006/03/27 19:32:29 1.2
+++ loncom/html/adm/jsMath/plugins/tex2math.js 2006/05/17 22:19:38 1.3
@@ -145,6 +145,7 @@ jsMath.Add(jsMath.tex2math,{
if (!element) {element = jsMath.document.body}
if (typeof(element) == 'string') {element = jsMath.document.getElementById(element)}
while (element) {
+ if (element.className == null) {element.className = ''}
if (element.nodeName == '#text') {
if (!ignore) {element = this.ScanText(element)}
} else if (element.firstChild && element.className != 'math') {
@@ -170,6 +171,7 @@ jsMath.Add(jsMath.tex2math,{
this.pattern.lastIndex = 0;
while (element && element.nodeName == '#text' &&
(match = this.pattern.exec(element.nodeValue))) {
+ this.pattern.match = match;
element = this.ProcessMatch(match[0],match.index,element);
}
if (this.search.matched) {element = this.EncloseMath(element)}
@@ -196,14 +198,16 @@ jsMath.Add(jsMath.tex2math,{
} else {
switch (match) {
case '\\(':
- if (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 != '$' && this.search.end != '$$' &&
+ if (this.search.end == null ||
+ (this.search.end != '$' && this.search.end != '$$') &&
this.processSlashBrackets) {
this.ScanMark('div',element,'\\]');
}
@@ -259,7 +263,7 @@ jsMath.Add(jsMath.tex2math,{
* for the math element, and the end delimiter we want to find.
*/
ScanMark: function (type,element,end) {
- var len = RegExp.$1.length;
+ var len = this.pattern.match[1].length;
this.search = {
type: type, end: end, open: element, olength: len,
pos: this.pattern.lastIndex - len