@@ -7,7 +7,16 @@ import moo from 'moo'
77import Cache from 'tmp-cache'
88import { getTextWithoutComments } from './doc'
99
10- export type LanguageBoundary = { type : 'html' | 'js' | 'css' | string ; range : Range }
10+ export type LanguageBoundary = { type : 'html' | 'js' | 'css' | ( string & { } ) ; range : Range }
11+
12+ let htmlScriptTypes = [
13+ // https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html#option-1-use-script-tag
14+ 'text/html' ,
15+ // https://vuejs.org/guide/essentials/component-basics.html#dom-template-parsing-caveats
16+ 'text/x-template' ,
17+ // https://github.com/tailwindlabs/tailwindcss-intellisense/issues/722
18+ 'text/x-handlebars-template' ,
19+ ]
1120
1221let text = { text : { match : / [ ^ ] / , lineBreaks : true } }
1322
@@ -30,6 +39,8 @@ let states = {
3039 jsBlockEnd : { match : '/>' , pop : 1 } ,
3140 langAttrStartDouble : { match : 'lang="' , push : 'langAttrDouble' } ,
3241 langAttrStartSingle : { match : "lang='" , push : 'langAttrSingle' } ,
42+ typeAttrStartDouble : { match : 'type="' , push : 'typeAttrDouble' } ,
43+ typeAttrStartSingle : { match : "type='" , push : 'typeAttrSingle' } ,
3344 attrStartDouble : { match : '"' , push : 'attrDouble' } ,
3445 attrStartSingle : { match : "'" , push : 'attrSingle' } ,
3546 interp : { match : '{' , push : 'interp' } ,
@@ -48,6 +59,14 @@ let states = {
4859 langAttrEnd : { match : "'" , pop : 1 } ,
4960 lang : { match : / [ ^ ' ] + / , lineBreaks : true } ,
5061 } ,
62+ typeAttrDouble : {
63+ langAttrEnd : { match : '"' , pop : 1 } ,
64+ type : { match : / [ ^ " ] + / , lineBreaks : true } ,
65+ } ,
66+ typeAttrSingle : {
67+ langAttrEnd : { match : "'" , pop : 1 } ,
68+ type : { match : / [ ^ ' ] + / , lineBreaks : true } ,
69+ } ,
5170 attrDouble : {
5271 attrEnd : { match : '"' , pop : 1 } ,
5372 ...text ,
@@ -156,6 +175,8 @@ export function getLanguageBoundaries(
156175 boundaries . push ( { type : defaultType , range : { start : position , end : undefined } } )
157176 } else if ( token . type === 'lang' ) {
158177 boundaries [ boundaries . length - 1 ] . type = token . text
178+ } else if ( token . type === 'type' && htmlScriptTypes . includes ( token . text ) ) {
179+ boundaries [ boundaries . length - 1 ] . type = 'html'
159180 }
160181 }
161182 offset += token . text . length
0 commit comments