Handle not supported plot type in pptx (#1122)

* Handle not supported plot type in pptx
* Fixed formatting.
This commit is contained in:
Emanuele Meazzo
2025-03-12 19:26:23 +01:00
committed by GitHub
parent 5f75e16d20
commit 12620f1545

View File

@@ -211,6 +211,7 @@ class PptxConverter(DocumentConverter):
return self._html_converter.convert_string(html_table).markdown.strip() + "\n"
def _convert_chart_to_markdown(self, chart):
try:
md = "\n\n### Chart"
if chart.has_title:
md += f": {chart.chart_title.text_frame.text}"
@@ -232,3 +233,10 @@ class PptxConverter(DocumentConverter):
header = markdown_table[0]
separator = "|" + "|".join(["---"] * len(data[0])) + "|"
return md + "\n".join([header, separator] + markdown_table[1:])
except ValueError as e:
# Handle the specific error for unsupported chart types
if "unsupported plot type" in str(e):
return "\n\n[unsupported chart]\n\n"
except Exception:
# Catch any other exceptions that might occur
return "\n\n[unsupported chart]\n\n"