Skip to main content

Convert legacy MS Word .doc files to Markdown — inspired by antiword

Project description

unword

Convert legacy Microsoft Word .doc files (OLE/CFB format) to Markdown. Inspired by antiword.

Extracts body text with heading levels, page breaks, and textbox contents. No external dependencies (no LibreOffice, no COM).

Installation

CLI (Rust)

cargo build --release

Python

Requires maturin and a virtual environment:

uv venv .venv && source .venv/bin/activate
maturin develop

Or build a wheel:

maturin build --release
pip install target/wheels/unword-*.whl

Usage

CLI

# Print to stdout
unword -i document.doc

# Write to file
unword -i document.doc -o output.md

Python

import unword

doc = unword.parse_doc(open("document.doc", "rb").read())

print(doc.body_text)      # Markdown string with headings
print(doc.textboxes)      # List of textbox strings

Rust library

let data = std::fs::read("document.doc")?;
let doc = unword::parse_doc(&data)?;
println!("{}", doc.body_text);

Output format

  • Headings are rendered as #, ##, ###, etc. based on Word styles
  • Paragraphs are separated by blank lines
  • Page breaks become ---
  • Textboxes are extracted separately

Tests

# Rust
cargo test

# Python
pytest tests/test_python.py

License

MIT

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

unword-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

unword-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl (438.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

File details

Details for the file unword-0.1.0.tar.gz.

File metadata

  • Download URL: unword-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for unword-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9355e433abbdfc02a3d1212caabcd93eb0e0c3c5b77e2a25e221495a5b562dec
MD5 9628bef9f1f3fad3873b3ffc21349ea5
BLAKE2b-256 2a49e2d1ca5bf1352cf1ee660143ec4812ce60af95ec9ca43544808dcfb363ca

See more details on using hashes here.

File details

Details for the file unword-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for unword-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 42f55ddb980b6db041e3641652c7256e8c0fba160d6ca68370ce598460224591
MD5 3cecc6cebfa8d299e3295b5231c19b23
BLAKE2b-256 7306ebab2f6963a04b64d09a6a7d5b60e4033f16a2108d09930de7e6fe3491cc

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