md-to-docx
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarkdown to Word (.docx) Skill
Markdown转Word(.docx)Skill
Convert Markdown () files into professionally formatted Word () documents with embedded PNG images. Uses pure JavaScript via the and npm packages — no Pandoc, LibreOffice, or any native binary required.
.md.docxdocxmarked将Markdown()文件转换为带有嵌入式PNG图片的专业格式Word()文档。通过和 npm包采用纯JavaScript实现——无需Pandoc、LibreOffice或任何原生二进制文件。
.md.docxdocxmarkedHow to Convert
转换方法
bash
undefinedbash
undefinedInstall dependencies (one-time, from the scripts folder)
安装依赖(仅需一次,在scripts目录下执行)
cd skills/md-to-docx/scripts && npm install
cd skills/md-to-docx/scripts && npm install
Convert (run from workspace root)
转换(在工作区根目录执行)
node skills/md-to-docx/scripts/md-to-docx.mjs <input.md> [output.docx]
If `output.docx` is omitted, it defaults to `<input-basename>.docx` in the current directory.node skills/md-to-docx/scripts/md-to-docx.mjs <input.md> [output.docx]
如果省略`output.docx`,默认会在当前目录生成`<input-basename>.docx`文件。Skill Folder Contents
Skill目录内容
| File | Purpose |
|---|---|
| This instruction file |
| Node.js Markdown-to-Word converter |
| Dependencies ( |
| 文件 | 用途 |
|---|---|
| 本说明文档 |
| Node.js Markdown转Word转换器 |
| 依赖包( |
Prerequisites
前置要求
| Requirement | Version | Notes |
|---|---|---|
| Node.js | 18+ | Required runtime |
| 9+ | Pure JS Word document generator |
| 15+ | Markdown parser |
No native binaries. No system-level installs. Works on Windows, macOS, and Linux.
| 要求 | 版本 | 说明 |
|---|---|---|
| Node.js | 18+ | 必需的运行时环境 |
| 9+ | 纯JS Word文档生成器 |
| 15+ | Markdown解析器 |
无需原生二进制文件,无需系统级安装,可在Windows、macOS和Linux系统上运行。
Features
功能特性
The converter:
- Extracts YAML front-matter — uses ,
title,date,versionfor the title pageaudience - Generates a title page — with project name, subtitle, date, version, and audience
- Generates a table of contents — built from H1-H3 headings
- Embeds PNG images — resolves references relative to the input
file, reads the PNG, and embeds it inline in the Word document.md - Styled output — Calibri font, colored headings (), styled tables with alternating row colors, code blocks in Consolas
#1F3864 - Handles all Markdown elements — headings, paragraphs, tables, code blocks, lists, images, links, horizontal rules
该转换器具备以下功能:
- 提取YAML前置元数据——使用、
title、date、version生成标题页audience - 生成标题页——包含项目名称、副标题、日期、版本和受众信息
- 生成目录——基于H1-H3标题构建
- 嵌入PNG图片——解析Markdown中引用,路径相对于输入的
文件,读取PNG并将其嵌入Word文档中.md - 样式化输出——采用Calibri字体、彩色标题()、带有交替行颜色的样式化表格、Consolas字体的代码块
#1F3864 - 支持所有Markdown元素——标题、段落、表格、代码块、列表、图片、链接、水平线
Image Embedding
图片嵌入
The converter automatically embeds PNG images referenced in the Markdown:
markdown
The image path is resolved relative to the input Markdown file. The PNG is read, dimensions are extracted from the PNG header, and the image is scaled to fit within 6 inches width while preserving aspect ratio.
If an image file is not found, a placeholder is inserted.
[Image not found: <path>]转换器会自动嵌入Markdown中引用的PNG图片:
markdown
图片路径是相对于输入Markdown文件进行解析的。读取PNG后,从PNG头中提取尺寸,并将图片缩放至宽度不超过6英寸,同时保持宽高比。
如果未找到图片文件,将插入占位符。
[Image not found: <path>]Front-Matter Format
前置元数据格式
yaml
---
title: Project Name — Project Summary
date: 2025-01-15
version: 1.0
audience: Engineering Team, Architects, Stakeholders
---The title is split on or into main title and subtitle for the title page.
—–yaml
---
title: Project Name — Project Summary
date: 2025-01-15
version: 1.0
audience: Engineering Team, Architects, Stakeholders
---标题会按或分割为主标题和副标题,用于标题页显示。
—–