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