Skill: bibekyess/docx-to-html (version 1.0.0)

--- name: docx-to-html description: "Use this skill whenever the user has a DOCX file (.docx) and wants to convert, read, view, extract content from, or process it in any way — including summarization, displaying in a browser, extracting tables or lists, or feeding into AI pipelines. Always use this skill for any task involving .docx files, even if the request seems simple. Triggers include: 'convert docx', 'open word file', 'read word document', 'extract tables from docx', or any mention of a .docx filename." --- # DOCX to HTML Converter This skill provides a straightforward method to convert Microsoft Word (.docx) documents into clean, semantic HTML, making them suitable for various web-based and AI-driven applications. ## Compatibility - **Python 3** (for the conversion wrapper) - **Node.js** with `mammoth` installed (core conversion engine) To install Node.js dependencies, run once from the `scripts/` directory: ```bash npm install ``` ## Use Cases - **Browser-Based Viewing**: Convert DOCX documents for display in web browsers without requiring Microsoft Word. - **AI-Ready Content**: Prepare DOCX content for LLMs for tasks like summarization, Q&A, and semantic search. - **Web Integration**: Integrate Word document content into web applications, CMS, or online editors. - **Data Extraction**: Extract structured data (tables, lists, headings) from DOCX files for automated reporting and analysis. - **Search and Indexing**: Enable full-text and vector search by converting DOCX content into easily indexable HTML. ## Workflow 1. **Locate DOCX File**: Identify the path to the `.docx` file to convert. 2. **Run Conversion Script**: Execute the Python wrapper from the skill's `scripts/` directory: ```bash python3 <skill-dir>/scripts/convert.py <input_path.docx> <output_path.html> ``` Replace `<skill-dir>` with the actual path where this skill is installed. 3. **Verify Output**: Open the generated `.html` file in a browser and check: - Headings (`<h1>`, `<h2>`, etc.) appear at the correct hierarchy levels - Tables render with the expected rows and columns - Lists appear as bullet or numbered items (not plain text) - Bold, italic, and inline formatting are preserved - Images are visible (embedded as base64 by default) 4. **Process HTML**: Use the resulting HTML for further tasks like summarization, indexing, or display. ## Bundled Resources - `scripts/docx-converter.js`: Core Node.js conversion logic using `mammoth.js`. - `scripts/convert.py`: Python wrapper for invoking the Node.js converter. - `scripts/package.json`: Node.js dependency manifest (includes `mammoth`). ## Technical Details The conversion leverages `mammoth.js`, which prioritizes semantic meaning over visual replication: - **Semantic Conversion**: Document structure maps to proper HTML — headings become `<h1>`/`<h2>`, lists become `<ul>`/`<ol>`, etc. - **Basic Styling**: Bold, italics, and common paragraph styles are preserved. - **Image Embedding**: Images are extracted and embedded as base64 data URIs in the HTML output. ## Troubleshooting | Problem | Likely Cause | Fix | |---|---|---| | `node: command not found` | Node.js not installed | Install Node.js (v16+) | | `Cannot find module 'mammoth'` | npm deps missing | Run `npm install` in `scripts/` | | Empty or garbled output | Corrupted or password-protected DOCX | Try re-saving the file from Microsoft Word | | Missing images | Large embedded images | Check `mammoth.js` image size limits in `docx-converter.js` | ## Limitations - Advanced or highly specific styling from the original DOCX may not be perfectly replicated in the HTML output. - Features like tracked changes, comments, or complex layout elements may be simplified or omitted.

path: scripts/convert.py
content: import subprocess
import sys
import os

def convert_docx_to_html(input_path, output_path):
    script_dir = os.path.dirname(os.path.abspath(__file__))
    js_script = os.path.join(script_dir, "docx-converter.js")
    
    try:
        result = subprocess.run(
            ["node", js_script, input_path, output_path],
            capture_output=True,
            text=True,
            check=True
        )
        print(result.stdout)
        return True
    except subprocess.CalledProcessError as e:
        print(f"Error during DOCX to HTML conversion: {e.stderr}", file=sys.stderr)
        return False

if __name__ == "__main__":
    if len(sys.argv) < 3:
        print("Usage: python3 convert.py <input_path> <output_path>")
        sys.exit(1)
    
    input_file = sys.argv[1]
    output_file = sys.argv[2]
    
    if convert_docx_to_html(input_file, output_file):
        sys.exit(0)
    else:
        sys.exit(1)


path: scripts/docx-converter.js
content: const mammoth = require("mammoth");
const fs = require("fs/promises");

async function convertDocxToHtml(inputPath, outputPath) {
    try {
        const buffer = await fs.readFile(inputPath);
        const result = await mammoth.convertToHtml({ buffer: buffer });
        await fs.writeFile(outputPath, result.value);
        console.log(`Successfully converted ${inputPath} to ${outputPath}`);
    } catch (error) {
        console.error(`Error converting DOCX to HTML: ${error.message}`);
        process.exit(1);
    }
}

const args = process.argv.slice(2);
if (args.length < 2) {
    console.error("Usage: node docx-converter.js <input_path> <output_path>");
    process.exit(1);
}

const inputPath = args[0];
const outputPath = args[1];

convertDocxToHtml(inputPath, outputPath);


path: scripts/package-lock.json
content: {
  "name": "scripts",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "scripts",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
        "mammoth": "^1.11.0"
      }
    },
    "node_modules/@xmldom/xmldom": {
      "version": "0.8.11",
      "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.11.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      }
    },
    "node_modules/argparse": {
      "version": "1.0.10",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "sprintf-js": "~1.0.2"
      }
    },
    "node_modules/base64-js": {
      "version": "1.5.1",
      "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
      "integrity": [REDACTED_SECRET],
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/feross"
        },
        {
          "type": "patreon",
          "url": "https://www.patreon.com/feross"
        },
        {
          "type": "consulting",
          "url": "https://feross.org/support"
        }
      ],
      "license": "MIT"
    },
    "node_modules/bluebird": {
      "version": "3.4.7",
      "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/core-util-is": {
      "version": "1.0.3",
      "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/dingbat-to-unicode": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/dingbat-to-unicode/-/dingbat-to-unicode-1.0.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD-2-Clause"
    },
    "node_modules/duck": {
      "version": "0.1.12",
      "resolved": "https://registry.npmjs.org/duck/-/duck-0.1.12.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD",
      "dependencies": {
        "underscore": "^1.13.1"
      }
    },
    "node_modules/immediate": {
      "version": "3.0.6",
      "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "ISC"
    },
    "node_modules/isarray": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/jszip": {
      "version": "3.10.1",
      "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "(MIT OR GPL-3.0-or-later)",
      "dependencies": {
        "lie": "~3.3.0",
        "pako": "~1.0.2",
        "readable-stream": "~2.3.6",
        "setimmediate": "^1.0.5"
      }
    },
    "node_modules/lie": {
      "version": "3.3.0",
      "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "immediate": "~3.0.5"
      }
    },
    "node_modules/lop": {
      "version": "0.4.2",
      "resolved": "https://registry.npmjs.org/lop/-/lop-0.4.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD-2-Clause",
      "dependencies": {
        "duck": "^0.1.12",
        "option": "~0.2.1",
        "underscore": "^1.13.1"
      }
    },
    "node_modules/mammoth": {
      "version": "1.11.0",
      "resolved": "https://registry.npmjs.org/mammoth/-/mammoth-1.11.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD-2-Clause",
      "dependencies": {
        "@xmldom/xmldom": "^0.8.6",
        "argparse": "~1.0.3",
        "base64-js": "^1.5.1",
        "bluebird": "~3.4.0",
        "dingbat-to-unicode": "^1.0.1",
        "jszip": "^3.7.1",
        "lop": "^0.4.2",
        "path-is-absolute": "^1.0.0",
        "underscore": "^1.13.1",
        "xmlbuilder": "^10.0.0"
      },
      "bin": {
        "mammoth": "bin/mammoth"
      },
      "engines": {
        "node": ">=12.0.0"
      }
    },
    "node_modules/option": {
      "version": "0.2.4",
      "resolved": "https://registry.npmjs.org/option/-/option-0.2.4.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD-2-Clause"
    },
    "node_modules/pako": {
      "version": "1.0.11",
      "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "(MIT AND Zlib)"
    },
    "node_modules/path-is-absolute": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/process-nextick-args": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/readable-stream": {
      "version": "2.3.8",
      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "core-util-is": "~1.0.0",
        "inherits": "~2.0.3",
        "isarray": "~1.0.0",
        "process-nextick-args": "~2.0.0",
        "safe-buffer": "~5.1.1",
        "string_decoder": "~1.1.1",
        "util-deprecate": "~1.0.1"
      }
    },
    "node_modules/safe-buffer": {
      "version": "5.1.2",
      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/setimmediate": {
      "version": "1.0.5",
      "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/sprintf-js": {
      "version": "1.0.3",
      "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD-3-Clause"
    },
    "node_modules/string_decoder": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "safe-buffer": "~5.1.0"
      }
    },
    "node_modules/underscore": {
      "version": "1.13.8",
      "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.8.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/util-deprecate": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/xmlbuilder": {
      "version": "10.1.1",
      "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-10.1.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">=4.0"
      }
    }
  }
}


path: scripts/package.json
content: {
  "name": "scripts",
  "version": "1.0.0",
  "main": "docx-converter.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "mammoth": "^1.11.0"
  }
}


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)