跳到正文
Skillpedia
写作40k · #7285

md-to-docx

它能做什么

这个工具可以把你用 Markdown(.md)格式写的文本,转换成排版专业的 Word(.docx)文档。它还会包含你在文本中引用的 PNG 图片。

适用场景

  • ✓当你需要把草稿变成正式文档时。
  • ✓需要根据标题自动生成目录时。
  • ✓需要分享可以用 Word 打开的文档时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/md-to-docx/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/md-to-docx/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把这个 Markdown 文件转换成 Word 文档:my_document.md”

每周 5 个新技能,1 分钟读完。

工作原理

你需要提供一个用 Markdown 编写的文本文件。工具会使用 Node.js 程序读取你的文本,识别标题、列表和图片,然后生成一个新的 Word(.docx)格式文件。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Markdown to Word (.docx) Skill

Convert Markdown (.md) files into professionally formatted Word (.docx) documents with embedded PNG images. Uses pure JavaScript via the docx and marked npm packages — no Pandoc, LibreOffice, or any native binary required.

How to Convert

# Install dependencies (one-time, from the scripts folder)
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.

Skill Folder Contents

File Purpose
SKILL.md This instruction file
scripts/md-to-docx.mjs Node.js Markdown-to-Word converter
scripts/package.json Dependencies (docx, marked)

Prerequisites

Requirement Version Notes
Node.js 18+ Required runtime
docx 9+ Pure JS Word document generator
marked 15+ Markdown parser

No native binaries. No system-level installs. Works on Windows, macOS, and Linux.

Features

The converter:

  • Extracts YAML front-matter — uses title, date, version, audience for the title page
  • 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 ![alt](path) references relative to the input .md file, reads the PNG, and embeds it inline in the Word document
  • Styled output — Calibri font, colored headings (#1F3864), styled tables with alternating row colors, code blocks in Consolas
  • Handles all Markdown elements — headings, paragraphs, tables, code blocks, lists, images, links, horizontal rules

Image Embedding

The converter automatically embeds PNG images referenced in the Markdown:

![High-Level Architecture](diagrams/high-level-architecture.drawio.png)

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 [Image not found: <path>] is inserted.

Front-Matter Format

---
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.

常见问题

我需要安装复杂的东西吗?

你的电脑需要先安装 Node.js。其余部分在运行安装命令时会自动完成设置。

如果文本中有图片怎么办?

如果图片是 PNG 格式,并且与你的 Markdown 文件位于同一位置或相关文件夹中,就会被包含在 Word 文档里。

什么是“YAML 前置元数据”?

它是 Markdown 文件开头的一小段文字,位于两条三短横线(---)之间。你可以在这里填写标题、日期、目标读者等信息,用于生成 Word 文档。

详情

作者的原始描述

Convert Markdown files to professionally formatted Word (.docx) documents with embedded PNG images — pure JavaScript, no external tools required

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7285
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能