@@ -20,10 +20,12 @@ let htmlScriptTypes = [
20
20
]
21
21
22
22
let text = { text : { match : / [ ^ ] / , lineBreaks : true } }
23
+ let styledCssBlockStart = { match : / c s s (?: \. r e s o l v e | \. g l o b a l ) ? ` / , push : 'styledCssBlock' }
23
24
24
25
let states = {
25
26
main : {
26
27
cssBlockStart : { match : / < s t y l e (? = [ > \s ] ) / , push : 'cssBlock' } ,
28
+ cssStyledBlockStart : styledCssBlockStart ,
27
29
jsBlockStart : { match : '<script' , push : 'jsBlock' } ,
28
30
...text ,
29
31
} ,
@@ -35,7 +37,13 @@ let states = {
35
37
interp : { match : '{' , push : 'interp' } ,
36
38
...text ,
37
39
} ,
40
+ styledCssBlock : {
41
+ cssBlockEnd : { match : '`' , pop : 1 } ,
42
+ jsBlockStart : { match : '${' , push : 'jsInterp' } ,
43
+ ...text ,
44
+ } ,
38
45
jsBlock : {
46
+ cssStyledBlockStart : styledCssBlockStart ,
39
47
scriptStart : { match : '>' , next : 'script' } ,
40
48
jsBlockEnd : { match : '/>' , pop : 1 } ,
41
49
langAttrStartDouble : { match : 'lang="' , push : 'langAttrDouble' } ,
@@ -47,6 +55,12 @@ let states = {
47
55
interp : { match : '{' , push : 'interp' } ,
48
56
...text ,
49
57
} ,
58
+ jsInterp : {
59
+ cssStyledBlockStart : styledCssBlockStart ,
60
+ interp : { match : '{' , push : 'jsInterp' } ,
61
+ jsBlockEnd : { match : '}' , pop : 1 } ,
62
+ ...text ,
63
+ } ,
50
64
interp : {
51
65
interp : { match : '{' , push : 'interp' } ,
52
66
end : { match : '}' , pop : 1 } ,
@@ -154,7 +168,7 @@ export function getLanguageBoundaries(
154
168
let lexer = defaultType === 'none' ? vueLexer : defaultLexer
155
169
lexer . reset ( text )
156
170
157
- let type = defaultType
171
+ let types = [ defaultType ]
158
172
let boundaries : LanguageBoundary [ ] = [
159
173
{ type : defaultType , range : { start : { line : 0 , character : 0 } , end : undefined } } ,
160
174
]
@@ -168,12 +182,13 @@ export function getLanguageBoundaries(
168
182
if ( ! boundaries [ boundaries . length - 1 ] . range . end ) {
169
183
boundaries [ boundaries . length - 1 ] . range . end = position
170
184
}
171
- type = token . type . replace ( / B l o c k S t a r t $ / , '' )
172
- boundaries . push ( { type, range : { start : position , end : undefined } } )
185
+ types . push ( token . type . replace ( / (?: [ A - Z ] . + ? ) ? B l o c k S t a r t $ / , '' ) )
186
+ boundaries . push ( { type : types [ types . length - 1 ] , range : { start : position , end : undefined } } )
173
187
} else if ( token . type . endsWith ( 'BlockEnd' ) ) {
174
188
let position = indexToPosition ( text , offset )
189
+ types . pop ( )
175
190
boundaries [ boundaries . length - 1 ] . range . end = position
176
- boundaries . push ( { type : defaultType , range : { start : position , end : undefined } } )
191
+ boundaries . push ( { type : types [ types . length - 1 ] , range : { start : position , end : undefined } } )
177
192
} else if ( token . type === 'lang' ) {
178
193
boundaries [ boundaries . length - 1 ] . type = token . text
179
194
} else if ( token . type === 'type' && htmlScriptTypes . includes ( token . text ) ) {
0 commit comments