Skip to content

Commit

Permalink
[JavaScript] Fix bug when closing script tag. (sublimehq#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Smith authored and wbond committed Jan 7, 2019
1 parent d5124e6 commit 4769288
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 15 additions & 9 deletions HTML/HTML.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ variables:
| [\x{10000}-\x{EFFFF}]
)
script_close_lookahead: (?i:(?=(?:-->\s*)?</script))

contexts:
immediately-pop:
- match: ''
Expand Down Expand Up @@ -370,7 +372,7 @@ contexts:
- match: (?=\S)
embed: scope:source.js
embed_scope: source.js.embedded.html
escape: (?i)(?=(?:-->\s*)?</script)
escape: '{{script_close_lookahead}}'

script-html:
- meta_content_scope: meta.tag.script.begin.html
Expand All @@ -393,14 +395,18 @@ contexts:
script-close-tag:
- match: <!--
scope: comment.block.html punctuation.definition.comment.begin.html
- match: (?i)(?:(-->)\s*)?(</)(script)(>)
scope: meta.tag.script.end.html
captures:
1: comment.block.html punctuation.definition.comment.end.html
2: punctuation.definition.tag.begin.html
3: entity.name.tag.script.html
4: punctuation.definition.tag.end.html
pop: true
- match: '{{script_close_lookahead}}'
set:
- match: '-->'
scope: comment.block.html punctuation.definition.comment.end.html
- match: (?i:(</)(script))
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.script.html
set:
- meta_scope: meta.tag.script.end.html
- include: tag-end
- include: tag-attributes

script-common:
- include: script-type-attribute
Expand Down
5 changes: 5 additions & 0 deletions HTML/syntax_test_html.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
## ^ text.html.basic text.html.embedded.html
## ^^^^^^^^^ text.html.basic - text.html.embedded.html meta.tag.script.end

<script>42</script >
## ^^^^^^^^ meta.tag.script.begin
## ^^ source.js.embedded
## ^^^^^^^^^^ meta.tag.script.end

<script
type
=
Expand Down

0 comments on commit 4769288

Please sign in to comment.