Skip to content

Conversation

EmanueleMeazzo
Copy link
Contributor

When converting a pptx with an unsupported plot type, in the current version the conversion simply silently fails
This is a simple change that adds a try/catch block and skips the unsupported plot type in case of errors

This is the error you would get with an unmanaged conversion:

'Traceback (most recent call last):\n File "c:\\DevOps\\xxx\\.venv\\Lib\\site-packages\\pptx\\chart\\plot.py", line 236, in PlotFactory\n PlotCls = {\n ~\n ...<8 lines>...\n qn("c:scatterChart"): XyPlot,\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n }[xChart.tag]\n ~^^^^^^^^^^^^\nKeyError: \'{http://schemas.openxmlformats.org/drawingml/2006/chart}pie3DChart\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "c:\\DevOps\\axxx\\.venv\\Lib\\site-packages\\markitdown\\_markitdown.py", line 1715, in _convert\n res = converter.convert(local_path, **_kwargs)\n File "c:\\DevOps\\xxx\\.venv\\Lib\\site-packages\\markitdown\\_markitdown.py", line 903, in convert\n md_content += self._convert_chart_to_markdown(shape.chart)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n File "c:\\DevOps\\xxx\\.venv\\Lib\\site-packages\\markitdown\\_markitdown.py", line 945, in _convert_chart_to_markdown\n category_names = [c.label for c in chart.plots[0].categories]\n ~~~~~~~~~~~^^^\n File "c:\\DevOps\\xxx\\.venv\\Lib\\site-packages\\pptx\\chart\\chart.py", line 277, in __getitem__\n return PlotFactory(xChart, self._chart)\n File "c:\\DevOps\\xxx\\.venv\\Lib\\site-packages\\pptx\\chart\\plot.py", line 248, in PlotFactory\n raise ValueError("unsupported plot type %s" % xChart.tag)\nValueError: unsupported plot type {http://schemas.openxmlformats.org/drawingml/2006/chart}pie3DChart'

@afourney afourney merged commit 12620f1 into microsoft:main Mar 12, 2025
3 checks passed
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.

2 participants