Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ def _convert_chart_to_markdown(self, chart):
try:
md = "\n\n### Chart"
if chart.has_title:
md += f": {chart.chart_title.text_frame.text}"
title_frame = chart.chart_title.text_frame
title_text = title_frame.text if title_frame is not None else ""
if title_text:
md += f": {title_text}"
md += "\n\n"
data = []
category_names = [c.label for c in chart.plots[0].categories]
Expand Down
17 changes: 17 additions & 0 deletions packages/markitdown/tests/test_module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import re
import shutil
import pytest
from types import SimpleNamespace
from unittest.mock import MagicMock

from markitdown._uri_utils import parse_data_uri, file_uri_to_path
from markitdown.converters import PptxConverter

from markitdown import (
MarkItDown,
Expand Down Expand Up @@ -532,6 +534,21 @@ def test_markitdown_llm() -> None:
validate_strings(result, PPTX_TEST_STRINGS)


def test_pptx_chart_title_without_text_frame_keeps_chart_data() -> None:
chart = MagicMock()
chart.has_title = True
chart.chart_title.text_frame = None
chart.plots = [SimpleNamespace(categories=[SimpleNamespace(label="FY2026")])]
chart.series = [SimpleNamespace(name="Revenue", values=[42])]

result = PptxConverter()._convert_chart_to_markdown(chart)

assert "[unsupported chart]" not in result
assert "### Chart\n\n" in result
assert "| Category | Revenue |" in result
assert "| FY2026 | 42 |" in result


if __name__ == "__main__":
"""Runs this file's tests from the command line."""
for test in [
Expand Down