kordoc 4.0.5 → 4.0.6
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/README.md +806 -800
- package/dist/{-QVHGOOCR.js → -NDU7YGSS.js} +8 -8
- package/dist/{chunk-QK2G34WE.js → chunk-4C7SBZNW.js} +2 -2
- package/dist/chunk-4C7SBZNW.js.map +1 -0
- package/dist/{chunk-MEPHGCPQ.js → chunk-5CJGKKMZ.js} +1 -1
- package/dist/chunk-5CJGKKMZ.js.map +1 -0
- package/dist/{chunk-OMERK4AW.js → chunk-5SOZXPQY.js} +3 -3
- package/dist/chunk-5SOZXPQY.js.map +1 -0
- package/dist/{chunk-6WDPB4SN.js → chunk-63ASYC4N.js} +3 -3
- package/dist/chunk-63ASYC4N.js.map +1 -0
- package/dist/{chunk-5RPYBC2Q.js → chunk-6GBLFQMA.js} +1 -1
- package/dist/chunk-6GBLFQMA.js.map +1 -0
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-6R5FY47W.cjs → chunk-DQJTNXVS.cjs} +2 -2
- package/dist/chunk-DQJTNXVS.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-Z6Q3YG22.js → chunk-HC2SEH6I.js} +39 -9
- package/dist/chunk-HC2SEH6I.js.map +1 -0
- package/dist/{chunk-FKK4K53F.js → chunk-HOGJ5ALY.js} +2 -2
- package/dist/chunk-HOGJ5ALY.js.map +1 -0
- package/dist/{chunk-ZGMMLYAL.js → chunk-KA4FEBS2.js} +2 -2
- package/dist/chunk-KA4FEBS2.js.map +1 -0
- package/dist/{chunk-6BABRVOJ.js → chunk-L3I4TIRP.js} +2 -2
- package/dist/chunk-L3I4TIRP.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-6PED5OOG.js → chunk-UVSOSFER.js} +2 -2
- package/dist/chunk-UVSOSFER.js.map +1 -0
- package/dist/cli.js +15 -15
- package/dist/cli.js.map +1 -1
- package/dist/{detect-RI2MQ33K.js → detect-PJZMUL2Z.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +167 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +13 -13
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +0 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-3MAYZUJX.js → parser-C636QIOB.js} +72 -4
- package/dist/parser-C636QIOB.js.map +1 -0
- package/dist/{parser-YSHZC5FQ.js → parser-DMKHIV4E.js} +71 -3
- package/dist/parser-DMKHIV4E.js.map +1 -0
- package/dist/{parser-2V5SPTU7.cjs → parser-VEY4B5CJ.cjs} +83 -15
- package/dist/parser-VEY4B5CJ.cjs.map +1 -0
- package/dist/{profile-io-3EECPDHG.js → profile-io-JYGCC6XQ.js} +3 -3
- package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
- package/dist/provider-5K7O3Z2O.cjs.map +1 -0
- package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
- package/dist/provider-7H4CPZYS.js.map +1 -0
- package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
- package/dist/provider-H4WWSPOV.js.map +1 -0
- package/dist/render-ISOEOMTM.js +10 -0
- package/dist/seal-676ZIAZZ.js +10 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-7MHSCKEQ.js → watch-ZQUFJBFR.js} +8 -8
- package/dist/watch-ZQUFJBFR.js.map +1 -0
- package/package.json +97 -97
- package/dist/chunk-5RPYBC2Q.js.map +0 -1
- package/dist/chunk-6BABRVOJ.js.map +0 -1
- package/dist/chunk-6PED5OOG.js.map +0 -1
- package/dist/chunk-6R5FY47W.cjs.map +0 -1
- package/dist/chunk-6WDPB4SN.js.map +0 -1
- package/dist/chunk-FKK4K53F.js.map +0 -1
- package/dist/chunk-MEPHGCPQ.js.map +0 -1
- package/dist/chunk-OMERK4AW.js.map +0 -1
- package/dist/chunk-QK2G34WE.js.map +0 -1
- package/dist/chunk-Z6Q3YG22.js.map +0 -1
- package/dist/chunk-ZGMMLYAL.js.map +0 -1
- package/dist/parser-2V5SPTU7.cjs.map +0 -1
- package/dist/parser-3MAYZUJX.js.map +0 -1
- package/dist/parser-YSHZC5FQ.js.map +0 -1
- package/dist/provider-4ZJKV3DC.js.map +0 -1
- package/dist/provider-AKROB7WQ.js.map +0 -1
- package/dist/provider-G4C2V2PD.cjs.map +0 -1
- package/dist/render-MJSQ4TG2.js +0 -10
- package/dist/seal-R3POFNOU.js +0 -10
- package/dist/watch-7MHSCKEQ.js.map +0 -1
- /package/dist/{-QVHGOOCR.js.map → -NDU7YGSS.js.map} +0 -0
- /package/dist/{detect-RI2MQ33K.js.map → detect-PJZMUL2Z.js.map} +0 -0
- /package/dist/{profile-io-3EECPDHG.js.map → profile-io-JYGCC6XQ.js.map} +0 -0
- /package/dist/{render-MJSQ4TG2.js.map → render-ISOEOMTM.js.map} +0 -0
- /package/dist/{seal-R3POFNOU.js.map → seal-676ZIAZZ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkDQJTNXVScjs = require('./chunk-DQJTNXVS.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -406,7 +406,7 @@ function createSectionShared() {
|
|
|
406
406
|
function createXmlParser(warnings) {
|
|
407
407
|
return new (0, _xmldom.DOMParser)({
|
|
408
408
|
onError(level, msg2) {
|
|
409
|
-
if (level === "fatalError") throw new (0,
|
|
409
|
+
if (level === "fatalError") throw new (0, _chunkDQJTNXVScjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
410
410
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
411
411
|
}
|
|
412
412
|
});
|
|
@@ -462,10 +462,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
462
462
|
const xml = await file.async("text");
|
|
463
463
|
if (decompressed) {
|
|
464
464
|
decompressed.total += xml.length * 2;
|
|
465
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
465
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
466
466
|
}
|
|
467
467
|
const parser = createXmlParser();
|
|
468
|
-
const doc = parser.parseFromString(
|
|
468
|
+
const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
|
|
469
469
|
if (!doc.documentElement) continue;
|
|
470
470
|
const domDoc = doc;
|
|
471
471
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -648,9 +648,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
648
648
|
let level = 0;
|
|
649
649
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
650
650
|
const ratio = block.style.fontSize / baseFontSize;
|
|
651
|
-
if (ratio >=
|
|
652
|
-
else if (ratio >=
|
|
653
|
-
else if (ratio >=
|
|
651
|
+
if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H1) level = 1;
|
|
652
|
+
else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H2) level = 2;
|
|
653
|
+
else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H3) level = 3;
|
|
654
654
|
}
|
|
655
655
|
const compactText = text.replace(/\s+/g, "");
|
|
656
656
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1575,7 +1575,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1575
1575
|
}
|
|
1576
1576
|
function assertFiniteRange(name, value, min, max) {
|
|
1577
1577
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1578
|
-
throw new (0,
|
|
1578
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
1581
1581
|
function validateGongmunOptions(opts) {
|
|
@@ -1590,10 +1590,10 @@ function validateGongmunOptions(opts) {
|
|
|
1590
1590
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1591
1591
|
}
|
|
1592
1592
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1593
|
-
throw new (0,
|
|
1593
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1594
1594
|
}
|
|
1595
1595
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1596
|
-
throw new (0,
|
|
1596
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1597
1597
|
}
|
|
1598
1598
|
}
|
|
1599
1599
|
if (opts.sizes) {
|
|
@@ -1602,7 +1602,7 @@ function validateGongmunOptions(opts) {
|
|
|
1602
1602
|
}
|
|
1603
1603
|
}
|
|
1604
1604
|
if (opts.approval && opts.approval.length > 6) {
|
|
1605
|
-
throw new (0,
|
|
1605
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("approval must contain at most 6 labels");
|
|
1606
1606
|
}
|
|
1607
1607
|
}
|
|
1608
1608
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1866,7 +1866,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1866
1866
|
|
|
1867
1867
|
// src/hwpx/table-build.ts
|
|
1868
1868
|
function buildTableWithCellMeta(state) {
|
|
1869
|
-
const table2 =
|
|
1869
|
+
const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, state.rows);
|
|
1870
1870
|
if (state.caption) table2.caption = state.caption;
|
|
1871
1871
|
const anchors = [];
|
|
1872
1872
|
{
|
|
@@ -1936,7 +1936,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1936
1936
|
const cell2 = parentTable.cell;
|
|
1937
1937
|
(cell2.blocks ??= []).push(block);
|
|
1938
1938
|
cell2.hasStructure = true;
|
|
1939
|
-
let flat =
|
|
1939
|
+
let flat = _chunkDQJTNXVScjs.convertTableToText.call(void 0, newTable.rows);
|
|
1940
1940
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1941
1941
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1942
1942
|
} else {
|
|
@@ -1948,7 +1948,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1948
1948
|
// src/hwpx/section-walker.ts
|
|
1949
1949
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1950
1950
|
const parser = createXmlParser(warnings);
|
|
1951
|
-
const doc = parser.parseFromString(
|
|
1951
|
+
const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1952
1952
|
if (!doc.documentElement) return [];
|
|
1953
1953
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1954
1954
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2053,8 +2053,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2053
2053
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2054
2054
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2055
2055
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2056
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2057
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2056
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkDQJTNXVScjs.MAX_COLS);
|
|
2057
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkDQJTNXVScjs.MAX_ROWS);
|
|
2058
2058
|
}
|
|
2059
2059
|
break;
|
|
2060
2060
|
case "p": {
|
|
@@ -2232,8 +2232,15 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
2232
2232
|
if (tag === "p" || tag === "para") {
|
|
2233
2233
|
const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
|
|
2234
2234
|
if (t) parts.push(t);
|
|
2235
|
+
const tbls = [];
|
|
2236
|
+
findTopLevelTbls(ch, tbls);
|
|
2237
|
+
for (const tbl2 of tbls) {
|
|
2238
|
+
const flat = flattenSubListTable(tbl2, ctx, depth);
|
|
2239
|
+
if (flat) parts.push(flat);
|
|
2240
|
+
}
|
|
2235
2241
|
} else if (tag === "tbl") {
|
|
2236
|
-
|
|
2242
|
+
const flat = flattenSubListTable(ch, ctx, depth);
|
|
2243
|
+
if (flat) parts.push(flat);
|
|
2237
2244
|
} else {
|
|
2238
2245
|
const t = collectSubListText(ch, ctx, depth + 1);
|
|
2239
2246
|
if (t) parts.push(t);
|
|
@@ -2241,6 +2248,29 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
2241
2248
|
}
|
|
2242
2249
|
return parts.join("\n").trim();
|
|
2243
2250
|
}
|
|
2251
|
+
function flattenSubListTable(el, ctx, depth) {
|
|
2252
|
+
const sink = [];
|
|
2253
|
+
const st = { rows: [], currentRow: [], cell: null };
|
|
2254
|
+
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2255
|
+
let flat = _chunkDQJTNXVScjs.convertTableToText.call(void 0, st.rows);
|
|
2256
|
+
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2257
|
+
return flat;
|
|
2258
|
+
}
|
|
2259
|
+
function findTopLevelTbls(el, out, depth = 0) {
|
|
2260
|
+
if (depth > MAX_XML_DEPTH) return;
|
|
2261
|
+
const kids2 = el.childNodes;
|
|
2262
|
+
if (!kids2) return;
|
|
2263
|
+
for (let i = 0; i < kids2.length; i++) {
|
|
2264
|
+
const ch = kids2[i];
|
|
2265
|
+
if (ch.nodeType !== 1) continue;
|
|
2266
|
+
const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
|
|
2267
|
+
if (tag === "tbl") {
|
|
2268
|
+
out.push(ch);
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
findTopLevelTbls(ch, out, depth + 1);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2244
2274
|
function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
2245
2275
|
if (depth > MAX_XML_DEPTH) return tableCtx;
|
|
2246
2276
|
const children = node.childNodes;
|
|
@@ -2355,7 +2385,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2355
2385
|
let url = (ch.textContent || "").trim();
|
|
2356
2386
|
if (!url) continue;
|
|
2357
2387
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2358
|
-
const safe =
|
|
2388
|
+
const safe = _chunkDQJTNXVScjs.sanitizeHref.call(void 0, url);
|
|
2359
2389
|
if (safe) return safe;
|
|
2360
2390
|
}
|
|
2361
2391
|
return void 0;
|
|
@@ -2493,7 +2523,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2493
2523
|
case "hyperlink": {
|
|
2494
2524
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2495
2525
|
if (url) {
|
|
2496
|
-
const safe =
|
|
2526
|
+
const safe = _chunkDQJTNXVScjs.sanitizeHref.call(void 0, url);
|
|
2497
2527
|
if (safe) href = safe;
|
|
2498
2528
|
}
|
|
2499
2529
|
walk(child);
|
|
@@ -2765,13 +2795,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
2765
2795
|
}
|
|
2766
2796
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
2767
2797
|
for (const path of allCandidates) {
|
|
2768
|
-
if (
|
|
2798
|
+
if (_chunkDQJTNXVScjs.isPathTraversal.call(void 0, path)) continue;
|
|
2769
2799
|
const file = zip.file(path);
|
|
2770
2800
|
if (!file) continue;
|
|
2771
2801
|
try {
|
|
2772
2802
|
const data = await file.async("uint8array");
|
|
2773
2803
|
decompressed.total += data.length;
|
|
2774
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2804
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2775
2805
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
2776
2806
|
const mimeType = imageExtToMime(ext);
|
|
2777
2807
|
imageIndex++;
|
|
@@ -2780,7 +2810,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
2780
2810
|
images.push(img);
|
|
2781
2811
|
break;
|
|
2782
2812
|
} catch (err) {
|
|
2783
|
-
if (err instanceof
|
|
2813
|
+
if (err instanceof _chunkDQJTNXVScjs.KordocError) throw err;
|
|
2784
2814
|
}
|
|
2785
2815
|
}
|
|
2786
2816
|
if (!img) _optionalChain([warnings, 'optionalAccess', _67 => _67.push, 'call', _68 => _68({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -2842,7 +2872,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
2842
2872
|
}
|
|
2843
2873
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
2844
2874
|
const name = new TextDecoder().decode(nameBytes);
|
|
2845
|
-
if (
|
|
2875
|
+
if (_chunkDQJTNXVScjs.isPathTraversal.call(void 0, name)) {
|
|
2846
2876
|
pos = fileStart + compSize;
|
|
2847
2877
|
continue;
|
|
2848
2878
|
}
|
|
@@ -2860,16 +2890,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2860
2890
|
continue;
|
|
2861
2891
|
}
|
|
2862
2892
|
totalDecompressed += content.length * 2;
|
|
2863
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2893
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2864
2894
|
sectionNum++;
|
|
2865
2895
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2866
2896
|
} catch (e13) {
|
|
2867
2897
|
continue;
|
|
2868
2898
|
}
|
|
2869
2899
|
}
|
|
2870
|
-
if (blocks.length === 0) throw new (0,
|
|
2900
|
+
if (blocks.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2871
2901
|
applyPageText(blocks, shared);
|
|
2872
|
-
const markdown =
|
|
2902
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
|
|
2873
2903
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2874
2904
|
}
|
|
2875
2905
|
async function readKordocLayout(zip) {
|
|
@@ -2894,18 +2924,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2894
2924
|
if (paths.length > 0) return paths;
|
|
2895
2925
|
}
|
|
2896
2926
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2897
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2927
|
+
return sectionFiles.map((f) => f.name).sort(_chunkDQJTNXVScjs.compareSectionPaths);
|
|
2898
2928
|
}
|
|
2899
2929
|
function parseSectionPathsFromManifest(xml) {
|
|
2900
2930
|
const parser = createXmlParser();
|
|
2901
|
-
const doc = parser.parseFromString(
|
|
2931
|
+
const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2902
2932
|
const items = doc.getElementsByTagName("opf:item");
|
|
2903
2933
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2904
2934
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2905
2935
|
for (let i = 0; i < items.length; i++) {
|
|
2906
2936
|
const item = items[i];
|
|
2907
2937
|
const id = item.getAttribute("id") || "";
|
|
2908
|
-
const href =
|
|
2938
|
+
const href = _chunkDQJTNXVScjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2909
2939
|
if (id && href) idToHref.set(id, href);
|
|
2910
2940
|
}
|
|
2911
2941
|
if (spine.length > 0) {
|
|
@@ -2916,7 +2946,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2916
2946
|
}
|
|
2917
2947
|
if (ordered.length > 0) return ordered;
|
|
2918
2948
|
}
|
|
2919
|
-
return Array.from(idToHref.values()).sort(
|
|
2949
|
+
return Array.from(idToHref.values()).sort(_chunkDQJTNXVScjs.compareSectionPaths);
|
|
2920
2950
|
}
|
|
2921
2951
|
|
|
2922
2952
|
// src/hwpx/metadata.ts
|
|
@@ -2929,7 +2959,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2929
2959
|
const xml = await file.async("text");
|
|
2930
2960
|
if (decompressed) {
|
|
2931
2961
|
decompressed.total += xml.length * 2;
|
|
2932
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2962
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2933
2963
|
}
|
|
2934
2964
|
parseDublinCoreMetadata(xml, metadata);
|
|
2935
2965
|
if (metadata.title || metadata.author) return;
|
|
@@ -2939,7 +2969,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2939
2969
|
}
|
|
2940
2970
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2941
2971
|
const parser = createXmlParser();
|
|
2942
|
-
const doc = parser.parseFromString(
|
|
2972
|
+
const doc = parser.parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2943
2973
|
if (!doc.documentElement) return;
|
|
2944
2974
|
const getText = (tagNames) => {
|
|
2945
2975
|
for (const tag of tagNames) {
|
|
@@ -2964,7 +2994,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2964
2994
|
|
|
2965
2995
|
// src/hwpx/parser.ts
|
|
2966
2996
|
async function parseHwpxDocument(buffer, options) {
|
|
2967
|
-
|
|
2997
|
+
_chunkDQJTNXVScjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2968
2998
|
let zip;
|
|
2969
2999
|
try {
|
|
2970
3000
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2973,7 +3003,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2973
3003
|
}
|
|
2974
3004
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2975
3005
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2976
|
-
throw new (0,
|
|
3006
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2977
3007
|
}
|
|
2978
3008
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2979
3009
|
if (manifestFile) {
|
|
@@ -2985,7 +3015,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2985
3015
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2986
3016
|
}
|
|
2987
3017
|
}
|
|
2988
|
-
throw new (0,
|
|
3018
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
2989
3019
|
}
|
|
2990
3020
|
}
|
|
2991
3021
|
const decompressed = { total: 0 };
|
|
@@ -2994,7 +3024,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2994
3024
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2995
3025
|
const warnings = [];
|
|
2996
3026
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2997
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3027
|
+
if (sectionPaths.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2998
3028
|
metadata.pageCount = sectionPaths.length;
|
|
2999
3029
|
const pageFilter = _optionalChain([options, 'optionalAccess', _77 => _77.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3000
3030
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3009,12 +3039,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3009
3039
|
try {
|
|
3010
3040
|
const xml = await file.async("text");
|
|
3011
3041
|
decompressed.total += xml.length * 2;
|
|
3012
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3042
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3013
3043
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3014
3044
|
parsedSections++;
|
|
3015
3045
|
_optionalChain([options, 'optionalAccess', _78 => _78.onProgress, 'optionalCall', _79 => _79(parsedSections, totalTarget)]);
|
|
3016
3046
|
} catch (secErr) {
|
|
3017
|
-
if (secErr instanceof
|
|
3047
|
+
if (secErr instanceof _chunkDQJTNXVScjs.KordocError) throw secErr;
|
|
3018
3048
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3019
3049
|
}
|
|
3020
3050
|
}
|
|
@@ -3022,7 +3052,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3022
3052
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
3023
3053
|
detectHwpxHeadings(blocks, styleMap);
|
|
3024
3054
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3025
|
-
const markdown =
|
|
3055
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
|
|
3026
3056
|
return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3027
3057
|
}
|
|
3028
3058
|
|
|
@@ -3089,7 +3119,7 @@ function decompressStream(data) {
|
|
|
3089
3119
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
3090
3120
|
}
|
|
3091
3121
|
function parseFileHeader(data) {
|
|
3092
|
-
if (data.length < 40) throw new (0,
|
|
3122
|
+
if (data.length < 40) throw new (0, _chunkDQJTNXVScjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
3093
3123
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
3094
3124
|
return {
|
|
3095
3125
|
signature: sig,
|
|
@@ -4759,7 +4789,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4759
4789
|
lenientCfb = parseLenientCfb(buffer);
|
|
4760
4790
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4761
4791
|
} catch (e22) {
|
|
4762
|
-
throw new (0,
|
|
4792
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4763
4793
|
}
|
|
4764
4794
|
}
|
|
4765
4795
|
const findStream = (path) => {
|
|
@@ -4770,11 +4800,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4770
4800
|
return lenientCfb.findStream(path);
|
|
4771
4801
|
};
|
|
4772
4802
|
const headerData = findStream("/FileHeader");
|
|
4773
|
-
if (!headerData) throw new (0,
|
|
4803
|
+
if (!headerData) throw new (0, _chunkDQJTNXVScjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4774
4804
|
const header = parseFileHeader(headerData);
|
|
4775
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4776
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4777
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4805
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkDQJTNXVScjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4806
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4807
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkDQJTNXVScjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4778
4808
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4779
4809
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4780
4810
|
const metadata = {
|
|
@@ -4783,7 +4813,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4783
4813
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4784
4814
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4785
4815
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4786
|
-
if (sections.length === 0) throw new (0,
|
|
4816
|
+
if (sections.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4787
4817
|
metadata.pageCount = sections.length;
|
|
4788
4818
|
const pageFilter = _optionalChain([options, 'optionalAccess', _84 => _84.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4789
4819
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4797,22 +4827,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4797
4827
|
const sectionData = sections[si];
|
|
4798
4828
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4799
4829
|
totalDecompressed += data.length;
|
|
4800
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4830
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4801
4831
|
const records = readRecords(data);
|
|
4802
4832
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4803
4833
|
bodyBlocks.push(...sectionBlocks);
|
|
4804
4834
|
parsedSections++;
|
|
4805
4835
|
_optionalChain([options, 'optionalAccess', _85 => _85.onProgress, 'optionalCall', _86 => _86(parsedSections, totalTarget)]);
|
|
4806
4836
|
} catch (secErr) {
|
|
4807
|
-
if (secErr instanceof
|
|
4837
|
+
if (secErr instanceof _chunkDQJTNXVScjs.KordocError) throw secErr;
|
|
4808
4838
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
4809
4839
|
}
|
|
4810
4840
|
}
|
|
4811
4841
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4812
4842
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
4813
|
-
let flatBlocks =
|
|
4843
|
+
let flatBlocks = _chunkDQJTNXVScjs.flattenLayoutTables.call(void 0, blocks);
|
|
4814
4844
|
if (_optionalChain([options, 'optionalAccess', _87 => _87.dedupeRunningHeaders])) {
|
|
4815
|
-
const deduped =
|
|
4845
|
+
const deduped = _chunkDQJTNXVScjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4816
4846
|
const removed = flatBlocks.length - deduped.length;
|
|
4817
4847
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4818
4848
|
flatBlocks = deduped;
|
|
@@ -4821,7 +4851,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4821
4851
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4822
4852
|
}
|
|
4823
4853
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4824
|
-
let markdown =
|
|
4854
|
+
let markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4825
4855
|
if (_optionalChain([options, 'optionalAccess', _88 => _88.inlineImages]) && images.length > 0) {
|
|
4826
4856
|
try {
|
|
4827
4857
|
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
@@ -4888,9 +4918,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4888
4918
|
let level = 0;
|
|
4889
4919
|
if (_optionalChain([block, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]) && baseFontSize > 0) {
|
|
4890
4920
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4891
|
-
if (ratio >=
|
|
4892
|
-
else if (ratio >=
|
|
4893
|
-
else if (ratio >=
|
|
4921
|
+
if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H1) level = 1;
|
|
4922
|
+
else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H2) level = 2;
|
|
4923
|
+
else if (ratio >= _chunkDQJTNXVScjs.HEADING_RATIO_H3) level = 3;
|
|
4894
4924
|
}
|
|
4895
4925
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4896
4926
|
if (level === 0) level = 2;
|
|
@@ -4975,7 +5005,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4975
5005
|
if (!raw) break;
|
|
4976
5006
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4977
5007
|
totalDecompressed += content.length;
|
|
4978
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5008
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4979
5009
|
sections.push({ idx: i, content });
|
|
4980
5010
|
}
|
|
4981
5011
|
if (sections.length === 0) {
|
|
@@ -4987,7 +5017,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4987
5017
|
if (raw) {
|
|
4988
5018
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4989
5019
|
totalDecompressed += content.length;
|
|
4990
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5020
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4991
5021
|
sections.push({ idx, content });
|
|
4992
5022
|
}
|
|
4993
5023
|
}
|
|
@@ -5004,7 +5034,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5004
5034
|
try {
|
|
5005
5035
|
const content = decryptViewText(raw, compressed);
|
|
5006
5036
|
totalDecompressed += content.length;
|
|
5007
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5037
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5008
5038
|
sections.push({ idx: i, content });
|
|
5009
5039
|
} catch (e27) {
|
|
5010
5040
|
break;
|
|
@@ -5107,7 +5137,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5107
5137
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5108
5138
|
if (!_optionalChain([ctrl, 'optionalAccess', _101 => _101.href]) || r.end <= r.start) continue;
|
|
5109
5139
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5110
|
-
const href =
|
|
5140
|
+
const href = _chunkDQJTNXVScjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5111
5141
|
if (!href) continue;
|
|
5112
5142
|
const anchor = text.slice(r.start, r.end);
|
|
5113
5143
|
if (!anchor.trim()) continue;
|
|
@@ -5340,8 +5370,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5340
5370
|
let tableIdx = -1;
|
|
5341
5371
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5342
5372
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5343
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5344
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5373
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkDQJTNXVScjs.MAX_ROWS);
|
|
5374
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkDQJTNXVScjs.MAX_COLS);
|
|
5345
5375
|
tableIdx = i2;
|
|
5346
5376
|
break;
|
|
5347
5377
|
}
|
|
@@ -5390,7 +5420,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5390
5420
|
return table3;
|
|
5391
5421
|
}
|
|
5392
5422
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5393
|
-
const table2 =
|
|
5423
|
+
const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
|
|
5394
5424
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5395
5425
|
return table2.rows > 0 ? table2 : null;
|
|
5396
5426
|
}
|
|
@@ -5407,8 +5437,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5407
5437
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5408
5438
|
const cs = rec.data.readUInt16LE(12);
|
|
5409
5439
|
const rs = rec.data.readUInt16LE(14);
|
|
5410
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5411
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5440
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkDQJTNXVScjs.MAX_COLS);
|
|
5441
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkDQJTNXVScjs.MAX_ROWS);
|
|
5412
5442
|
}
|
|
5413
5443
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5414
5444
|
const parts = [];
|
|
@@ -5418,7 +5448,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5418
5448
|
parts.push(``);
|
|
5419
5449
|
hasStructure = true;
|
|
5420
5450
|
} else if (b.type === "table" && b.table) {
|
|
5421
|
-
const flat =
|
|
5451
|
+
const flat = _chunkDQJTNXVScjs.convertTableToText.call(void 0, b.table.cells);
|
|
5422
5452
|
if (flat) parts.push(flat);
|
|
5423
5453
|
hasStructure = true;
|
|
5424
5454
|
} else if (b.text) {
|
|
@@ -17855,7 +17885,7 @@ function getTextContent(el) {
|
|
|
17855
17885
|
return _nullishCoalesce(_optionalChain([el, 'access', _116 => _116.textContent, 'optionalAccess', _117 => _117.trim, 'call', _118 => _118()]), () => ( ""));
|
|
17856
17886
|
}
|
|
17857
17887
|
function parseXml(text) {
|
|
17858
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17888
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, text), "text/xml");
|
|
17859
17889
|
}
|
|
17860
17890
|
function parseSharedStrings(xml) {
|
|
17861
17891
|
const doc = parseXml(xml);
|
|
@@ -17999,7 +18029,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17999
18029
|
cellRows.push(row);
|
|
18000
18030
|
}
|
|
18001
18031
|
if (cellRows.length > 0) {
|
|
18002
|
-
const table2 =
|
|
18032
|
+
const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
|
|
18003
18033
|
if (table2.rows > 0) {
|
|
18004
18034
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18005
18035
|
}
|
|
@@ -18007,12 +18037,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
18007
18037
|
return blocks;
|
|
18008
18038
|
}
|
|
18009
18039
|
async function parseXlsxDocument(buffer, options) {
|
|
18010
|
-
|
|
18040
|
+
_chunkDQJTNXVScjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
18011
18041
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18012
18042
|
const warnings = [];
|
|
18013
18043
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18014
18044
|
if (!workbookFile) {
|
|
18015
|
-
throw new (0,
|
|
18045
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18016
18046
|
}
|
|
18017
18047
|
let sharedStrings = [];
|
|
18018
18048
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18021,7 +18051,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18021
18051
|
}
|
|
18022
18052
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
18023
18053
|
if (sheets.length === 0) {
|
|
18024
|
-
throw new (0,
|
|
18054
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18025
18055
|
}
|
|
18026
18056
|
let relsMap = /* @__PURE__ */ new Map();
|
|
18027
18057
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -18093,7 +18123,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18093
18123
|
} catch (e28) {
|
|
18094
18124
|
}
|
|
18095
18125
|
}
|
|
18096
|
-
const markdown =
|
|
18126
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
|
|
18097
18127
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18098
18128
|
}
|
|
18099
18129
|
|
|
@@ -18500,11 +18530,11 @@ function processGlobals(records) {
|
|
|
18500
18530
|
let encrypted = false;
|
|
18501
18531
|
const firstBof = records[0];
|
|
18502
18532
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18503
|
-
throw new (0,
|
|
18533
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18504
18534
|
}
|
|
18505
18535
|
const bof = decodeBof(firstBof.data);
|
|
18506
18536
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18507
|
-
throw new (0,
|
|
18537
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18508
18538
|
}
|
|
18509
18539
|
let i = 1;
|
|
18510
18540
|
while (i < records.length) {
|
|
@@ -18619,7 +18649,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
18619
18649
|
cellRows.push(row);
|
|
18620
18650
|
}
|
|
18621
18651
|
if (cellRows.length > 0) {
|
|
18622
|
-
const table2 =
|
|
18652
|
+
const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
|
|
18623
18653
|
if (table2.rows > 0) {
|
|
18624
18654
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18625
18655
|
}
|
|
@@ -18632,21 +18662,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18632
18662
|
try {
|
|
18633
18663
|
cfb = parseLenientCfb(buf);
|
|
18634
18664
|
} catch (e) {
|
|
18635
|
-
throw new (0,
|
|
18665
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
18636
18666
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18637
18667
|
);
|
|
18638
18668
|
}
|
|
18639
18669
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18640
18670
|
if (!wb) {
|
|
18641
|
-
throw new (0,
|
|
18671
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18642
18672
|
}
|
|
18643
18673
|
const records = readRecords2(wb);
|
|
18644
18674
|
if (records.length === 0) {
|
|
18645
|
-
throw new (0,
|
|
18675
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18646
18676
|
}
|
|
18647
18677
|
const firstBof = decodeBof(records[0].data);
|
|
18648
18678
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18649
|
-
throw new (0,
|
|
18679
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
18650
18680
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18651
18681
|
);
|
|
18652
18682
|
}
|
|
@@ -18706,7 +18736,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18706
18736
|
pageCount: totalSheets
|
|
18707
18737
|
};
|
|
18708
18738
|
return {
|
|
18709
|
-
markdown:
|
|
18739
|
+
markdown: _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18710
18740
|
blocks: allBlocks,
|
|
18711
18741
|
metadata,
|
|
18712
18742
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19144,7 +19174,7 @@ function getAttr(el, localName2) {
|
|
|
19144
19174
|
return null;
|
|
19145
19175
|
}
|
|
19146
19176
|
function parseXml2(text) {
|
|
19147
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19177
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkDQJTNXVScjs.stripDtd.call(void 0, text), "text/xml");
|
|
19148
19178
|
}
|
|
19149
19179
|
function parseStyles(xml) {
|
|
19150
19180
|
const doc = parseXml2(xml);
|
|
@@ -19429,7 +19459,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19429
19459
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19430
19460
|
})
|
|
19431
19461
|
);
|
|
19432
|
-
const table2 =
|
|
19462
|
+
const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
|
|
19433
19463
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19434
19464
|
return { type: "table", table: table2 };
|
|
19435
19465
|
}
|
|
@@ -19496,12 +19526,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
19496
19526
|
return { blocks, images };
|
|
19497
19527
|
}
|
|
19498
19528
|
async function parseDocxDocument(buffer, options) {
|
|
19499
|
-
|
|
19529
|
+
_chunkDQJTNXVScjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
19500
19530
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19501
19531
|
const warnings = [];
|
|
19502
19532
|
const docFile = zip.file("word/document.xml");
|
|
19503
19533
|
if (!docFile) {
|
|
19504
|
-
throw new (0,
|
|
19534
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19505
19535
|
}
|
|
19506
19536
|
let rels = /* @__PURE__ */ new Map();
|
|
19507
19537
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19548,7 +19578,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19548
19578
|
const doc = parseXml2(docXml);
|
|
19549
19579
|
const body = findElements(doc, "body");
|
|
19550
19580
|
if (body.length === 0) {
|
|
19551
|
-
throw new (0,
|
|
19581
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19552
19582
|
}
|
|
19553
19583
|
const blocks = [];
|
|
19554
19584
|
const bodyEl = body[0];
|
|
@@ -19593,7 +19623,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19593
19623
|
}
|
|
19594
19624
|
}
|
|
19595
19625
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19596
|
-
const markdown =
|
|
19626
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
|
|
19597
19627
|
return {
|
|
19598
19628
|
markdown,
|
|
19599
19629
|
blocks,
|
|
@@ -19616,7 +19646,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19616
19646
|
}
|
|
19617
19647
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19618
19648
|
const normalized = text.replace(/ /g, " ");
|
|
19619
|
-
const xml =
|
|
19649
|
+
const xml = _chunkDQJTNXVScjs.stripDtd.call(void 0, normalized);
|
|
19620
19650
|
const warnings = [];
|
|
19621
19651
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19622
19652
|
onError: (_level, msg2) => {
|
|
@@ -19656,7 +19686,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19656
19686
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
19657
19687
|
}
|
|
19658
19688
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
19659
|
-
const markdown =
|
|
19689
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
|
|
19660
19690
|
return {
|
|
19661
19691
|
markdown,
|
|
19662
19692
|
blocks,
|
|
@@ -19814,7 +19844,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
19814
19844
|
const cellRows = grid.map(
|
|
19815
19845
|
(row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
19816
19846
|
);
|
|
19817
|
-
const table2 =
|
|
19847
|
+
const table2 = _chunkDQJTNXVScjs.buildTable.call(void 0, cellRows);
|
|
19818
19848
|
const caption = extractShapeCaption(el);
|
|
19819
19849
|
if (caption.text && caption.before) {
|
|
19820
19850
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21142,19 +21172,19 @@ function parseCentralDirectory(buf) {
|
|
|
21142
21172
|
}
|
|
21143
21173
|
}
|
|
21144
21174
|
}
|
|
21145
|
-
if (eocdOffset < 0) throw new (0,
|
|
21175
|
+
if (eocdOffset < 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21146
21176
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21147
21177
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21148
21178
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21149
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21179
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21150
21180
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21151
|
-
throw new (0,
|
|
21181
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21152
21182
|
}
|
|
21153
21183
|
const decoder = new TextDecoder("utf-8");
|
|
21154
21184
|
const entries = [];
|
|
21155
21185
|
let pos = cdOffset;
|
|
21156
21186
|
for (let i = 0; i < totalEntries; i++) {
|
|
21157
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21187
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21158
21188
|
const flags = view.getUint16(pos + 8, true);
|
|
21159
21189
|
const method = view.getUint16(pos + 10, true);
|
|
21160
21190
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21165,7 +21195,7 @@ function parseCentralDirectory(buf) {
|
|
|
21165
21195
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21166
21196
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21167
21197
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21168
|
-
throw new (0,
|
|
21198
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21169
21199
|
}
|
|
21170
21200
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21171
21201
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21194,11 +21224,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21194
21224
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21195
21225
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21196
21226
|
for (const name of replacements.keys()) {
|
|
21197
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21227
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkDQJTNXVScjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21198
21228
|
}
|
|
21199
21229
|
if (additions) {
|
|
21200
21230
|
for (const name of additions.keys()) {
|
|
21201
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21231
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkDQJTNXVScjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21202
21232
|
}
|
|
21203
21233
|
}
|
|
21204
21234
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21217,7 +21247,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21217
21247
|
offset += seg.length;
|
|
21218
21248
|
continue;
|
|
21219
21249
|
}
|
|
21220
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21250
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkDQJTNXVScjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21221
21251
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21222
21252
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21223
21253
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21323,7 +21353,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21323
21353
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21324
21354
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21325
21355
|
if (sectionPaths.length === 0) {
|
|
21326
|
-
throw new (0,
|
|
21356
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21327
21357
|
}
|
|
21328
21358
|
const normalizedValues = normalizeValues(values);
|
|
21329
21359
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -22012,7 +22042,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22012
22042
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22013
22043
|
const got = m ? Number(m[1]) : NaN;
|
|
22014
22044
|
if (got !== startId + i) {
|
|
22015
|
-
throw new (0,
|
|
22045
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
22016
22046
|
`\uB0B4\uBD80 \uC624\uB958: ${label} id \uD30C\uD2F0\uC158 \uB4DC\uB9AC\uD504\uD2B8 \u2014 ${startId + i} \uC704\uCE58\uC5D0 id=${m ? m[1] : "?"} \uBC29\uCD9C. id \uC0C1\uC218(gen-ids)\uC640 \uC2E4\uC81C \uBC29\uCD9C \uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4 (GJ_CHAR_COUNT\uB958 \uCE74\uC6B4\uD2B8\xB7base \uC0B0\uC220 \uD655\uC778)`
|
|
22017
22047
|
);
|
|
22018
22048
|
}
|
|
@@ -22096,7 +22126,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22096
22126
|
}
|
|
22097
22127
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22098
22128
|
if (rows.length !== expectedBase) {
|
|
22099
|
-
throw new (0,
|
|
22129
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
22100
22130
|
`\uB0B4\uBD80 \uC624\uB958: charPr \uAE30\uBCF8 \uBE14\uB85D \uBC29\uCD9C \uC218(${rows.length}) \u2260 charVariantBase(${expectedBase}) \u2014 gen-header \uBC29\uCD9C \uD589\uACFC gen-ids \uCE74\uC6B4\uD2B8 \uC0C1\uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4`
|
|
22101
22131
|
);
|
|
22102
22132
|
}
|
|
@@ -22971,7 +23001,7 @@ function escapeGfm(text) {
|
|
|
22971
23001
|
}
|
|
22972
23002
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
22973
23003
|
function sanitizeText(text) {
|
|
22974
|
-
let result =
|
|
23004
|
+
let result = _chunkDQJTNXVScjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
22975
23005
|
if (result.length <= 30 && result.includes(" ")) {
|
|
22976
23006
|
const tokens = result.split(" ");
|
|
22977
23007
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -25372,11 +25402,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25372
25402
|
return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
|
|
25373
25403
|
}
|
|
25374
25404
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25375
|
-
if (ops.length === 0) throw new (0,
|
|
25405
|
+
if (ops.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25376
25406
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25377
25407
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25378
25408
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _332 => _332.match, 'call', _333 => _333(/(\d+)\.xml$/i), 'optionalAccess', _334 => _334[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _335 => _335.match, 'call', _336 => _336(/(\d+)\.xml$/i), 'optionalAccess', _337 => _337[1]]), () => ( 0))));
|
|
25379
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25409
|
+
if (sectionPaths.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25380
25410
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25381
25411
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25382
25412
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25417,11 +25447,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25417
25447
|
const manifestItems = [];
|
|
25418
25448
|
const placed = [];
|
|
25419
25449
|
for (const op of ops) {
|
|
25420
|
-
if (!op.anchor) throw new (0,
|
|
25421
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25450
|
+
if (!op.anchor) throw new (0, _chunkDQJTNXVScjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25451
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25422
25452
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25423
|
-
if (!MIME[ext]) throw new (0,
|
|
25424
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25453
|
+
if (!MIME[ext]) throw new (0, _chunkDQJTNXVScjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25454
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkDQJTNXVScjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
25425
25455
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25426
25456
|
let found = null;
|
|
25427
25457
|
let total = 0;
|
|
@@ -25454,7 +25484,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25454
25484
|
}
|
|
25455
25485
|
}
|
|
25456
25486
|
}
|
|
25457
|
-
throw new (0,
|
|
25487
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
25458
25488
|
`place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
|
|
25459
25489
|
);
|
|
25460
25490
|
}
|
|
@@ -25462,7 +25492,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25462
25492
|
const xml = sectionXmls[si];
|
|
25463
25493
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25464
25494
|
if (!run) {
|
|
25465
|
-
throw new (0,
|
|
25495
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
25466
25496
|
}
|
|
25467
25497
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _338 => _338.charPr, 'access', _339 => _339.get, 'call', _340 => _340(run.charPr), 'optionalAccess', _341 => _341.height]), () => ( 1e3));
|
|
25468
25498
|
const fontPt = charPrHeight / 100;
|
|
@@ -25740,7 +25770,7 @@ function pick(map, keys) {
|
|
|
25740
25770
|
return out;
|
|
25741
25771
|
}
|
|
25742
25772
|
async function hwpxToProfile(input) {
|
|
25743
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
25773
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, input);
|
|
25744
25774
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
25745
25775
|
const parser = createXmlParser();
|
|
25746
25776
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _363 => _363.file, 'call', _364 => _364(/[Hh]eader\.xml$/), 'optionalAccess', _365 => _365[0]])));
|
|
@@ -26659,7 +26689,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
26659
26689
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
26660
26690
|
if (paths.length > 0) return paths;
|
|
26661
26691
|
}
|
|
26662
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
26692
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkDQJTNXVScjs.compareSectionPaths);
|
|
26663
26693
|
}
|
|
26664
26694
|
function sectionPathsFromManifest(xml) {
|
|
26665
26695
|
const attr = (tag, name) => {
|
|
@@ -26669,7 +26699,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26669
26699
|
const idToHref = /* @__PURE__ */ new Map();
|
|
26670
26700
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
26671
26701
|
const id = attr(m[1], "id");
|
|
26672
|
-
const href =
|
|
26702
|
+
const href = _chunkDQJTNXVScjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
26673
26703
|
if (id && href) idToHref.set(id, href);
|
|
26674
26704
|
}
|
|
26675
26705
|
const ordered = [];
|
|
@@ -26678,7 +26708,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26678
26708
|
if (href) ordered.push(href);
|
|
26679
26709
|
}
|
|
26680
26710
|
if (ordered.length > 0) return ordered;
|
|
26681
|
-
return Array.from(idToHref.values()).sort(
|
|
26711
|
+
return Array.from(idToHref.values()).sort(_chunkDQJTNXVScjs.compareSectionPaths);
|
|
26682
26712
|
}
|
|
26683
26713
|
|
|
26684
26714
|
// src/roundtrip/patcher.ts
|
|
@@ -26789,9 +26819,9 @@ function buildOrigUnits(blocks) {
|
|
|
26789
26819
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
26790
26820
|
const next = blocks[i + 1];
|
|
26791
26821
|
if (_optionalChain([next, 'optionalAccess', _398 => _398.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
26792
|
-
chunk2 =
|
|
26822
|
+
chunk2 = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
26793
26823
|
} else {
|
|
26794
|
-
chunk2 =
|
|
26824
|
+
chunk2 = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, [block]);
|
|
26795
26825
|
}
|
|
26796
26826
|
if (chunk2) {
|
|
26797
26827
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
@@ -28630,13 +28660,13 @@ async function htmlToPdf(html, options) {
|
|
|
28630
28660
|
try {
|
|
28631
28661
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
28632
28662
|
} catch (e31) {
|
|
28633
|
-
throw new (0,
|
|
28663
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
28634
28664
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
28635
28665
|
);
|
|
28636
28666
|
}
|
|
28637
28667
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
28638
28668
|
if (!executablePath) {
|
|
28639
|
-
throw new (0,
|
|
28669
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)(
|
|
28640
28670
|
"Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
|
|
28641
28671
|
);
|
|
28642
28672
|
}
|
|
@@ -28695,7 +28725,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
28695
28725
|
return htmlToPdf(html, options);
|
|
28696
28726
|
}
|
|
28697
28727
|
async function blocksToPdf(blocks, options) {
|
|
28698
|
-
const markdown =
|
|
28728
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, blocks);
|
|
28699
28729
|
return markdownToPdf(markdown, options);
|
|
28700
28730
|
}
|
|
28701
28731
|
|
|
@@ -29581,15 +29611,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
29581
29611
|
async function renderHwpxToSvg(input, options) {
|
|
29582
29612
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
29583
29613
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
29584
|
-
|
|
29614
|
+
_chunkDQJTNXVScjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
29585
29615
|
let zip;
|
|
29586
29616
|
try {
|
|
29587
29617
|
zip = await _jszip2.default.loadAsync(input);
|
|
29588
29618
|
} catch (e32) {
|
|
29589
|
-
throw new (0,
|
|
29619
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
29590
29620
|
}
|
|
29591
29621
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
29592
|
-
if (secFiles.length === 0) throw new (0,
|
|
29622
|
+
if (secFiles.length === 0) throw new (0, _chunkDQJTNXVScjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
29593
29623
|
const warnings = [];
|
|
29594
29624
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
29595
29625
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -29597,7 +29627,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29597
29627
|
const secXmls = [];
|
|
29598
29628
|
for (const f of secFiles) {
|
|
29599
29629
|
const xml = await f.async("string");
|
|
29600
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
29630
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
29601
29631
|
secXmls.push(xml);
|
|
29602
29632
|
}
|
|
29603
29633
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -29669,9 +29699,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29669
29699
|
}
|
|
29670
29700
|
if (rendered.length === 0) {
|
|
29671
29701
|
if (noCacheSkipped) {
|
|
29672
|
-
throw new (0,
|
|
29702
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
|
|
29673
29703
|
}
|
|
29674
|
-
throw new (0,
|
|
29704
|
+
throw new (0, _chunkDQJTNXVScjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
29675
29705
|
}
|
|
29676
29706
|
const GAP = 2400;
|
|
29677
29707
|
const clipDefs = [];
|
|
@@ -29707,13 +29737,13 @@ async function parse(input, options) {
|
|
|
29707
29737
|
if (typeof input === "string") {
|
|
29708
29738
|
try {
|
|
29709
29739
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29710
|
-
buffer =
|
|
29740
|
+
buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, buf);
|
|
29711
29741
|
} catch (err) {
|
|
29712
29742
|
const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
|
|
29713
29743
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
29714
29744
|
}
|
|
29715
29745
|
} else if (Buffer.isBuffer(input)) {
|
|
29716
|
-
buffer =
|
|
29746
|
+
buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, input);
|
|
29717
29747
|
} else {
|
|
29718
29748
|
buffer = input;
|
|
29719
29749
|
}
|
|
@@ -29748,7 +29778,7 @@ async function parseHwp3(buffer, options) {
|
|
|
29748
29778
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
29749
29779
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
29750
29780
|
} catch (err) {
|
|
29751
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29781
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29752
29782
|
}
|
|
29753
29783
|
}
|
|
29754
29784
|
async function parseHwpx(buffer, options) {
|
|
@@ -29756,7 +29786,7 @@ async function parseHwpx(buffer, options) {
|
|
|
29756
29786
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
29757
29787
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _486 => _486.length]) ? images : void 0 };
|
|
29758
29788
|
} catch (err) {
|
|
29759
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29789
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29760
29790
|
}
|
|
29761
29791
|
}
|
|
29762
29792
|
async function parseHwp(buffer, options) {
|
|
@@ -29781,13 +29811,13 @@ async function parseHwp(buffer, options) {
|
|
|
29781
29811
|
}
|
|
29782
29812
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _488 => _488.length]) ? images : void 0 };
|
|
29783
29813
|
} catch (err) {
|
|
29784
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29814
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29785
29815
|
}
|
|
29786
29816
|
}
|
|
29787
29817
|
async function parsePdf(buffer, options) {
|
|
29788
29818
|
let parsePdfDocument;
|
|
29789
29819
|
try {
|
|
29790
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
29820
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-VEY4B5CJ.cjs")));
|
|
29791
29821
|
parsePdfDocument = mod.parsePdfDocument;
|
|
29792
29822
|
} catch (e34) {
|
|
29793
29823
|
return {
|
|
@@ -29802,7 +29832,7 @@ async function parsePdf(buffer, options) {
|
|
|
29802
29832
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
29803
29833
|
} catch (err) {
|
|
29804
29834
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
29805
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29835
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err), isImageBased };
|
|
29806
29836
|
}
|
|
29807
29837
|
}
|
|
29808
29838
|
async function parseXlsx(buffer, options) {
|
|
@@ -29810,7 +29840,7 @@ async function parseXlsx(buffer, options) {
|
|
|
29810
29840
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
29811
29841
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
29812
29842
|
} catch (err) {
|
|
29813
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29843
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29814
29844
|
}
|
|
29815
29845
|
}
|
|
29816
29846
|
async function parseXls(buffer, options) {
|
|
@@ -29818,7 +29848,7 @@ async function parseXls(buffer, options) {
|
|
|
29818
29848
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
29819
29849
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
29820
29850
|
} catch (err) {
|
|
29821
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29851
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29822
29852
|
}
|
|
29823
29853
|
}
|
|
29824
29854
|
async function parseDocx(buffer, options) {
|
|
@@ -29826,7 +29856,7 @@ async function parseDocx(buffer, options) {
|
|
|
29826
29856
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
29827
29857
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
|
|
29828
29858
|
} catch (err) {
|
|
29829
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29859
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29830
29860
|
}
|
|
29831
29861
|
}
|
|
29832
29862
|
async function parseHwpml(buffer, options) {
|
|
@@ -29834,16 +29864,16 @@ async function parseHwpml(buffer, options) {
|
|
|
29834
29864
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
29835
29865
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
29836
29866
|
} catch (err) {
|
|
29837
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29867
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDQJTNXVScjs.classifyError.call(void 0, err) };
|
|
29838
29868
|
}
|
|
29839
29869
|
}
|
|
29840
29870
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
29841
29871
|
let buffer;
|
|
29842
29872
|
if (typeof input === "string") {
|
|
29843
29873
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29844
|
-
buffer =
|
|
29874
|
+
buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, buf);
|
|
29845
29875
|
} else if (Buffer.isBuffer(input)) {
|
|
29846
|
-
buffer =
|
|
29876
|
+
buffer = _chunkDQJTNXVScjs.toArrayBuffer.call(void 0, input);
|
|
29847
29877
|
} else {
|
|
29848
29878
|
buffer = input;
|
|
29849
29879
|
}
|
|
@@ -29869,7 +29899,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29869
29899
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
29870
29900
|
}
|
|
29871
29901
|
const fill = fillFormFields(parsed.blocks, values);
|
|
29872
|
-
const markdown =
|
|
29902
|
+
const markdown = _chunkDQJTNXVScjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
29873
29903
|
if (outputFormat === "hwpx") {
|
|
29874
29904
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
29875
29905
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -29938,5 +29968,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29938
29968
|
|
|
29939
29969
|
|
|
29940
29970
|
|
|
29941
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
29971
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkDQJTNXVScjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkDQJTNXVScjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
29942
29972
|
//# sourceMappingURL=index.cjs.map
|