Skip to content

Commit 64325ec

Browse files
committed
Improve removeStyleTags
1 parent 79c5cc5 commit 64325ec

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changeset/shaggy-books-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"scan-chart": patch
3+
---
4+
5+
Improve removeStyleTags

src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ const allowedTags = [
194194
'uppercase',
195195
'voffset',
196196
'width',
197-
'#',
198197
]
199198
const tagPattern = allowedTags.map(tag => `\\b${tag}\\b`).join('|')
200199
/**
@@ -205,7 +204,7 @@ export function removeStyleTags(text: string) {
205204
let newText = text
206205
do {
207206
oldText = newText
208-
newText = newText.replace(new RegExp(`<\\s*\\/?\\s*(?:${tagPattern})[^>]*>`, 'gi'), '').trim()
207+
newText = newText.replace(new RegExp(`<\\s*\\/?\\s*(?:#|${tagPattern})[^>]*>`, 'gi'), '').trim()
209208
} while (newText !== oldText)
210209
return newText
211210
}

0 commit comments

Comments
 (0)