A flexible, high-quality Markdown to Word (DOCX) converter with YAML-based styling customization.
Transform your Markdown documents into professionally formatted Word files with complete control over styling through YAML configuration files. Supports horizontal and vertical (Japanese tategaki) text, making it ideal for technical documentation, business reports, and publishing workflows.
๐ English Documentation | ๐ ๆฅๆฌ่ชใใญใฅใกใณใ
Visit our comprehensive documentation site for detailed guides, configuration examples, and API references.
- ๐จ YAML-Based Styling: Customize fonts, colors, borders, backgrounds, spacing through simple YAML files
- ๐ Rich Formatting: Headings (H1-H6), paragraphs, lists, code blocks, quotes with full styling control
- ๐ Table of Contents: Auto-generated TOC with configurable depth and title
- ๐ผ๏ธ Cover Page: Title page with centered cover image and configurable sizing
- ๐ Cross-Platform: Docker-based distribution works on Windows, Mac, Linux
- ๐ Japanese Support: Full vertical text (tategaki) support for novel and document formatting
- ๐ง Extensible: Easy-to-create custom presets for any use case
- โก Performance: Optimized for documents up to 500+ pages
- ๐ Open Source: MIT licensed, community-driven
# Pull the image from Docker Hub
docker pull forest6511/md2docx:latest
# Convert a file
docker run --rm -v $(pwd):/workspace forest6511/md2docx:latest \
input.md -o output.docx -p default --preset-dir /app/config/presets
# Or build locally
docker build -t md2docx:latest -f Dockerfile .
docker run --rm -v $(pwd):/workspace md2docx:latest \
input.md -o output.docx -p default --preset-dir /app/config/presetscd csharp-version
dotnet run --project src/MarkdownToDocx.CLI/MarkdownToDocx.CLI.csproj -- \
input.md -o output.docx -p default --preset-dir ../config/presets# Add to ~/.bashrc or ~/.zshrc
alias md2docx='docker run --rm -v $(pwd):/workspace forest6511/md2docx:latest'
# Then use simply:
md2docx input.md -o output.docx -p default --preset-dir /app/config/presetsdocker run --rm -v $(pwd):/workspace forest6511/md2docx:latest \
README.md -o README.docx -p technical --preset-dir /app/config/presetsPerfect for:
- API documentation
- Software manuals
- Technical specifications
- README files
Features: Compact layout, monospace code blocks, syntax highlighting markers
docker run --rm -v $(pwd):/workspace forest6511/md2docx:latest proposal.md -o proposal.docx -p default --preset-dir /app/config/presetsPerfect for:
- Proposals and reports
- Meeting minutes
- Project documentation
- General-purpose documents
Features: Balanced styling, professional appearance, colored headings
docker run --rm -v $(pwd):/workspace forest6511/md2docx:latest novel.md -o novel.docx -p vertical-novel --preset-dir /app/config/verticalPerfect for:
- Japanese novels
- Traditional documents
- Vertical text publications
Features: A5 page size, vertical text flow, appropriate line spacing
-
minimal- Bare minimum styling- Black & white, no borders
- Straightforward conversion
- Smallest file size
-
default- Balanced general-purpose- Colored headings (#2c3e50, #34495e)
- Bottom borders on H1/H2
- Code blocks with light gray background
- Quote blocks with left border
-
technical- Code-heavy documentation- Sans-serif fonts (Noto Sans)
- Compact layout (10pt base)
- Emphasized code blocks
- GitHub-inspired color palette
-
business- Professional business documents- Wide margins (3.0cm) for formal documents
- Navy/blue heading palette (#1a5490, #2e5c8a)
- Generous line spacing (1.75ร) for readability
- Proposals, reports, meeting minutes
vertical-novel- Japanese novel formatting- A5 page size (14.8cm ร 21.0cm)
- Vertical text direction
- Wide line spacing (440 twips)
- Minimal styling for readability
โ Currently Supported:
- Headings (H1-H6) with configurable borders, page breaks, and outline levels
- Paragraphs with inline formatting (bold, italic)
- Ordered and unordered lists
- Fenced code blocks with language specification
- Blockquotes with left border styling
- Horizontal rules (thematic breaks)
- Table of Contents (auto-generated with configurable depth)
- Cover/Title page with centered image
- Inline images (PNG/JPEG with configurable max width and alignment)
๐ง Planned for Future Releases:
- Tables
- Inline code
- Links
- Task lists
- Footnotes
- Copy an existing preset:
cp config/presets/default.yaml config/custom/my-style.yaml- Edit YAML file to customize styling:
SchemaVersion: "2.0"
Metadata:
Name: "My Custom Style"
Description: "Custom styling for my documents"
Author: "Your Name"
Version: "1.0.0"
TextDirection: "Horizontal" # or "Vertical"
Fonts:
Ascii: "Noto Serif"
EastAsia: "Noto Serif CJK JP"
DefaultSize: 11
TitlePage:
Enabled: false
ImageMaxWidthPercent: 80
ImageMaxHeightPercent: 80
PageBreakAfter: true
TableOfContents:
Enabled: false
Depth: 3
Title: "Contents"
PageBreakAfter: true
Styles:
H1:
Size: 26
Bold: true
Color: "2c3e50"
ShowBorder: true
BorderColor: "3498db"
BorderSize: 6
BorderPosition: "bottom"
BorderExtent: "text"
PageBreakBefore: true
SpaceBefore: "600"
SpaceAfter: "300"
Paragraph:
Size: 11
Color: "2c3e50"
LineSpacing: "360"
FirstLineIndent: "0"
LeftIndent: "0"
CodeBlock:
Size: 10
Color: "2c3e50"
BackgroundColor: "ecf0f1"
BorderColor: "bdc3c7"
MonospaceFontAscii: "Noto Sans Mono"
MonospaceFontEastAsia: "Noto Sans Mono CJK JP"
BorderSpace: 4
ShowBorder: true- Use your custom style:
md2docx input.md -o output.docx -c config/custom/my-style.yamlSee existing presets in config/presets/ for complete examples.
# Standard image (recommended)
./scripts/build-docker.sh
# Manual build
docker build -t md2docx:latest -f Dockerfile .| Component | Details |
|---|---|
| Base Image | mcr.microsoft.com/dotnet/runtime:8.0 |
| Size | ~560MB |
| Included Fonts | Noto Serif, Noto Sans, Noto CJK JP, Noto Mono |
| Presets | 5 built-in (minimal, default, technical, business, vertical-novel) |
# Run automated tests
./scripts/test-docker.sh
# Manual test
docker run --rm md2docx:latest --help- .NET 8.0 SDK
- Docker (optional, for container builds)
- Git
# Clone repository
git clone https://github.com/forest6511/md2docx.git
cd md2docx
# Install git hooks
./.claude/hooks/install.sh
# Build project
cd csharp-version
dotnet build
# Run tests
dotnet testmd2docx/
โโโ csharp-version/
โ โโโ src/
โ โ โโโ MarkdownToDocx.Core/ # Markdown parsing & DOCX generation
โ โ โโโ MarkdownToDocx.Styling/ # YAML configuration & styling
โ โ โโโ MarkdownToDocx.CLI/ # Command-line interface
โ โโโ tests/
โ โโโ MarkdownToDocx.Tests/ # Unit & integration tests
โโโ config/
โ โโโ presets/ # Standard presets
โ โโโ vertical/ # Vertical text presets
โโโ scripts/
โ โโโ build-docker.sh # Docker build automation
โ โโโ test-docker.sh # Docker test automation
โโโ Dockerfile # Production Docker image
โโโ docker-compose.yml # Docker Compose configuration
# Run all tests
cd csharp-version
dotnet test
# Current test coverage: 202 tests passing
# - Core layer: Unit tests for builder, parser, imaging
# - Styling layer: Unit tests for config loader, style applicator
# - Integration: End-to-end conversion tests- Create feature branch:
git checkout -b feature/your-feature - Make changes: Implement your feature
- Test:
dotnet test - Commit: Pre-commit hooks run automatically (YAML validation, secret detection)
- Push: Pre-push hooks run Codex review
- Create PR: Review and merge
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Presets: Create new YAML presets for specific use cases
- Features: Implement tables, inline code, links, nested lists
- Bug Fixes: Report and fix issues
- Documentation: Improve docs, add examples
- Testing: Add test cases, improve coverage
-
๐ English Documentation - Complete documentation in English
- Getting Started - Installation and first steps
- Configuration - YAML configuration guide
- Presets - Built-in presets reference
- API Reference - C# API documentation
-
๐ ๆฅๆฌ่ชใใญใฅใกใณใ - ๆฅๆฌ่ชใฎๅฎๅ จใชใใญใฅใกใณใ
- ใฏใใใซ - ใคใณในใใผใซใจๅๅไฝฟ็จ
- ่จญๅฎ - YAML่จญๅฎใฌใคใ
- ใใชใปใใ - ใใซใใคใณใใชใปใใใชใใกใฌใณใน
- APIใชใใกใฌใณใน - C# API ใใญใฅใกใณใ
- CLAUDE.md - Project configuration for Claude Code
- DIRECTORY_STRUCTURE.md - Complete project structure
- Config Examples - YAML preset examples
Problem: Generated DOCX shows different font than expected
Solution:
- Docker images include Noto fonts automatically
- Verify font name in YAML matches available fonts
- Use Noto family fonts for maximum compatibility
Problem: Error during conversion
Solution:
- Validate Markdown syntax
- Check YAML configuration:
python3 -c "import yaml; yaml.safe_load(open('config.yaml'))" - Run with
-vor--verboseflag for detailed error messages - Check GitHub Issues
Problem: Cannot write output file
Solution:
# Ensure output directory is writable
chmod 755 $(pwd)
# Or run with user permissions
docker run --user $(id -u):$(id -g) \
-v $(pwd):/workspace md2docx:latest input.md -o output.docxThis project is licensed under the MIT License - see the LICENSE file for details.
- Noto Fonts: SIL Open Font License 1.1
- Commercial fonts (MS Gothic, Yu Mincho, Hiragino, etc.) are NOT included
If you find this project useful, please consider giving it a star on GitHub!
Made with โค๏ธ by the open-source community