feat: add EmlConverter with attachment support#1663
Open
VANDRANKI wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: add EmlConverter with attachment support#1663VANDRANKI wants to merge 1 commit intomicrosoft:mainfrom
VANDRANKI wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Adds EmlConverter for converting RFC 822 .eml files to markdown. Extracts email headers (From, To, Cc, Subject, Date) and body content, preferring text/plain over text/html (with tag stripping as fallback). Attachments are converted by passing them back through the MarkItDown converter pipeline when a MarkItDown instance is available. Each attachment is rendered under its own heading in the output. Unsupported or failing attachments show a descriptive note rather than silently failing. Closes microsoft#1662
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
EmlConverterfor converting RFC 822.emlfiles to markdown.This extends the gap identified in issue #1662. The converter handles:
text/plain, falls back totext/htmlwith tag stripping)What this PR covers
converters/_eml_converter.py- newEmlConverterclassconverters/__init__.py- registers the new converter in exports_markitdown.py- registersEmlConverter(markitdown=self)inenable_builtins(), matching theZipConverterpattern for recursive conversiontests/test_eml_converter.py- 11 tests covering headers, body, attachment conversion, unsupported format fallback, and body/attachment isolationAttachment design
Attachment conversion follows the same pattern as
ZipConverter: aMarkItDowninstance is injected via the constructor and used to callconvert_stream()on each attachment. This means any format markitdown supports (XLSX, PDF, DOCX, etc.) is automatically available for email attachments with no additional code.If no
MarkItDowninstance is available (e.g., the converter is instantiated directly), attachments are listed by filename with a note rather than silently skipped.Example output
Testing
All 11 tests pass. ruff check and ruff format pass with zero issues.
Closes #1662