Skip to main content

markdown-html-finder PyPI

A Python library to locate HTML spans in markdown text. This library is written in Rust with bindings for Python.

why?

For a separate project I needed to locate HTML comments in markdown documents. Sadly the markdown parsers I found for Python didn't provide span information for nodes.

While it wouldn't be too hard to add some features to existing Python markdown parsers, I thought it would be interesting to see how Rust can be used from Python. The excellent pulldown-cmark crate provides span information for HTML elements, so that's what we use here.

pyo3 and maturin do the hard work of providing bindings to Python and building wheels to distribute on PyPi.

install

# poetry
poetry add markdown-html-finder

# pip
pip install markdown-html-finder

usage

from markdown_html_finder import find_html_positions

DOCUMENT = """\
# example markdown document

Amet nobis et numquam qui. Animi perferendis quia qui ut aut expedita. Ut eveniet quia quaerat.
<!-- hello world -->
Quisquam et et velit soluta quia.
"""

# NOTE: find_html_positions raises a ValueError if passed carriage returns `\r`
stripped_document = DOCUMENT.replace('\r', '')
html_positions = find_html_positions(stripped_document)
assert html_positions == [(125, 145)]

dev

# install build dependencies
poetry install

# build for python development
poetry run maturin development

building wheels

We need a wheel per version and platform. To support Python 3.7, 3.8, 3.9 we need to have 3.7, 3.8, 3.9 installed on macOS and Linux. For macOS we can use pyenv. For Linux we can use a Docker container.

macos

  1. install pyenv
  2. install each python version we want to support via pyenv install. Use pyenv install --list to see the available options.
  3. add your new Python installs globally via pyenv global 3.8.7 3.9.0
  4. configure your $PATH with the .pyenv python versions. use pyenv shims to find the binary paths and add them, like PATH=/Users/chris/.pyenv/shims/:$PATH
  5. verify your Python versions are accessible via python3.9 and verify maturin can find your python versions via ./.venv/bin/maturin list-python
  6. build the macOS wheels via ./.venv/bin/maturin build
  7. upload wheels to pypi via ./.venv/bin/twine upload --skip-existing target/wheels/*

linux

  1. use the docker container to build all the Linux Python wheels via docker run --rm -v $(pwd):/io cdignam/markdown-html-finder-builder:0.3.0 build --release
  2. upload wheels to pypi via ./.venv/bin/twine upload --skip-existing target/wheels/*

markdown-html-finder-builder

This container extends the quay.io/pypa/manylinux2014_x86_64 docker image and is based on the konstin2/maturin image, with Python2 support removed.

This image is built and uploaded manually to Docker Hub when necessary.

# build and publish a new version
VERSION='0.2.0'
docker build -f build.Dockerfile . --tag cdignam/markdown-html-finder-builder:$VERSION
docker push cdignam/markdown-html-finder-builder:$VERSION

Release files for markdown-html-finder 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdown-html-finder 0.2.5
File Size Uploaded
markdown_html_finder-0.2.5.tar.gz 37.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for markdown-html-finder 0.2.5
File
markdown_html_finder-0.2.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.5+ x86-64 Details
markdown_html_finder-0.2.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.5+ x86-64 Details
markdown_html_finder-0.2.5-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
markdown_html_finder-0.2.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-64 Details
markdown_html_finder-0.2.5-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
markdown_html_finder-0.2.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
markdown_html_finder-0.2.5-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details
markdown_html_finder-0.2.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
markdown_html_finder-0.2.5-cp37-cp37m-macosx_11_0_arm64.whl CPython 3.7 CPython 3.7 pymalloc macOS 11.0+ ARM64 Details

Total release size: 8.3 MB

Release files / markdown_html_finder-0.2.5.tar.gz

Download URL markdown_html_finder-0.2.5.tar.gz
Size 37.8 kB
Tags Source
SHA-256 checksum
How to use checksums
12188883422f6342a78f8acf60e2c753e09946d00696b1f9ba86d8f532192f1c
BLAKE2b-256 checksum
How to use checksums
9e73d82a6056090900c05cd31f9a532742a63c365345beb836c9b719d270129b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / markdown_html_finder-0.2.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL markdown_html_finder-0.2.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.1 MB
Tags CPython 3.11 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
0a2637763a23d4bad98ad40e1d6563e28cea19faa9508dfaa69c9b8cf0ddda78
BLAKE2b-256 checksum
How to use checksums
524605443089368a6739a9a56b8ecb2e21a129c7b2596a12325732326532e7d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / markdown_html_finder-0.2.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL markdown_html_finder-0.2.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
6ac8de530f5209de88a056287c3836266db02f2ad27e5f666e65dcb624852371
BLAKE2b-256 checksum
How to use checksums
345119408d31f835486299d48e7f3f13097a2d3ef5cec52dd3fc231b69545439
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / markdown_html_finder-0.2.5-cp310-cp310-macosx_11_0_arm64.whl

Download URL markdown_html_finder-0.2.5-cp310-cp310-macosx_11_0_arm64.whl
Size 660.4 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c7b893f56650d0013ed1061cc883b4f67185b16113d02a3b96a688d47db34016
BLAKE2b-256 checksum
How to use checksums
d22e214cd7959802bdf91be9efdc95818453b1454ac0025737794c0b676fec7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / markdown_html_finder-0.2.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL markdown_html_finder-0.2.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.1 MB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
86afbb199c139e7eef27e9ad134c0781867b54124461721db261bdb3bb82f6ce
BLAKE2b-256 checksum
How to use checksums
8866a61fb3c61b3cb1f15451fbf583a4651aaa5164846fc34d8cf4d08831bc5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / markdown_html_finder-0.2.5-cp39-cp39-macosx_11_0_arm64.whl

Download URL markdown_html_finder-0.2.5-cp39-cp39-macosx_11_0_arm64.whl
Size 660.3 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fbecdd05ac013b27a1ed130cdbc9d0ff1fc367a9f242697f4c3897854440b877
BLAKE2b-256 checksum
How to use checksums
dcadb2e165ac819614be3cd3ada316462a5e1628b112c3ae616473f4b2324eff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / markdown_html_finder-0.2.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL markdown_html_finder-0.2.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.1 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2ea98e46c67747190620afeb5ccfffef3b8090df281465917d8d4a025a2c39cc
BLAKE2b-256 checksum
How to use checksums
4b96e12602d01057126eff0550309dff00293fc810111019141c5e9b6cc3a10c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / markdown_html_finder-0.2.5-cp38-cp38-macosx_11_0_arm64.whl

Download URL markdown_html_finder-0.2.5-cp38-cp38-macosx_11_0_arm64.whl
Size 660.1 kB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dfeca5ae00b1e5e19c1c4b93e63976c8279c98aca74d525f0cdf85c5501c3c03
BLAKE2b-256 checksum
How to use checksums
adec46557380115ed67cfe194af7b7b6884719f8b927c133171cb5fa8156f5e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / markdown_html_finder-0.2.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL markdown_html_finder-0.2.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.1 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a24e093b21dc699c638283a58598cbbb2489e029bcc8d90fddc608ddd8e78f9a
BLAKE2b-256 checksum
How to use checksums
6c69b18e9743323836afc49751e38257dc2f01cb764bdd2d6bf6e21f0c92e1b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / markdown_html_finder-0.2.5-cp37-cp37m-macosx_11_0_arm64.whl

Download URL markdown_html_finder-0.2.5-cp37-cp37m-macosx_11_0_arm64.whl
Size 660.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5588c0dcba92c8425d5e7d17a57fe6db22a94d78313094b701b6b3a8ce1d2c23
BLAKE2b-256 checksum
How to use checksums
f13df5865fa11736a62dd93db7c81965953dc792eabbfa3d81b3e9db36a7dd94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.2.5 This release

10 release files

0.2.4

5 release files

0.2.3

14 release files

0.2.2

8 release files

0.2.1

1 release file

0.2.0

4 release files

0.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page