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
|
|
@ -4,11 +4,22 @@ define(function(require, exports, module) {
|
|||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var LatexHighlightRules = function() {
|
||||
var LatexHighlightRules = function() {
|
||||
|
||||
this.$rules = {
|
||||
"start" : [{
|
||||
// A tex command e.g. \foo
|
||||
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]+)"
|
||||
}, {
|
||||
// Curly and square braces
|
||||
|
|
@ -18,19 +29,40 @@ var LatexHighlightRules = function() {
|
|||
// Curly and square braces
|
||||
token : "rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
// Inline math between two $ symbols
|
||||
token : "string",
|
||||
regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$"
|
||||
}, {
|
||||
// A comment. Tex comments start with % and go to
|
||||
// the end of the line
|
||||
token : "comment",
|
||||
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);
|
||||
|
||||
exports.LatexHighlightRules = LatexHighlightRules;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue