Skip to content

fix(email): preserve furniture from HTML message bodies - #5228

Merged
PeterStaar-IBM merged 2 commits into
docling-project:mainfrom
BrownieCoder:fix/email-html-furniture
Nov 10, 2026
Merged

PeterStaar-IBM merged 2 commits into
docling-project:mainfrom
BrownieCoder:fix/email-html-furniture

Conversation

@BrownieCoder

@BrownieCoder BrownieCoder commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

HTML-only emails lost text inside <footer> elements during conversion. The HTML backend kept the text, but the email backend dropped the furniture layer when converting it to Markdown.

Keep footer text on ContentLayer.FURNITURE. It is available in JSON and when Markdown explicitly includes that layer. Default Markdown still exports the body, and non-empty plain-text alternatives remain preferred.

Fixes the remaining footer loss in #5219. Double escaping was already fixed on main; #4877 handles image placeholders separately.

Testing

The footer regressions fail on main and pass with the fix. Tests cover HTML-only messages, blank plain-text alternatives, footer-only messages, multipart HTML, escaping, and the text-body fallback. They also compare the document model, JSON, and default/all-layer exports.

  • pytest -q tests/test_backend_email.py tests/test_backend_html.py: 175 passed, 1 optional Playwright test skipped.
  • pytest -q tests/test_input_doc.py -k "email or eml or msg": 3 passed.
  • make validate: passed.
  • Local coverage exercises all 14 executable lines added to the email backend.

Full make check stops at 17 existing file-length violations, also reproduced on clean main. The full model/OCR suite was not run locally. Tested with Python 3.12.4 and docling-core 2.106.0.

Checklist

  • Documentation updated.
  • Regression tests added.
  • No new example or reference fixtures needed.

Signed-off-by: Wayne <36395303+BrownieCoder@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

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

@BrownieCoder
BrownieCoder marked this pull request as ready for review November 7, 2026 01:36
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working docling-document tests issue related to changes needed in the tests labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

The email backend now keeps text from HTML <footer> elements on ContentLayer.FURNITURE. Before, it dropped this text when it converted the HTML body to Markdown. Default Markdown still exports only the body. The PR adds regression tests and a short note in the docs.

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

2 related pull request(s) in the same code
PR State Signal Assessment
#4877 open referenced as #4877; changes the same code related: Both PRs change the export_to_markdown call in _get_body_paragraphs. #4877 removes image placeholders with image_placeholder="". This PR keeps footer text on the furniture layer. The two fixes solve different problems, but they will conflict when merged.
#3978 open changes the same code related: #3978 adds parsing of email attachments. This PR keeps HTML footer text. Both change email_backend.py and its tests, but the features are different.

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 4d1c25cca6. It read the code and did not run it.

I found no defect that blocks the merge. The change in docling/backend/email_backend.py exports the HTML body once per content layer, then adds each paragraph with its layer. This matches how the HTML backend marks footers as furniture, and the HTML options already set infer_furniture=False, so only <footer> text lands in the furniture layer.

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 Nov 7, 2026
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Signed-off-by: Wayne <36395303+BrownieCoder@users.noreply.github.com>
@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 7, 2026

@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 changes since 4d1c25cca6 at 340a9926c0. It read the code and did not run it.

I found no defect that blocks the merge. In docling/backend/email_backend.py, _get_body_paragraphs exports each content layer of the HTML body separately and keeps the plain-text-first order. The new calendar test in the incremental diff checks existing fallback behavior and does not cover this fix. I could not check it against the mailparser source, because the dependency was not installed in the workspace.

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 Nov 7, 2026
@github-actions github-actions Bot mentioned this pull request Nov 7, 2026
2 of 3 tasks

@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!

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) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working docling-document tests issue related to changes needed in the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants