kordoc 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +584 -584
- package/dist/{-56JCPGII.js → -YOQGQ22S.js} +5 -5
- package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
- package/dist/chunk-3TBUDJDE.js.map +1 -0
- package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
- package/dist/chunk-AIQ3ISQU.js.map +1 -0
- package/dist/{chunk-MEPHGCPQ.js → chunk-CFQLK3LM.js} +1 -1
- package/dist/chunk-CFQLK3LM.js.map +1 -0
- package/dist/{chunk-YFNBHLLM.js → chunk-CGHPBI3X.js} +37 -24
- package/dist/chunk-CGHPBI3X.js.map +1 -0
- package/dist/{chunk-MHYDBT2Q.js → chunk-FPFB7AFX.js} +2 -2
- package/dist/chunk-FPFB7AFX.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-ZPLRG2SJ.js → chunk-SE3KEL4G.js} +2 -2
- package/dist/chunk-SE3KEL4G.js.map +1 -0
- package/dist/{chunk-YYKQN7SA.cjs → chunk-W7JHJQ2O.cjs} +2 -2
- package/dist/chunk-W7JHJQ2O.cjs.map +1 -0
- package/dist/{chunk-DCZVOIEO.cjs → chunk-X34YWRL5.cjs} +1 -1
- package/dist/chunk-X34YWRL5.cjs.map +1 -0
- package/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/{detect-RI2MQ33K.js → detect-NTR2FUEG.js} +2 -2
- package/dist/{formula-JCNF43NE.js → formula-KOQV353G.js} +1 -1
- package/dist/formula-KOQV353G.js.map +1 -0
- package/dist/{formula-RXVSQPXI.js → formula-MEDGYQXS.js} +1 -1
- package/dist/formula-MEDGYQXS.js.map +1 -0
- package/dist/{formula-5NKVS2LR.cjs → formula-ZYUDQHD3.cjs} +1 -1
- package/dist/formula-ZYUDQHD3.cjs.map +1 -0
- package/dist/index.cjs +206 -193
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -22
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +6 -6
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-CIRRJPXJ.js +7 -0
- package/dist/page-range-OF5I4PQY.js +8 -0
- package/dist/page-range-TPIRSA3J.cjs +8 -0
- package/dist/page-range-TPIRSA3J.cjs.map +1 -0
- package/dist/{parser-VZL3MK5X.js → parser-5HDZZWDH.js} +5 -5
- package/dist/parser-5HDZZWDH.js.map +1 -0
- package/dist/{parser-PQDICHD5.js → parser-ET64VEEX.js} +5 -5
- package/dist/parser-ET64VEEX.js.map +1 -0
- package/dist/{parser-XDW6I25C.cjs → parser-JAZCZJI6.cjs} +18 -18
- package/dist/parser-JAZCZJI6.cjs.map +1 -0
- package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
- package/dist/provider-5K7O3Z2O.cjs.map +1 -0
- package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
- package/dist/provider-7H4CPZYS.js.map +1 -0
- package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
- package/dist/provider-H4WWSPOV.js.map +1 -0
- package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
- package/dist/setup-QSJ2INNS.js.map +1 -0
- package/dist/{watch-KERZCCNR.js → watch-56GNC2YN.js} +5 -5
- package/dist/watch-56GNC2YN.js.map +1 -0
- package/package.json +98 -98
- package/dist/chunk-DCZVOIEO.cjs.map +0 -1
- package/dist/chunk-GE43BE46.js.map +0 -1
- package/dist/chunk-MEPHGCPQ.js.map +0 -1
- package/dist/chunk-MHYDBT2Q.js.map +0 -1
- package/dist/chunk-MOL7MDBG.js.map +0 -1
- package/dist/chunk-YFNBHLLM.js.map +0 -1
- package/dist/chunk-YYKQN7SA.cjs.map +0 -1
- package/dist/chunk-ZPLRG2SJ.js.map +0 -1
- package/dist/formula-5NKVS2LR.cjs.map +0 -1
- package/dist/formula-JCNF43NE.js.map +0 -1
- package/dist/formula-RXVSQPXI.js.map +0 -1
- package/dist/page-range-737B4EZW.js +0 -8
- package/dist/page-range-LNMXJU6W.js +0 -7
- package/dist/page-range-P7SDW6LR.cjs +0 -8
- package/dist/page-range-P7SDW6LR.cjs.map +0 -1
- package/dist/parser-PQDICHD5.js.map +0 -1
- package/dist/parser-VZL3MK5X.js.map +0 -1
- package/dist/parser-XDW6I25C.cjs.map +0 -1
- package/dist/provider-4ZJKV3DC.js.map +0 -1
- package/dist/provider-AKROB7WQ.js.map +0 -1
- package/dist/provider-G4C2V2PD.cjs.map +0 -1
- package/dist/setup-57FB3LSP.js.map +0 -1
- package/dist/watch-KERZCCNR.js.map +0 -1
- /package/dist/{-56JCPGII.js.map → -YOQGQ22S.js.map} +0 -0
- /package/dist/{detect-RI2MQ33K.js.map → detect-NTR2FUEG.js.map} +0 -0
- /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
- /package/dist/{page-range-LNMXJU6W.js.map → page-range-OF5I4PQY.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkW7JHJQ2Ocjs = require('./chunk-W7JHJQ2O.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkX34YWRL5cjs = require('./chunk-X34YWRL5.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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(_chunkW7JHJQ2Ocjs.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
|
+
_chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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,9 +1105,9 @@ 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, _chunkW7JHJQ2Ocjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1109
1109
|
metadata.pageCount = sectionPaths.length;
|
|
1110
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ?
|
|
1110
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
1111
1111
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
1112
1112
|
const blocks = [];
|
|
1113
1113
|
const shared = createSectionShared();
|
|
@@ -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, _chunkW7JHJQ2Ocjs.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 _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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 (_chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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 _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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(_chunkW7JHJQ2Ocjs.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 (_chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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(_chunkW7JHJQ2Ocjs.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 >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H1) level = 1;
|
|
1428
|
+
else if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H2) level = 2;
|
|
1429
|
+
else if (ratio >= _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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(_chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.MAX_COLS);
|
|
1587
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3672
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3673
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkW7JHJQ2Ocjs.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,9 +3679,9 @@ 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, _chunkW7JHJQ2Ocjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3683
3683
|
metadata.pageCount = sections.length;
|
|
3684
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ?
|
|
3684
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3685
3685
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
3686
3686
|
const bodyBlocks = [];
|
|
3687
3687
|
const doc = createHwp5DocState();
|
|
@@ -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, _chunkW7JHJQ2Ocjs.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 _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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 >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H1) level = 1;
|
|
3775
|
+
else if (ratio >= _chunkW7JHJQ2Ocjs.HEADING_RATIO_H2) level = 2;
|
|
3776
|
+
else if (ratio >= _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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), _chunkW7JHJQ2Ocjs.MAX_ROWS);
|
|
4227
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.MAX_COLS);
|
|
4294
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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(_chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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
|
+
_chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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");
|
|
@@ -16910,7 +16910,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16910
16910
|
}
|
|
16911
16911
|
let pageFilter = null;
|
|
16912
16912
|
if (_optionalChain([options, 'optionalAccess', _84 => _84.pages])) {
|
|
16913
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
16913
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-TPIRSA3J.cjs")));
|
|
16914
16914
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
16915
16915
|
}
|
|
16916
16916
|
const blocks = [];
|
|
@@ -16973,7 +16973,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16973
16973
|
} catch (e26) {
|
|
16974
16974
|
}
|
|
16975
16975
|
}
|
|
16976
|
-
const markdown =
|
|
16976
|
+
const markdown = _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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 = _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.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, _chunkW7JHJQ2Ocjs.KordocError)(
|
|
17530
17530
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17531
17531
|
);
|
|
17532
17532
|
}
|
|
@@ -17548,7 +17548,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17548
17548
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17549
17549
|
let pageFilter = null;
|
|
17550
17550
|
if (_optionalChain([options, 'optionalAccess', _89 => _89.pages])) {
|
|
17551
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
17551
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-TPIRSA3J.cjs")));
|
|
17552
17552
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17553
17553
|
}
|
|
17554
17554
|
const allBlocks = [];
|
|
@@ -17586,7 +17586,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17586
17586
|
pageCount: totalSheets
|
|
17587
17587
|
};
|
|
17588
17588
|
return {
|
|
17589
|
-
markdown:
|
|
17589
|
+
markdown: _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17590
17590
|
blocks: allBlocks,
|
|
17591
17591
|
metadata,
|
|
17592
17592
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17971,20 +17971,32 @@ function isDisplayMath(el) {
|
|
|
17971
17971
|
|
|
17972
17972
|
// src/docx/parser.ts
|
|
17973
17973
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
17974
|
-
function
|
|
17974
|
+
function matchesLocal(el, localName2) {
|
|
17975
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _95 => _95.tagName, 'optionalAccess', _96 => _96.endsWith, 'call', _97 => _97(`:${localName2}`)]), () => ( false)));
|
|
17976
|
+
}
|
|
17977
|
+
function effectiveChildElements(parent) {
|
|
17975
17978
|
const result = [];
|
|
17976
17979
|
const children = parent.childNodes;
|
|
17977
17980
|
for (let i = 0; i < children.length; i++) {
|
|
17978
17981
|
const node = children[i];
|
|
17979
|
-
if (node.nodeType
|
|
17980
|
-
|
|
17981
|
-
|
|
17982
|
-
|
|
17982
|
+
if (node.nodeType !== 1) continue;
|
|
17983
|
+
const el = node;
|
|
17984
|
+
if (matchesLocal(el, "sdt")) {
|
|
17985
|
+
for (let j = 0; j < el.childNodes.length; j++) {
|
|
17986
|
+
const c = el.childNodes[j];
|
|
17987
|
+
if (c.nodeType === 1 && matchesLocal(c, "sdtContent")) {
|
|
17988
|
+
result.push(...effectiveChildElements(c));
|
|
17989
|
+
}
|
|
17983
17990
|
}
|
|
17991
|
+
} else {
|
|
17992
|
+
result.push(el);
|
|
17984
17993
|
}
|
|
17985
17994
|
}
|
|
17986
17995
|
return result;
|
|
17987
17996
|
}
|
|
17997
|
+
function getChildElements(parent, localName2) {
|
|
17998
|
+
return effectiveChildElements(parent).filter((el) => matchesLocal(el, localName2));
|
|
17999
|
+
}
|
|
17988
18000
|
function findElements(parent, localName2) {
|
|
17989
18001
|
const result = [];
|
|
17990
18002
|
const walk = (node) => {
|
|
@@ -18012,7 +18024,7 @@ function getAttr(el, localName2) {
|
|
|
18012
18024
|
return null;
|
|
18013
18025
|
}
|
|
18014
18026
|
function parseXml2(text) {
|
|
18015
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18027
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkW7JHJQ2Ocjs.stripDtd.call(void 0, text), "text/xml");
|
|
18016
18028
|
}
|
|
18017
18029
|
function parseStyles(xml) {
|
|
18018
18030
|
const doc = parseXml2(xml);
|
|
@@ -18331,12 +18343,12 @@ async function extractImages(zip, rels, doc) {
|
|
|
18331
18343
|
return { blocks, images };
|
|
18332
18344
|
}
|
|
18333
18345
|
async function parseDocxDocument(buffer, options) {
|
|
18334
|
-
|
|
18346
|
+
_chunkW7JHJQ2Ocjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18335
18347
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18336
18348
|
const warnings = [];
|
|
18337
18349
|
const docFile = zip.file("word/document.xml");
|
|
18338
18350
|
if (!docFile) {
|
|
18339
|
-
throw new (0,
|
|
18351
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18340
18352
|
}
|
|
18341
18353
|
let rels = /* @__PURE__ */ new Map();
|
|
18342
18354
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18371,15 +18383,12 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18371
18383
|
const doc = parseXml2(docXml);
|
|
18372
18384
|
const body = findElements(doc, "body");
|
|
18373
18385
|
if (body.length === 0) {
|
|
18374
|
-
throw new (0,
|
|
18386
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18375
18387
|
}
|
|
18376
18388
|
const blocks = [];
|
|
18377
18389
|
const bodyEl = body[0];
|
|
18378
|
-
const
|
|
18379
|
-
for (
|
|
18380
|
-
const node = children[i];
|
|
18381
|
-
if (node.nodeType !== 1) continue;
|
|
18382
|
-
const el = node;
|
|
18390
|
+
const topLevel = effectiveChildElements(bodyEl);
|
|
18391
|
+
for (const el of topLevel) {
|
|
18383
18392
|
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _118 => _118.tagName, 'optionalAccess', _119 => _119.split, 'call', _120 => _120(":"), 'access', _121 => _121.pop, 'call', _122 => _122()])));
|
|
18384
18393
|
if (localName2 === "p") {
|
|
18385
18394
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
@@ -18411,7 +18420,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18411
18420
|
}
|
|
18412
18421
|
}
|
|
18413
18422
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18414
|
-
const markdown =
|
|
18423
|
+
const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
|
|
18415
18424
|
return {
|
|
18416
18425
|
markdown,
|
|
18417
18426
|
blocks,
|
|
@@ -18434,7 +18443,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18434
18443
|
}
|
|
18435
18444
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18436
18445
|
const normalized = text.replace(/ /g, " ");
|
|
18437
|
-
const xml =
|
|
18446
|
+
const xml = _chunkW7JHJQ2Ocjs.stripDtd.call(void 0, normalized);
|
|
18438
18447
|
const warnings = [];
|
|
18439
18448
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18440
18449
|
onError: (_level, msg2) => {
|
|
@@ -18462,7 +18471,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18462
18471
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18463
18472
|
}
|
|
18464
18473
|
const blocks = [];
|
|
18465
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ?
|
|
18474
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18466
18475
|
let sectionIdx = 0;
|
|
18467
18476
|
const children = body.childNodes;
|
|
18468
18477
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18474,7 +18483,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18474
18483
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18475
18484
|
}
|
|
18476
18485
|
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 =
|
|
18486
|
+
const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
|
|
18478
18487
|
return {
|
|
18479
18488
|
markdown,
|
|
18480
18489
|
blocks,
|
|
@@ -18616,7 +18625,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18616
18625
|
const cellRows = grid.map(
|
|
18617
18626
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18618
18627
|
);
|
|
18619
|
-
const table =
|
|
18628
|
+
const table = _chunkW7JHJQ2Ocjs.buildTable.call(void 0, cellRows);
|
|
18620
18629
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18621
18630
|
}
|
|
18622
18631
|
function extractCellText(cellEl) {
|
|
@@ -18885,8 +18894,9 @@ function extractFromTable(table) {
|
|
|
18885
18894
|
if (table.cols >= 2) {
|
|
18886
18895
|
for (let r = 0; r < table.rows; r++) {
|
|
18887
18896
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
18888
|
-
const labelCell = table.cells[r][c];
|
|
18889
|
-
const valueCell = table.cells[r][c + 1];
|
|
18897
|
+
const labelCell = _optionalChain([table, 'access', _125 => _125.cells, 'access', _126 => _126[r], 'optionalAccess', _127 => _127[c]]);
|
|
18898
|
+
const valueCell = _optionalChain([table, 'access', _128 => _128.cells, 'access', _129 => _129[r], 'optionalAccess', _130 => _130[c + 1]]);
|
|
18899
|
+
if (!labelCell || !valueCell) continue;
|
|
18890
18900
|
if (isLabelCell(labelCell.text)) {
|
|
18891
18901
|
fields.push({
|
|
18892
18902
|
label: labelCell.text.trim().replace(/[::]\s*$/, ""),
|
|
@@ -18907,8 +18917,8 @@ function extractFromTable(table) {
|
|
|
18907
18917
|
if (allLabels) {
|
|
18908
18918
|
for (let r = 1; r < table.rows; r++) {
|
|
18909
18919
|
for (let c = 0; c < table.cols; c++) {
|
|
18910
|
-
const label = headerRow[c].text.trim();
|
|
18911
|
-
const value = table.cells[r][c].text.trim();
|
|
18920
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _131 => _131[c], 'optionalAccess', _132 => _132.text, 'access', _133 => _133.trim, 'call', _134 => _134()]), () => ( ""));
|
|
18921
|
+
const value = _nullishCoalesce(_optionalChain([table, 'access', _135 => _135.cells, 'access', _136 => _136[r], 'optionalAccess', _137 => _137[c], 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()]), () => ( ""));
|
|
18912
18922
|
if (label && value) {
|
|
18913
18923
|
fields.push({ label, value, row: r, col: c });
|
|
18914
18924
|
}
|
|
@@ -19000,7 +19010,7 @@ function fillFormFields(blocks, values) {
|
|
|
19000
19010
|
if (block.type !== "table" || !block.table) continue;
|
|
19001
19011
|
for (let r = 0; r < block.table.rows; r++) {
|
|
19002
19012
|
for (let c = 0; c < block.table.cols; c++) {
|
|
19003
|
-
const cell = _optionalChain([block, 'access',
|
|
19013
|
+
const cell = _optionalChain([block, 'access', _141 => _141.table, 'access', _142 => _142.cells, 'access', _143 => _143[r], 'optionalAccess', _144 => _144[c]]);
|
|
19004
19014
|
if (!cell) continue;
|
|
19005
19015
|
const result = fillInCellPatterns(cell.text, normalizedValues, matchedLabels);
|
|
19006
19016
|
if (result) {
|
|
@@ -19039,7 +19049,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19039
19049
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
19040
19050
|
if (matchKey === void 0) continue;
|
|
19041
19051
|
const newValue = values.get(matchKey);
|
|
19042
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19052
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _145 => _145.has, 'call', _146 => _146(`${r},${c + 1}`)])) {
|
|
19043
19053
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19044
19054
|
} else {
|
|
19045
19055
|
valueCell.text = newValue;
|
|
@@ -19062,15 +19072,18 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19062
19072
|
if (!allLabels) return;
|
|
19063
19073
|
for (let r = 1; r < table.rows; r++) {
|
|
19064
19074
|
for (let c = 0; c < table.cols; c++) {
|
|
19065
|
-
const
|
|
19075
|
+
const headerCell = headerRow[c];
|
|
19076
|
+
const valueCell = _optionalChain([table, 'access', _147 => _147.cells, 'access', _148 => _148[r], 'optionalAccess', _149 => _149[c]]);
|
|
19077
|
+
if (!headerCell || !valueCell) continue;
|
|
19078
|
+
const headerLabel = normalizeLabel(headerCell.text);
|
|
19066
19079
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
19067
19080
|
if (matchKey === void 0) continue;
|
|
19068
19081
|
if (matchedLabels.has(matchKey)) continue;
|
|
19069
19082
|
const newValue = values.get(matchKey);
|
|
19070
|
-
|
|
19083
|
+
valueCell.text = newValue;
|
|
19071
19084
|
matchedLabels.add(matchKey);
|
|
19072
19085
|
filled.push({
|
|
19073
|
-
label:
|
|
19086
|
+
label: headerCell.text.trim(),
|
|
19074
19087
|
value: newValue,
|
|
19075
19088
|
row: r,
|
|
19076
19089
|
col: c
|
|
@@ -19639,19 +19652,19 @@ function parseCentralDirectory(buf) {
|
|
|
19639
19652
|
}
|
|
19640
19653
|
}
|
|
19641
19654
|
}
|
|
19642
|
-
if (eocdOffset < 0) throw new (0,
|
|
19655
|
+
if (eocdOffset < 0) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19643
19656
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19644
19657
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19645
19658
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19646
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19659
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19647
19660
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19648
|
-
throw new (0,
|
|
19661
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19649
19662
|
}
|
|
19650
19663
|
const decoder = new TextDecoder("utf-8");
|
|
19651
19664
|
const entries = [];
|
|
19652
19665
|
let pos = cdOffset;
|
|
19653
19666
|
for (let i = 0; i < totalEntries; i++) {
|
|
19654
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19667
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19655
19668
|
const flags = view.getUint16(pos + 8, true);
|
|
19656
19669
|
const method = view.getUint16(pos + 10, true);
|
|
19657
19670
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19662,7 +19675,7 @@ function parseCentralDirectory(buf) {
|
|
|
19662
19675
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19663
19676
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19664
19677
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19665
|
-
throw new (0,
|
|
19678
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19666
19679
|
}
|
|
19667
19680
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19668
19681
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19691,7 +19704,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19691
19704
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19692
19705
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19693
19706
|
for (const name of replacements.keys()) {
|
|
19694
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19707
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19695
19708
|
}
|
|
19696
19709
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19697
19710
|
const segments = [];
|
|
@@ -19709,7 +19722,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19709
19722
|
offset += seg.length;
|
|
19710
19723
|
continue;
|
|
19711
19724
|
}
|
|
19712
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
19725
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19713
19726
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19714
19727
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19715
19728
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -19764,7 +19777,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19764
19777
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
19765
19778
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
19766
19779
|
if (sectionPaths.length === 0) {
|
|
19767
|
-
throw new (0,
|
|
19780
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19768
19781
|
}
|
|
19769
19782
|
const normalizedValues = normalizeValues(values);
|
|
19770
19783
|
const matchedLabels = /* @__PURE__ */ new Set();
|
|
@@ -19912,7 +19925,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19912
19925
|
}
|
|
19913
19926
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
19914
19927
|
const existing = ledger.get(para);
|
|
19915
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
19928
|
+
if (_optionalChain([existing, 'optionalAccess', _150 => _150.fullText]) !== void 0) continue;
|
|
19916
19929
|
const text = matchText(para);
|
|
19917
19930
|
for (const seg of scanInlineSegments(text)) {
|
|
19918
19931
|
const matchKey = findMatchingKey(normalizeLabel(seg.label), normalizedValues);
|
|
@@ -20124,21 +20137,21 @@ var PARA_LIST = 7;
|
|
|
20124
20137
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20125
20138
|
function resolveTheme(theme) {
|
|
20126
20139
|
return {
|
|
20127
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20128
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20129
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20130
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20131
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20132
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20140
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _151 => _151.headingColors, 'optionalAccess', _152 => _152[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20141
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _153 => _153.headingColors, 'optionalAccess', _154 => _154[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20142
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _155 => _155.headingColors, 'optionalAccess', _156 => _156[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20143
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _157 => _157.headingColors, 'optionalAccess', _158 => _158[4]]), () => ( _optionalChain([theme, 'optionalAccess', _159 => _159.headingColors, 'optionalAccess', _160 => _160[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20144
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _161 => _161.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20145
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _162 => _162.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20133
20146
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20134
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20135
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20136
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
20147
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _163 => _163.quoteColor]) !== void 0,
|
|
20148
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _164 => _164.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _165 => _165.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20149
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _166 => _166.tableHeaderBold])
|
|
20137
20150
|
};
|
|
20138
20151
|
}
|
|
20139
20152
|
async function markdownToHwpx(markdown, options) {
|
|
20140
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
20141
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
20153
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _167 => _167.theme]));
|
|
20154
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _168 => _168.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
20142
20155
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
20143
20156
|
const sectionXml = blocksToSectionXml(blocks, theme, gongmun);
|
|
20144
20157
|
const zip = new (0, _jszip2.default)();
|
|
@@ -20417,7 +20430,7 @@ ${base.join("\n")}
|
|
|
20417
20430
|
</hh:paraProperties>`;
|
|
20418
20431
|
}
|
|
20419
20432
|
function generateHeaderXml(theme, gongmun) {
|
|
20420
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
20433
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _169 => _169.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
20421
20434
|
const charPropsXml = buildCharProperties(theme, gongmun);
|
|
20422
20435
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
20423
20436
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -20616,8 +20629,8 @@ function blocksToSectionXml(blocks, theme, gongmun) {
|
|
|
20616
20629
|
case "list_item": {
|
|
20617
20630
|
if (gongmun && gongmunList) {
|
|
20618
20631
|
const info = gongmunList.get(blockIdx);
|
|
20619
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
20620
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
20632
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _170 => _170.depth]), () => ( 0));
|
|
20633
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _171 => _171.marker]), () => ( ""));
|
|
20621
20634
|
const content = block.text || "";
|
|
20622
20635
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
20623
20636
|
xml = generateParagraph(text, GONGMUN_LIST_BASE + depth);
|
|
@@ -20914,7 +20927,7 @@ function escapeGfm(text) {
|
|
|
20914
20927
|
}
|
|
20915
20928
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
20916
20929
|
function sanitizeText(text) {
|
|
20917
|
-
let result =
|
|
20930
|
+
let result = _chunkW7JHJQ2Ocjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
20918
20931
|
if (result.length <= 30 && result.includes(" ")) {
|
|
20919
20932
|
const tokens = result.split(" ");
|
|
20920
20933
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -20944,7 +20957,7 @@ function replicateGfmTable(table) {
|
|
|
20944
20957
|
for (let r = 0; r < numRows; r++) {
|
|
20945
20958
|
for (let c = 0; c < numCols; c++) {
|
|
20946
20959
|
if (skip.has(`${r},${c}`)) continue;
|
|
20947
|
-
const cell = _optionalChain([cells, 'access',
|
|
20960
|
+
const cell = _optionalChain([cells, 'access', _172 => _172[r], 'optionalAccess', _173 => _173[c]]);
|
|
20948
20961
|
if (!cell) continue;
|
|
20949
20962
|
display[r][c] = {
|
|
20950
20963
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -20998,7 +21011,7 @@ function unescapeGfmCell(text) {
|
|
|
20998
21011
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\~/g, "~");
|
|
20999
21012
|
}
|
|
21000
21013
|
function replicateCellInnerHtml(cell) {
|
|
21001
|
-
if (_optionalChain([cell, 'access',
|
|
21014
|
+
if (_optionalChain([cell, 'access', _174 => _174.blocks, 'optionalAccess', _175 => _175.length])) {
|
|
21002
21015
|
return cell.blocks.map((b) => {
|
|
21003
21016
|
if (b.type === "table" && b.table) {
|
|
21004
21017
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -21037,7 +21050,7 @@ function replicateHtmlTable(table) {
|
|
|
21037
21050
|
const rowCells = [];
|
|
21038
21051
|
for (let c = 0; c < numCols; c++) {
|
|
21039
21052
|
if (skip.has(`${r},${c}`)) continue;
|
|
21040
|
-
const cell = _optionalChain([cells, 'access',
|
|
21053
|
+
const cell = _optionalChain([cells, 'access', _176 => _176[r], 'optionalAccess', _177 => _177[c]]);
|
|
21041
21054
|
if (!cell) continue;
|
|
21042
21055
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
21043
21056
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -21083,8 +21096,8 @@ function parseHtmlTable(raw) {
|
|
|
21083
21096
|
}
|
|
21084
21097
|
} else {
|
|
21085
21098
|
if (!isClose) {
|
|
21086
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
21087
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
21099
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _178 => _178.match, 'call', _179 => _179(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _180 => _180[1]]) || "1", 10);
|
|
21100
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _181 => _181.match, 'call', _182 => _182(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _183 => _183[1]]) || "1", 10);
|
|
21088
21101
|
cellStart = m.index + m[0].length;
|
|
21089
21102
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
21090
21103
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -21246,9 +21259,9 @@ function patchHtmlTableRaw(table, scanTable, origRaw, editedRaw, ctx, skip, dept
|
|
|
21246
21259
|
return applied;
|
|
21247
21260
|
}
|
|
21248
21261
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
21249
|
-
const irCell = _optionalChain([table, 'access',
|
|
21262
|
+
const irCell = _optionalChain([table, 'access', _184 => _184.cells, 'access', _185 => _185[oc.gridR], 'optionalAccess', _186 => _186[oc.gridC]]);
|
|
21250
21263
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
21251
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
21264
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _187 => _187.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
21252
21265
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
21253
21266
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
21254
21267
|
}
|
|
@@ -21316,7 +21329,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21316
21329
|
};
|
|
21317
21330
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
21318
21331
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
21319
|
-
const irCell = _optionalChain([table, 'access',
|
|
21332
|
+
const irCell = _optionalChain([table, 'access', _188 => _188.cells, 'access', _189 => _189[gridR], 'optionalAccess', _190 => _190[gridC]]);
|
|
21320
21333
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
21321
21334
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
21322
21335
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -21339,7 +21352,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21339
21352
|
if (newLines.length === 0) return 0;
|
|
21340
21353
|
const target = cell.paragraphs[0];
|
|
21341
21354
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
21342
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
21355
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _191 => _191.scans, 'access', _192 => _192[target.sectionIndex], 'optionalAccess', _193 => _193.xml]));
|
|
21343
21356
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21344
21357
|
splices.push(...sp);
|
|
21345
21358
|
sectionIndex = target.sectionIndex;
|
|
@@ -21360,7 +21373,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21360
21373
|
}
|
|
21361
21374
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
21362
21375
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
21363
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
21376
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _194 => _194.scans, 'access', _195 => _195[nonEmpty[i].sectionIndex], 'optionalAccess', _196 => _196.xml]));
|
|
21364
21377
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21365
21378
|
splices.push(...sp);
|
|
21366
21379
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -21482,7 +21495,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21482
21495
|
}
|
|
21483
21496
|
}
|
|
21484
21497
|
let verification;
|
|
21485
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
21498
|
+
if (_optionalChain([options, 'optionalAccess', _197 => _197.verify]) !== false) {
|
|
21486
21499
|
try {
|
|
21487
21500
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
21488
21501
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -21500,17 +21513,17 @@ function buildOrigUnits(blocks) {
|
|
|
21500
21513
|
let chunk;
|
|
21501
21514
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
21502
21515
|
const next = blocks[i + 1];
|
|
21503
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
21504
|
-
chunk =
|
|
21516
|
+
if (_optionalChain([next, 'optionalAccess', _198 => _198.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
21517
|
+
chunk = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
21505
21518
|
} else {
|
|
21506
|
-
chunk =
|
|
21519
|
+
chunk = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, [block]);
|
|
21507
21520
|
}
|
|
21508
21521
|
if (chunk) {
|
|
21509
21522
|
const subUnits = splitMarkdownUnits(chunk);
|
|
21510
21523
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
21511
21524
|
for (let s = 0; s < subUnits.length; s++) {
|
|
21512
21525
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
21513
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
21526
|
+
if (block.type === "table" && _optionalChain([block, 'access', _199 => _199.table, 'optionalAccess', _200 => _200.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
21514
21527
|
u.role = "caption";
|
|
21515
21528
|
}
|
|
21516
21529
|
units.push(u);
|
|
@@ -21687,7 +21700,7 @@ function handleModifiedUnit(orig, edited, ctx) {
|
|
|
21687
21700
|
}
|
|
21688
21701
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
21689
21702
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
21690
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
21703
|
+
if (!_optionalChain([mapping, 'optionalAccess', _201 => _201.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
21691
21704
|
if (block.text && block.text.includes("\n")) {
|
|
21692
21705
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
21693
21706
|
}
|
|
@@ -21718,7 +21731,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
21718
21731
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
21719
21732
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
21720
21733
|
}
|
|
21721
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
21734
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _202 => _202.scans, 'access', _203 => _203[mapping.para.sectionIndex], 'optionalAccess', _204 => _204.xml]));
|
|
21722
21735
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21723
21736
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
21724
21737
|
return 1;
|
|
@@ -21886,7 +21899,7 @@ var Surgeon = (_class3 = class {
|
|
|
21886
21899
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
21887
21900
|
findEntry(path) {
|
|
21888
21901
|
const parts = path.replace(/^\//, "").split("/");
|
|
21889
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
21902
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _205 => _205.entries, 'access', _206 => _206[0], 'optionalAccess', _207 => _207.child]), () => ( -1));
|
|
21890
21903
|
let current;
|
|
21891
21904
|
for (const part of parts) {
|
|
21892
21905
|
const search = (idx) => {
|
|
@@ -22092,7 +22105,7 @@ function readRecordsStrict(stream) {
|
|
|
22092
22105
|
function serializeRecords(recs, repl) {
|
|
22093
22106
|
const parts = [];
|
|
22094
22107
|
for (let i = 0; i < recs.length; i++) {
|
|
22095
|
-
const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
22108
|
+
const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _208 => _208.get, 'call', _209 => _209(i)]), () => ( recs[i].data));
|
|
22096
22109
|
const ext = data.length >= 4095;
|
|
22097
22110
|
const header = Buffer.alloc(ext ? 8 : 4);
|
|
22098
22111
|
header.writeUInt32LE((recs[i].tagId & 1023 | (recs[i].level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
|
|
@@ -22215,7 +22228,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22215
22228
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
22216
22229
|
}
|
|
22217
22230
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
22218
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
22231
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _210 => _210.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
22219
22232
|
let flags;
|
|
22220
22233
|
try {
|
|
22221
22234
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -22237,7 +22250,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22237
22250
|
const scans = [];
|
|
22238
22251
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
22239
22252
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
22240
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
22253
|
+
if (!_optionalChain([entry, 'optionalAccess', _211 => _211.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
22241
22254
|
let stream;
|
|
22242
22255
|
try {
|
|
22243
22256
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -22288,7 +22301,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22288
22301
|
}
|
|
22289
22302
|
}
|
|
22290
22303
|
let verification;
|
|
22291
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22304
|
+
if (_optionalChain([options, 'optionalAccess', _212 => _212.verify]) !== false) {
|
|
22292
22305
|
try {
|
|
22293
22306
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
22294
22307
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -22377,7 +22390,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
22377
22390
|
for (const [key, scanCell] of scanTable.cells) {
|
|
22378
22391
|
const comma = key.indexOf(",");
|
|
22379
22392
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
22380
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
22393
|
+
const irCell = _optionalChain([irTable, 'access', _213 => _213.cells, 'access', _214 => _214[r], 'optionalAccess', _215 => _215[c]]);
|
|
22381
22394
|
if (!irCell) continue;
|
|
22382
22395
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
22383
22396
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -22410,7 +22423,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
22410
22423
|
}
|
|
22411
22424
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
22412
22425
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22413
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22426
|
+
if (!_optionalChain([mapping, 'optionalAccess', _216 => _216.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
22414
22427
|
if (block.text && block.text.includes("\n")) {
|
|
22415
22428
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
22416
22429
|
}
|
|
@@ -22589,7 +22602,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
22589
22602
|
};
|
|
22590
22603
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
22591
22604
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
22592
|
-
const irCell = _optionalChain([table, 'access',
|
|
22605
|
+
const irCell = _optionalChain([table, 'access', _217 => _217.cells, 'access', _218 => _218[gridR], 'optionalAccess', _219 => _219[gridC]]);
|
|
22593
22606
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
22594
22607
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
22595
22608
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -22832,7 +22845,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22832
22845
|
const block = st.blocks[blockIndex];
|
|
22833
22846
|
if (!block) return void 0;
|
|
22834
22847
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
22835
|
-
const para = _optionalChain([st, 'access',
|
|
22848
|
+
const para = _optionalChain([st, 'access', _220 => _220.paraMap, 'access', _221 => _221.get, 'call', _222 => _222(blockIndex), 'optionalAccess', _223 => _223.para]);
|
|
22836
22849
|
if (!para) return void 0;
|
|
22837
22850
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
22838
22851
|
}
|
|
@@ -22857,7 +22870,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22857
22870
|
if (block.text && block.text.includes("\n")) {
|
|
22858
22871
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
|
|
22859
22872
|
}
|
|
22860
|
-
if (!_optionalChain([st, 'access',
|
|
22873
|
+
if (!_optionalChain([st, 'access', _224 => _224.paraMap, 'access', _225 => _225.get, 'call', _226 => _226(blockIndex), 'optionalAccess', _227 => _227.para])) {
|
|
22861
22874
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
|
|
22862
22875
|
}
|
|
22863
22876
|
return { capability: "text" };
|
|
@@ -22923,7 +22936,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22923
22936
|
continue;
|
|
22924
22937
|
}
|
|
22925
22938
|
if (block.type === "table" && block.table) {
|
|
22926
|
-
if (!_optionalChain([edit, 'access',
|
|
22939
|
+
if (!_optionalChain([edit, 'access', _228 => _228.cells, 'optionalAccess', _229 => _229.length])) {
|
|
22927
22940
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
22928
22941
|
continue;
|
|
22929
22942
|
}
|
|
@@ -22943,7 +22956,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22943
22956
|
skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
|
|
22944
22957
|
continue;
|
|
22945
22958
|
}
|
|
22946
|
-
const irCell = _optionalChain([block, 'access',
|
|
22959
|
+
const irCell = _optionalChain([block, 'access', _230 => _230.table, 'access', _231 => _231.cells, 'access', _232 => _232[cellEdit.row], 'optionalAccess', _233 => _233[cellEdit.col]]);
|
|
22947
22960
|
if (!irCell) {
|
|
22948
22961
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
22949
22962
|
continue;
|
|
@@ -22998,7 +23011,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22998
23011
|
}
|
|
22999
23012
|
if (replacements.size === 0) {
|
|
23000
23013
|
let changes2;
|
|
23001
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23014
|
+
if (_optionalChain([options, 'optionalAccess', _234 => _234.verify]) !== false) {
|
|
23002
23015
|
const units = splitMarkdownUnits(st.markdown);
|
|
23003
23016
|
changes2 = diffUnitLists(units, units);
|
|
23004
23017
|
}
|
|
@@ -23019,7 +23032,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23019
23032
|
}
|
|
23020
23033
|
this.state = newState;
|
|
23021
23034
|
let changes;
|
|
23022
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23035
|
+
if (_optionalChain([options, 'optionalAccess', _235 => _235.verify]) !== false) {
|
|
23023
23036
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
23024
23037
|
}
|
|
23025
23038
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -23039,7 +23052,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23039
23052
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
23040
23053
|
}
|
|
23041
23054
|
const mapping = st.paraMap.get(blockIndex);
|
|
23042
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
23055
|
+
if (!_optionalChain([mapping, 'optionalAccess', _236 => _236.para])) {
|
|
23043
23056
|
return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
23044
23057
|
}
|
|
23045
23058
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -23059,14 +23072,14 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23059
23072
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
23060
23073
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
23061
23074
|
}
|
|
23062
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
23075
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _237 => _237.scans, 'access', _238 => _238[mapping.para.sectionIndex], 'optionalAccess', _239 => _239.xml]));
|
|
23063
23076
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23064
23077
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
23065
23078
|
return 1;
|
|
23066
23079
|
}
|
|
23067
23080
|
}, _class4);
|
|
23068
23081
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
23069
|
-
const irCell = _optionalChain([table, 'access',
|
|
23082
|
+
const irCell = _optionalChain([table, 'access', _240 => _240.cells, 'access', _241 => _241[r], 'optionalAccess', _242 => _242[c]]);
|
|
23070
23083
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
23071
23084
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
23072
23085
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -23150,11 +23163,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
23150
23163
|
breaks: false
|
|
23151
23164
|
});
|
|
23152
23165
|
function renderHtml(markdown, options) {
|
|
23153
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23154
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23166
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _243 => _243.preset]), () => ( "default"));
|
|
23167
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.extraCss]), () => ( "")));
|
|
23155
23168
|
const body = md.render(markdown);
|
|
23156
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
23157
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
23169
|
+
const watermark = _optionalChain([options, 'optionalAccess', _245 => _245.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
23170
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _246 => _246.watermark]) ? `
|
|
23158
23171
|
.watermark {
|
|
23159
23172
|
position: fixed;
|
|
23160
23173
|
top: 50%; left: 50%;
|
|
@@ -23185,13 +23198,13 @@ async function htmlToPdf(html, options) {
|
|
|
23185
23198
|
try {
|
|
23186
23199
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
23187
23200
|
} catch (e34) {
|
|
23188
|
-
throw new (0,
|
|
23201
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(
|
|
23189
23202
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
23190
23203
|
);
|
|
23191
23204
|
}
|
|
23192
23205
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
23193
23206
|
if (!executablePath) {
|
|
23194
|
-
throw new (0,
|
|
23207
|
+
throw new (0, _chunkW7JHJQ2Ocjs.KordocError)(
|
|
23195
23208
|
"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."
|
|
23196
23209
|
);
|
|
23197
23210
|
}
|
|
@@ -23203,10 +23216,10 @@ async function htmlToPdf(html, options) {
|
|
|
23203
23216
|
try {
|
|
23204
23217
|
const page = await browser.newPage();
|
|
23205
23218
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
23206
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
23219
|
+
const margin = _optionalChain([options, 'optionalAccess', _247 => _247.margin]);
|
|
23207
23220
|
const pdf = await page.pdf({
|
|
23208
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23209
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
23221
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _248 => _248.pageSize]), () => ( "A4")),
|
|
23222
|
+
landscape: _optionalChain([options, 'optionalAccess', _249 => _249.orientation]) === "landscape",
|
|
23210
23223
|
printBackground: true,
|
|
23211
23224
|
margin: margin ? {
|
|
23212
23225
|
top: toCss(margin.top),
|
|
@@ -23214,9 +23227,9 @@ async function htmlToPdf(html, options) {
|
|
|
23214
23227
|
bottom: toCss(margin.bottom),
|
|
23215
23228
|
left: toCss(margin.left)
|
|
23216
23229
|
} : void 0,
|
|
23217
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
23218
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23219
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23230
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _250 => _250.header]) || _optionalChain([options, 'optionalAccess', _251 => _251.footer])),
|
|
23231
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _252 => _252.header]), () => ( "<div></div>")),
|
|
23232
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _253 => _253.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
23220
23233
|
});
|
|
23221
23234
|
return Buffer.from(pdf);
|
|
23222
23235
|
} finally {
|
|
@@ -23250,24 +23263,24 @@ async function markdownToPdf(markdown, options) {
|
|
|
23250
23263
|
return htmlToPdf(html, options);
|
|
23251
23264
|
}
|
|
23252
23265
|
async function blocksToPdf(blocks, options) {
|
|
23253
|
-
const markdown =
|
|
23266
|
+
const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, blocks);
|
|
23254
23267
|
return markdownToPdf(markdown, options);
|
|
23255
23268
|
}
|
|
23256
23269
|
|
|
23257
23270
|
// src/index.ts
|
|
23258
23271
|
async function parse(input, options) {
|
|
23259
23272
|
let buffer;
|
|
23260
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
23273
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _254 => _254.filePath]) ? { ...options, filePath: input } : options;
|
|
23261
23274
|
if (typeof input === "string") {
|
|
23262
23275
|
try {
|
|
23263
23276
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23264
|
-
buffer =
|
|
23277
|
+
buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, buf);
|
|
23265
23278
|
} catch (err) {
|
|
23266
23279
|
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}`;
|
|
23267
23280
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
23268
23281
|
}
|
|
23269
23282
|
} else if (Buffer.isBuffer(input)) {
|
|
23270
|
-
buffer =
|
|
23283
|
+
buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, input);
|
|
23271
23284
|
} else {
|
|
23272
23285
|
buffer = input;
|
|
23273
23286
|
}
|
|
@@ -23302,21 +23315,21 @@ async function parseHwp3(buffer, options) {
|
|
|
23302
23315
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
23303
23316
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
23304
23317
|
} catch (err) {
|
|
23305
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23318
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23306
23319
|
}
|
|
23307
23320
|
}
|
|
23308
23321
|
async function parseHwpx(buffer, options) {
|
|
23309
23322
|
try {
|
|
23310
23323
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
23311
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23324
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _255 => _255.length]) ? images : void 0 };
|
|
23312
23325
|
} catch (err) {
|
|
23313
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23326
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23314
23327
|
}
|
|
23315
23328
|
}
|
|
23316
23329
|
async function parseHwp(buffer, options) {
|
|
23317
23330
|
try {
|
|
23318
23331
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
23319
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
23332
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _256 => _256.filePath])) {
|
|
23320
23333
|
try {
|
|
23321
23334
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
23322
23335
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -23333,15 +23346,15 @@ async function parseHwp(buffer, options) {
|
|
|
23333
23346
|
} catch (e35) {
|
|
23334
23347
|
}
|
|
23335
23348
|
}
|
|
23336
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23349
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _257 => _257.length]) ? images : void 0 };
|
|
23337
23350
|
} catch (err) {
|
|
23338
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23351
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23339
23352
|
}
|
|
23340
23353
|
}
|
|
23341
23354
|
async function parsePdf(buffer, options) {
|
|
23342
23355
|
let parsePdfDocument;
|
|
23343
23356
|
try {
|
|
23344
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
23357
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-JAZCZJI6.cjs")));
|
|
23345
23358
|
parsePdfDocument = mod.parsePdfDocument;
|
|
23346
23359
|
} catch (e36) {
|
|
23347
23360
|
return {
|
|
@@ -23356,7 +23369,7 @@ async function parsePdf(buffer, options) {
|
|
|
23356
23369
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
23357
23370
|
} catch (err) {
|
|
23358
23371
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
23359
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23372
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err), isImageBased };
|
|
23360
23373
|
}
|
|
23361
23374
|
}
|
|
23362
23375
|
async function parseXlsx(buffer, options) {
|
|
@@ -23364,7 +23377,7 @@ async function parseXlsx(buffer, options) {
|
|
|
23364
23377
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
23365
23378
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
23366
23379
|
} catch (err) {
|
|
23367
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23380
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23368
23381
|
}
|
|
23369
23382
|
}
|
|
23370
23383
|
async function parseXls(buffer, options) {
|
|
@@ -23372,15 +23385,15 @@ async function parseXls(buffer, options) {
|
|
|
23372
23385
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
23373
23386
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
23374
23387
|
} catch (err) {
|
|
23375
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23388
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23376
23389
|
}
|
|
23377
23390
|
}
|
|
23378
23391
|
async function parseDocx(buffer, options) {
|
|
23379
23392
|
try {
|
|
23380
23393
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
23381
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23394
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _258 => _258.length]) ? images : void 0 };
|
|
23382
23395
|
} catch (err) {
|
|
23383
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23396
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23384
23397
|
}
|
|
23385
23398
|
}
|
|
23386
23399
|
async function parseHwpml(buffer, options) {
|
|
@@ -23388,16 +23401,16 @@ async function parseHwpml(buffer, options) {
|
|
|
23388
23401
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
23389
23402
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
23390
23403
|
} catch (err) {
|
|
23391
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23404
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkW7JHJQ2Ocjs.classifyError.call(void 0, err) };
|
|
23392
23405
|
}
|
|
23393
23406
|
}
|
|
23394
23407
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
23395
23408
|
let buffer;
|
|
23396
23409
|
if (typeof input === "string") {
|
|
23397
23410
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23398
|
-
buffer =
|
|
23411
|
+
buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, buf);
|
|
23399
23412
|
} else if (Buffer.isBuffer(input)) {
|
|
23400
|
-
buffer =
|
|
23413
|
+
buffer = _chunkW7JHJQ2Ocjs.toArrayBuffer.call(void 0, input);
|
|
23401
23414
|
} else {
|
|
23402
23415
|
buffer = input;
|
|
23403
23416
|
}
|
|
@@ -23423,7 +23436,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23423
23436
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
23424
23437
|
}
|
|
23425
23438
|
const fill = fillFormFields(parsed.blocks, values);
|
|
23426
|
-
const markdown =
|
|
23439
|
+
const markdown = _chunkW7JHJQ2Ocjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
23427
23440
|
if (outputFormat === "hwpx") {
|
|
23428
23441
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
23429
23442
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -23471,5 +23484,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23471
23484
|
|
|
23472
23485
|
|
|
23473
23486
|
|
|
23474
|
-
exports.HwpxSession = HwpxSession; exports.VERSION =
|
|
23487
|
+
exports.HwpxSession = HwpxSession; exports.VERSION = _chunkW7JHJQ2Ocjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkW7JHJQ2Ocjs.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;
|
|
23475
23488
|
//# sourceMappingURL=index.cjs.map
|