Skip to main content

Convert HTML to markdown or plain text

Project description

Python >= 3.8 Downloads CI

html2text_rs

Convert HTML to markdown or plain text.
Python binding to the rust rust-html2text library.

Table of Contents

Installation

pip install -U html2text_rs

Usage

1. text_markdown()

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:

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()

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:

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()

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:

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html2text_rs-0.2.0.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distributions

html2text_rs-0.2.0-cp38-abi3-win_amd64.whl (386.3 kB view hashes)

Uploaded CPython 3.8+ Windows x86-64

html2text_rs-0.2.0-cp38-abi3-win32.whl (377.0 kB view hashes)

Uploaded CPython 3.8+ Windows x86

html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl (695.8 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ x86-64

html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_i686.whl (678.0 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ i686

html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl (735.1 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ ARMv7l

html2text_rs-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl (677.9 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ ARM64

html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (523.8 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (719.4 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ s390x

html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (565.1 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64le

html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (470.7 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

html2text_rs-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (496.9 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

html2text_rs-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (501.1 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.5+ i686

html2text_rs-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (430.3 kB view hashes)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

html2text_rs-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl (457.9 kB view hashes)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page