kordoc 3.5.2 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-LYUGJZQG.js → -N2SJBI4R.js} +3 -3
- package/dist/{chunk-NOIHZQWC.js → chunk-3Z2RAKIL.js} +2 -2
- package/dist/{chunk-G44XLS26.cjs → chunk-53XNKPN6.cjs} +2 -2
- package/dist/{chunk-G44XLS26.cjs.map → chunk-53XNKPN6.cjs.map} +1 -1
- package/dist/{chunk-DN5LTND6.js → chunk-GUDFEDFK.js} +26 -23
- package/dist/{chunk-DN5LTND6.js.map → chunk-GUDFEDFK.js.map} +1 -1
- package/dist/{chunk-QXXQIZBH.js → chunk-JOLDAN3Q.js} +2 -2
- package/dist/cli.js +4 -4
- package/dist/index.cjs +135 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -22
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-2O276TRF.cjs → parser-CK5C6FF4.cjs} +14 -14
- package/dist/{parser-2O276TRF.cjs.map → parser-CK5C6FF4.cjs.map} +1 -1
- package/dist/{parser-4FFTFIYL.js → parser-CPFIB47T.js} +2 -2
- package/dist/{parser-KDF76UCB.js → parser-IAROZTY3.js} +2 -2
- package/dist/{watch-MF7JFR7S.js → watch-ZYNP3QFT.js} +3 -3
- package/package.json +1 -1
- /package/dist/{-LYUGJZQG.js.map → -N2SJBI4R.js.map} +0 -0
- /package/dist/{chunk-NOIHZQWC.js.map → chunk-3Z2RAKIL.js.map} +0 -0
- /package/dist/{chunk-QXXQIZBH.js.map → chunk-JOLDAN3Q.js.map} +0 -0
- /package/dist/{parser-4FFTFIYL.js.map → parser-CPFIB47T.js.map} +0 -0
- /package/dist/{parser-KDF76UCB.js.map → parser-IAROZTY3.js.map} +0 -0
- /package/dist/{watch-MF7JFR7S.js.map → watch-ZYNP3QFT.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunk53XNKPN6cjs = require('./chunk-53XNKPN6.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -845,7 +845,7 @@ function createSectionShared() {
|
|
|
845
845
|
function createXmlParser(warnings) {
|
|
846
846
|
return new (0, _xmldom.DOMParser)({
|
|
847
847
|
onError(level, msg2) {
|
|
848
|
-
if (level === "fatalError") throw new (0,
|
|
848
|
+
if (level === "fatalError") throw new (0, _chunk53XNKPN6cjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
849
849
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
850
850
|
}
|
|
851
851
|
});
|
|
@@ -867,10 +867,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
867
867
|
const xml = await file.async("text");
|
|
868
868
|
if (decompressed) {
|
|
869
869
|
decompressed.total += xml.length * 2;
|
|
870
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
870
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
871
871
|
}
|
|
872
872
|
const parser = createXmlParser();
|
|
873
|
-
const doc = parser.parseFromString(
|
|
873
|
+
const doc = parser.parseFromString(_chunk53XNKPN6cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
874
874
|
if (!doc.documentElement) continue;
|
|
875
875
|
parseCharProperties(doc, result.charProperties);
|
|
876
876
|
parseStyleElements(doc, result.styles);
|
|
@@ -1092,7 +1092,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1092
1092
|
return { prefix, headingLevel };
|
|
1093
1093
|
}
|
|
1094
1094
|
async function parseHwpxDocument(buffer, options) {
|
|
1095
|
-
|
|
1095
|
+
_chunk53XNKPN6cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
1096
1096
|
let zip;
|
|
1097
1097
|
try {
|
|
1098
1098
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -1101,7 +1101,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1101
1101
|
}
|
|
1102
1102
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
1103
1103
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
1104
|
-
throw new (0,
|
|
1104
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1105
1105
|
}
|
|
1106
1106
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
1107
1107
|
if (manifestFile) {
|
|
@@ -1113,7 +1113,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1113
1113
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
1114
1114
|
}
|
|
1115
1115
|
}
|
|
1116
|
-
throw new (0,
|
|
1116
|
+
throw new (0, _chunk53XNKPN6cjs.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.");
|
|
1117
1117
|
}
|
|
1118
1118
|
}
|
|
1119
1119
|
const decompressed = { total: 0 };
|
|
@@ -1122,7 +1122,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1122
1122
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
1123
1123
|
const warnings = [];
|
|
1124
1124
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
1125
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
1125
|
+
if (sectionPaths.length === 0) throw new (0, _chunk53XNKPN6cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1126
1126
|
metadata.pageCount = sectionPaths.length;
|
|
1127
1127
|
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
1128
1128
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -1136,12 +1136,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1136
1136
|
try {
|
|
1137
1137
|
const xml = await file.async("text");
|
|
1138
1138
|
decompressed.total += xml.length * 2;
|
|
1139
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1139
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1140
1140
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
1141
1141
|
parsedSections++;
|
|
1142
1142
|
_optionalChain([options, 'optionalAccess', _13 => _13.onProgress, 'optionalCall', _14 => _14(parsedSections, totalTarget)]);
|
|
1143
1143
|
} catch (secErr) {
|
|
1144
|
-
if (secErr instanceof
|
|
1144
|
+
if (secErr instanceof _chunk53XNKPN6cjs.KordocError) throw secErr;
|
|
1145
1145
|
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" });
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
@@ -1149,7 +1149,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1149
1149
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
1150
1150
|
detectHwpxHeadings(blocks, styleMap);
|
|
1151
1151
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
1152
|
-
const markdown =
|
|
1152
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
1153
1153
|
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 };
|
|
1154
1154
|
}
|
|
1155
1155
|
function applyPageText(blocks, shared) {
|
|
@@ -1238,13 +1238,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1238
1238
|
let found = false;
|
|
1239
1239
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1240
1240
|
for (const path of allCandidates) {
|
|
1241
|
-
if (
|
|
1241
|
+
if (_chunk53XNKPN6cjs.isPathTraversal.call(void 0, path)) continue;
|
|
1242
1242
|
const file = zip.file(path);
|
|
1243
1243
|
if (!file) continue;
|
|
1244
1244
|
try {
|
|
1245
1245
|
const data = await file.async("uint8array");
|
|
1246
1246
|
decompressed.total += data.length;
|
|
1247
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1247
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1248
1248
|
const actualPath = path;
|
|
1249
1249
|
const ext = actualPath.includes(".") ? actualPath.split(".").pop() || "png" : "png";
|
|
1250
1250
|
const mimeType = imageExtToMime(ext);
|
|
@@ -1257,7 +1257,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1257
1257
|
found = true;
|
|
1258
1258
|
break;
|
|
1259
1259
|
} catch (err) {
|
|
1260
|
-
if (err instanceof
|
|
1260
|
+
if (err instanceof _chunk53XNKPN6cjs.KordocError) throw err;
|
|
1261
1261
|
}
|
|
1262
1262
|
}
|
|
1263
1263
|
if (!found) {
|
|
@@ -1278,7 +1278,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
1278
1278
|
const xml = await file.async("text");
|
|
1279
1279
|
if (decompressed) {
|
|
1280
1280
|
decompressed.total += xml.length * 2;
|
|
1281
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1281
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1282
1282
|
}
|
|
1283
1283
|
parseDublinCoreMetadata(xml, metadata);
|
|
1284
1284
|
if (metadata.title || metadata.author) return;
|
|
@@ -1288,7 +1288,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
1288
1288
|
}
|
|
1289
1289
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
1290
1290
|
const parser = createXmlParser();
|
|
1291
|
-
const doc = parser.parseFromString(
|
|
1291
|
+
const doc = parser.parseFromString(_chunk53XNKPN6cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1292
1292
|
if (!doc.documentElement) return;
|
|
1293
1293
|
const getText = (tagNames) => {
|
|
1294
1294
|
for (const tag of tagNames) {
|
|
@@ -1348,7 +1348,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1348
1348
|
}
|
|
1349
1349
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1350
1350
|
const name = new TextDecoder().decode(nameBytes);
|
|
1351
|
-
if (
|
|
1351
|
+
if (_chunk53XNKPN6cjs.isPathTraversal.call(void 0, name)) {
|
|
1352
1352
|
pos = fileStart + compSize;
|
|
1353
1353
|
continue;
|
|
1354
1354
|
}
|
|
@@ -1366,16 +1366,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1366
1366
|
continue;
|
|
1367
1367
|
}
|
|
1368
1368
|
totalDecompressed += content.length * 2;
|
|
1369
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1369
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1370
1370
|
sectionNum++;
|
|
1371
1371
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1372
1372
|
} catch (e14) {
|
|
1373
1373
|
continue;
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
|
-
if (blocks.length === 0) throw new (0,
|
|
1376
|
+
if (blocks.length === 0) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1377
1377
|
applyPageText(blocks, shared);
|
|
1378
|
-
const markdown =
|
|
1378
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
1379
1379
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1380
1380
|
}
|
|
1381
1381
|
async function resolveSectionPaths(zip) {
|
|
@@ -1389,18 +1389,18 @@ async function resolveSectionPaths(zip) {
|
|
|
1389
1389
|
if (paths.length > 0) return paths;
|
|
1390
1390
|
}
|
|
1391
1391
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
1392
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
1392
|
+
return sectionFiles.map((f) => f.name).sort(_chunk53XNKPN6cjs.compareSectionPaths);
|
|
1393
1393
|
}
|
|
1394
1394
|
function parseSectionPathsFromManifest(xml) {
|
|
1395
1395
|
const parser = createXmlParser();
|
|
1396
|
-
const doc = parser.parseFromString(
|
|
1396
|
+
const doc = parser.parseFromString(_chunk53XNKPN6cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1397
1397
|
const items = doc.getElementsByTagName("opf:item");
|
|
1398
1398
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
1399
1399
|
const idToHref = /* @__PURE__ */ new Map();
|
|
1400
1400
|
for (let i = 0; i < items.length; i++) {
|
|
1401
1401
|
const item = items[i];
|
|
1402
1402
|
const id = item.getAttribute("id") || "";
|
|
1403
|
-
const href =
|
|
1403
|
+
const href = _chunk53XNKPN6cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
1404
1404
|
if (id && href) idToHref.set(id, href);
|
|
1405
1405
|
}
|
|
1406
1406
|
if (spine.length > 0) {
|
|
@@ -1411,7 +1411,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
1411
1411
|
}
|
|
1412
1412
|
if (ordered.length > 0) return ordered;
|
|
1413
1413
|
}
|
|
1414
|
-
return Array.from(idToHref.values()).sort(
|
|
1414
|
+
return Array.from(idToHref.values()).sort(_chunk53XNKPN6cjs.compareSectionPaths);
|
|
1415
1415
|
}
|
|
1416
1416
|
function detectHwpxHeadings(blocks, styleMap) {
|
|
1417
1417
|
if (blocks.some((b) => b.type === "heading")) return;
|
|
@@ -1436,9 +1436,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
1436
1436
|
let level = 0;
|
|
1437
1437
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _25 => _25.style, 'optionalAccess', _26 => _26.fontSize])) {
|
|
1438
1438
|
const ratio = block.style.fontSize / baseFontSize;
|
|
1439
|
-
if (ratio >=
|
|
1440
|
-
else if (ratio >=
|
|
1441
|
-
else if (ratio >=
|
|
1439
|
+
if (ratio >= _chunk53XNKPN6cjs.HEADING_RATIO_H1) level = 1;
|
|
1440
|
+
else if (ratio >= _chunk53XNKPN6cjs.HEADING_RATIO_H2) level = 2;
|
|
1441
|
+
else if (ratio >= _chunk53XNKPN6cjs.HEADING_RATIO_H3) level = 3;
|
|
1442
1442
|
}
|
|
1443
1443
|
const compactText = text.replace(/\s+/g, "");
|
|
1444
1444
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1451,7 +1451,7 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
1453
|
function buildTableWithCellMeta(state) {
|
|
1454
|
-
const table =
|
|
1454
|
+
const table = _chunk53XNKPN6cjs.buildTable.call(void 0, state.rows);
|
|
1455
1455
|
if (state.caption) table.caption = state.caption;
|
|
1456
1456
|
const claimed = /* @__PURE__ */ new Set();
|
|
1457
1457
|
for (const row of state.rows) {
|
|
@@ -1494,7 +1494,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1494
1494
|
const cell = parentTable.cell;
|
|
1495
1495
|
(cell.blocks ??= []).push(block);
|
|
1496
1496
|
cell.hasStructure = true;
|
|
1497
|
-
let flat =
|
|
1497
|
+
let flat = _chunk53XNKPN6cjs.convertTableToText.call(void 0, newTable.rows);
|
|
1498
1498
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1499
1499
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1500
1500
|
} else {
|
|
@@ -1504,7 +1504,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1506
1506
|
const parser = createXmlParser(warnings);
|
|
1507
|
-
const doc = parser.parseFromString(
|
|
1507
|
+
const doc = parser.parseFromString(_chunk53XNKPN6cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1508
1508
|
if (!doc.documentElement) return [];
|
|
1509
1509
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1510
1510
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1595,8 +1595,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1595
1595
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1596
1596
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1597
1597
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1598
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1599
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1598
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunk53XNKPN6cjs.MAX_COLS);
|
|
1599
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunk53XNKPN6cjs.MAX_ROWS);
|
|
1600
1600
|
}
|
|
1601
1601
|
break;
|
|
1602
1602
|
case "p": {
|
|
@@ -1818,7 +1818,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1818
1818
|
let url = (ch.textContent || "").trim();
|
|
1819
1819
|
if (!url) continue;
|
|
1820
1820
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1821
|
-
const safe =
|
|
1821
|
+
const safe = _chunk53XNKPN6cjs.sanitizeHref.call(void 0, url);
|
|
1822
1822
|
if (safe) return safe;
|
|
1823
1823
|
}
|
|
1824
1824
|
return void 0;
|
|
@@ -1953,7 +1953,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1953
1953
|
case "hyperlink": {
|
|
1954
1954
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1955
1955
|
if (url) {
|
|
1956
|
-
const safe =
|
|
1956
|
+
const safe = _chunk53XNKPN6cjs.sanitizeHref.call(void 0, url);
|
|
1957
1957
|
if (safe) href = safe;
|
|
1958
1958
|
}
|
|
1959
1959
|
walk(child);
|
|
@@ -2143,7 +2143,7 @@ function decompressStream(data) {
|
|
|
2143
2143
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2144
2144
|
}
|
|
2145
2145
|
function parseFileHeader(data) {
|
|
2146
|
-
if (data.length < 40) throw new (0,
|
|
2146
|
+
if (data.length < 40) throw new (0, _chunk53XNKPN6cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2147
2147
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2148
2148
|
return {
|
|
2149
2149
|
signature: sig,
|
|
@@ -3667,7 +3667,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3667
3667
|
lenientCfb = parseLenientCfb(buffer);
|
|
3668
3668
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3669
3669
|
} catch (e21) {
|
|
3670
|
-
throw new (0,
|
|
3670
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3671
3671
|
}
|
|
3672
3672
|
}
|
|
3673
3673
|
const findStream = (path) => {
|
|
@@ -3678,11 +3678,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3678
3678
|
return lenientCfb.findStream(path);
|
|
3679
3679
|
};
|
|
3680
3680
|
const headerData = findStream("/FileHeader");
|
|
3681
|
-
if (!headerData) throw new (0,
|
|
3681
|
+
if (!headerData) throw new (0, _chunk53XNKPN6cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3682
3682
|
const header = parseFileHeader(headerData);
|
|
3683
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3684
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3685
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3683
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunk53XNKPN6cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3684
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3685
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunk53XNKPN6cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3686
3686
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3687
3687
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3688
3688
|
const metadata = {
|
|
@@ -3691,7 +3691,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3691
3691
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3692
3692
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3693
3693
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3694
|
-
if (sections.length === 0) throw new (0,
|
|
3694
|
+
if (sections.length === 0) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3695
3695
|
metadata.pageCount = sections.length;
|
|
3696
3696
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3697
3697
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3705,25 +3705,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3705
3705
|
const sectionData = sections[si];
|
|
3706
3706
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3707
3707
|
totalDecompressed += data.length;
|
|
3708
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3708
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3709
3709
|
const records = readRecords(data);
|
|
3710
3710
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3711
3711
|
bodyBlocks.push(...sectionBlocks);
|
|
3712
3712
|
parsedSections++;
|
|
3713
3713
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3714
3714
|
} catch (secErr) {
|
|
3715
|
-
if (secErr instanceof
|
|
3715
|
+
if (secErr instanceof _chunk53XNKPN6cjs.KordocError) throw secErr;
|
|
3716
3716
|
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" });
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
3719
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3720
3720
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3721
|
-
const flatBlocks =
|
|
3721
|
+
const flatBlocks = _chunk53XNKPN6cjs.flattenLayoutTables.call(void 0, blocks);
|
|
3722
3722
|
if (docInfo) {
|
|
3723
3723
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3724
3724
|
}
|
|
3725
3725
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3726
|
-
const markdown =
|
|
3726
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3727
3727
|
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 };
|
|
3728
3728
|
}
|
|
3729
3729
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3783,9 +3783,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3783
3783
|
let level = 0;
|
|
3784
3784
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3785
3785
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3786
|
-
if (ratio >=
|
|
3787
|
-
else if (ratio >=
|
|
3788
|
-
else if (ratio >=
|
|
3786
|
+
if (ratio >= _chunk53XNKPN6cjs.HEADING_RATIO_H1) level = 1;
|
|
3787
|
+
else if (ratio >= _chunk53XNKPN6cjs.HEADING_RATIO_H2) level = 2;
|
|
3788
|
+
else if (ratio >= _chunk53XNKPN6cjs.HEADING_RATIO_H3) level = 3;
|
|
3789
3789
|
}
|
|
3790
3790
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3791
3791
|
if (level === 0) level = 2;
|
|
@@ -3870,7 +3870,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3870
3870
|
if (!raw) break;
|
|
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, _chunk53XNKPN6cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3874
3874
|
sections.push({ idx: i, content });
|
|
3875
3875
|
}
|
|
3876
3876
|
if (sections.length === 0) {
|
|
@@ -3882,7 +3882,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3882
3882
|
if (raw) {
|
|
3883
3883
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3884
3884
|
totalDecompressed += content.length;
|
|
3885
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3885
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3886
3886
|
sections.push({ idx, content });
|
|
3887
3887
|
}
|
|
3888
3888
|
}
|
|
@@ -3899,7 +3899,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3899
3899
|
try {
|
|
3900
3900
|
const content = decryptViewText(raw, compressed);
|
|
3901
3901
|
totalDecompressed += content.length;
|
|
3902
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3902
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk53XNKPN6cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3903
3903
|
sections.push({ idx: i, content });
|
|
3904
3904
|
} catch (e26) {
|
|
3905
3905
|
break;
|
|
@@ -4002,7 +4002,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4002
4002
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4003
4003
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
4004
4004
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4005
|
-
const href =
|
|
4005
|
+
const href = _chunk53XNKPN6cjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4006
4006
|
if (!href) continue;
|
|
4007
4007
|
const anchor = text.slice(r.start, r.end);
|
|
4008
4008
|
if (!anchor.trim()) continue;
|
|
@@ -4235,8 +4235,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4235
4235
|
let tableIdx = -1;
|
|
4236
4236
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4237
4237
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4238
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4239
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4238
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunk53XNKPN6cjs.MAX_ROWS);
|
|
4239
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunk53XNKPN6cjs.MAX_COLS);
|
|
4240
4240
|
tableIdx = i2;
|
|
4241
4241
|
break;
|
|
4242
4242
|
}
|
|
@@ -4285,7 +4285,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4285
4285
|
return table2;
|
|
4286
4286
|
}
|
|
4287
4287
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4288
|
-
const table =
|
|
4288
|
+
const table = _chunk53XNKPN6cjs.buildTable.call(void 0, cellRows);
|
|
4289
4289
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4290
4290
|
return table.rows > 0 ? table : null;
|
|
4291
4291
|
}
|
|
@@ -4302,8 +4302,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4302
4302
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4303
4303
|
const cs = rec.data.readUInt16LE(12);
|
|
4304
4304
|
const rs = rec.data.readUInt16LE(14);
|
|
4305
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4306
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4305
|
+
if (cs > 0) colSpan = Math.min(cs, _chunk53XNKPN6cjs.MAX_COLS);
|
|
4306
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunk53XNKPN6cjs.MAX_ROWS);
|
|
4307
4307
|
}
|
|
4308
4308
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4309
4309
|
const parts = [];
|
|
@@ -4313,7 +4313,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4313
4313
|
parts.push(``);
|
|
4314
4314
|
hasStructure = true;
|
|
4315
4315
|
} else if (b.type === "table" && b.table) {
|
|
4316
|
-
const flat =
|
|
4316
|
+
const flat = _chunk53XNKPN6cjs.convertTableToText.call(void 0, b.table.cells);
|
|
4317
4317
|
if (flat) parts.push(flat);
|
|
4318
4318
|
hasStructure = true;
|
|
4319
4319
|
} else if (b.text) {
|
|
@@ -16747,7 +16747,7 @@ function getTextContent(el) {
|
|
|
16747
16747
|
return _nullishCoalesce(_optionalChain([el, 'access', _79 => _79.textContent, 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]), () => ( ""));
|
|
16748
16748
|
}
|
|
16749
16749
|
function parseXml(text) {
|
|
16750
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16750
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk53XNKPN6cjs.stripDtd.call(void 0, text), "text/xml");
|
|
16751
16751
|
}
|
|
16752
16752
|
function parseSharedStrings(xml) {
|
|
16753
16753
|
const doc = parseXml(xml);
|
|
@@ -16891,7 +16891,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16891
16891
|
cellRows.push(row);
|
|
16892
16892
|
}
|
|
16893
16893
|
if (cellRows.length > 0) {
|
|
16894
|
-
const table =
|
|
16894
|
+
const table = _chunk53XNKPN6cjs.buildTable.call(void 0, cellRows);
|
|
16895
16895
|
if (table.rows > 0) {
|
|
16896
16896
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16897
16897
|
}
|
|
@@ -16899,12 +16899,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16899
16899
|
return blocks;
|
|
16900
16900
|
}
|
|
16901
16901
|
async function parseXlsxDocument(buffer, options) {
|
|
16902
|
-
|
|
16902
|
+
_chunk53XNKPN6cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16903
16903
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16904
16904
|
const warnings = [];
|
|
16905
16905
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16906
16906
|
if (!workbookFile) {
|
|
16907
|
-
throw new (0,
|
|
16907
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16908
16908
|
}
|
|
16909
16909
|
let sharedStrings = [];
|
|
16910
16910
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16913,7 +16913,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16913
16913
|
}
|
|
16914
16914
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16915
16915
|
if (sheets.length === 0) {
|
|
16916
|
-
throw new (0,
|
|
16916
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16917
16917
|
}
|
|
16918
16918
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16919
16919
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16985,7 +16985,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16985
16985
|
} catch (e27) {
|
|
16986
16986
|
}
|
|
16987
16987
|
}
|
|
16988
|
-
const markdown =
|
|
16988
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
16989
16989
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
16990
16990
|
}
|
|
16991
16991
|
|
|
@@ -17392,11 +17392,11 @@ function processGlobals(records) {
|
|
|
17392
17392
|
let encrypted = false;
|
|
17393
17393
|
const firstBof = records[0];
|
|
17394
17394
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17395
|
-
throw new (0,
|
|
17395
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17396
17396
|
}
|
|
17397
17397
|
const bof = decodeBof(firstBof.data);
|
|
17398
17398
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17399
|
-
throw new (0,
|
|
17399
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17400
17400
|
}
|
|
17401
17401
|
let i = 1;
|
|
17402
17402
|
while (i < records.length) {
|
|
@@ -17511,7 +17511,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17511
17511
|
cellRows.push(row);
|
|
17512
17512
|
}
|
|
17513
17513
|
if (cellRows.length > 0) {
|
|
17514
|
-
const table =
|
|
17514
|
+
const table = _chunk53XNKPN6cjs.buildTable.call(void 0, cellRows);
|
|
17515
17515
|
if (table.rows > 0) {
|
|
17516
17516
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17517
17517
|
}
|
|
@@ -17524,21 +17524,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17524
17524
|
try {
|
|
17525
17525
|
cfb = parseLenientCfb(buf);
|
|
17526
17526
|
} catch (e) {
|
|
17527
|
-
throw new (0,
|
|
17527
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)(
|
|
17528
17528
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17529
17529
|
);
|
|
17530
17530
|
}
|
|
17531
17531
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17532
17532
|
if (!wb) {
|
|
17533
|
-
throw new (0,
|
|
17533
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17534
17534
|
}
|
|
17535
17535
|
const records = readRecords2(wb);
|
|
17536
17536
|
if (records.length === 0) {
|
|
17537
|
-
throw new (0,
|
|
17537
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17538
17538
|
}
|
|
17539
17539
|
const firstBof = decodeBof(records[0].data);
|
|
17540
17540
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17541
|
-
throw new (0,
|
|
17541
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)(
|
|
17542
17542
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17543
17543
|
);
|
|
17544
17544
|
}
|
|
@@ -17598,7 +17598,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17598
17598
|
pageCount: totalSheets
|
|
17599
17599
|
};
|
|
17600
17600
|
return {
|
|
17601
|
-
markdown:
|
|
17601
|
+
markdown: _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17602
17602
|
blocks: allBlocks,
|
|
17603
17603
|
metadata,
|
|
17604
17604
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18036,7 +18036,7 @@ function getAttr(el, localName2) {
|
|
|
18036
18036
|
return null;
|
|
18037
18037
|
}
|
|
18038
18038
|
function parseXml2(text) {
|
|
18039
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18039
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk53XNKPN6cjs.stripDtd.call(void 0, text), "text/xml");
|
|
18040
18040
|
}
|
|
18041
18041
|
function parseStyles(xml) {
|
|
18042
18042
|
const doc = parseXml2(xml);
|
|
@@ -18355,12 +18355,12 @@ async function extractImages(zip, rels, doc) {
|
|
|
18355
18355
|
return { blocks, images };
|
|
18356
18356
|
}
|
|
18357
18357
|
async function parseDocxDocument(buffer, options) {
|
|
18358
|
-
|
|
18358
|
+
_chunk53XNKPN6cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18359
18359
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18360
18360
|
const warnings = [];
|
|
18361
18361
|
const docFile = zip.file("word/document.xml");
|
|
18362
18362
|
if (!docFile) {
|
|
18363
|
-
throw new (0,
|
|
18363
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18364
18364
|
}
|
|
18365
18365
|
let rels = /* @__PURE__ */ new Map();
|
|
18366
18366
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18395,7 +18395,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18395
18395
|
const doc = parseXml2(docXml);
|
|
18396
18396
|
const body = findElements(doc, "body");
|
|
18397
18397
|
if (body.length === 0) {
|
|
18398
|
-
throw new (0,
|
|
18398
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18399
18399
|
}
|
|
18400
18400
|
const blocks = [];
|
|
18401
18401
|
const bodyEl = body[0];
|
|
@@ -18432,7 +18432,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18432
18432
|
}
|
|
18433
18433
|
}
|
|
18434
18434
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18435
|
-
const markdown =
|
|
18435
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18436
18436
|
return {
|
|
18437
18437
|
markdown,
|
|
18438
18438
|
blocks,
|
|
@@ -18455,7 +18455,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18455
18455
|
}
|
|
18456
18456
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18457
18457
|
const normalized = text.replace(/ /g, " ");
|
|
18458
|
-
const xml =
|
|
18458
|
+
const xml = _chunk53XNKPN6cjs.stripDtd.call(void 0, normalized);
|
|
18459
18459
|
const warnings = [];
|
|
18460
18460
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18461
18461
|
onError: (_level, msg2) => {
|
|
@@ -18495,7 +18495,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18495
18495
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18496
18496
|
}
|
|
18497
18497
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18498
|
-
const markdown =
|
|
18498
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18499
18499
|
return {
|
|
18500
18500
|
markdown,
|
|
18501
18501
|
blocks,
|
|
@@ -18637,7 +18637,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18637
18637
|
const cellRows = grid.map(
|
|
18638
18638
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18639
18639
|
);
|
|
18640
|
-
const table =
|
|
18640
|
+
const table = _chunk53XNKPN6cjs.buildTable.call(void 0, cellRows);
|
|
18641
18641
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18642
18642
|
}
|
|
18643
18643
|
function extractCellText(cellEl) {
|
|
@@ -19664,19 +19664,19 @@ function parseCentralDirectory(buf) {
|
|
|
19664
19664
|
}
|
|
19665
19665
|
}
|
|
19666
19666
|
}
|
|
19667
|
-
if (eocdOffset < 0) throw new (0,
|
|
19667
|
+
if (eocdOffset < 0) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19668
19668
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19669
19669
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19670
19670
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19671
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19671
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19672
19672
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19673
|
-
throw new (0,
|
|
19673
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19674
19674
|
}
|
|
19675
19675
|
const decoder = new TextDecoder("utf-8");
|
|
19676
19676
|
const entries = [];
|
|
19677
19677
|
let pos = cdOffset;
|
|
19678
19678
|
for (let i = 0; i < totalEntries; i++) {
|
|
19679
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19679
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19680
19680
|
const flags = view.getUint16(pos + 8, true);
|
|
19681
19681
|
const method = view.getUint16(pos + 10, true);
|
|
19682
19682
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19687,7 +19687,7 @@ function parseCentralDirectory(buf) {
|
|
|
19687
19687
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19688
19688
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19689
19689
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19690
|
-
throw new (0,
|
|
19690
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19691
19691
|
}
|
|
19692
19692
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19693
19693
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19716,7 +19716,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19716
19716
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19717
19717
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19718
19718
|
for (const name of replacements.keys()) {
|
|
19719
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19719
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunk53XNKPN6cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19720
19720
|
}
|
|
19721
19721
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19722
19722
|
const segments = [];
|
|
@@ -19734,7 +19734,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19734
19734
|
offset += seg.length;
|
|
19735
19735
|
continue;
|
|
19736
19736
|
}
|
|
19737
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
19737
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunk53XNKPN6cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19738
19738
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19739
19739
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19740
19740
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -19789,7 +19789,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19789
19789
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
19790
19790
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
19791
19791
|
if (sectionPaths.length === 0) {
|
|
19792
|
-
throw new (0,
|
|
19792
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19793
19793
|
}
|
|
19794
19794
|
const normalizedValues = normalizeValues(values);
|
|
19795
19795
|
const matchedLabels = /* @__PURE__ */ new Set();
|
|
@@ -20372,24 +20372,26 @@ function generateManifest() {
|
|
|
20372
20372
|
</opf:spine>
|
|
20373
20373
|
</opf:package>`;
|
|
20374
20374
|
}
|
|
20375
|
-
function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_COLOR) {
|
|
20375
|
+
function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_COLOR, ratioPct = 100) {
|
|
20376
20376
|
const boldAttr = bold ? ` bold="1"` : "";
|
|
20377
20377
|
const italicAttr = italic ? ` italic="1"` : "";
|
|
20378
20378
|
const effFont = bold ? 2 : fontId;
|
|
20379
20379
|
return ` <hh:charPr id="${id}" height="${height}" textColor="${textColor}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="0"${boldAttr}${italicAttr}>
|
|
20380
20380
|
<hh:fontRef hangul="${effFont}" latin="${effFont}" hanja="${effFont}" japanese="${effFont}" other="${effFont}" symbol="${effFont}" user="${effFont}"/>
|
|
20381
|
-
<hh:ratio hangul="
|
|
20381
|
+
<hh:ratio hangul="${ratioPct}" latin="${ratioPct}" hanja="${ratioPct}" japanese="100" other="100" symbol="100" user="100"/>
|
|
20382
20382
|
<hh:spacing hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
20383
20383
|
<hh:relSz hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
20384
20384
|
<hh:offset hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
20385
20385
|
</hh:charPr>`;
|
|
20386
20386
|
}
|
|
20387
20387
|
function paraPr(id, opts = {}) {
|
|
20388
|
-
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0 } = opts;
|
|
20389
|
-
|
|
20388
|
+
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0, keepWord = false } = opts;
|
|
20389
|
+
const breakNonLatin = keepWord ? "KEEP_WORD" : "BREAK_WORD";
|
|
20390
|
+
const snapGrid = keepWord ? "0" : "1";
|
|
20391
|
+
return ` <hh:paraPr id="${id}" tabPrIDRef="0" condense="0" fontLineHeight="0" snapToGrid="${snapGrid}" suppressLineNumbers="0" checked="0" textDir="AUTO">
|
|
20390
20392
|
<hh:align horizontal="${align}" vertical="BASELINE"/>
|
|
20391
20393
|
<hh:heading type="NONE" idRef="0" level="0"/>
|
|
20392
|
-
<hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="
|
|
20394
|
+
<hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="${breakNonLatin}" widowOrphan="0" keepWithNext="0" keepLines="0" pageBreakBefore="0" lineWrap="BREAK"/>
|
|
20393
20395
|
<hh:autoSpacing eAsianEng="0" eAsianNum="0"/>
|
|
20394
20396
|
<hh:margin><hc:intent value="${indent}" unit="HWPUNIT"/><hc:left value="${left}" unit="HWPUNIT"/><hc:right value="0" unit="HWPUNIT"/><hc:prev value="${spaceBefore}" unit="HWPUNIT"/><hc:next value="${spaceAfter}" unit="HWPUNIT"/></hh:margin>
|
|
20395
20397
|
<hh:lineSpacing type="PERCENT" value="${lineSpacing}"/>
|
|
@@ -20409,11 +20411,12 @@ function buildCharProperties(theme, gongmun) {
|
|
|
20409
20411
|
h3 = body;
|
|
20410
20412
|
h4 = Math.max(body - 100, 1300);
|
|
20411
20413
|
}
|
|
20414
|
+
const bodyRatio = gongmun ? 95 : 100;
|
|
20412
20415
|
const rows = [
|
|
20413
|
-
charPr(0, body, false, false, 0, theme.body),
|
|
20414
|
-
charPr(1, body, true, false, 0, theme.body),
|
|
20415
|
-
charPr(2, body, false, true, 0, theme.body),
|
|
20416
|
-
charPr(3, body, true, true, 0, theme.body),
|
|
20416
|
+
charPr(0, body, false, false, 0, theme.body, bodyRatio),
|
|
20417
|
+
charPr(1, body, true, false, 0, theme.body, bodyRatio),
|
|
20418
|
+
charPr(2, body, false, true, 0, theme.body, bodyRatio),
|
|
20419
|
+
charPr(3, body, true, true, 0, theme.body, bodyRatio),
|
|
20417
20420
|
charPr(4, code, false, false, 1),
|
|
20418
20421
|
charPr(5, h1, true, false, 1, theme.h1),
|
|
20419
20422
|
charPr(6, h2, true, false, 1, theme.h2),
|
|
@@ -20445,21 +20448,21 @@ ${base2.join("\n")}
|
|
|
20445
20448
|
const ls = gongmun.lineSpacing;
|
|
20446
20449
|
const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
|
|
20447
20450
|
const base = [
|
|
20448
|
-
paraPr(0, { lineSpacing: ls }),
|
|
20449
|
-
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls }),
|
|
20450
|
-
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls }),
|
|
20451
|
-
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls }),
|
|
20452
|
-
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls }),
|
|
20453
|
-
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20454
|
-
paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600 }),
|
|
20455
|
-
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600 })
|
|
20451
|
+
paraPr(0, { lineSpacing: ls, keepWord: true }),
|
|
20452
|
+
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls, keepWord: true }),
|
|
20453
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls, keepWord: true }),
|
|
20454
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
20455
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
20456
|
+
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400, keepWord: true }),
|
|
20457
|
+
paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true }),
|
|
20458
|
+
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true })
|
|
20456
20459
|
];
|
|
20457
20460
|
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
20458
20461
|
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering);
|
|
20459
20462
|
const sectionGap = gongmun.numbering === "report" && d === 0 ? Math.round(gongmun.bodyHeight * 0.5) : 0;
|
|
20460
|
-
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent, spaceBefore: sectionGap }));
|
|
20463
|
+
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent, spaceBefore: sectionGap, keepWord: true }));
|
|
20461
20464
|
}
|
|
20462
|
-
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls }));
|
|
20465
|
+
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls, keepWord: true }));
|
|
20463
20466
|
return `<hh:paraProperties itemCnt="${base.length}">
|
|
20464
20467
|
${base.join("\n")}
|
|
20465
20468
|
</hh:paraProperties>`;
|
|
@@ -20552,7 +20555,7 @@ function generateHeaderXml(theme, gongmun) {
|
|
|
20552
20555
|
<hh:style id="0" type="PARA" name="\uBC14\uD0D5\uAE00" engName="Normal" paraPrIDRef="0" charPrIDRef="0" nextStyleIDRef="0" langIDRef="1042" lockForm="0"/>
|
|
20553
20556
|
</hh:styles>
|
|
20554
20557
|
</hh:refList>
|
|
20555
|
-
<hh:compatibleDocument targetProgram="HWP2018"
|
|
20558
|
+
<hh:compatibleDocument targetProgram="HWP2018"><hh:layoutCompatibility/></hh:compatibleDocument>
|
|
20556
20559
|
</hh:head>`;
|
|
20557
20560
|
}
|
|
20558
20561
|
function generateSecPr(gongmun) {
|
|
@@ -20963,7 +20966,7 @@ function escapeGfm(text) {
|
|
|
20963
20966
|
}
|
|
20964
20967
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
20965
20968
|
function sanitizeText(text) {
|
|
20966
|
-
let result =
|
|
20969
|
+
let result = _chunk53XNKPN6cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
20967
20970
|
if (result.length <= 30 && result.includes(" ")) {
|
|
20968
20971
|
const tokens = result.split(" ");
|
|
20969
20972
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21490,7 +21493,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
21490
21493
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
21491
21494
|
if (paths.length > 0) return paths;
|
|
21492
21495
|
}
|
|
21493
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
21496
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk53XNKPN6cjs.compareSectionPaths);
|
|
21494
21497
|
}
|
|
21495
21498
|
function sectionPathsFromManifest(xml) {
|
|
21496
21499
|
const attr = (tag, name) => {
|
|
@@ -21500,7 +21503,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
21500
21503
|
const idToHref = /* @__PURE__ */ new Map();
|
|
21501
21504
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
21502
21505
|
const id = attr(m[1], "id");
|
|
21503
|
-
const href =
|
|
21506
|
+
const href = _chunk53XNKPN6cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
21504
21507
|
if (id && href) idToHref.set(id, href);
|
|
21505
21508
|
}
|
|
21506
21509
|
const ordered = [];
|
|
@@ -21509,7 +21512,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
21509
21512
|
if (href) ordered.push(href);
|
|
21510
21513
|
}
|
|
21511
21514
|
if (ordered.length > 0) return ordered;
|
|
21512
|
-
return Array.from(idToHref.values()).sort(
|
|
21515
|
+
return Array.from(idToHref.values()).sort(_chunk53XNKPN6cjs.compareSectionPaths);
|
|
21513
21516
|
}
|
|
21514
21517
|
|
|
21515
21518
|
// src/roundtrip/patcher.ts
|
|
@@ -21619,9 +21622,9 @@ function buildOrigUnits(blocks) {
|
|
|
21619
21622
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
21620
21623
|
const next = blocks[i + 1];
|
|
21621
21624
|
if (_optionalChain([next, 'optionalAccess', _198 => _198.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
21622
|
-
chunk =
|
|
21625
|
+
chunk = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
21623
21626
|
} else {
|
|
21624
|
-
chunk =
|
|
21627
|
+
chunk = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, [block]);
|
|
21625
21628
|
}
|
|
21626
21629
|
if (chunk) {
|
|
21627
21630
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -23362,13 +23365,13 @@ async function htmlToPdf(html, options) {
|
|
|
23362
23365
|
try {
|
|
23363
23366
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
23364
23367
|
} catch (e35) {
|
|
23365
|
-
throw new (0,
|
|
23368
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)(
|
|
23366
23369
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
23367
23370
|
);
|
|
23368
23371
|
}
|
|
23369
23372
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
23370
23373
|
if (!executablePath) {
|
|
23371
|
-
throw new (0,
|
|
23374
|
+
throw new (0, _chunk53XNKPN6cjs.KordocError)(
|
|
23372
23375
|
"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."
|
|
23373
23376
|
);
|
|
23374
23377
|
}
|
|
@@ -23427,7 +23430,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
23427
23430
|
return htmlToPdf(html, options);
|
|
23428
23431
|
}
|
|
23429
23432
|
async function blocksToPdf(blocks, options) {
|
|
23430
|
-
const markdown =
|
|
23433
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
23431
23434
|
return markdownToPdf(markdown, options);
|
|
23432
23435
|
}
|
|
23433
23436
|
|
|
@@ -23438,13 +23441,13 @@ async function parse(input, options) {
|
|
|
23438
23441
|
if (typeof input === "string") {
|
|
23439
23442
|
try {
|
|
23440
23443
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23441
|
-
buffer =
|
|
23444
|
+
buffer = _chunk53XNKPN6cjs.toArrayBuffer.call(void 0, buf);
|
|
23442
23445
|
} catch (err) {
|
|
23443
23446
|
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}`;
|
|
23444
23447
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
23445
23448
|
}
|
|
23446
23449
|
} else if (Buffer.isBuffer(input)) {
|
|
23447
|
-
buffer =
|
|
23450
|
+
buffer = _chunk53XNKPN6cjs.toArrayBuffer.call(void 0, input);
|
|
23448
23451
|
} else {
|
|
23449
23452
|
buffer = input;
|
|
23450
23453
|
}
|
|
@@ -23479,7 +23482,7 @@ async function parseHwp3(buffer, options) {
|
|
|
23479
23482
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
23480
23483
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
23481
23484
|
} catch (err) {
|
|
23482
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23485
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23483
23486
|
}
|
|
23484
23487
|
}
|
|
23485
23488
|
async function parseHwpx(buffer, options) {
|
|
@@ -23487,7 +23490,7 @@ async function parseHwpx(buffer, options) {
|
|
|
23487
23490
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
23488
23491
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _256 => _256.length]) ? images : void 0 };
|
|
23489
23492
|
} catch (err) {
|
|
23490
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23493
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23491
23494
|
}
|
|
23492
23495
|
}
|
|
23493
23496
|
async function parseHwp(buffer, options) {
|
|
@@ -23512,13 +23515,13 @@ async function parseHwp(buffer, options) {
|
|
|
23512
23515
|
}
|
|
23513
23516
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _258 => _258.length]) ? images : void 0 };
|
|
23514
23517
|
} catch (err) {
|
|
23515
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23518
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23516
23519
|
}
|
|
23517
23520
|
}
|
|
23518
23521
|
async function parsePdf(buffer, options) {
|
|
23519
23522
|
let parsePdfDocument;
|
|
23520
23523
|
try {
|
|
23521
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
23524
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-CK5C6FF4.cjs")));
|
|
23522
23525
|
parsePdfDocument = mod.parsePdfDocument;
|
|
23523
23526
|
} catch (e37) {
|
|
23524
23527
|
return {
|
|
@@ -23533,7 +23536,7 @@ async function parsePdf(buffer, options) {
|
|
|
23533
23536
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
23534
23537
|
} catch (err) {
|
|
23535
23538
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
23536
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23539
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err), isImageBased };
|
|
23537
23540
|
}
|
|
23538
23541
|
}
|
|
23539
23542
|
async function parseXlsx(buffer, options) {
|
|
@@ -23541,7 +23544,7 @@ async function parseXlsx(buffer, options) {
|
|
|
23541
23544
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
23542
23545
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
23543
23546
|
} catch (err) {
|
|
23544
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23547
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23545
23548
|
}
|
|
23546
23549
|
}
|
|
23547
23550
|
async function parseXls(buffer, options) {
|
|
@@ -23549,7 +23552,7 @@ async function parseXls(buffer, options) {
|
|
|
23549
23552
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
23550
23553
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
23551
23554
|
} catch (err) {
|
|
23552
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23555
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23553
23556
|
}
|
|
23554
23557
|
}
|
|
23555
23558
|
async function parseDocx(buffer, options) {
|
|
@@ -23557,7 +23560,7 @@ async function parseDocx(buffer, options) {
|
|
|
23557
23560
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
23558
23561
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _259 => _259.length]) ? images : void 0 };
|
|
23559
23562
|
} catch (err) {
|
|
23560
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23563
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23561
23564
|
}
|
|
23562
23565
|
}
|
|
23563
23566
|
async function parseHwpml(buffer, options) {
|
|
@@ -23565,16 +23568,16 @@ async function parseHwpml(buffer, options) {
|
|
|
23565
23568
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
23566
23569
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
23567
23570
|
} catch (err) {
|
|
23568
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23571
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk53XNKPN6cjs.classifyError.call(void 0, err) };
|
|
23569
23572
|
}
|
|
23570
23573
|
}
|
|
23571
23574
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
23572
23575
|
let buffer;
|
|
23573
23576
|
if (typeof input === "string") {
|
|
23574
23577
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23575
|
-
buffer =
|
|
23578
|
+
buffer = _chunk53XNKPN6cjs.toArrayBuffer.call(void 0, buf);
|
|
23576
23579
|
} else if (Buffer.isBuffer(input)) {
|
|
23577
|
-
buffer =
|
|
23580
|
+
buffer = _chunk53XNKPN6cjs.toArrayBuffer.call(void 0, input);
|
|
23578
23581
|
} else {
|
|
23579
23582
|
buffer = input;
|
|
23580
23583
|
}
|
|
@@ -23600,7 +23603,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23600
23603
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
23601
23604
|
}
|
|
23602
23605
|
const fill = fillFormFields(parsed.blocks, values);
|
|
23603
|
-
const markdown =
|
|
23606
|
+
const markdown = _chunk53XNKPN6cjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
23604
23607
|
if (outputFormat === "hwpx") {
|
|
23605
23608
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
23606
23609
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -23650,5 +23653,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23650
23653
|
|
|
23651
23654
|
|
|
23652
23655
|
|
|
23653
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.VERSION =
|
|
23656
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.VERSION = _chunk53XNKPN6cjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk53XNKPN6cjs.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.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml;
|
|
23654
23657
|
//# sourceMappingURL=index.cjs.map
|