auto-hwpx
v0.1.2
Published
TypeScript utility for replacing text and image placeholders in HWPX files.
Maintainers
Readme
auto-hwpx
Utility to replace {{key}} and {{@imgKey}} placeholders in .hwpx files and emit a new .hwpx.
Note: Written by Codex.
Install
npm install -g auto-hwpx@latestUsage
$ auto-hwpx template.hwpx -o output.hwpx title="아무도안읽음" @img1="어린왕자.jpg"The above command will replace the following placeholders in template.hwpx:
{{title}}into "아무도안읽음",- and image right after
{{@img1}}into user given image"어린왕자.jpg".
Placeholder syntax
- Text placeholder:
{{key}} - Text placeholder with default:
{{key=default text}} - Image placeholder:
{{@imgKey}}
Demo

Command:
auto-hwpx \
template.hwpx \
-o output.hwpx \ # or output/directory (same file name as input)
title="아무도안읽음" \
name="차 은 우" \
content_line1="줄바꿈 지원은 하지 않습니다. 따로 placeholder를 사용해야 합니다." \
content_line2="HWPX 포맷이 좀 까다롭고, 대단한걸 원하는게 아니여서 구현하기 귗낳습니다." \
content_line3="**주의**: {{key}} 치환이후에 포맷이 바뀌어버리면 문제가 발생합니다." \
content_line4="예를들어, {{very_long_long_ 다음줄 long_long_key}} -> 토마토 의 경우 " \
content_line5="두줄에서 한줄이 되어버리므로 변환이 실패합니다." \
location="한강뷰 아파트" \
caption1="캡션도 가능!" \
@img1="어린왕자.jpg"Programmatic API
import { replaceHwpxPlaceholdersV2 } from "./src/render-hwpx-v2.js";
const result = await replaceHwpxPlaceholdersV2({
inputPath: "demo-assets/example.hwpx",
outputPath: "/tmp/output.hwpx",
replacements: {
name: "홍길동",
content: "작업 내용",
"@img1": "/absolute/path/to/image.png",
},
removeUnresolvedPlaceholders: true, // default true
});
console.log(result);Return shape:
interface ReplaceHwpxV2Result {
replacements: number;
imageReplacements: number;
unresolvedPlaceholders: string[];
}List keys API:
import { listHwpxPlaceholderKeysV2 } from "./src/render-hwpx-v2.js";
const keys = await listHwpxPlaceholderKeysV2({
inputPath: "demo-assets/example.hwpx",
});