@ -33,79 +33,110 @@ require(['vs/editor/editor.main'], function () {
PascalDefinition ,
PascalDefinition ,
PythonDefinition ,
PythonDefinition ,
RubyDefinition ) {
RubyDefinition ) {
monaco . languages . register ( { id : 'ace_c_cpp' } ) ;
var overrideLangauges = [
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_c_cpp' , new c _cppDefinition . default ) ;
'cpp' ,
monaco . languages . setLanguageConfiguration ( 'ace_c_cpp' , {
'c' ,
comments : {
'csharp' ,
lineComment : '//' ,
'haskell' ,
blockComment : [ '/*' , '*/' ] ,
'java' ,
} ,
'javascript' ,
brackets : [
'pascal' ,
[ '{' , '}' ] ,
'python' ,
[ '[' , ']' ] ,
'ruby' ,
[ '(' , ')' ]
'markdown'
] ,
] ;
autoClosingPairs : [
{ open : '[' , close : ']' } ,
monaco . languages . getLanguages ( ) . forEach ( function ( lang ) {
{ open : '{' , close : '}' } ,
if ( overrideLangauges . includes ( lang . id ) ) {
{ open : '(' , close : ')' } ,
lang . loader = function ( ) {
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
return { then : function ( ) { } } ;
{ open : '"' , close : '"' , notIn : [ 'string' ] } ,
} ;
] ,
surroundingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '"' , close : '"' } ,
{ open : '\'' , close : '\'' } ,
] ,
folding : {
markers : {
start : new RegExp ( "^\\s*#pragma\\s+region\\b" ) ,
end : new RegExp ( "^\\s*#pragma\\s+endregion\\b" )
}
}
}
} ) ;
} ) ;
monaco . languages . register ( { id : 'ace_csharp' } ) ;
var cppAliases = [ 'c' , 'cpp' , 'c++' , 'cxx' , 'cc' ] ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_csharp' , new CSharpDefinition . default ) ;
for ( var i in cppAliases ) {
monaco . languages . setLanguageConfiguration ( 'ace_csharp' , {
var alias = cppAliases [ i ] ;
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
comments : {
monaco . languages . register ( { id : alias } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( alias , new c _cppDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( alias , {
comments : {
lineComment : '//' ,
lineComment : '//' ,
blockComment : [ '/*' , '*/' ] ,
blockComment : [ '/*' , '*/' ] ,
} ,
} ,
brackets : [
brackets : [
[ '{' , '}' ] ,
[ '{' , '}' ] ,
[ '[' , ']' ] ,
[ '[' , ']' ] ,
[ '(' , ')' ] ,
[ '(' , ')' ]
] ,
] ,
autoClosingPairs : [
autoClosingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '[' , close : ']' } ,
{ open : '{' , close : '}' } ,
{ open : '(' , close : ')' } ,
{ open : '(' , close : ')' } ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
{ open : '"' , close : '"' , notIn : [ 'string' , 'comment' ] } ,
{ open : '"' , close : '"' , notIn : [ 'string' ] } ,
] ,
] ,
surroundingPairs : [
surroundingPairs : [
{ open : '{' , close : '}' } ,
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '(' , close : ')' } ,
{ open : '<' , close : '>' } ,
{ open : '\'' , close : '\'' } ,
{ open : '"' , close : '"' } ,
{ open : '"' , close : '"' } ,
] ,
{ open : '\'' , close : '\'' } ,
folding : {
] ,
folding : {
markers : {
markers : {
start : new RegExp ( "^\\s*#region\\b" ) ,
start : new RegExp ( "^\\s*#pragma\\s+ region\\b" ) ,
end : new RegExp ( "^\\s*#endregion\\b" )
end : new RegExp ( "^\\s*#pragma\\s+ endregion\\b" )
}
}
}
}
} ) ;
} ) ;
}
var csharpAliases = [ 'csharp' , 'cs' , 'c#' ] ;
for ( var i in csharpAliases ) {
var alias = csharpAliases [ i ] ;
monaco . languages . register ( { id : 'ace_haskell' } ) ;
monaco . languages . register ( { id : alias } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_haskell' , new HaskellDefinition . default ) ;
MonacoAceTokenizer . registerRulesForLanguage ( alias , new CSharpDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( 'ace_haskell' , {
monaco . languages . setLanguageConfiguration ( alias , {
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
comments : {
lineComment : '//' ,
blockComment : [ '/*' , '*/' ] ,
} ,
brackets : [
[ '{' , '}' ] ,
[ '[' , ']' ] ,
[ '(' , ')' ] ,
] ,
autoClosingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
{ open : '"' , close : '"' , notIn : [ 'string' , 'comment' ] } ,
] ,
surroundingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '<' , close : '>' } ,
{ open : '\'' , close : '\'' } ,
{ open : '"' , close : '"' } ,
] ,
folding : {
markers : {
start : new RegExp ( "^\\s*#region\\b" ) ,
end : new RegExp ( "^\\s*#endregion\\b" )
}
}
} ) ;
}
monaco . languages . register ( { id : 'haskell' } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'haskell' , new HaskellDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( 'haskell' , {
comments : {
comments : {
lineComment : '--' ,
lineComment : '--' ,
blockComment : [ '{-' , '-}' ]
blockComment : [ '{-' , '-}' ]
@ -136,9 +167,9 @@ require(['vs/editor/editor.main'], function () {
}
}
} ) ;
} ) ;
monaco . languages . register ( { id : 'ace_ java' } ) ;
monaco . languages . register ( { id : 'java' } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_ java' , new JavaDefinition . default ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'java' , new JavaDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( 'ace_ java' , {
monaco . languages . setLanguageConfiguration ( 'java' , {
// the default separators except `@$`
// the default separators except `@$`
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
comments : {
comments : {
@ -173,140 +204,154 @@ require(['vs/editor/editor.main'], function () {
}
}
} ) ;
} ) ;
monaco . languages . register ( { id : 'ace_javascript' } ) ;
var javascriptAliases = [ 'javascript' , 'js' ] ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_javascript' , new JavaScriptDefinition . default ) ;
for ( var i in javascriptAliases ) {
monaco . languages . setLanguageConfiguration ( 'ace_javascript' , {
var alias = javascriptAliases [ i ] ;
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
monaco . languages . register ( { id : alias } ) ;
comments : {
MonacoAceTokenizer . registerRulesForLanguage ( alias , new JavaScriptDefinition . default ) ;
lineComment : '//' ,
monaco . languages . setLanguageConfiguration ( alias , {
blockComment : [ '/*' , '*/' ]
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
} ,
comments : {
brackets : [
lineComment : '//' ,
[ '{' , '}' ] ,
blockComment : [ '/*' , '*/' ]
[ '[' , ']' ] ,
} ,
[ '(' , ')' ]
brackets : [
] ,
[ '{' , '}' ] ,
onEnterRules : [
[ '[' , ']' ] ,
{
[ '(' , ')' ]
// e.g. /** | */
] ,
beforeText : /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/ ,
onEnterRules : [
afterText : /^\s*\*\/$/ ,
{
action : { indentAction : monaco . languages . IndentAction . IndentOutdent , appendText : ' * ' }
// e.g. /** | */
} ,
beforeText : /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/ ,
{
afterText : /^\s*\*\/$/ ,
// e.g. /** ...|
action : { indentAction : monaco . languages . IndentAction . IndentOutdent , appendText : ' * ' }
beforeText : /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/ ,
} ,
action : { indentAction : monaco . languages . IndentAction . None , appendText : ' * ' }
{
} ,
// e.g. /** ...|
{
beforeText : /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/ ,
// e.g. * ...|
action : { indentAction : monaco . languages . IndentAction . None , appendText : ' * ' }
beforeText : /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/ ,
} ,
action : { indentAction : monaco . languages . IndentAction . None , appendText : '* ' }
{
} ,
// e.g. * ...|
{
beforeText : /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/ ,
// e.g. */|
action : { indentAction : monaco . languages . IndentAction . None , appendText : '* ' }
beforeText : /^(\t|(\ \ ))*\ \*\/\s*$/ ,
} ,
action : { indentAction : monaco . languages . IndentAction . None , removeText : 1 }
{
}
// e.g. */|
] ,
beforeText : /^(\t|(\ \ ))*\ \*\/\s*$/ ,
autoClosingPairs : [
action : { indentAction : monaco . languages . IndentAction . None , removeText : 1 }
{ open : '{' , close : '}' } ,
}
{ open : '[' , close : ']' } ,
] ,
{ open : '(' , close : ')' } ,
autoClosingPairs : [
{ open : '"' , close : '"' , notIn : [ 'string' ] } ,
{ open : '{' , close : '}' } ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
{ open : '[' , close : ']' } ,
{ open : '`' , close : '`' , notIn : [ 'string' , 'comment' ] } ,
{ open : '(' , close : ')' } ,
{ open : "/**" , close : " */" , notIn : [ "string" ] }
{ open : '"' , close : '"' , notIn : [ 'string' ] } ,
] ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
folding : {
{ open : '`' , close : '`' , notIn : [ 'string' , 'comment' ] } ,
markers : {
{ open : "/**" , close : " */" , notIn : [ "string" ] }
start : new RegExp ( "^\\s*//\\s*#?region\\b" ) ,
] ,
end : new RegExp ( "^\\s*//\\s*#?endregion\\b" )
folding : {
}
markers : {
}
start : new RegExp ( "^\\s*//\\s*#?region\\b" ) ,
} ) ;
end : new RegExp ( "^\\s*//\\s*#?endregion\\b" )
}
monaco . languages . register ( { id : 'ace_pascal' } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_pascal' , new PascalDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( 'ace_pascal' , {
// the default separators except `@$`
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
comments : {
lineComment : '//' ,
blockComment : [ '{' , '}' ] ,
} ,
brackets : [
[ '{' , '}' ] ,
[ '[' , ']' ] ,
[ '(' , ')' ] ,
[ '<' , '>' ] ,
] ,
autoClosingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '<' , close : '>' } ,
{ open : '\'' , close : '\'' } ,
] ,
surroundingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '<' , close : '>' } ,
{ open : '\'' , close : '\'' } ,
] ,
folding : {
markers : {
start : new RegExp ( "^\\s*\\{\\$REGION(\\s\\'.*\\')?\\}" ) ,
end : new RegExp ( "^\\s*\\{\\$ENDREGION\\}" )
}
}
}
} ) ;
} ) ;
}
monaco . languages . register ( { id : 'ace_python' } ) ;
var pascalAliases = [ 'pascal' , 'pas' ] ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_python' , new PythonDefinition . default ) ;
for ( var i in pascalAliases ) {
monaco . languages . setLanguageConfiguration ( 'ace_python' , {
var alias = pascalAliases [ i ] ;
comments : {
lineComment : '#' ,
monaco . languages . register ( { id : alias } ) ;
blockComment : [ '\'\'\'' , '\'\'\'' ] ,
MonacoAceTokenizer . registerRulesForLanguage ( alias , new PascalDefinition . default ) ;
} ,
monaco . languages . setLanguageConfiguration ( alias , {
brackets : [
// the default separators except `@$`
wordPattern : /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g ,
comments : {
lineComment : '//' ,
blockComment : [ '{' , '}' ] ,
} ,
brackets : [
[ '{' , '}' ] ,
[ '{' , '}' ] ,
[ '[' , ']' ] ,
[ '[' , ']' ] ,
[ '(' , ')' ]
[ '(' , ')' ] ,
] ,
[ '<' , '>' ] ,
autoClosingPairs : [
] ,
autoClosingPairs : [
{ open : '{' , close : '}' } ,
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '(' , close : ')' } ,
{ open : '" ' , close : '"' , notIn : [ 'string' ] } ,
{ open : '<' , close : '>' } ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
{ open : '\'' , close : '\'' } ,
] ,
] ,
surroundingPairs : [
surroundingPairs : [
{ open : '{' , close : '}' } ,
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '(' , close : ')' } ,
{ open : '" ' , close : '" ' } ,
{ open : '< ' , close : '> ' } ,
{ open : '\'' , close : '\'' } ,
{ open : '\'' , close : '\'' } ,
] ,
] ,
onEnterRules : [
folding : {
{
beforeText : new RegExp ( "^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$" ) ,
action : { indentAction : monaco . languages . IndentAction . Indent }
}
] ,
folding : {
offSide : true ,
markers : {
markers : {
start : new RegExp ( "^\\s*#region\\b " ) ,
start : new RegExp ( "^\\s*\\{\\$REGION(\\s\\'.*\\')?\\}" ) ,
end : new RegExp ( "^\\s*#endregion\\b " )
end : new RegExp ( "^\\s*\\{\\$ENDREGION\\}" )
}
}
}
}
} ) ;
} ) ;
}
var pythonAliases = [ 'python' , 'python2' , 'python3' , 'py' , 'py2' , 'py3' ] ;
for ( var i in pythonAliases ) {
var alias = pythonAliases [ i ] ;
monaco . languages . register ( { id : alias } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( alias , new PythonDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( alias , {
comments : {
lineComment : '#' ,
blockComment : [ '\'\'\'' , '\'\'\'' ] ,
} ,
brackets : [
[ '{' , '}' ] ,
[ '[' , ']' ] ,
[ '(' , ')' ]
] ,
autoClosingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '"' , close : '"' , notIn : [ 'string' ] } ,
{ open : '\'' , close : '\'' , notIn : [ 'string' , 'comment' ] } ,
] ,
surroundingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '"' , close : '"' } ,
{ open : '\'' , close : '\'' } ,
] ,
onEnterRules : [
{
beforeText : new RegExp ( "^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$" ) ,
action : { indentAction : monaco . languages . IndentAction . Indent }
}
] ,
folding : {
offSide : true ,
markers : {
start : new RegExp ( "^\\s*#region\\b" ) ,
end : new RegExp ( "^\\s*#endregion\\b" )
}
}
} ) ;
}
monaco . languages . register ( { id : 'ace_ruby' } ) ;
monaco . languages . register ( { id : 'ruby' } ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ace_ruby' , new RubyDefinition . default ) ;
MonacoAceTokenizer . registerRulesForLanguage ( 'ruby' , new RubyDefinition . default ) ;
monaco . languages . setLanguageConfiguration ( 'ace_ruby' , {
monaco . languages . setLanguageConfiguration ( 'ruby' , {
comments : {
comments : {
lineComment : '#' ,
lineComment : '#' ,
blockComment : [ '=begin' , '=end' ] ,
blockComment : [ '=begin' , '=end' ] ,
@ -336,9 +381,212 @@ require(['vs/editor/editor.main'], function () {
}
}
} ) ;
} ) ;
var markdownAliases = [ 'markdown' , 'md' ] ;
for ( var i in markdownAliases ) {
var alias = markdownAliases [ i ] ;
monaco . languages . register ( { id : alias } ) ;
monaco . languages . setLanguageConfiguration ( alias , {
comments : {
blockComment : [ '<!--' , '-->' , ]
} ,
brackets : [
[ '{' , '}' ] ,
[ '[' , ']' ] ,
[ '(' , ')' ]
] ,
autoClosingPairs : [
{ open : '{' , close : '}' } ,
{ open : '[' , close : ']' } ,
{ open : '(' , close : ')' } ,
{ open : '<' , close : '>' , notIn : [ 'string' ] }
] ,
surroundingPairs : [
{ open : '(' , close : ')' } ,
{ open : '[' , close : ']' } ,
{ open : '`' , close : '`' } ,
] ,
folding : {
markers : {
start : new RegExp ( "^\\s*<!--\\s*#?region\\b.*-->" ) ,
end : new RegExp ( "^\\s*<!--\\s*#?endregion\\b.*-->" )
}
}
} ) ;
monaco . languages . setMonarchTokensProvider ( alias , {
defaultToken : '' ,
tokenPostfix : '.md' ,
// escape codes
control : /[\\`*_\[\]{}()#+\-\.!\$]/ ,
noncontrol : /[^\\`*_\[\]{}()#+\-\.!\$]/ ,
escapes : /\\(?:@control)/ ,
// escape codes for javascript/CSS strings
jsescapes : /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/ ,
// non matched elements
empty : [
'area' , 'base' , 'basefont' , 'br' , 'col' , 'frame' ,
'hr' , 'img' , 'input' , 'isindex' , 'link' , 'meta' , 'param'
] ,
tokenizer : {
root : [
// headers (with #)
[ /^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/ , [ 'white' , 'keyword' , 'keyword' , 'keyword' ] ] ,
// headers (with =)
[ /^\s*(=+|\-+)\s*$/ , 'keyword' ] ,
// headers (with ***)
[ /^\s*((\*[ ]?)+)\s*$/ , 'meta.separator' ] ,
// quote
[ /^\s*>+/ , 'comment' ] ,
// list (starting with * or number)
[ /^\s*([\*\-+:]|\d+\.)\s/ , 'keyword' ] ,
// code block (4 spaces indent)
[ /^(\t|[ ]{4})[^ ].*$/ , 'string' ] ,
// code block (3 tilde)
[ /^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/ , { token : 'string' , next : '@codeblock' } ] ,
// display math
[ /\$\$/ , { token : 'string' , next : '@displaymath' } ] ,
// github style code blocks (with backticks and language)
[ /^\s*```\s*((?:\w|[\/\-#\+])+)\s*$/ , { token : 'string' , next : '@codeblockgh' , nextEmbedded : '$1' } ] ,
// github style code blocks (with backticks but no language)
[ /^\s*```\s*$/ , { token : 'string' , next : '@codeblock' } ] ,
// markup within lines
{ include : '@linecontent' } ,
] ,
displaymath : [
[ /\\\$/ , 'variable.source' ] ,
[ /\$\$/ , { token : 'string' , next : '@pop' } ] ,
[ /./ , 'variable.source' ]
] ,
codeblock : [
[ /^\s*~~~\s*$/ , { token : 'string' , next : '@pop' } ] ,
[ /^\s*```\s*$/ , { token : 'string' , next : '@pop' } ] ,
[ /.*$/ , 'variable.source' ] ,
] ,
// github style code blocks
codeblockgh : [
[ /```\s*$/ , { token : 'variable.source' , next : '@pop' , nextEmbedded : '@pop' } ] ,
[ /[^`]+/ , 'variable.source' ] ,
] ,
linecontent : [
// inline math
[ /\$/ , { token : 'string' , next : '@inlinemath' } ] ,
// escapes
[ /&\w+;/ , 'string.escape' ] ,
[ /@escapes/ , 'escape' ] ,
// various markup
[ /\b__([^\\_]|@escapes|_(?!_))+__\b/ , 'strong' ] ,
[ /\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/ , 'strong' ] ,
[ /\b_[^_]+_\b/ , 'emphasis' ] ,
[ /\*([^\\*]|@escapes)+\*/ , 'emphasis' ] ,
[ /`([^\\`]|@escapes)+`/ , 'variable' ] ,
// links
[ /\{+[^}]+\}+/ , 'string.target' ] ,
[ /(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/ , [ 'string.link' , '' , 'string.link' ] ] ,
[ /(!?\[)((?:[^\]\\]|@escapes)*)(\])/ , 'string.link' ] ,
// or html
{ include : 'html' } ,
] ,
inlinemath : [
[ /\\\$/ , 'variable.source' ] ,
[ /\$/ , { token : 'string' , next : '@pop' } ] ,
[ /./ , 'variable.source' ]
] ,
// Note: it is tempting to rather switch to the real HTML mode instead of building our own here
// but currently there is a limitation in Monarch that prevents us from doing it: The opening
// '<' would start the HTML mode, however there is no way to jump 1 character back to let the
// HTML mode also tokenize the opening angle bracket. Thus, even though we could jump to HTML,
// we cannot correctly tokenize it in that mode yet.
html : [
// html tags
[ /<(\w+)\/>/ , 'tag' ] ,
[ /<(\w+)/ , {
cases : {
'@empty' : { token : 'tag' , next : '@tag.$1' } ,
'@default' : { token : 'tag' , next : '@tag.$1' }
}
} ] ,
[ /<\/(\w+)\s*>/ , { token : 'tag' } ] ,
[ /<!--/ , 'comment' , '@comment' ]
] ,
comment : [
[ /[^<\-]+/ , 'comment.content' ] ,
[ /-->/ , 'comment' , '@pop' ] ,
[ /<!--/ , 'comment.content.invalid' ] ,
[ /[<\-]/ , 'comment.content' ]
] ,
// Almost full HTML tag matching, complete with embedded scripts & styles
tag : [
[ /[ \t\r\n]+/ , 'white' ] ,
[ /(type)(\s*=\s*)(")([^"]+)(")/ , [ 'attribute.name.html' , 'delimiter.html' , 'string.html' ,
{ token : 'string.html' , switchTo : '@tag.$S2.$4' } ,
'string.html' ] ] ,
[ /(type)(\s*=\s*)(')([^']+)(')/ , [ 'attribute.name.html' , 'delimiter.html' , 'string.html' ,
{ token : 'string.html' , switchTo : '@tag.$S2.$4' } ,
'string.html' ] ] ,
[ /(\w+)(\s*=\s*)("[^"]*"|'[^']*')/ , [ 'attribute.name.html' , 'delimiter.html' , 'string.html' ] ] ,
[ /\w+/ , 'attribute.name.html' ] ,
[ /\/>/ , 'tag' , '@pop' ] ,
[ />/ , {
cases : {
'$S2==style' : { token : 'tag' , switchTo : 'embeddedStyle' , nextEmbedded : 'text/css' } ,
'$S2==script' : {
cases : {
'$S3' : { token : 'tag' , switchTo : 'embeddedScript' , nextEmbedded : '$S3' } ,
'@default' : { token : 'tag' , switchTo : 'embeddedScript' , nextEmbedded : 'text/javascript' }
}
} ,
'@default' : { token : 'tag' , next : '@pop' }
}
} ] ,
] ,
embeddedStyle : [
[ /[^<]+/ , '' ] ,
[ /<\/style\s*>/ , { token : '@rematch' , next : '@pop' , nextEmbedded : '@pop' } ] ,
[ /</ , '' ]
] ,
embeddedScript : [
[ /[^<]+/ , '' ] ,
[ /<\/script\s*>/ , { token : '@rematch' , next : '@pop' , nextEmbedded : '@pop' } ] ,
[ /</ , '' ]
] ,
}
} ) ;
}
$ . getScript ( window . pathSelfLib + "monaco-editor-tomorrow.js" , function ( ) {
$ . getScript ( window . pathSelfLib + "monaco-editor-tomorrow.js" , function ( ) {
window . createEditor = function ( editorElement , langauge , content ) {
window . createCodeEditor = function ( editorElement , langauge , content ) {
editorElement . innerHTML = '' ;
return monaco . editor . create ( editorElement , {
return monaco . editor . create ( editorElement , {
value : content ,
value : content ,
language : langauge ,
language : langauge ,
@ -347,10 +595,60 @@ require(['vs/editor/editor.main'], function () {
theme : 'tomorrow' ,
theme : 'tomorrow' ,
lineHeight : 22 ,
lineHeight : 22 ,
fontSize : 14 ,
fontSize : 14 ,
fontFamily : "'Fira Mono', 'Bitstream Vera Sans Mono', 'Menlo', 'Consolas', 'Lucida Console', monospace" ,
fontFamily : "'Fira Mono', 'Bitstream Vera Sans Mono', 'Menlo', 'Consolas', 'Lucida Console', 'Source Han Sans SC', 'Noto Sans CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft Yahei', monospace" ,
lineNumbersMinChars : 4 ,
glyphMargin : false ,
renderFinalNewline : true ,
scrollbar : {
useShadows : false ,
verticalScrollbarSize : 0 ,
vertical : 'hidden'
} ,
overviewRulerBorder : false ,
hideCursorInOverviewRuler : true
} ) ;
} ;
window . createMarkdownEditor = function ( editorElement , content , input ) {
editorElement . innerHTML = '' ;
var editor = monaco . editor . create ( editorElement , {
value : content ,
language : 'markdown' ,
multicursorModifier : 'ctrlCmd' ,
cursorWidth : 1 ,
theme : 'tomorrow' ,
fontSize : 14 ,
fontFamily : "'Fira Mono', 'Source Han Sans SC', 'Noto Sans CJK SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft Yahei', monospace" ,
lineNumbersMinChars : 4 ,
lineNumbersMinChars : 4 ,
glyphMargin : false
glyphMargin : false ,
lineNumbers : false ,
folding : false ,
minimap : {
enabled : false
} ,
hover : {
enabled : false
} ,
wordWrap : "on" ,
renderIndentGuides : false ,
renderFinalNewline : false ,
wordBasedSuggestions : false ,
renderLineHighlight : false ,
occurrencesHighlight : false ,
scrollbar : {
useShadows : false ,
vertical : 'auto' ,
verticalScrollbarSize : 10
} ,
overviewRulerBorder : false ,
hideCursorInOverviewRuler : true
} ) ;
} ) ;
input . form . addEventListener ( 'submit' , function ( ) {
input . value = editor . getValue ( ) ;
} ) ;
return editor ;
} ;
} ;
window . editorLoaded = true ;
window . editorLoaded = true ;