-
Notifications
You must be signed in to change notification settings - Fork 597
[HTML] Tweak embedded script/style code boundaries and comment indentation #4020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HTML] Tweak embedded script/style code boundaries and comment indentation #4020
Conversation
This commit...
1. consumes
a) any trailing whitespace until end of line after opening script/style tags
or optionally following `<!--` punctuation.
b) any leading whitespace in front of closing script/style tags or optionally
preceded `-->` punctuation.
to not apply embedded syntax's scope after standalone opening or in front of
standalone closing tags.
This change makes sure to ...
a) always apply HTML specific indentation rules to
enclosing script/style tags or comment punctuation.
b) apply custom background highlighting of embedded syntaxes only on full
lines, but not after or in front of standalone tags.
2. modifies indentation rules for HTML comments to remove indentation
of comments' content.
keith-hall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always liked having the background coloring of embedded code start immediately after the open tag and end right before the close tag, but agree that it makes sense for indentation to leave those whitespaces unscoped. And that adding meta scopes just to satisfy me likely isn't worth the maintenance burden. Approved
|
You prefer it even if those tags are on a separate line? The idea behind this change besides indentation is better visual appearance of embedded contents' background, which is inspired by how fenced codeblocks are handled in Markdown. With regards to maintanance - it's rather a compatibility issue as adding meta scopes would affect various 3rd-party packages.
|
I do, but I accept that maybe I'm the odd one out here. I find it draws my eye exactly to the tag boundaries where the embedding really starts and ends.
Upvoted 🙂 |
d7e884b to
4dc9b5f
Compare
|
Sorry, added and pushed the PHP fix in wrong branch. Reverted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually kind of like this, even if it's not 100% accurate for the start and end of the language scopes. 😅
required by (PR sublimehq/Packages#4020)
Be a bit more lazy as scope changed from `meta.string.js` to `meta.string.template.js` in PR sublimehq/Packages#4020.
This commit backports sublimehq/Packages#4020 to ensure related indentation rules are correctly applied for ST4181+. Scope changes are backported primarily due to their effect on syntax tests and the goal to avoid a need to ship dedicated ST4181+ releases just due to failing syntax tests, which do otherwise not have any significant effect on highlighting.
In order to properly handle `<template>` tag indentation in combination with script/style comment handling dedicated indentation rules are required. This commit therefore backports and adjusts indentation rules from sublimehq/Packages#4020
This PR...
teaches HTML to consume
<!--punctuation.-->punctuation.to not apply embedded syntax's scope after standalone opening or in front of standalone closing tags.
This change makes sure to ...
always apply HTML specific indentation rules to enclosing script/style tags or comment punctuation.
apply custom background highlighting of embedded syntaxes only on full lines, but not after or in front of standalone tags.
modifies indentation rules for HTML comments to ignore indentation of comments' content.
This is primarily required to correctly handle indentation of embedded script/style source code, if it is enclosed in HTML comments. In such cases, additional indentation level is probably undesirable.
Highlighting changes
Before:
After:
Background in front of closing
</script>no longer has customsource.js.embeddedbackground.However everything between tags is scoped
source.<name>.embeddedif tags and code exist in same line(s).