Skip to content

fix(pptx): preserve native Office Math equations - #4625

Merged
PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
RauPro:fix/pptx-omml-equations
Oct 7, 2026
Merged

PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
RauPro:fix/pptx-omml-equations

Conversation

@RauPro

@RauPro RauPro commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

PowerPoint text extraction skips Office Math elements, so equations disappear from equation-only shapes and mixed paragraphs. Read OMML in paragraph order and reuse the existing Office Math to LaTeX converter. Standalone equations become formula items; mixed paragraphs and list items contain inline formula items. For mc:AlternateContent, read one supported choice or its fallback to avoid duplicate output. Mixed title paragraphs retain their title label.

The format-pptx extra now includes pylatexenc, which the shared converter requires. The lockfile changes only the corresponding dependency entries.

Issue resolved by this Pull Request:
Resolves #4603

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary. (Synthetic presentations are included in the tests.)
  • Tests have been added, if necessary.

Review evidence:

  • a14:m/m:oMath content that was absent from both the document tree and Markdown now appears once as a formula. Tests also cover wrapped equations, the fallback for unsupported compatibility choices, text/formula order, list parents, fractions, and title labels.
  • The first six regression cases all failed on the original code and passed after the fix; a seventh case checks preservation of title structure.
  • python -m pytest -p no:tach tests/test_backend_pptx.py tests/test_backend_pptx_math.py -q: 39 passed.
  • make validate: passed with the isolated test environment (UV_PROJECT_ENVIRONMENT=../venv, UV_NO_SYNC=1). All applicable hooks passed, including Ruff, ty, Tach and the lockfile check.
  • uv lock --locked --offline: passed.
  • No reference fixtures changed. The full suite, including unrelated model-backed PDF/OCR tests, was not run.

Prepared with assistance from OpenAI Codex.

Signed-off-by: Raul Ernesto Guillen Hernandez <37725305+RauPro@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @RauPro, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.98246% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/mspowerpoint_backend.py 92.98% 0 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM PeterStaar-IBM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@PeterStaar-IBM
PeterStaar-IBM merged commit a85f04d into docling-project:main Oct 7, 2026
46 checks passed
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Oct 7, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Oct 8, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Oct 9, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Oct 14, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Nov 11, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Nov 26, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
avanish-garg added a commit to avanish-garg/docling that referenced this pull request Dec 3, 2026
The PPTX text-extraction loop built each paragraph's text via plain
string concatenation (p_text += e.text) and handed the whole thing to
a single add_text/add_list_item call, discarding every run's own
hyperlink and bold/italic/underline formatting - the same information
DOCX/HTML/ODF/MD backends already preserve per run.

Splits each paragraph into (text, formatting, hyperlink) tuples per
run, mirroring msword_backend.py's existing _iter_paragraph_content/
_get_format_from_run/_get_hyperlink_target pattern:

- Adjacent runs with identical formatting/hyperlink are coalesced back
  into one unit first, since PowerPoint sometimes splits a single word
  across runs with no actual formatting difference (e.g. spell-check
  markup) - without this, wrapping each such run in its own item would
  let the markdown serializer's inter-sibling space split real words.
- A paragraph with more than one run is wrapped in an inline group
  (mirroring the DOCX backend's own _create_or_reuse_parent), so a
  sentence with a bold word or a link in the middle stays one flowing
  unit on export instead of splintering into separate blocks.
- Title/section-header paragraphs are kept as a single item as before:
  a heading is one outline-level unit, not a sequence of independently
  formatted spans.
- Each item's own provenance is now built from its own text rather
  than the whole paragraph's, so charspan stays correct once a
  paragraph can produce more than one item (python-pptx exposes no
  finer bbox than the shape's, so the bbox itself stays shape-level).

New test: test_pptx_preserves_run_level_formatting_and_hyperlinks,
covering a bold run, a plain run, and a hyperlinked run in one
paragraph. Golden fixtures regenerated; diffs are exactly the fixed
behavior (a real markdown hyperlink where the URL was silently
dropped, formatting: {...} now present throughout) with no unrelated
changes.

Native Office Math equations (docling-project#4625) keep their own FORMULA items; the text
runs around them now carry their run-level formatting and hyperlinks too.

Signed-off-by: Avanish Garg <gargavanish@gmail.com>
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.

PY-04-PPTX: equations in text shapes (a14:m / m:oMath) are silently dropped

2 participants