Skip to content

Commit 1736565

Browse files
authored
Handle PPTX shapes where position is None (#1161)
* Handle shapes where position is None * Fixed recursion error, and place no-coord shapes at front
1 parent 59eb60f commit 1736565

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/markitdown/src/markitdown/converters/_pptx_converter.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,23 @@ def get_shape_content(shape, **kwargs):
168168

169169
# Group Shapes
170170
if shape.shape_type == pptx.enum.shapes.MSO_SHAPE_TYPE.GROUP:
171-
sorted_shapes = sorted(shape.shapes, key=attrgetter("top", "left"))
171+
sorted_shapes = sorted(
172+
shape.shapes,
173+
key=lambda x: (
174+
float("-inf") if not x.top else x.top,
175+
float("-inf") if not x.left else x.left,
176+
),
177+
)
172178
for subshape in sorted_shapes:
173179
get_shape_content(subshape, **kwargs)
174180

175-
sorted_shapes = sorted(slide.shapes, key=attrgetter("top", "left"))
181+
sorted_shapes = sorted(
182+
slide.shapes,
183+
key=lambda x: (
184+
float("-inf") if not x.top else x.top,
185+
float("-inf") if not x.left else x.left,
186+
),
187+
)
176188
for shape in sorted_shapes:
177189
get_shape_content(shape, **kwargs)
178190

0 commit comments

Comments
 (0)