Skip to content

Comments

Add WMF to SVG Conversion and Image Inclusion in Markdown Output#87

Open
laura-dietz wants to merge 4 commits intossine:masterfrom
laura-dietz:master
Open

Add WMF to SVG Conversion and Image Inclusion in Markdown Output#87
laura-dietz wants to merge 4 commits intossine:masterfrom
laura-dietz:master

Conversation

@laura-dietz
Copy link

This PR introduces two key enhancements to pptx2md, improving its robustness and extending support for vector graphics.


🔧 Summary of Changes

1. WMF Image Support and SVG Conversion

  • Adds support for extracting .wmf images from PowerPoint files.

  • Automatically converts .wmf to .svg using inkscape CLI:

    inkscape input.wmf --export-type=svg --export-filename=output.svg --export-plain-svg
  • References the .svg in the Markdown output for inclusion in rendered output.

2. Bug Fix: Shape Sorting Crash

  • Fixes a bug in parser.py where ungrouped shapes could lack top or left attributes.

  • This previously caused attrgetter('top', 'left') to crash conversion on some slides.

  • Now uses:

    shapes = [sp for sp in ungroup_shapes(...) if getattr(sp, "top", None) is not None]
    shapes.sort(key=attrgetter('top', 'left'))
  • Prevents hard crashes and logs a warning when a malformed shape is encountered.


✅ Behavior Improvements

  • Gracefully skips and logs invalid shapes instead of crashing.
  • Enables full extraction and rendering of .wmf-based diagrams, equations, and flowcharts — often used in academic slides.

🧱 Dependency Notes

  • No additional Python dependencies.

  • Assumes inkscape is available in the $PATH.

    • If unavailable, .wmf images are skipped with a warning.
    • This fallback behavior is safe and non-breaking.

🧪 Tested With

  • Linux (NixOS), Python 3.12

  • Slide decks containing .png, .jpeg, .wmf, grouped shapes, and malformed objects

  • Markdown output rendered via:

    pandoc out.md -t beamer -o out.pdf

📎 Related

  • Consolidates local improvements from university lecture slide conversion workflows.
  • If accepted, enables better support for vector graphics and reduces conversion fragility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant