microsoft / microsoft/markitdown
[FEATURE REQUEST] MHTML Support
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
It would be incredibly helpful if MarkItDown could support the conversion of MHTML files to Markdown. MHTML (MIME HTML) files are a common format for saving web pages and preserving their structure, including embedded assets like images and styles. Adding support for MHTML would enhance MarkItDown’s utility, especially for users working with offline web archives or needing to extract text and structure from web-based documents.
Why It’s Useful
- Web Page Archiving: Many users save web pages as MHTML files for offline access, and extracting meaningful content from these files is a frequent need.
- Consistency with HTML Support: Since MarkItDown already supports HTML, extending this to MHTML would align with its existing functionality.
- Expanding Use Cases: This feature would open up new workflows for researchers, content managers, and developers working with archived web content.
Proposed Functionality
- Input: Allow
.mhtmlfiles as valid inputs for themarkitdowncommand and Python API. - Conversion Process:
- Extract the HTML content from the MHTML container.
- Resolve embedded resources (e.g., images, CSS) to ensure a clean Markdown output.
- Process the HTML content using the existing pipeline for HTML conversion.
- Output: A Markdown file or string, similar to the handling of other file types.
Examples
CLI:
markitdown path-to-file.mhtml > document.md
Python API:
from markitdown import MarkItDown
md = MarkItDown()
result = md.convert("example.mhtml")
print(result.text_content)
Challenges & Considerations
- Parsing Embedded Resources: Properly handling and optionally excluding embedded resources could require additional tooling.
- Dependencies: Adding support for MHTML might introduce new dependencies for handling MIME encapsulated data.
References
I believe this feature would significantly enhance MarkItDown's capabilities and appeal to a broader user base. Thank you for considering this request!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the markitdown command entry point and the MarkItDown Python API, then trace how existing HTML inputs reach the conversion pipeline. Review how MIME-encapsulated content and embedded resources should be handled. Done means .mhtml files work through both CLI and API and produce Markdown through the existing HTML conversion path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, python
- Domain
- backend, content
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100