some more syntax highlighting for latex mode
This commit is contained in:
parent
ffc547d2c3
commit
08bf3696e7
1 changed files with 39 additions and 7 deletions
|
|
@ -5,10 +5,21 @@ var oop = require("../lib/oop");
|
||||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var LatexHighlightRules = function() {
|
var LatexHighlightRules = function() {
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start" : [{
|
"start" : [{
|
||||||
// A tex command e.g. \foo
|
|
||||||
token : "keyword",
|
token : "keyword",
|
||||||
|
regex : "\\\\(documentclass|usepackage|label)"
|
||||||
|
},{
|
||||||
|
token : "constant.character.escape",
|
||||||
|
regex : "\\\\{2}"
|
||||||
|
},{
|
||||||
|
token : "storage.type",
|
||||||
|
regex : "\\\\(:?begin|end)",
|
||||||
|
next : "block"
|
||||||
|
},{
|
||||||
|
// A tex command e.g. \foo
|
||||||
|
token : "storage.type",
|
||||||
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
|
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
|
||||||
}, {
|
}, {
|
||||||
// Curly and square braces
|
// Curly and square braces
|
||||||
|
|
@ -18,19 +29,40 @@ var LatexHighlightRules = function() {
|
||||||
// Curly and square braces
|
// Curly and square braces
|
||||||
token : "rparen",
|
token : "rparen",
|
||||||
regex : "[\\])}]"
|
regex : "[\\])}]"
|
||||||
}, {
|
|
||||||
// Inline math between two $ symbols
|
|
||||||
token : "string",
|
|
||||||
regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$"
|
|
||||||
}, {
|
}, {
|
||||||
// A comment. Tex comments start with % and go to
|
// A comment. Tex comments start with % and go to
|
||||||
// the end of the line
|
// the end of the line
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "%.*$"
|
regex : "%.*$"
|
||||||
|
},{
|
||||||
|
// An equation
|
||||||
|
token : "string",
|
||||||
|
regex : "\\${1,2}",
|
||||||
|
next : "equation"
|
||||||
|
}],
|
||||||
|
"block" : [{
|
||||||
|
token : ["","variable.parameter",""],
|
||||||
|
regex : "({)([^}\\s]*)(}?)",
|
||||||
|
next : "start"
|
||||||
|
},{
|
||||||
|
token : "",
|
||||||
|
regex : "",
|
||||||
|
next : "start"
|
||||||
|
}],
|
||||||
|
"equation" : [{
|
||||||
|
token : "string",
|
||||||
|
regex : "\\${1,2}",
|
||||||
|
next : "start"
|
||||||
|
},{
|
||||||
|
token : "constant.character.escape",
|
||||||
|
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
|
||||||
|
},{
|
||||||
|
token : "string",
|
||||||
|
regex : "."
|
||||||
}]
|
}]
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(LatexHighlightRules, TextHighlightRules);
|
oop.inherits(LatexHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
exports.LatexHighlightRules = LatexHighlightRules;
|
exports.LatexHighlightRules = LatexHighlightRules;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue