tweak style block regexes

master
Brad Cornes 2021-09-29 16:38:23 +01:00
parent 62ddc243d3
commit a4f5a5f287
2 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ export function getLanguageBoundaries(state: State, doc: TextDocument): Language
if (isHtmlDoc(state, doc) || isJsDoc(state, doc) || isSvelteDoc(doc)) { if (isHtmlDoc(state, doc) || isJsDoc(state, doc) || isSvelteDoc(doc)) {
let text = doc.getText() let text = doc.getText()
let styleBlocks = findAll( let styleBlocks = findAll(
/(?<open><style(?:\s[^>]*[^\/]>|>|[^\/]>)).*?(?<close><\/style>|$)/gis, /(?<open><style(?:\s[^>]*[^\/]>|\s*>)).*?(?<close><\/style>|$)/gis,
text text
) )
let htmlRanges: Range[] = [] let htmlRanges: Range[] = []

View File

@ -44,7 +44,7 @@ export function isInsideTag(str: string, tag: string | string[]): boolean {
let close = 0 let close = 0
let match: RegExpExecArray let match: RegExpExecArray
let tags = Array.isArray(tag) ? tag : [tag] let tags = Array.isArray(tag) ? tag : [tag]
let regex = new RegExp(`<(?<slash>/?)(?:${tags.join('|')})(?:\\s[^>]*[^\/]>|>|[^\/]>)`, 'ig') let regex = new RegExp(`<(?<slash>/?)(?:${tags.join('|')})(?:\\s[^>]*[^\/]>|\\s*>)`, 'ig')
while ((match = regex.exec(str)) !== null) { while ((match = regex.exec(str)) !== null) {
if (match.groups.slash) { if (match.groups.slash) {
close += 1 close += 1