diff --git a/components/prism-haml.js b/components/prism-haml.js index 69c2d6fd56..d1bc7ef336 100644 --- a/components/prism-haml.js +++ b/components/prism-haml.js @@ -95,7 +95,10 @@ pattern: /^#\{|\}$/, alias: 'punctuation' }, - rest: Prism.languages.ruby + 'ruby': { + pattern: /[\s\S]+/, + inside: Prism.languages.ruby + } } }, 'punctuation': { @@ -131,7 +134,11 @@ pattern: /^:[\w-]+/, alias: 'variable' }, - rest: Prism.languages[filter.language] + 'text': { + pattern: /[\s\S]+/, + alias: [filter.language, 'language-' + filter.language], + inside: Prism.languages[filter.language] + } } }; } diff --git a/components/prism-haml.min.js b/components/prism-haml.min.js index 24b4db4a50..cdde71d4ec 100644 --- a/components/prism-haml.min.js +++ b/components/prism-haml.min.js @@ -1 +1 @@ -!function(e){e.languages.haml={"multiline-comment":{pattern:/((?:^|\r?\n|\r)([\t ]*))(?:\/|-#).*(?:(?:\r?\n|\r)\2[\t ].+)*/,lookbehind:!0,alias:"comment"},"multiline-code":[{pattern:/((?:^|\r?\n|\r)([\t ]*)(?:[~-]|[&!]?=)).*,[\t ]*(?:(?:\r?\n|\r)\2[\t ].*,[\t ]*)*(?:(?:\r?\n|\r)\2[\t ].+)/,lookbehind:!0,inside:e.languages.ruby},{pattern:/((?:^|\r?\n|\r)([\t ]*)(?:[~-]|[&!]?=)).*\|[\t ]*(?:(?:\r?\n|\r)\2[\t ].*\|[\t ]*)*/,lookbehind:!0,inside:e.languages.ruby}],filter:{pattern:/((?:^|\r?\n|\r)([\t ]*)):[\w-]+(?:(?:\r?\n|\r)(?:\2[\t ].+|\s*?(?=\r?\n|\r)))+/,lookbehind:!0,inside:{"filter-name":{pattern:/^:[\w-]+/,alias:"variable"}}},markup:{pattern:/((?:^|\r?\n|\r)[\t ]*)<.+/,lookbehind:!0,inside:e.languages.markup},doctype:{pattern:/((?:^|\r?\n|\r)[\t ]*)!!!(?: .+)?/,lookbehind:!0},tag:{pattern:/((?:^|\r?\n|\r)[\t ]*)[%.#][\w\-#.]*[\w\-](?:\([^)]+\)|\{(?:\{[^}]+\}|[^{}])+\}|\[[^\]]+\])*[\/<>]*/,lookbehind:!0,inside:{attributes:[{pattern:/(^|[^#])\{(?:\{[^}]+\}|[^{}])+\}/,lookbehind:!0,inside:e.languages.ruby},{pattern:/\([^)]+\)/,inside:{"attr-value":{pattern:/(=\s*)(?:"(?:\\.|[^\\"\r\n])*"|[^)\s]+)/,lookbehind:!0},"attr-name":/[\w:-]+(?=\s*!?=|\s*[,)])/,punctuation:/[=(),]/}},{pattern:/\[[^\]]+\]/,inside:e.languages.ruby}],punctuation:/[<>]/}},code:{pattern:/((?:^|\r?\n|\r)[\t ]*(?:[~-]|[&!]?=)).+/,lookbehind:!0,inside:e.languages.ruby},interpolation:{pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"},rest:e.languages.ruby}},punctuation:{pattern:/((?:^|\r?\n|\r)[\t ]*)[~=\-&!]+/,lookbehind:!0}};for(var t=["css",{filter:"coffee",language:"coffeescript"},"erb","javascript","less","markdown","ruby","scss","textile"],n={},r=0,a=t.length;r]*/,lookbehind:!0,inside:{attributes:[{pattern:/(^|[^#])\{(?:\{[^}]+\}|[^{}])+\}/,lookbehind:!0,inside:e.languages.ruby},{pattern:/\([^)]+\)/,inside:{"attr-value":{pattern:/(=\s*)(?:"(?:\\.|[^\\"\r\n])*"|[^)\s]+)/,lookbehind:!0},"attr-name":/[\w:-]+(?=\s*!?=|\s*[,)])/,punctuation:/[=(),]/}},{pattern:/\[[^\]]+\]/,inside:e.languages.ruby}],punctuation:/[<>]/}},code:{pattern:/((?:^|\r?\n|\r)[\t ]*(?:[~-]|[&!]?=)).+/,lookbehind:!0,inside:e.languages.ruby},interpolation:{pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"},ruby:{pattern:/[\s\S]+/,inside:e.languages.ruby}}},punctuation:{pattern:/((?:^|\r?\n|\r)[\t ]*)[~=\-&!]+/,lookbehind:!0}};for(var n=["css",{filter:"coffee",language:"coffeescript"},"erb","javascript","less","markdown","ruby","scss","textile"],t={},r=0,a=n.length;r"] + ["text", [ + ["operator", "<"], + ["operator", "%"], + ["operator", "="], + " render ", + ["variable", "@products"], + ["operator", "||"], + ["string", ["\"empty_list\""]], + ["operator", "%"], + ["operator", ">"] + ]] ]], ["punctuation", "~"], ["filter-erb", [ ["filter-name", ":erb"], - ["operator", "<"], - ["operator", "%"], - ["operator", "="], - " render ", - ["variable", "@products"], - ["operator", "||"], - ["string", [ - "\"empty_list\"" - ]], - ["delimiter", "%>"] + ["text", [ + ["operator", "<"], + ["operator", "%"], + ["operator", "="], + " render ", + ["variable", "@products"], + ["operator", "||"], + ["string", ["\"empty_list\""]], + ["delimiter", "%>"] + ]] ]] ] diff --git a/tests/languages/haml/interpolation_feature.test b/tests/languages/haml/interpolation_feature.test index ed13c87a81..17d00e6924 100644 --- a/tests/languages/haml/interpolation_feature.test +++ b/tests/languages/haml/interpolation_feature.test @@ -6,16 +6,20 @@ [ ["interpolation", [ ["delimiter", "#{"], - ["number", "42"], + ["ruby", [ + ["number", "42"] + ]], ["delimiter", "}"] ]], ["interpolation", [ ["delimiter", "#{"], - ["string", ["\"foobar\""]], + ["ruby", [ + ["string", ["\"foobar\""]] + ]], ["delimiter", "}"] ]] ] ---------------------------------------------------- -Checks for interpolation in plain text. \ No newline at end of file +Checks for interpolation in plain text. diff --git a/tests/languages/haml/tag_feature.test b/tests/languages/haml/tag_feature.test index a1e0c0de8d..09f967f5e7 100644 --- a/tests/languages/haml/tag_feature.test +++ b/tests/languages/haml/tag_feature.test @@ -42,11 +42,14 @@ ["attributes", [ ["punctuation", "{"], ["symbol", ":type"], - ["operator", "="], ["operator", ">"], + ["operator", "="], + ["operator", ">"], ["string", ["\"text/javascript\""]], ["punctuation", ","], + ["symbol", ":src"], - ["operator", "="], ["operator", ">"], + ["operator", "="], + ["operator", ">"], ["string", [ "\"javascripts/script_", ["interpolation", [ @@ -65,7 +68,8 @@ ["attributes", [ ["punctuation", "{"], ["symbol", ":id"], - ["operator", "="], ["operator", ">"], + ["operator", "="], + ["operator", ">"], ["punctuation", "["], ["variable", "@item"], ["punctuation", "."], @@ -88,8 +92,8 @@ ["attr-value", "@title"], ["attr-name", "href"], ["punctuation", "="], - ["attr-value", "href"], - ["punctuation", ")"] + ["attr-value", "href"], + ["punctuation", ")"] ]] ]], ["tag", [ @@ -138,7 +142,8 @@ ["attributes", [ ["punctuation", "{"], ["symbol", ":id"], - ["operator", "="], ["operator", ">"], + ["operator", "="], + ["operator", ">"], ["variable", "@article"], ["punctuation", "."], "number", @@ -150,8 +155,14 @@ ["tag", [".item"]], ["tag", ["%br/"]], - ["tag", ["%blockquote", ["punctuation", "<"]]], - ["tag", ["%img", ["punctuation", ">"]]] + ["tag", [ + "%blockquote", + ["punctuation", "<"] + ]], + ["tag", [ + "%img", + ["punctuation", ">"] + ]] ] ---------------------------------------------------- diff --git a/tests/languages/javascript+haml/javascript_inclusion.test b/tests/languages/javascript+haml/javascript_inclusion.test index 2420e60f12..2faae7b676 100644 --- a/tests/languages/javascript+haml/javascript_inclusion.test +++ b/tests/languages/javascript+haml/javascript_inclusion.test @@ -10,15 +10,19 @@ [ ["filter-javascript", [ ["filter-name", ":javascript"], - ["number", "0xBadFace"] + ["text", [ + ["number", "0xBadFace"] + ]] ]], ["punctuation", "~"], ["filter-javascript", [ ["filter-name", ":javascript"], - ["number", "0xBadFace"] + ["text", [ + ["number", "0xBadFace"] + ]] ]] ] ---------------------------------------------------- -Checks for JavaScript filter in Haml. The tilde serves only as a separator. \ No newline at end of file +Checks for JavaScript filter in Haml. The tilde serves only as a separator. diff --git a/tests/languages/less+haml/less_inclusion.test b/tests/languages/less+haml/less_inclusion.test index fffe2ca74e..ae8db1a307 100644 --- a/tests/languages/less+haml/less_inclusion.test +++ b/tests/languages/less+haml/less_inclusion.test @@ -10,23 +10,27 @@ [ ["filter-less", [ ["filter-name", ":less"], - ["selector", [".foo"]], - ["punctuation", "{"], - ["mixin-usage", ".bar"], - ["punctuation", ";"], - ["punctuation", "}"] + ["text", [ + ["selector", [".foo"]], + ["punctuation", "{"], + ["mixin-usage", ".bar"], + ["punctuation", ";"], + ["punctuation", "}"] + ]] ]], ["punctuation", "~"], ["filter-less", [ ["filter-name", ":less"], - ["selector", [".foo"]], - ["punctuation", "{"], - ["mixin-usage", ".bar"], - ["punctuation", ";"], - ["punctuation", "}"] + ["text", [ + ["selector", [".foo"]], + ["punctuation", "{"], + ["mixin-usage", ".bar"], + ["punctuation", ";"], + ["punctuation", "}"] + ]] ]] ] ---------------------------------------------------- -Checks for Less filter in Haml. The tilde serves only as a separator. \ No newline at end of file +Checks for Less filter in Haml. The tilde serves only as a separator. diff --git a/tests/languages/markdown+haml/markdown_inclusion.test b/tests/languages/markdown+haml/markdown_inclusion.test index 4a75fa9cc2..c0b9224640 100644 --- a/tests/languages/markdown+haml/markdown_inclusion.test +++ b/tests/languages/markdown+haml/markdown_inclusion.test @@ -10,18 +10,22 @@ [ ["filter-markdown", [ ["filter-name", ":markdown"], - ["title", [ - ["punctuation", "#"], - " Title 1" + ["text", [ + ["title", [ + ["punctuation", "#"], + " Title 1" + ]] ]] ]], ["punctuation", "~"], ["filter-markdown", [ ["filter-name", ":markdown"], - ["title", [ - ["punctuation", "#"], - " Title 1" - ]] + ["text", [ + ["title", [ + ["punctuation", "#"], + " Title 1" + ]] + ]] ]] ] @@ -29,4 +33,4 @@ Checks for Markdown filter in Haml. The tilde serves only as a separator. Indentation is intentionally less than 1 tab, otherwise markdown is -interpreted as code. \ No newline at end of file +interpreted as code. diff --git a/tests/languages/ruby+haml/ruby_inclusion.test b/tests/languages/ruby+haml/ruby_inclusion.test index dc1cd7cb25..f1bbc0f006 100644 --- a/tests/languages/ruby+haml/ruby_inclusion.test +++ b/tests/languages/ruby+haml/ruby_inclusion.test @@ -14,45 +14,47 @@ [ ["filter-ruby", [ ["filter-name", ":ruby"], - - ["keyword", "def"], - ["method-definition", [ - ["function", "circumference"] - ]], - - ["constant", "Math"], - ["punctuation", ":"], - ["punctuation", ":"], - ["constant", "PI"], - ["operator", "*"], - " radius ", - ["operator", "*"], - ["operator", "*"], - ["number", "2"], - - ["keyword", "end"] + ["text", [ + ["keyword", "def"], + ["method-definition", [ + ["function", "circumference"] + ]], + + ["constant", "Math"], + ["punctuation", ":"], + ["punctuation", ":"], + ["constant", "PI"], + ["operator", "*"], + " radius ", + ["operator", "*"], + ["operator", "*"], + ["number", "2"], + + ["keyword", "end"] + ]] ]], ["punctuation", "~"], ["filter-ruby", [ ["filter-name", ":ruby"], - - ["keyword", "def"], - ["method-definition", [ - ["function", "circumference"] - ]], - - ["constant", "Math"], - ["punctuation", ":"], - ["punctuation", ":"], - ["constant", "PI"], - ["operator", "*"], - " radius ", - ["operator", "*"], - ["operator", "*"], - ["number", "2"], - - ["keyword", "end"] + ["text", [ + ["keyword", "def"], + ["method-definition", [ + ["function", "circumference"] + ]], + + ["constant", "Math"], + ["punctuation", ":"], + ["punctuation", ":"], + ["constant", "PI"], + ["operator", "*"], + " radius ", + ["operator", "*"], + ["operator", "*"], + ["number", "2"], + + ["keyword", "end"] + ]] ]] ] diff --git a/tests/languages/scss+haml/scss_inclusion.test b/tests/languages/scss+haml/scss_inclusion.test index b2c545c45c..ab69f07839 100644 --- a/tests/languages/scss+haml/scss_inclusion.test +++ b/tests/languages/scss+haml/scss_inclusion.test @@ -14,27 +14,37 @@ [ ["filter-scss", [ ["filter-name", ":scss"], - ["selector", ["#main "]], - ["punctuation", "{"], - ["property", ["width"]], - ["punctuation", ":"], - ["variable", "$width"], - ["punctuation", ";"], - ["punctuation", "}"] + ["text", [ + ["selector", ["#main "]], + ["punctuation", "{"], + + ["property", ["width"]], + ["punctuation", ":"], + ["variable", "$width"], + ["punctuation", ";"], + + ["punctuation", "}"] + ]] ]], + ["punctuation", "~"], + ["filter-scss", [ ["filter-name", ":scss"], - ["selector", ["#main "]], - ["punctuation", "{"], - ["property", ["width"]], - ["punctuation", ":"], - ["variable", "$width"], - ["punctuation", ";"], - ["punctuation", "}"] + ["text", [ + ["selector", ["#main "]], + ["punctuation", "{"], + + ["property", ["width"]], + ["punctuation", ":"], + ["variable", "$width"], + ["punctuation", ";"], + + ["punctuation", "}"] + ]] ]] ] ---------------------------------------------------- -Checks for CSS filter in Haml. The tilde serves only as a separator. \ No newline at end of file +Checks for CSS filter in Haml. The tilde serves only as a separator. diff --git a/tests/languages/textile+haml/textile_inclusion.test b/tests/languages/textile+haml/textile_inclusion.test index c6474027ef..2bdd989b44 100644 --- a/tests/languages/textile+haml/textile_inclusion.test +++ b/tests/languages/textile+haml/textile_inclusion.test @@ -10,41 +10,41 @@ [ ["filter-textile", [ ["filter-name", ":textile"], - - ["tag", [ + ["text", [ ["tag", [ - ["punctuation", "<"], - "div" + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] ]], - ["punctuation", ">"] - ]], - ["tag", [ ["tag", [ - ["punctuation", ""] + ["tag", [ + ["punctuation", ""] + ]] ]] ]], - ["punctuation", "~"], - ["filter-textile", [ ["filter-name", ":textile"], - - ["tag", [ + ["text", [ ["tag", [ - ["punctuation", "<"], - "div" + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] ]], - ["punctuation", ">"] - ]], - ["tag", [ ["tag", [ - ["punctuation", ""] + ["tag", [ + ["punctuation", ""] + ]] ]] ]] ]