Files
NapCatQQ/.pnpm-store/v3/files/3e/89230a6c14f5b77bf8c5b645f80b82f7e06388c35684ba8d37d622dffe54dd205b78c9d46631e9d38a8558be1ed6e50f97cedf7dbfc5b819d9de8ba54f1ba6
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

24 lines
971 B
Plaintext

const normalWeightRegexp = /font-weight:\s*normal/;
const blockTagNames = ['P', 'OL', 'UL'];
const isBlockElement = element => {
return element && blockTagNames.includes(element.tagName);
};
const normalizeEmptyLines = doc => {
Array.from(doc.querySelectorAll('br')).filter(br => isBlockElement(br.previousElementSibling) && isBlockElement(br.nextElementSibling)).forEach(br => {
br.parentNode?.removeChild(br);
});
};
const normalizeFontWeight = doc => {
Array.from(doc.querySelectorAll('b[style*="font-weight"]')).filter(node => node.getAttribute('style')?.match(normalWeightRegexp)).forEach(node => {
const fragment = doc.createDocumentFragment();
fragment.append(...node.childNodes);
node.parentNode?.replaceChild(fragment, node);
});
};
export default function normalize(doc) {
if (doc.querySelector('[id^="docs-internal-guid-"]')) {
normalizeFontWeight(doc);
normalizeEmptyLines(doc);
}
}
//# sourceMappingURL=googleDocs.js.map