fix: address phase two review and theme benchmark page

This commit is contained in:
2026-09-07 13:26:14 +08:00
parent 0e3f2a7325
commit 47c53b6f38
12 changed files with 451 additions and 35 deletions
+7 -1
View File
@@ -115,7 +115,13 @@ class DocxExporter:
from PIL import Image
png = node.attributes['static_png']
with Image.open(BytesIO(png)) as image:
width = min(5.8, image.width / (180 if node.type == 'math_block' else 96))
section = self._doc.sections[-1]
available_width = (section.page_width - section.left_margin - section.right_margin) / 914400
# Leave room for Word's containing paragraph line/spacing.
available_height = (section.page_height - section.top_margin - section.bottom_margin) / 914400 - 0.25
width = min(5.8, available_width,
image.width / (180 if node.type == 'math_block' else 96),
available_height * image.width / image.height)
self._doc.add_picture(BytesIO(png), width=Inches(width))
return
handler = getattr(self, f"_block_{node.type}", None)