mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Cleanup previous PR
This commit is contained in:
parent
f232ddc734
commit
5d6d01b989
@ -115,6 +115,27 @@ class style_map(dict):
|
||||
self.important_properties = set()
|
||||
|
||||
|
||||
def epub_prefix_properties() -> dict[str, tuple[str, str]]:
|
||||
ans = getattr(epub_prefix_properties, 'ans', None)
|
||||
if ans is None:
|
||||
ans = {}
|
||||
for unprefixed in (
|
||||
'writing-mode', 'text-emphasis', 'text-emphasis-color', 'text-emphasis-position', 'text-emphasis-style'
|
||||
):
|
||||
ans[f'-epub-{unprefixed}'] = f'-webkit-{unprefixed}', unprefixed
|
||||
setattr(epub_prefix_properties, 'ans', ans)
|
||||
return ans
|
||||
|
||||
|
||||
def cleanup_epub_prefixed_properties(style: dict[str, str]) -> None:
|
||||
epub_prefixed = epub_prefix_properties()
|
||||
for x in tuple(filter(epub_prefixed.__contains__, style)):
|
||||
val = style.pop(x)
|
||||
for key in epub_prefixed[x]:
|
||||
if key not in style:
|
||||
style[key] = val
|
||||
|
||||
|
||||
class StylizerRules:
|
||||
|
||||
def __init__(self, opts, profile, stylesheets):
|
||||
@ -185,17 +206,7 @@ class StylizerRules:
|
||||
size = 'xx-small'
|
||||
if size in FONT_SIZE_NAMES:
|
||||
style['font-size'] = f'{self.profile.fnames[size]/float(self.profile.fbase):.1f}rem'
|
||||
UNPREFIXED_PROPERTIES = (
|
||||
['writing-mode'] +
|
||||
[f'text-emphasis{x}' for x in ('', '-color', '-position', '-style')]
|
||||
)
|
||||
for unprefixed_property in UNPREFIXED_PROPERTIES:
|
||||
epub_property = f'-epub-{unprefixed_property}'
|
||||
webkit_property = f'-webkit-{unprefixed_property}'
|
||||
if epub_property in style:
|
||||
value = style[epub_property]
|
||||
style[unprefixed_property] = style.get(unprefixed_property, value)
|
||||
style[webkit_property] = style.get(webkit_property, value)
|
||||
cleanup_epub_prefixed_properties(style)
|
||||
return style
|
||||
|
||||
def _apply_text_align(self, text):
|
||||
|
Loading…
x
Reference in New Issue
Block a user