Skip to main content

Markkit for Python

Native Python bindings for Markkit HTML-to-Markdown extraction.

The PyPI distribution and Python import are both named markkit (pip install markkit, then import markkit). The Rust crate remains markkit-python.

The current wheel publisher builds for Linux x64 and CPython 3.12. It does not publish macOS, Windows, ARM64 or other Python-version wheels. A source distribution is also published; source builds require Rust and native build tools and are validated with Rust 1.99. Other wheel targets require a separate future release; Rust and npm availability is independent.

import markkit

print(markkit.extract_html_sync("<h1>Hello</h1>"))
# # Hello

# Resource limits (all optional, generous defaults); breaches raise RuntimeError
limits = markkit.Limits(timeout=10.0, max_output_size=8 << 20, max_nesting_depth=128)
markkit.extract_html_sync("<h1>Hello</h1>", limits=limits)

Limits fields: max_input_size, max_output_size, timeout (seconds), max_nesting_depth, max_nodes, max_archive_entries, max_archive_entry_size, max_archive_total_size, max_sheet_rows, max_sheet_cols, max_spreadsheet_cells, max_redirects, max_pdf_pages, max_pdf_stream_size, max_pdf_decoded_size. Every function accepts limits=.

Publication verifies wheel metadata, installs the actual wheel into a clean virtual environment and exercises native extraction before upload.

The manual publisher uses PyPI Trusted Publishing (OIDC), without a stored PyPI API token. A dry run builds and verifies distributions without publishing.

Python packaging is configured by the workspace-root pyproject.toml. Source archives retain the complete Cargo workspace and its unchanged security lockfile.

Structured documents, PDF layout and OCR

from markkit import extract_document_sync, Limits
result = extract_document_sync(
    pdf_bytes, file_name="report.pdf", pdf_layout=True,
    pdf_remove_repeated_headers=True,
)
print(result["markdown"], result["stats"]["tables"])
print(result["layout"]["pages"][0]["blocks"])

PDF extraction reconstructs reading order, columns and ruled/borderless tables, with merged/wrapped cells, emphasis, numbered lists and tagged headings/ActualText. Layout includes source runs/words and semantic block/line/cell geometry. Keys are snake_case; coordinates are display points from the cropped/rotated top-left.

For image-only pages, install Tesseract and your language data: extract_document_sync(pdf_bytes, file_name="scan.pdf", pdf_ocr=True, pdf_ocr_language="eng", pdf_layout=True, limits=Limits(timeout=300)). OCR is opt-in and only processes pages without text. Resource limits also bound geometry, grid expansion, raster dimensions/helper files and process deadlines.

Optional Rust OCR backend

Source builds can enable Cargo feature pdf-ocr-ocrs (for example, maturin build --features pdf-ocr-ocrs). Default wheels retain Tesseract. Prepare the repository's pinned model pair with python3 scripts/prepare_ocr_models.py, then use:

markkit.extract_document_sync(
    data, file_name="scan.pdf", pdf_ocr=True, pdf_ocr_backend="ocrs",
    pdf_ocr_detection_model="/models/text-detection.onnx",
    pdf_ocr_recognition_model="/models/text-recognition.onnx",
    limits=markkit.Limits(timeout=300),
)

Extraction never downloads models. The pinned weights are CC-BY-SA 4.0 assets with attribution in the setup script's NOTICE.json. The current Latin model accepts pdf_ocr_language="eng" only. Model files are trusted deployment assets; inference deadlines are cooperative and hard CPU/memory limits require host quotas. Invalid backend names raise ValueError; missing features/models and unsupported languages raise RuntimeError.

Metadata

Release files for markkit 0.3.1

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

Source distribution (sdist)

Source distribution for markkit 0.3.1
File Size Uploaded Provenance Actions
markkit-0.3.1.tar.gz 810.3 kB With provenance Details for markkit-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for markkit 0.3.1
File Interpreter ABI Platform Actions
markkit-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for markkit-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 7.6 MB

Release files / markkit-0.3.1.tar.gz

Download URL markkit-0.3.1.tar.gz
Size 810.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eb3a795c6433081409c69d010130260885450d7c108142b357e7a2fcd9ad2775
BLAKE2b-256 checksum
How to use checksums
420e1149bba627249991822b42e1944e596d934d46d4c1301f5d4fbabf8f80cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / markkit-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL markkit-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 6.8 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5b718e794be52ec1b4cfa441e86840d4c6e00c2dbeb45d55f4de5ecf1cf4f98a
BLAKE2b-256 checksum
How to use checksums
59f9871e9eb83bd401f340a9a79089e95690b0bb91bd4c7a8341f85a04547957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for markkit 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for markkit-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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