fix: support multi-line lang attribute detection in style/script tags#16763
Open
algojogacor wants to merge 1 commit into
Open
fix: support multi-line lang attribute detection in style/script tags#16763algojogacor wants to merge 1 commit into
algojogacor wants to merge 1 commit into
Conversation
The TextMate grammar used [^>]*? to scan for lang/type attributes in style and script tags. In Oniguruma (VS Code's regex engine), this does not reliably match across newlines, causing SASS/SCSS/LESS content to be incorrectly highlighted as CSS when the lang attribute is on a different line from the opening tag. Changed [^>]*? to [\s\S]*? in all three language detection patterns to explicitly match any character including newlines. Fixes withastro#14657 - Updated astro.tmLanguage.src.yaml (source) - Updated astro.tmLanguage.json (compiled) - Added test fixture: sass-multiline.astro
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix syntax highlighting for
<style>and<script>tags when thelangortypeattribute is on a different line from the opening tag.Root Cause
The TextMate grammar regex used
[^>]*?to scan forlang/typeattributes within style/script tags. In Oniguruma (VS Code's regex engine),[^>]does not reliably match across newlines in all configurations, causing the language detection to fail when attributes span multiple lines. The content then falls back to default CSS highlighting.Changes
astro.tmLanguage.src.yaml: Changed[^>]*?→[\s\S]*?in all three language-detection patterns (JSON-LD, module/JS, and generic language)astro.tmLanguage.json: Same change in compiled grammarsass-multiline.astrocovering SCSS, LESS, SASS, and CSS with both single-line and multi-line attribute layoutsTesting
<style>tag layoutspnpm test:grammar)Related
Fixes #14657
Closes draft PR #15066 (supersedes with proper YAML source + JSON update)