Add native dynamic slide numbers (0.9.2)
This commit is contained in:
@@ -134,15 +134,17 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(prefix="native-export-", dir=output.parent) as temporary:
|
||||
temporary = Path(temporary)
|
||||
definitions = []
|
||||
definitions, definition_roots = [], {}
|
||||
for layout_id, filename in roster.items():
|
||||
source = boundary_file(workspace / "templates", filename, f"layout {layout_id}")
|
||||
target = temporary / f"layout_{layout_id}.svg"
|
||||
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)
|
||||
definition_roots[layout_id] = root
|
||||
from math_component import prepare_math, apply_math
|
||||
public, expected_names, compiled_notes, indexed_notes, math_pages = [], [], {}, {}, []
|
||||
from slide_number import prepare_slide_number, finalize_slide_numbers
|
||||
public, expected_names, compiled_notes, indexed_notes, math_pages, number_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)
|
||||
@@ -150,8 +152,9 @@ 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")
|
||||
number_pages.append(prepare_slide_number(root, definition_roots[layout_id], index + 1))
|
||||
equations = prepare_math(root, style["canvas"])
|
||||
if equations:
|
||||
if equations or number_pages[-1]:
|
||||
ET.ElementTree(root).write(target, encoding="utf-8", xml_declaration=True)
|
||||
math_pages.append(equations)
|
||||
public.append(target)
|
||||
@@ -172,6 +175,7 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
|
||||
ref.require(success, "Bundled structured compiler failed")
|
||||
finalize(generated, theme, style)
|
||||
math_facts = apply_math(generated, math_pages, style["canvas"])
|
||||
number_facts = finalize_slide_numbers(generated, number_pages)
|
||||
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.
|
||||
@@ -185,7 +189,7 @@ def export(manifest_path: Path, theme_id: str, sources: list[Path], output: Path
|
||||
if created:
|
||||
output.unlink(missing_ok=True)
|
||||
raise
|
||||
return {**facts, **math_facts, "template_id": manifest["template_id"], "template_version": manifest["version"],
|
||||
return {**facts, **math_facts, **number_facts, "template_id": manifest["template_id"], "template_version": manifest["version"],
|
||||
"theme": theme_id, "output": str(output)}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user