diff --git a/grammars/Handlebars.json b/grammars/Handlebars.json
index 2a5ff3c..19c47b5 100644
--- a/grammars/Handlebars.json
+++ b/grammars/Handlebars.json
@@ -693,19 +693,13 @@
]
},
"inline_script": {
- "begin": "(?:^\\s+)?(<)((?i:script))\\b(?:.*(type)=([\"'](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)[\"']))(?![^>]*/>)",
+ "begin": "(?:^\\s+)?(<)((?i:script))\\b(?=[^>]*\\stype=[\"'](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)[\"'])(?![^>]*/>)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.html"
},
"2": {
"name": "entity.name.tag.script.html"
- },
- "3": {
- "name": "entity.other.attribute-name.html"
- },
- "4": {
- "name": "string.quoted.double.html"
}
},
"end": "(?<=(script|SCRIPT))(>)(?:\\s*\\n)?",
diff --git a/grammars/Handlebars.sublime-syntax b/grammars/Handlebars.sublime-syntax
index ba2d35d..9fe0c61 100644
--- a/grammars/Handlebars.sublime-syntax
+++ b/grammars/Handlebars.sublime-syntax
@@ -336,12 +336,10 @@ contexts:
- match: <
scope: invalid.illegal.bad-angle-bracket.html
inline_script:
- - match: '(?:^\s+)?(<)((?i:script))\b(?:.*(type)=(["''](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)["'']))(?![^>]*/>)'
+ - match: '(?:^\s+)?(<)((?i:script))\b(?=[^>]*\stype=(["''](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)["'']))(?![^>]*/>)'
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.script.html
- 3: entity.other.attribute-name.html
- 4: string.quoted.double.html
push:
- meta_scope: source.handlebars.embedded.html
- match: (?<=(script|SCRIPT))(>)(?:\s*\n)?
diff --git a/grammars/Handlebars.tmLanguage b/grammars/Handlebars.tmLanguage
index 9d0c1f5..c09e0c8 100644
--- a/grammars/Handlebars.tmLanguage
+++ b/grammars/Handlebars.tmLanguage
@@ -928,7 +928,7 @@
inline_script
begin
- (?:^\s+)?(<)((?i:script))\b(?:.*(type)=(["'](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)["']))(?![^>]*/>)
+ (?:^\s+)?(<)((?i:script))\b(?=[^>]*\stype=(["'](?:text/x-handlebars-template|text/x-handlebars|text/template|x-tmpl-handlebars)["']))(?![^>]*/>)
beginCaptures
1
@@ -941,16 +941,6 @@
name
entity.name.tag.script.html
- 3
-
- name
- entity.other.attribute-name.html
-
- 4
-
- name
- string.quoted.double.html
-
end
(?<=</(script|SCRIPT))(>)(?:\s*\n)?
diff --git a/test/embedding.test.js b/test/embedding.test.js
index d6d2f65..808e138 100644
--- a/test/embedding.test.js
+++ b/test/embedding.test.js
@@ -54,6 +54,36 @@ test('inline ';
+ await assertScope(src, 'id', 'entity.other.attribute-name.id.html');
+ await assertScope(src, 't', 'string.quoted.double.handlebars');
+ // The script body is still recognised as an embedded handlebars template.
+ await assertScope(src, 'script', 'entity.name.tag.script.html');
+});
+
+test('#58: id attribute after type is still highlighted (no regression)', async () => {
+ const src = '';
+ await assertScope(src, 'id', 'entity.other.attribute-name.id.html');
+ await assertScope(src, 't', 'string.quoted.double.handlebars');
+});
+
+test('#58: a plain text/javascript script is NOT a handlebars template', async () => {
+ // The lookahead must not fire for a non-handlebars type; the body should fall
+ // through to source.js, not the handlebars embedding.
+ const src = '