Release PPT workflow 0.7.3 with fixed spacing, paragraphs and native math

This commit is contained in:
2026-10-13 17:16:50 +08:00
parent c4efbed9b0
commit d671e412ae
26 changed files with 1210 additions and 78 deletions
+8 -2
View File
@@ -141,7 +141,8 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
root = prepare_svg(source, target, template_root)
ref.require(root.get("data-pptx-layout") == layout_id, f"Roster/source layout identity mismatch: {layout_id}")
definitions.append(target)
public, expected_names, compiled_notes, indexed_notes = [], [], {}, {}
from math_component import prepare_math, apply_math
public, expected_names, compiled_notes, indexed_notes, math_pages = [], [], {}, {}, []
for index, source in enumerate(sources):
target = temporary / f"page_{index:04d}.svg"
allowed = source_root or (template_root if source.is_relative_to(template_root) else source.parent)
@@ -149,6 +150,10 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
layout_id = root.get("data-pptx-layout")
ref.require(layout_id in layouts, f"Source references an undeclared layout: {layout_id}")
ref.require(root.get("viewBox") == style["canvas"]["viewbox"], "Source viewBox differs from declared template canvas")
equations = prepare_math(root, style["canvas"])
if equations:
ET.ElementTree(root).write(target, encoding="utf-8", xml_declaration=True)
math_pages.append(equations)
public.append(target)
expected_names.append(layouts[layout_id])
if source.stem in notes:
@@ -166,6 +171,7 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
workers=1, primary_language=style.get("language"))
ref.require(success, "Bundled structured compiler failed")
finalize(generated, theme, style)
math_facts = apply_math(generated, math_pages, style["canvas"])
facts = verify(generated, layouts, expected_names, indexed_notes)
# Exclusive publication also protects against a writer racing the initial
# existence check. A failed compile never disturbs the previous output.
@@ -179,7 +185,7 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
if created:
output.unlink(missing_ok=True)
raise
return {**facts, "template_id": manifest["template_id"], "template_version": manifest["version"],
return {**facts, **math_facts, "template_id": manifest["template_id"], "template_version": manifest["version"],
"theme": theme_id, "output": str(output)}