[HTML] Fix scopes of stray script and style tags #3032
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR...
fixes scopes of stray script and style tags, which didn't match those from tag pairs.
avoids multi-pushing into embedded script/style syntaxes to simplify the language a bit and improve parsing performance. Closing tags are consumed within
main
context now.removes pushing
text.html.embedded.html
onto stack.a) As
main
context is pushed, it is not required for highlighting.b) The only thing we loose is the mentioned scope, which seems to be of little value.
c) It is required as change (2) would break boundaries of
text.html.embedded
otherwise.d) The less contexts HTML pushes onto stack the better it is for most possible flexibility with regards to inheritance or re-use in
heavily context aware templating syntaxes such as JSP or PHP.
e) It slightly improves parsing performance.
New
script-tag
andstyle-tag
contexts are introduced to form a kind of template which can be used by inheriting syntaxes for other custom tags.Notes:
script-close-tag
still exists, so existing syntaxes shouldn't break by this change.ASP syntax is adjusted to use the same strategy, but that's just to keep inline. It would have worked without that change, too.
This PR is inspired by vuejs/vue-syntax-highlight#216