diff --git a/lib/ace/mode/html_highlight_rules.js b/lib/ace/mode/html_highlight_rules.js index 26ab064e..d1220f49 100644 --- a/lib/ace/mode/html_highlight_rules.js +++ b/lib/ace/mode/html_highlight_rules.js @@ -47,6 +47,36 @@ var HtmlHighlightRules = function() { // regexp must not have capturing parentheses // regexps are ordered -> the first match is used + function string(state) { + return [ + { + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + regex : '["].*$', + next : state + "-qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + regex : "['].*$", + next : state + "-qstring" + }] + } + + function multiLineString(quote, state) { + return [{ + token : "string", + regex : ".*" + quote, + next : state + }, { + token : "string", + regex : '.+' + }] + } + this.$rules = { start : [ { token : "text", @@ -89,13 +119,7 @@ var HtmlHighlightRules = function() { }, { token : "text", regex : "\\s+" - }, { - token : "string", - regex : '".*?"' - }, { - token : "string", - regex : "'.*?'" - } ], + }].concat(string("script")), css : [ { token : "text", @@ -107,13 +131,7 @@ var HtmlHighlightRules = function() { }, { token : "text", regex : "\\s+" - }, { - token : "string", - regex : '".*?"' - }, { - token : "string", - regex : "'.*?'" - } ], + }].concat(string("css")), tag : [ { token : "text", @@ -125,14 +143,15 @@ var HtmlHighlightRules = function() { }, { token : "text", regex : "\\s+" - }, { - token : "string", - regex : '".*?"' - }, { - token : "string", - regex : "'.*?'" - } ], - + }].concat(string("tag")), + + "css-qstring": multiLineString("'", "css"), + "css-qqstring": multiLineString('"', "css"), + "script-qstring": multiLineString("'", "script"), + "script-qqstring": multiLineString('"', "script"), + "tag-qstring": multiLineString("'", "tag"), + "tag-qqstring": multiLineString('"', "tag"), + cdata : [ { token : "text", regex : "\\]\\]>", diff --git a/lib/ace/mode/html_tokenizer_test.js b/lib/ace/mode/html_tokenizer_test.js index 084f9642..45c978e9 100644 --- a/lib/ace/mode/html_tokenizer_test.js +++ b/lib/ace/mode/html_tokenizer_test.js @@ -66,7 +66,23 @@ module.exports = { assert.equal("text", tokens[8].type); assert.equal("keyword", tokens[9].type); assert.equal("text", tokens[10].type); - } + }, + + "test: tokenize multiline attribute value with double quotes": function() { + var line1 = this.tokenizer.getLineTokens('', line1.state).tokens; + assert.equal(t1[t1.length-1].type, "string"); + assert.equal(t2[0].type, "string"); + }, + + "test: tokenize multiline attribute value with single quotes": function() { + var line1 = this.tokenizer.getLineTokens('', line1.state).tokens; + assert.equal(t1[t1.length-1].type, "string"); + assert.equal(t2[0].type, "string"); + } }; }); diff --git a/lib/ace/mode/xml_highlight_rules.js b/lib/ace/mode/xml_highlight_rules.js index f8f6fe6c..dc759c34 100644 --- a/lib/ace/mode/xml_highlight_rules.js +++ b/lib/ace/mode/xml_highlight_rules.js @@ -82,11 +82,37 @@ var XmlHighlightRules = function() { }, { token : "string", regex : '".*?"' + }, { + token : "string", // multi line string start + regex : '["].*$', + next : "qqstring" }, { token : "string", regex : "'.*?'" - } ], + }, { + token : "string", // multi line string start + regex : "['].*$", + next : "qstring" + }], + qstring: [{ + token : "string", + regex : ".*'", + next : "tag" + }, { + token : "string", + regex : '.+' + }], + + qqstring: [{ + token : "string", + regex : ".*\"", + next : "tag" + }, { + token : "string", + regex : '.+' + }], + cdata : [ { token : "text", regex : "\\]\\]>",