![Python >= 3.8](https://img.shields.io/badge/python->=3.8-red.svg) [![](https://badgen.net/github/release/deedy5/html2text_rs)](https://github.com/deedy5/html2text_rs/releases) [![](https://badge.fury.io/py/html2text_rs.svg)](https://pypi.org/project/html2text_rs) [![Downloads](https://static.pepy.tech/badge/html2text_rs/week)](https://pepy.tech/project/html2text_rs) [![CI](https://github.com/deedy5/html2text_rs/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/deedy5/html2text_rs/actions/workflows/CI.yml)
# html2text_rs
Convert HTML to markdown or plain text.</br>
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)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "html2text-rs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "python, html2text, html-to-text, html-to-markdown, html2md, markdown",
"author": "deedy5",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/c0/32/d497ec967c11ec3815015d2e3b0ff9492f26ffde57d261ea1f6d41f62897/html2text_rs-0.2.0.tar.gz",
"platform": null,
"description": "![Python >= 3.8](https://img.shields.io/badge/python->=3.8-red.svg) [![](https://badgen.net/github/release/deedy5/html2text_rs)](https://github.com/deedy5/html2text_rs/releases) [![](https://badge.fury.io/py/html2text_rs.svg)](https://pypi.org/project/html2text_rs) [![Downloads](https://static.pepy.tech/badge/html2text_rs/week)](https://pepy.tech/project/html2text_rs) [![CI](https://github.com/deedy5/html2text_rs/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/deedy5/html2text_rs/actions/workflows/CI.yml)\n\n# html2text_rs\nConvert HTML to markdown or plain text.</br>\nPython binding to the rust [rust-html2text](https://github.com/jugglerchris/rust-html2text) library.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n - [text_markdown()](#1-text_markdown)\n - [text_plain()](#2-text_plain)\n - [text_rich()](#3-text_rich)\n\n## Installation\n\n```python\npip install -U html2text_rs\n```\n\n## Usage\n### 1. text_markdown()\n```python\ndef text_markdown(html: str, width: int = 100):\n \"\"\"Convert HTML to markdown text.\n\n Args:\n html (str): input html text.\n width (int): wrap text to width columns. Default is 100.\n\n \"\"\"\n```\nexample:\n```python\nimport html2text_rs\nimport requests\n\nresp = requests.get(\"https://en.wikipedia.org/wiki/AGM-88_HARM\")\n\ntext_markdown = html2text_rs.text_markdown(resp.text)\nprint(text_markdown)\n```\n### 2. text_plain()\n```python\ndef text_plain(html: str, width: int = 100):\n \"\"\"Convert HTML to plain text.\n\n Args:\n html (str): input html text.\n width (int): wrap text to width columns. Default is 100.\n\n \"\"\"\n```\nexample:\n```python\nimport html2text_rs\nimport requests\n\nresp = requests.get(\"https://en.wikipedia.org/wiki/AGM-88_HARM\")\n\ntext_plain = html2text_rs.text_plain(resp.text)\nprint(text_plain)\n```\n### 3. text_rich()\n```python\ndef text_rich(html: str, width: int = 100):\n \"\"\"Convert HTML to rich text.\n\n Args:\n html (str): input html text.\n width (int): wrap text to width columns. Default is 100.\n\n \"\"\"\n```\nexample:\n```python\nimport html2text_rs\nimport requests\n\nresp = requests.get(\"https://en.wikipedia.org/wiki/AGM-88_HARM\")\n\ntext_rich = html2text_rs.text_rich(resp.text)\nprint(text_rich)\n```\n\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Convert HTML to markdown or plain text",
"version": "0.2.0",
"project_urls": null,
"split_keywords": [
"python",
" html2text",
" html-to-text",
" html-to-markdown",
" html2md",
" markdown"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ee8f2da669b146663876ad4200e5de873d226447ff89a030ec0f0765f7f9d939",
"md5": "7420d96680501e0e3a2e3221ddba98e3",
"sha256": "a09396710e3fcead9ab37857b6f7949cc791a0f815c75d964d91a25030871539"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "7420d96680501e0e3a2e3221ddba98e3",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 457859,
"upload_time": "2024-08-01T05:58:50",
"upload_time_iso_8601": "2024-08-01T05:58:50.422379Z",
"url": "https://files.pythonhosted.org/packages/ee/8f/2da669b146663876ad4200e5de873d226447ff89a030ec0f0765f7f9d939/html2text_rs-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8af740d93a4c84496f23b6f1aa4d21db571a51e6db11168c4dc8c6e14188b4dc",
"md5": "a53170c93629257a3fe598b2294dd744",
"sha256": "ebe858f461ab874afedec8447fc12bf21a3c54ef4fbd0fa2efcab222d0301e69"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "a53170c93629257a3fe598b2294dd744",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 430278,
"upload_time": "2024-08-01T05:58:48",
"upload_time_iso_8601": "2024-08-01T05:58:48.497444Z",
"url": "https://files.pythonhosted.org/packages/8a/f7/40d93a4c84496f23b6f1aa4d21db571a51e6db11168c4dc8c6e14188b4dc/html2text_rs-0.2.0-cp38-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c564692203c07500bf06a0c9049b4717b268ce12038ed9e31c61cb42e5a0eb7b",
"md5": "eb56fbb6ecd5d47f357a736467b6643e",
"sha256": "2397fd93de5ae76c4fddc714b14dfbdc57660a22051dd683529eaeed11153d3d"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "eb56fbb6ecd5d47f357a736467b6643e",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 496861,
"upload_time": "2024-08-01T05:58:34",
"upload_time_iso_8601": "2024-08-01T05:58:34.914288Z",
"url": "https://files.pythonhosted.org/packages/c5/64/692203c07500bf06a0c9049b4717b268ce12038ed9e31c61cb42e5a0eb7b/html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "da3191da1959344cfc8a2e22715c0140c5c9707853108bf6f2fa86fad8c6b764",
"md5": "7039580bb40de4b53883cafdc3c73b7b",
"sha256": "76c386b9f1099d4da51d67b04d671544c5f96e7f9de0ecd7501589307de894c5"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
"has_sig": false,
"md5_digest": "7039580bb40de4b53883cafdc3c73b7b",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 470704,
"upload_time": "2024-08-01T05:58:36",
"upload_time_iso_8601": "2024-08-01T05:58:36.951825Z",
"url": "https://files.pythonhosted.org/packages/da/31/91da1959344cfc8a2e22715c0140c5c9707853108bf6f2fa86fad8c6b764/html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7d02b24cf92d5ccfd46c4110fb264f2f0a5af414334831939ee7b465e5049893",
"md5": "2f8756d94bca01bfbdba39b50d3a87f7",
"sha256": "c8a8efd458558180ab8cf386b87d8aefe9432aad7d61218b65a5728006c323ee"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
"has_sig": false,
"md5_digest": "2f8756d94bca01bfbdba39b50d3a87f7",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 565144,
"upload_time": "2024-08-01T05:58:39",
"upload_time_iso_8601": "2024-08-01T05:58:39.500143Z",
"url": "https://files.pythonhosted.org/packages/7d/02/b24cf92d5ccfd46c4110fb264f2f0a5af414334831939ee7b465e5049893/html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7c5ca6f4a3117c813a1b652ee639e313e7239cfcfb7b1ab15c6512da068e3fae",
"md5": "e01842e2b462b678a75080fc2e80dc2e",
"sha256": "698e7ee4cf7ba7e1a7e4a15cf3c0e71727c6e45afbe36490016d751e8abf5468"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl",
"has_sig": false,
"md5_digest": "e01842e2b462b678a75080fc2e80dc2e",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 719398,
"upload_time": "2024-08-01T05:58:41",
"upload_time_iso_8601": "2024-08-01T05:58:41.971629Z",
"url": "https://files.pythonhosted.org/packages/7c/5c/a6f4a3117c813a1b652ee639e313e7239cfcfb7b1ab15c6512da068e3fae/html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "90062dca43c9fbc817a517ecfa601e931c7eef9992d0fc637696ee76f3419b52",
"md5": "ad4a3ac4d3923b4b8faebd0f6929584a",
"sha256": "2095c764511c0c0f6ebca9d119eef6f053a516af7aa480c1ff89dfce03b94edd"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "ad4a3ac4d3923b4b8faebd0f6929584a",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 523757,
"upload_time": "2024-08-01T05:58:46",
"upload_time_iso_8601": "2024-08-01T05:58:46.247766Z",
"url": "https://files.pythonhosted.org/packages/90/06/2dca43c9fbc817a517ecfa601e931c7eef9992d0fc637696ee76f3419b52/html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5c93407e8a8a76505af1aea51224399386e33a9bb3aa6fc90f3c299128688c55",
"md5": "9fa6622138edd1c39164d7e5dc1b263b",
"sha256": "a701dce89d31f5177badb195a49dbc1c0419193a69ab92e8900792ba6daf92c2"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl",
"has_sig": false,
"md5_digest": "9fa6622138edd1c39164d7e5dc1b263b",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 501056,
"upload_time": "2024-08-01T05:58:44",
"upload_time_iso_8601": "2024-08-01T05:58:44.335907Z",
"url": "https://files.pythonhosted.org/packages/5c/93/407e8a8a76505af1aea51224399386e33a9bb3aa6fc90f3c299128688c55/html2text_rs-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "631a1c3448d75abe1ccf739e907662a4e611b2b4cbdcc5840570c91f6a4da2c4",
"md5": "66977ba1e3c89760e2873ad2248bf28e",
"sha256": "5bc98c1c6e6b6cc1b44c45b4a3368880dee81a64ea7fa8fcf2b0023294352369"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl",
"has_sig": false,
"md5_digest": "66977ba1e3c89760e2873ad2248bf28e",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 677909,
"upload_time": "2024-08-01T05:58:52",
"upload_time_iso_8601": "2024-08-01T05:58:52.602594Z",
"url": "https://files.pythonhosted.org/packages/63/1a/1c3448d75abe1ccf739e907662a4e611b2b4cbdcc5840570c91f6a4da2c4/html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1b57ebf3c1c8185c84b0ce985d11b2644578ae6185888948c3df6ce0f1b71038",
"md5": "7e9b1a2247a0a5fe0b53ebc66735057b",
"sha256": "3c457447255450b3d8db08d0be8248a9a38ed56efed117bbd6ac5e816edfa691"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl",
"has_sig": false,
"md5_digest": "7e9b1a2247a0a5fe0b53ebc66735057b",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 735135,
"upload_time": "2024-08-01T05:58:54",
"upload_time_iso_8601": "2024-08-01T05:58:54.879168Z",
"url": "https://files.pythonhosted.org/packages/1b/57/ebf3c1c8185c84b0ce985d11b2644578ae6185888948c3df6ce0f1b71038/html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "09380829199c56f8b1c436ad8664ce86c7c91b4da159a30cec1d17f2965f7e91",
"md5": "958a01ac09aa03a65b84a83b628785dc",
"sha256": "27d6910f1b6b2cec2d48767bafc2bfd6c6ea7957669b7d562a5f3fae8368a087"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_i686.whl",
"has_sig": false,
"md5_digest": "958a01ac09aa03a65b84a83b628785dc",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 678027,
"upload_time": "2024-08-01T05:58:57",
"upload_time_iso_8601": "2024-08-01T05:58:57.014054Z",
"url": "https://files.pythonhosted.org/packages/09/38/0829199c56f8b1c436ad8664ce86c7c91b4da159a30cec1d17f2965f7e91/html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8c770ebdb5a3edd2711461a20c9152ecd9fcf87a1d4eaad44a375bae72737365",
"md5": "37f86cd79b03431db0d67678f3e11cf0",
"sha256": "dfadcdc49a7fd9eb1bfa34ec9157c80188c605bfa122f01728a4fa3a031ea2f8"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "37f86cd79b03431db0d67678f3e11cf0",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 695817,
"upload_time": "2024-08-01T05:58:59",
"upload_time_iso_8601": "2024-08-01T05:58:59.451786Z",
"url": "https://files.pythonhosted.org/packages/8c/77/0ebdb5a3edd2711461a20c9152ecd9fcf87a1d4eaad44a375bae72737365/html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f9e615b673aba19ac751806d61e74e22d3e930d9d881f53020bdec1a099b39e8",
"md5": "c849b47d36252844f625133c4e60ab4d",
"sha256": "cfd29be897483a6692f20abf475de5e741dda73a7a7b4d9ef80f5a9e1b8a5e36"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-win32.whl",
"has_sig": false,
"md5_digest": "c849b47d36252844f625133c4e60ab4d",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 377026,
"upload_time": "2024-08-01T05:59:05",
"upload_time_iso_8601": "2024-08-01T05:59:05.189281Z",
"url": "https://files.pythonhosted.org/packages/f9/e6/15b673aba19ac751806d61e74e22d3e930d9d881f53020bdec1a099b39e8/html2text_rs-0.2.0-cp38-abi3-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d47f08a61c3f68bd75450c385140ffea27b870bcdd0dd99697675291e6bd0084",
"md5": "9c788d59ee93b8ff16170ca6e331728f",
"sha256": "5d795588e3564154238696c2c0f7ba7aa76ac316a98a225a91a01ed1fa031af4"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0-cp38-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "9c788d59ee93b8ff16170ca6e331728f",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 386293,
"upload_time": "2024-08-01T05:59:02",
"upload_time_iso_8601": "2024-08-01T05:59:02.717599Z",
"url": "https://files.pythonhosted.org/packages/d4/7f/08a61c3f68bd75450c385140ffea27b870bcdd0dd99697675291e6bd0084/html2text_rs-0.2.0-cp38-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c032d497ec967c11ec3815015d2e3b0ff9492f26ffde57d261ea1f6d41f62897",
"md5": "48e87cbf276f17fa61754eeeddea3829",
"sha256": "9f9a6e2351917f10e1126237eac972b456b7e4a674ed77156ad8649da570ebf6"
},
"downloads": -1,
"filename": "html2text_rs-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "48e87cbf276f17fa61754eeeddea3829",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9086,
"upload_time": "2024-08-01T05:59:01",
"upload_time_iso_8601": "2024-08-01T05:59:01.124984Z",
"url": "https://files.pythonhosted.org/packages/c0/32/d497ec967c11ec3815015d2e3b0ff9492f26ffde57d261ea1f6d41f62897/html2text_rs-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-01 05:59:01",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "html2text-rs"
}