Skip to content

fix(pptx): do not emit a heading for a slide with an empty title - #2442

Merged
afourney merged 2 commits into
microsoft:mainfrom
kevin9327:fix/pptx-empty-title
Sep 10, 2026
Merged

fix(pptx): do not emit a heading for a slide with an empty title#2442
afourney merged 2 commits into
microsoft:mainfrom
kevin9327:fix/pptx-empty-title

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Converting a deck whose slide has an empty title placeholder produces a bare # line where the heading should be:

<!-- Slide number: 1 -->
#
Some body text on the slide.

expected the slide's text with no heading at all:

<!-- Slide number: 1 -->
Some body text on the slide.

A layout's title placeholder is on the slide whether or not anything was typed into it — PowerPoint shows it as "Click to add title" — so slide.shapes.title returning a shape says nothing about there being a title to read. convert emitted "# " + text.lstrip() unconditionally, so an untouched placeholder wrote "# ", and the trailing space is then removed by the output normalization, leaving # on a line of its own. Every slide built from a title layout but headed by a picture, a chart or a table carries one.

This is the same shape as the notes fix in #2427: a section header written before the thing it heads is known to exist.

The fix guards the heading on the title having text, matching how the notes heading is guarded a few lines below.

Reproduction

New test file, on unmodified main (packages/markitdown):

$ python -m pytest tests/test_pptx_empty_title.py -q
FAILED tests/test_pptx_empty_title.py::test_untouched_title_placeholder_produces_no_heading
FAILED tests/test_pptx_empty_title.py::test_empty_title_produces_no_heading
FAILED tests/test_pptx_empty_title.py::test_whitespace_only_title_produces_no_heading
3 failed, 1 passed in 1.78s

with the failure being the heading that should not be there:

    def test_empty_title_produces_no_heading() -> None:
        markdown = _convert("")
        assert BODY_TEXT in markdown
>       assert _heading_lines(markdown) == []
E       AssertionError: assert ['#'] == []

The fourth test — a title that does have text still emitting # Quarterly Results — passes before and after.

With the fix:

$ python -m pytest tests/test_pptx_empty_title.py -q
4 passed in 1.39s

Verification

The existing PPTX and end-to-end vector tests are unchanged, before and after:

$ python -m pytest tests/test_pptx_notes.py tests/test_pptx_none_text.py tests/test_pptx_svg.py tests/test_module_vectors.py -q
119 passed in 38.98s   # origin/main
119 passed in 42.53s   # this branch

black reports both touched files unchanged.

A layout's title placeholder is present on the slide whether or not
anything was typed into it, so its presence says nothing about there
being a title. The converter emitted "# " unconditionally, leaving a
bare "#" in the output.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The OCR PPTX converter still emits bare headings and must receive the equivalent fix.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Prevents empty PPTX title placeholders from producing bare Markdown headings.

Changes:

  • Guards heading emission on non-whitespace title text.
  • Adds regression tests for empty, whitespace-only, untouched, and populated titles.
File summaries
File Description
test_pptx_empty_title.py Adds title-placeholder regression coverage.
_pptx_converter.py Suppresses headings without title text.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The equivalent OCR converter still emits bare headings for empty titles.

Review details

Suppressed comments (1)

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

  • This fixes only the built-in converter, but the OCR plugin registers PptxConverterWithOCR ahead of it and that converter still unconditionally emits "# " + shape.text.lstrip() for an empty title (packages/markitdown-ocr/src/markitdown_ocr/_pptx_converter_with_ocr.py:148-153). Consequently, enabling the plugin preserves the reported bare heading; please apply the same guard there and update its existing empty-title snapshot (test_pptx_multiple_images).
                        if text.strip():
                            md_content += "# " + text.lstrip() + "\n"
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@afourney
afourney merged commit 075c05b into microsoft:main Sep 10, 2026
10 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.

3 participants