forked from akai/readest
This commit is contained in:
@@ -737,6 +737,21 @@ export const transformStylesheet = (css: string, vw: number, vh: number, vertica
|
||||
return selector + block;
|
||||
});
|
||||
|
||||
// unset font-family for body when set to serif or sans-serif
|
||||
css = css.replace(ruleRegex, (_, selector, block) => {
|
||||
if (/\bbody\b/i.test(selector)) {
|
||||
const hasSerifFont = /font-family\s*:\s*serif\s*[;$]/.test(block);
|
||||
const hasSansSerifFont = /font-family\s*:\s*sans-serif\s*[;$]/.test(block);
|
||||
if (hasSerifFont) {
|
||||
block = block.replace(/font-family\s*:\s*serif\s*([;$])/gi, 'font-family: unset$1');
|
||||
}
|
||||
if (hasSansSerifFont) {
|
||||
block = block.replace(/font-family\s*:\s*sans-serif\s*([;$])/gi, 'font-family: unset$1');
|
||||
}
|
||||
}
|
||||
return selector + block;
|
||||
});
|
||||
|
||||
// replace absolute font sizes with rem units
|
||||
// replace vw and vh as they cause problems with layout
|
||||
// replace hardcoded colors
|
||||
|
||||
Reference in New Issue
Block a user