kordoc 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-MSRLLJNM.js → -RAVJL5UK.js} +3 -3
- package/dist/{chunk-7KFBGOXZ.js → chunk-ESBGMBRF.js} +2 -2
- package/dist/{chunk-SWEBVX5K.cjs → chunk-FUB2BGXV.cjs} +2 -2
- package/dist/{chunk-SWEBVX5K.cjs.map → chunk-FUB2BGXV.cjs.map} +1 -1
- package/dist/{chunk-ZWVTR2HQ.js → chunk-HNUFTEV5.js} +2 -2
- package/dist/{chunk-CYLOXVYY.js → chunk-J72F7FIT.js} +13 -3
- package/dist/{chunk-CYLOXVYY.js.map → chunk-J72F7FIT.js.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +116 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +59 -4
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-U6KRTEB7.js → parser-DADWQYCQ.js} +2 -2
- package/dist/{parser-HAWIRFS4.js → parser-FLE2ZPAW.js} +2 -2
- package/dist/{parser-LKIUKZJV.cjs → parser-YWKNDGKI.cjs} +14 -14
- package/dist/{parser-LKIUKZJV.cjs.map → parser-YWKNDGKI.cjs.map} +1 -1
- package/dist/{watch-OKZAU3I5.js → watch-6QPQU277.js} +3 -3
- package/package.json +1 -1
- /package/dist/{-MSRLLJNM.js.map → -RAVJL5UK.js.map} +0 -0
- /package/dist/{chunk-7KFBGOXZ.js.map → chunk-ESBGMBRF.js.map} +0 -0
- /package/dist/{chunk-ZWVTR2HQ.js.map → chunk-HNUFTEV5.js.map} +0 -0
- /package/dist/{parser-U6KRTEB7.js.map → parser-DADWQYCQ.js.map} +0 -0
- /package/dist/{parser-HAWIRFS4.js.map → parser-FLE2ZPAW.js.map} +0 -0
- /package/dist/{watch-OKZAU3I5.js.map → watch-6QPQU277.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkFUB2BGXVcjs = require('./chunk-FUB2BGXV.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -828,7 +828,7 @@ function createSectionShared() {
|
|
|
828
828
|
function createXmlParser(warnings) {
|
|
829
829
|
return new (0, _xmldom.DOMParser)({
|
|
830
830
|
onError(level, msg2) {
|
|
831
|
-
if (level === "fatalError") throw new (0,
|
|
831
|
+
if (level === "fatalError") throw new (0, _chunkFUB2BGXVcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
832
832
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
833
833
|
}
|
|
834
834
|
});
|
|
@@ -850,10 +850,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
850
850
|
const xml = await file.async("text");
|
|
851
851
|
if (decompressed) {
|
|
852
852
|
decompressed.total += xml.length * 2;
|
|
853
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
853
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
854
854
|
}
|
|
855
855
|
const parser = createXmlParser();
|
|
856
|
-
const doc = parser.parseFromString(
|
|
856
|
+
const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
857
857
|
if (!doc.documentElement) continue;
|
|
858
858
|
parseCharProperties(doc, result.charProperties);
|
|
859
859
|
parseStyleElements(doc, result.styles);
|
|
@@ -1075,7 +1075,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1075
1075
|
return { prefix, headingLevel };
|
|
1076
1076
|
}
|
|
1077
1077
|
async function parseHwpxDocument(buffer, options) {
|
|
1078
|
-
|
|
1078
|
+
_chunkFUB2BGXVcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
1079
1079
|
let zip;
|
|
1080
1080
|
try {
|
|
1081
1081
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -1084,7 +1084,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
1086
1086
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
1087
|
-
throw new (0,
|
|
1087
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1088
1088
|
}
|
|
1089
1089
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
1090
1090
|
if (manifestFile) {
|
|
@@ -1096,7 +1096,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1096
1096
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
|
-
throw new (0,
|
|
1099
|
+
throw new (0, _chunkFUB2BGXVcjs.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.");
|
|
1100
1100
|
}
|
|
1101
1101
|
}
|
|
1102
1102
|
const decompressed = { total: 0 };
|
|
@@ -1105,7 +1105,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1105
1105
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
1106
1106
|
const warnings = [];
|
|
1107
1107
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
1108
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
1108
|
+
if (sectionPaths.length === 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1109
1109
|
metadata.pageCount = sectionPaths.length;
|
|
1110
1110
|
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
1111
1111
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -1119,12 +1119,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1119
1119
|
try {
|
|
1120
1120
|
const xml = await file.async("text");
|
|
1121
1121
|
decompressed.total += xml.length * 2;
|
|
1122
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1122
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1123
1123
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
1124
1124
|
parsedSections++;
|
|
1125
1125
|
_optionalChain([options, 'optionalAccess', _13 => _13.onProgress, 'optionalCall', _14 => _14(parsedSections, totalTarget)]);
|
|
1126
1126
|
} catch (secErr) {
|
|
1127
|
-
if (secErr instanceof
|
|
1127
|
+
if (secErr instanceof _chunkFUB2BGXVcjs.KordocError) throw secErr;
|
|
1128
1128
|
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" });
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
@@ -1132,7 +1132,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1132
1132
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
1133
1133
|
detectHwpxHeadings(blocks, styleMap);
|
|
1134
1134
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
1135
|
-
const markdown =
|
|
1135
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1136
1136
|
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 };
|
|
1137
1137
|
}
|
|
1138
1138
|
function applyPageText(blocks, shared) {
|
|
@@ -1221,13 +1221,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1221
1221
|
let found = false;
|
|
1222
1222
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1223
1223
|
for (const path of allCandidates) {
|
|
1224
|
-
if (
|
|
1224
|
+
if (_chunkFUB2BGXVcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1225
1225
|
const file = zip.file(path);
|
|
1226
1226
|
if (!file) continue;
|
|
1227
1227
|
try {
|
|
1228
1228
|
const data = await file.async("uint8array");
|
|
1229
1229
|
decompressed.total += data.length;
|
|
1230
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1230
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1231
1231
|
const actualPath = path;
|
|
1232
1232
|
const ext = actualPath.includes(".") ? actualPath.split(".").pop() || "png" : "png";
|
|
1233
1233
|
const mimeType = imageExtToMime(ext);
|
|
@@ -1240,7 +1240,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1240
1240
|
found = true;
|
|
1241
1241
|
break;
|
|
1242
1242
|
} catch (err) {
|
|
1243
|
-
if (err instanceof
|
|
1243
|
+
if (err instanceof _chunkFUB2BGXVcjs.KordocError) throw err;
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
1246
|
if (!found) {
|
|
@@ -1261,7 +1261,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
1261
1261
|
const xml = await file.async("text");
|
|
1262
1262
|
if (decompressed) {
|
|
1263
1263
|
decompressed.total += xml.length * 2;
|
|
1264
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1264
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1265
1265
|
}
|
|
1266
1266
|
parseDublinCoreMetadata(xml, metadata);
|
|
1267
1267
|
if (metadata.title || metadata.author) return;
|
|
@@ -1271,7 +1271,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
1271
1271
|
}
|
|
1272
1272
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
1273
1273
|
const parser = createXmlParser();
|
|
1274
|
-
const doc = parser.parseFromString(
|
|
1274
|
+
const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1275
1275
|
if (!doc.documentElement) return;
|
|
1276
1276
|
const getText = (tagNames) => {
|
|
1277
1277
|
for (const tag of tagNames) {
|
|
@@ -1331,7 +1331,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1331
1331
|
}
|
|
1332
1332
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1333
1333
|
const name = new TextDecoder().decode(nameBytes);
|
|
1334
|
-
if (
|
|
1334
|
+
if (_chunkFUB2BGXVcjs.isPathTraversal.call(void 0, name)) {
|
|
1335
1335
|
pos = fileStart + compSize;
|
|
1336
1336
|
continue;
|
|
1337
1337
|
}
|
|
@@ -1349,16 +1349,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1349
1349
|
continue;
|
|
1350
1350
|
}
|
|
1351
1351
|
totalDecompressed += content.length * 2;
|
|
1352
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1352
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1353
1353
|
sectionNum++;
|
|
1354
1354
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1355
1355
|
} catch (e13) {
|
|
1356
1356
|
continue;
|
|
1357
1357
|
}
|
|
1358
1358
|
}
|
|
1359
|
-
if (blocks.length === 0) throw new (0,
|
|
1359
|
+
if (blocks.length === 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1360
1360
|
applyPageText(blocks, shared);
|
|
1361
|
-
const markdown =
|
|
1361
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1362
1362
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1363
1363
|
}
|
|
1364
1364
|
async function resolveSectionPaths(zip) {
|
|
@@ -1376,7 +1376,7 @@ async function resolveSectionPaths(zip) {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
function parseSectionPathsFromManifest(xml) {
|
|
1378
1378
|
const parser = createXmlParser();
|
|
1379
|
-
const doc = parser.parseFromString(
|
|
1379
|
+
const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1380
1380
|
const items = doc.getElementsByTagName("opf:item");
|
|
1381
1381
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
1382
1382
|
const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
|
|
@@ -1424,9 +1424,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
1424
1424
|
let level = 0;
|
|
1425
1425
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _25 => _25.style, 'optionalAccess', _26 => _26.fontSize])) {
|
|
1426
1426
|
const ratio = block.style.fontSize / baseFontSize;
|
|
1427
|
-
if (ratio >=
|
|
1428
|
-
else if (ratio >=
|
|
1429
|
-
else if (ratio >=
|
|
1427
|
+
if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H1) level = 1;
|
|
1428
|
+
else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H2) level = 2;
|
|
1429
|
+
else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H3) level = 3;
|
|
1430
1430
|
}
|
|
1431
1431
|
const compactText = text.replace(/\s+/g, "");
|
|
1432
1432
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1439,7 +1439,7 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
1441
|
function buildTableWithCellMeta(state) {
|
|
1442
|
-
const table =
|
|
1442
|
+
const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, state.rows);
|
|
1443
1443
|
if (state.caption) table.caption = state.caption;
|
|
1444
1444
|
const claimed = /* @__PURE__ */ new Set();
|
|
1445
1445
|
for (const row of state.rows) {
|
|
@@ -1482,7 +1482,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1482
1482
|
const cell = parentTable.cell;
|
|
1483
1483
|
(cell.blocks ??= []).push(block);
|
|
1484
1484
|
cell.hasStructure = true;
|
|
1485
|
-
let flat =
|
|
1485
|
+
let flat = _chunkFUB2BGXVcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1486
1486
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1487
1487
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1488
1488
|
} else {
|
|
@@ -1492,7 +1492,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1492
1492
|
}
|
|
1493
1493
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1494
1494
|
const parser = createXmlParser(warnings);
|
|
1495
|
-
const doc = parser.parseFromString(
|
|
1495
|
+
const doc = parser.parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1496
1496
|
if (!doc.documentElement) return [];
|
|
1497
1497
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1498
1498
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1583,8 +1583,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1583
1583
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1584
1584
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1585
1585
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1586
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1587
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1586
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkFUB2BGXVcjs.MAX_COLS);
|
|
1587
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkFUB2BGXVcjs.MAX_ROWS);
|
|
1588
1588
|
}
|
|
1589
1589
|
break;
|
|
1590
1590
|
case "p": {
|
|
@@ -1806,7 +1806,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1806
1806
|
let url = (ch.textContent || "").trim();
|
|
1807
1807
|
if (!url) continue;
|
|
1808
1808
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1809
|
-
const safe =
|
|
1809
|
+
const safe = _chunkFUB2BGXVcjs.sanitizeHref.call(void 0, url);
|
|
1810
1810
|
if (safe) return safe;
|
|
1811
1811
|
}
|
|
1812
1812
|
return void 0;
|
|
@@ -1941,7 +1941,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1941
1941
|
case "hyperlink": {
|
|
1942
1942
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1943
1943
|
if (url) {
|
|
1944
|
-
const safe =
|
|
1944
|
+
const safe = _chunkFUB2BGXVcjs.sanitizeHref.call(void 0, url);
|
|
1945
1945
|
if (safe) href = safe;
|
|
1946
1946
|
}
|
|
1947
1947
|
walk(child);
|
|
@@ -2131,7 +2131,7 @@ function decompressStream(data) {
|
|
|
2131
2131
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2132
2132
|
}
|
|
2133
2133
|
function parseFileHeader(data) {
|
|
2134
|
-
if (data.length < 40) throw new (0,
|
|
2134
|
+
if (data.length < 40) throw new (0, _chunkFUB2BGXVcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2135
2135
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2136
2136
|
return {
|
|
2137
2137
|
signature: sig,
|
|
@@ -3655,7 +3655,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3655
3655
|
lenientCfb = parseLenientCfb(buffer);
|
|
3656
3656
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3657
3657
|
} catch (e20) {
|
|
3658
|
-
throw new (0,
|
|
3658
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3659
3659
|
}
|
|
3660
3660
|
}
|
|
3661
3661
|
const findStream = (path) => {
|
|
@@ -3666,11 +3666,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3666
3666
|
return lenientCfb.findStream(path);
|
|
3667
3667
|
};
|
|
3668
3668
|
const headerData = findStream("/FileHeader");
|
|
3669
|
-
if (!headerData) throw new (0,
|
|
3669
|
+
if (!headerData) throw new (0, _chunkFUB2BGXVcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3670
3670
|
const header = parseFileHeader(headerData);
|
|
3671
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3672
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3673
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3671
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkFUB2BGXVcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3672
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3673
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkFUB2BGXVcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3674
3674
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3675
3675
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3676
3676
|
const metadata = {
|
|
@@ -3679,7 +3679,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3679
3679
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3680
3680
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3681
3681
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3682
|
-
if (sections.length === 0) throw new (0,
|
|
3682
|
+
if (sections.length === 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3683
3683
|
metadata.pageCount = sections.length;
|
|
3684
3684
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3685
3685
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3693,25 +3693,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3693
3693
|
const sectionData = sections[si];
|
|
3694
3694
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3695
3695
|
totalDecompressed += data.length;
|
|
3696
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3696
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3697
3697
|
const records = readRecords(data);
|
|
3698
3698
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3699
3699
|
bodyBlocks.push(...sectionBlocks);
|
|
3700
3700
|
parsedSections++;
|
|
3701
3701
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3702
3702
|
} catch (secErr) {
|
|
3703
|
-
if (secErr instanceof
|
|
3703
|
+
if (secErr instanceof _chunkFUB2BGXVcjs.KordocError) throw secErr;
|
|
3704
3704
|
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" });
|
|
3705
3705
|
}
|
|
3706
3706
|
}
|
|
3707
3707
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3708
3708
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3709
|
-
const flatBlocks =
|
|
3709
|
+
const flatBlocks = _chunkFUB2BGXVcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3710
3710
|
if (docInfo) {
|
|
3711
3711
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3712
3712
|
}
|
|
3713
3713
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3714
|
-
const markdown =
|
|
3714
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3715
3715
|
return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3716
3716
|
}
|
|
3717
3717
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3771,9 +3771,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3771
3771
|
let level = 0;
|
|
3772
3772
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3773
3773
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3774
|
-
if (ratio >=
|
|
3775
|
-
else if (ratio >=
|
|
3776
|
-
else if (ratio >=
|
|
3774
|
+
if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H1) level = 1;
|
|
3775
|
+
else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H2) level = 2;
|
|
3776
|
+
else if (ratio >= _chunkFUB2BGXVcjs.HEADING_RATIO_H3) level = 3;
|
|
3777
3777
|
}
|
|
3778
3778
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3779
3779
|
if (level === 0) level = 2;
|
|
@@ -3858,7 +3858,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3858
3858
|
if (!raw) break;
|
|
3859
3859
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3860
3860
|
totalDecompressed += content.length;
|
|
3861
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3861
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3862
3862
|
sections.push({ idx: i, content });
|
|
3863
3863
|
}
|
|
3864
3864
|
if (sections.length === 0) {
|
|
@@ -3870,7 +3870,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3870
3870
|
if (raw) {
|
|
3871
3871
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3872
3872
|
totalDecompressed += content.length;
|
|
3873
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3873
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3874
3874
|
sections.push({ idx, content });
|
|
3875
3875
|
}
|
|
3876
3876
|
}
|
|
@@ -3887,7 +3887,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3887
3887
|
try {
|
|
3888
3888
|
const content = decryptViewText(raw, compressed);
|
|
3889
3889
|
totalDecompressed += content.length;
|
|
3890
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3890
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3891
3891
|
sections.push({ idx: i, content });
|
|
3892
3892
|
} catch (e25) {
|
|
3893
3893
|
break;
|
|
@@ -3990,7 +3990,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
3990
3990
|
const ctrl = ctrls[r.ctrlIdx];
|
|
3991
3991
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
3992
3992
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
3993
|
-
const href =
|
|
3993
|
+
const href = _chunkFUB2BGXVcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
3994
3994
|
if (!href) continue;
|
|
3995
3995
|
const anchor = text.slice(r.start, r.end);
|
|
3996
3996
|
if (!anchor.trim()) continue;
|
|
@@ -4223,8 +4223,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4223
4223
|
let tableIdx = -1;
|
|
4224
4224
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4225
4225
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4226
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4227
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4226
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkFUB2BGXVcjs.MAX_ROWS);
|
|
4227
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkFUB2BGXVcjs.MAX_COLS);
|
|
4228
4228
|
tableIdx = i2;
|
|
4229
4229
|
break;
|
|
4230
4230
|
}
|
|
@@ -4273,7 +4273,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4273
4273
|
return table2;
|
|
4274
4274
|
}
|
|
4275
4275
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4276
|
-
const table =
|
|
4276
|
+
const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
|
|
4277
4277
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4278
4278
|
return table.rows > 0 ? table : null;
|
|
4279
4279
|
}
|
|
@@ -4290,8 +4290,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4290
4290
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4291
4291
|
const cs = rec.data.readUInt16LE(12);
|
|
4292
4292
|
const rs = rec.data.readUInt16LE(14);
|
|
4293
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4294
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4293
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkFUB2BGXVcjs.MAX_COLS);
|
|
4294
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkFUB2BGXVcjs.MAX_ROWS);
|
|
4295
4295
|
}
|
|
4296
4296
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4297
4297
|
const parts = [];
|
|
@@ -4301,7 +4301,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4301
4301
|
parts.push(``);
|
|
4302
4302
|
hasStructure = true;
|
|
4303
4303
|
} else if (b.type === "table" && b.table) {
|
|
4304
|
-
const flat =
|
|
4304
|
+
const flat = _chunkFUB2BGXVcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4305
4305
|
if (flat) parts.push(flat);
|
|
4306
4306
|
hasStructure = true;
|
|
4307
4307
|
} else if (b.text) {
|
|
@@ -16735,7 +16735,7 @@ function getTextContent(el) {
|
|
|
16735
16735
|
return _nullishCoalesce(_optionalChain([el, 'access', _79 => _79.textContent, 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]), () => ( ""));
|
|
16736
16736
|
}
|
|
16737
16737
|
function parseXml(text) {
|
|
16738
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16738
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16739
16739
|
}
|
|
16740
16740
|
function parseSharedStrings(xml) {
|
|
16741
16741
|
const doc = parseXml(xml);
|
|
@@ -16879,7 +16879,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16879
16879
|
cellRows.push(row);
|
|
16880
16880
|
}
|
|
16881
16881
|
if (cellRows.length > 0) {
|
|
16882
|
-
const table =
|
|
16882
|
+
const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
|
|
16883
16883
|
if (table.rows > 0) {
|
|
16884
16884
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16885
16885
|
}
|
|
@@ -16887,12 +16887,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16887
16887
|
return blocks;
|
|
16888
16888
|
}
|
|
16889
16889
|
async function parseXlsxDocument(buffer, options) {
|
|
16890
|
-
|
|
16890
|
+
_chunkFUB2BGXVcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16891
16891
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16892
16892
|
const warnings = [];
|
|
16893
16893
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16894
16894
|
if (!workbookFile) {
|
|
16895
|
-
throw new (0,
|
|
16895
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16896
16896
|
}
|
|
16897
16897
|
let sharedStrings = [];
|
|
16898
16898
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16901,7 +16901,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16901
16901
|
}
|
|
16902
16902
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16903
16903
|
if (sheets.length === 0) {
|
|
16904
|
-
throw new (0,
|
|
16904
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16905
16905
|
}
|
|
16906
16906
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16907
16907
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16973,7 +16973,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16973
16973
|
} catch (e26) {
|
|
16974
16974
|
}
|
|
16975
16975
|
}
|
|
16976
|
-
const markdown =
|
|
16976
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
|
|
16977
16977
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
16978
16978
|
}
|
|
16979
16979
|
|
|
@@ -17380,11 +17380,11 @@ function processGlobals(records) {
|
|
|
17380
17380
|
let encrypted = false;
|
|
17381
17381
|
const firstBof = records[0];
|
|
17382
17382
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17383
|
-
throw new (0,
|
|
17383
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17384
17384
|
}
|
|
17385
17385
|
const bof = decodeBof(firstBof.data);
|
|
17386
17386
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17387
|
-
throw new (0,
|
|
17387
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17388
17388
|
}
|
|
17389
17389
|
let i = 1;
|
|
17390
17390
|
while (i < records.length) {
|
|
@@ -17499,7 +17499,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17499
17499
|
cellRows.push(row);
|
|
17500
17500
|
}
|
|
17501
17501
|
if (cellRows.length > 0) {
|
|
17502
|
-
const table =
|
|
17502
|
+
const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
|
|
17503
17503
|
if (table.rows > 0) {
|
|
17504
17504
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17505
17505
|
}
|
|
@@ -17512,21 +17512,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17512
17512
|
try {
|
|
17513
17513
|
cfb = parseLenientCfb(buf);
|
|
17514
17514
|
} catch (e) {
|
|
17515
|
-
throw new (0,
|
|
17515
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)(
|
|
17516
17516
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17517
17517
|
);
|
|
17518
17518
|
}
|
|
17519
17519
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17520
17520
|
if (!wb) {
|
|
17521
|
-
throw new (0,
|
|
17521
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17522
17522
|
}
|
|
17523
17523
|
const records = readRecords2(wb);
|
|
17524
17524
|
if (records.length === 0) {
|
|
17525
|
-
throw new (0,
|
|
17525
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17526
17526
|
}
|
|
17527
17527
|
const firstBof = decodeBof(records[0].data);
|
|
17528
17528
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17529
|
-
throw new (0,
|
|
17529
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)(
|
|
17530
17530
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17531
17531
|
);
|
|
17532
17532
|
}
|
|
@@ -17586,7 +17586,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17586
17586
|
pageCount: totalSheets
|
|
17587
17587
|
};
|
|
17588
17588
|
return {
|
|
17589
|
-
markdown:
|
|
17589
|
+
markdown: _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17590
17590
|
blocks: allBlocks,
|
|
17591
17591
|
metadata,
|
|
17592
17592
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18012,7 +18012,7 @@ function getAttr(el, localName2) {
|
|
|
18012
18012
|
return null;
|
|
18013
18013
|
}
|
|
18014
18014
|
function parseXml2(text) {
|
|
18015
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18015
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkFUB2BGXVcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18016
18016
|
}
|
|
18017
18017
|
function parseStyles(xml) {
|
|
18018
18018
|
const doc = parseXml2(xml);
|
|
@@ -18331,12 +18331,12 @@ async function extractImages(zip, rels, doc) {
|
|
|
18331
18331
|
return { blocks, images };
|
|
18332
18332
|
}
|
|
18333
18333
|
async function parseDocxDocument(buffer, options) {
|
|
18334
|
-
|
|
18334
|
+
_chunkFUB2BGXVcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18335
18335
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18336
18336
|
const warnings = [];
|
|
18337
18337
|
const docFile = zip.file("word/document.xml");
|
|
18338
18338
|
if (!docFile) {
|
|
18339
|
-
throw new (0,
|
|
18339
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18340
18340
|
}
|
|
18341
18341
|
let rels = /* @__PURE__ */ new Map();
|
|
18342
18342
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18371,7 +18371,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18371
18371
|
const doc = parseXml2(docXml);
|
|
18372
18372
|
const body = findElements(doc, "body");
|
|
18373
18373
|
if (body.length === 0) {
|
|
18374
|
-
throw new (0,
|
|
18374
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18375
18375
|
}
|
|
18376
18376
|
const blocks = [];
|
|
18377
18377
|
const bodyEl = body[0];
|
|
@@ -18411,7 +18411,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18411
18411
|
}
|
|
18412
18412
|
}
|
|
18413
18413
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18414
|
-
const markdown =
|
|
18414
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18415
18415
|
return {
|
|
18416
18416
|
markdown,
|
|
18417
18417
|
blocks,
|
|
@@ -18434,7 +18434,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18434
18434
|
}
|
|
18435
18435
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18436
18436
|
const normalized = text.replace(/ /g, " ");
|
|
18437
|
-
const xml =
|
|
18437
|
+
const xml = _chunkFUB2BGXVcjs.stripDtd.call(void 0, normalized);
|
|
18438
18438
|
const warnings = [];
|
|
18439
18439
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18440
18440
|
onError: (_level, msg2) => {
|
|
@@ -18474,7 +18474,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18474
18474
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18475
18475
|
}
|
|
18476
18476
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18477
|
-
const markdown =
|
|
18477
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18478
18478
|
return {
|
|
18479
18479
|
markdown,
|
|
18480
18480
|
blocks,
|
|
@@ -18616,7 +18616,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18616
18616
|
const cellRows = grid.map(
|
|
18617
18617
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18618
18618
|
);
|
|
18619
|
-
const table =
|
|
18619
|
+
const table = _chunkFUB2BGXVcjs.buildTable.call(void 0, cellRows);
|
|
18620
18620
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18621
18621
|
}
|
|
18622
18622
|
function extractCellText(cellEl) {
|
|
@@ -19585,6 +19585,15 @@ function buildRangeSplices(para, xml, start, end, replacement) {
|
|
|
19585
19585
|
}
|
|
19586
19586
|
return placed ? splices : null;
|
|
19587
19587
|
}
|
|
19588
|
+
function allLinesegRemovalSplices(xml) {
|
|
19589
|
+
const segRe = /<(\w+:)?linesegarray\b[^>]*?(?:\/>|>[\s\S]*?<\/\1linesegarray>)/g;
|
|
19590
|
+
const splices = [];
|
|
19591
|
+
let m;
|
|
19592
|
+
while ((m = segRe.exec(xml)) !== null) {
|
|
19593
|
+
splices.push({ start: m.index, end: m.index + m[0].length, replacement: "" });
|
|
19594
|
+
}
|
|
19595
|
+
return splices;
|
|
19596
|
+
}
|
|
19588
19597
|
function applySplices(xml, splices) {
|
|
19589
19598
|
const sorted = [...splices].sort((a, b) => a.start - b.start);
|
|
19590
19599
|
for (let i = 1; i < sorted.length; i++) {
|
|
@@ -19630,19 +19639,19 @@ function parseCentralDirectory(buf) {
|
|
|
19630
19639
|
}
|
|
19631
19640
|
}
|
|
19632
19641
|
}
|
|
19633
|
-
if (eocdOffset < 0) throw new (0,
|
|
19642
|
+
if (eocdOffset < 0) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19634
19643
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19635
19644
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19636
19645
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19637
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19646
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19638
19647
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19639
|
-
throw new (0,
|
|
19648
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19640
19649
|
}
|
|
19641
19650
|
const decoder = new TextDecoder("utf-8");
|
|
19642
19651
|
const entries = [];
|
|
19643
19652
|
let pos = cdOffset;
|
|
19644
19653
|
for (let i = 0; i < totalEntries; i++) {
|
|
19645
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19654
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19646
19655
|
const flags = view.getUint16(pos + 8, true);
|
|
19647
19656
|
const method = view.getUint16(pos + 10, true);
|
|
19648
19657
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19653,7 +19662,7 @@ function parseCentralDirectory(buf) {
|
|
|
19653
19662
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19654
19663
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19655
19664
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19656
|
-
throw new (0,
|
|
19665
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19657
19666
|
}
|
|
19658
19667
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19659
19668
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19682,7 +19691,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19682
19691
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19683
19692
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19684
19693
|
for (const name of replacements.keys()) {
|
|
19685
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19694
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkFUB2BGXVcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19686
19695
|
}
|
|
19687
19696
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19688
19697
|
const segments = [];
|
|
@@ -19700,7 +19709,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19700
19709
|
offset += seg.length;
|
|
19701
19710
|
continue;
|
|
19702
19711
|
}
|
|
19703
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
19712
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkFUB2BGXVcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19704
19713
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19705
19714
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19706
19715
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -19755,7 +19764,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19755
19764
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
19756
19765
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
19757
19766
|
if (sectionPaths.length === 0) {
|
|
19758
|
-
throw new (0,
|
|
19767
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19759
19768
|
}
|
|
19760
19769
|
const normalizedValues = normalizeValues(values);
|
|
19761
19770
|
const matchedLabels = /* @__PURE__ */ new Set();
|
|
@@ -20905,7 +20914,7 @@ function escapeGfm(text) {
|
|
|
20905
20914
|
}
|
|
20906
20915
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
20907
20916
|
function sanitizeText(text) {
|
|
20908
|
-
let result =
|
|
20917
|
+
let result = _chunkFUB2BGXVcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
20909
20918
|
if (result.length <= 30 && result.includes(" ")) {
|
|
20910
20919
|
const tokens = result.split(" ");
|
|
20911
20920
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21455,6 +21464,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21455
21464
|
try {
|
|
21456
21465
|
for (let i = 0; i < scans.length; i++) {
|
|
21457
21466
|
if (sectionSplices[i].length === 0) continue;
|
|
21467
|
+
sectionSplices[i].push(...allLinesegRemovalSplices(scans[i].xml));
|
|
21458
21468
|
const newXml = applySplices(scans[i].xml, sectionSplices[i]);
|
|
21459
21469
|
replacements.set(sectionPaths[i], encoder.encode(newXml));
|
|
21460
21470
|
}
|
|
@@ -21491,9 +21501,9 @@ function buildOrigUnits(blocks) {
|
|
|
21491
21501
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
21492
21502
|
const next = blocks[i + 1];
|
|
21493
21503
|
if (_optionalChain([next, 'optionalAccess', _179 => _179.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
21494
|
-
chunk =
|
|
21504
|
+
chunk = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
21495
21505
|
} else {
|
|
21496
|
-
chunk =
|
|
21506
|
+
chunk = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, [block]);
|
|
21497
21507
|
}
|
|
21498
21508
|
if (chunk) {
|
|
21499
21509
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -23016,13 +23026,13 @@ async function htmlToPdf(html, options) {
|
|
|
23016
23026
|
try {
|
|
23017
23027
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
23018
23028
|
} catch (e34) {
|
|
23019
|
-
throw new (0,
|
|
23029
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)(
|
|
23020
23030
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
23021
23031
|
);
|
|
23022
23032
|
}
|
|
23023
23033
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
23024
23034
|
if (!executablePath) {
|
|
23025
|
-
throw new (0,
|
|
23035
|
+
throw new (0, _chunkFUB2BGXVcjs.KordocError)(
|
|
23026
23036
|
"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."
|
|
23027
23037
|
);
|
|
23028
23038
|
}
|
|
@@ -23081,7 +23091,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
23081
23091
|
return htmlToPdf(html, options);
|
|
23082
23092
|
}
|
|
23083
23093
|
async function blocksToPdf(blocks, options) {
|
|
23084
|
-
const markdown =
|
|
23094
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, blocks);
|
|
23085
23095
|
return markdownToPdf(markdown, options);
|
|
23086
23096
|
}
|
|
23087
23097
|
|
|
@@ -23092,13 +23102,13 @@ async function parse(input, options) {
|
|
|
23092
23102
|
if (typeof input === "string") {
|
|
23093
23103
|
try {
|
|
23094
23104
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23095
|
-
buffer =
|
|
23105
|
+
buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, buf);
|
|
23096
23106
|
} catch (err) {
|
|
23097
23107
|
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}`;
|
|
23098
23108
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
23099
23109
|
}
|
|
23100
23110
|
} else if (Buffer.isBuffer(input)) {
|
|
23101
|
-
buffer =
|
|
23111
|
+
buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, input);
|
|
23102
23112
|
} else {
|
|
23103
23113
|
buffer = input;
|
|
23104
23114
|
}
|
|
@@ -23133,7 +23143,7 @@ async function parseHwp3(buffer, options) {
|
|
|
23133
23143
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
23134
23144
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
23135
23145
|
} catch (err) {
|
|
23136
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23146
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23137
23147
|
}
|
|
23138
23148
|
}
|
|
23139
23149
|
async function parseHwpx(buffer, options) {
|
|
@@ -23141,7 +23151,7 @@ async function parseHwpx(buffer, options) {
|
|
|
23141
23151
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
23142
23152
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _233 => _233.length]) ? images : void 0 };
|
|
23143
23153
|
} catch (err) {
|
|
23144
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23154
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23145
23155
|
}
|
|
23146
23156
|
}
|
|
23147
23157
|
async function parseHwp(buffer, options) {
|
|
@@ -23166,13 +23176,13 @@ async function parseHwp(buffer, options) {
|
|
|
23166
23176
|
}
|
|
23167
23177
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _235 => _235.length]) ? images : void 0 };
|
|
23168
23178
|
} catch (err) {
|
|
23169
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23179
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23170
23180
|
}
|
|
23171
23181
|
}
|
|
23172
23182
|
async function parsePdf(buffer, options) {
|
|
23173
23183
|
let parsePdfDocument;
|
|
23174
23184
|
try {
|
|
23175
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
23185
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-YWKNDGKI.cjs")));
|
|
23176
23186
|
parsePdfDocument = mod.parsePdfDocument;
|
|
23177
23187
|
} catch (e36) {
|
|
23178
23188
|
return {
|
|
@@ -23187,7 +23197,7 @@ async function parsePdf(buffer, options) {
|
|
|
23187
23197
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
23188
23198
|
} catch (err) {
|
|
23189
23199
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
23190
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23200
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err), isImageBased };
|
|
23191
23201
|
}
|
|
23192
23202
|
}
|
|
23193
23203
|
async function parseXlsx(buffer, options) {
|
|
@@ -23195,7 +23205,7 @@ async function parseXlsx(buffer, options) {
|
|
|
23195
23205
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
23196
23206
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
23197
23207
|
} catch (err) {
|
|
23198
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23208
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23199
23209
|
}
|
|
23200
23210
|
}
|
|
23201
23211
|
async function parseXls(buffer, options) {
|
|
@@ -23203,7 +23213,7 @@ async function parseXls(buffer, options) {
|
|
|
23203
23213
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
23204
23214
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
23205
23215
|
} catch (err) {
|
|
23206
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23216
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23207
23217
|
}
|
|
23208
23218
|
}
|
|
23209
23219
|
async function parseDocx(buffer, options) {
|
|
@@ -23211,7 +23221,7 @@ async function parseDocx(buffer, options) {
|
|
|
23211
23221
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
23212
23222
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _236 => _236.length]) ? images : void 0 };
|
|
23213
23223
|
} catch (err) {
|
|
23214
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23224
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23215
23225
|
}
|
|
23216
23226
|
}
|
|
23217
23227
|
async function parseHwpml(buffer, options) {
|
|
@@ -23219,16 +23229,16 @@ async function parseHwpml(buffer, options) {
|
|
|
23219
23229
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
23220
23230
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
23221
23231
|
} catch (err) {
|
|
23222
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23232
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkFUB2BGXVcjs.classifyError.call(void 0, err) };
|
|
23223
23233
|
}
|
|
23224
23234
|
}
|
|
23225
23235
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
23226
23236
|
let buffer;
|
|
23227
23237
|
if (typeof input === "string") {
|
|
23228
23238
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23229
|
-
buffer =
|
|
23239
|
+
buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, buf);
|
|
23230
23240
|
} else if (Buffer.isBuffer(input)) {
|
|
23231
|
-
buffer =
|
|
23241
|
+
buffer = _chunkFUB2BGXVcjs.toArrayBuffer.call(void 0, input);
|
|
23232
23242
|
} else {
|
|
23233
23243
|
buffer = input;
|
|
23234
23244
|
}
|
|
@@ -23254,7 +23264,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23254
23264
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
23255
23265
|
}
|
|
23256
23266
|
const fill = fillFormFields(parsed.blocks, values);
|
|
23257
|
-
const markdown =
|
|
23267
|
+
const markdown = _chunkFUB2BGXVcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
23258
23268
|
if (outputFormat === "hwpx") {
|
|
23259
23269
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
23260
23270
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -23302,5 +23312,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23302
23312
|
|
|
23303
23313
|
|
|
23304
23314
|
|
|
23305
|
-
exports.HwpxSession = HwpxSession; exports.VERSION =
|
|
23315
|
+
exports.HwpxSession = HwpxSession; exports.VERSION = _chunkFUB2BGXVcjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkFUB2BGXVcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; 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.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; 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.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml;
|
|
23306
23316
|
//# sourceMappingURL=index.cjs.map
|