simplifications and different highlight for labels etc.

This commit is contained in:
Daniel Felder 2014-08-11 09:13:50 +00:00
commit 9fb80fb72c

View file

@ -8,21 +8,26 @@ var LatexHighlightRules = function() {
this.$rules = { this.$rules = {
"start" : [{ "start" : [{
token : "keyword", // A comment. Tex comments start with % and go to
regex : "\\\\(documentclass|usepackage|label)" // the end of the line
token : "comment",
regex : "%.*$"
},{ },{
// Escaped character (including new line) // Documentclass and usepackage
token : "constant.character.escape", token : ["keyword","lparen","variable.parameter","rparen", "lparen","storage.type","rparen"],
regex : "\\\\[^a-zA-Z]" regex : "(\\\\(?:documentclass|usepackage))(?:(\\[)([^\\]]*)(\\]))?({)(\\w*)(})"
},{
// A label
token : ["keyword","lparen","variable.parameter","rparen"],
regex : "(\\\\label)(?:({)([^}]*)(}))?"
},{ },{
// A block // A block
token : "storage.type", token : ["storage.type", "lparen","variable.parameter","rparen"],
regex : "\\\\(:?begin|end)", regex : "(\\\\(?:begin|end))({)(\\w*)(})"
next : "block"
},{ },{
// A tex command e.g. \foo // A tex command e.g. \foo
token : "storage.type", token : "storage.type",
regex : "\\\\[a-zA-Z\\d]+" regex : "\\\\[a-zA-Z]+"
}, { }, {
// Curly and square braces // Curly and square braces
token : "lparen", token : "lparen",
@ -31,26 +36,16 @@ var LatexHighlightRules = function() {
// Curly and square braces // Curly and square braces
token : "rparen", token : "rparen",
regex : "[\\])}]" regex : "[\\])}]"
}, { },{
// A comment. Tex comments start with % and go to // Escaped character (including new line)
// the end of the line token : "constant.character.escape",
token : "comment", regex : "\\\\[^a-zA-Z]?"
regex : "%.*$"
},{ },{
// An equation // An equation
token : "string", token : "string",
regex : "\\${1,2}", regex : "\\${1,2}",
next : "equation" next : "equation"
}], }],
"block" : [{
token : ["lparen","variable.parameter","rparen"],
regex : "({)([^}\\s]*)(}?)",
next : "start"
},{
token : "",
regex : "",
next : "start"
}],
"equation" : [{ "equation" : [{
token : "string", token : "string",
regex : "\\${1,2}", regex : "\\${1,2}",