kordoc 4.2.6 → 4.2.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/dist/{-UYYP67I6.js → -7TEU6IRU.js} +8 -8
- package/dist/{chunk-6KT4B4QX.js → chunk-2CHFQQXM.js} +2 -2
- package/dist/{chunk-64DMMXFW.js → chunk-5HFKMCAX.js} +2 -2
- package/dist/{chunk-N4BFHNLA.js → chunk-62DHK6KT.js} +2 -2
- package/dist/{chunk-NVPCKSNL.js → chunk-AES6PHIG.js} +2 -2
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-YF6JUAM7.js → chunk-ESV4KOSE.js} +3 -3
- package/dist/{chunk-EGQQVYKL.js → chunk-FSUCQ6ZM.js} +3 -3
- package/dist/{chunk-O5JOHYCV.js → chunk-G2AS6ICC.js} +2 -2
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/chunk-H7OWEYH2.cjs.map +1 -1
- package/dist/{chunk-5FS4IZWY.cjs → chunk-HH4SD5RE.cjs} +2 -2
- package/dist/chunk-HH4SD5RE.cjs.map +1 -0
- package/dist/{chunk-TZLLCYDN.js → chunk-IVX3YLQH.js} +2 -2
- package/dist/{chunk-VQ5NQBL2.js → chunk-LPRNVK4G.js} +19 -10
- package/dist/{chunk-VQ5NQBL2.js.map → chunk-LPRNVK4G.js.map} +1 -1
- package/dist/{chunk-QPPOC6OL.js → chunk-NAWC6HTC.js} +2 -2
- package/dist/{chunk-SYJ6FPPQ.js → chunk-NKERQ6GB.js} +2 -2
- package/dist/{chunk-DSCSR6NE.js → chunk-PK5GLL5C.js} +2 -2
- package/dist/{chunk-ZB3WT7XX.cjs → chunk-RS5OID2J.cjs} +9 -9
- package/dist/chunk-RS5OID2J.cjs.map +1 -0
- package/dist/{chunk-YHAB7UP6.js → chunk-T6BTWUTC.js} +2 -2
- package/dist/{chunk-6XVQSILN.cjs → chunk-VWXA47AW.cjs} +4 -4
- package/dist/chunk-VWXA47AW.cjs.map +1 -0
- package/dist/{chunk-5E7ZMWDF.js → chunk-YAQRGQUJ.js} +2 -2
- package/dist/{chunk-LIG666DX.cjs → chunk-YTRJDQ4Q.cjs} +3 -3
- package/dist/chunk-YTRJDQ4Q.cjs.map +1 -0
- package/dist/chunks-TLAOHNPB.js +10 -0
- package/dist/cli.js +16 -16
- package/dist/formula-SB3NHDUM.cjs.map +1 -1
- package/dist/{image-ocr-WN3UO4UY.js → image-ocr-OS4ETBOL.js} +4 -4
- package/dist/{image-ocr-FXLX2GM6.js → image-ocr-PGQ7JPDP.js} +4 -4
- package/dist/{image-ocr-YOUVLJIH.cjs → image-ocr-UX4QM35J.cjs} +9 -9
- package/dist/image-ocr-UX4QM35J.cjs.map +1 -0
- package/dist/index.cjs +162 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +14 -14
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-KIXK2IEX.js → parser-2JAC5WMM.js} +5 -5
- package/dist/{parser-AUMEO4OU.cjs → parser-GAZROLSA.cjs} +24 -24
- package/dist/parser-GAZROLSA.cjs.map +1 -0
- package/dist/{parser-KYSMRSMJ.js → parser-T74C7Q57.js} +5 -5
- package/dist/pdf-ocr-2SKGRXIR.cjs +13 -0
- package/dist/pdf-ocr-2SKGRXIR.cjs.map +1 -0
- package/dist/{pdf-ocr-NQFV46WZ.js → pdf-ocr-3A3QLPID.js} +4 -4
- package/dist/pdf-ocr-WBOTDQ4D.js +12 -0
- package/dist/{profile-io-NKUXEPI4.js → profile-io-6GX564CO.js} +3 -3
- package/dist/{rasterize-OT5TROD4.js → rasterize-4V7PKE7A.js} +2 -2
- package/dist/render-2AF7GZVN.js +10 -0
- package/dist/seal-2ES6UAN6.js +10 -0
- package/dist/{watch-6KMSCCM5.js → watch-JVRAAJNA.js} +8 -8
- package/package.json +1 -1
- package/dist/chunk-5FS4IZWY.cjs.map +0 -1
- package/dist/chunk-6XVQSILN.cjs.map +0 -1
- package/dist/chunk-LIG666DX.cjs.map +0 -1
- package/dist/chunk-ZB3WT7XX.cjs.map +0 -1
- package/dist/chunks-G7YDTLNI.js +0 -10
- package/dist/image-ocr-YOUVLJIH.cjs.map +0 -1
- package/dist/parser-AUMEO4OU.cjs.map +0 -1
- package/dist/pdf-ocr-2QOASWPI.js +0 -12
- package/dist/pdf-ocr-BUKZ5R4P.cjs +0 -13
- package/dist/pdf-ocr-BUKZ5R4P.cjs.map +0 -1
- package/dist/render-HQTKZ3ZE.js +0 -10
- package/dist/seal-KH6IL23B.js +0 -10
- /package/dist/{-UYYP67I6.js.map → -7TEU6IRU.js.map} +0 -0
- /package/dist/{chunk-6KT4B4QX.js.map → chunk-2CHFQQXM.js.map} +0 -0
- /package/dist/{chunk-64DMMXFW.js.map → chunk-5HFKMCAX.js.map} +0 -0
- /package/dist/{chunk-N4BFHNLA.js.map → chunk-62DHK6KT.js.map} +0 -0
- /package/dist/{chunk-NVPCKSNL.js.map → chunk-AES6PHIG.js.map} +0 -0
- /package/dist/{chunk-YF6JUAM7.js.map → chunk-ESV4KOSE.js.map} +0 -0
- /package/dist/{chunk-EGQQVYKL.js.map → chunk-FSUCQ6ZM.js.map} +0 -0
- /package/dist/{chunk-O5JOHYCV.js.map → chunk-G2AS6ICC.js.map} +0 -0
- /package/dist/{chunk-TZLLCYDN.js.map → chunk-IVX3YLQH.js.map} +0 -0
- /package/dist/{chunk-QPPOC6OL.js.map → chunk-NAWC6HTC.js.map} +0 -0
- /package/dist/{chunk-SYJ6FPPQ.js.map → chunk-NKERQ6GB.js.map} +0 -0
- /package/dist/{chunk-DSCSR6NE.js.map → chunk-PK5GLL5C.js.map} +0 -0
- /package/dist/{chunk-YHAB7UP6.js.map → chunk-T6BTWUTC.js.map} +0 -0
- /package/dist/{chunk-5E7ZMWDF.js.map → chunk-YAQRGQUJ.js.map} +0 -0
- /package/dist/{chunks-G7YDTLNI.js.map → chunks-TLAOHNPB.js.map} +0 -0
- /package/dist/{image-ocr-WN3UO4UY.js.map → image-ocr-OS4ETBOL.js.map} +0 -0
- /package/dist/{image-ocr-FXLX2GM6.js.map → image-ocr-PGQ7JPDP.js.map} +0 -0
- /package/dist/{parser-KIXK2IEX.js.map → parser-2JAC5WMM.js.map} +0 -0
- /package/dist/{parser-KYSMRSMJ.js.map → parser-T74C7Q57.js.map} +0 -0
- /package/dist/{pdf-ocr-2QOASWPI.js.map → pdf-ocr-3A3QLPID.js.map} +0 -0
- /package/dist/{pdf-ocr-NQFV46WZ.js.map → pdf-ocr-WBOTDQ4D.js.map} +0 -0
- /package/dist/{profile-io-NKUXEPI4.js.map → profile-io-6GX564CO.js.map} +0 -0
- /package/dist/{rasterize-OT5TROD4.js.map → rasterize-4V7PKE7A.js.map} +0 -0
- /package/dist/{render-HQTKZ3ZE.js.map → render-2AF7GZVN.js.map} +0 -0
- /package/dist/{seal-KH6IL23B.js.map → seal-2ES6UAN6.js.map} +0 -0
- /package/dist/{watch-6KMSCCM5.js.map → watch-JVRAAJNA.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkVWXA47AWcjs = require('./chunk-VWXA47AW.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -27,7 +27,7 @@ var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkHH4SD5REcjs = require('./chunk-HH4SD5RE.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -413,7 +413,7 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
413
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
414
414
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
415
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
416
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkHH4SD5REcjs.KordocError {
|
|
417
417
|
constructor(message) {
|
|
418
418
|
super(message);
|
|
419
419
|
this.name = "ZipBombError";
|
|
@@ -429,7 +429,7 @@ function createSectionShared() {
|
|
|
429
429
|
function createXmlParser(warnings) {
|
|
430
430
|
return new (0, _xmldom.DOMParser)({
|
|
431
431
|
onError(level, msg2) {
|
|
432
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkHH4SD5REcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
433
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -506,10 +506,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
506
506
|
const xml = await file.async("text");
|
|
507
507
|
if (decompressed) {
|
|
508
508
|
decompressed.total += xml.length * 2;
|
|
509
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
509
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
510
510
|
}
|
|
511
511
|
const parser = createXmlParser();
|
|
512
|
-
const doc = parser.parseFromString(
|
|
512
|
+
const doc = parser.parseFromString(_chunkHH4SD5REcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
513
513
|
if (!doc.documentElement) continue;
|
|
514
514
|
const domDoc = doc;
|
|
515
515
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -696,9 +696,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
696
696
|
let level = 0;
|
|
697
697
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
698
698
|
const ratio = block.style.fontSize / baseFontSize;
|
|
699
|
-
if (ratio >=
|
|
700
|
-
else if (ratio >=
|
|
701
|
-
else if (ratio >=
|
|
699
|
+
if (ratio >= _chunkHH4SD5REcjs.HEADING_RATIO_H1) level = 1;
|
|
700
|
+
else if (ratio >= _chunkHH4SD5REcjs.HEADING_RATIO_H2) level = 2;
|
|
701
|
+
else if (ratio >= _chunkHH4SD5REcjs.HEADING_RATIO_H3) level = 3;
|
|
702
702
|
}
|
|
703
703
|
const compactText = text.replace(/\s+/g, "");
|
|
704
704
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1623,7 +1623,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
function assertFiniteRange(name, value, min, max) {
|
|
1625
1625
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1626
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1627
1627
|
}
|
|
1628
1628
|
}
|
|
1629
1629
|
function validateGongmunOptions(opts) {
|
|
@@ -1638,10 +1638,10 @@ function validateGongmunOptions(opts) {
|
|
|
1638
1638
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1639
1639
|
}
|
|
1640
1640
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1641
|
-
throw new (0,
|
|
1641
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1642
1642
|
}
|
|
1643
1643
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1644
|
-
throw new (0,
|
|
1644
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1645
1645
|
}
|
|
1646
1646
|
}
|
|
1647
1647
|
if (opts.sizes) {
|
|
@@ -1650,7 +1650,7 @@ function validateGongmunOptions(opts) {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
if (opts.approval && opts.approval.length > 6) {
|
|
1653
|
-
throw new (0,
|
|
1653
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("approval must contain at most 6 labels");
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1915,7 +1915,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1915
1915
|
|
|
1916
1916
|
// src/hwpx/table-build.ts
|
|
1917
1917
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1918
|
-
const table2 =
|
|
1918
|
+
const table2 = _chunkVWXA47AWcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1919
1919
|
if (state.caption) table2.caption = state.caption;
|
|
1920
1920
|
const anchors = [];
|
|
1921
1921
|
{
|
|
@@ -1985,7 +1985,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1985
1985
|
const cell2 = parentTable.cell;
|
|
1986
1986
|
(cell2.blocks ??= []).push(block);
|
|
1987
1987
|
cell2.hasStructure = true;
|
|
1988
|
-
let flat =
|
|
1988
|
+
let flat = _chunkVWXA47AWcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1989
1989
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1990
1990
|
if (flat) {
|
|
1991
1991
|
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
@@ -2001,7 +2001,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
2001
2001
|
// src/hwpx/section-walker.ts
|
|
2002
2002
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
2003
2003
|
const parser = createXmlParser(warnings);
|
|
2004
|
-
const doc = parser.parseFromString(
|
|
2004
|
+
const doc = parser.parseFromString(_chunkHH4SD5REcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2005
2005
|
if (!doc.documentElement) return [];
|
|
2006
2006
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
2007
2007
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2107,8 +2107,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2107
2107
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2108
2108
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2109
2109
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2110
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2111
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2110
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkVWXA47AWcjs.MAX_COLS);
|
|
2111
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkVWXA47AWcjs.MAX_ROWS);
|
|
2112
2112
|
}
|
|
2113
2113
|
break;
|
|
2114
2114
|
case "p": {
|
|
@@ -2350,7 +2350,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2350
2350
|
const sink = [];
|
|
2351
2351
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2352
2352
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2353
|
-
let flat =
|
|
2353
|
+
let flat = _chunkVWXA47AWcjs.convertTableToText.call(void 0, st.rows);
|
|
2354
2354
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2355
2355
|
return flat;
|
|
2356
2356
|
}
|
|
@@ -2487,7 +2487,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2487
2487
|
let url = (ch.textContent || "").trim();
|
|
2488
2488
|
if (!url) continue;
|
|
2489
2489
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2490
|
-
const safe =
|
|
2490
|
+
const safe = _chunkHH4SD5REcjs.sanitizeHref.call(void 0, url);
|
|
2491
2491
|
if (safe) return safe;
|
|
2492
2492
|
}
|
|
2493
2493
|
return void 0;
|
|
@@ -2647,7 +2647,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2647
2647
|
case "hyperlink": {
|
|
2648
2648
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2649
2649
|
if (url) {
|
|
2650
|
-
const safe =
|
|
2650
|
+
const safe = _chunkHH4SD5REcjs.sanitizeHref.call(void 0, url);
|
|
2651
2651
|
if (safe) href = safe;
|
|
2652
2652
|
}
|
|
2653
2653
|
walk(child, depth + 1);
|
|
@@ -2921,7 +2921,7 @@ function decompressStream(data) {
|
|
|
2921
2921
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2922
2922
|
}
|
|
2923
2923
|
function parseFileHeader(data) {
|
|
2924
|
-
if (data.length < 40) throw new (0,
|
|
2924
|
+
if (data.length < 40) throw new (0, _chunkHH4SD5REcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2925
2925
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2926
2926
|
return {
|
|
2927
2927
|
signature: sig,
|
|
@@ -3370,13 +3370,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3370
3370
|
}
|
|
3371
3371
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3372
3372
|
for (const path of allCandidates) {
|
|
3373
|
-
if (
|
|
3373
|
+
if (_chunkHH4SD5REcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3374
3374
|
const file = zip.file(path);
|
|
3375
3375
|
if (!file) continue;
|
|
3376
3376
|
try {
|
|
3377
3377
|
const data = await file.async("uint8array");
|
|
3378
3378
|
decompressed.total += data.length;
|
|
3379
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3379
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3380
3380
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3381
3381
|
const mimeType = imageExtToMime(ext);
|
|
3382
3382
|
imageIndex++;
|
|
@@ -3386,7 +3386,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3386
3386
|
usedPaths.add(path);
|
|
3387
3387
|
break;
|
|
3388
3388
|
} catch (err) {
|
|
3389
|
-
if (err instanceof
|
|
3389
|
+
if (err instanceof _chunkHH4SD5REcjs.KordocError) throw err;
|
|
3390
3390
|
}
|
|
3391
3391
|
}
|
|
3392
3392
|
if (!img) _optionalChain([warnings, 'optionalAccess', _78 => _78.push, 'call', _79 => _79({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -3406,11 +3406,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3406
3406
|
if (sweepUnreferenced) {
|
|
3407
3407
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3408
3408
|
for (const file of binEntries) {
|
|
3409
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3409
|
+
if (file.dir || usedPaths.has(file.name) || _chunkHH4SD5REcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3410
3410
|
try {
|
|
3411
3411
|
const data = await file.async("uint8array");
|
|
3412
3412
|
decompressed.total += data.length;
|
|
3413
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3413
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3414
3414
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3415
3415
|
let mimeType = imageExtToMime(ext);
|
|
3416
3416
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3424,7 +3424,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3424
3424
|
images.push(img);
|
|
3425
3425
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3426
3426
|
} catch (err) {
|
|
3427
|
-
if (err instanceof
|
|
3427
|
+
if (err instanceof _chunkHH4SD5REcjs.KordocError) throw err;
|
|
3428
3428
|
_optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3429
3429
|
}
|
|
3430
3430
|
}
|
|
@@ -3475,7 +3475,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3475
3475
|
}
|
|
3476
3476
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3477
3477
|
const name = new TextDecoder().decode(nameBytes);
|
|
3478
|
-
if (
|
|
3478
|
+
if (_chunkHH4SD5REcjs.isPathTraversal.call(void 0, name)) {
|
|
3479
3479
|
pos = fileStart + compSize;
|
|
3480
3480
|
continue;
|
|
3481
3481
|
}
|
|
@@ -3493,16 +3493,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3493
3493
|
continue;
|
|
3494
3494
|
}
|
|
3495
3495
|
totalDecompressed += content.length * 2;
|
|
3496
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3496
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3497
3497
|
sectionNum++;
|
|
3498
3498
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3499
3499
|
} catch (e16) {
|
|
3500
3500
|
continue;
|
|
3501
3501
|
}
|
|
3502
3502
|
}
|
|
3503
|
-
if (blocks.length === 0) throw new (0,
|
|
3503
|
+
if (blocks.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3504
3504
|
applyPageText(blocks, shared);
|
|
3505
|
-
const markdown =
|
|
3505
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3506
3506
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3507
3507
|
}
|
|
3508
3508
|
async function readKordocLayout(zip) {
|
|
@@ -3527,18 +3527,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3527
3527
|
if (paths.length > 0) return paths;
|
|
3528
3528
|
}
|
|
3529
3529
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3530
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3530
|
+
return sectionFiles.map((f) => f.name).sort(_chunkHH4SD5REcjs.compareSectionPaths);
|
|
3531
3531
|
}
|
|
3532
3532
|
function parseSectionPathsFromManifest(xml) {
|
|
3533
3533
|
const parser = createXmlParser();
|
|
3534
|
-
const doc = parser.parseFromString(
|
|
3534
|
+
const doc = parser.parseFromString(_chunkHH4SD5REcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3535
3535
|
const items = doc.getElementsByTagName("opf:item");
|
|
3536
3536
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3537
3537
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3538
3538
|
for (let i = 0; i < items.length; i++) {
|
|
3539
3539
|
const item = items[i];
|
|
3540
3540
|
const id = item.getAttribute("id") || "";
|
|
3541
|
-
const href =
|
|
3541
|
+
const href = _chunkHH4SD5REcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3542
3542
|
if (id && href) idToHref.set(id, href);
|
|
3543
3543
|
}
|
|
3544
3544
|
if (spine.length > 0) {
|
|
@@ -3549,7 +3549,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3549
3549
|
}
|
|
3550
3550
|
if (ordered.length > 0) return ordered;
|
|
3551
3551
|
}
|
|
3552
|
-
return Array.from(idToHref.values()).sort(
|
|
3552
|
+
return Array.from(idToHref.values()).sort(_chunkHH4SD5REcjs.compareSectionPaths);
|
|
3553
3553
|
}
|
|
3554
3554
|
|
|
3555
3555
|
// src/hwpx/metadata.ts
|
|
@@ -3562,7 +3562,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3562
3562
|
const xml = await file.async("text");
|
|
3563
3563
|
if (decompressed) {
|
|
3564
3564
|
decompressed.total += xml.length * 2;
|
|
3565
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3565
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3566
3566
|
}
|
|
3567
3567
|
parseDublinCoreMetadata(xml, metadata);
|
|
3568
3568
|
if (metadata.title || metadata.author) return;
|
|
@@ -3572,7 +3572,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3572
3572
|
}
|
|
3573
3573
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3574
3574
|
const parser = createXmlParser();
|
|
3575
|
-
const doc = parser.parseFromString(
|
|
3575
|
+
const doc = parser.parseFromString(_chunkHH4SD5REcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3576
3576
|
if (!doc.documentElement) return;
|
|
3577
3577
|
const getText = (tagNames) => {
|
|
3578
3578
|
for (const tag of tagNames) {
|
|
@@ -3597,7 +3597,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3597
3597
|
|
|
3598
3598
|
// src/hwpx/parser.ts
|
|
3599
3599
|
async function parseHwpxDocument(buffer, options) {
|
|
3600
|
-
|
|
3600
|
+
_chunkHH4SD5REcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3601
3601
|
let zip;
|
|
3602
3602
|
try {
|
|
3603
3603
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3606,7 +3606,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3606
3606
|
}
|
|
3607
3607
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3608
3608
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3609
|
-
throw new (0,
|
|
3609
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3610
3610
|
}
|
|
3611
3611
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3612
3612
|
if (manifestFile) {
|
|
@@ -3618,7 +3618,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3618
3618
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3619
3619
|
}
|
|
3620
3620
|
}
|
|
3621
|
-
throw new (0,
|
|
3621
|
+
throw new (0, _chunkHH4SD5REcjs.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.");
|
|
3622
3622
|
}
|
|
3623
3623
|
}
|
|
3624
3624
|
const decompressed = { total: 0 };
|
|
@@ -3627,7 +3627,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3627
3627
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3628
3628
|
const warnings = [];
|
|
3629
3629
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3630
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3630
|
+
if (sectionPaths.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3631
3631
|
metadata.pageCount = sectionPaths.length;
|
|
3632
3632
|
const pageFilter = _optionalChain([options, 'optionalAccess', _90 => _90.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3633
3633
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3656,7 +3656,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3656
3656
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3657
3657
|
detectHwpxHeadings(blocks, styleMap);
|
|
3658
3658
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3659
|
-
const markdown =
|
|
3659
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3660
3660
|
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 };
|
|
3661
3661
|
}
|
|
3662
3662
|
|
|
@@ -4835,7 +4835,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4835
4835
|
lenientCfb = parseLenientCfb(buffer);
|
|
4836
4836
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4837
4837
|
} catch (e22) {
|
|
4838
|
-
throw new (0,
|
|
4838
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4839
4839
|
}
|
|
4840
4840
|
}
|
|
4841
4841
|
const findStream = (path) => {
|
|
@@ -4846,11 +4846,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4846
4846
|
return lenientCfb.findStream(path);
|
|
4847
4847
|
};
|
|
4848
4848
|
const headerData = findStream("/FileHeader");
|
|
4849
|
-
if (!headerData) throw new (0,
|
|
4849
|
+
if (!headerData) throw new (0, _chunkHH4SD5REcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4850
4850
|
const header = parseFileHeader(headerData);
|
|
4851
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4852
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4853
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4851
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkHH4SD5REcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4852
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4853
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkHH4SD5REcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4854
4854
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4855
4855
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4856
4856
|
const metadata = {
|
|
@@ -4859,7 +4859,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4859
4859
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4860
4860
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4861
4861
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4862
|
-
if (sections.length === 0) throw new (0,
|
|
4862
|
+
if (sections.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4863
4863
|
metadata.pageCount = sections.length;
|
|
4864
4864
|
const pageFilter = _optionalChain([options, 'optionalAccess', _95 => _95.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4865
4865
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4874,22 +4874,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4874
4874
|
const sectionData = sections[si];
|
|
4875
4875
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4876
4876
|
totalDecompressed += data.length;
|
|
4877
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4877
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4878
4878
|
const records = readRecords(data);
|
|
4879
4879
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4880
4880
|
bodyBlocks.push(...sectionBlocks);
|
|
4881
4881
|
parsedSections++;
|
|
4882
4882
|
_optionalChain([options, 'optionalAccess', _97 => _97.onProgress, 'optionalCall', _98 => _98(parsedSections, totalTarget)]);
|
|
4883
4883
|
} catch (secErr) {
|
|
4884
|
-
if (secErr instanceof
|
|
4884
|
+
if (secErr instanceof _chunkHH4SD5REcjs.KordocError) throw secErr;
|
|
4885
4885
|
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" });
|
|
4886
4886
|
}
|
|
4887
4887
|
}
|
|
4888
4888
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4889
4889
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4890
|
-
let flatBlocks =
|
|
4890
|
+
let flatBlocks = _chunkVWXA47AWcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4891
4891
|
if (_optionalChain([options, 'optionalAccess', _99 => _99.dedupeRunningHeaders])) {
|
|
4892
|
-
const deduped =
|
|
4892
|
+
const deduped = _chunkVWXA47AWcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4893
4893
|
const removed = flatBlocks.length - deduped.length;
|
|
4894
4894
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4895
4895
|
flatBlocks = deduped;
|
|
@@ -4898,10 +4898,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4898
4898
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4899
4899
|
}
|
|
4900
4900
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4901
|
-
let markdown =
|
|
4901
|
+
let markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4902
4902
|
if (_optionalChain([options, 'optionalAccess', _100 => _100.inlineImages]) && images.length > 0) {
|
|
4903
4903
|
try {
|
|
4904
|
-
markdown =
|
|
4904
|
+
markdown = _chunkVWXA47AWcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4905
4905
|
} catch (inlineErr) {
|
|
4906
4906
|
warnings.push({ message: `\uC774\uBBF8\uC9C0 \uC778\uB77C\uC778 \uC2E4\uD328 \u2014 \uC6D0\uBCF8 \uD30C\uC77C \uCC38\uC870\uB85C \uD3F4\uBC31: ${inlineErr instanceof Error ? inlineErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "SKIPPED_IMAGE" });
|
|
4907
4907
|
}
|
|
@@ -4965,9 +4965,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4965
4965
|
let level = 0;
|
|
4966
4966
|
if (_optionalChain([block, 'access', _105 => _105.style, 'optionalAccess', _106 => _106.fontSize]) && baseFontSize > 0) {
|
|
4967
4967
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4968
|
-
if (ratio >=
|
|
4969
|
-
else if (ratio >=
|
|
4970
|
-
else if (ratio >=
|
|
4968
|
+
if (ratio >= _chunkHH4SD5REcjs.HEADING_RATIO_H1) level = 1;
|
|
4969
|
+
else if (ratio >= _chunkHH4SD5REcjs.HEADING_RATIO_H2) level = 2;
|
|
4970
|
+
else if (ratio >= _chunkHH4SD5REcjs.HEADING_RATIO_H3) level = 3;
|
|
4971
4971
|
}
|
|
4972
4972
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4973
4973
|
if (level === 0) level = 2;
|
|
@@ -5052,7 +5052,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5052
5052
|
if (!raw) break;
|
|
5053
5053
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5054
5054
|
totalDecompressed += content.length;
|
|
5055
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5055
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5056
5056
|
sections.push({ idx: i, content });
|
|
5057
5057
|
}
|
|
5058
5058
|
if (sections.length === 0) {
|
|
@@ -5064,7 +5064,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5064
5064
|
if (raw) {
|
|
5065
5065
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5066
5066
|
totalDecompressed += content.length;
|
|
5067
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5067
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5068
5068
|
sections.push({ idx, content });
|
|
5069
5069
|
}
|
|
5070
5070
|
}
|
|
@@ -5081,7 +5081,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5081
5081
|
try {
|
|
5082
5082
|
const content = decryptViewText(raw, compressed);
|
|
5083
5083
|
totalDecompressed += content.length;
|
|
5084
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5084
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5085
5085
|
sections.push({ idx: i, content });
|
|
5086
5086
|
} catch (e27) {
|
|
5087
5087
|
break;
|
|
@@ -5184,7 +5184,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5184
5184
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5185
5185
|
if (!_optionalChain([ctrl, 'optionalAccess', _113 => _113.href]) || r.end <= r.start) continue;
|
|
5186
5186
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5187
|
-
const href =
|
|
5187
|
+
const href = _chunkHH4SD5REcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5188
5188
|
if (!href) continue;
|
|
5189
5189
|
const anchor = text.slice(r.start, r.end);
|
|
5190
5190
|
if (!anchor.trim()) continue;
|
|
@@ -5420,8 +5420,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5420
5420
|
let tableIdx = -1;
|
|
5421
5421
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5422
5422
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5423
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5424
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5423
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkVWXA47AWcjs.MAX_ROWS);
|
|
5424
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkVWXA47AWcjs.MAX_COLS);
|
|
5425
5425
|
tableIdx = i2;
|
|
5426
5426
|
break;
|
|
5427
5427
|
}
|
|
@@ -5470,7 +5470,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5470
5470
|
return table3;
|
|
5471
5471
|
}
|
|
5472
5472
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5473
|
-
const table2 =
|
|
5473
|
+
const table2 = _chunkVWXA47AWcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5474
5474
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5475
5475
|
return table2.rows > 0 ? table2 : null;
|
|
5476
5476
|
}
|
|
@@ -5487,8 +5487,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5487
5487
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5488
5488
|
const cs = rec.data.readUInt16LE(12);
|
|
5489
5489
|
const rs = rec.data.readUInt16LE(14);
|
|
5490
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5491
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5490
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkVWXA47AWcjs.MAX_COLS);
|
|
5491
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkVWXA47AWcjs.MAX_ROWS);
|
|
5492
5492
|
}
|
|
5493
5493
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5494
5494
|
const parts = [];
|
|
@@ -5498,7 +5498,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5498
5498
|
parts.push(``);
|
|
5499
5499
|
hasStructure = true;
|
|
5500
5500
|
} else if (b.type === "table" && b.table) {
|
|
5501
|
-
const flat =
|
|
5501
|
+
const flat = _chunkVWXA47AWcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5502
5502
|
if (flat) parts.push(flat);
|
|
5503
5503
|
hasStructure = true;
|
|
5504
5504
|
} else if (b.text) {
|
|
@@ -17993,7 +17993,7 @@ function getTextContent(el) {
|
|
|
17993
17993
|
return _nullishCoalesce(_optionalChain([el, 'access', _129 => _129.textContent, 'optionalAccess', _130 => _130.trim, 'call', _131 => _131()]), () => ( ""));
|
|
17994
17994
|
}
|
|
17995
17995
|
function parseXml(text) {
|
|
17996
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17996
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkHH4SD5REcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17997
17997
|
}
|
|
17998
17998
|
function collectRichText(root) {
|
|
17999
17999
|
let out = "";
|
|
@@ -18228,7 +18228,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18228
18228
|
cellRows.push(row);
|
|
18229
18229
|
}
|
|
18230
18230
|
if (cellRows.length > 0) {
|
|
18231
|
-
const table2 =
|
|
18231
|
+
const table2 = _chunkVWXA47AWcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18232
18232
|
if (table2.rows > 0) {
|
|
18233
18233
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18234
18234
|
}
|
|
@@ -18236,12 +18236,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18236
18236
|
return blocks;
|
|
18237
18237
|
}
|
|
18238
18238
|
async function parseXlsxDocument(buffer, options) {
|
|
18239
|
-
|
|
18239
|
+
_chunkHH4SD5REcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18240
18240
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18241
18241
|
const warnings = [];
|
|
18242
18242
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18243
18243
|
if (!workbookFile) {
|
|
18244
|
-
throw new (0,
|
|
18244
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18245
18245
|
}
|
|
18246
18246
|
let sharedStrings = [];
|
|
18247
18247
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18250,7 +18250,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18250
18250
|
}
|
|
18251
18251
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18252
18252
|
if (sheets.length === 0) {
|
|
18253
|
-
throw new (0,
|
|
18253
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18254
18254
|
}
|
|
18255
18255
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18256
18256
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18330,7 +18330,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18330
18330
|
} catch (e29) {
|
|
18331
18331
|
}
|
|
18332
18332
|
}
|
|
18333
|
-
const markdown =
|
|
18333
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18334
18334
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18335
18335
|
}
|
|
18336
18336
|
|
|
@@ -18781,11 +18781,11 @@ function processGlobals(records) {
|
|
|
18781
18781
|
const xfFmtIds = [];
|
|
18782
18782
|
const firstBof = records[0];
|
|
18783
18783
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18784
|
-
throw new (0,
|
|
18784
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18785
18785
|
}
|
|
18786
18786
|
const bof = decodeBof(firstBof.data);
|
|
18787
18787
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18788
|
-
throw new (0,
|
|
18788
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18789
18789
|
}
|
|
18790
18790
|
let i = 1;
|
|
18791
18791
|
while (i < records.length) {
|
|
@@ -18920,7 +18920,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18920
18920
|
cellRows.push(row);
|
|
18921
18921
|
}
|
|
18922
18922
|
if (cellRows.length > 0) {
|
|
18923
|
-
const table2 =
|
|
18923
|
+
const table2 = _chunkVWXA47AWcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18924
18924
|
if (table2.rows > 0) {
|
|
18925
18925
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18926
18926
|
}
|
|
@@ -18933,21 +18933,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18933
18933
|
try {
|
|
18934
18934
|
cfb = parseLenientCfb(buf);
|
|
18935
18935
|
} catch (e) {
|
|
18936
|
-
throw new (0,
|
|
18936
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
18937
18937
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18938
18938
|
);
|
|
18939
18939
|
}
|
|
18940
18940
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18941
18941
|
if (!wb) {
|
|
18942
|
-
throw new (0,
|
|
18942
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18943
18943
|
}
|
|
18944
18944
|
const records = readRecords2(wb);
|
|
18945
18945
|
if (records.length === 0) {
|
|
18946
|
-
throw new (0,
|
|
18946
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18947
18947
|
}
|
|
18948
18948
|
const firstBof = decodeBof(records[0].data);
|
|
18949
18949
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18950
|
-
throw new (0,
|
|
18950
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
18951
18951
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18952
18952
|
);
|
|
18953
18953
|
}
|
|
@@ -19015,7 +19015,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
19015
19015
|
pageCount: totalSheets
|
|
19016
19016
|
};
|
|
19017
19017
|
return {
|
|
19018
|
-
markdown:
|
|
19018
|
+
markdown: _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
19019
19019
|
blocks: allBlocks,
|
|
19020
19020
|
metadata,
|
|
19021
19021
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19471,7 +19471,7 @@ function getAttr(el, localName2) {
|
|
|
19471
19471
|
return null;
|
|
19472
19472
|
}
|
|
19473
19473
|
function parseXml2(text) {
|
|
19474
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19474
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkHH4SD5REcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19475
19475
|
}
|
|
19476
19476
|
function parseStyles(xml) {
|
|
19477
19477
|
const doc = parseXml2(xml);
|
|
@@ -19629,7 +19629,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19629
19629
|
function makeLink(text, rawHref) {
|
|
19630
19630
|
if (!text) return "";
|
|
19631
19631
|
if (!rawHref) return text;
|
|
19632
|
-
const href =
|
|
19632
|
+
const href = _chunkHH4SD5REcjs.sanitizeHref.call(void 0, rawHref);
|
|
19633
19633
|
return href ? `[${text}](${href})` : text;
|
|
19634
19634
|
}
|
|
19635
19635
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19823,7 +19823,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19823
19823
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19824
19824
|
})
|
|
19825
19825
|
);
|
|
19826
|
-
const table2 =
|
|
19826
|
+
const table2 = _chunkVWXA47AWcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19827
19827
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19828
19828
|
return { type: "table", table: table2 };
|
|
19829
19829
|
}
|
|
@@ -19925,12 +19925,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19925
19925
|
}
|
|
19926
19926
|
}
|
|
19927
19927
|
async function parseDocxDocument(buffer, options) {
|
|
19928
|
-
|
|
19928
|
+
_chunkHH4SD5REcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19929
19929
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19930
19930
|
const warnings = [];
|
|
19931
19931
|
const docFile = zip.file("word/document.xml");
|
|
19932
19932
|
if (!docFile) {
|
|
19933
|
-
throw new (0,
|
|
19933
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19934
19934
|
}
|
|
19935
19935
|
let rels = /* @__PURE__ */ new Map();
|
|
19936
19936
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19977,7 +19977,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19977
19977
|
const doc = parseXml2(docXml);
|
|
19978
19978
|
const body = findElements(doc, "body");
|
|
19979
19979
|
if (body.length === 0) {
|
|
19980
|
-
throw new (0,
|
|
19980
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19981
19981
|
}
|
|
19982
19982
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19983
19983
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -20028,7 +20028,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
20028
20028
|
}
|
|
20029
20029
|
}
|
|
20030
20030
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
20031
|
-
const markdown =
|
|
20031
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20032
20032
|
return {
|
|
20033
20033
|
markdown,
|
|
20034
20034
|
blocks,
|
|
@@ -20051,7 +20051,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20051
20051
|
}
|
|
20052
20052
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
20053
20053
|
const normalized = text.replace(/ /g, " ");
|
|
20054
|
-
const xml =
|
|
20054
|
+
const xml = _chunkHH4SD5REcjs.stripDtd.call(void 0, normalized);
|
|
20055
20055
|
const warnings = [];
|
|
20056
20056
|
const parser = new (0, _xmldom.DOMParser)({
|
|
20057
20057
|
onError: (_level, msg2) => {
|
|
@@ -20091,7 +20091,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20091
20091
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.keepTrailingEmptyCols]), () => ( false)));
|
|
20092
20092
|
}
|
|
20093
20093
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20094
|
-
const markdown =
|
|
20094
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20095
20095
|
return {
|
|
20096
20096
|
markdown,
|
|
20097
20097
|
blocks,
|
|
@@ -20236,7 +20236,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20236
20236
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20237
20237
|
cellRows[r].push(cell2);
|
|
20238
20238
|
}
|
|
20239
|
-
const table2 =
|
|
20239
|
+
const table2 = _chunkVWXA47AWcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20240
20240
|
const caption = extractShapeCaption(el);
|
|
20241
20241
|
if (caption.text && caption.before) {
|
|
20242
20242
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21618,19 +21618,19 @@ function parseCentralDirectory(buf) {
|
|
|
21618
21618
|
}
|
|
21619
21619
|
}
|
|
21620
21620
|
}
|
|
21621
|
-
if (eocdOffset < 0) throw new (0,
|
|
21621
|
+
if (eocdOffset < 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21622
21622
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21623
21623
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21624
21624
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21625
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21625
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21626
21626
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21627
|
-
throw new (0,
|
|
21627
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21628
21628
|
}
|
|
21629
21629
|
const decoder = new TextDecoder("utf-8");
|
|
21630
21630
|
const entries = [];
|
|
21631
21631
|
let pos = cdOffset;
|
|
21632
21632
|
for (let i = 0; i < totalEntries; i++) {
|
|
21633
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21633
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21634
21634
|
const flags = view.getUint16(pos + 8, true);
|
|
21635
21635
|
const method = view.getUint16(pos + 10, true);
|
|
21636
21636
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21641,7 +21641,7 @@ function parseCentralDirectory(buf) {
|
|
|
21641
21641
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21642
21642
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21643
21643
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21644
|
-
throw new (0,
|
|
21644
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21645
21645
|
}
|
|
21646
21646
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21647
21647
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21670,11 +21670,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21670
21670
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21671
21671
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21672
21672
|
for (const name of replacements.keys()) {
|
|
21673
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21673
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkHH4SD5REcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21674
21674
|
}
|
|
21675
21675
|
if (additions) {
|
|
21676
21676
|
for (const name of additions.keys()) {
|
|
21677
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21677
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkHH4SD5REcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21678
21678
|
}
|
|
21679
21679
|
}
|
|
21680
21680
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21693,7 +21693,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21693
21693
|
offset += seg.length;
|
|
21694
21694
|
continue;
|
|
21695
21695
|
}
|
|
21696
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21696
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkHH4SD5REcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21697
21697
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21698
21698
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21699
21699
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21701,7 +21701,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21701
21701
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21702
21702
|
const method = e.method;
|
|
21703
21703
|
if (method !== 0 && method !== 8) {
|
|
21704
|
-
throw new (0,
|
|
21704
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 ZIP \uC555\uCD95 \uBC29\uC2DD(method=${method}): ${e.name} \u2014 STORE(0)/DEFLATE(8)\uB9CC \uAD50\uCCB4 \uAC00\uB2A5`);
|
|
21705
21705
|
}
|
|
21706
21706
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21707
21707
|
const crc = crc32(newData);
|
|
@@ -21802,7 +21802,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21802
21802
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21803
21803
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21804
21804
|
if (sectionPaths.length === 0) {
|
|
21805
|
-
throw new (0,
|
|
21805
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21806
21806
|
}
|
|
21807
21807
|
const warnings = [];
|
|
21808
21808
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22539,7 +22539,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22539
22539
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22540
22540
|
const got = m ? Number(m[1]) : NaN;
|
|
22541
22541
|
if (got !== startId + i) {
|
|
22542
|
-
throw new (0,
|
|
22542
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
22543
22543
|
`\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)`
|
|
22544
22544
|
);
|
|
22545
22545
|
}
|
|
@@ -22623,7 +22623,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22623
22623
|
}
|
|
22624
22624
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22625
22625
|
if (rows.length !== expectedBase) {
|
|
22626
|
-
throw new (0,
|
|
22626
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
22627
22627
|
`\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`
|
|
22628
22628
|
);
|
|
22629
22629
|
}
|
|
@@ -23519,7 +23519,7 @@ function escapeGfm(text) {
|
|
|
23519
23519
|
}
|
|
23520
23520
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23521
23521
|
function sanitizeText(text) {
|
|
23522
|
-
let result =
|
|
23522
|
+
let result = _chunkVWXA47AWcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23523
23523
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23524
23524
|
const tokens = result.split(" ");
|
|
23525
23525
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23691,7 +23691,7 @@ function parseHtmlTable(raw) {
|
|
|
23691
23691
|
const cs = parseInt(_optionalChain([attrs, 'access', _285 => _285.match, 'call', _286 => _286(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _287 => _287[1]]) || "1", 10);
|
|
23692
23692
|
const rs = parseInt(_optionalChain([attrs, 'access', _288 => _288.match, 'call', _289 => _289(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _290 => _290[1]]) || "1", 10);
|
|
23693
23693
|
cellStart = m.index + m[0].length;
|
|
23694
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23694
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkVWXA47AWcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkVWXA47AWcjs.MAX_ROWS) };
|
|
23695
23695
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23696
23696
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23697
23697
|
cellStart = -1;
|
|
@@ -24347,8 +24347,8 @@ function layoutHtmlRows(rows) {
|
|
|
24347
24347
|
let c = 0;
|
|
24348
24348
|
for (const cell2 of rows[r].cells) {
|
|
24349
24349
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24350
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24351
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24350
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkVWXA47AWcjs.MAX_COLS);
|
|
24351
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkVWXA47AWcjs.MAX_ROWS);
|
|
24352
24352
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24353
24353
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24354
24354
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -25945,11 +25945,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25945
25945
|
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>`;
|
|
25946
25946
|
}
|
|
25947
25947
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25948
|
-
if (ops.length === 0) throw new (0,
|
|
25948
|
+
if (ops.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25949
25949
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25950
25950
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25951
25951
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _392 => _392.match, 'call', _393 => _393(/(\d+)\.xml$/i), 'optionalAccess', _394 => _394[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _395 => _395.match, 'call', _396 => _396(/(\d+)\.xml$/i), 'optionalAccess', _397 => _397[1]]), () => ( 0))));
|
|
25952
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25952
|
+
if (sectionPaths.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25953
25953
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25954
25954
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25955
25955
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25990,11 +25990,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25990
25990
|
const manifestItems = [];
|
|
25991
25991
|
const placed = [];
|
|
25992
25992
|
for (const op of ops) {
|
|
25993
|
-
if (!op.anchor) throw new (0,
|
|
25994
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25993
|
+
if (!op.anchor) throw new (0, _chunkHH4SD5REcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25994
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25995
25995
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25996
|
-
if (!MIME[ext]) throw new (0,
|
|
25997
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25996
|
+
if (!MIME[ext]) throw new (0, _chunkHH4SD5REcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25997
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkHH4SD5REcjs.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)`);
|
|
25998
25998
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25999
25999
|
let found = null;
|
|
26000
26000
|
let total = 0;
|
|
@@ -26027,7 +26027,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26027
26027
|
}
|
|
26028
26028
|
}
|
|
26029
26029
|
}
|
|
26030
|
-
throw new (0,
|
|
26030
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
26031
26031
|
`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)})`
|
|
26032
26032
|
);
|
|
26033
26033
|
}
|
|
@@ -26035,7 +26035,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26035
26035
|
const xml = sectionXmls[si];
|
|
26036
26036
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26037
26037
|
if (!run) {
|
|
26038
|
-
throw new (0,
|
|
26038
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26039
26039
|
}
|
|
26040
26040
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _398 => _398.charPr, 'access', _399 => _399.get, 'call', _400 => _400(run.charPr), 'optionalAccess', _401 => _401.height]), () => ( 1e3));
|
|
26041
26041
|
const fontPt = charPrHeight / 100;
|
|
@@ -26313,7 +26313,7 @@ function pick(map, keys) {
|
|
|
26313
26313
|
return out;
|
|
26314
26314
|
}
|
|
26315
26315
|
async function hwpxToProfile(input) {
|
|
26316
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26316
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkHH4SD5REcjs.toArrayBuffer.call(void 0, input);
|
|
26317
26317
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26318
26318
|
const parser = createXmlParser();
|
|
26319
26319
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _423 => _423.file, 'call', _424 => _424(/[Hh]eader\.xml$/), 'optionalAccess', _425 => _425[0]])));
|
|
@@ -27128,8 +27128,17 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27128
27128
|
if (newLines.length === 0) return 0;
|
|
27129
27129
|
const target = cell2.paragraphs[0];
|
|
27130
27130
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
27131
|
-
const
|
|
27132
|
-
|
|
27131
|
+
const value = newLines.join(" ");
|
|
27132
|
+
const xml = _optionalChain([ctx, 'access', _451 => _451.scans, 'access', _452 => _452[target.sectionIndex], 'optionalAccess', _453 => _453.xml]);
|
|
27133
|
+
const rawT = xml ? paraTText(target, xml) : null;
|
|
27134
|
+
let sp;
|
|
27135
|
+
if (xml && rawT !== null && rawT.length > 0 && rawT.trim() === "") {
|
|
27136
|
+
sp = buildRangeSplices(target, xml, 0, 0, value);
|
|
27137
|
+
if (sp === null) return skip("\uBE48 \uC140 \uACF5\uBC31 \uBCF4\uC874 \uC0BD\uC785 \uACBD\uACC4 \uBAA8\uD638 \u2014 \uC6D0\uBB38 \uC190\uC2E4 \uBC29\uC9C0\uB85C \uBBF8\uC801\uC6A9");
|
|
27138
|
+
} else {
|
|
27139
|
+
sp = buildParagraphSplices(target, value, xml);
|
|
27140
|
+
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27141
|
+
}
|
|
27133
27142
|
splices.push(...sp);
|
|
27134
27143
|
sectionIndex = target.sectionIndex;
|
|
27135
27144
|
if (newLines.length > 1) {
|
|
@@ -27232,7 +27241,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27232
27241
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27233
27242
|
if (paths.length > 0) return paths;
|
|
27234
27243
|
}
|
|
27235
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27244
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkHH4SD5REcjs.compareSectionPaths);
|
|
27236
27245
|
}
|
|
27237
27246
|
function sectionPathsFromManifest(xml) {
|
|
27238
27247
|
const attr = (tag, name) => {
|
|
@@ -27242,7 +27251,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27242
27251
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27243
27252
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27244
27253
|
const id = attr(m[1], "id");
|
|
27245
|
-
const href =
|
|
27254
|
+
const href = _chunkHH4SD5REcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27246
27255
|
if (id && href) idToHref.set(id, href);
|
|
27247
27256
|
}
|
|
27248
27257
|
const ordered = [];
|
|
@@ -27251,7 +27260,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27251
27260
|
if (href) ordered.push(href);
|
|
27252
27261
|
}
|
|
27253
27262
|
if (ordered.length > 0) return ordered;
|
|
27254
|
-
return Array.from(idToHref.values()).sort(
|
|
27263
|
+
return Array.from(idToHref.values()).sort(_chunkHH4SD5REcjs.compareSectionPaths);
|
|
27255
27264
|
}
|
|
27256
27265
|
|
|
27257
27266
|
// src/roundtrip/patcher.ts
|
|
@@ -27362,9 +27371,9 @@ function buildOrigUnits(blocks) {
|
|
|
27362
27371
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27363
27372
|
const next = blocks[i + 1];
|
|
27364
27373
|
if (_optionalChain([next, 'optionalAccess', _458 => _458.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27365
|
-
chunk =
|
|
27374
|
+
chunk = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27366
27375
|
} else {
|
|
27367
|
-
chunk =
|
|
27376
|
+
chunk = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27368
27377
|
}
|
|
27369
27378
|
if (chunk) {
|
|
27370
27379
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -28967,12 +28976,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28967
28976
|
let run = null;
|
|
28968
28977
|
const flushRun = () => {
|
|
28969
28978
|
if (!run) return;
|
|
28970
|
-
push("text", run.breadcrumb,
|
|
28979
|
+
push("text", run.breadcrumb, _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28971
28980
|
run = null;
|
|
28972
28981
|
};
|
|
28973
28982
|
for (let i = 0; i < blocks.length; i++) {
|
|
28974
28983
|
const block = blocks[i];
|
|
28975
|
-
const md2 =
|
|
28984
|
+
const md2 = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28976
28985
|
if (!md2) continue;
|
|
28977
28986
|
if (block.type === "heading") {
|
|
28978
28987
|
flushRun();
|
|
@@ -29442,13 +29451,13 @@ async function htmlToPdf(html, options) {
|
|
|
29442
29451
|
try {
|
|
29443
29452
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29444
29453
|
} catch (e32) {
|
|
29445
|
-
throw new (0,
|
|
29454
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
29446
29455
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29447
29456
|
);
|
|
29448
29457
|
}
|
|
29449
29458
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29450
29459
|
if (!executablePath) {
|
|
29451
|
-
throw new (0,
|
|
29460
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)(
|
|
29452
29461
|
"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."
|
|
29453
29462
|
);
|
|
29454
29463
|
}
|
|
@@ -29507,7 +29516,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29507
29516
|
return htmlToPdf(html, options);
|
|
29508
29517
|
}
|
|
29509
29518
|
async function blocksToPdf(blocks, options) {
|
|
29510
|
-
const markdown =
|
|
29519
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29511
29520
|
return markdownToPdf(markdown, options);
|
|
29512
29521
|
}
|
|
29513
29522
|
|
|
@@ -30401,15 +30410,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30401
30410
|
async function renderHwpxToSvg(input, options) {
|
|
30402
30411
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30403
30412
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30404
|
-
|
|
30413
|
+
_chunkHH4SD5REcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30405
30414
|
let zip;
|
|
30406
30415
|
try {
|
|
30407
30416
|
zip = await _jszip2.default.loadAsync(input);
|
|
30408
30417
|
} catch (e33) {
|
|
30409
|
-
throw new (0,
|
|
30418
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30410
30419
|
}
|
|
30411
30420
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30412
|
-
if (secFiles.length === 0) throw new (0,
|
|
30421
|
+
if (secFiles.length === 0) throw new (0, _chunkHH4SD5REcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30413
30422
|
const warnings = [];
|
|
30414
30423
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30415
30424
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30417,7 +30426,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30417
30426
|
const secXmls = [];
|
|
30418
30427
|
for (const f of secFiles) {
|
|
30419
30428
|
const xml = await f.async("string");
|
|
30420
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30429
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkHH4SD5REcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30421
30430
|
secXmls.push(xml);
|
|
30422
30431
|
}
|
|
30423
30432
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30490,9 +30499,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30490
30499
|
}
|
|
30491
30500
|
if (rendered.length === 0) {
|
|
30492
30501
|
if (noCacheSkipped) {
|
|
30493
|
-
throw new (0,
|
|
30502
|
+
throw new (0, _chunkHH4SD5REcjs.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)");
|
|
30494
30503
|
}
|
|
30495
|
-
throw new (0,
|
|
30504
|
+
throw new (0, _chunkHH4SD5REcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30496
30505
|
}
|
|
30497
30506
|
const GAP = 2400;
|
|
30498
30507
|
const clipDefs = [];
|
|
@@ -30528,13 +30537,13 @@ async function parse(input, options) {
|
|
|
30528
30537
|
if (typeof input === "string") {
|
|
30529
30538
|
try {
|
|
30530
30539
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30531
|
-
buffer =
|
|
30540
|
+
buffer = _chunkHH4SD5REcjs.toArrayBuffer.call(void 0, buf);
|
|
30532
30541
|
} catch (err) {
|
|
30533
30542
|
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}`;
|
|
30534
30543
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30535
30544
|
}
|
|
30536
30545
|
} else if (Buffer.isBuffer(input)) {
|
|
30537
|
-
buffer =
|
|
30546
|
+
buffer = _chunkHH4SD5REcjs.toArrayBuffer.call(void 0, input);
|
|
30538
30547
|
} else {
|
|
30539
30548
|
buffer = input;
|
|
30540
30549
|
}
|
|
@@ -30568,18 +30577,18 @@ async function parse(input, options) {
|
|
|
30568
30577
|
}
|
|
30569
30578
|
async function parseImage(buffer, options) {
|
|
30570
30579
|
try {
|
|
30571
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
30580
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-UX4QM35J.cjs")));
|
|
30572
30581
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30573
30582
|
return {
|
|
30574
30583
|
success: true,
|
|
30575
30584
|
fileType: "image",
|
|
30576
|
-
markdown:
|
|
30585
|
+
markdown: _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30577
30586
|
blocks,
|
|
30578
30587
|
warnings: warnings.length ? warnings : void 0,
|
|
30579
30588
|
pageCount: 1
|
|
30580
30589
|
};
|
|
30581
30590
|
} catch (err) {
|
|
30582
|
-
return { success: false, fileType: "image", error:
|
|
30591
|
+
return { success: false, fileType: "image", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30583
30592
|
}
|
|
30584
30593
|
}
|
|
30585
30594
|
async function parseHwp3(buffer, options) {
|
|
@@ -30587,7 +30596,7 @@ async function parseHwp3(buffer, options) {
|
|
|
30587
30596
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30588
30597
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30589
30598
|
} catch (err) {
|
|
30590
|
-
return { success: false, fileType: "hwp3", error:
|
|
30599
|
+
return { success: false, fileType: "hwp3", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30591
30600
|
}
|
|
30592
30601
|
}
|
|
30593
30602
|
async function parseHwpx(buffer, options) {
|
|
@@ -30595,7 +30604,7 @@ async function parseHwpx(buffer, options) {
|
|
|
30595
30604
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30596
30605
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _562 => _562.length]) ? images : void 0 };
|
|
30597
30606
|
} catch (err) {
|
|
30598
|
-
return { success: false, fileType: "hwpx", error:
|
|
30607
|
+
return { success: false, fileType: "hwpx", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30599
30608
|
}
|
|
30600
30609
|
}
|
|
30601
30610
|
async function parseHwp(buffer, options) {
|
|
@@ -30620,13 +30629,13 @@ async function parseHwp(buffer, options) {
|
|
|
30620
30629
|
}
|
|
30621
30630
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _564 => _564.length]) ? images : void 0 };
|
|
30622
30631
|
} catch (err) {
|
|
30623
|
-
return { success: false, fileType: "hwp", error:
|
|
30632
|
+
return { success: false, fileType: "hwp", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30624
30633
|
}
|
|
30625
30634
|
}
|
|
30626
30635
|
async function parsePdf(buffer, options) {
|
|
30627
30636
|
let parsePdfDocument;
|
|
30628
30637
|
try {
|
|
30629
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30638
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-GAZROLSA.cjs")));
|
|
30630
30639
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30631
30640
|
} catch (e35) {
|
|
30632
30641
|
return {
|
|
@@ -30641,7 +30650,7 @@ async function parsePdf(buffer, options) {
|
|
|
30641
30650
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30642
30651
|
} catch (err) {
|
|
30643
30652
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30644
|
-
return { success: false, fileType: "pdf", error:
|
|
30653
|
+
return { success: false, fileType: "pdf", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err), isImageBased };
|
|
30645
30654
|
}
|
|
30646
30655
|
}
|
|
30647
30656
|
async function parseXlsx(buffer, options) {
|
|
@@ -30649,7 +30658,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30649
30658
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30650
30659
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30651
30660
|
} catch (err) {
|
|
30652
|
-
return { success: false, fileType: "xlsx", error:
|
|
30661
|
+
return { success: false, fileType: "xlsx", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30653
30662
|
}
|
|
30654
30663
|
}
|
|
30655
30664
|
async function parseXls(buffer, options) {
|
|
@@ -30657,7 +30666,7 @@ async function parseXls(buffer, options) {
|
|
|
30657
30666
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30658
30667
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30659
30668
|
} catch (err) {
|
|
30660
|
-
return { success: false, fileType: "xls", error:
|
|
30669
|
+
return { success: false, fileType: "xls", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30661
30670
|
}
|
|
30662
30671
|
}
|
|
30663
30672
|
async function parseDocx(buffer, options) {
|
|
@@ -30665,7 +30674,7 @@ async function parseDocx(buffer, options) {
|
|
|
30665
30674
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30666
30675
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _565 => _565.length]) ? images : void 0 };
|
|
30667
30676
|
} catch (err) {
|
|
30668
|
-
return { success: false, fileType: "docx", error:
|
|
30677
|
+
return { success: false, fileType: "docx", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30669
30678
|
}
|
|
30670
30679
|
}
|
|
30671
30680
|
async function parseHwpml(buffer, options) {
|
|
@@ -30673,16 +30682,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30673
30682
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30674
30683
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30675
30684
|
} catch (err) {
|
|
30676
|
-
return { success: false, fileType: "hwpml", error:
|
|
30685
|
+
return { success: false, fileType: "hwpml", error: _chunkHH4SD5REcjs.sanitizeError.call(void 0, err), code: _chunkHH4SD5REcjs.classifyError.call(void 0, err) };
|
|
30677
30686
|
}
|
|
30678
30687
|
}
|
|
30679
30688
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30680
30689
|
let buffer;
|
|
30681
30690
|
if (typeof input === "string") {
|
|
30682
30691
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30683
|
-
buffer =
|
|
30692
|
+
buffer = _chunkHH4SD5REcjs.toArrayBuffer.call(void 0, buf);
|
|
30684
30693
|
} else if (Buffer.isBuffer(input)) {
|
|
30685
|
-
buffer =
|
|
30694
|
+
buffer = _chunkHH4SD5REcjs.toArrayBuffer.call(void 0, input);
|
|
30686
30695
|
} else {
|
|
30687
30696
|
buffer = input;
|
|
30688
30697
|
}
|
|
@@ -30708,7 +30717,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30708
30717
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30709
30718
|
}
|
|
30710
30719
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30711
|
-
const markdown =
|
|
30720
|
+
const markdown = _chunkVWXA47AWcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30712
30721
|
if (outputFormat === "hwpx") {
|
|
30713
30722
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30714
30723
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30782,5 +30791,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30782
30791
|
|
|
30783
30792
|
|
|
30784
30793
|
|
|
30785
|
-
exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
30794
|
+
exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkHH4SD5REcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkVWXA47AWcjs.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.parseImage = parseImage; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
30786
30795
|
//# sourceMappingURL=index.cjs.map
|