md2docx

A user-friendly tool for converting Markdown to DOCX

Installation

pip install python-md2docx

Usage

Use in CMD

md2docx --help

md2docx tests/demo.md -o tests/demo-default.docx
md2docx tests/demo.md -o tests/demo-code-as-image.docx --code-as-image
md2docx tests/demo.md -o tests/demo-render-mermaid.docx --render-mermaid 
md2docx tests/demo.md -o tests/demo-styles.docx --heading-color FF00FF --default-font Arial --chinese-font 微软雅黑

Use in Python

from md2docx.core import MD2DOCX

MD2DOCX().convert('tests/demo.md', output_file='tests/demo.docx')

MD2DOCX().convert(
    'tests/demo.md',
    output_file='tests/demo.docx',
    heading_color='FF00FF',
    default_font='Arial',
    chinese_font='微软雅黑',
    code_as_image=True,
)

Support Features

Render Mermaid based on Mermaid Client(mmdc) install it with: npm install -g @mermaid-js/mermaid-cli