Skip to content
cccskills
FreePublished on GitHub

md-to-docx

Convert Markdown files into Word documents with headings, tables, images, and code formatting. Supports batch conversion, optional contents pages, custom templates, and Chinese document styling, including automatic superscript formatting for eligible citation numbers.

OriginalShow the original description

Convert Markdown files to Word documents (.docx) with proper formatting, Chinese font support (FangSong for all text including headings), black font color, 1.5x line spacing, precise first-line indent (24pt), heading spacing after (1 line), no italic headings, and automatic superscript conversion for citation numbers. Use when converting .md files to .docx, creating Word documents from markdown, or when user mentions Word, DOCX, or document conversion. Requires pandoc.

Works withWord

Run score Not tested

See how to install

Good for

  • Converting a Markdown report into a Word document
  • Formatting Chinese documents with citation superscripts
  • Batch converting Markdown files in a folder
  • Applying a custom Word template and adding contents

Files included (10)

  • SKILL.md7.5 KB
  • chinese_template.docx26.7 KB
  • convert_md_to_docx.py18.8 KB
  • create_chinese_template.py9.9 KB
  • DISTRIBUTION.md4.4 KB
  • fix_heading_fonts.py2.6 KB
  • fix_tables.py6.6 KB
  • INSTALLATION.md2.6 KB
  • README.md4.7 KB
  • 快速使用指南.md3.7 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Markdown to Word (DOCX) Converter

Convert markdown files to professionally formatted Word documents (.docx) using pandoc.

What this Skill does

This Skill enables Claude to convert Markdown files to Word documents with proper formatting, including:

  • Headings and text formatting (H1-H6, bold, italic, strikethrough)
  • Lists (ordered and unordered, nested)
  • Tables with proper formatting
  • Images (automatically embedded)
  • Links and references
  • Code blocks and inline code
  • Chinese punctuation preservation (。,""();!?)
  • Citation superscript: Automatically converts citation numbers (e.g., 文献1。 → 文献¹。) to superscript format for academic documents
  • Default Chinese template: Uses FangSong (仿宋) font for all Chinese text (body, headings, and subtitles), Times New Roman for English text, black color for all text, 1.5x line spacing, first-line indent of two characters (24pt, precisely aligned), heading spacing after (1 line / 12pt), and no italic style for headings

Requirements

Packages must be installed in your environment before using this Skill:

pandoc (required):

# macOS
brew install pandoc

# Linux (Debian/Ubuntu)
sudo apt-get install pandoc

# Windows
choco install pandoc

python-docx (required for template creation):

pip install python-docx

Verify pandoc installation:

pandoc --version

Instructions

When the user requests to convert a Markdown file to Word format:

  1. Check if pandoc is installed by running pandoc --version

    • If not installed, guide the user to install it (see Requirements section)
  2. Identify the input and output files

    • Ask for clarification if the user hasn't specified the output filename
    • Use meaningful names (e.g., if input is report.md, suggest report.docx)
  3. Run the conversion script using the Bash tool:

    python .claude/skills/md-to-docx/convert_md_to_docx.py input.md output.docx
    
  4. Use additional options as needed:

    • Add --toc for table of contents (default: no TOC)
    • Add --no-chinese-template if user doesn't want FangSong font
    • Add --no-superscript-citations to disable automatic citation superscript conversion
    • Add --reference-doc template.docx for custom styling
    • Add --title, --author, --date for document metadata
  5. For batch conversions:

    python .claude/skills/md-to-docx/convert_md_to_docx.py --batch input_dir/ output_dir/
    
  6. Verify the conversion succeeded and inform the user of the output location

Default behavior: The script automatically uses a Chinese template with FangSong (仿宋) font for Chinese text unless --no-chinese-template is specified.

Examples

Convert a single file (uses default Chinese template):

python .claude/skills/md-to-docx/convert_md_to_docx.py "教育改革方案.md" "教育改革方案.docx"

Convert with table of contents (optional, default is no TOC):

python .claude/skills/md-to-docx/convert_md_to_docx.py report.md report.docx --toc

Convert with metadata:

python .claude/skills/md-to-docx/convert_md_to_docx.py paper.md paper.docx \
  --title "研究报告" \
  --author "张三" \
  --date "2025-11-20"

Batch convert all markdown files:

python .claude/skills/md-to-docx/convert_md_to_docx.py --batch ./markdown_files/ ./word_docs/

Use custom template for organizational styling:

python .claude/skills/md-to-docx/convert_md_to_docx.py doc.md doc.docx \
  --reference-doc company_template.docx

Supporting Files

This Skill includes additional resources:

  • README.md: Detailed usage guide with examples
  • 快速使用指南.md: Quick start guide in Chinese
  • convert_md_to_docx.py: Main conversion script with automatic post-processing
  • create_chinese_template.py: Utility to create custom Chinese templates
  • fix_heading_fonts.py: Post-processing script for font and spacing fixes
  • chinese_template.docx: Default Chinese font template (FangSong, 1.5x line spacing, heading spacing)

Troubleshooting

"pandoc: command not found"

  • Install pandoc using your package manager (see Requirements section)

Images not appearing in output

  • Ensure image paths in markdown are correct (use relative paths from markdown file location)
  • Verify image files exist at specified paths

Table formatting issues

  • Verify markdown table syntax:
    | Header 1 | Header 2 |
    |----------|----------|
    | Cell 1   | Cell 2   |
    

Script execution errors

  • Ensure script has execute permissions: chmod +x convert_md_to_docx.py
  • Use forward slashes in all file paths (Unix style)

Chinese Document Best Practices

When converting Chinese documents:

  1. Encoding: Ensure markdown files use UTF-8 encoding
  2. Punctuation: Use proper Chinese punctuation (。,""();!?)
  3. Font: Default template uses FangSong for all Chinese text (body, headings, and subtitles) with black color
  4. Line spacing: 1.5x line spacing for all paragraphs (符合中文文档标准)
  5. Paragraph formatting: First-line indent of two characters (24pt, precisely aligned) for proper Chinese document style
  6. Heading spacing: 1 line (12pt) spacing after all headings for better readability
  7. Heading style: All headings use FangSong font without italic style
  8. Custom templates: Create organizational templates with create_chinese_template.py

Command Line Options Reference

OptionDescription
input.mdInput Markdown file path
output.docxOutput Word document path
--tocGenerate table of contents (default: no TOC)
--no-chinese-templateDon't use default Chinese font template
--no-superscript-citationsDon't convert citation numbers to superscript
--reference-doc FILEUse custom Word template for styling
--title TEXTSet document title metadata
--author TEXTSet document author metadata
--date TEXTSet document date metadata
--batchEnable batch conversion mode
--pattern PATTERNFile pattern for batch mode (default: *.md)

Default Document Formatting

The Chinese template automatically applies:

  • Font: FangSong (仿宋) for Chinese text, Times New Roman for English
  • Font size: 12pt (body text)
  • Font color: Black for all text
  • Line spacing: 1.5x for all paragraphs
  • First-line indent: 24pt (2 Chinese characters)
  • Heading spacing: 12pt (1 line) after each heading
  • Heading style: Bold, no italic
  • Citation superscript: Numbers before sentence-ending punctuation (。;) are automatically converted to superscript (e.g., 参考文献1。 → 参考文献¹。). Only converts numbers 1-60 that directly follow Chinese characters or letters.
  • Table of contents: Not generated by default (use --toc to add)

For complete documentation, see README.md.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

a1

FreeSummary

Turn a broad research idea into clear, testable questions. Compare familiar and less conventional approaches, structure the selected question around its population and methods, and assess variables, feasibility, and potential theoretical contributions.

  • Turn a research topic into testable questions
  • Narrow an overly broad research question
  • Compare alternative research angles
brycewang-stanford/Auto-Empirical-Research-Skills4.7KUpdated Oct 20, 2026

a2

FreeSummary

Helps build a research framework by comparing theories, mapping relationships between variables, and deriving testable hypotheses. Explores less conventional options, examines weaknesses and competing explanations, and produces diagrams with anticipated reviewer objections.

  • Comparing theories for a research question
  • Deriving hypotheses from relationships between variables
  • Examining weaknesses and anticipated reviewer objections
brycewang-stanford/Auto-Empirical-Research-Skills4.7KUpdated Oct 20, 2026

a5

FreeSummary

Clarify the philosophical assumptions behind a research project and check whether they fit the proposed methods. Get a reasoned research stance, draft proposal wording, and guidance for explaining how the researcher's background and values shape the study.

  • Clarifying philosophical foundations for a research proposal
  • Explaining why the chosen research methods fit the study
  • Drafting a statement about the researcher's position
brycewang-stanford/Auto-Empirical-Research-Skills4.7KUpdated Oct 20, 2026

academic-paper

FreeSummary

Plan and draft academic papers through specialized agent roles covering literature, arguments, citations, and review. Get chapter guidance, revision roadmaps, Traditional Chinese and English abstracts, and documents formatted as LaTeX, DOCX, PDF, or Markdown.

  • Planning a paper chapter by chapter
  • Drafting a paper from research materials
  • Turning reviewer comments into a revision roadmap
brycewang-stanford/Auto-Empirical-Research-Skills4.7KUpdated Oct 20, 2026

Turn a detailed outline into a philosophy or interdisciplinary manuscript. Draft chapters with repeated quality reviews, check terminology and arguments across sections, and prepare the manuscript, evaluation reports, abstract, and metadata for submission.

  • Draft a full paper from a detailed outline
  • Review argument and citation quality chapter by chapter
  • Check terminology and argument flow across chapters
brycewang-stanford/Auto-Empirical-Research-Skills4.7KUpdated Oct 20, 2026

Simulate academic peer review through five reviewer roles tailored to the paper's field. Receive separate critiques, an editorial decision, and a prioritized revision roadmap, or check whether a revised manuscript addresses earlier comments.

  • Review a manuscript before journal submission
  • Examine research methods and statistical validity
  • Challenge core arguments and alternative explanations
brycewang-stanford/Auto-Empirical-Research-Skills4.7KUpdated Oct 20, 2026

See all skills by brycewang-stanford

Report a problem with this skill