Skip to main content

A package for processing and analyzing raw document formats

Project description

Raw DOCX

A Python library that extends python-docx to convert Word documents into structured, traversable Python objects with export to dictionary, HTML, and plain text formats.

Installation

pip install raw_docx

Features

  • Document hierarchy - Multi-level section numbering that mirrors Word: only headings Word actually numbers get a number; unnumbered headings (front matter, bullets, "no number" styles) are kept as sections without one
  • Rich text - Colors, highlighting, bold, italic, superscript, and subscript
  • Tables - Full support for merged cells (row and column spans)
  • Nested lists - Arbitrary nesting depth with level tracking and numId boundary detection
  • Indentation hierarchy - Infers nesting from indentation when all items share the same level
  • Bookmarks and cross-references - Bookmark anchors and field-based references
  • Image extraction - Extracts embedded images with base64 HTML embedding
  • Multiple export formats - Dictionary, HTML, and plain text
  • Search - Find text across sections, tables, and the full document
  • Error tracking - Integrated logging via simple_error_log

Quick Start

from raw_docx import RawDocx

# Load and process a document
docx = RawDocx("path/to/document.docx", work_dir="/tmp/output")

# Disable indentation-based hierarchy inference if needed
# docx = RawDocx("path/to/document.docx", infer_indent_hierarchy=False)

# Access the structured document
document = docx.target_document

# Export to dictionary
data = docx.to_dict()

# Work with sections
section = document.section_by_title("Introduction")
paragraphs = section.paragraphs()
tables = section.tables()
lists = section.lists()

# Search for content
results = section.find("keyword")

# Generate HTML
html = section.to_html()

Key Classes

Class Description
RawDocx Main entry point; loads and processes a .docx file
RawDocument Top-level container managing sections and hierarchy
RawSection A document section/heading with its content
RawParagraph A paragraph containing runs and bookmarks
RawRun A text run with formatting attributes
RawTable / RawTableRow / RawTableCell Table structure with merged cell support
RawList / RawListItem Nested list structure
RawImage Embedded image handling

Requirements

License

MIT - see LICENSE for details.

Build and Release

pytest
ruff format
ruff check
python3 -m build --sdist --wheel
twine upload dist/*

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

raw_docx-0.15.0.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raw_docx-0.15.0-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file raw_docx-0.15.0.tar.gz.

File metadata

  • Download URL: raw_docx-0.15.0.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for raw_docx-0.15.0.tar.gz
Algorithm Hash digest
SHA256 8695d787e01a5793519320fcbfaa2459e8aa6d10a8a79c50f8ae6d3811e2d0d7
MD5 091c5c4dedb178de2b018e241ed63858
BLAKE2b-256 aa2212afba339f80acf1adb9f5f9411b0bdf0e9453bb038dfb8d07c00a14b718

See more details on using hashes here.

File details

Details for the file raw_docx-0.15.0-py3-none-any.whl.

File metadata

  • Download URL: raw_docx-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for raw_docx-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ef4f89148c52dde374d5753c40a76957329007987e5685c86d7da8d4440b4fb
MD5 de62e914369c0d8ac0b747df966002e5
BLAKE2b-256 98fcf6dcb03759cc29c3233e3acb00e72b18fe16ac3c0233acf600b389be70b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page