@@ -53,12 +53,11 @@ MathJax.Extension.mml2jax = {
53
53
//
54
54
// Handle all math tags with no namespaces
55
55
//
56
- mathArray . push . apply ( mathArray , element . getElementsByTagName ( "math" ) ) ;
56
+ this . PushMathElements ( mathArray , element , "math" ) ;
57
57
//
58
58
// Handle math with namespaces in XHTML
59
59
//
60
- if ( element . getElementsByTagNameNS )
61
- { mathArray . push . apply ( mathArray , element . getElementsByTagNameNS ( this . MMLnamespace , "math" ) ) }
60
+ this . PushMathElements ( mathArray , element , "math" , this . MMLnamespace ) ;
62
61
//
63
62
// Handle math with namespaces in HTML
64
63
//
@@ -71,7 +70,7 @@ MathJax.Extension.mml2jax = {
71
70
for ( i = 0 , m = document . namespaces . length ; i < m ; i ++ ) {
72
71
var ns = document . namespaces [ i ] ;
73
72
if ( ns . urn === this . MMLnamespace )
74
- { mathArray . push . apply ( mathArray , element . getElementsByTagName ( ns . name + ":math" ) ) }
73
+ { this . PushMathElements ( mathArray , element , ns . name + ":math" ) }
75
74
}
76
75
} catch ( err ) { }
77
76
} else {
@@ -83,13 +82,28 @@ MathJax.Extension.mml2jax = {
83
82
for ( i = 0 , m = html . attributes . length ; i < m ; i ++ ) {
84
83
var attr = html . attributes [ i ] ;
85
84
if ( attr . nodeName . substr ( 0 , 6 ) === "xmlns:" && attr . nodeValue === this . MMLnamespace )
86
- { mathArray . push . apply ( mathArray , element . getElementsByTagName ( attr . nodeName . substr ( 6 ) + ":math" ) ) }
85
+ { this . PushMathElements ( mathArray , element , attr . nodeName . substr ( 6 ) + ":math" ) }
87
86
}
88
87
}
89
88
}
90
89
this . ProcessMathArray ( mathArray ) ;
91
90
} ,
92
91
92
+ PushMathElements : function ( array , element , name , namespace ) {
93
+ var math , preview = MathJax . Hub . config . preRemoveClass ;
94
+ if ( namespace ) {
95
+ if ( ! element . getElementsByTagNameNS ) return ;
96
+ math = element . getElementsByTagNameNS ( namespace , name ) ;
97
+ } else {
98
+ math = element . getElementsByTagName ( name ) ;
99
+ }
100
+ for ( var i = 0 , m = math . length ; i < m ; i ++ ) {
101
+ var parent = math [ i ] . parentNode ;
102
+ if ( parent && parent . className !== preview && ! math [ i ] . prefix === ! namespace )
103
+ { array . push ( math [ i ] ) }
104
+ }
105
+ } ,
106
+
93
107
ProcessMathArray : function ( math ) {
94
108
var i , m = math . length ;
95
109
if ( m ) {
0 commit comments