@@ -11,34 +11,34 @@ import { ICodeMirror } from '@jupyterlab/codemirror';
1111/** Of the default codemirror tokens, "keyword" matches MATLAB comment style best,
1212 * and variable-2 matches MATLAB keyword style best. These tokens are only used for
1313 * display and not for execution. */
14- export const token_to_matlab_style = new Map < string , string > ( [
15- [ " comment" , " keyword" ] ,
16- [ " string" , " string-2" ] ,
17- [ " keyword" , " variable-2" ]
14+ export const tokenToMatlabStyle = new Map < string , string > ( [
15+ [ ' comment' , ' keyword' ] ,
16+ [ ' string' , ' string-2' ] ,
17+ [ ' keyword' , ' variable-2' ]
1818] ) ;
1919
2020const baseRegex = [
2121 /** The boolean "sol" is needed as the ^ regexp marker is not
2222 * sufficient in this context.
2323 * See https://codemirror.net/5/demo/simplemode.html. */
24- { regex : / ( [ \s ] * ) ( % \{ ) [ ^ \S \n ] * $ / , token : token_to_matlab_style . get ( " comment" ) , next : 'comment' , sol : true } ,
25- { regex : / % .* $ / , token : token_to_matlab_style . get ( " comment" ) } ,
26- { regex : / " .* ?( " | $ ) / , token : token_to_matlab_style . get ( " string" ) } ,
27- { regex : / ' .* ?( ' | $ ) / , token : token_to_matlab_style . get ( " string" ) } ,
28- { regex : / \b ( b r e a k | c a s e | c l a s s d e f | c o n t i n u e | g l o b a l | o t h e r w i s e | p e r s i s t e n t | r e t u r n | s p m d ) \b / , token : token_to_matlab_style . get ( " keyword" ) } ,
24+ { regex : / ( [ \s ] * ) ( % \{ ) [ ^ \S \n ] * $ / , token : tokenToMatlabStyle . get ( ' comment' ) , next : 'comment' , sol : true } ,
25+ { regex : / % .* $ / , token : tokenToMatlabStyle . get ( ' comment' ) } ,
26+ { regex : / " .* ?( " | $ ) / , token : tokenToMatlabStyle . get ( ' string' ) } ,
27+ { regex : / ' .* ?( ' | $ ) / , token : tokenToMatlabStyle . get ( ' string' ) } ,
28+ { regex : / \b ( b r e a k | c a s e | c l a s s d e f | c o n t i n u e | g l o b a l | o t h e r w i s e | p e r s i s t e n t | r e t u r n | s p m d ) \b / , token : tokenToMatlabStyle . get ( ' keyword' ) } ,
2929 { regex : / ( \b i m p o r t \b ) ( .* ) (? = ; | % | $ ) / , token : [ 'variable' , 'meta' , 'variable' ] } ,
30- { regex : / \b ( a r g u m e n t s | e n u m e r a t i o n | e v e n t s | f o r | f u n c t i o n | i f | m e t h o d s | p a r f o r | p r o p e r t i e s | t r y | w h i l e ) \b / , indent : true , token : token_to_matlab_style . get ( " keyword" ) } ,
31- { regex : / \b ( s w i t c h ) \b / , indent : true , token : token_to_matlab_style . get ( " keyword" ) } ,
32- { regex : / \b ( c a t c h | e l s e | e l s e i f ) \b / , indent : true , dedent : true , token : token_to_matlab_style . get ( " keyword" ) } ,
33- { regex : / \b (?: e n d ) \b / , dedent : true , token : token_to_matlab_style . get ( " keyword" ) } ,
30+ { regex : / \b ( a r g u m e n t s | e n u m e r a t i o n | e v e n t s | f o r | f u n c t i o n | i f | m e t h o d s | p a r f o r | p r o p e r t i e s | t r y | w h i l e ) \b / , indent : true , token : tokenToMatlabStyle . get ( ' keyword' ) } ,
31+ { regex : / \b ( s w i t c h ) \b / , indent : true , token : tokenToMatlabStyle . get ( ' keyword' ) } ,
32+ { regex : / \b ( c a t c h | e l s e | e l s e i f ) \b / , indent : true , dedent : true , token : tokenToMatlabStyle . get ( ' keyword' ) } ,
33+ { regex : / \b (?: e n d ) \b / , dedent : true , token : tokenToMatlabStyle . get ( ' keyword' ) } ,
3434 /** Removing this line (or adding \s* around it) will break tab completion. */
35- { regex : / [ a - z A - Z _ ] \w * / , token : " variable" }
35+ { regex : / [ a - z A - Z _ ] \w * / , token : ' variable' }
3636] ;
3737
3838const startRegex = baseRegex ;
3939const multilineCommentRegex = [
40- { regex : / ( [ \s ] * ) ( % \} ) [ ^ \S \n ] * (?: $ ) / , token : token_to_matlab_style . get ( " comment" ) , next : 'start' , sol : true } ,
41- { regex : / .* / , token : token_to_matlab_style . get ( " comment" ) }
40+ { regex : / ( [ \s ] * ) ( % \} ) [ ^ \S \n ] * (?: $ ) / , token : tokenToMatlabStyle . get ( ' comment' ) , next : 'start' , sol : true } ,
41+ { regex : / .* / , token : tokenToMatlabStyle . get ( ' comment' ) }
4242] ;
4343
4444/** Install mode in CodeMirror */
@@ -71,7 +71,7 @@ export const matlabCodeMirrorPlugin: JupyterFrontEndPlugin<void> = {
7171 requires : [ ICodeMirror ] ,
7272 activate : (
7373 app : JupyterFrontEnd ,
74- codeMirror : ICodeMirror ,
74+ codeMirror : ICodeMirror
7575 ) => {
7676 defineMATLABMode ( codeMirror ) ;
7777 }
0 commit comments