tweak style block regexes
parent
62ddc243d3
commit
a4f5a5f287
|
@ -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[] = []
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue