https://github.com/deedy5/html2text_rs
Python library for converting HTML to markup or plain text
https://github.com/deedy5/html2text_rs
html-to-markdown html-to-text html2markdown html2md html2text markdown python
Last synced: 2 months ago
JSON representation
Python library for converting HTML to markup or plain text
- Host: GitHub
- URL: https://github.com/deedy5/html2text_rs
- Owner: deedy5
- License: mit
- Created: 2024-07-28T16:47:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-30T16:42:27.000Z (8 months ago)
- Last Synced: 2025-08-30T18:23:44.018Z (8 months ago)
- Topics: html-to-markdown, html-to-text, html2markdown, html2md, html2text, markdown, python
- Language: Rust
- Homepage:
- Size: 51.8 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
 [](https://github.com/deedy5/html2text_rs/releases) [](https://pypi.org/project/html2text_rs) [](https://pepy.tech/project/html2text_rs) [](https://github.com/deedy5/html2text_rs/actions/workflows/CI.yml)
# html2text_rs
Convert HTML to markdown or plain text.
Python binding to the rust [rust-html2text](https://github.com/jugglerchris/rust-html2text) library.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [text_markdown()](#1-text_markdown)
- [text_plain()](#2-text_plain)
- [text_rich()](#3-text_rich)
## Installation
```python
pip install -U html2text_rs
```
## Usage
### 1. text_markdown()
```python
def text_markdown(html: str, width: int = 100):
"""Convert HTML to markdown text.
Args:
html (str): input html text.
width (int): wrap text to width columns. Default is 100.
"""
```
example:
```python
import html2text_rs
import requests
resp = requests.get("https://en.wikipedia.org/wiki/AGM-88_HARM")
text_markdown = html2text_rs.text_markdown(resp.text)
print(text_markdown)
```
### 2. text_plain()
```python
def text_plain(html: str, width: int = 100):
"""Convert HTML to plain text.
Args:
html (str): input html text.
width (int): wrap text to width columns. Default is 100.
"""
```
example:
```python
import html2text_rs
import requests
resp = requests.get("https://en.wikipedia.org/wiki/AGM-88_HARM")
text_plain = html2text_rs.text_plain(resp.text)
print(text_plain)
```
### 3. text_rich()
```python
def text_rich(html: str, width: int = 100):
"""Convert HTML to rich text.
Args:
html (str): input html text.
width (int): wrap text to width columns. Default is 100.
"""
```
example:
```python
import html2text_rs
import requests
resp = requests.get("https://en.wikipedia.org/wiki/AGM-88_HARM")
text_rich = html2text_rs.text_rich(resp.text)
print(text_rich)
```