File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -426,6 +426,20 @@ function ConfigureMathJax() {
426
426
427
427
} ) ;
428
428
429
+ //
430
+ // Reset the color extension after `autoload-all`
431
+ //
432
+ if ( MathJax . AuthorConfig . extensions . indexOf ( "TeX/color.js" ) == - 1 ) {
433
+ MathJax . Hub . Register . StartupHook ( "TeX autoload-all Ready" , function ( ) {
434
+ var macros = MathJax . InputJax . TeX . Definitions . macros ;
435
+ macros . color = "Color" ;
436
+ delete macros . textcolor ;
437
+ delete macros . colorbox ;
438
+ delete macros . fcolorbox ;
439
+ delete macros . definecolor ;
440
+ } ) ;
441
+ }
442
+
429
443
//
430
444
// Start the typesetting queue when MathJax is ready
431
445
// (reseting the counters so that the initial math doesn't affect them)
Original file line number Diff line number Diff line change
1
+ var tape = require ( 'tape' ) ;
2
+ var mjAPI = require ( "../lib/main.js" ) ;
3
+ var jsdom = require ( 'jsdom' ) . jsdom ;
4
+
5
+ tape ( 'color extension should be reset' , function ( t ) {
6
+ t . plan ( 3 ) ;
7
+ mjAPI . start ( ) ;
8
+ var tex = '\\colorbox{green}{x}' ;
9
+ var tex2 = '\\color{red}{x}x' ;
10
+
11
+ mjAPI . typeset ( {
12
+ math : tex ,
13
+ format : "TeX" ,
14
+ mml : true
15
+ } , function ( data ) {
16
+ t . ok ( data . errors , 'Color extension disabled' ) ;
17
+ } ) ;
18
+ mjAPI . typeset ( {
19
+ math : tex2 ,
20
+ format : "TeX" ,
21
+ mml : true
22
+ } , function ( data ) {
23
+ var document = jsdom ( data . mml ) ;
24
+ var mstyle = document . defaultView . document . querySelector ( 'mstyle' ) ;
25
+ t . ok ( document . defaultView . document . querySelectorAll ( 'mi' ) [ 0 ] . parentNode === mstyle , 'Color macro behaves correctly (1 of 2)' ) ;
26
+ t . notOk ( document . defaultView . document . querySelectorAll ( 'mi' ) [ 1 ] . parentNode === mstyle , 'Color macro behaves correctly (2 of 2)' ) ;
27
+ } ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments