html-to-markdown is a high-performance Python library for converting HTML to Markdown, powered by a Rust core. Currently at version 3.1.0, it offers a clean Python API and aims for consistent output across multiple language bindings. The library is actively maintained with ongoing development and performance enhancements.
pip install html-to-markdownVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic HTML to Markdown conversion using the `convert` function. It also shows how to apply `ConversionOptions` to customize the output format, such as specifying heading styles or using Djot instead of standard Markdown.
Consult the library's CHANGELOG for specific migration steps. Consider using `html_to_markdown.v1_compat` if direct migration is complex.
Pre-process HTML with a tool like BeautifulSoup to simplify or strip unwanted elements before conversion. Review converted Markdown carefully for fidelity.
For critical code blocks or tables, manually verify the output. Consider using the 'Visitor Pattern' feature (`convert_with_visitor`) for fine-grained control over specific element conversions, especially for `pre` and `code` tags.
Use `from html_to_markdown import convert_with_metadata` and process the returned dictionary, e.g., `result = convert_with_metadata(html_content); markdown_content = result['content']; metadata = result['metadata']`.
Ensure the package is correctly installed using pip: `pip install html-to-markdown`
Import the `convert` function specifically and use it to perform the conversion: `from html_to_markdown import convert markdown = convert(html_content)`
Review the library's documentation for `ConversionOptions` and `visitor` patterns to customize conversion behavior. For very complex or problematic HTML, consider preprocessing the HTML with a library like BeautifulSoup to simplify it before passing to `html-to-markdown`, or handling specific elements with custom logic during conversion.
No dependency data recorded yet.