| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- define(function(require, exports, module) {
- "use strict";
- var oop = require("../lib/oop");
- var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
- var LatexHighlightRules = function() {
- this.$rules = {
- "start" : [{
- // A comment. Tex comments start with % and go to
- // the end of the line
- token : "comment",
- regex : "%.*$"
- }, {
- // Documentclass and usepackage
- token : ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"],
- regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})"
- }, {
- // A label
- token : ["keyword","lparen", "variable.parameter", "rparen"],
- regex : "(\\\\(?:label|v?ref|cite(?:[^{]*)))(?:({)([^}]*)(}))?"
- }, {
- // A 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]+"
- }, {
- // Curly and square braces
- token : "lparen",
- regex : "[[({]"
- }, {
- // Curly and square braces
- token : "rparen",
- regex : "[\\])}]"
- }, {
- // Escaped character (including new line)
- token : "constant.character.escape",
- regex : "\\\\[^a-zA-Z]?"
- }, {
- // An equation
- token : "string",
- regex : "\\${1,2}",
- next : "equation"
- }],
- "equation" : [{
- token : "comment",
- regex : "%.*$"
- }, {
- token : "string",
- regex : "\\${1,2}",
- next : "start"
- }, {
- token : "constant.character.escape",
- regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
- }, {
- token : "error",
- regex : "^\\s*$",
- next : "start"
- }, {
- defaultToken : "string"
- }]
- };
- };
- oop.inherits(LatexHighlightRules, TextHighlightRules);
- exports.LatexHighlightRules = LatexHighlightRules;
- });
|