aboutsummaryrefslogtreecommitdiff
path: root/src/services/html_converter/utility.service.js
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2023-01-22 09:34:01 -0500
committertusooa <tusooa@kazv.moe>2023-01-22 09:34:01 -0500
commitb1e75c25bd50180e715afde70c6e659e7509a3f3 (patch)
treef5d529d81b4bfa98009e39e7c37d64132d316592 /src/services/html_converter/utility.service.js
parent6649baaac94348bbf09015eeb2c8eeea714096db (diff)
parent0d6435261ef3e91c06fe34cc8bf72ff1b30078c2 (diff)
Merge remote-tracking branch 'upstream/develop' into birthdays
Diffstat (limited to 'src/services/html_converter/utility.service.js')
-rw-r--r--src/services/html_converter/utility.service.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/services/html_converter/utility.service.js b/src/services/html_converter/utility.service.js
index 583ccca5..f1042971 100644
--- a/src/services/html_converter/utility.service.js
+++ b/src/services/html_converter/utility.service.js
@@ -16,7 +16,7 @@ export const getTagName = (tag) => {
* @return {Object} - map of attributes key = attribute name, value = attribute value
* attributes without values represented as boolean true
*/
-export const getAttrs = tag => {
+export const getAttrs = (tag, filter) => {
const innertag = tag
.substring(1, tag.length - 1)
.replace(new RegExp('^' + getTagName(tag)), '')
@@ -28,7 +28,15 @@ export const getAttrs = tag => {
if (!v) return [k, true]
return [k, v.substring(1, v.length - 1)]
})
- return Object.fromEntries(attrs)
+ const defaultFilter = ([k, v]) => {
+ const attrKey = k.toLowerCase()
+ if (attrKey === 'style') return false
+ if (attrKey === 'class') {
+ return v === 'greentext' || v === 'cyantext'
+ }
+ return true
+ }
+ return Object.fromEntries(attrs.filter(filter || defaultFilter))
}
/**