@@ -11,34 +11,34 @@ import { ICodeMirror } from '@jupyterlab/codemirror';
11
11
/** Of the default codemirror tokens, "keyword" matches MATLAB comment style best,
12
12
* and variable-2 matches MATLAB keyword style best. These tokens are only used for
13
13
* 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' ]
18
18
] ) ;
19
19
20
20
const baseRegex = [
21
21
/** The boolean "sol" is needed as the ^ regexp marker is not
22
22
* sufficient in this context.
23
23
* 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' ) } ,
29
29
{ 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' ) } ,
34
34
/** 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' }
36
36
] ;
37
37
38
38
const startRegex = baseRegex ;
39
39
const 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' ) }
42
42
] ;
43
43
44
44
/** Install mode in CodeMirror */
@@ -71,7 +71,7 @@ export const matlabCodeMirrorPlugin: JupyterFrontEndPlugin<void> = {
71
71
requires : [ ICodeMirror ] ,
72
72
activate : (
73
73
app : JupyterFrontEnd ,
74
- codeMirror : ICodeMirror ,
74
+ codeMirror : ICodeMirror
75
75
) => {
76
76
defineMATLABMode ( codeMirror ) ;
77
77
}
0 commit comments