Skip to main content

Convert between .docx and .md files with template support

Project description

DocxMD Converter

PyPI version Python 3.8+ License: MIT

A powerful Python package for converting between Microsoft Word (.docx) and Markdown (.md) files with template support and recursive directory processing.

✨ Features

  • Bidirectional conversion: .docx.md
  • Template support: Use custom .docx templates for consistent formatting
  • Recursive processing: Convert entire directory trees while preserving structure
  • Dual interfaces: Both CLI and GUI applications
  • Cross-platform: Works on Windows, macOS, and Linux
  • Batch processing: Convert multiple files in one operation
  • Detailed logging: Track conversion progress and errors

🚀 Quick Start

Installation

pip install docxmd-converter

Note: This package requires Pandoc to be installed on your system.

Installing Pandoc

On Ubuntu/Debian:

sudo apt-get install pandoc

On macOS:

brew install pandoc

On Windows: Download from pandoc.org or use Chocolatey:

choco install pandoc

Command Line Usage

Convert .docx files to Markdown

docxmd --src ./documents --dst ./markdown --direction docx2md

Convert Markdown to .docx with template

docxmd --src ./markdown --dst ./documents --direction md2docx --template ./template.docx

Enable verbose logging

docxmd --src ./input --dst ./output --direction docx2md --verbose

GUI Usage

Launch the graphical interface:

docxmd-gui

The GUI provides an intuitive interface with:

  • Directory selection dialogs
  • Conversion direction selection
  • Template file picker
  • Real-time conversion logging
  • Progress tracking

📖 Detailed Usage

CLI Parameters

Parameter Required Description
--src Source directory containing files to convert
--dst Destination directory for converted files
--direction Conversion direction: docx2md or md2docx
--template Path to .docx template (only for md2docx)
--verbose Enable detailed logging

Python API

from docxmd_converter import DocxMdConverter

# Initialize converter
converter = DocxMdConverter()

# Convert a single file
success = converter.convert_file(
    input_file="document.docx",
    output_file="document.md",
    direction="docx2md"
)

# Convert entire directory
successful, total = converter.convert_directory(
    src_dir="./documents",
    dst_dir="./markdown",
    direction="docx2md"
)

print(f"Converted {successful}/{total} files")

Using Templates

Templates allow you to maintain consistent formatting when converting from Markdown to Word:

  1. Create a .docx file with your desired styles (fonts, colors, spacing, etc.)
  2. Use it as a template in conversion:
docxmd --src ./markdown --dst ./documents --direction md2docx --template ./my_template.docx

The template's styles will be applied to:

  • Headings (H1-H6)
  • Body text
  • Lists (ordered and unordered)
  • Tables
  • Code blocks

🏗️ Project Structure

docxmd_converter/
├── __init__.py          # Package initialization
├── cli.py              # Command-line interface
├── gui.py              # Graphical user interface
└── core.py             # Core conversion functionality

🔧 Development

Setup Development Environment

# Clone the repository
git clone https://github.com/yourusername/docxmd-converter.git
cd docxmd-converter

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .

# Install development dependencies
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

# Format code
black docxmd_converter/

# Sort imports
isort docxmd_converter/

# Lint code
flake8 docxmd_converter/

📋 Requirements

  • Python 3.8+
  • Pandoc (external dependency)
  • pypandoc>=1.11
  • python-docx>=0.8.11

🐛 Known Issues

  • Large files: Very large .docx files may take considerable time to convert
  • Complex formatting: Some advanced Word formatting may not translate perfectly to Markdown
  • Images: Image handling depends on Pandoc's capabilities

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

If you encounter any problems or have questions, please:

  1. Check the GitHub Issues
  2. Create a new issue if needed
  3. Provide detailed information about your problem

🗺️ Roadmap

  • Enhanced template customization through GUI
  • Support for additional formats (PDF, HTML)
  • Batch template application
  • Integration with cloud storage services
  • Plugin system for custom converters

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

docxmd_converter-0.1.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

docxmd_converter-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docxmd_converter-0.1.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for docxmd_converter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 07faf6cacd389f320d6a955f24bd2b887d25232691902e6a370970e3a43e97da
MD5 0778f4e50f3e094dab6210e953989b83
BLAKE2b-256 ce2ecd72f5d9fafe4c3007e026c30fb0071a379bb0409730895319917623d9d7

See more details on using hashes here.

File details

Details for the file docxmd_converter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docxmd_converter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0aa0b655cf4fcce4e77a5192354a65ef320513c8a8fa153fd7592ebb111995d
MD5 bcb0137873e6e34cadee5850b3504c75
BLAKE2b-256 4da87a67ce25471c9b5892fa2433cd2bd800abefe08fe69b26542a4db1719a0a

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