@@ -163,14 +163,48 @@ function cleanEscapesForTex(s) {
163
163
}
164
164
165
165
function texToSVG ( _texString , _config , _callback ) {
166
- var randomID = 'math-output-' + Lib . randstr ( { } , 64 ) ;
167
- var tmpDiv = d3 . select ( 'body' ) . append ( 'div' )
168
- . attr ( { id : randomID } )
169
- . style ( { visibility : 'hidden' , position : 'absolute' } )
170
- . style ( { 'font-size' : _config . fontSize + 'px' } )
171
- . text ( cleanEscapesForTex ( _texString ) ) ;
172
-
173
- MathJax . Hub . Queue ( [ 'Typeset' , MathJax . Hub , tmpDiv . node ( ) ] , function ( ) {
166
+
167
+ var originalRenderer ,
168
+ originalConfig ,
169
+ originalProcessSectionDelay ,
170
+ tmpDiv ;
171
+
172
+ MathJax . Hub . Queue (
173
+ function ( ) {
174
+ originalConfig = Lib . extendDeepAll ( { } , MathJax . Hub . config ) ;
175
+
176
+ originalProcessSectionDelay = MathJax . Hub . processSectionDelay ;
177
+ if ( MathJax . Hub . processSectionDelay !== undefined ) {
178
+ // MathJax 2.5+
179
+ MathJax . Hub . processSectionDelay = 0 ;
180
+ }
181
+
182
+ return MathJax . Hub . Config ( {
183
+ messageStyle : 'none' ,
184
+ tex2jax : {
185
+ inlineMath : [ [ '$' , '$' ] , [ '\\(' , '\\)' ] ]
186
+ } ,
187
+ displayAlign : 'left' ,
188
+ } ) ;
189
+ } ,
190
+ function ( ) {
191
+ // Get original renderer
192
+ originalRenderer = MathJax . Hub . config . menuSettings . renderer ;
193
+ if ( originalRenderer !== 'SVG' ) {
194
+ return MathJax . Hub . setRenderer ( 'SVG' ) ;
195
+ }
196
+ } ,
197
+ function ( ) {
198
+ var randomID = 'math-output-' + Lib . randstr ( { } , 64 ) ;
199
+ tmpDiv = d3 . select ( 'body' ) . append ( 'div' )
200
+ . attr ( { id : randomID } )
201
+ . style ( { visibility : 'hidden' , position : 'absolute' } )
202
+ . style ( { 'font-size' : _config . fontSize + 'px' } )
203
+ . text ( cleanEscapesForTex ( _texString ) ) ;
204
+
205
+ return MathJax . Hub . Typeset ( tmpDiv . node ( ) ) ;
206
+ } ,
207
+ function ( ) {
174
208
var glyphDefs = d3 . select ( 'body' ) . select ( '#MathJax_SVG_glyphs' ) ;
175
209
176
210
if ( tmpDiv . select ( '.MathJax_SVG' ) . empty ( ) || ! tmpDiv . select ( 'svg' ) . node ( ) ) {
@@ -183,6 +217,16 @@ function texToSVG(_texString, _config, _callback) {
183
217
}
184
218
185
219
tmpDiv . remove ( ) ;
220
+
221
+ if ( originalRenderer !== 'SVG' ) {
222
+ return MathJax . Hub . setRenderer ( originalRenderer ) ;
223
+ }
224
+ } ,
225
+ function ( ) {
226
+ if ( originalProcessSectionDelay !== undefined ) {
227
+ MathJax . Hub . processSectionDelay = originalProcessSectionDelay ;
228
+ }
229
+ return MathJax . Hub . Config ( originalConfig ) ;
186
230
} ) ;
187
231
}
188
232
0 commit comments