Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

doc-to-md-cli

Convert PDF and DOCX files to Markdown from the command line — no AI agent needed.

Features

  • PDF → Markdown via marker-pdf (tables, formulas, layouts)
  • DOCX → Markdown via docling
  • Image extraction — saves images as separate files, referenced in the markdown
  • Batch mode — convert entire folders recursively, preserving directory structure
  • Dry-run — preview what would be converted

Requirements

  • Python 3.9+

Install

git clone https://github.com/adg81/doc-to-md-cli.git
cd doc-to-md-cli
pip install -e .

Or install directly from GitHub:

pip install git+https://github.com/adg81/doc-to-md-cli.git

Development install

pip install -e ".[dev]"

Usage

Single file

# Output defaults to same name with .md extension
doc-to-md-cli document.pdf

# Specify output path
doc-to-md-cli report.docx -o output/report.md

Batch (recursive folder)

# Converts all PDF/DOCX in docs/, output in out/ with same structure
doc-to-md-cli ./docs/ -o ./out/

# Example: docs/2024/annual.pdf → out/2024/annual.md

Options

doc-to-md-cli docs/ -o out/ [OPTIONS]

  -o, --output PATH    Output file or directory
  --no-images          Disable image extraction
  --dry-run            Show what would be converted without converting
  -v, --verbose        Detailed output
  --version            Show version

Examples

# Preview what will be converted
doc-to-md-cli ./my-folder/ --dry-run

# Convert without extracting images
doc-to-md-cli document.pdf --no-images

# Verbose batch conversion
doc-to-md-cli ./library/ -o ./markdown/ --verbose

How images work

  • PDF: marker-pdf saves images as _page_0_Picture_1.jpeg alongside the .md file
  • DOCX: images are extracted from the DOCX archive into a <name>_immagini/ folder

In both cases, the markdown contains relative references like ![alt](_page_0_Picture_1.jpeg).

Project structure

doc-to-md-cli/
├── pyproject.toml
├── Makefile
├── README.md
├── CHANGELOG.md
├── LICENSE
├── src/doc_to_md_cli/
│   ├── __init__.py
│   ├── __main__.py        # python -m doc_to_md_cli
│   ├── cli.py             # Argument parsing
│   ├── converter.py       # PDF (marker) + DOCX (docling) conversion
│   └── discover.py        # Recursive file discovery
└── tests/
    ├── test_discover.py
    └── test_cli.py

Run tests

make test

License

MIT

About

Convert PDF and DOCX files to Markdown from the command line — no AI agent needed.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages