File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,13 @@ function GetState(state) {
741741 MML . SUPER . ID = ID = 0 ;
742742 MathJax . OutputJax . CommonHTML . ID = 0 ;
743743 }
744+
745+ // Clear any existing user defined macros
746+ Object . keys ( TEX . Definitions . macros ) . forEach ( function ( macroName ) {
747+ if ( TEX . Definitions . macros [ macroName ] . isUser ) {
748+ delete TEX . Definitions . macros [ macroName ] ;
749+ }
750+ } ) ;
744751}
745752
746753//
Original file line number Diff line number Diff line change 1+ var tape = require ( 'tape' ) ;
2+ var mjAPI = require ( "../lib/main.js" ) ;
3+
4+ tape ( 'macros should be cleared from global state' , function ( t ) {
5+ t . plan ( 2 ) ;
6+ mjAPI . start ( ) ;
7+
8+ mjAPI . typeset ( {
9+ math : "\\def\\mymacro{2\\pi} \\mymacro" ,
10+ format : "TeX" ,
11+ mml : true
12+ } , function ( data ) {
13+ t . false ( data . errors , 'Defined and used macro' ) ;
14+ } ) ;
15+
16+ mjAPI . typeset ( {
17+ math : "\\mymacro" ,
18+ format : "TeX" ,
19+ mml : true
20+ } , function ( data ) {
21+ t . true ( data . errors , '\\mymacro should no longer be defined' ) ;
22+ } ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments