Skip to content

ubermensch1218/hwpx-ts

 
 

Repository files navigation

hwpx-ts

The TypeScript toolkit for reading, editing, and automating Korean word processor (HWPX) documents.

npm version GitHub stars

HWPX is the modern XML-based format used by Hangul (한글), the dominant word processor in Korea — used by government, education, and enterprise. hwpx-ts gives you full programmatic access to these documents in TypeScript/JavaScript.

Why hwpx-ts?

  • Only TypeScript HWPX library — no native binaries, no Python, no Java dependency
  • Works everywhere — Node.js, browsers, serverless (Cloudflare Workers, Vercel Edge)
  • AI/Agent-ready — built-in MCP server for Claude, llms.txt for LLM discovery
  • Zero-confignpm install and start coding in 30 seconds

Fast Paths

Pick the path that matches your goal:

  • Use as a library
    npm install @ubermensch1218/hwpxcore
  • Connect to an AI agent (MCP)
    npx @ubermensch1218/hwpx-mcp
  • Contribute to this monorepo
    corepack enable
    pnpm install
    pnpm --filter @ubermensch1218/hwpxcore typecheck
    pnpm --filter @ubermensch1218/hwpxcore test
    pnpm --filter @ubermensch1218/hwpxcore build

AI Operator Notes

  • Canonical TypeScript onboarding lives in this README and package READMEs under packages/
  • docs/ is currently a Sphinx site with Python-oriented workflows; use package READMEs for TypeScript-first usage
  • If you want one-step scaffolding, run npx @ubermensch1218/hwpx-cli init

Quick Start

How do I read an HWPX file?

npm install @ubermensch1218/hwpxcore
import { HwpxDocument } from "@ubermensch1218/hwpxcore";

const buffer = await fetch("document.hwpx").then((r) => r.arrayBuffer());
const doc = await HwpxDocument.open(new Uint8Array(buffer));

console.log(doc.text);           // all text content
console.log(doc.tables);         // all tables
console.log(doc.sections.length); // section count

How do I create and edit a document?

import { HwpxDocument, loadSkeletonHwpx } from "@ubermensch1218/hwpxcore";

const doc = await HwpxDocument.open(loadSkeletonHwpx());

doc.addParagraph("Hello, HWPX!");
doc.addParagraph("Second paragraph.");
doc.replaceText("Hello", "Hi");

// Save
const bytes = await doc.saveToBuffer();  // Uint8Array
const blob  = await doc.saveToBlob();    // Blob (for browsers)
await doc.saveToPath("./output.hwpx");   // Node.js file path

How do I work with tables?

const para = doc.sections[0].paragraphs[0];
para.addTable(2, 3);

const table = para.tables[0];
table.setCellText(0, 0, "Item");
table.setCellText(0, 1, "Qty");
table.setCellText(0, 2, "Price");
table.setCellText(1, 0, "Widget");
table.setCellText(1, 1, "10");
table.setCellText(1, 2, "100,000");

How do I add images?

doc.addImage(imageBytes, {
  mediaType: "image/png",
  widthMm: 100,
  heightMm: 80,
});

How do I style text?

const charPrId = doc.ensureRunStyle({ bold: true, italic: true, fontSize: 14 });
const paraPrId = doc.ensureParaStyle({ alignment: "center" });

How do I convert HWPX to Markdown or plain text?

npx @ubermensch1218/hwpx-cli hwpx-to-md document.hwpx
npx @ubermensch1218/hwpx-cli read document.hwpx

How do I connect HWPX to an AI agent (MCP)?

npx @ubermensch1218/hwpx-mcp

Claude Desktop / Claude Code config:

{
  "mcpServers": {
    "hwpx": {
      "command": "npx",
      "args": ["@ubermensch1218/hwpx-mcp"]
    }
  }
}

MCP tools provided: hwpx_read, hwpx_export, hwpx_extract_xml, hwpx_info

One-command setup

Set up everything at once — install dependencies, configure MCP, and you're ready:

npx @ubermensch1218/hwpx-cli init

This will:

  1. Install @ubermensch1218/hwpxcore into your project
  2. Optionally configure the HWPX MCP server for Claude Code
  3. Create a starter example file

Packages

Package Description npm
@ubermensch1218/hwpxcore Core HWPX read/edit library npm
@ubermensch1218/hwpxeditor React-based HWPX editor UI npm
@ubermensch1218/hwpx-mcp MCP server for LLM integration -
@ubermensch1218/hwpx-tools Conversion & export utilities -
@ubermensch1218/hwpx-cli CLI tool -

React Editor

npm install @ubermensch1218/hwpxeditor react react-dom
import { Editor } from "@ubermensch1218/hwpxeditor";

export default function App() {
  return <Editor />;
}

Compatibility

  • ZIP save writes mimetype as first entry with STORE compression (HWPX spec compliance)
  • XML serialization preserves HWPX namespace prefixes (hp, hs, hc, hh)
  • Graceful fallback for non-standard container/manifest with warning handlers

For LLMs & AI Agents

  • See llms.txt for a concise, machine-readable API reference
  • See llms-full.txt for complete API documentation
  • MCP server enables direct HWPX manipulation from Claude and other LLM agents

Research Notes

Development

pnpm install

# Test, typecheck, build
pnpm --filter @ubermensch1218/hwpxcore test
pnpm --filter @ubermensch1218/hwpxcore typecheck
pnpm --filter @ubermensch1218/hwpxcore build

License

Non-Commercial License. See LICENSE for details.


If hwpx-ts is useful to you, please consider giving it a star on GitHub!

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 71.0%
  • Python 27.4%
  • JavaScript 1.1%
  • Other 0.5%