kordoc 2.7.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OBSPVJ6A.js → chunk-3QA624ON.js} +59 -24
- package/dist/chunk-3QA624ON.js.map +1 -0
- package/dist/{chunk-GNN6MHH4.js → chunk-DLQY6FJH.js} +2 -2
- package/dist/{chunk-RFGEEHI4.cjs → chunk-HXWPJPRO.cjs} +2 -2
- package/dist/{chunk-RFGEEHI4.cjs.map → chunk-HXWPJPRO.cjs.map} +1 -1
- package/dist/{chunk-LA66FVBN.js → chunk-XSF3N6GU.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/index.cjs +168 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +58 -23
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-SRI2TIZX.cjs → parser-LKF6PGPD.cjs} +15 -15
- package/dist/{parser-SRI2TIZX.cjs.map → parser-LKF6PGPD.cjs.map} +1 -1
- package/dist/{parser-5CJGXQCJ.js → parser-UCO6WPUW.js} +2 -2
- package/dist/{parser-6L6DZCOB.js → parser-ZQQM6J7T.js} +2 -2
- package/dist/{watch-7CTGUDQB.js → watch-MRHNFJPC.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-OBSPVJ6A.js.map +0 -1
- /package/dist/{chunk-GNN6MHH4.js.map → chunk-DLQY6FJH.js.map} +0 -0
- /package/dist/{chunk-LA66FVBN.js.map → chunk-XSF3N6GU.js.map} +0 -0
- /package/dist/{parser-5CJGXQCJ.js.map → parser-UCO6WPUW.js.map} +0 -0
- /package/dist/{parser-6L6DZCOB.js.map → parser-ZQQM6J7T.js.map} +0 -0
- /package/dist/{watch-7CTGUDQB.js.map → watch-MRHNFJPC.js.map} +0 -0
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
sanitizeHref,
|
|
23
23
|
stripDtd,
|
|
24
24
|
toArrayBuffer
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-XSF3N6GU.js";
|
|
26
26
|
import {
|
|
27
27
|
parsePageRange
|
|
28
28
|
} from "./chunk-MOL7MDBG.js";
|
|
@@ -3829,7 +3829,15 @@ function setRunText(runEl, text) {
|
|
|
3829
3829
|
for (let i = 1; i < tElements.length; i++) {
|
|
3830
3830
|
clearChildren(tElements[i]);
|
|
3831
3831
|
}
|
|
3832
|
+
return;
|
|
3832
3833
|
}
|
|
3834
|
+
if (!text) return;
|
|
3835
|
+
const doc = runEl.ownerDocument;
|
|
3836
|
+
const ns = runEl.namespaceURI;
|
|
3837
|
+
const qualifiedName = runEl.prefix ? `${runEl.prefix}:t` : "t";
|
|
3838
|
+
const tEl = ns ? doc.createElementNS(ns, qualifiedName) : doc.createElement(qualifiedName);
|
|
3839
|
+
tEl.appendChild(doc.createTextNode(text));
|
|
3840
|
+
runEl.appendChild(tEl);
|
|
3833
3841
|
}
|
|
3834
3842
|
function clearChildren(el) {
|
|
3835
3843
|
while (el.firstChild) el.removeChild(el.firstChild);
|
|
@@ -3920,6 +3928,8 @@ var CHAR_H1 = 5;
|
|
|
3920
3928
|
var CHAR_H2 = 6;
|
|
3921
3929
|
var CHAR_H3 = 7;
|
|
3922
3930
|
var CHAR_H4 = 8;
|
|
3931
|
+
var CHAR_TABLE_HEADER = 9;
|
|
3932
|
+
var CHAR_QUOTE = 10;
|
|
3923
3933
|
var PARA_NORMAL = 0;
|
|
3924
3934
|
var PARA_H1 = 1;
|
|
3925
3935
|
var PARA_H2 = 2;
|
|
@@ -3928,14 +3938,30 @@ var PARA_H4 = 4;
|
|
|
3928
3938
|
var PARA_CODE = 5;
|
|
3929
3939
|
var PARA_QUOTE = 6;
|
|
3930
3940
|
var PARA_LIST = 7;
|
|
3931
|
-
|
|
3941
|
+
var DEFAULT_TEXT_COLOR = "#000000";
|
|
3942
|
+
function resolveTheme(theme) {
|
|
3943
|
+
return {
|
|
3944
|
+
h1: theme?.headingColors?.[1] ?? DEFAULT_TEXT_COLOR,
|
|
3945
|
+
h2: theme?.headingColors?.[2] ?? DEFAULT_TEXT_COLOR,
|
|
3946
|
+
h3: theme?.headingColors?.[3] ?? DEFAULT_TEXT_COLOR,
|
|
3947
|
+
h4: theme?.headingColors?.[4] ?? theme?.headingColors?.[3] ?? DEFAULT_TEXT_COLOR,
|
|
3948
|
+
body: theme?.bodyColor ?? DEFAULT_TEXT_COLOR,
|
|
3949
|
+
quote: theme?.quoteColor ?? DEFAULT_TEXT_COLOR,
|
|
3950
|
+
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
3951
|
+
hasQuoteOption: theme?.quoteColor !== void 0,
|
|
3952
|
+
tableHeader: theme?.tableHeaderColor ?? theme?.bodyColor ?? DEFAULT_TEXT_COLOR,
|
|
3953
|
+
tableHeaderBold: !!theme?.tableHeaderBold
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
async function markdownToHwpx(markdown, options) {
|
|
3957
|
+
const theme = resolveTheme(options?.theme);
|
|
3932
3958
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
3933
|
-
const sectionXml = blocksToSectionXml(blocks);
|
|
3959
|
+
const sectionXml = blocksToSectionXml(blocks, theme);
|
|
3934
3960
|
const zip = new JSZip3();
|
|
3935
3961
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
3936
3962
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
3937
3963
|
zip.file("Contents/content.hpf", generateManifest());
|
|
3938
|
-
zip.file("Contents/header.xml", generateHeaderXml());
|
|
3964
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme));
|
|
3939
3965
|
zip.file("Contents/section0.xml", sectionXml);
|
|
3940
3966
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
3941
3967
|
return await zip.generateAsync({ type: "arraybuffer" });
|
|
@@ -4115,11 +4141,11 @@ function generateManifest() {
|
|
|
4115
4141
|
</opf:spine>
|
|
4116
4142
|
</opf:package>`;
|
|
4117
4143
|
}
|
|
4118
|
-
function charPr(id, height, bold, italic, fontId = 0) {
|
|
4144
|
+
function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_COLOR) {
|
|
4119
4145
|
const boldAttr = bold ? ` bold="1"` : "";
|
|
4120
4146
|
const italicAttr = italic ? ` italic="1"` : "";
|
|
4121
4147
|
const effFont = bold ? 2 : fontId;
|
|
4122
|
-
return ` <hh:charPr id="${id}" height="${height}" textColor="
|
|
4148
|
+
return ` <hh:charPr id="${id}" height="${height}" textColor="${textColor}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="0"${boldAttr}${italicAttr}>
|
|
4123
4149
|
<hh:fontRef hangul="${effFont}" latin="${effFont}" hanja="${effFont}" japanese="${effFont}" other="${effFont}" symbol="${effFont}" user="${effFont}"/>
|
|
4124
4150
|
<hh:ratio hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
4125
4151
|
<hh:spacing hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
@@ -4139,7 +4165,7 @@ function paraPr(id, opts = {}) {
|
|
|
4139
4165
|
<hh:border borderFillIDRef="0" offsetLeft="0" offsetRight="0" offsetTop="0" offsetBottom="0" connect="0" ignoreMargin="0"/>
|
|
4140
4166
|
</hh:paraPr>`;
|
|
4141
4167
|
}
|
|
4142
|
-
function generateHeaderXml() {
|
|
4168
|
+
function generateHeaderXml(theme) {
|
|
4143
4169
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
4144
4170
|
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" version="1.4" secCnt="1">
|
|
4145
4171
|
<hh:beginNum page="1" footnote="1" endnote="1" pic="1" tbl="1" equation="1"/>
|
|
@@ -4215,16 +4241,18 @@ function generateHeaderXml() {
|
|
|
4215
4241
|
<hh:fillInfo/>
|
|
4216
4242
|
</hh:borderFill>
|
|
4217
4243
|
</hh:borderFills>
|
|
4218
|
-
<hh:charProperties itemCnt="
|
|
4219
|
-
${charPr(0, 1e3, false, false)}
|
|
4220
|
-
${charPr(1, 1e3, true, false)}
|
|
4221
|
-
${charPr(2, 1e3, false, true)}
|
|
4222
|
-
${charPr(3, 1e3, true, true)}
|
|
4244
|
+
<hh:charProperties itemCnt="11">
|
|
4245
|
+
${charPr(0, 1e3, false, false, 0, theme.body)}
|
|
4246
|
+
${charPr(1, 1e3, true, false, 0, theme.body)}
|
|
4247
|
+
${charPr(2, 1e3, false, true, 0, theme.body)}
|
|
4248
|
+
${charPr(3, 1e3, true, true, 0, theme.body)}
|
|
4223
4249
|
${charPr(4, 900, false, false, 1)}
|
|
4224
|
-
${charPr(5, 1800, true, false, 1)}
|
|
4225
|
-
${charPr(6, 1400, true, false, 1)}
|
|
4226
|
-
${charPr(7, 1200, true, false, 1)}
|
|
4227
|
-
${charPr(8, 1100, true, false, 1)}
|
|
4250
|
+
${charPr(5, 1800, true, false, 1, theme.h1)}
|
|
4251
|
+
${charPr(6, 1400, true, false, 1, theme.h2)}
|
|
4252
|
+
${charPr(7, 1200, true, false, 1, theme.h3)}
|
|
4253
|
+
${charPr(8, 1100, true, false, 1, theme.h4)}
|
|
4254
|
+
${charPr(CHAR_TABLE_HEADER, 1e3, theme.tableHeaderBold, false, 0, theme.tableHeader)}
|
|
4255
|
+
${charPr(CHAR_QUOTE, 1e3, false, true, 0, theme.quote)}
|
|
4228
4256
|
</hh:charProperties>
|
|
4229
4257
|
<hh:tabProperties itemCnt="0"/>
|
|
4230
4258
|
<hh:numberings itemCnt="0"/>
|
|
@@ -4254,7 +4282,7 @@ var tableIdCounter = TABLE_ID_BASE;
|
|
|
4254
4282
|
function nextTableId() {
|
|
4255
4283
|
return ++tableIdCounter;
|
|
4256
4284
|
}
|
|
4257
|
-
function generateTable(rows) {
|
|
4285
|
+
function generateTable(rows, theme) {
|
|
4258
4286
|
const rowCnt = rows.length;
|
|
4259
4287
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
4260
4288
|
const cellW = Math.floor(44e3 / colCnt);
|
|
@@ -4262,12 +4290,15 @@ function generateTable(rows) {
|
|
|
4262
4290
|
const tblW = cellW * colCnt;
|
|
4263
4291
|
const tblH = cellH * rowCnt;
|
|
4264
4292
|
const tblId = nextTableId();
|
|
4293
|
+
const useHeaderStyle = theme.tableHeader !== theme.body || theme.tableHeaderBold;
|
|
4265
4294
|
const trElements = rows.map((row, rowIdx) => {
|
|
4266
4295
|
const cells = row.length < colCnt ? [...row, ...Array(colCnt - row.length).fill("")] : row;
|
|
4296
|
+
const isHeaderRow = rowIdx === 0;
|
|
4297
|
+
const headerCharPr = isHeaderRow && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
4267
4298
|
const tdElements = cells.map((cell, colIdx) => {
|
|
4268
|
-
const runs = generateRuns(cell);
|
|
4299
|
+
const runs = generateRuns(cell, headerCharPr);
|
|
4269
4300
|
const p = `<hp:p paraPrIDRef="0" styleIDRef="0">${runs}</hp:p>`;
|
|
4270
|
-
return `<hp:tc name="" header="${
|
|
4301
|
+
return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="1"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${p}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${cellW}" height="${cellH}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
4271
4302
|
}).join("");
|
|
4272
4303
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
4273
4304
|
}).join("");
|
|
@@ -4275,7 +4306,7 @@ function generateTable(rows) {
|
|
|
4275
4306
|
const tbl = `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="1" noShading="0">${tblInner}</hp:tbl>`;
|
|
4276
4307
|
return `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${tbl}</hp:run></hp:p>`;
|
|
4277
4308
|
}
|
|
4278
|
-
function blocksToSectionXml(blocks) {
|
|
4309
|
+
function blocksToSectionXml(blocks, theme) {
|
|
4279
4310
|
const paraXmls = [];
|
|
4280
4311
|
let isFirst = true;
|
|
4281
4312
|
const orderedCounters = {};
|
|
@@ -4304,7 +4335,11 @@ function blocksToSectionXml(blocks) {
|
|
|
4304
4335
|
break;
|
|
4305
4336
|
}
|
|
4306
4337
|
case "blockquote":
|
|
4307
|
-
xml = generateParagraph(
|
|
4338
|
+
xml = generateParagraph(
|
|
4339
|
+
block.text || "",
|
|
4340
|
+
PARA_QUOTE,
|
|
4341
|
+
theme.hasQuoteOption ? CHAR_QUOTE : CHAR_NORMAL
|
|
4342
|
+
);
|
|
4308
4343
|
break;
|
|
4309
4344
|
case "list_item": {
|
|
4310
4345
|
const indent = block.indent || 0;
|
|
@@ -4337,7 +4372,7 @@ function blocksToSectionXml(blocks) {
|
|
|
4337
4372
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
4338
4373
|
isFirst = false;
|
|
4339
4374
|
}
|
|
4340
|
-
xml = generateTable(block.rows);
|
|
4375
|
+
xml = generateTable(block.rows, theme);
|
|
4341
4376
|
}
|
|
4342
4377
|
break;
|
|
4343
4378
|
}
|
|
@@ -18706,7 +18741,7 @@ async function parseHwp(buffer, options) {
|
|
|
18706
18741
|
async function parsePdf(buffer, options) {
|
|
18707
18742
|
let parsePdfDocument;
|
|
18708
18743
|
try {
|
|
18709
|
-
const mod = await import("./parser-
|
|
18744
|
+
const mod = await import("./parser-UCO6WPUW.js");
|
|
18710
18745
|
parsePdfDocument = mod.parsePdfDocument;
|
|
18711
18746
|
} catch {
|
|
18712
18747
|
return {
|
|
@@ -18944,4 +18979,4 @@ export {
|
|
|
18944
18979
|
compare,
|
|
18945
18980
|
parse
|
|
18946
18981
|
};
|
|
18947
|
-
//# sourceMappingURL=chunk-
|
|
18982
|
+
//# sourceMappingURL=chunk-3QA624ON.js.map
|