Skip to content

fix(email): leave image placeholders out of the HTML body text - #4877

Open
wfatih wants to merge 1 commit into
docling-project:mainfrom
wfatih:fix/email-html-image-placeholder
Open

wfatih wants to merge 1 commit into
docling-project:mainfrom
wfatih:fix/email-html-image-placeholder

Conversation

@wfatih

@wfatih wfatih commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

For an HTML-only email, EmailDocumentBackend converts the HTML part with the HTML backend, exports it to Markdown and splits the Markdown into plain text paragraphs. The Markdown export writes <!-- image --> for every picture, so each <img> in the body turns into a paragraph with that literal text:

Content-Type: text/html; charset="utf-8"

<p>Hello</p><img src="cid:logo"><p>Bye</p>

On main the body texts are ["Hello", "<!-- image -->", "Bye"], and the Markdown of the email shows a visible &lt;!-- image --&gt; line, because text items are escaped on export. The same happens for an image in a table cell (| <!-- image --> | cell |) and in a <figure>. Logos in signatures and newsletters are a common case.

This passes image_placeholder="" to that export_to_markdown() call. The empty paragraph that is left is already dropped by _split_paragraphs(), and alt text and figure captions are kept as before.

The new test converts the email above and checks that the body is ["Hello", "Bye"] and that the Markdown has no image placeholder. It fails on main and passes with this change. tests/test_backend_email.py passes (28 passed). The email tests have no groundtruth files, and none of the sample emails has an image.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

  • Before: <p>Hello</p><img src="cid:logo"><p>Bye</p> gives the body texts Hello, <!-- image -->, Bye; the Markdown export shows &lt;!-- image --&gt;.
  • After: the body texts are Hello, Bye. With alt="Logo" the alt text is still kept (Hello, Logo, Bye).
  • pytest tests/test_backend_email.py: 28 passed. The new test fails on main (1 failed, 27 passed).
  • pytest tests/test_input_doc.py -k "email or eml or msg": 3 passed.
  • ruff check and ruff format --check pass on the changed files.

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Oct 17, 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)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working labels Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 26f6184e2b. The analysis read the diff only. It did not run code from this pull request.

The email backend now passes image_placeholder="" when it exports the HTML body to Markdown. This stops <!-- image --> from appearing as literal body text in HTML emails. A new test covers the fix.

CI safety: no concern found. A maintainer must still approve CI.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot 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.

AI first review (advisory): no blocker found

This review covers the full diff at a862179a26. It read the code and did not run it.

I verified that setting image_placeholder="" in EmailDocumentBackend._get_body_paragraphs prevents placeholder paragraphs in HTML email conversions without altering public export APIs or other backends.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 17, 2026
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM PeterStaar-IBM added the email issue related to email (EML, MSG) backend label Nov 6, 2026
@PeterStaar-IBM

Copy link
Copy Markdown
Member

Hi @wfatih, thank you for this pull request.

It has a merge conflict with main. Please rebase your branch on the latest main and resolve the conflict:

git fetch upstream
git rebase upstream/main
# resolve the conflicts, then:
git push --force-with-lease

We can continue with the review and CI after that.

The HTML body is converted to Markdown and split into plain text
paragraphs. The Markdown export writes "<!-- image -->" for each
picture, so an image in the HTML body became a body paragraph with that
literal text. Export the Markdown without an image placeholder.

Signed-off-by: wfatih <ckrfth.s@gmail.com>
@wfatih
wfatih force-pushed the fix/email-html-image-placeholder branch from a862179 to 26f6184 Compare November 27, 2026 17:15
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Nov 27, 2026
@wfatih

wfatih commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main and resolved the conflict with #5228. Since #5228 exports the body and furniture layers separately, image_placeholder="" now goes into that per-layer export.

The change is still that one argument plus the regression test. The test fails without it (['Hello', '<!-- image -->', 'Bye']) and passes with it, and tests/test_backend_email.py passes in full (59 tests).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working email issue related to email (EML, MSG) backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants