diff --git a/markdown2html.py b/markdown2html.py
index 34259e8..09df2db 100644
--- a/markdown2html.py
+++ b/markdown2html.py
@@ -84,9 +84,32 @@ def markdown2html(markdown, basepath, re_render, resources, viewport_width, font
# FIXME: highlight the code using Sublime's syntax
+ # Apply font scaling via inline styles
+ if font_scale != 1.0:
+ BASE_PX_SIZE = 15 # Base font size in pixels
+ TAG_MULTIPLIERS = {
+ 'p': 1.0,
+ 'li': 1.0,
+ 'h1': 2.0,
+ 'h2': 1.8,
+ 'h3': 1.6,
+ 'h4': 1.4,
+ 'h5': 1.2,
+ 'h6': 1.1,
+ 'blockquote': 1.0,
+ 'code': 0.9, # Assuming code is slightly smaller
+ # Add other tags as needed, e.g., 'td', 'th' for tables
+ }
+
+ # Find all tags that we want to scale
+ for element in soup.find_all(list(TAG_MULTIPLIERS.keys())):
+ multiplier = TAG_MULTIPLIERS.get(element.name, 1.0)
+ target_size = round(BASE_PX_SIZE * multiplier * font_scale)
+ # Simple style setting (overwrites existing inline style if any)
+ # A more robust solution would parse and merge existing styles
+ element['style'] = f"font-size: {target_size}px;"
+
# FIXME: report that ST doesn't support
but does work with
... WTF?
- # Add font scaling CSS rule - REMOVED as MiniHTML doesn't support transform/font-size scaling this way
- # font_scale_css = "body {{ transform: scale({}); transform-origin: top left; }}\n".format(font_scale)
stylesheet = resources["stylesheet"] # Use only the base stylesheet
return "\n\n{}".format(stylesheet, soup).replace(