fix: preserve CSS resets and independent variable decorations
This commit is contained in:
@@ -752,11 +752,15 @@ class MarkdownRenderer:
|
||||
font_size = max(12, min(int(document_font_size or fallback_font_size), 28))
|
||||
font_family = self._css_font_family(document_font_family)
|
||||
escaped_font_family = html.escape(font_family, quote=False)
|
||||
from .reader_decoration import MARKER, wrap_decoration_text
|
||||
from .reader_decoration import MARKER, DYNAMIC_MARKER, wrap_decoration_text
|
||||
leaf_decorations = MARKER in document_style_css
|
||||
if leaf_decorations: body = wrap_decoration_text(body)
|
||||
reader_shell = self._reader_shell_html(body)
|
||||
if leaf_decorations: reader_shell = reader_shell.replace('<main ', '<main data-mdh-leaf-decoration ', 1)
|
||||
if DYNAMIC_MARKER in document_style_css:
|
||||
path = self.resources_dir / 'reader_decorations.js'
|
||||
stat = path.stat()
|
||||
js = _resource_text(path, stat.st_mtime_ns, stat.st_size) + '\n' + js
|
||||
|
||||
return f"""<!doctype html>
|
||||
<html lang="zh-CN" data-theme="{escaped_theme}" data-math-engine="{escaped_math_engine}" data-wheel-scroll-speed="{normalized_wheel_speed:.1f}">
|
||||
|
||||
Reference in New Issue
Block a user