mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-08 07:40:44 +08:00
fix(parser): 解决样式不生效问题,后续待优化
This commit is contained in:
@@ -15,13 +15,30 @@ export function parseAnnoContent(data: string): string {
|
||||
const htmlBase = new DOMParser().parseFromString(data, "text/html");
|
||||
// 遍历所有 span 标签
|
||||
htmlBase.querySelectorAll("span").forEach(span => {
|
||||
return (span.innerHTML = decodeRegExp(span.innerHTML));
|
||||
if (span.style.fontSize) {
|
||||
span.style.fontSize = "";
|
||||
}
|
||||
if (span.children.length === 0) {
|
||||
return (span.innerHTML = decodeRegExp(span.innerHTML));
|
||||
} else {
|
||||
span.querySelectorAll("*").forEach(child => {
|
||||
if (child.children.length === 0) {
|
||||
return (child.innerHTML = decodeRegExp(child.innerHTML));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// 遍历所有 p 标签
|
||||
htmlBase.querySelectorAll("p").forEach(p => {
|
||||
// 如果没有子元素
|
||||
if (p.children.length === 0) {
|
||||
return (p.innerHTML = decodeRegExp(p.innerHTML));
|
||||
} else {
|
||||
p.querySelectorAll("*").forEach(child => {
|
||||
if (child.children.length === 0) {
|
||||
return (child.innerHTML = decodeRegExp(child.innerHTML));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// 遍历所有 a 标签
|
||||
|
||||
Reference in New Issue
Block a user