@@ -126,7 +126,8 @@ function fixLocations(node: ParentNode, ctx: Context): void {
126126 walk (
127127 node ,
128128 ctx . code ,
129- ( node ) => {
129+ // eslint-disable-next-line complexity -- X(
130+ ( node , parent ) => {
130131 if ( node . type === "frontmatter" ) {
131132 start = node . position ! . start . offset = tokenIndex (
132133 ctx ,
@@ -161,12 +162,28 @@ function fixLocations(node: ParentNode, ctx: Context): void {
161162 node . position ! . start . offset = tokenIndex ( ctx , "<!--" , start )
162163 start = getCommentEndOffset ( node , ctx )
163164 } else if ( node . type === "text" ) {
164- start = node . position ! . start . offset = tokenIndex (
165- ctx ,
166- node . value ,
167- start ,
168- )
169- start += node . value . length
165+ if (
166+ parent . type === "element" &&
167+ ( parent . name === "script" || parent . name === "style" )
168+ ) {
169+ node . position ! . start . offset = start
170+ start = ctx . code . indexOf ( `</${ parent . name } ` , start )
171+ if ( start < 0 ) {
172+ start = ctx . code . length
173+ }
174+ // Workaround for escape bugs
175+ node . value = ctx . code . slice (
176+ node . position ! . start . offset ,
177+ start ,
178+ )
179+ } else {
180+ start = node . position ! . start . offset = tokenIndex (
181+ ctx ,
182+ node . value ,
183+ start ,
184+ )
185+ start += node . value . length
186+ }
170187 } else if ( node . type === "expression" ) {
171188 start = node . position ! . start . offset = tokenIndex (
172189 ctx ,
0 commit comments