ホーム / Skills / オフィス・文書 / Markdown から Word(.docx)への変換
オフィス・文書

Markdown から Word(.docx)への変換

awesome-copilot communityMITSkill の言語: 英語
ライセンス確認済みスクリプトを含む中リスク
デモ実行記録 · claude-sonnet-5-5 · 2026年10月
Please turn the Markdown report at .claude/skills/md-to-docx/sample/report.md into a Word document, saved as .claude/skills/md-to-docx/sample/report.docx. Dependencies are not installed yet: install them with `npm install --prefix .claude/skills/md-to-docx/scripts` first (that exact command is allowed), then convert using relative paths. Afterwards tell me what the document contains (title page, table of contents, sections, table, image) and anything that did not convert. To check the result you may run `unzip -p .claude/skills/md-to-docx/sample/report.docx word/document.xml` (that exact command is allowed), and base your description on what is actually in the file.
Skill: md-to-docx

I converted the report and saved it as .claude/skills/md-to-docx/sample/report.docx (11 KB). The dependencies installed with only an engine warning: nanoid wants Node 22 or later and this machine has v20.19.0. The conversion ran fine anyway. The description below comes from the document XML, not just the script's success message.

What the document contains

  • Title page: "Q3 Platform Review" as the title, "Summary for Engineering" as the subtitle, then "Date: 2026-10-01 | Version: 1.2" and "Audience: Engineering, Product". It is followed by a page break.
  • Table of contents: It lists Highlights, Key numbers (indented as a sub-entry) and Plan, then a page break.
  • Sections:
    • Highlights (heading 2) has a paragraph with bold "18%", italic "0.2%", status.md in Consolas with a grey background, and "the dashboard" in blue underline.
    • Key numbers (heading 3) holds the table.
    • Plan (heading 2) has the numbered list "1. Migrate the queue" and "2. Add retries", with "exponential backoff" and "jitter" as indented bullets.
    • A Python code block follows, in Consolas on a grey background.
    • The document ends with the Chinese paragraph (中文段落:延迟下降 18%。), a horizontal rule and "Done."
  • Table: It has 3 columns (Metric, Q2, Q3) and 2 data rows, p95 latency (420 → 344) and Error rate (0.3% → 0.19%). The header row is shaded and repeats across pages, and the rows alternate in colour.
  • Image: diagrams/arch.png is embedded, centred, with the caption "Architecture".

What did not convert cleanly

  • Missing image: diagrams/nope.png was not found, so the document has the placeholder text [Image not found: diagrams/nope.png].
  • Mermaid diagram: It was not rendered. The document has the placeholder "[Diagram: See source .md file for interactive Mermaid diagram]".
  • Tiny image: The embedded architecture image is only about 0.4 × 0.2 inches (381000 × 190500 EMU). The source PNG is probably a tiny placeholder, so it will look very small in Word.
  • Dropped H1: The # Q3 Platform Review — Summary for Engineering heading does not appear in the body or the table of contents. Its text is only on the title page.
  • Link has no URL: "the dashboard" is styled as a link, but there is no hyperlink element in the file, so the https://example.com/dash URL is lost.
  • Static table of contents: It is plain text with no page numbers and no links, so it won't update in Word.
  • Fake lists: The list markers ("1.", "•") are typed characters with indentation, not real Word lists.
  • Code language dropped: The code block keeps its text but not the python language tag, and there is no syntax highlighting.
  • Chinese font: The Chinese text is set in Calibri, which has no CJK glyphs, so Word will substitute a fallback font. I didn't check how it looks.

试用方式:Skill 需要 npm 依赖,我让模型先执行文档里的 npm install,再转换我构造的示例 Markdown(含封面信息、表格、嵌套列表、代码块、PNG 图片、一个故意缺失的图片、Mermaid 代码块、中文段落);Bash 只放行 npm install、转换命令和查看 docx 内部 XML 这三条。我另外手动解压 docx 核对,模型的描述与实际一致。示例中的 PNG 只是 40×20 像素的占位图,所以文中说它在文档里很小。

できること

同梱の Node.js スクリプトを実行し、npm パッケージの docx と marked で .md ファイルを .docx に変換します。Pandoc や LibreOffice は不要です。YAML のフロントマター(タイトル、日付、バージョン、対象読者)から表紙を作り、H1〜H3 の見出しから目次を作り、見出し、行ごとに色が交互になる表、コードブロックを装飾し、リスト、リンク、区切り線を処理し、Markdown で参照された PNG 画像を埋め込みます(パスはファイルからの相対、幅は約 6 インチに縮小)。Mermaid ブロックは 1 行のプレースホルダーになります。

動き方

  1. scripts フォルダーで一度だけ npm install を実行します。
  2. node md-to-docx.mjs input.md [output.docx] を実行します。出力名を省略すると、カレントディレクトリに入力ファイル名で作成します。

向いている場面

Markdown で書いたドキュメント、仕様書、レポートを、共有用の Word ファイルにしたいとき。

補足とリスク

中リスク:Node スクリプトを実行し、`npm install`(`docx` と `marked` のダウンロード)が必要です。`.docx` を出力パスに書き込み、同名のファイルは確認なしに置き換えるため、新しい名前にするかバックアップを取ってください。Markdown 内の画像パスは入力ファイルからの相対で解決され、そのフォルダー内に限定されず、PNG かどうかの確認もないため、出所の不明な Markdown を変換すると、ディスク上の他のファイルが文書に取り込まれる恐れがあります。スクリプトはネットワークリクエストを行いません。試用済みで、変換結果は正しかったです。制限:リンクは文字だけが残り URL は失われます。目次は静的なテキストでページ番号やジャンプはありません。リストは文字で再現されています。埋め込めるのは PNG のみで、他の画像形式は PNG として書き込まれ、表示されない場合があります。