Handle not supported plot type in pptx (#1122)
* Handle not supported plot type in pptx * Fixed formatting.
This commit is contained in:
@@ -211,6 +211,7 @@ class PptxConverter(DocumentConverter):
|
|||||||
return self._html_converter.convert_string(html_table).markdown.strip() + "\n"
|
return self._html_converter.convert_string(html_table).markdown.strip() + "\n"
|
||||||
|
|
||||||
def _convert_chart_to_markdown(self, chart):
|
def _convert_chart_to_markdown(self, chart):
|
||||||
|
try:
|
||||||
md = "\n\n### Chart"
|
md = "\n\n### Chart"
|
||||||
if chart.has_title:
|
if chart.has_title:
|
||||||
md += f": {chart.chart_title.text_frame.text}"
|
md += f": {chart.chart_title.text_frame.text}"
|
||||||
@@ -232,3 +233,10 @@ class PptxConverter(DocumentConverter):
|
|||||||
header = markdown_table[0]
|
header = markdown_table[0]
|
||||||
separator = "|" + "|".join(["---"] * len(data[0])) + "|"
|
separator = "|" + "|".join(["---"] * len(data[0])) + "|"
|
||||||
return md + "\n".join([header, separator] + markdown_table[1:])
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user