kordoc 4.0.5 → 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/README.md +806 -800
- package/dist/{-QVHGOOCR.js → -6HWEFXVV.js} +9 -9
- package/dist/{chunk-6PED5OOG.js → chunk-2SN3CKME.js} +2 -2
- package/dist/chunk-2SN3CKME.js.map +1 -0
- package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
- package/dist/chunk-3TBUDJDE.js.map +1 -0
- package/dist/{chunk-FKK4K53F.js → chunk-5OKHAJ62.js} +2 -2
- package/dist/chunk-5OKHAJ62.js.map +1 -0
- package/dist/{chunk-5RPYBC2Q.js → chunk-6GBLFQMA.js} +1 -1
- package/dist/chunk-6GBLFQMA.js.map +1 -0
- package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
- package/dist/chunk-AIQ3ISQU.js.map +1 -0
- package/dist/{chunk-OMERK4AW.js → chunk-BKWHX3RC.js} +3 -3
- package/dist/chunk-BKWHX3RC.js.map +1 -0
- package/dist/{chunk-MEPHGCPQ.js → chunk-CFQLK3LM.js} +1 -1
- package/dist/chunk-CFQLK3LM.js.map +1 -0
- package/dist/{chunk-6BABRVOJ.js → chunk-CNM75ZSX.js} +2 -2
- package/dist/chunk-CNM75ZSX.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-6WDPB4SN.js → chunk-NGSHDBQR.js} +3 -3
- package/dist/chunk-NGSHDBQR.js.map +1 -0
- package/dist/{chunk-ZGMMLYAL.js → chunk-ONXVBURQ.js} +2 -2
- package/dist/chunk-ONXVBURQ.js.map +1 -0
- package/dist/{chunk-QK2G34WE.js → chunk-Q7EN4EUJ.js} +2 -2
- package/dist/chunk-Q7EN4EUJ.js.map +1 -0
- package/dist/{chunk-Z6Q3YG22.js → chunk-TJJTLM76.js} +197 -98
- package/dist/chunk-TJJTLM76.js.map +1 -0
- package/dist/{chunk-6R5FY47W.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 +18 -18
- package/dist/cli.js.map +1 -1
- package/dist/{detect-RI2MQ33K.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 +328 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +191 -92
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +14 -14
- package/dist/mcp.js.map +1 -1
- 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-3MAYZUJX.js → parser-5EHWYJMC.js} +93 -7
- package/dist/parser-5EHWYJMC.js.map +1 -0
- package/dist/{parser-2V5SPTU7.cjs → parser-E6U5TNAU.cjs} +105 -19
- package/dist/parser-E6U5TNAU.cjs.map +1 -0
- package/dist/{parser-YSHZC5FQ.js → parser-UGB3NIVH.js} +92 -6
- package/dist/parser-UGB3NIVH.js.map +1 -0
- package/dist/{profile-io-3EECPDHG.js → profile-io-CAKRPQRD.js} +3 -3
- package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
- package/dist/provider-5K7O3Z2O.cjs.map +1 -0
- package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
- package/dist/provider-7H4CPZYS.js.map +1 -0
- package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
- package/dist/provider-H4WWSPOV.js.map +1 -0
- package/dist/render-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-7MHSCKEQ.js → watch-RMX427YR.js} +9 -9
- package/dist/watch-RMX427YR.js.map +1 -0
- package/package.json +97 -97
- package/dist/chunk-5RPYBC2Q.js.map +0 -1
- package/dist/chunk-6BABRVOJ.js.map +0 -1
- package/dist/chunk-6PED5OOG.js.map +0 -1
- package/dist/chunk-6R5FY47W.cjs.map +0 -1
- package/dist/chunk-6WDPB4SN.js.map +0 -1
- package/dist/chunk-DCZVOIEO.cjs.map +0 -1
- package/dist/chunk-FKK4K53F.js.map +0 -1
- package/dist/chunk-GE43BE46.js.map +0 -1
- package/dist/chunk-MEPHGCPQ.js.map +0 -1
- package/dist/chunk-MOL7MDBG.js.map +0 -1
- package/dist/chunk-OMERK4AW.js.map +0 -1
- package/dist/chunk-QK2G34WE.js.map +0 -1
- package/dist/chunk-Z6Q3YG22.js.map +0 -1
- package/dist/chunk-ZGMMLYAL.js.map +0 -1
- package/dist/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-2V5SPTU7.cjs.map +0 -1
- package/dist/parser-3MAYZUJX.js.map +0 -1
- package/dist/parser-YSHZC5FQ.js.map +0 -1
- package/dist/provider-4ZJKV3DC.js.map +0 -1
- package/dist/provider-AKROB7WQ.js.map +0 -1
- package/dist/provider-G4C2V2PD.cjs.map +0 -1
- package/dist/render-MJSQ4TG2.js +0 -10
- package/dist/seal-R3POFNOU.js +0 -10
- package/dist/setup-57FB3LSP.js.map +0 -1
- package/dist/watch-7MHSCKEQ.js.map +0 -1
- /package/dist/{-QVHGOOCR.js.map → -6HWEFXVV.js.map} +0 -0
- /package/dist/{detect-RI2MQ33K.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-3EECPDHG.js.map → profile-io-CAKRPQRD.js.map} +0 -0
- /package/dist/{render-MJSQ4TG2.js.map → render-P6663O4I.js.map} +0 -0
- /package/dist/{seal-R3POFNOU.js.map → seal-7PPTXKKV.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": {
|
|
@@ -2232,8 +2232,15 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
2232
2232
|
if (tag === "p" || tag === "para") {
|
|
2233
2233
|
const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
|
|
2234
2234
|
if (t) parts.push(t);
|
|
2235
|
+
const tbls = [];
|
|
2236
|
+
findTopLevelTbls(ch, tbls);
|
|
2237
|
+
for (const tbl2 of tbls) {
|
|
2238
|
+
const flat = flattenSubListTable(tbl2, ctx, depth);
|
|
2239
|
+
if (flat) parts.push(flat);
|
|
2240
|
+
}
|
|
2235
2241
|
} else if (tag === "tbl") {
|
|
2236
|
-
|
|
2242
|
+
const flat = flattenSubListTable(ch, ctx, depth);
|
|
2243
|
+
if (flat) parts.push(flat);
|
|
2237
2244
|
} else {
|
|
2238
2245
|
const t = collectSubListText(ch, ctx, depth + 1);
|
|
2239
2246
|
if (t) parts.push(t);
|
|
@@ -2241,6 +2248,29 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
2241
2248
|
}
|
|
2242
2249
|
return parts.join("\n").trim();
|
|
2243
2250
|
}
|
|
2251
|
+
function flattenSubListTable(el, ctx, depth) {
|
|
2252
|
+
const sink = [];
|
|
2253
|
+
const st = { rows: [], currentRow: [], cell: null };
|
|
2254
|
+
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2255
|
+
let flat = _chunkU25XGCNHcjs.convertTableToText.call(void 0, st.rows);
|
|
2256
|
+
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2257
|
+
return flat;
|
|
2258
|
+
}
|
|
2259
|
+
function findTopLevelTbls(el, out, depth = 0) {
|
|
2260
|
+
if (depth > MAX_XML_DEPTH) return;
|
|
2261
|
+
const kids2 = el.childNodes;
|
|
2262
|
+
if (!kids2) return;
|
|
2263
|
+
for (let i = 0; i < kids2.length; i++) {
|
|
2264
|
+
const ch = kids2[i];
|
|
2265
|
+
if (ch.nodeType !== 1) continue;
|
|
2266
|
+
const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
|
|
2267
|
+
if (tag === "tbl") {
|
|
2268
|
+
out.push(ch);
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
findTopLevelTbls(ch, out, depth + 1);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2244
2274
|
function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
2245
2275
|
if (depth > MAX_XML_DEPTH) return tableCtx;
|
|
2246
2276
|
const children = node.childNodes;
|
|
@@ -2355,7 +2385,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2355
2385
|
let url = (ch.textContent || "").trim();
|
|
2356
2386
|
if (!url) continue;
|
|
2357
2387
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2358
|
-
const safe =
|
|
2388
|
+
const safe = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, url);
|
|
2359
2389
|
if (safe) return safe;
|
|
2360
2390
|
}
|
|
2361
2391
|
return void 0;
|
|
@@ -2493,7 +2523,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2493
2523
|
case "hyperlink": {
|
|
2494
2524
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2495
2525
|
if (url) {
|
|
2496
|
-
const safe =
|
|
2526
|
+
const safe = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, url);
|
|
2497
2527
|
if (safe) href = safe;
|
|
2498
2528
|
}
|
|
2499
2529
|
walk(child);
|
|
@@ -2765,13 +2795,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
2765
2795
|
}
|
|
2766
2796
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
2767
2797
|
for (const path of allCandidates) {
|
|
2768
|
-
if (
|
|
2798
|
+
if (_chunkU25XGCNHcjs.isPathTraversal.call(void 0, path)) continue;
|
|
2769
2799
|
const file = zip.file(path);
|
|
2770
2800
|
if (!file) continue;
|
|
2771
2801
|
try {
|
|
2772
2802
|
const data = await file.async("uint8array");
|
|
2773
2803
|
decompressed.total += data.length;
|
|
2774
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2804
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2775
2805
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
2776
2806
|
const mimeType = imageExtToMime(ext);
|
|
2777
2807
|
imageIndex++;
|
|
@@ -2780,7 +2810,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
2780
2810
|
images.push(img);
|
|
2781
2811
|
break;
|
|
2782
2812
|
} catch (err) {
|
|
2783
|
-
if (err instanceof
|
|
2813
|
+
if (err instanceof _chunkU25XGCNHcjs.KordocError) throw err;
|
|
2784
2814
|
}
|
|
2785
2815
|
}
|
|
2786
2816
|
if (!img) _optionalChain([warnings, 'optionalAccess', _67 => _67.push, 'call', _68 => _68({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -2842,7 +2872,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
2842
2872
|
}
|
|
2843
2873
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
2844
2874
|
const name = new TextDecoder().decode(nameBytes);
|
|
2845
|
-
if (
|
|
2875
|
+
if (_chunkU25XGCNHcjs.isPathTraversal.call(void 0, name)) {
|
|
2846
2876
|
pos = fileStart + compSize;
|
|
2847
2877
|
continue;
|
|
2848
2878
|
}
|
|
@@ -2860,16 +2890,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2860
2890
|
continue;
|
|
2861
2891
|
}
|
|
2862
2892
|
totalDecompressed += content.length * 2;
|
|
2863
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2893
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2864
2894
|
sectionNum++;
|
|
2865
2895
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2866
2896
|
} catch (e13) {
|
|
2867
2897
|
continue;
|
|
2868
2898
|
}
|
|
2869
2899
|
}
|
|
2870
|
-
if (blocks.length === 0) throw new (0,
|
|
2900
|
+
if (blocks.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2871
2901
|
applyPageText(blocks, shared);
|
|
2872
|
-
const markdown =
|
|
2902
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2873
2903
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2874
2904
|
}
|
|
2875
2905
|
async function readKordocLayout(zip) {
|
|
@@ -2894,18 +2924,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2894
2924
|
if (paths.length > 0) return paths;
|
|
2895
2925
|
}
|
|
2896
2926
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2897
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2927
|
+
return sectionFiles.map((f) => f.name).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
2898
2928
|
}
|
|
2899
2929
|
function parseSectionPathsFromManifest(xml) {
|
|
2900
2930
|
const parser = createXmlParser();
|
|
2901
|
-
const doc = parser.parseFromString(
|
|
2931
|
+
const doc = parser.parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2902
2932
|
const items = doc.getElementsByTagName("opf:item");
|
|
2903
2933
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2904
2934
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2905
2935
|
for (let i = 0; i < items.length; i++) {
|
|
2906
2936
|
const item = items[i];
|
|
2907
2937
|
const id = item.getAttribute("id") || "";
|
|
2908
|
-
const href =
|
|
2938
|
+
const href = _chunkU25XGCNHcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2909
2939
|
if (id && href) idToHref.set(id, href);
|
|
2910
2940
|
}
|
|
2911
2941
|
if (spine.length > 0) {
|
|
@@ -2916,7 +2946,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2916
2946
|
}
|
|
2917
2947
|
if (ordered.length > 0) return ordered;
|
|
2918
2948
|
}
|
|
2919
|
-
return Array.from(idToHref.values()).sort(
|
|
2949
|
+
return Array.from(idToHref.values()).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
2920
2950
|
}
|
|
2921
2951
|
|
|
2922
2952
|
// src/hwpx/metadata.ts
|
|
@@ -2929,7 +2959,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2929
2959
|
const xml = await file.async("text");
|
|
2930
2960
|
if (decompressed) {
|
|
2931
2961
|
decompressed.total += xml.length * 2;
|
|
2932
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2962
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2933
2963
|
}
|
|
2934
2964
|
parseDublinCoreMetadata(xml, metadata);
|
|
2935
2965
|
if (metadata.title || metadata.author) return;
|
|
@@ -2939,7 +2969,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2939
2969
|
}
|
|
2940
2970
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2941
2971
|
const parser = createXmlParser();
|
|
2942
|
-
const doc = parser.parseFromString(
|
|
2972
|
+
const doc = parser.parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2943
2973
|
if (!doc.documentElement) return;
|
|
2944
2974
|
const getText = (tagNames) => {
|
|
2945
2975
|
for (const tag of tagNames) {
|
|
@@ -2964,7 +2994,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2964
2994
|
|
|
2965
2995
|
// src/hwpx/parser.ts
|
|
2966
2996
|
async function parseHwpxDocument(buffer, options) {
|
|
2967
|
-
|
|
2997
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2968
2998
|
let zip;
|
|
2969
2999
|
try {
|
|
2970
3000
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2973,7 +3003,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2973
3003
|
}
|
|
2974
3004
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2975
3005
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2976
|
-
throw new (0,
|
|
3006
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2977
3007
|
}
|
|
2978
3008
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2979
3009
|
if (manifestFile) {
|
|
@@ -2985,7 +3015,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2985
3015
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2986
3016
|
}
|
|
2987
3017
|
}
|
|
2988
|
-
throw new (0,
|
|
3018
|
+
throw new (0, _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.");
|
|
2989
3019
|
}
|
|
2990
3020
|
}
|
|
2991
3021
|
const decompressed = { total: 0 };
|
|
@@ -2994,9 +3024,9 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2994
3024
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2995
3025
|
const warnings = [];
|
|
2996
3026
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2997
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3027
|
+
if (sectionPaths.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2998
3028
|
metadata.pageCount = sectionPaths.length;
|
|
2999
|
-
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;
|
|
3000
3030
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3001
3031
|
const blocks = [];
|
|
3002
3032
|
const shared = createSectionShared();
|
|
@@ -3009,12 +3039,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3009
3039
|
try {
|
|
3010
3040
|
const xml = await file.async("text");
|
|
3011
3041
|
decompressed.total += xml.length * 2;
|
|
3012
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3042
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3013
3043
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3014
3044
|
parsedSections++;
|
|
3015
3045
|
_optionalChain([options, 'optionalAccess', _78 => _78.onProgress, 'optionalCall', _79 => _79(parsedSections, totalTarget)]);
|
|
3016
3046
|
} catch (secErr) {
|
|
3017
|
-
if (secErr instanceof
|
|
3047
|
+
if (secErr instanceof _chunkU25XGCNHcjs.KordocError) throw secErr;
|
|
3018
3048
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3019
3049
|
}
|
|
3020
3050
|
}
|
|
@@ -3022,7 +3052,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3022
3052
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
3023
3053
|
detectHwpxHeadings(blocks, styleMap);
|
|
3024
3054
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3025
|
-
const markdown =
|
|
3055
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3026
3056
|
return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3027
3057
|
}
|
|
3028
3058
|
|
|
@@ -3089,7 +3119,7 @@ function decompressStream(data) {
|
|
|
3089
3119
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
3090
3120
|
}
|
|
3091
3121
|
function parseFileHeader(data) {
|
|
3092
|
-
if (data.length < 40) throw new (0,
|
|
3122
|
+
if (data.length < 40) throw new (0, _chunkU25XGCNHcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
3093
3123
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
3094
3124
|
return {
|
|
3095
3125
|
signature: sig,
|
|
@@ -4759,7 +4789,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4759
4789
|
lenientCfb = parseLenientCfb(buffer);
|
|
4760
4790
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4761
4791
|
} catch (e22) {
|
|
4762
|
-
throw new (0,
|
|
4792
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4763
4793
|
}
|
|
4764
4794
|
}
|
|
4765
4795
|
const findStream = (path) => {
|
|
@@ -4770,11 +4800,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4770
4800
|
return lenientCfb.findStream(path);
|
|
4771
4801
|
};
|
|
4772
4802
|
const headerData = findStream("/FileHeader");
|
|
4773
|
-
if (!headerData) throw new (0,
|
|
4803
|
+
if (!headerData) throw new (0, _chunkU25XGCNHcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4774
4804
|
const header = parseFileHeader(headerData);
|
|
4775
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4776
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4777
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4805
|
+
if (header.signature !== "HWP Document File") throw new (0, _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");
|
|
4778
4808
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4779
4809
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4780
4810
|
const metadata = {
|
|
@@ -4783,9 +4813,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
4783
4813
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4784
4814
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4785
4815
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4786
|
-
if (sections.length === 0) throw new (0,
|
|
4816
|
+
if (sections.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4787
4817
|
metadata.pageCount = sections.length;
|
|
4788
|
-
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;
|
|
4789
4819
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4790
4820
|
const bodyBlocks = [];
|
|
4791
4821
|
const doc = createHwp5DocState();
|
|
@@ -4797,22 +4827,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4797
4827
|
const sectionData = sections[si];
|
|
4798
4828
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4799
4829
|
totalDecompressed += data.length;
|
|
4800
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4830
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4801
4831
|
const records = readRecords(data);
|
|
4802
4832
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4803
4833
|
bodyBlocks.push(...sectionBlocks);
|
|
4804
4834
|
parsedSections++;
|
|
4805
4835
|
_optionalChain([options, 'optionalAccess', _85 => _85.onProgress, 'optionalCall', _86 => _86(parsedSections, totalTarget)]);
|
|
4806
4836
|
} catch (secErr) {
|
|
4807
|
-
if (secErr instanceof
|
|
4837
|
+
if (secErr instanceof _chunkU25XGCNHcjs.KordocError) throw secErr;
|
|
4808
4838
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
4809
4839
|
}
|
|
4810
4840
|
}
|
|
4811
4841
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4812
4842
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
4813
|
-
let flatBlocks =
|
|
4843
|
+
let flatBlocks = _chunkU25XGCNHcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4814
4844
|
if (_optionalChain([options, 'optionalAccess', _87 => _87.dedupeRunningHeaders])) {
|
|
4815
|
-
const deduped =
|
|
4845
|
+
const deduped = _chunkU25XGCNHcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4816
4846
|
const removed = flatBlocks.length - deduped.length;
|
|
4817
4847
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4818
4848
|
flatBlocks = deduped;
|
|
@@ -4821,7 +4851,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4821
4851
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4822
4852
|
}
|
|
4823
4853
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4824
|
-
let markdown =
|
|
4854
|
+
let markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4825
4855
|
if (_optionalChain([options, 'optionalAccess', _88 => _88.inlineImages]) && images.length > 0) {
|
|
4826
4856
|
try {
|
|
4827
4857
|
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
@@ -4888,9 +4918,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4888
4918
|
let level = 0;
|
|
4889
4919
|
if (_optionalChain([block, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]) && baseFontSize > 0) {
|
|
4890
4920
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4891
|
-
if (ratio >=
|
|
4892
|
-
else if (ratio >=
|
|
4893
|
-
else if (ratio >=
|
|
4921
|
+
if (ratio >= _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;
|
|
4894
4924
|
}
|
|
4895
4925
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4896
4926
|
if (level === 0) level = 2;
|
|
@@ -4975,7 +5005,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4975
5005
|
if (!raw) break;
|
|
4976
5006
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4977
5007
|
totalDecompressed += content.length;
|
|
4978
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5008
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4979
5009
|
sections.push({ idx: i, content });
|
|
4980
5010
|
}
|
|
4981
5011
|
if (sections.length === 0) {
|
|
@@ -4987,7 +5017,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4987
5017
|
if (raw) {
|
|
4988
5018
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4989
5019
|
totalDecompressed += content.length;
|
|
4990
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5020
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4991
5021
|
sections.push({ idx, content });
|
|
4992
5022
|
}
|
|
4993
5023
|
}
|
|
@@ -5004,7 +5034,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5004
5034
|
try {
|
|
5005
5035
|
const content = decryptViewText(raw, compressed);
|
|
5006
5036
|
totalDecompressed += content.length;
|
|
5007
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5037
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkU25XGCNHcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5008
5038
|
sections.push({ idx: i, content });
|
|
5009
5039
|
} catch (e27) {
|
|
5010
5040
|
break;
|
|
@@ -5107,7 +5137,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5107
5137
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5108
5138
|
if (!_optionalChain([ctrl, 'optionalAccess', _101 => _101.href]) || r.end <= r.start) continue;
|
|
5109
5139
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5110
|
-
const href =
|
|
5140
|
+
const href = _chunkU25XGCNHcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5111
5141
|
if (!href) continue;
|
|
5112
5142
|
const anchor = text.slice(r.start, r.end);
|
|
5113
5143
|
if (!anchor.trim()) continue;
|
|
@@ -5340,8 +5370,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5340
5370
|
let tableIdx = -1;
|
|
5341
5371
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5342
5372
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5343
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5344
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5373
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkU25XGCNHcjs.MAX_ROWS);
|
|
5374
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkU25XGCNHcjs.MAX_COLS);
|
|
5345
5375
|
tableIdx = i2;
|
|
5346
5376
|
break;
|
|
5347
5377
|
}
|
|
@@ -5390,7 +5420,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5390
5420
|
return table3;
|
|
5391
5421
|
}
|
|
5392
5422
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5393
|
-
const table2 =
|
|
5423
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
5394
5424
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5395
5425
|
return table2.rows > 0 ? table2 : null;
|
|
5396
5426
|
}
|
|
@@ -5407,8 +5437,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5407
5437
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5408
5438
|
const cs = rec.data.readUInt16LE(12);
|
|
5409
5439
|
const rs = rec.data.readUInt16LE(14);
|
|
5410
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5411
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5440
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkU25XGCNHcjs.MAX_COLS);
|
|
5441
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkU25XGCNHcjs.MAX_ROWS);
|
|
5412
5442
|
}
|
|
5413
5443
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5414
5444
|
const parts = [];
|
|
@@ -5418,7 +5448,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5418
5448
|
parts.push(``);
|
|
5419
5449
|
hasStructure = true;
|
|
5420
5450
|
} else if (b.type === "table" && b.table) {
|
|
5421
|
-
const flat =
|
|
5451
|
+
const flat = _chunkU25XGCNHcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5422
5452
|
if (flat) parts.push(flat);
|
|
5423
5453
|
hasStructure = true;
|
|
5424
5454
|
} else if (b.text) {
|
|
@@ -17855,7 +17885,7 @@ function getTextContent(el) {
|
|
|
17855
17885
|
return _nullishCoalesce(_optionalChain([el, 'access', _116 => _116.textContent, 'optionalAccess', _117 => _117.trim, 'call', _118 => _118()]), () => ( ""));
|
|
17856
17886
|
}
|
|
17857
17887
|
function parseXml(text) {
|
|
17858
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17888
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17859
17889
|
}
|
|
17860
17890
|
function parseSharedStrings(xml) {
|
|
17861
17891
|
const doc = parseXml(xml);
|
|
@@ -17999,7 +18029,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17999
18029
|
cellRows.push(row);
|
|
18000
18030
|
}
|
|
18001
18031
|
if (cellRows.length > 0) {
|
|
18002
|
-
const table2 =
|
|
18032
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
18003
18033
|
if (table2.rows > 0) {
|
|
18004
18034
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18005
18035
|
}
|
|
@@ -18007,12 +18037,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
18007
18037
|
return blocks;
|
|
18008
18038
|
}
|
|
18009
18039
|
async function parseXlsxDocument(buffer, options) {
|
|
18010
|
-
|
|
18040
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
18011
18041
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18012
18042
|
const warnings = [];
|
|
18013
18043
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18014
18044
|
if (!workbookFile) {
|
|
18015
|
-
throw new (0,
|
|
18045
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18016
18046
|
}
|
|
18017
18047
|
let sharedStrings = [];
|
|
18018
18048
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18021,7 +18051,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18021
18051
|
}
|
|
18022
18052
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
18023
18053
|
if (sheets.length === 0) {
|
|
18024
|
-
throw new (0,
|
|
18054
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18025
18055
|
}
|
|
18026
18056
|
let relsMap = /* @__PURE__ */ new Map();
|
|
18027
18057
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -18030,7 +18060,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18030
18060
|
}
|
|
18031
18061
|
let pageFilter = null;
|
|
18032
18062
|
if (_optionalChain([options, 'optionalAccess', _121 => _121.pages])) {
|
|
18033
|
-
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")));
|
|
18034
18064
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18035
18065
|
}
|
|
18036
18066
|
const blocks = [];
|
|
@@ -18093,7 +18123,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18093
18123
|
} catch (e28) {
|
|
18094
18124
|
}
|
|
18095
18125
|
}
|
|
18096
|
-
const markdown =
|
|
18126
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18097
18127
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18098
18128
|
}
|
|
18099
18129
|
|
|
@@ -18500,11 +18530,11 @@ function processGlobals(records) {
|
|
|
18500
18530
|
let encrypted = false;
|
|
18501
18531
|
const firstBof = records[0];
|
|
18502
18532
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18503
|
-
throw new (0,
|
|
18533
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18504
18534
|
}
|
|
18505
18535
|
const bof = decodeBof(firstBof.data);
|
|
18506
18536
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18507
|
-
throw new (0,
|
|
18537
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18508
18538
|
}
|
|
18509
18539
|
let i = 1;
|
|
18510
18540
|
while (i < records.length) {
|
|
@@ -18619,7 +18649,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
18619
18649
|
cellRows.push(row);
|
|
18620
18650
|
}
|
|
18621
18651
|
if (cellRows.length > 0) {
|
|
18622
|
-
const table2 =
|
|
18652
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
18623
18653
|
if (table2.rows > 0) {
|
|
18624
18654
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18625
18655
|
}
|
|
@@ -18632,21 +18662,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18632
18662
|
try {
|
|
18633
18663
|
cfb = parseLenientCfb(buf);
|
|
18634
18664
|
} catch (e) {
|
|
18635
|
-
throw new (0,
|
|
18665
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
18636
18666
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18637
18667
|
);
|
|
18638
18668
|
}
|
|
18639
18669
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18640
18670
|
if (!wb) {
|
|
18641
|
-
throw new (0,
|
|
18671
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18642
18672
|
}
|
|
18643
18673
|
const records = readRecords2(wb);
|
|
18644
18674
|
if (records.length === 0) {
|
|
18645
|
-
throw new (0,
|
|
18675
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18646
18676
|
}
|
|
18647
18677
|
const firstBof = decodeBof(records[0].data);
|
|
18648
18678
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18649
|
-
throw new (0,
|
|
18679
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
18650
18680
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18651
18681
|
);
|
|
18652
18682
|
}
|
|
@@ -18668,7 +18698,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18668
18698
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18669
18699
|
let pageFilter = null;
|
|
18670
18700
|
if (_optionalChain([options, 'optionalAccess', _126 => _126.pages])) {
|
|
18671
|
-
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")));
|
|
18672
18702
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18673
18703
|
}
|
|
18674
18704
|
const allBlocks = [];
|
|
@@ -18706,7 +18736,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18706
18736
|
pageCount: totalSheets
|
|
18707
18737
|
};
|
|
18708
18738
|
return {
|
|
18709
|
-
markdown:
|
|
18739
|
+
markdown: _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18710
18740
|
blocks: allBlocks,
|
|
18711
18741
|
metadata,
|
|
18712
18742
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19144,7 +19174,7 @@ function getAttr(el, localName2) {
|
|
|
19144
19174
|
return null;
|
|
19145
19175
|
}
|
|
19146
19176
|
function parseXml2(text) {
|
|
19147
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19177
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkU25XGCNHcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19148
19178
|
}
|
|
19149
19179
|
function parseStyles(xml) {
|
|
19150
19180
|
const doc = parseXml2(xml);
|
|
@@ -19270,6 +19300,102 @@ function extractRun(r) {
|
|
|
19270
19300
|
}
|
|
19271
19301
|
return { text, bold, italic };
|
|
19272
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
|
+
}
|
|
19273
19399
|
function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
19274
19400
|
const pPrEls = getChildElements(p, "pPr");
|
|
19275
19401
|
let styleId = "";
|
|
@@ -19286,54 +19412,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19286
19412
|
ilvl = ilvlEls.length > 0 ? parseInt(_nullishCoalesce(getAttr(ilvlEls[0], "val"), () => ( "0")), 10) : 0;
|
|
19287
19413
|
}
|
|
19288
19414
|
}
|
|
19289
|
-
const
|
|
19290
|
-
let hasBold = false;
|
|
19291
|
-
let hasItalic = false;
|
|
19292
|
-
let href;
|
|
19293
|
-
let footnoteText;
|
|
19294
|
-
const hyperlinks = getChildElements(p, "hyperlink");
|
|
19295
|
-
const hyperlinkTexts = /* @__PURE__ */ new Set();
|
|
19296
|
-
for (const hl of hyperlinks) {
|
|
19297
|
-
const rId = getAttr(hl, "id");
|
|
19298
|
-
const hlText = [];
|
|
19299
|
-
const runs2 = findElements(hl, "r");
|
|
19300
|
-
for (const r of runs2) {
|
|
19301
|
-
const result = extractRun(r);
|
|
19302
|
-
hlText.push(result.text);
|
|
19303
|
-
}
|
|
19304
|
-
const text2 = hlText.join("");
|
|
19305
|
-
if (text2) {
|
|
19306
|
-
hyperlinkTexts.add(text2);
|
|
19307
|
-
if (rId && rels.has(rId)) {
|
|
19308
|
-
href = rels.get(rId);
|
|
19309
|
-
parts.push(text2);
|
|
19310
|
-
} else {
|
|
19311
|
-
parts.push(text2);
|
|
19312
|
-
}
|
|
19313
|
-
}
|
|
19314
|
-
}
|
|
19315
|
-
const runs = getChildElements(p, "r");
|
|
19316
|
-
for (const r of runs) {
|
|
19317
|
-
if (r.parentNode && r.parentNode.localName === "hyperlink") continue;
|
|
19318
|
-
const result = extractRun(r);
|
|
19319
|
-
if (result.bold) hasBold = true;
|
|
19320
|
-
if (result.italic) hasItalic = true;
|
|
19321
|
-
const fnRefEls = getChildElements(r, "footnoteReference");
|
|
19322
|
-
if (fnRefEls.length > 0) {
|
|
19323
|
-
const fnId = getAttr(fnRefEls[0], "id");
|
|
19324
|
-
if (fnId && footnotes.has(fnId)) {
|
|
19325
|
-
footnoteText = footnotes.get(fnId);
|
|
19326
|
-
}
|
|
19327
|
-
}
|
|
19328
|
-
if (result.text) parts.push(result.text);
|
|
19329
|
-
}
|
|
19330
|
-
for (const om of collectOmmlRoots(p)) {
|
|
19331
|
-
const latex = ommlElementToLatex(om);
|
|
19332
|
-
if (!latex) continue;
|
|
19333
|
-
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
19334
|
-
else parts.push(" $" + latex + "$ ");
|
|
19335
|
-
}
|
|
19336
|
-
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
19415
|
+
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19337
19416
|
if (!text) return null;
|
|
19338
19417
|
const style = styles.get(styleId);
|
|
19339
19418
|
if (_optionalChain([style, 'optionalAccess', _141 => _141.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
@@ -19353,7 +19432,6 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19353
19432
|
if (hasBold || hasItalic) {
|
|
19354
19433
|
block.style = { bold: hasBold || void 0, italic: hasItalic || void 0 };
|
|
19355
19434
|
}
|
|
19356
|
-
if (href) block.href = href;
|
|
19357
19435
|
if (footnoteText) block.footnoteText = footnoteText;
|
|
19358
19436
|
return block;
|
|
19359
19437
|
}
|
|
@@ -19429,7 +19507,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19429
19507
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19430
19508
|
})
|
|
19431
19509
|
);
|
|
19432
|
-
const table2 =
|
|
19510
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
19433
19511
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19434
19512
|
return { type: "table", table: table2 };
|
|
19435
19513
|
}
|
|
@@ -19454,54 +19532,69 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19454
19532
|
}
|
|
19455
19533
|
return parts;
|
|
19456
19534
|
}
|
|
19457
|
-
async function
|
|
19458
|
-
const
|
|
19535
|
+
async function buildImageMap(zip, rels, doc, warnings) {
|
|
19536
|
+
const imageMap = /* @__PURE__ */ new Map();
|
|
19459
19537
|
const images = [];
|
|
19460
|
-
const drawingElements = findElements(doc.documentElement, "drawing");
|
|
19461
19538
|
let imgIdx = 0;
|
|
19462
|
-
for (const
|
|
19463
|
-
const
|
|
19464
|
-
|
|
19465
|
-
|
|
19466
|
-
|
|
19467
|
-
|
|
19468
|
-
|
|
19469
|
-
|
|
19470
|
-
|
|
19471
|
-
|
|
19472
|
-
|
|
19473
|
-
|
|
19474
|
-
|
|
19475
|
-
|
|
19476
|
-
|
|
19477
|
-
|
|
19478
|
-
|
|
19479
|
-
|
|
19480
|
-
|
|
19481
|
-
|
|
19482
|
-
|
|
19483
|
-
|
|
19484
|
-
|
|
19485
|
-
|
|
19486
|
-
|
|
19487
|
-
|
|
19488
|
-
|
|
19489
|
-
|
|
19490
|
-
|
|
19491
|
-
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19492
|
-
});
|
|
19493
|
-
}
|
|
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
|
+
});
|
|
19494
19568
|
}
|
|
19495
19569
|
}
|
|
19496
|
-
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
|
+
}
|
|
19497
19590
|
}
|
|
19498
19591
|
async function parseDocxDocument(buffer, options) {
|
|
19499
|
-
|
|
19592
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
19500
19593
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19501
19594
|
const warnings = [];
|
|
19502
19595
|
const docFile = zip.file("word/document.xml");
|
|
19503
19596
|
if (!docFile) {
|
|
19504
|
-
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");
|
|
19505
19598
|
}
|
|
19506
19599
|
let rels = /* @__PURE__ */ new Map();
|
|
19507
19600
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19548,8 +19641,10 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19548
19641
|
const doc = parseXml2(docXml);
|
|
19549
19642
|
const body = findElements(doc, "body");
|
|
19550
19643
|
if (body.length === 0) {
|
|
19551
|
-
throw new (0,
|
|
19644
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19552
19645
|
}
|
|
19646
|
+
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19647
|
+
const linkedImages = /* @__PURE__ */ new Set();
|
|
19553
19648
|
const blocks = [];
|
|
19554
19649
|
const bodyEl = body[0];
|
|
19555
19650
|
const topLevel = effectiveChildElements(bodyEl);
|
|
@@ -19558,16 +19653,20 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19558
19653
|
if (localName2 === "p") {
|
|
19559
19654
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19560
19655
|
if (block) blocks.push(block);
|
|
19656
|
+
if (imageMap.size > 0) emitParagraphImages(el, imageMap, linkedImages, blocks);
|
|
19561
19657
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19562
19658
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19563
19659
|
if (tb) blocks.push(tb);
|
|
19660
|
+
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19564
19661
|
}
|
|
19565
19662
|
} else if (localName2 === "tbl") {
|
|
19566
19663
|
const block = parseTable(el, styles, numbering, footnotes, rels);
|
|
19567
19664
|
if (block) blocks.push(block);
|
|
19568
19665
|
}
|
|
19569
19666
|
}
|
|
19570
|
-
const
|
|
19667
|
+
for (const [embedId, filename] of imageMap) {
|
|
19668
|
+
if (!linkedImages.has(embedId)) blocks.push({ type: "image", text: filename });
|
|
19669
|
+
}
|
|
19571
19670
|
const metadata = {};
|
|
19572
19671
|
const coreFile = zip.file("docProps/core.xml");
|
|
19573
19672
|
if (coreFile) {
|
|
@@ -19593,7 +19692,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19593
19692
|
}
|
|
19594
19693
|
}
|
|
19595
19694
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19596
|
-
const markdown =
|
|
19695
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19597
19696
|
return {
|
|
19598
19697
|
markdown,
|
|
19599
19698
|
blocks,
|
|
@@ -19616,7 +19715,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19616
19715
|
}
|
|
19617
19716
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19618
19717
|
const normalized = text.replace(/ /g, " ");
|
|
19619
|
-
const xml =
|
|
19718
|
+
const xml = _chunkU25XGCNHcjs.stripDtd.call(void 0, normalized);
|
|
19620
19719
|
const warnings = [];
|
|
19621
19720
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19622
19721
|
onError: (_level, msg2) => {
|
|
@@ -19644,7 +19743,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19644
19743
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19645
19744
|
}
|
|
19646
19745
|
const blocks = [];
|
|
19647
|
-
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;
|
|
19648
19747
|
let sectionIdx = 0;
|
|
19649
19748
|
const children = body.childNodes;
|
|
19650
19749
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -19656,7 +19755,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19656
19755
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
19657
19756
|
}
|
|
19658
19757
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
19659
|
-
const markdown =
|
|
19758
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19660
19759
|
return {
|
|
19661
19760
|
markdown,
|
|
19662
19761
|
blocks,
|
|
@@ -19814,7 +19913,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
19814
19913
|
const cellRows = grid.map(
|
|
19815
19914
|
(row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
19816
19915
|
);
|
|
19817
|
-
const table2 =
|
|
19916
|
+
const table2 = _chunkU25XGCNHcjs.buildTable.call(void 0, cellRows);
|
|
19818
19917
|
const caption = extractShapeCaption(el);
|
|
19819
19918
|
if (caption.text && caption.before) {
|
|
19820
19919
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21142,19 +21241,19 @@ function parseCentralDirectory(buf) {
|
|
|
21142
21241
|
}
|
|
21143
21242
|
}
|
|
21144
21243
|
}
|
|
21145
|
-
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");
|
|
21146
21245
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21147
21246
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21148
21247
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21149
|
-
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");
|
|
21150
21249
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21151
|
-
throw new (0,
|
|
21250
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21152
21251
|
}
|
|
21153
21252
|
const decoder = new TextDecoder("utf-8");
|
|
21154
21253
|
const entries = [];
|
|
21155
21254
|
let pos = cdOffset;
|
|
21156
21255
|
for (let i = 0; i < totalEntries; i++) {
|
|
21157
|
-
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");
|
|
21158
21257
|
const flags = view.getUint16(pos + 8, true);
|
|
21159
21258
|
const method = view.getUint16(pos + 10, true);
|
|
21160
21259
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21165,7 +21264,7 @@ function parseCentralDirectory(buf) {
|
|
|
21165
21264
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21166
21265
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21167
21266
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21168
|
-
throw new (0,
|
|
21267
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21169
21268
|
}
|
|
21170
21269
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21171
21270
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21194,11 +21293,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21194
21293
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21195
21294
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21196
21295
|
for (const name of replacements.keys()) {
|
|
21197
|
-
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}`);
|
|
21198
21297
|
}
|
|
21199
21298
|
if (additions) {
|
|
21200
21299
|
for (const name of additions.keys()) {
|
|
21201
|
-
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}`);
|
|
21202
21301
|
}
|
|
21203
21302
|
}
|
|
21204
21303
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21217,7 +21316,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21217
21316
|
offset += seg.length;
|
|
21218
21317
|
continue;
|
|
21219
21318
|
}
|
|
21220
|
-
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");
|
|
21221
21320
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21222
21321
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21223
21322
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21323,7 +21422,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21323
21422
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21324
21423
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21325
21424
|
if (sectionPaths.length === 0) {
|
|
21326
|
-
throw new (0,
|
|
21425
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21327
21426
|
}
|
|
21328
21427
|
const normalizedValues = normalizeValues(values);
|
|
21329
21428
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -22012,7 +22111,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22012
22111
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22013
22112
|
const got = m ? Number(m[1]) : NaN;
|
|
22014
22113
|
if (got !== startId + i) {
|
|
22015
|
-
throw new (0,
|
|
22114
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
22016
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)`
|
|
22017
22116
|
);
|
|
22018
22117
|
}
|
|
@@ -22096,7 +22195,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22096
22195
|
}
|
|
22097
22196
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22098
22197
|
if (rows.length !== expectedBase) {
|
|
22099
|
-
throw new (0,
|
|
22198
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
22100
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`
|
|
22101
22200
|
);
|
|
22102
22201
|
}
|
|
@@ -22971,7 +23070,7 @@ function escapeGfm(text) {
|
|
|
22971
23070
|
}
|
|
22972
23071
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
22973
23072
|
function sanitizeText(text) {
|
|
22974
|
-
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();
|
|
22975
23074
|
if (result.length <= 30 && result.includes(" ")) {
|
|
22976
23075
|
const tokens = result.split(" ");
|
|
22977
23076
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -25372,11 +25471,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25372
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>`;
|
|
25373
25472
|
}
|
|
25374
25473
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25375
|
-
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");
|
|
25376
25475
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25377
25476
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25378
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))));
|
|
25379
|
-
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");
|
|
25380
25479
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25381
25480
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25382
25481
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25417,11 +25516,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25417
25516
|
const manifestItems = [];
|
|
25418
25517
|
const placed = [];
|
|
25419
25518
|
for (const op of ops) {
|
|
25420
|
-
if (!op.anchor) throw new (0,
|
|
25421
|
-
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");
|
|
25422
25521
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25423
|
-
if (!MIME[ext]) throw new (0,
|
|
25424
|
-
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)`);
|
|
25425
25524
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25426
25525
|
let found = null;
|
|
25427
25526
|
let total = 0;
|
|
@@ -25454,7 +25553,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25454
25553
|
}
|
|
25455
25554
|
}
|
|
25456
25555
|
}
|
|
25457
|
-
throw new (0,
|
|
25556
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
25458
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)})`
|
|
25459
25558
|
);
|
|
25460
25559
|
}
|
|
@@ -25462,7 +25561,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25462
25561
|
const xml = sectionXmls[si];
|
|
25463
25562
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25464
25563
|
if (!run) {
|
|
25465
|
-
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`);
|
|
25466
25565
|
}
|
|
25467
25566
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _338 => _338.charPr, 'access', _339 => _339.get, 'call', _340 => _340(run.charPr), 'optionalAccess', _341 => _341.height]), () => ( 1e3));
|
|
25468
25567
|
const fontPt = charPrHeight / 100;
|
|
@@ -25740,7 +25839,7 @@ function pick(map, keys) {
|
|
|
25740
25839
|
return out;
|
|
25741
25840
|
}
|
|
25742
25841
|
async function hwpxToProfile(input) {
|
|
25743
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
25842
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, input);
|
|
25744
25843
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
25745
25844
|
const parser = createXmlParser();
|
|
25746
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]])));
|
|
@@ -26659,7 +26758,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
26659
26758
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
26660
26759
|
if (paths.length > 0) return paths;
|
|
26661
26760
|
}
|
|
26662
|
-
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);
|
|
26663
26762
|
}
|
|
26664
26763
|
function sectionPathsFromManifest(xml) {
|
|
26665
26764
|
const attr = (tag, name) => {
|
|
@@ -26669,7 +26768,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26669
26768
|
const idToHref = /* @__PURE__ */ new Map();
|
|
26670
26769
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
26671
26770
|
const id = attr(m[1], "id");
|
|
26672
|
-
const href =
|
|
26771
|
+
const href = _chunkU25XGCNHcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
26673
26772
|
if (id && href) idToHref.set(id, href);
|
|
26674
26773
|
}
|
|
26675
26774
|
const ordered = [];
|
|
@@ -26678,7 +26777,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26678
26777
|
if (href) ordered.push(href);
|
|
26679
26778
|
}
|
|
26680
26779
|
if (ordered.length > 0) return ordered;
|
|
26681
|
-
return Array.from(idToHref.values()).sort(
|
|
26780
|
+
return Array.from(idToHref.values()).sort(_chunkU25XGCNHcjs.compareSectionPaths);
|
|
26682
26781
|
}
|
|
26683
26782
|
|
|
26684
26783
|
// src/roundtrip/patcher.ts
|
|
@@ -26789,9 +26888,9 @@ function buildOrigUnits(blocks) {
|
|
|
26789
26888
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
26790
26889
|
const next = blocks[i + 1];
|
|
26791
26890
|
if (_optionalChain([next, 'optionalAccess', _398 => _398.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
26792
|
-
chunk2 =
|
|
26891
|
+
chunk2 = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
26793
26892
|
} else {
|
|
26794
|
-
chunk2 =
|
|
26893
|
+
chunk2 = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, [block]);
|
|
26795
26894
|
}
|
|
26796
26895
|
if (chunk2) {
|
|
26797
26896
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
@@ -28630,13 +28729,13 @@ async function htmlToPdf(html, options) {
|
|
|
28630
28729
|
try {
|
|
28631
28730
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
28632
28731
|
} catch (e31) {
|
|
28633
|
-
throw new (0,
|
|
28732
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
28634
28733
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
28635
28734
|
);
|
|
28636
28735
|
}
|
|
28637
28736
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
28638
28737
|
if (!executablePath) {
|
|
28639
|
-
throw new (0,
|
|
28738
|
+
throw new (0, _chunkU25XGCNHcjs.KordocError)(
|
|
28640
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."
|
|
28641
28740
|
);
|
|
28642
28741
|
}
|
|
@@ -28695,7 +28794,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
28695
28794
|
return htmlToPdf(html, options);
|
|
28696
28795
|
}
|
|
28697
28796
|
async function blocksToPdf(blocks, options) {
|
|
28698
|
-
const markdown =
|
|
28797
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
28699
28798
|
return markdownToPdf(markdown, options);
|
|
28700
28799
|
}
|
|
28701
28800
|
|
|
@@ -29581,15 +29680,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
29581
29680
|
async function renderHwpxToSvg(input, options) {
|
|
29582
29681
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
29583
29682
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
29584
|
-
|
|
29683
|
+
_chunkU25XGCNHcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
29585
29684
|
let zip;
|
|
29586
29685
|
try {
|
|
29587
29686
|
zip = await _jszip2.default.loadAsync(input);
|
|
29588
29687
|
} catch (e32) {
|
|
29589
|
-
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");
|
|
29590
29689
|
}
|
|
29591
29690
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
29592
|
-
if (secFiles.length === 0) throw new (0,
|
|
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");
|
|
29593
29692
|
const warnings = [];
|
|
29594
29693
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
29595
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() };
|
|
@@ -29597,7 +29696,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29597
29696
|
const secXmls = [];
|
|
29598
29697
|
for (const f of secFiles) {
|
|
29599
29698
|
const xml = await f.async("string");
|
|
29600
|
-
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");
|
|
29601
29700
|
secXmls.push(xml);
|
|
29602
29701
|
}
|
|
29603
29702
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -29669,9 +29768,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29669
29768
|
}
|
|
29670
29769
|
if (rendered.length === 0) {
|
|
29671
29770
|
if (noCacheSkipped) {
|
|
29672
|
-
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)");
|
|
29673
29772
|
}
|
|
29674
|
-
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");
|
|
29675
29774
|
}
|
|
29676
29775
|
const GAP = 2400;
|
|
29677
29776
|
const clipDefs = [];
|
|
@@ -29707,13 +29806,13 @@ async function parse(input, options) {
|
|
|
29707
29806
|
if (typeof input === "string") {
|
|
29708
29807
|
try {
|
|
29709
29808
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29710
|
-
buffer =
|
|
29809
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, buf);
|
|
29711
29810
|
} catch (err) {
|
|
29712
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}`;
|
|
29713
29812
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
29714
29813
|
}
|
|
29715
29814
|
} else if (Buffer.isBuffer(input)) {
|
|
29716
|
-
buffer =
|
|
29815
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, input);
|
|
29717
29816
|
} else {
|
|
29718
29817
|
buffer = input;
|
|
29719
29818
|
}
|
|
@@ -29748,7 +29847,7 @@ async function parseHwp3(buffer, options) {
|
|
|
29748
29847
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
29749
29848
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
29750
29849
|
} catch (err) {
|
|
29751
|
-
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) };
|
|
29752
29851
|
}
|
|
29753
29852
|
}
|
|
29754
29853
|
async function parseHwpx(buffer, options) {
|
|
@@ -29756,7 +29855,7 @@ async function parseHwpx(buffer, options) {
|
|
|
29756
29855
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
29757
29856
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _486 => _486.length]) ? images : void 0 };
|
|
29758
29857
|
} catch (err) {
|
|
29759
|
-
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) };
|
|
29760
29859
|
}
|
|
29761
29860
|
}
|
|
29762
29861
|
async function parseHwp(buffer, options) {
|
|
@@ -29781,13 +29880,13 @@ async function parseHwp(buffer, options) {
|
|
|
29781
29880
|
}
|
|
29782
29881
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _488 => _488.length]) ? images : void 0 };
|
|
29783
29882
|
} catch (err) {
|
|
29784
|
-
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) };
|
|
29785
29884
|
}
|
|
29786
29885
|
}
|
|
29787
29886
|
async function parsePdf(buffer, options) {
|
|
29788
29887
|
let parsePdfDocument;
|
|
29789
29888
|
try {
|
|
29790
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
29889
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-E6U5TNAU.cjs")));
|
|
29791
29890
|
parsePdfDocument = mod.parsePdfDocument;
|
|
29792
29891
|
} catch (e34) {
|
|
29793
29892
|
return {
|
|
@@ -29802,7 +29901,7 @@ async function parsePdf(buffer, options) {
|
|
|
29802
29901
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
29803
29902
|
} catch (err) {
|
|
29804
29903
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
29805
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
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 };
|
|
29806
29905
|
}
|
|
29807
29906
|
}
|
|
29808
29907
|
async function parseXlsx(buffer, options) {
|
|
@@ -29810,7 +29909,7 @@ async function parseXlsx(buffer, options) {
|
|
|
29810
29909
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
29811
29910
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
29812
29911
|
} catch (err) {
|
|
29813
|
-
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) };
|
|
29814
29913
|
}
|
|
29815
29914
|
}
|
|
29816
29915
|
async function parseXls(buffer, options) {
|
|
@@ -29818,7 +29917,7 @@ async function parseXls(buffer, options) {
|
|
|
29818
29917
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
29819
29918
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
29820
29919
|
} catch (err) {
|
|
29821
|
-
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) };
|
|
29822
29921
|
}
|
|
29823
29922
|
}
|
|
29824
29923
|
async function parseDocx(buffer, options) {
|
|
@@ -29826,7 +29925,7 @@ async function parseDocx(buffer, options) {
|
|
|
29826
29925
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
29827
29926
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
|
|
29828
29927
|
} catch (err) {
|
|
29829
|
-
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) };
|
|
29830
29929
|
}
|
|
29831
29930
|
}
|
|
29832
29931
|
async function parseHwpml(buffer, options) {
|
|
@@ -29834,16 +29933,16 @@ async function parseHwpml(buffer, options) {
|
|
|
29834
29933
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
29835
29934
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
29836
29935
|
} catch (err) {
|
|
29837
|
-
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) };
|
|
29838
29937
|
}
|
|
29839
29938
|
}
|
|
29840
29939
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
29841
29940
|
let buffer;
|
|
29842
29941
|
if (typeof input === "string") {
|
|
29843
29942
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29844
|
-
buffer =
|
|
29943
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, buf);
|
|
29845
29944
|
} else if (Buffer.isBuffer(input)) {
|
|
29846
|
-
buffer =
|
|
29945
|
+
buffer = _chunkU25XGCNHcjs.toArrayBuffer.call(void 0, input);
|
|
29847
29946
|
} else {
|
|
29848
29947
|
buffer = input;
|
|
29849
29948
|
}
|
|
@@ -29869,7 +29968,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29869
29968
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
29870
29969
|
}
|
|
29871
29970
|
const fill = fillFormFields(parsed.blocks, values);
|
|
29872
|
-
const markdown =
|
|
29971
|
+
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
29873
29972
|
if (outputFormat === "hwpx") {
|
|
29874
29973
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
29875
29974
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -29938,5 +30037,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29938
30037
|
|
|
29939
30038
|
|
|
29940
30039
|
|
|
29941
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
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;
|
|
29942
30041
|
//# sourceMappingURL=index.cjs.map
|