diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 3057c0de..43ee0394 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -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;