kordoc 4.0.6 → 4.0.7
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/LICENSE +21 -21
- package/dist/{-NDU7YGSS.js → -6HWEFXVV.js} +9 -9
- package/dist/{chunk-UVSOSFER.js → chunk-2SN3CKME.js} +2 -2
- package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
- package/dist/chunk-3TBUDJDE.js.map +1 -0
- package/dist/{chunk-HOGJ5ALY.js → chunk-5OKHAJ62.js} +2 -2
- package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
- package/dist/chunk-AIQ3ISQU.js.map +1 -0
- package/dist/{chunk-5SOZXPQY.js → chunk-BKWHX3RC.js} +3 -3
- package/dist/{chunk-5CJGKKMZ.js → chunk-CFQLK3LM.js} +1 -1
- package/dist/chunk-CFQLK3LM.js.map +1 -0
- package/dist/{chunk-L3I4TIRP.js → chunk-CNM75ZSX.js} +2 -2
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-63ASYC4N.js → chunk-NGSHDBQR.js} +3 -3
- package/dist/{chunk-KA4FEBS2.js → chunk-ONXVBURQ.js} +2 -2
- package/dist/{chunk-4C7SBZNW.js → chunk-Q7EN4EUJ.js} +2 -2
- package/dist/{chunk-HC2SEH6I.js → chunk-TJJTLM76.js} +166 -97
- package/dist/chunk-TJJTLM76.js.map +1 -0
- package/dist/{chunk-DQJTNXVS.cjs → chunk-U25XGCNH.cjs} +2 -2
- package/dist/chunk-U25XGCNH.cjs.map +1 -0
- package/dist/{chunk-DCZVOIEO.cjs → chunk-X34YWRL5.cjs} +1 -1
- package/dist/chunk-X34YWRL5.cjs.map +1 -0
- package/dist/cli.js +17 -17
- package/dist/{detect-PJZMUL2Z.js → detect-NTR2FUEG.js} +2 -2
- package/dist/{formula-JCNF43NE.js → formula-KOQV353G.js} +1 -1
- package/dist/formula-KOQV353G.js.map +1 -0
- package/dist/{formula-RXVSQPXI.js → formula-MEDGYQXS.js} +1 -1
- package/dist/formula-MEDGYQXS.js.map +1 -0
- package/dist/{formula-5NKVS2LR.cjs → formula-ZYUDQHD3.cjs} +1 -1
- package/dist/formula-ZYUDQHD3.cjs.map +1 -0
- package/dist/index.cjs +298 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +160 -91
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +13 -13
- package/dist/page-range-CIRRJPXJ.js +7 -0
- package/dist/page-range-OF5I4PQY.js +8 -0
- package/dist/page-range-TPIRSA3J.cjs +8 -0
- package/dist/page-range-TPIRSA3J.cjs.map +1 -0
- package/dist/{parser-C636QIOB.js → parser-5EHWYJMC.js} +24 -6
- package/dist/parser-5EHWYJMC.js.map +1 -0
- package/dist/{parser-VEY4B5CJ.cjs → parser-E6U5TNAU.cjs} +36 -18
- package/dist/parser-E6U5TNAU.cjs.map +1 -0
- package/dist/{parser-DMKHIV4E.js → parser-UGB3NIVH.js} +23 -5
- package/dist/parser-UGB3NIVH.js.map +1 -0
- package/dist/{profile-io-JYGCC6XQ.js → profile-io-CAKRPQRD.js} +3 -3
- package/dist/provider-5K7O3Z2O.cjs.map +1 -1
- package/dist/render-P6663O4I.js +10 -0
- package/dist/seal-7PPTXKKV.js +10 -0
- package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
- package/dist/setup-QSJ2INNS.js.map +1 -0
- package/dist/{watch-ZQUFJBFR.js → watch-RMX427YR.js} +9 -9
- package/package.json +1 -1
- package/dist/chunk-5CJGKKMZ.js.map +0 -1
- package/dist/chunk-DCZVOIEO.cjs.map +0 -1
- package/dist/chunk-DQJTNXVS.cjs.map +0 -1
- package/dist/chunk-GE43BE46.js.map +0 -1
- package/dist/chunk-HC2SEH6I.js.map +0 -1
- package/dist/chunk-MOL7MDBG.js.map +0 -1
- package/dist/formula-5NKVS2LR.cjs.map +0 -1
- package/dist/formula-JCNF43NE.js.map +0 -1
- package/dist/formula-RXVSQPXI.js.map +0 -1
- package/dist/page-range-737B4EZW.js +0 -8
- package/dist/page-range-LNMXJU6W.js +0 -7
- package/dist/page-range-P7SDW6LR.cjs +0 -8
- package/dist/page-range-P7SDW6LR.cjs.map +0 -1
- package/dist/parser-C636QIOB.js.map +0 -1
- package/dist/parser-DMKHIV4E.js.map +0 -1
- package/dist/parser-VEY4B5CJ.cjs.map +0 -1
- package/dist/render-ISOEOMTM.js +0 -10
- package/dist/seal-676ZIAZZ.js +0 -10
- package/dist/setup-57FB3LSP.js.map +0 -1
- /package/dist/{-NDU7YGSS.js.map → -6HWEFXVV.js.map} +0 -0
- /package/dist/{chunk-UVSOSFER.js.map → chunk-2SN3CKME.js.map} +0 -0
- /package/dist/{chunk-HOGJ5ALY.js.map → chunk-5OKHAJ62.js.map} +0 -0
- /package/dist/{chunk-5SOZXPQY.js.map → chunk-BKWHX3RC.js.map} +0 -0
- /package/dist/{chunk-L3I4TIRP.js.map → chunk-CNM75ZSX.js.map} +0 -0
- /package/dist/{chunk-63ASYC4N.js.map → chunk-NGSHDBQR.js.map} +0 -0
- /package/dist/{chunk-KA4FEBS2.js.map → chunk-ONXVBURQ.js.map} +0 -0
- /package/dist/{chunk-4C7SBZNW.js.map → chunk-Q7EN4EUJ.js.map} +0 -0
- /package/dist/{detect-PJZMUL2Z.js.map → detect-NTR2FUEG.js.map} +0 -0
- /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
- /package/dist/{page-range-LNMXJU6W.js.map → page-range-OF5I4PQY.js.map} +0 -0
- /package/dist/{profile-io-JYGCC6XQ.js.map → profile-io-CAKRPQRD.js.map} +0 -0
- /package/dist/{render-ISOEOMTM.js.map → render-P6663O4I.js.map} +0 -0
- /package/dist/{seal-676ZIAZZ.js.map → seal-7PPTXKKV.js.map} +0 -0
- /package/dist/{watch-ZQUFJBFR.js.map → watch-RMX427YR.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkU25XGCNHcjs = require('./chunk-U25XGCNH.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkX34YWRL5cjs = require('./chunk-X34YWRL5.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.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, _chunkU25XGCNHcjs.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, _chunkU25XGCNHcjs.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(_chunkU25XGCNHcjs.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 >= _chunkU25XGCNHcjs.HEADING_RATIO_H1) level = 1;
|
|
652
|
+
else if (ratio >= _chunkU25XGCNHcjs.HEADING_RATIO_H2) level = 2;
|
|
653
|
+
else if (ratio >= _chunkU25XGCNHcjs.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, _chunkU25XGCNHcjs.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, _chunkU25XGCNHcjs.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, _chunkU25XGCNHcjs.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, _chunkU25XGCNHcjs.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 = _chunkU25XGCNHcjs.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 = _chunkU25XGCNHcjs.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(_chunkU25XGCNHcjs.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, _chunkU25XGCNHcjs.MAX_COLS);
|
|
2057
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkU25XGCNHcjs.MAX_ROWS);
|
|
2058
2058
|
}
|
|
2059
2059
|
break;
|
|
2060
2060
|
case "p": {
|
|
@@ -2252,7 +2252,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2252
2252
|
const sink = [];
|
|
2253
2253
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2254
2254
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2255
|
-
let flat =
|
|
2255
|
+
let flat = _chunkU25XGCNHcjs.convertTableToText.call(void 0, st.rows);
|
|
2256
2256
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2257
2257
|
return flat;
|
|
2258
2258
|
}
|
|
@@ -2385,7 +2385,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2385
2385
|
let url = (ch.textContent || "").trim();
|
|
2386
2386
|
if (!url) continue;
|
|
2387
2387
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2388
|
-
const safe =
|
|
2388
|
+
const safe = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, url);
|
|
2389
2389
|
if (safe) return safe;
|
|
2390
2390
|
}
|
|
2391
2391
|
return void 0;
|
|
@@ -2523,7 +2523,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2523
2523
|
case "hyperlink": {
|
|
2524
2524
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2525
2525
|
if (url) {
|
|
2526
|
-
const safe =
|
|
2526
|
+
const safe = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, url);
|
|
2527
2527
|
if (safe) href = safe;
|
|
2528
2528
|
}
|
|
2529
2529
|
walk(child);
|
|
@@ -2795,13 +2795,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
2795
2795
|
}
|
|
2796
2796
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
2797
2797
|
for (const path of allCandidates) {
|
|
2798
|
-
if (
|
|
2798
|
+
if (_chunkU25XGCNHcjs.isPathTraversal.call(void 0, path)) continue;
|
|
2799
2799
|
const file = zip.file(path);
|
|
2800
2800
|
if (!file) continue;
|
|
2801
2801
|
try {
|
|
2802
2802
|
const data = await file.async("uint8array");
|
|
2803
2803
|
decompressed.total += data.length;
|
|
2804
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2804
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2805
2805
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
2806
2806
|
const mimeType = imageExtToMime(ext);
|
|
2807
2807
|
imageIndex++;
|
|
@@ -2810,7 +2810,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
2810
2810
|
images.push(img);
|
|
2811
2811
|
break;
|
|
2812
2812
|
} catch (err) {
|
|
2813
|
-
if (err instanceof
|
|
2813
|
+
if (err instanceof _chunkU25XGCNHcjs.KordocError) throw err;
|
|
2814
2814
|
}
|
|
2815
2815
|
}
|
|
2816
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" })]);
|
|
@@ -2872,7 +2872,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
2872
2872
|
}
|
|
2873
2873
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
2874
2874
|
const name = new TextDecoder().decode(nameBytes);
|
|
2875
|
-
if (
|
|
2875
|
+
if (_chunkU25XGCNHcjs.isPathTraversal.call(void 0, name)) {
|
|
2876
2876
|
pos = fileStart + compSize;
|
|
2877
2877
|
continue;
|
|
2878
2878
|
}
|
|
@@ -2890,16 +2890,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2890
2890
|
continue;
|
|
2891
2891
|
}
|
|
2892
2892
|
totalDecompressed += content.length * 2;
|
|
2893
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2893
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2894
2894
|
sectionNum++;
|
|
2895
2895
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2896
2896
|
} catch (e13) {
|
|
2897
2897
|
continue;
|
|
2898
2898
|
}
|
|
2899
2899
|
}
|
|
2900
|
-
if (blocks.length === 0) throw new (0,
|
|
2900
|
+
if (blocks.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2901
2901
|
applyPageText(blocks, shared);
|
|
2902
|
-
const markdown =
|
|
2902
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2903
2903
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2904
2904
|
}
|
|
2905
2905
|
async function readKordocLayout(zip) {
|
|
@@ -2924,18 +2924,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2924
2924
|
if (paths.length > 0) return paths;
|
|
2925
2925
|
}
|
|
2926
2926
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2927
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2927
|
+
return sectionFiles.map((f) => f.name).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
2928
2928
|
}
|
|
2929
2929
|
function parseSectionPathsFromManifest(xml) {
|
|
2930
2930
|
const parser = createXmlParser();
|
|
2931
|
-
const doc = parser.parseFromString(
|
|
2931
|
+
const doc = parser.parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2932
2932
|
const items = doc.getElementsByTagName("opf:item");
|
|
2933
2933
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2934
2934
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2935
2935
|
for (let i = 0; i < items.length; i++) {
|
|
2936
2936
|
const item = items[i];
|
|
2937
2937
|
const id = item.getAttribute("id") || "";
|
|
2938
|
-
const href =
|
|
2938
|
+
const href = _chunkU25XGCNHcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2939
2939
|
if (id && href) idToHref.set(id, href);
|
|
2940
2940
|
}
|
|
2941
2941
|
if (spine.length > 0) {
|
|
@@ -2946,7 +2946,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2946
2946
|
}
|
|
2947
2947
|
if (ordered.length > 0) return ordered;
|
|
2948
2948
|
}
|
|
2949
|
-
return Array.from(idToHref.values()).sort(
|
|
2949
|
+
return Array.from(idToHref.values()).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
2950
2950
|
}
|
|
2951
2951
|
|
|
2952
2952
|
// src/hwpx/metadata.ts
|
|
@@ -2959,7 +2959,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2959
2959
|
const xml = await file.async("text");
|
|
2960
2960
|
if (decompressed) {
|
|
2961
2961
|
decompressed.total += xml.length * 2;
|
|
2962
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2962
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2963
2963
|
}
|
|
2964
2964
|
parseDublinCoreMetadata(xml, metadata);
|
|
2965
2965
|
if (metadata.title || metadata.author) return;
|
|
@@ -2969,7 +2969,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2969
2969
|
}
|
|
2970
2970
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2971
2971
|
const parser = createXmlParser();
|
|
2972
|
-
const doc = parser.parseFromString(
|
|
2972
|
+
const doc = parser.parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2973
2973
|
if (!doc.documentElement) return;
|
|
2974
2974
|
const getText = (tagNames) => {
|
|
2975
2975
|
for (const tag of tagNames) {
|
|
@@ -2994,7 +2994,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2994
2994
|
|
|
2995
2995
|
// src/hwpx/parser.ts
|
|
2996
2996
|
async function parseHwpxDocument(buffer, options) {
|
|
2997
|
-
|
|
2997
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2998
2998
|
let zip;
|
|
2999
2999
|
try {
|
|
3000
3000
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3003,7 +3003,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3003
3003
|
}
|
|
3004
3004
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3005
3005
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3006
|
-
throw new (0,
|
|
3006
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3007
3007
|
}
|
|
3008
3008
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3009
3009
|
if (manifestFile) {
|
|
@@ -3015,7 +3015,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3015
3015
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3016
3016
|
}
|
|
3017
3017
|
}
|
|
3018
|
-
throw new (0,
|
|
3018
|
+
throw new (0, _chunkU25XGCNHcjs.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.");
|
|
3019
3019
|
}
|
|
3020
3020
|
}
|
|
3021
3021
|
const decompressed = { total: 0 };
|
|
@@ -3024,9 +3024,9 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3024
3024
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3025
3025
|
const warnings = [];
|
|
3026
3026
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3027
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3027
|
+
if (sectionPaths.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3028
3028
|
metadata.pageCount = sectionPaths.length;
|
|
3029
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _77 => _77.pages]) ?
|
|
3029
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _77 => _77.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3030
3030
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3031
3031
|
const blocks = [];
|
|
3032
3032
|
const shared = createSectionShared();
|
|
@@ -3039,12 +3039,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3039
3039
|
try {
|
|
3040
3040
|
const xml = await file.async("text");
|
|
3041
3041
|
decompressed.total += xml.length * 2;
|
|
3042
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3042
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3043
3043
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3044
3044
|
parsedSections++;
|
|
3045
3045
|
_optionalChain([options, 'optionalAccess', _78 => _78.onProgress, 'optionalCall', _79 => _79(parsedSections, totalTarget)]);
|
|
3046
3046
|
} catch (secErr) {
|
|
3047
|
-
if (secErr instanceof
|
|
3047
|
+
if (secErr instanceof _chunkU25XGCNHcjs.KordocError) throw secErr;
|
|
3048
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" });
|
|
3049
3049
|
}
|
|
3050
3050
|
}
|
|
@@ -3052,7 +3052,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3052
3052
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
3053
3053
|
detectHwpxHeadings(blocks, styleMap);
|
|
3054
3054
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3055
|
-
const markdown =
|
|
3055
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3056
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 };
|
|
3057
3057
|
}
|
|
3058
3058
|
|
|
@@ -3119,7 +3119,7 @@ function decompressStream(data) {
|
|
|
3119
3119
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
3120
3120
|
}
|
|
3121
3121
|
function parseFileHeader(data) {
|
|
3122
|
-
if (data.length < 40) throw new (0,
|
|
3122
|
+
if (data.length < 40) throw new (0, _chunkU25XGCNHcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
3123
3123
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
3124
3124
|
return {
|
|
3125
3125
|
signature: sig,
|
|
@@ -4789,7 +4789,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4789
4789
|
lenientCfb = parseLenientCfb(buffer);
|
|
4790
4790
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4791
4791
|
} catch (e22) {
|
|
4792
|
-
throw new (0,
|
|
4792
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4793
4793
|
}
|
|
4794
4794
|
}
|
|
4795
4795
|
const findStream = (path) => {
|
|
@@ -4800,11 +4800,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4800
4800
|
return lenientCfb.findStream(path);
|
|
4801
4801
|
};
|
|
4802
4802
|
const headerData = findStream("/FileHeader");
|
|
4803
|
-
if (!headerData) throw new (0,
|
|
4803
|
+
if (!headerData) throw new (0, _chunkU25XGCNHcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4804
4804
|
const header = parseFileHeader(headerData);
|
|
4805
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4806
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4807
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4805
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkU25XGCNHcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4806
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4807
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkU25XGCNHcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4808
4808
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4809
4809
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4810
4810
|
const metadata = {
|
|
@@ -4813,9 +4813,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
4813
4813
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4814
4814
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4815
4815
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4816
|
-
if (sections.length === 0) throw new (0,
|
|
4816
|
+
if (sections.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4817
4817
|
metadata.pageCount = sections.length;
|
|
4818
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _84 => _84.pages]) ?
|
|
4818
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _84 => _84.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4819
4819
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4820
4820
|
const bodyBlocks = [];
|
|
4821
4821
|
const doc = createHwp5DocState();
|
|
@@ -4827,22 +4827,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4827
4827
|
const sectionData = sections[si];
|
|
4828
4828
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4829
4829
|
totalDecompressed += data.length;
|
|
4830
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4830
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4831
4831
|
const records = readRecords(data);
|
|
4832
4832
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4833
4833
|
bodyBlocks.push(...sectionBlocks);
|
|
4834
4834
|
parsedSections++;
|
|
4835
4835
|
_optionalChain([options, 'optionalAccess', _85 => _85.onProgress, 'optionalCall', _86 => _86(parsedSections, totalTarget)]);
|
|
4836
4836
|
} catch (secErr) {
|
|
4837
|
-
if (secErr instanceof
|
|
4837
|
+
if (secErr instanceof _chunkU25XGCNHcjs.KordocError) throw secErr;
|
|
4838
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" });
|
|
4839
4839
|
}
|
|
4840
4840
|
}
|
|
4841
4841
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4842
4842
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
4843
|
-
let flatBlocks =
|
|
4843
|
+
let flatBlocks = _chunkU25XGCNHcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4844
4844
|
if (_optionalChain([options, 'optionalAccess', _87 => _87.dedupeRunningHeaders])) {
|
|
4845
|
-
const deduped =
|
|
4845
|
+
const deduped = _chunkU25XGCNHcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4846
4846
|
const removed = flatBlocks.length - deduped.length;
|
|
4847
4847
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4848
4848
|
flatBlocks = deduped;
|
|
@@ -4851,7 +4851,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4851
4851
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4852
4852
|
}
|
|
4853
4853
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4854
|
-
let markdown =
|
|
4854
|
+
let markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4855
4855
|
if (_optionalChain([options, 'optionalAccess', _88 => _88.inlineImages]) && images.length > 0) {
|
|
4856
4856
|
try {
|
|
4857
4857
|
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
@@ -4918,9 +4918,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4918
4918
|
let level = 0;
|
|
4919
4919
|
if (_optionalChain([block, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]) && baseFontSize > 0) {
|
|
4920
4920
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4921
|
-
if (ratio >=
|
|
4922
|
-
else if (ratio >=
|
|
4923
|
-
else if (ratio >=
|
|
4921
|
+
if (ratio >= _chunkU25XGCNHcjs.HEADING_RATIO_H1) level = 1;
|
|
4922
|
+
else if (ratio >= _chunkU25XGCNHcjs.HEADING_RATIO_H2) level = 2;
|
|
4923
|
+
else if (ratio >= _chunkU25XGCNHcjs.HEADING_RATIO_H3) level = 3;
|
|
4924
4924
|
}
|
|
4925
4925
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4926
4926
|
if (level === 0) level = 2;
|
|
@@ -5005,7 +5005,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5005
5005
|
if (!raw) break;
|
|
5006
5006
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5007
5007
|
totalDecompressed += content.length;
|
|
5008
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5008
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5009
5009
|
sections.push({ idx: i, content });
|
|
5010
5010
|
}
|
|
5011
5011
|
if (sections.length === 0) {
|
|
@@ -5017,7 +5017,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5017
5017
|
if (raw) {
|
|
5018
5018
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5019
5019
|
totalDecompressed += content.length;
|
|
5020
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5020
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5021
5021
|
sections.push({ idx, content });
|
|
5022
5022
|
}
|
|
5023
5023
|
}
|
|
@@ -5034,7 +5034,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5034
5034
|
try {
|
|
5035
5035
|
const content = decryptViewText(raw, compressed);
|
|
5036
5036
|
totalDecompressed += content.length;
|
|
5037
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5037
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5038
5038
|
sections.push({ idx: i, content });
|
|
5039
5039
|
} catch (e27) {
|
|
5040
5040
|
break;
|
|
@@ -5137,7 +5137,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5137
5137
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5138
5138
|
if (!_optionalChain([ctrl, 'optionalAccess', _101 => _101.href]) || r.end <= r.start) continue;
|
|
5139
5139
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5140
|
-
const href =
|
|
5140
|
+
const href = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5141
5141
|
if (!href) continue;
|
|
5142
5142
|
const anchor = text.slice(r.start, r.end);
|
|
5143
5143
|
if (!anchor.trim()) continue;
|
|
@@ -5370,8 +5370,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5370
5370
|
let tableIdx = -1;
|
|
5371
5371
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5372
5372
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5373
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5374
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5373
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkU25XGCNHcjs.MAX_ROWS);
|
|
5374
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkU25XGCNHcjs.MAX_COLS);
|
|
5375
5375
|
tableIdx = i2;
|
|
5376
5376
|
break;
|
|
5377
5377
|
}
|
|
@@ -5420,7 +5420,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5420
5420
|
return table3;
|
|
5421
5421
|
}
|
|
5422
5422
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5423
|
-
const table2 =
|
|
5423
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
5424
5424
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5425
5425
|
return table2.rows > 0 ? table2 : null;
|
|
5426
5426
|
}
|
|
@@ -5437,8 +5437,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5437
5437
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5438
5438
|
const cs = rec.data.readUInt16LE(12);
|
|
5439
5439
|
const rs = rec.data.readUInt16LE(14);
|
|
5440
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5441
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5440
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkU25XGCNHcjs.MAX_COLS);
|
|
5441
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkU25XGCNHcjs.MAX_ROWS);
|
|
5442
5442
|
}
|
|
5443
5443
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5444
5444
|
const parts = [];
|
|
@@ -5448,7 +5448,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5448
5448
|
parts.push(``);
|
|
5449
5449
|
hasStructure = true;
|
|
5450
5450
|
} else if (b.type === "table" && b.table) {
|
|
5451
|
-
const flat =
|
|
5451
|
+
const flat = _chunkU25XGCNHcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5452
5452
|
if (flat) parts.push(flat);
|
|
5453
5453
|
hasStructure = true;
|
|
5454
5454
|
} else if (b.text) {
|
|
@@ -17885,7 +17885,7 @@ function getTextContent(el) {
|
|
|
17885
17885
|
return _nullishCoalesce(_optionalChain([el, 'access', _116 => _116.textContent, 'optionalAccess', _117 => _117.trim, 'call', _118 => _118()]), () => ( ""));
|
|
17886
17886
|
}
|
|
17887
17887
|
function parseXml(text) {
|
|
17888
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17888
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17889
17889
|
}
|
|
17890
17890
|
function parseSharedStrings(xml) {
|
|
17891
17891
|
const doc = parseXml(xml);
|
|
@@ -18029,7 +18029,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
18029
18029
|
cellRows.push(row);
|
|
18030
18030
|
}
|
|
18031
18031
|
if (cellRows.length > 0) {
|
|
18032
|
-
const table2 =
|
|
18032
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
18033
18033
|
if (table2.rows > 0) {
|
|
18034
18034
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18035
18035
|
}
|
|
@@ -18037,12 +18037,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
18037
18037
|
return blocks;
|
|
18038
18038
|
}
|
|
18039
18039
|
async function parseXlsxDocument(buffer, options) {
|
|
18040
|
-
|
|
18040
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
18041
18041
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18042
18042
|
const warnings = [];
|
|
18043
18043
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18044
18044
|
if (!workbookFile) {
|
|
18045
|
-
throw new (0,
|
|
18045
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18046
18046
|
}
|
|
18047
18047
|
let sharedStrings = [];
|
|
18048
18048
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18051,7 +18051,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18051
18051
|
}
|
|
18052
18052
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
18053
18053
|
if (sheets.length === 0) {
|
|
18054
|
-
throw new (0,
|
|
18054
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18055
18055
|
}
|
|
18056
18056
|
let relsMap = /* @__PURE__ */ new Map();
|
|
18057
18057
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -18060,7 +18060,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18060
18060
|
}
|
|
18061
18061
|
let pageFilter = null;
|
|
18062
18062
|
if (_optionalChain([options, 'optionalAccess', _121 => _121.pages])) {
|
|
18063
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
18063
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-TPIRSA3J.cjs")));
|
|
18064
18064
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18065
18065
|
}
|
|
18066
18066
|
const blocks = [];
|
|
@@ -18123,7 +18123,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18123
18123
|
} catch (e28) {
|
|
18124
18124
|
}
|
|
18125
18125
|
}
|
|
18126
|
-
const markdown =
|
|
18126
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18127
18127
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18128
18128
|
}
|
|
18129
18129
|
|
|
@@ -18530,11 +18530,11 @@ function processGlobals(records) {
|
|
|
18530
18530
|
let encrypted = false;
|
|
18531
18531
|
const firstBof = records[0];
|
|
18532
18532
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18533
|
-
throw new (0,
|
|
18533
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18534
18534
|
}
|
|
18535
18535
|
const bof = decodeBof(firstBof.data);
|
|
18536
18536
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18537
|
-
throw new (0,
|
|
18537
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18538
18538
|
}
|
|
18539
18539
|
let i = 1;
|
|
18540
18540
|
while (i < records.length) {
|
|
@@ -18649,7 +18649,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
18649
18649
|
cellRows.push(row);
|
|
18650
18650
|
}
|
|
18651
18651
|
if (cellRows.length > 0) {
|
|
18652
|
-
const table2 =
|
|
18652
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
18653
18653
|
if (table2.rows > 0) {
|
|
18654
18654
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18655
18655
|
}
|
|
@@ -18662,21 +18662,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18662
18662
|
try {
|
|
18663
18663
|
cfb = parseLenientCfb(buf);
|
|
18664
18664
|
} catch (e) {
|
|
18665
|
-
throw new (0,
|
|
18665
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
18666
18666
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18667
18667
|
);
|
|
18668
18668
|
}
|
|
18669
18669
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18670
18670
|
if (!wb) {
|
|
18671
|
-
throw new (0,
|
|
18671
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18672
18672
|
}
|
|
18673
18673
|
const records = readRecords2(wb);
|
|
18674
18674
|
if (records.length === 0) {
|
|
18675
|
-
throw new (0,
|
|
18675
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18676
18676
|
}
|
|
18677
18677
|
const firstBof = decodeBof(records[0].data);
|
|
18678
18678
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18679
|
-
throw new (0,
|
|
18679
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
18680
18680
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18681
18681
|
);
|
|
18682
18682
|
}
|
|
@@ -18698,7 +18698,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18698
18698
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18699
18699
|
let pageFilter = null;
|
|
18700
18700
|
if (_optionalChain([options, 'optionalAccess', _126 => _126.pages])) {
|
|
18701
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
18701
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-TPIRSA3J.cjs")));
|
|
18702
18702
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18703
18703
|
}
|
|
18704
18704
|
const allBlocks = [];
|
|
@@ -18736,7 +18736,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18736
18736
|
pageCount: totalSheets
|
|
18737
18737
|
};
|
|
18738
18738
|
return {
|
|
18739
|
-
markdown:
|
|
18739
|
+
markdown: _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18740
18740
|
blocks: allBlocks,
|
|
18741
18741
|
metadata,
|
|
18742
18742
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19174,7 +19174,7 @@ function getAttr(el, localName2) {
|
|
|
19174
19174
|
return null;
|
|
19175
19175
|
}
|
|
19176
19176
|
function parseXml2(text) {
|
|
19177
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19177
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19178
19178
|
}
|
|
19179
19179
|
function parseStyles(xml) {
|
|
19180
19180
|
const doc = parseXml2(xml);
|
|
@@ -19300,6 +19300,102 @@ function extractRun(r) {
|
|
|
19300
19300
|
}
|
|
19301
19301
|
return { text, bold, italic };
|
|
19302
19302
|
}
|
|
19303
|
+
function fieldUrlFromInstr(instr) {
|
|
19304
|
+
if (!/HYPERLINK\b/i.test(instr)) return null;
|
|
19305
|
+
const urlM = instr.match(/HYPERLINK\s+"([^"]*)"/i);
|
|
19306
|
+
const anchorM = instr.match(/\\l\s+"([^"]*)"/i);
|
|
19307
|
+
if (urlM && urlM[1]) {
|
|
19308
|
+
return anchorM && anchorM[1] ? `${urlM[1]}#${anchorM[1]}` : urlM[1];
|
|
19309
|
+
}
|
|
19310
|
+
if (anchorM && anchorM[1]) return `#${anchorM[1]}`;
|
|
19311
|
+
return null;
|
|
19312
|
+
}
|
|
19313
|
+
function makeLink(text, rawHref) {
|
|
19314
|
+
if (!text) return "";
|
|
19315
|
+
if (!rawHref) return text;
|
|
19316
|
+
const href = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, rawHref);
|
|
19317
|
+
return href ? `[${text}](${href})` : text;
|
|
19318
|
+
}
|
|
19319
|
+
function collectInline(p, footnotes, rels) {
|
|
19320
|
+
const parts = [];
|
|
19321
|
+
let bold = false;
|
|
19322
|
+
let italic = false;
|
|
19323
|
+
let footnoteText;
|
|
19324
|
+
let fieldActive = false;
|
|
19325
|
+
let fieldStage = "instr";
|
|
19326
|
+
let fieldInstr = "";
|
|
19327
|
+
let fieldDisplay = "";
|
|
19328
|
+
const flushField = () => {
|
|
19329
|
+
if (!fieldActive) return;
|
|
19330
|
+
if (fieldDisplay) {
|
|
19331
|
+
const url = fieldUrlFromInstr(fieldInstr);
|
|
19332
|
+
parts.push(url ? makeLink(fieldDisplay, url) : fieldDisplay);
|
|
19333
|
+
}
|
|
19334
|
+
fieldActive = false;
|
|
19335
|
+
fieldStage = "instr";
|
|
19336
|
+
fieldInstr = "";
|
|
19337
|
+
fieldDisplay = "";
|
|
19338
|
+
};
|
|
19339
|
+
for (const el of effectiveChildElements(p)) {
|
|
19340
|
+
if (matchesLocal(el, "hyperlink")) {
|
|
19341
|
+
const rId = getAttr(el, "id");
|
|
19342
|
+
const anchor = getAttr(el, "anchor");
|
|
19343
|
+
const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
|
|
19344
|
+
if (!t) continue;
|
|
19345
|
+
let raw = null;
|
|
19346
|
+
if (rId && rels.has(rId)) raw = rels.get(rId);
|
|
19347
|
+
else if (anchor) raw = `#${anchor}`;
|
|
19348
|
+
if (fieldActive && fieldStage === "display") fieldDisplay += t;
|
|
19349
|
+
else parts.push(makeLink(t, raw));
|
|
19350
|
+
continue;
|
|
19351
|
+
}
|
|
19352
|
+
if (matchesLocal(el, "fldSimple")) {
|
|
19353
|
+
const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
|
|
19354
|
+
if (!t) continue;
|
|
19355
|
+
const url = fieldUrlFromInstr(_nullishCoalesce(getAttr(el, "instr"), () => ( "")));
|
|
19356
|
+
parts.push(url ? makeLink(t, url) : t);
|
|
19357
|
+
continue;
|
|
19358
|
+
}
|
|
19359
|
+
if (matchesLocal(el, "r")) {
|
|
19360
|
+
for (const fc of getChildElements(el, "fldChar")) {
|
|
19361
|
+
const ty = getAttr(fc, "fldCharType");
|
|
19362
|
+
if (ty === "begin") {
|
|
19363
|
+
flushField();
|
|
19364
|
+
fieldActive = true;
|
|
19365
|
+
fieldStage = "instr";
|
|
19366
|
+
} else if (ty === "separate") {
|
|
19367
|
+
if (fieldActive) fieldStage = "display";
|
|
19368
|
+
} else if (ty === "end") flushField();
|
|
19369
|
+
}
|
|
19370
|
+
if (fieldActive && fieldStage === "instr") {
|
|
19371
|
+
for (const it of getChildElements(el, "instrText")) fieldInstr += _nullishCoalesce(it.textContent, () => ( ""));
|
|
19372
|
+
}
|
|
19373
|
+
const rr = extractRun(el);
|
|
19374
|
+
if (rr.bold) bold = true;
|
|
19375
|
+
if (rr.italic) italic = true;
|
|
19376
|
+
const fnRefEls = getChildElements(el, "footnoteReference");
|
|
19377
|
+
if (fnRefEls.length > 0) {
|
|
19378
|
+
const fnId = getAttr(fnRefEls[0], "id");
|
|
19379
|
+
if (fnId && footnotes.has(fnId)) footnoteText = footnotes.get(fnId);
|
|
19380
|
+
}
|
|
19381
|
+
if (rr.text) {
|
|
19382
|
+
if (fieldActive && fieldStage === "display") fieldDisplay += rr.text;
|
|
19383
|
+
else if (fieldActive && fieldStage === "instr") {
|
|
19384
|
+
} else parts.push(rr.text);
|
|
19385
|
+
}
|
|
19386
|
+
continue;
|
|
19387
|
+
}
|
|
19388
|
+
}
|
|
19389
|
+
flushField();
|
|
19390
|
+
for (const om of collectOmmlRoots(p)) {
|
|
19391
|
+
const latex = ommlElementToLatex(om);
|
|
19392
|
+
if (!latex) continue;
|
|
19393
|
+
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
19394
|
+
else parts.push(" $" + latex + "$ ");
|
|
19395
|
+
}
|
|
19396
|
+
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
19397
|
+
return { text, bold, italic, footnoteText };
|
|
19398
|
+
}
|
|
19303
19399
|
function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
19304
19400
|
const pPrEls = getChildElements(p, "pPr");
|
|
19305
19401
|
let styleId = "";
|
|
@@ -19316,54 +19412,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19316
19412
|
ilvl = ilvlEls.length > 0 ? parseInt(_nullishCoalesce(getAttr(ilvlEls[0], "val"), () => ( "0")), 10) : 0;
|
|
19317
19413
|
}
|
|
19318
19414
|
}
|
|
19319
|
-
const
|
|
19320
|
-
let hasBold = false;
|
|
19321
|
-
let hasItalic = false;
|
|
19322
|
-
let href;
|
|
19323
|
-
let footnoteText;
|
|
19324
|
-
const hyperlinks = getChildElements(p, "hyperlink");
|
|
19325
|
-
const hyperlinkTexts = /* @__PURE__ */ new Set();
|
|
19326
|
-
for (const hl of hyperlinks) {
|
|
19327
|
-
const rId = getAttr(hl, "id");
|
|
19328
|
-
const hlText = [];
|
|
19329
|
-
const runs2 = findElements(hl, "r");
|
|
19330
|
-
for (const r of runs2) {
|
|
19331
|
-
const result = extractRun(r);
|
|
19332
|
-
hlText.push(result.text);
|
|
19333
|
-
}
|
|
19334
|
-
const text2 = hlText.join("");
|
|
19335
|
-
if (text2) {
|
|
19336
|
-
hyperlinkTexts.add(text2);
|
|
19337
|
-
if (rId && rels.has(rId)) {
|
|
19338
|
-
href = rels.get(rId);
|
|
19339
|
-
parts.push(text2);
|
|
19340
|
-
} else {
|
|
19341
|
-
parts.push(text2);
|
|
19342
|
-
}
|
|
19343
|
-
}
|
|
19344
|
-
}
|
|
19345
|
-
const runs = getChildElements(p, "r");
|
|
19346
|
-
for (const r of runs) {
|
|
19347
|
-
if (r.parentNode && r.parentNode.localName === "hyperlink") continue;
|
|
19348
|
-
const result = extractRun(r);
|
|
19349
|
-
if (result.bold) hasBold = true;
|
|
19350
|
-
if (result.italic) hasItalic = true;
|
|
19351
|
-
const fnRefEls = getChildElements(r, "footnoteReference");
|
|
19352
|
-
if (fnRefEls.length > 0) {
|
|
19353
|
-
const fnId = getAttr(fnRefEls[0], "id");
|
|
19354
|
-
if (fnId && footnotes.has(fnId)) {
|
|
19355
|
-
footnoteText = footnotes.get(fnId);
|
|
19356
|
-
}
|
|
19357
|
-
}
|
|
19358
|
-
if (result.text) parts.push(result.text);
|
|
19359
|
-
}
|
|
19360
|
-
for (const om of collectOmmlRoots(p)) {
|
|
19361
|
-
const latex = ommlElementToLatex(om);
|
|
19362
|
-
if (!latex) continue;
|
|
19363
|
-
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
19364
|
-
else parts.push(" $" + latex + "$ ");
|
|
19365
|
-
}
|
|
19366
|
-
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
19415
|
+
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19367
19416
|
if (!text) return null;
|
|
19368
19417
|
const style = styles.get(styleId);
|
|
19369
19418
|
if (_optionalChain([style, 'optionalAccess', _141 => _141.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
@@ -19383,7 +19432,6 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19383
19432
|
if (hasBold || hasItalic) {
|
|
19384
19433
|
block.style = { bold: hasBold || void 0, italic: hasItalic || void 0 };
|
|
19385
19434
|
}
|
|
19386
|
-
if (href) block.href = href;
|
|
19387
19435
|
if (footnoteText) block.footnoteText = footnoteText;
|
|
19388
19436
|
return block;
|
|
19389
19437
|
}
|
|
@@ -19459,7 +19507,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19459
19507
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19460
19508
|
})
|
|
19461
19509
|
);
|
|
19462
|
-
const table2 =
|
|
19510
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
19463
19511
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19464
19512
|
return { type: "table", table: table2 };
|
|
19465
19513
|
}
|
|
@@ -19484,54 +19532,69 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19484
19532
|
}
|
|
19485
19533
|
return parts;
|
|
19486
19534
|
}
|
|
19487
|
-
async function
|
|
19488
|
-
const
|
|
19535
|
+
async function buildImageMap(zip, rels, doc, warnings) {
|
|
19536
|
+
const imageMap = /* @__PURE__ */ new Map();
|
|
19489
19537
|
const images = [];
|
|
19490
|
-
const drawingElements = findElements(doc.documentElement, "drawing");
|
|
19491
19538
|
let imgIdx = 0;
|
|
19492
|
-
for (const
|
|
19493
|
-
const
|
|
19494
|
-
|
|
19495
|
-
|
|
19496
|
-
|
|
19497
|
-
|
|
19498
|
-
|
|
19499
|
-
|
|
19500
|
-
|
|
19501
|
-
|
|
19502
|
-
|
|
19503
|
-
|
|
19504
|
-
|
|
19505
|
-
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
|
|
19509
|
-
|
|
19510
|
-
|
|
19511
|
-
|
|
19512
|
-
|
|
19513
|
-
|
|
19514
|
-
|
|
19515
|
-
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
|
|
19520
|
-
|
|
19521
|
-
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19522
|
-
});
|
|
19523
|
-
}
|
|
19539
|
+
for (const blip of findElements(doc.documentElement, "blip")) {
|
|
19540
|
+
const embedId = getAttr(blip, "embed");
|
|
19541
|
+
if (!embedId || imageMap.has(embedId)) continue;
|
|
19542
|
+
const target = rels.get(embedId);
|
|
19543
|
+
if (!target) continue;
|
|
19544
|
+
const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
|
|
19545
|
+
const imgFile = zip.file(imgPath);
|
|
19546
|
+
if (!imgFile) continue;
|
|
19547
|
+
try {
|
|
19548
|
+
const data = await imgFile.async("uint8array");
|
|
19549
|
+
imgIdx++;
|
|
19550
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _147 => _147.split, 'call', _148 => _148("."), 'access', _149 => _149.pop, 'call', _150 => _150(), 'optionalAccess', _151 => _151.toLowerCase, 'call', _152 => _152()]), () => ( "png"));
|
|
19551
|
+
const mimeMap = {
|
|
19552
|
+
png: "image/png",
|
|
19553
|
+
jpg: "image/jpeg",
|
|
19554
|
+
jpeg: "image/jpeg",
|
|
19555
|
+
gif: "image/gif",
|
|
19556
|
+
bmp: "image/bmp",
|
|
19557
|
+
wmf: "image/wmf",
|
|
19558
|
+
emf: "image/emf"
|
|
19559
|
+
};
|
|
19560
|
+
const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
|
|
19561
|
+
images.push({ filename, data, mimeType: _nullishCoalesce(mimeMap[ext], () => ( "image/png")) });
|
|
19562
|
+
imageMap.set(embedId, filename);
|
|
19563
|
+
} catch (err) {
|
|
19564
|
+
warnings.push({
|
|
19565
|
+
code: "SKIPPED_IMAGE",
|
|
19566
|
+
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19567
|
+
});
|
|
19524
19568
|
}
|
|
19525
19569
|
}
|
|
19526
|
-
return {
|
|
19570
|
+
return { imageMap, images };
|
|
19571
|
+
}
|
|
19572
|
+
function collectParagraphBlips(node, out = [], depth = 0) {
|
|
19573
|
+
if (depth > 40) return out;
|
|
19574
|
+
for (const el of effectiveChildElements(node)) {
|
|
19575
|
+
if (matchesLocal(el, "txbxContent") || matchesLocal(el, "Fallback")) continue;
|
|
19576
|
+
if (matchesLocal(el, "blip")) out.push(el);
|
|
19577
|
+
else collectParagraphBlips(el, out, depth + 1);
|
|
19578
|
+
}
|
|
19579
|
+
return out;
|
|
19580
|
+
}
|
|
19581
|
+
function emitParagraphImages(p, imageMap, linked, out) {
|
|
19582
|
+
for (const blip of collectParagraphBlips(p)) {
|
|
19583
|
+
const embedId = getAttr(blip, "embed");
|
|
19584
|
+
if (!embedId) continue;
|
|
19585
|
+
const filename = imageMap.get(embedId);
|
|
19586
|
+
if (!filename) continue;
|
|
19587
|
+
linked.add(embedId);
|
|
19588
|
+
out.push({ type: "image", text: filename });
|
|
19589
|
+
}
|
|
19527
19590
|
}
|
|
19528
19591
|
async function parseDocxDocument(buffer, options) {
|
|
19529
|
-
|
|
19592
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
19530
19593
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19531
19594
|
const warnings = [];
|
|
19532
19595
|
const docFile = zip.file("word/document.xml");
|
|
19533
19596
|
if (!docFile) {
|
|
19534
|
-
throw new (0,
|
|
19597
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19535
19598
|
}
|
|
19536
19599
|
let rels = /* @__PURE__ */ new Map();
|
|
19537
19600
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19578,8 +19641,10 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19578
19641
|
const doc = parseXml2(docXml);
|
|
19579
19642
|
const body = findElements(doc, "body");
|
|
19580
19643
|
if (body.length === 0) {
|
|
19581
|
-
throw new (0,
|
|
19644
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19582
19645
|
}
|
|
19646
|
+
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19647
|
+
const linkedImages = /* @__PURE__ */ new Set();
|
|
19583
19648
|
const blocks = [];
|
|
19584
19649
|
const bodyEl = body[0];
|
|
19585
19650
|
const topLevel = effectiveChildElements(bodyEl);
|
|
@@ -19588,16 +19653,20 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19588
19653
|
if (localName2 === "p") {
|
|
19589
19654
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19590
19655
|
if (block) blocks.push(block);
|
|
19656
|
+
if (imageMap.size > 0) emitParagraphImages(el, imageMap, linkedImages, blocks);
|
|
19591
19657
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19592
19658
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19593
19659
|
if (tb) blocks.push(tb);
|
|
19660
|
+
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19594
19661
|
}
|
|
19595
19662
|
} else if (localName2 === "tbl") {
|
|
19596
19663
|
const block = parseTable(el, styles, numbering, footnotes, rels);
|
|
19597
19664
|
if (block) blocks.push(block);
|
|
19598
19665
|
}
|
|
19599
19666
|
}
|
|
19600
|
-
const
|
|
19667
|
+
for (const [embedId, filename] of imageMap) {
|
|
19668
|
+
if (!linkedImages.has(embedId)) blocks.push({ type: "image", text: filename });
|
|
19669
|
+
}
|
|
19601
19670
|
const metadata = {};
|
|
19602
19671
|
const coreFile = zip.file("docProps/core.xml");
|
|
19603
19672
|
if (coreFile) {
|
|
@@ -19623,7 +19692,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19623
19692
|
}
|
|
19624
19693
|
}
|
|
19625
19694
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19626
|
-
const markdown =
|
|
19695
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19627
19696
|
return {
|
|
19628
19697
|
markdown,
|
|
19629
19698
|
blocks,
|
|
@@ -19646,7 +19715,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19646
19715
|
}
|
|
19647
19716
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19648
19717
|
const normalized = text.replace(/ /g, " ");
|
|
19649
|
-
const xml =
|
|
19718
|
+
const xml = _chunkU25XGCNHcjs.stripDtd.call(void 0, normalized);
|
|
19650
19719
|
const warnings = [];
|
|
19651
19720
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19652
19721
|
onError: (_level, msg2) => {
|
|
@@ -19674,7 +19743,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19674
19743
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19675
19744
|
}
|
|
19676
19745
|
const blocks = [];
|
|
19677
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _158 => _158.pages]) ?
|
|
19746
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _158 => _158.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
19678
19747
|
let sectionIdx = 0;
|
|
19679
19748
|
const children = body.childNodes;
|
|
19680
19749
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -19686,7 +19755,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19686
19755
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
19687
19756
|
}
|
|
19688
19757
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
19689
|
-
const markdown =
|
|
19758
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19690
19759
|
return {
|
|
19691
19760
|
markdown,
|
|
19692
19761
|
blocks,
|
|
@@ -19844,7 +19913,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
19844
19913
|
const cellRows = grid.map(
|
|
19845
19914
|
(row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
19846
19915
|
);
|
|
19847
|
-
const table2 =
|
|
19916
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
19848
19917
|
const caption = extractShapeCaption(el);
|
|
19849
19918
|
if (caption.text && caption.before) {
|
|
19850
19919
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21172,19 +21241,19 @@ function parseCentralDirectory(buf) {
|
|
|
21172
21241
|
}
|
|
21173
21242
|
}
|
|
21174
21243
|
}
|
|
21175
|
-
if (eocdOffset < 0) throw new (0,
|
|
21244
|
+
if (eocdOffset < 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21176
21245
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21177
21246
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21178
21247
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21179
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21248
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21180
21249
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21181
|
-
throw new (0,
|
|
21250
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21182
21251
|
}
|
|
21183
21252
|
const decoder = new TextDecoder("utf-8");
|
|
21184
21253
|
const entries = [];
|
|
21185
21254
|
let pos = cdOffset;
|
|
21186
21255
|
for (let i = 0; i < totalEntries; i++) {
|
|
21187
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21256
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21188
21257
|
const flags = view.getUint16(pos + 8, true);
|
|
21189
21258
|
const method = view.getUint16(pos + 10, true);
|
|
21190
21259
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21195,7 +21264,7 @@ function parseCentralDirectory(buf) {
|
|
|
21195
21264
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21196
21265
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21197
21266
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21198
|
-
throw new (0,
|
|
21267
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21199
21268
|
}
|
|
21200
21269
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21201
21270
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21224,11 +21293,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21224
21293
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21225
21294
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21226
21295
|
for (const name of replacements.keys()) {
|
|
21227
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21296
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkU25XGCNHcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21228
21297
|
}
|
|
21229
21298
|
if (additions) {
|
|
21230
21299
|
for (const name of additions.keys()) {
|
|
21231
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21300
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkU25XGCNHcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21232
21301
|
}
|
|
21233
21302
|
}
|
|
21234
21303
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21247,7 +21316,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21247
21316
|
offset += seg.length;
|
|
21248
21317
|
continue;
|
|
21249
21318
|
}
|
|
21250
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21319
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21251
21320
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21252
21321
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21253
21322
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21353,7 +21422,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21353
21422
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21354
21423
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21355
21424
|
if (sectionPaths.length === 0) {
|
|
21356
|
-
throw new (0,
|
|
21425
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21357
21426
|
}
|
|
21358
21427
|
const normalizedValues = normalizeValues(values);
|
|
21359
21428
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -22042,7 +22111,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22042
22111
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22043
22112
|
const got = m ? Number(m[1]) : NaN;
|
|
22044
22113
|
if (got !== startId + i) {
|
|
22045
|
-
throw new (0,
|
|
22114
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
22046
22115
|
`\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)`
|
|
22047
22116
|
);
|
|
22048
22117
|
}
|
|
@@ -22126,7 +22195,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22126
22195
|
}
|
|
22127
22196
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22128
22197
|
if (rows.length !== expectedBase) {
|
|
22129
|
-
throw new (0,
|
|
22198
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
22130
22199
|
`\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`
|
|
22131
22200
|
);
|
|
22132
22201
|
}
|
|
@@ -23001,7 +23070,7 @@ function escapeGfm(text) {
|
|
|
23001
23070
|
}
|
|
23002
23071
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
23003
23072
|
function sanitizeText(text) {
|
|
23004
|
-
let result =
|
|
23073
|
+
let result = _chunkU25XGCNHcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23005
23074
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23006
23075
|
const tokens = result.split(" ");
|
|
23007
23076
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -25402,11 +25471,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25402
25471
|
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>`;
|
|
25403
25472
|
}
|
|
25404
25473
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25405
|
-
if (ops.length === 0) throw new (0,
|
|
25474
|
+
if (ops.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25406
25475
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25407
25476
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25408
25477
|
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))));
|
|
25409
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25478
|
+
if (sectionPaths.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25410
25479
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25411
25480
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25412
25481
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25447,11 +25516,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25447
25516
|
const manifestItems = [];
|
|
25448
25517
|
const placed = [];
|
|
25449
25518
|
for (const op of ops) {
|
|
25450
|
-
if (!op.anchor) throw new (0,
|
|
25451
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25519
|
+
if (!op.anchor) throw new (0, _chunkU25XGCNHcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25520
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25452
25521
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25453
|
-
if (!MIME[ext]) throw new (0,
|
|
25454
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25522
|
+
if (!MIME[ext]) throw new (0, _chunkU25XGCNHcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25523
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkU25XGCNHcjs.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)`);
|
|
25455
25524
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25456
25525
|
let found = null;
|
|
25457
25526
|
let total = 0;
|
|
@@ -25484,7 +25553,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25484
25553
|
}
|
|
25485
25554
|
}
|
|
25486
25555
|
}
|
|
25487
|
-
throw new (0,
|
|
25556
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
25488
25557
|
`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)})`
|
|
25489
25558
|
);
|
|
25490
25559
|
}
|
|
@@ -25492,7 +25561,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25492
25561
|
const xml = sectionXmls[si];
|
|
25493
25562
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25494
25563
|
if (!run) {
|
|
25495
|
-
throw new (0,
|
|
25564
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
25496
25565
|
}
|
|
25497
25566
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _338 => _338.charPr, 'access', _339 => _339.get, 'call', _340 => _340(run.charPr), 'optionalAccess', _341 => _341.height]), () => ( 1e3));
|
|
25498
25567
|
const fontPt = charPrHeight / 100;
|
|
@@ -25770,7 +25839,7 @@ function pick(map, keys) {
|
|
|
25770
25839
|
return out;
|
|
25771
25840
|
}
|
|
25772
25841
|
async function hwpxToProfile(input) {
|
|
25773
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
25842
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, input);
|
|
25774
25843
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
25775
25844
|
const parser = createXmlParser();
|
|
25776
25845
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _363 => _363.file, 'call', _364 => _364(/[Hh]eader\.xml$/), 'optionalAccess', _365 => _365[0]])));
|
|
@@ -26689,7 +26758,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
26689
26758
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
26690
26759
|
if (paths.length > 0) return paths;
|
|
26691
26760
|
}
|
|
26692
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
26761
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
26693
26762
|
}
|
|
26694
26763
|
function sectionPathsFromManifest(xml) {
|
|
26695
26764
|
const attr = (tag, name) => {
|
|
@@ -26699,7 +26768,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26699
26768
|
const idToHref = /* @__PURE__ */ new Map();
|
|
26700
26769
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
26701
26770
|
const id = attr(m[1], "id");
|
|
26702
|
-
const href =
|
|
26771
|
+
const href = _chunkU25XGCNHcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
26703
26772
|
if (id && href) idToHref.set(id, href);
|
|
26704
26773
|
}
|
|
26705
26774
|
const ordered = [];
|
|
@@ -26708,7 +26777,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26708
26777
|
if (href) ordered.push(href);
|
|
26709
26778
|
}
|
|
26710
26779
|
if (ordered.length > 0) return ordered;
|
|
26711
|
-
return Array.from(idToHref.values()).sort(
|
|
26780
|
+
return Array.from(idToHref.values()).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
26712
26781
|
}
|
|
26713
26782
|
|
|
26714
26783
|
// src/roundtrip/patcher.ts
|
|
@@ -26819,9 +26888,9 @@ function buildOrigUnits(blocks) {
|
|
|
26819
26888
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
26820
26889
|
const next = blocks[i + 1];
|
|
26821
26890
|
if (_optionalChain([next, 'optionalAccess', _398 => _398.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
26822
|
-
chunk2 =
|
|
26891
|
+
chunk2 = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
26823
26892
|
} else {
|
|
26824
|
-
chunk2 =
|
|
26893
|
+
chunk2 = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, [block]);
|
|
26825
26894
|
}
|
|
26826
26895
|
if (chunk2) {
|
|
26827
26896
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
@@ -28660,13 +28729,13 @@ async function htmlToPdf(html, options) {
|
|
|
28660
28729
|
try {
|
|
28661
28730
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
28662
28731
|
} catch (e31) {
|
|
28663
|
-
throw new (0,
|
|
28732
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
28664
28733
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
28665
28734
|
);
|
|
28666
28735
|
}
|
|
28667
28736
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
28668
28737
|
if (!executablePath) {
|
|
28669
|
-
throw new (0,
|
|
28738
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
28670
28739
|
"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."
|
|
28671
28740
|
);
|
|
28672
28741
|
}
|
|
@@ -28725,7 +28794,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
28725
28794
|
return htmlToPdf(html, options);
|
|
28726
28795
|
}
|
|
28727
28796
|
async function blocksToPdf(blocks, options) {
|
|
28728
|
-
const markdown =
|
|
28797
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
28729
28798
|
return markdownToPdf(markdown, options);
|
|
28730
28799
|
}
|
|
28731
28800
|
|
|
@@ -29611,15 +29680,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
29611
29680
|
async function renderHwpxToSvg(input, options) {
|
|
29612
29681
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
29613
29682
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
29614
|
-
|
|
29683
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
29615
29684
|
let zip;
|
|
29616
29685
|
try {
|
|
29617
29686
|
zip = await _jszip2.default.loadAsync(input);
|
|
29618
29687
|
} catch (e32) {
|
|
29619
|
-
throw new (0,
|
|
29688
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
29620
29689
|
}
|
|
29621
29690
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
29622
|
-
if (secFiles.length === 0) throw new (0,
|
|
29691
|
+
if (secFiles.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
29623
29692
|
const warnings = [];
|
|
29624
29693
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
29625
29694
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -29627,7 +29696,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29627
29696
|
const secXmls = [];
|
|
29628
29697
|
for (const f of secFiles) {
|
|
29629
29698
|
const xml = await f.async("string");
|
|
29630
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
29699
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
29631
29700
|
secXmls.push(xml);
|
|
29632
29701
|
}
|
|
29633
29702
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -29699,9 +29768,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29699
29768
|
}
|
|
29700
29769
|
if (rendered.length === 0) {
|
|
29701
29770
|
if (noCacheSkipped) {
|
|
29702
|
-
throw new (0,
|
|
29771
|
+
throw new (0, _chunkU25XGCNHcjs.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)");
|
|
29703
29772
|
}
|
|
29704
|
-
throw new (0,
|
|
29773
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
29705
29774
|
}
|
|
29706
29775
|
const GAP = 2400;
|
|
29707
29776
|
const clipDefs = [];
|
|
@@ -29737,13 +29806,13 @@ async function parse(input, options) {
|
|
|
29737
29806
|
if (typeof input === "string") {
|
|
29738
29807
|
try {
|
|
29739
29808
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29740
|
-
buffer =
|
|
29809
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, buf);
|
|
29741
29810
|
} catch (err) {
|
|
29742
29811
|
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}`;
|
|
29743
29812
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
29744
29813
|
}
|
|
29745
29814
|
} else if (Buffer.isBuffer(input)) {
|
|
29746
|
-
buffer =
|
|
29815
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, input);
|
|
29747
29816
|
} else {
|
|
29748
29817
|
buffer = input;
|
|
29749
29818
|
}
|
|
@@ -29778,7 +29847,7 @@ async function parseHwp3(buffer, options) {
|
|
|
29778
29847
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
29779
29848
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
29780
29849
|
} catch (err) {
|
|
29781
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29850
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29782
29851
|
}
|
|
29783
29852
|
}
|
|
29784
29853
|
async function parseHwpx(buffer, options) {
|
|
@@ -29786,7 +29855,7 @@ async function parseHwpx(buffer, options) {
|
|
|
29786
29855
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
29787
29856
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _486 => _486.length]) ? images : void 0 };
|
|
29788
29857
|
} catch (err) {
|
|
29789
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29858
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29790
29859
|
}
|
|
29791
29860
|
}
|
|
29792
29861
|
async function parseHwp(buffer, options) {
|
|
@@ -29811,13 +29880,13 @@ async function parseHwp(buffer, options) {
|
|
|
29811
29880
|
}
|
|
29812
29881
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _488 => _488.length]) ? images : void 0 };
|
|
29813
29882
|
} catch (err) {
|
|
29814
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29883
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29815
29884
|
}
|
|
29816
29885
|
}
|
|
29817
29886
|
async function parsePdf(buffer, options) {
|
|
29818
29887
|
let parsePdfDocument;
|
|
29819
29888
|
try {
|
|
29820
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
29889
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-E6U5TNAU.cjs")));
|
|
29821
29890
|
parsePdfDocument = mod.parsePdfDocument;
|
|
29822
29891
|
} catch (e34) {
|
|
29823
29892
|
return {
|
|
@@ -29832,7 +29901,7 @@ async function parsePdf(buffer, options) {
|
|
|
29832
29901
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
29833
29902
|
} catch (err) {
|
|
29834
29903
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
29835
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29904
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err), isImageBased };
|
|
29836
29905
|
}
|
|
29837
29906
|
}
|
|
29838
29907
|
async function parseXlsx(buffer, options) {
|
|
@@ -29840,7 +29909,7 @@ async function parseXlsx(buffer, options) {
|
|
|
29840
29909
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
29841
29910
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
29842
29911
|
} catch (err) {
|
|
29843
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29912
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29844
29913
|
}
|
|
29845
29914
|
}
|
|
29846
29915
|
async function parseXls(buffer, options) {
|
|
@@ -29848,7 +29917,7 @@ async function parseXls(buffer, options) {
|
|
|
29848
29917
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
29849
29918
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
29850
29919
|
} catch (err) {
|
|
29851
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29920
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29852
29921
|
}
|
|
29853
29922
|
}
|
|
29854
29923
|
async function parseDocx(buffer, options) {
|
|
@@ -29856,7 +29925,7 @@ async function parseDocx(buffer, options) {
|
|
|
29856
29925
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
29857
29926
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
|
|
29858
29927
|
} catch (err) {
|
|
29859
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29928
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29860
29929
|
}
|
|
29861
29930
|
}
|
|
29862
29931
|
async function parseHwpml(buffer, options) {
|
|
@@ -29864,16 +29933,16 @@ async function parseHwpml(buffer, options) {
|
|
|
29864
29933
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
29865
29934
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
29866
29935
|
} catch (err) {
|
|
29867
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29936
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkU25XGCNHcjs.classifyError.call(void 0, err) };
|
|
29868
29937
|
}
|
|
29869
29938
|
}
|
|
29870
29939
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
29871
29940
|
let buffer;
|
|
29872
29941
|
if (typeof input === "string") {
|
|
29873
29942
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29874
|
-
buffer =
|
|
29943
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, buf);
|
|
29875
29944
|
} else if (Buffer.isBuffer(input)) {
|
|
29876
|
-
buffer =
|
|
29945
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, input);
|
|
29877
29946
|
} else {
|
|
29878
29947
|
buffer = input;
|
|
29879
29948
|
}
|
|
@@ -29899,7 +29968,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29899
29968
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
29900
29969
|
}
|
|
29901
29970
|
const fill = fillFormFields(parsed.blocks, values);
|
|
29902
|
-
const markdown =
|
|
29971
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
29903
29972
|
if (outputFormat === "hwpx") {
|
|
29904
29973
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
29905
29974
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -29968,5 +30037,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29968
30037
|
|
|
29969
30038
|
|
|
29970
30039
|
|
|
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 =
|
|
30040
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkU25XGCNHcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkU25XGCNHcjs.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;
|
|
29972
30041
|
//# sourceMappingURL=index.cjs.map
|