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.2.0

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.2.0
File Size Uploaded Provenance Actions
markkit-0.2.0.tar.gz 804.8 kB With provenance Details for markkit-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for markkit 0.2.0
File Interpreter ABI Platform Actions
markkit-0.2.0-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.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 7.6 MB

Release files / markkit-0.2.0.tar.gz

Download URL markkit-0.2.0.tar.gz
Size 804.8 kB
Tags Source
SHA-256 checksum
How to use checksums
887979818895dc80d727408ff49e5ca70c7b39f8c6097a637ba90edbc9b175d7
BLAKE2b-256 checksum
How to use checksums
c69c3439522207be079a42daa8a26e522a41d728ecf200bb209f4f8a40485e33
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 Oct 31, 2026.

Transparency log

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

Download URL markkit-0.2.0-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
22f46d9374fd9549f1aeae723a3c3eb0a73fc03bd6164187c7cd2a0ea0d5e341
BLAKE2b-256 checksum
How to use checksums
a2eed609ae3695cafb291da950d951ac715c590ca49fd045e0aa22a3e749b893
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 Oct 31, 2026.

Transparency log

Security for markkit 0.2.0

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.2.0.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 Oct 31, 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