Metadata-Version: 2.4
Name: legacy-doc
Version: 0.1.0
Summary: Pure-Python text extraction for classic Microsoft Word .doc files.
Project-URL: Homepage, https://github.com/lcorrigan704/legacy-doc
Project-URL: Repository, https://github.com/lcorrigan704/legacy-doc
Project-URL: Issues, https://github.com/lcorrigan704/legacy-doc/issues
Author: Liam Corrigan
License-Expression: MIT
License-File: LICENSE
Keywords: doc,ole,pure-python,text-extraction,word
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: hatchling>=1.27; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: twine>=5; extra == 'dev'
Description-Content-Type: text/markdown

# legacy-doc

`legacy-doc` is a small, dependency-free Python library for extracting readable text from classic Microsoft Word `.doc` files.

It is intentionally narrow:

- supports OLE Compound File Word 97-2003 `.doc` files
- extracts normalized text from the Word piece table
- rejects encrypted, malformed, non-OLE, or unsafe files clearly
- does not execute macros, embedded objects, links, scripts, or external references
- does not use native binaries, LibreOffice, `antiword`, or third-party parsers

## Install

```bash
pip install legacy-doc
```

## Usage

```python
from legacy_doc import extract_text

with open("document.doc", "rb") as file:
    result = extract_text(file.read())

print(result.text)
print(result.metadata)
```

## API

```python
extract_text(document_bytes: bytes, *, options: ExtractionOptions | None = None) -> DocExtractionResult
```

`DocExtractionResult` contains:

- `text`: normalized extracted text
- `parser`: parser name
- `version`: parser version
- `metadata`: lightweight extraction metadata
- `warnings`: non-fatal parser warnings

## Limitations

This is not a full Microsoft Word renderer. It aims to recover readable text safely from common legacy `.doc` files. Formatting fidelity, OCR, images, macros, tracked changes, and embedded object extraction are out of scope.

## Development

```bash
python -m pip install -e ".[dev]"
python -m pytest
python -m build
python -m twine check dist/*
```

The test suite includes small generated OLE WordDocument fixtures and malformed corpus cases for parser limits, encryption markers, missing piece tables, and cyclic FAT chains.

## Security

`legacy-doc` treats input files as untrusted binary data. It performs bounded parsing, rejects encrypted documents, and never executes macros or embedded content. Report security issues privately before opening a public issue.
