DOC Converter
Overview
A user may ask you to convert Markdown files to DOCX format, including handling embedded diagrams. This skill provides a workflow for managing the conversion process using the md_to_docx.py script.
Workflow
1. Identify conversion requirements
- Determine the workspace root directory
- Verify the Python script exists at
script/md_to_docx.py - Verify the source markdown file exists
- Check for diagram dependencies (SVG/PNG files in diagrams folder)
- Confirm output path and naming
2. Execute conversion
Run the conversion script using the run_in_terminal tool:
python script/md_to_docx.py
3. Verify results
- Check that the DOCX file was created successfully
- Report any errors or warnings from the conversion process
- Confirm diagram insertions completed
Conversion Rules
- The script expects markdown files in
docs/folder - Diagrams should be in
docs/diagrams/folder - SVG files are automatically converted to PNG for DOCX insertion
- Mermaid code blocks are replaced with corresponding diagram images
- Default conversion:
docs/Software-Architecture-AutoReceipt-zh.md→docs/Software-Architecture-AutoReceipt-zh.docx
Error Handling
If conversion fails, follow these diagnostic steps:
- Verify Python script path:
- Check if
script/md_to_docx.pyexists -
If not found, use read_file or list_dir to locate the correct path
-
Check Python environment:
- Verify python-docx is installed:
pip list | Select-String "python-docx" -
If missing, suggest:
pip install python-docx -
Verify input files:
- Confirm markdown file exists
-
Check diagram files are present
-
Check optional dependencies:
- Test cairosvg availability for SVG→PNG conversion
-
If missing and needed, suggest:
pip install cairosvg -
Path resolution:
- Ensure working directory is the workspace root
- Use absolute paths to avoid path resolution issues
Dependencies
Required dependencies:
- python-docx
- cairosvg (optional, for SVG conversion)