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://tmz.com")

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://tmz.com")

text_plain = html2text_rs.text_plain(resp.text)
print(text_plain)

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.1.0.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distributions

html2text_rs-0.1.0-cp38-abi3-win_amd64.whl (361.2 kB view hashes)

Uploaded CPython 3.8+ Windows x86-64

html2text_rs-0.1.0-cp38-abi3-win32.whl (352.8 kB view hashes)

Uploaded CPython 3.8+ Windows x86

html2text_rs-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl (666.7 kB view hashes)

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

html2text_rs-0.1.0-cp38-abi3-musllinux_1_2_i686.whl (652.9 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ i686

html2text_rs-0.1.0-cp38-abi3-musllinux_1_2_armv7l.whl (709.8 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ ARMv7l

html2text_rs-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl (654.9 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ ARM64

html2text_rs-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (495.5 kB view hashes)

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

html2text_rs-0.1.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (665.5 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ s390x

html2text_rs-0.1.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (537.9 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ppc64le

html2text_rs-0.1.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (446.1 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

html2text_rs-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (475.2 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

html2text_rs-0.1.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (474.8 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.5+ i686

html2text_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (413.6 kB view hashes)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

html2text_rs-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl (428.2 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