From 4b398798c0c43c5aa13cfa804a073fe0bd431ba3 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 22 Jun 2013 22:38:54 +0400 Subject: [PATCH] highlight escapes in sh mode --- lib/ace/mode/sh_highlight_rules.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/ace/mode/sh_highlight_rules.js b/lib/ace/mode/sh_highlight_rules.js index a73efb5e..d9ed5600 100644 --- a/lib/ace/mode/sh_highlight_rules.js +++ b/lib/ace/mode/sh_highlight_rules.js @@ -77,12 +77,28 @@ var ShHighlightRules = function() { var func = "(?:" + variableName + "\\s*\\(\\))"; this.$rules = { - "start" : [ { + "start" : [{ + token : "constant", + regex : /\\./ + }, { token : ["text", "comment"], regex : /(^|\s)(#.*)$/ }, { - token : "string", // " string - regex : '"(?:[^\\\\]|\\\\.)*?"' + token : "string", + regex : '"', + push : [{ + token : "constant.language.escape", + regex : /\\(?:[$abeEfnrtv\\'"]|x[a-fA-F\d]{1,2}|u[a-fA-F\d]{4}([a-fA-F\d]{4})?|c.|\d{1,3})/ + }, { + token : "constant", + regex : /\$\w+/ + }, { + token : "string", + regex : '"', + next: "pop" + }, { + defaultToken: "string" + }] }, { token : "variable.language", regex : builtinVariable @@ -97,7 +113,7 @@ var ShHighlightRules = function() { regex : fileDescriptor }, { token : "string", // ' string - regex : "'(?:[^\\\\]|\\\\.)*?'" + start : "'", end : "'" }, { token : "constant.numeric", // float regex : floatNumber @@ -118,6 +134,8 @@ var ShHighlightRules = function() { regex : "[\\]\\)\\}]" } ] }; + + this.normalizeRules(); }; oop.inherits(ShHighlightRules, TextHighlightRules);