From 0706e5919c18befc7557b511fee9df491175f923 Mon Sep 17 00:00:00 2001 From: Richard Ye <33409792+richardye101@users.noreply.github.com> Date: Fri, 28 Mar 2025 10:26:00 -0400 Subject: [PATCH 1/3] Handle shapes where position is None --- .../markitdown/src/markitdown/converters/_pptx_converter.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/markitdown/src/markitdown/converters/_pptx_converter.py b/packages/markitdown/src/markitdown/converters/_pptx_converter.py index 087da32c5..a518a45ec 100644 --- a/packages/markitdown/src/markitdown/converters/_pptx_converter.py +++ b/packages/markitdown/src/markitdown/converters/_pptx_converter.py @@ -168,11 +168,13 @@ def get_shape_content(shape, **kwargs): # Group Shapes if shape.shape_type == pptx.enum.shapes.MSO_SHAPE_TYPE.GROUP: - sorted_shapes = sorted(shape.shapes, key=attrgetter("top", "left")) + not_none_shapes = [shape for shape in slide.shapes if shape.top is not None and shape.left is not None] + sorted_shapes = sorted(not_none_shapes, key=attrgetter("top", "left")) for subshape in sorted_shapes: get_shape_content(subshape, **kwargs) - sorted_shapes = sorted(slide.shapes, key=attrgetter("top", "left")) + not_none_shapes = [shape for shape in slide.shapes if shape.top is not None and shape.left is not None] + sorted_shapes = sorted(not_none_shapes, key=attrgetter("top", "left")) for shape in sorted_shapes: get_shape_content(shape, **kwargs) From f62d3e80e8fb37e1daea98c9500e1a02bed69263 Mon Sep 17 00:00:00 2001 From: Richard Ye <33409792+richardye101@users.noreply.github.com> Date: Tue, 1 Apr 2025 15:59:23 -0400 Subject: [PATCH 2/3] Fixed recursion error, and place no-coord shapes at front --- .../src/markitdown/converters/_pptx_converter.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/markitdown/src/markitdown/converters/_pptx_converter.py b/packages/markitdown/src/markitdown/converters/_pptx_converter.py index a518a45ec..5e4e853f1 100644 --- a/packages/markitdown/src/markitdown/converters/_pptx_converter.py +++ b/packages/markitdown/src/markitdown/converters/_pptx_converter.py @@ -168,13 +168,11 @@ def get_shape_content(shape, **kwargs): # Group Shapes if shape.shape_type == pptx.enum.shapes.MSO_SHAPE_TYPE.GROUP: - not_none_shapes = [shape for shape in slide.shapes if shape.top is not None and shape.left is not None] - sorted_shapes = sorted(not_none_shapes, key=attrgetter("top", "left")) + sorted_shapes = sorted(shape.shapes, key=lambda x: (float('-inf') if not x.top else x.top, float('-inf') if not x.left else x.left)) for subshape in sorted_shapes: get_shape_content(subshape, **kwargs) - - not_none_shapes = [shape for shape in slide.shapes if shape.top is not None and shape.left is not None] - sorted_shapes = sorted(not_none_shapes, key=attrgetter("top", "left")) + + sorted_shapes = sorted(slide.shapes, key=lambda x: (float('-inf') if not x.top else x.top, float('-inf') if not x.left else x.left)) for shape in sorted_shapes: get_shape_content(shape, **kwargs) From fbae702cc5b26a197452727b73fc1c0ab3c8bb8a Mon Sep 17 00:00:00 2001 From: Adam Fourney Date: Tue, 26 Aug 2025 15:26:00 -0700 Subject: [PATCH 3/3] Fixed formatting. --- .../markitdown/converters/_pptx_converter.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/markitdown/src/markitdown/converters/_pptx_converter.py b/packages/markitdown/src/markitdown/converters/_pptx_converter.py index 5e4e853f1..360f17706 100644 --- a/packages/markitdown/src/markitdown/converters/_pptx_converter.py +++ b/packages/markitdown/src/markitdown/converters/_pptx_converter.py @@ -168,11 +168,23 @@ def get_shape_content(shape, **kwargs): # Group Shapes if shape.shape_type == pptx.enum.shapes.MSO_SHAPE_TYPE.GROUP: - sorted_shapes = sorted(shape.shapes, key=lambda x: (float('-inf') if not x.top else x.top, float('-inf') if not x.left else x.left)) + sorted_shapes = sorted( + shape.shapes, + key=lambda x: ( + float("-inf") if not x.top else x.top, + float("-inf") if not x.left else x.left, + ), + ) for subshape in sorted_shapes: get_shape_content(subshape, **kwargs) - - sorted_shapes = sorted(slide.shapes, key=lambda x: (float('-inf') if not x.top else x.top, float('-inf') if not x.left else x.left)) + + sorted_shapes = sorted( + slide.shapes, + key=lambda x: ( + float("-inf") if not x.top else x.top, + float("-inf") if not x.left else x.left, + ), + ) for shape in sorted_shapes: get_shape_content(shape, **kwargs)