agentleFS
fabioc-alohafabioc-aloha/Alex_ACT_Edition/.github/skills/docx-to-md/SKILL.md

docx-to-md

Skill0 starsChanged 4 months agoMITView on GitHub

Convert Word documents (.docx) to clean Markdown with image extraction and pandoc cleanup

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Headers/footers: Not extracted (document body only)

    line 199

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Docx To Md

Ingest Word documents into your Markdown workflow — clean, linted, version-control ready

Convert .docx files into clean, linted Markdown with extracted images, normalized headings, and cleaned table formatting. The reverse converter for ingesting external documents into a Markdown-based workflow.


When to Use

  • Importing Word documents from stakeholders into a Markdown-based workflow
  • Converting legacy documentation to Markdown for version control
  • Extracting content from .docx for further processing (presentations, email, web)
  • Onboarding external resources (SOWs, RFPs, specs) into project repositories
  • Migrating from Word-based documentation to docs-as-code
  • Preparing content for static site generators (VitePress, Docusaurus, etc.)

Supported Content

Content TypeStatusNotes
Headings✅Hierarchy normalized to start at H1
Bold/Italic✅Converted to Markdown syntax
Links✅Preserved as Markdown links
Images✅Extracted to images/ folder
Tables✅Cleaned and aligned
Lists✅Ordered, unordered, nested
Code blocks⚠️Detected if styled as code
Footnotes✅Converted to Markdown footnotes
Comments⚠️Stripped with --strip-comments
Track changes❌Accept/reject before converting
Embedded objects❌Extract manually

Key Features

FeatureDetails
Image extractionEmbedded images saved to images/ folder with sequential naming
Pandoc cleanupRemoves escaped brackets, span classes, trailing backslashes
Table normalizationAligns columns, adds proper separators
Heading fixNormalizes hierarchy to start at H1
FrontmatterOptional YAML frontmatter with title and date
Comment strippingRemoves Word review comments

Usage

# Basic conversion
node .github/skills/docx-to-md/scripts/docx-to-md.cjs report.docx

# With frontmatter and heading normalization
node .github/skills/docx-to-md/scripts/docx-to-md.cjs spec.docx --add-frontmatter --fix-headings

# Strip review comments
node .github/skills/docx-to-md/scripts/docx-to-md.cjs reviewed.docx --strip-comments

# Custom output path
node .github/skills/docx-to-md/scripts/docx-to-md.cjs input.docx output/document.md

# Debug mode (keeps raw pandoc output)
node .github/skills/docx-to-md/scripts/docx-to-md.cjs input.docx --debug

# Full cleanup pipeline
node .github/skills/docx-to-md/scripts/docx-to-md.cjs spec.docx --add-frontmatter --fix-headings --strip-comments --clean-tables

Options Reference

OptionDefaultDescription
--extract-imagestrueExtract images to images/ folder
--no-extract-images-Keep images as raw base64 in markdown
--add-frontmatteroffGenerate YAML frontmatter with title/date
--clean-tablestrueNormalize table column widths
--no-clean-tables-Keep pandoc raw table output
--fix-headingsoffNormalize heading hierarchy to start at H1
--wrap N0Wrap lines at N characters (0 = no wrap)
--strip-commentsoffRemove Word comment annotations
--debugoffKeep intermediate pandoc output

Post-Processing Pipeline

The conversion follows a multi-stage cleanup:

.docx → pandoc → raw MD → cleanup → clean MD
                            ↓
                    1. Escaped brackets removed
                    2. Trailing backslashes removed
                    3. Span classes stripped
                    4. Image attributes cleaned
                    5. Comments stripped (optional)
                    6. Headings normalized (optional)
                    7. Tables reformatted
                    8. Images extracted
                    9. Frontmatter added (optional)

Pandoc Cleanup Details

Pandoc QuirkBeforeAfter
Escaped brackets\[text\][text]
Trailing backslashesline\line
Span classes{.underline}(removed)
Image attributes{width="5in"}(removed)
Heading anchors{#section-1}(removed)
Excessive blank lines\n\n\n\n\n\n

Image Extraction

Embedded images are extracted to a sibling images/ folder:

input/
├── document.docx
└── document.md (output)
    └── images/
        ├── image1.png
        ├── image2.png
        └── image3.jpg

Image references in markdown are updated automatically:

![](images/image1.png)

Common Workflows

Stakeholder Document Ingestion

# Convert with full cleanup
node .github/skills/docx-to-md/scripts/docx-to-md.cjs stakeholder-spec.docx \
  --add-frontmatter --fix-headings --strip-comments

# Validate formatting (exits 1 if file would be reformatted)
node .github/skills/markdown-mermaid/scripts/md-format.cjs stakeholder-spec.md --check

# Review and commit
git add stakeholder-spec.md images/
git commit -m "docs: ingest stakeholder specification"

Legacy Documentation Migration

# Batch convert all Word docs
Get-ChildItem *.docx | ForEach-Object {
  node .github/skills/docx-to-md/scripts/docx-to-md.cjs $_.FullName --add-frontmatter --fix-headings
}

Troubleshooting

ProblemCauseSolution
"pandoc not found"pandoc not installedwinget install pandoc
Images missingExtraction failedCheck images/ folder, re-run
Tables misalignedComplex table structureManual cleanup may be needed
Headings start at H3Original doc structureUse --fix-headings
Comments in outputTrack changes not strippedUse --strip-comments
Encoding issuesNon-UTF8 contentRe-save .docx as UTF-8

Limitations

  • Track changes: Accept or reject all changes in Word before converting
  • Embedded objects: Charts, SmartArt, etc. must be extracted manually
  • Complex tables: Merged cells may not convert cleanly
  • Styles: Word styles are lost (only structural elements preserved)
  • Headers/footers: Not extracted (document body only)

Requirements

  • Node.js 24+
  • pandoc (winget install pandoc)

Muscle Script

.github/skills/docx-to-md/scripts/docx-to-md.cjs (v1.0.0)


Conversion Acceptance Decision Table

ConditionVerdictAction
All headings mapped to correct # levelsAcceptVerify no skipped heading levels
Headings rendered as bold paragraphs instead of #RejectCheck pandoc --shift-heading-level and source styles
Tables converted to valid Markdown pipe tablesAcceptSpot-check alignment
Complex tables (merged cells) lose structureWarningManual restructure or use HTML table fallback
Images extracted and linked with relative pathsAcceptVerify image files exist in output dir
Images lost or referenced with absolute Windows pathsRejectUse --extract-media with correct output dir
Footnotes converted to Markdown footnote syntaxAcceptVerify numbering is sequential
Footnotes lost or inlined as parenthetical textWarningCheck pandoc footnote handling
Code blocks preserve monospace and indentationAcceptVerify language fence tags present
Track changes / comments stripped from outputAcceptExpected — Markdown has no change tracking
Track changes rendered as visible markupRejectAccept or reject all changes before conversion
Bullet and numbered lists preserve nestingAcceptVerify indent levels match source
Output passes markdownlint with zero errorsAcceptRun lint-clean-markdown post-conversion
Round-trip (docx→md→docx) preserves semantic contentAcceptFormatting differences OK; content loss is not

Related Skills

  • md-to-word — Reverse direction (Markdown to Word)
  • lint-clean-markdown — Post-validate converted Markdown
  • md-to-html — Convert result to HTML for web

Skill version: 2.0.0 | Last updated: 2026-04-14 | Category: document-conversion

Falsifiability

  • This skill is wrong if converted documents lose semantic structure (headings, lists, tables) that Pandoc preserves by default without the documented flags
  • The flag recommendations are stale if a Pandoc major version changes default behaviors for the documented options
  • The workflow is not earning its tokens if the user must manually fix the same structural issues on every conversion

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.