File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -126,19 +126,23 @@ MathJax.Extension.asciimath2jax = {
126
126
}
127
127
} ,
128
128
129
- scanText : function ( element ) {
129
+ scanText : function ( element , pos ) {
130
130
if ( element . nodeValue . replace ( / \s + / , '' ) == '' ) { return element }
131
131
var match , prev ;
132
132
this . search = { start : true } ;
133
133
this . pattern = this . start ;
134
134
while ( element ) {
135
- this . pattern . lastIndex = 0 ;
135
+ this . pattern . lastIndex = pos || 0 ;
136
136
while ( element && element . nodeName . toLowerCase ( ) === '#text' &&
137
137
( match = this . pattern . exec ( element . nodeValue ) ) ) {
138
138
if ( this . search . start ) { element = this . startMatch ( match , element ) }
139
139
else { element = this . endMatch ( match , element ) }
140
140
}
141
- if ( this . search . matched ) { element = this . encloseMath ( element ) }
141
+ if ( this . search . matched ) {
142
+ element = this . encloseMath ( element ) ;
143
+ } else if ( ! this . search . start ) {
144
+ element = this . scanText ( this . search . open , this . search . opos + this . search . olen ) ;
145
+ }
142
146
if ( element ) {
143
147
do { prev = element ; element = element . nextSibling }
144
148
while ( element && this . ignoreTags [ element . nodeName . toLowerCase ( ) ] != null ) ;
Original file line number Diff line number Diff line change @@ -154,19 +154,23 @@ MathJax.Extension.tex2jax = {
154
154
}
155
155
} ,
156
156
157
- scanText : function ( element ) {
157
+ scanText : function ( element , pos ) {
158
158
if ( element . nodeValue . replace ( / \s + / , '' ) == '' ) { return element }
159
159
var match , prev ;
160
160
this . search = { start : true } ;
161
161
this . pattern = this . start ;
162
162
while ( element ) {
163
- this . pattern . lastIndex = 0 ;
163
+ this . pattern . lastIndex = pos || 0 ;
164
164
while ( element && element . nodeName . toLowerCase ( ) === '#text' &&
165
165
( match = this . pattern . exec ( element . nodeValue ) ) ) {
166
166
if ( this . search . start ) { element = this . startMatch ( match , element ) }
167
167
else { element = this . endMatch ( match , element ) }
168
168
}
169
- if ( this . search . matched ) { element = this . encloseMath ( element ) }
169
+ if ( this . search . matched ) {
170
+ element = this . encloseMath ( element ) ;
171
+ } else if ( ! this . search . start ) {
172
+ element = this . scanText ( this . search . open , this . search . opos + this . search . olen ) ;
173
+ }
170
174
if ( element ) {
171
175
do { prev = element ; element = element . nextSibling }
172
176
while ( element && this . ignoreTags [ element . nodeName . toLowerCase ( ) ] != null ) ;
You can’t perform that action at this time.
0 commit comments