simplifications and different highlight for labels etc.
This commit is contained in:
parent
b4dc4b7694
commit
9fb80fb72c
1 changed files with 18 additions and 23 deletions
|
|
@ -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}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue