Skip to main content

Dextract

Dextract is a Python package designed for extracting content from any document type (PDF, DOCX, PPTX, etc.) into structured HTML and logical sections. By leveraging Apache Tika, it converts binary files into XHTML and logically oorganizes the content into a hierarchical model of headings, paragraphs, tables, and images.

Features

  • Hierarchical Extraction: Groups content into sections based on h1-h6 tags.
  • Breadcrumb Tracking: Maintains the full heading path for each section.
  • Rich Element Parsing:
    • Prose: Cleaned and normalized text from block-level tags.
    • Tables: Parsed into pipe-delimited Markdown-style text, including headers and metadata.
    • Lists: Ordered and unordered lists with appropriate prefixes.
    • Images: Extraction of src, alt, title, and dimensions.
    • Embedded Objects: Identification of Tika-embedded sub-documents and OLE objects.
    • Code Blocks: Preservation of formatting and language detection.
    • Quotes & Definitions: Structured extraction of blockquotes and definition lists.
  • Confluence Formatting: Includes a specialized formatter to convert Tika XHTML directly into Confluence Storage Format.

Installation

pip install dextract

Quick Start

File Parsing with Apache Tika

Dextract includes a utility to wrap Apache Tika for parsing binary files (like PDFs or Word documents) into XHTML, which can then be processed.

from dextract import parse_file, process_html

# Parse a binary file into HTML and metadata
# Use extract_media=True to pull out attachments/images
parsed = parse_file("report.pdf", extract_media=True)

# Process the resulting HTML into structured sections
sections = process_html(parsed["html_content"])

Basic Extraction (from HTML)

from dextract import process_html, summarise

# Raw HTML from Tika (or any other source)
html_content = """
<html>
    <body>
        <h1>Project Overview</h1>
        <p>This is a sample document.</p>
        <h2>Key Features</h2>
        <ul>
            <li>Fast extraction</li>
            <li>Structured output</li>
        </ul>
    </body>
</html>
"""

# Process the HTML into sections
sections = process_html(html_content)

# Print a summary of the extracted sections
summarise(sections)

Confluence Formatting

from dextract.formatter import ConfluenceFormatter

tika_html = "..." # Raw XHTML from Tika
attachments = {"image1.png": b"..."} # Optional attachment data

formatter = ConfluenceFormatter(tika_html, attachments)
confluence_xhtml = formatter.convert()

Package Structure

  • dextract.processor: The primary entry point (process_html).
  • dextract.parser: File parsing utilities using Apache Tika (parse_file).
  • dextract.models: Core data structures (Section, Element).
  • dextract.traversal: The engine that walks the HTML tree.
  • dextract.element_parsers: Specialized parsers for different HTML tags.
  • dextract.formatter: Confluence Storage Format conversion utilities.
  • dextract.debug: Helpers for inspection and statistics.

License

MIT

Metadata

Release files for dextractpy 0.1.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 dextractpy 0.1.0
File Size Uploaded Provenance
dextractpy-0.1.0.tar.gz 19.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dextractpy 0.1.0
File Interpreter ABI Platform
dextractpy-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.8 kB

Release files / dextractpy-0.1.0.tar.gz

Download URL dextractpy-0.1.0.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8d1142f3465f0cc437de91a394ef3012432137b14d7564f0651092b1d0ee2aca
BLAKE2b-256 checksum
How to use checksums
555f92595681d1757be172eb62fff14d5bf79121ba7bea8751d297caad23f136
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.10 Darwin/25.1.0

Release files / dextractpy-0.1.0-py3-none-any.whl

Download URL dextractpy-0.1.0-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0dacc35b6dc949edf244134dea78c19a7dd00bdd005d175e206df3ddbe1f059f
BLAKE2b-256 checksum
How to use checksums
acac0d1a9deb0075f9356f49a23a63860313f992e2ace6fbc2ca7da24ff8b776
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.10 Darwin/25.1.0

Security for dextractpy 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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