agentleFS
richyuhrichyuh/claude-skills/md-to-docx/SKILL.md

md-to-docx

Skill0 starsChanged 2 months agoMITView on GitHub

Convert a Markdown document into a clean, professional Word (.docx) or PDF where Markdown syntax (#, *, -, |, links, tables) renders as real headings, bold, bullets, and tables — never literal symbols. Use when asked to convert/export Markdown to docx/Word/PDF, or when a converted document still shows raw Markdown symbols like # or **. Wraps the locally installed pandoc with tech-document defaults and an optional styled reference template.

  • Installs packages

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Verify pandoc is available.

    line 30
  2. Distinctive:

    Verify the output has no literal Markdown: Run a round-trip check and inspect:

    line 33
  3. Distinctive:

    If raw markdown is detected, the source likely used a syntax pandoc didn't parse — investigate rather than shipping.

    line 37

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Markdown → Polished Word/PDF

Convert Markdown to a real, well-formatted .docx (or PDF) using the locally installed pandoc. Pandoc parses the Markdown and emits true document structure — headings become Word heading styles, **bold** becomes bold, lists and tables become real lists and tables. Literal #, *, and | never appear in the output.

Preconditions

  • Requires pandoc (already installed: check with pandoc --version). If missing, tell the user to brew install pandoc — do not attempt a silent workaround that reintroduces raw symbols.
  • For PDF output, pandoc needs a PDF engine. Prefer --pdf-engine=weasyprint or wkhtmltopdf if present; if none is available, produce .docx and tell the user to export to PDF from Word.

Core conversion (this is the fix for "raw # symbols")

pandoc INPUT.md \
  --from gfm \
  --to docx \
  --toc --toc-depth=3 \
  --number-sections \
  --reference-doc="$HOME/.claude/skills/md-to-docx/reference/template.docx" \
  -o OUTPUT.docx
  • --from gfm parses GitHub-Flavored Markdown (tables, task lists, fenced code).
  • --toc adds a table of contents; --number-sections numbers headings (drop either if unwanted).
  • --reference-doc applies the styled template for fonts/spacing/branding. If the template file does not exist, omit that flag — pandoc then uses its clean default styles (still no raw symbols).

Workflow

  1. Confirm the input .md path and desired output (docx or pdf) and filename.
  2. Verify pandoc is available.
  3. Decide on options with the user only if they care: TOC yes/no, numbered sections yes/no, styled template yes/no. Otherwise use the defaults above.
  4. Run the conversion.
  5. Verify the output has no literal Markdown. Run a round-trip check and inspect:
    pandoc OUTPUT.docx -t plain | grep -nE '(^#{1,6} )|\*\*|\]\(http|^\s*\|' && echo "WARN: raw markdown detected" || echo "clean"
    If raw markdown is detected, the source likely used a syntax pandoc didn't parse — investigate rather than shipping.
  6. Report the output path and that the conversion is clean.

Styled template (visual quality)

To make the document look good (corporate fonts, heading colors, spacing), create a reference template once and pass it with --reference-doc:

# Generate a starter template, then edit its styles in Word and re-save:
pandoc -o "$HOME/.claude/skills/md-to-docx/reference/template.docx" --print-default-data-file reference.docx

Edit the heading/body styles in that file (Home → Styles → modify), save, and every future conversion inherits the look. See reference/styling-notes.md.

Notes

  • Pandoc is deterministic and local — no network calls. This skill only orchestrates it.
  • This skill is the final step after the customer-facing-spec → leak-check → writing-clearly-and-concisely pipeline: convert only the cleared, edited Markdown.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.