Python tool for converting files and office documents to Markdown.
feat: sort pptx shapes to be parsed in top-to-bottom, left-to-right order (#1104)
Richard Ye0229ff6cb75a
diff --git a/README.md b/README.mdindex 0aa788c6..40f4b827 100644--- a/README.md+++ b/README.md@@ -14,7 +14,7 @@ MarkItDown is a lightweight Python utility for converting various files to MarkdAt present, MarkItDown supports:-- PowerPoint+- PowerPoint (reading in top-to-bottom, left-to-right order)- Word- Excel- Images (EXIF metadata and OCR)diff --git a/packages/markitdown/src/markitdown/converters/_pptx_converter.py b/packages/markitdown/src/markitdown/converters/_pptx_converter.pyindex bea12267..bcde6c95 100644--- a/packages/markitdown/src/markitdown/converters/_pptx_converter.py+++ b/packages/markitdown/src/markitdown/converters/_pptx_converter.py@@ -6,6 +6,7 @@ import reimport htmlfrom typing import BinaryIO, Any+from operator import attrgetterfrom ._html_converter import HtmlConverterfrom ._llm_caption import llm_caption@@ -160,10 +161,12 @@ class PptxConverter(DocumentConverter):# Group Shapesif shape.shape_type == pptx.enum.shapes.MSO_SHAPE_TYPE.GROUP:- for subshape in shape.shapes:+ sorted_shapes = sorted(shape.shapes, key=attrgetter("top", "left"))+ for subshape in sorted_shapes:get_shape_content(subshape, **kwargs)- for shape in slide.shapes:+ sorted_shapes = sorted(slide.shapes, key=attrgetter("top", "left"))+ for shape in sorted_shapes:get_shape_content(shape, **kwargs)md_content = md_content.strip()