kordoc 3.1.1 → 3.2.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/README.md +584 -559
- package/dist/{-UCE73NNK.js → -NMUBDTYV.js} +4 -4
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-KR6DSGM7.js → chunk-F4A7OTBT.js} +2 -2
- package/dist/chunk-F4A7OTBT.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-VMUP5WPI.js → chunk-LPKAF45D.js} +257 -43
- package/dist/chunk-LPKAF45D.js.map +1 -0
- package/dist/{chunk-5CJGKKMZ.js → chunk-MEPHGCPQ.js} +1 -1
- package/dist/chunk-MEPHGCPQ.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-ZZNSI4GV.js → chunk-Q7IWG4E3.js} +2 -2
- package/dist/chunk-Q7IWG4E3.js.map +1 -0
- package/dist/{chunk-FJON4QNB.cjs → chunk-ZY524HB6.cjs} +2 -2
- package/dist/chunk-ZY524HB6.cjs.map +1 -0
- package/dist/cli.js +72 -5
- package/dist/cli.js.map +1 -1
- package/dist/{detect-PJZMUL2Z.js → detect-RI2MQ33K.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +419 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +255 -41
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +5 -5
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +0 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-XULVNDMN.cjs → parser-CV3FOVOS.cjs} +15 -15
- package/dist/parser-CV3FOVOS.cjs.map +1 -0
- package/dist/{parser-4L7UFVEP.js → parser-HC5NXB3F.js} +3 -3
- package/dist/parser-HC5NXB3F.js.map +1 -0
- package/dist/{parser-QTJL6IQY.js → parser-ZWGQCMRS.js} +3 -3
- package/dist/parser-ZWGQCMRS.js.map +1 -0
- package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/provider-4ZJKV3DC.js.map +1 -0
- package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
- package/dist/provider-AKROB7WQ.js.map +1 -0
- package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-FPDSHB23.js → watch-IUEQDWC3.js} +4 -4
- package/dist/watch-IUEQDWC3.js.map +1 -0
- package/package.json +98 -98
- package/dist/chunk-5CJGKKMZ.js.map +0 -1
- package/dist/chunk-FJON4QNB.cjs.map +0 -1
- package/dist/chunk-KR6DSGM7.js.map +0 -1
- package/dist/chunk-VMUP5WPI.js.map +0 -1
- package/dist/chunk-ZZNSI4GV.js.map +0 -1
- package/dist/parser-4L7UFVEP.js.map +0 -1
- package/dist/parser-QTJL6IQY.js.map +0 -1
- package/dist/parser-XULVNDMN.cjs.map +0 -1
- package/dist/provider-5K7O3Z2O.cjs.map +0 -1
- package/dist/provider-7H4CPZYS.js.map +0 -1
- package/dist/provider-H4WWSPOV.js.map +0 -1
- package/dist/watch-FPDSHB23.js.map +0 -1
- /package/dist/{-UCE73NNK.js.map → -NMUBDTYV.js.map} +0 -0
- /package/dist/{detect-PJZMUL2Z.js.map → detect-RI2MQ33K.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkZY524HB6cjs = require('./chunk-ZY524HB6.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -828,7 +828,7 @@ function createSectionShared() {
|
|
|
828
828
|
function createXmlParser(warnings) {
|
|
829
829
|
return new (0, _xmldom.DOMParser)({
|
|
830
830
|
onError(level, msg2) {
|
|
831
|
-
if (level === "fatalError") throw new (0,
|
|
831
|
+
if (level === "fatalError") throw new (0, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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(_chunkZY524HB6cjs.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
|
+
_chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
1100
1100
|
}
|
|
1101
1101
|
}
|
|
1102
1102
|
const decompressed = { total: 0 };
|
|
@@ -1105,7 +1105,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1105
1105
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
1106
1106
|
const warnings = [];
|
|
1107
1107
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
1108
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
1108
|
+
if (sectionPaths.length === 0) throw new (0, _chunkZY524HB6cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1109
1109
|
metadata.pageCount = sectionPaths.length;
|
|
1110
1110
|
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
1111
1111
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -1119,12 +1119,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1119
1119
|
try {
|
|
1120
1120
|
const xml = await file.async("text");
|
|
1121
1121
|
decompressed.total += xml.length * 2;
|
|
1122
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1122
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZY524HB6cjs.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 _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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 (_chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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 _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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(_chunkZY524HB6cjs.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 (_chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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(_chunkZY524HB6cjs.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 >= _chunkZY524HB6cjs.HEADING_RATIO_H1) level = 1;
|
|
1428
|
+
else if (ratio >= _chunkZY524HB6cjs.HEADING_RATIO_H2) level = 2;
|
|
1429
|
+
else if (ratio >= _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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(_chunkZY524HB6cjs.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, _chunkZY524HB6cjs.MAX_COLS);
|
|
1587
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3672
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkZY524HB6cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3673
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkZY524HB6cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3674
3674
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3675
3675
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3676
3676
|
const metadata = {
|
|
@@ -3679,7 +3679,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3679
3679
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3680
3680
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3681
3681
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3682
|
-
if (sections.length === 0) throw new (0,
|
|
3682
|
+
if (sections.length === 0) throw new (0, _chunkZY524HB6cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3683
3683
|
metadata.pageCount = sections.length;
|
|
3684
3684
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3685
3685
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3693,25 +3693,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3693
3693
|
const sectionData = sections[si];
|
|
3694
3694
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3695
3695
|
totalDecompressed += data.length;
|
|
3696
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3696
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZY524HB6cjs.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 _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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 >= _chunkZY524HB6cjs.HEADING_RATIO_H1) level = 1;
|
|
3775
|
+
else if (ratio >= _chunkZY524HB6cjs.HEADING_RATIO_H2) level = 2;
|
|
3776
|
+
else if (ratio >= _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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), _chunkZY524HB6cjs.MAX_ROWS);
|
|
4227
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.MAX_COLS);
|
|
4294
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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(_chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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
|
+
_chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16905
16905
|
}
|
|
16906
16906
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16907
16907
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16973,7 +16973,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16973
16973
|
} catch (e26) {
|
|
16974
16974
|
}
|
|
16975
16975
|
}
|
|
16976
|
-
const markdown =
|
|
16976
|
+
const markdown = _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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 = _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.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, _chunkZY524HB6cjs.KordocError)(
|
|
17530
17530
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17531
17531
|
);
|
|
17532
17532
|
}
|
|
@@ -17586,7 +17586,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17586
17586
|
pageCount: totalSheets
|
|
17587
17587
|
};
|
|
17588
17588
|
return {
|
|
17589
|
-
markdown:
|
|
17589
|
+
markdown: _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17590
17590
|
blocks: allBlocks,
|
|
17591
17591
|
metadata,
|
|
17592
17592
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18012,7 +18012,7 @@ function getAttr(el, localName2) {
|
|
|
18012
18012
|
return null;
|
|
18013
18013
|
}
|
|
18014
18014
|
function parseXml2(text) {
|
|
18015
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18015
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkZY524HB6cjs.stripDtd.call(void 0, text), "text/xml");
|
|
18016
18016
|
}
|
|
18017
18017
|
function parseStyles(xml) {
|
|
18018
18018
|
const doc = parseXml2(xml);
|
|
@@ -18331,12 +18331,12 @@ async function extractImages(zip, rels, doc) {
|
|
|
18331
18331
|
return { blocks, images };
|
|
18332
18332
|
}
|
|
18333
18333
|
async function parseDocxDocument(buffer, options) {
|
|
18334
|
-
|
|
18334
|
+
_chunkZY524HB6cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18335
18335
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18336
18336
|
const warnings = [];
|
|
18337
18337
|
const docFile = zip.file("word/document.xml");
|
|
18338
18338
|
if (!docFile) {
|
|
18339
|
-
throw new (0,
|
|
18339
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18340
18340
|
}
|
|
18341
18341
|
let rels = /* @__PURE__ */ new Map();
|
|
18342
18342
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18371,7 +18371,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18371
18371
|
const doc = parseXml2(docXml);
|
|
18372
18372
|
const body = findElements(doc, "body");
|
|
18373
18373
|
if (body.length === 0) {
|
|
18374
|
-
throw new (0,
|
|
18374
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18375
18375
|
}
|
|
18376
18376
|
const blocks = [];
|
|
18377
18377
|
const bodyEl = body[0];
|
|
@@ -18411,7 +18411,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18411
18411
|
}
|
|
18412
18412
|
}
|
|
18413
18413
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18414
|
-
const markdown =
|
|
18414
|
+
const markdown = _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18415
18415
|
return {
|
|
18416
18416
|
markdown,
|
|
18417
18417
|
blocks,
|
|
@@ -18434,7 +18434,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18434
18434
|
}
|
|
18435
18435
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18436
18436
|
const normalized = text.replace(/ /g, " ");
|
|
18437
|
-
const xml =
|
|
18437
|
+
const xml = _chunkZY524HB6cjs.stripDtd.call(void 0, normalized);
|
|
18438
18438
|
const warnings = [];
|
|
18439
18439
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18440
18440
|
onError: (_level, msg2) => {
|
|
@@ -18474,7 +18474,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18474
18474
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18475
18475
|
}
|
|
18476
18476
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18477
|
-
const markdown =
|
|
18477
|
+
const markdown = _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18478
18478
|
return {
|
|
18479
18479
|
markdown,
|
|
18480
18480
|
blocks,
|
|
@@ -18616,7 +18616,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18616
18616
|
const cellRows = grid.map(
|
|
18617
18617
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18618
18618
|
);
|
|
18619
|
-
const table =
|
|
18619
|
+
const table = _chunkZY524HB6cjs.buildTable.call(void 0, cellRows);
|
|
18620
18620
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18621
18621
|
}
|
|
18622
18622
|
function extractCellText(cellEl) {
|
|
@@ -19585,6 +19585,15 @@ function buildRangeSplices(para, xml, start, end, replacement) {
|
|
|
19585
19585
|
}
|
|
19586
19586
|
return placed ? splices : null;
|
|
19587
19587
|
}
|
|
19588
|
+
function allLinesegRemovalSplices(xml) {
|
|
19589
|
+
const segRe = /<(\w+:)?linesegarray\b[^>]*?(?:\/>|>[\s\S]*?<\/\1linesegarray>)/g;
|
|
19590
|
+
const splices = [];
|
|
19591
|
+
let m;
|
|
19592
|
+
while ((m = segRe.exec(xml)) !== null) {
|
|
19593
|
+
splices.push({ start: m.index, end: m.index + m[0].length, replacement: "" });
|
|
19594
|
+
}
|
|
19595
|
+
return splices;
|
|
19596
|
+
}
|
|
19588
19597
|
function applySplices(xml, splices) {
|
|
19589
19598
|
const sorted = [...splices].sort((a, b) => a.start - b.start);
|
|
19590
19599
|
for (let i = 1; i < sorted.length; i++) {
|
|
@@ -19630,19 +19639,19 @@ function parseCentralDirectory(buf) {
|
|
|
19630
19639
|
}
|
|
19631
19640
|
}
|
|
19632
19641
|
}
|
|
19633
|
-
if (eocdOffset < 0) throw new (0,
|
|
19642
|
+
if (eocdOffset < 0) throw new (0, _chunkZY524HB6cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19634
19643
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19635
19644
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19636
19645
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19637
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19646
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkZY524HB6cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19638
19647
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19639
|
-
throw new (0,
|
|
19648
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19640
19649
|
}
|
|
19641
19650
|
const decoder = new TextDecoder("utf-8");
|
|
19642
19651
|
const entries = [];
|
|
19643
19652
|
let pos = cdOffset;
|
|
19644
19653
|
for (let i = 0; i < totalEntries; i++) {
|
|
19645
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19654
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkZY524HB6cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19646
19655
|
const flags = view.getUint16(pos + 8, true);
|
|
19647
19656
|
const method = view.getUint16(pos + 10, true);
|
|
19648
19657
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19653,7 +19662,7 @@ function parseCentralDirectory(buf) {
|
|
|
19653
19662
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19654
19663
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19655
19664
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19656
|
-
throw new (0,
|
|
19665
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19657
19666
|
}
|
|
19658
19667
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19659
19668
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19682,7 +19691,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19682
19691
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19683
19692
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19684
19693
|
for (const name of replacements.keys()) {
|
|
19685
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19694
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkZY524HB6cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19686
19695
|
}
|
|
19687
19696
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19688
19697
|
const segments = [];
|
|
@@ -19700,7 +19709,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19700
19709
|
offset += seg.length;
|
|
19701
19710
|
continue;
|
|
19702
19711
|
}
|
|
19703
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
19712
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkZY524HB6cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19704
19713
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19705
19714
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19706
19715
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -19755,7 +19764,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19755
19764
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
19756
19765
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
19757
19766
|
if (sectionPaths.length === 0) {
|
|
19758
|
-
throw new (0,
|
|
19767
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19759
19768
|
}
|
|
19760
19769
|
const normalizedValues = normalizeValues(values);
|
|
19761
19770
|
const matchedLabels = /* @__PURE__ */ new Set();
|
|
@@ -19981,9 +19990,115 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19981
19990
|
|
|
19982
19991
|
// src/hwpx/generator.ts
|
|
19983
19992
|
|
|
19993
|
+
|
|
19994
|
+
// src/hwpx/gongmun.ts
|
|
19995
|
+
var OFFICIAL_MARGINS = { top: 20, bottom: 10, left: 20, right: 20 };
|
|
19996
|
+
var PRESET_DEFAULTS = {
|
|
19997
|
+
official: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
19998
|
+
report: { bodyPt: 15, lineSpacing: 160, numbering: "report" },
|
|
19999
|
+
plan: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
20000
|
+
notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
20001
|
+
minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" }
|
|
20002
|
+
};
|
|
20003
|
+
function resolveGongmun(opts) {
|
|
20004
|
+
const preset = _nullishCoalesce(opts.preset, () => ( "official"));
|
|
20005
|
+
const d = PRESET_DEFAULTS[preset];
|
|
20006
|
+
const bodyPt = _nullishCoalesce(opts.bodyPt, () => ( d.bodyPt));
|
|
20007
|
+
return {
|
|
20008
|
+
preset,
|
|
20009
|
+
bodyFont: _nullishCoalesce(opts.bodyFont, () => ( "myeongjo")),
|
|
20010
|
+
bodyHeight: Math.round(bodyPt * 100),
|
|
20011
|
+
lineSpacing: _nullishCoalesce(opts.lineSpacing, () => ( d.lineSpacing)),
|
|
20012
|
+
numbering: _nullishCoalesce(opts.numbering, () => ( d.numbering)),
|
|
20013
|
+
margins: _nullishCoalesce(opts.margins, () => ( OFFICIAL_MARGINS)),
|
|
20014
|
+
centerTitle: _nullishCoalesce(opts.centerTitle, () => ( true))
|
|
20015
|
+
};
|
|
20016
|
+
}
|
|
20017
|
+
var HANGUL_INITIALS = [0, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18];
|
|
20018
|
+
var HANGUL_MEDIALS = [0, 4, 8, 13, 18, 20];
|
|
20019
|
+
function hangulOrdinal(n) {
|
|
20020
|
+
const cols = HANGUL_INITIALS.length;
|
|
20021
|
+
const vowel = HANGUL_MEDIALS[Math.min(Math.floor(n / cols), HANGUL_MEDIALS.length - 1)];
|
|
20022
|
+
const init = HANGUL_INITIALS[n % cols];
|
|
20023
|
+
return String.fromCodePoint(44032 + init * 588 + vowel * 28);
|
|
20024
|
+
}
|
|
20025
|
+
function circledNumber(n) {
|
|
20026
|
+
return String.fromCodePoint(9312 + n % 20);
|
|
20027
|
+
}
|
|
20028
|
+
function circledHangul(n) {
|
|
20029
|
+
return String.fromCodePoint(12910 + n % 14);
|
|
20030
|
+
}
|
|
20031
|
+
var REPORT_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
20032
|
+
function standardMarker(depth, n) {
|
|
20033
|
+
switch (depth) {
|
|
20034
|
+
case 0:
|
|
20035
|
+
return `${n + 1}.`;
|
|
20036
|
+
case 1:
|
|
20037
|
+
return `${hangulOrdinal(n)}.`;
|
|
20038
|
+
case 2:
|
|
20039
|
+
return `${n + 1})`;
|
|
20040
|
+
case 3:
|
|
20041
|
+
return `${hangulOrdinal(n)})`;
|
|
20042
|
+
case 4:
|
|
20043
|
+
return `(${n + 1})`;
|
|
20044
|
+
case 5:
|
|
20045
|
+
return `(${hangulOrdinal(n)})`;
|
|
20046
|
+
case 6:
|
|
20047
|
+
return circledNumber(n);
|
|
20048
|
+
case 7:
|
|
20049
|
+
return circledHangul(n);
|
|
20050
|
+
default:
|
|
20051
|
+
return circledHangul(n);
|
|
20052
|
+
}
|
|
20053
|
+
}
|
|
20054
|
+
function reportMarker(depth) {
|
|
20055
|
+
return REPORT_BULLETS[Math.min(depth, REPORT_BULLETS.length - 1)];
|
|
20056
|
+
}
|
|
20057
|
+
function levelIndent(depth, bodyHeight, numbering) {
|
|
20058
|
+
const ta = bodyHeight / 2;
|
|
20059
|
+
const markerTa = numbering === "standard" && (depth === 4 || depth === 5) ? 3 : 2;
|
|
20060
|
+
const hang = Math.round((markerTa + 1) * ta);
|
|
20061
|
+
return { left: Math.round(depth * bodyHeight), indent: -hang };
|
|
20062
|
+
}
|
|
20063
|
+
function computeSuppression(depths) {
|
|
20064
|
+
const counts = /* @__PURE__ */ new Map();
|
|
20065
|
+
const keys = [];
|
|
20066
|
+
const path = [];
|
|
20067
|
+
for (const depth of depths) {
|
|
20068
|
+
path.length = depth + 1;
|
|
20069
|
+
path[depth] = (_nullishCoalesce(path[depth], () => ( 0))) + 1;
|
|
20070
|
+
const parentKey = path.slice(0, depth).join(".") + "|" + depth;
|
|
20071
|
+
keys.push(parentKey);
|
|
20072
|
+
counts.set(parentKey, (_nullishCoalesce(counts.get(parentKey), () => ( 0))) + 1);
|
|
20073
|
+
}
|
|
20074
|
+
return keys.map((k) => (_nullishCoalesce(counts.get(k), () => ( 0))) <= 1);
|
|
20075
|
+
}
|
|
20076
|
+
var GongmunNumberer = (_class2 = class {
|
|
20077
|
+
constructor(numbering) {;_class2.prototype.__init4.call(this);
|
|
20078
|
+
this.numbering = numbering;
|
|
20079
|
+
}
|
|
20080
|
+
__init4() {this.counts = []}
|
|
20081
|
+
/** depth 항목 하나에 대한 마커. suppress=true면 빈 문자열(부호 없음) */
|
|
20082
|
+
next(depth, suppress) {
|
|
20083
|
+
this.counts.length = depth + 1;
|
|
20084
|
+
const n = _nullishCoalesce(this.counts[depth], () => ( 0));
|
|
20085
|
+
this.counts[depth] = n + 1;
|
|
20086
|
+
if (suppress) return "";
|
|
20087
|
+
return this.numbering === "report" ? reportMarker(depth) : standardMarker(depth, n);
|
|
20088
|
+
}
|
|
20089
|
+
reset() {
|
|
20090
|
+
this.counts = [];
|
|
20091
|
+
}
|
|
20092
|
+
}, _class2);
|
|
20093
|
+
function mmToHwpunit(mm) {
|
|
20094
|
+
return Math.round(mm * 7200 / 25.4);
|
|
20095
|
+
}
|
|
20096
|
+
|
|
20097
|
+
// src/hwpx/generator.ts
|
|
19984
20098
|
var NS_SECTION = "http://www.hancom.co.kr/hwpml/2011/section";
|
|
19985
20099
|
var NS_PARA = "http://www.hancom.co.kr/hwpml/2011/paragraph";
|
|
19986
20100
|
var NS_HEAD = "http://www.hancom.co.kr/hwpml/2011/head";
|
|
20101
|
+
var NS_CORE = "http://www.hancom.co.kr/hwpml/2011/core";
|
|
19987
20102
|
var NS_OPF = "http://www.idpf.org/2007/opf/";
|
|
19988
20103
|
var NS_HPF = "http://www.hancom.co.kr/schema/2011/hpf";
|
|
19989
20104
|
var NS_OCF = "urn:oasis:names:tc:opendocument:xmlns:container";
|
|
@@ -20023,13 +20138,14 @@ function resolveTheme(theme) {
|
|
|
20023
20138
|
}
|
|
20024
20139
|
async function markdownToHwpx(markdown, options) {
|
|
20025
20140
|
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _148 => _148.theme]));
|
|
20141
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _149 => _149.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
20026
20142
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
20027
|
-
const sectionXml = blocksToSectionXml(blocks, theme);
|
|
20143
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun);
|
|
20028
20144
|
const zip = new (0, _jszip2.default)();
|
|
20029
20145
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
20030
20146
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
20031
20147
|
zip.file("Contents/content.hpf", generateManifest());
|
|
20032
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme));
|
|
20148
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun));
|
|
20033
20149
|
zip.file("Contents/section0.xml", sectionXml);
|
|
20034
20150
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
20035
20151
|
return await zip.generateAsync({ type: "arraybuffer" });
|
|
@@ -20222,25 +20338,95 @@ function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_C
|
|
|
20222
20338
|
</hh:charPr>`;
|
|
20223
20339
|
}
|
|
20224
20340
|
function paraPr(id, opts = {}) {
|
|
20225
|
-
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0 } = opts;
|
|
20341
|
+
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0 } = opts;
|
|
20226
20342
|
return ` <hh:paraPr id="${id}" tabPrIDRef="0" condense="0" fontLineHeight="0" snapToGrid="1" suppressLineNumbers="0" checked="0" textDir="AUTO">
|
|
20227
20343
|
<hh:align horizontal="${align}" vertical="BASELINE"/>
|
|
20228
20344
|
<hh:heading type="NONE" idRef="0" level="0"/>
|
|
20229
20345
|
<hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="BREAK_WORD" widowOrphan="0" keepWithNext="0" keepLines="0" pageBreakBefore="0" lineWrap="BREAK"/>
|
|
20230
20346
|
<hh:autoSpacing eAsianEng="0" eAsianNum="0"/>
|
|
20231
|
-
<hh:margin
|
|
20347
|
+
<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>
|
|
20232
20348
|
<hh:lineSpacing type="PERCENT" value="${lineSpacing}"/>
|
|
20233
20349
|
<hh:border borderFillIDRef="0" offsetLeft="0" offsetRight="0" offsetTop="0" offsetBottom="0" connect="0" ignoreMargin="0"/>
|
|
20234
20350
|
</hh:paraPr>`;
|
|
20235
20351
|
}
|
|
20236
|
-
|
|
20352
|
+
var GONGMUN_LIST_BASE = 8;
|
|
20353
|
+
var GONGMUN_LIST_LEVELS = 8;
|
|
20354
|
+
var GONGMUN_CENTER = GONGMUN_LIST_BASE + GONGMUN_LIST_LEVELS;
|
|
20355
|
+
function buildCharProperties(theme, gongmun) {
|
|
20356
|
+
let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
|
|
20357
|
+
if (gongmun) {
|
|
20358
|
+
body = gongmun.bodyHeight;
|
|
20359
|
+
code = Math.max(body - 200, 900);
|
|
20360
|
+
h1 = gongmun.preset === "report" || gongmun.preset === "plan" ? 2e3 : 1700;
|
|
20361
|
+
h2 = 1600;
|
|
20362
|
+
h3 = body;
|
|
20363
|
+
h4 = Math.max(body - 100, 1300);
|
|
20364
|
+
}
|
|
20365
|
+
const rows = [
|
|
20366
|
+
charPr(0, body, false, false, 0, theme.body),
|
|
20367
|
+
charPr(1, body, true, false, 0, theme.body),
|
|
20368
|
+
charPr(2, body, false, true, 0, theme.body),
|
|
20369
|
+
charPr(3, body, true, true, 0, theme.body),
|
|
20370
|
+
charPr(4, code, false, false, 1),
|
|
20371
|
+
charPr(5, h1, true, false, 1, theme.h1),
|
|
20372
|
+
charPr(6, h2, true, false, 1, theme.h2),
|
|
20373
|
+
charPr(7, h3, true, false, 1, theme.h3),
|
|
20374
|
+
charPr(8, h4, true, false, 1, theme.h4),
|
|
20375
|
+
charPr(CHAR_TABLE_HEADER, body, theme.tableHeaderBold, false, 0, theme.tableHeader),
|
|
20376
|
+
charPr(CHAR_QUOTE, body, false, true, 0, theme.quote)
|
|
20377
|
+
];
|
|
20378
|
+
return `<hh:charProperties itemCnt="${rows.length}">
|
|
20379
|
+
${rows.join("\n")}
|
|
20380
|
+
</hh:charProperties>`;
|
|
20381
|
+
}
|
|
20382
|
+
function buildParaProperties(gongmun) {
|
|
20383
|
+
if (!gongmun) {
|
|
20384
|
+
const base2 = [
|
|
20385
|
+
paraPr(0),
|
|
20386
|
+
paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 }),
|
|
20387
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 }),
|
|
20388
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 }),
|
|
20389
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 }),
|
|
20390
|
+
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20391
|
+
paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 }),
|
|
20392
|
+
paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })
|
|
20393
|
+
];
|
|
20394
|
+
return `<hh:paraProperties itemCnt="${base2.length}">
|
|
20395
|
+
${base2.join("\n")}
|
|
20396
|
+
</hh:paraProperties>`;
|
|
20397
|
+
}
|
|
20398
|
+
const ls = gongmun.lineSpacing;
|
|
20399
|
+
const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
|
|
20400
|
+
const base = [
|
|
20401
|
+
paraPr(0, { lineSpacing: ls }),
|
|
20402
|
+
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls }),
|
|
20403
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls }),
|
|
20404
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls }),
|
|
20405
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls }),
|
|
20406
|
+
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20407
|
+
paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600 }),
|
|
20408
|
+
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600 })
|
|
20409
|
+
];
|
|
20410
|
+
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
20411
|
+
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering);
|
|
20412
|
+
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent }));
|
|
20413
|
+
}
|
|
20414
|
+
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls }));
|
|
20415
|
+
return `<hh:paraProperties itemCnt="${base.length}">
|
|
20416
|
+
${base.join("\n")}
|
|
20417
|
+
</hh:paraProperties>`;
|
|
20418
|
+
}
|
|
20419
|
+
function generateHeaderXml(theme, gongmun) {
|
|
20420
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _150 => _150.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
20421
|
+
const charPropsXml = buildCharProperties(theme, gongmun);
|
|
20422
|
+
const paraPropsXml = buildParaProperties(gongmun);
|
|
20237
20423
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
20238
|
-
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" version="1.4" secCnt="1">
|
|
20424
|
+
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" xmlns:hc="${NS_CORE}" version="1.4" secCnt="1">
|
|
20239
20425
|
<hh:beginNum page="1" footnote="1" endnote="1" pic="1" tbl="1" equation="1"/>
|
|
20240
20426
|
<hh:refList>
|
|
20241
20427
|
<hh:fontfaces itemCnt="7">
|
|
20242
20428
|
<hh:fontface lang="HANGUL" fontCnt="3">
|
|
20243
|
-
<hh:font id="0" face="
|
|
20429
|
+
<hh:font id="0" face="${bodyFace}" type="TTF" isEmbedded="0">
|
|
20244
20430
|
<hh:typeInfo familyType="FCAT_GOTHIC" weight="6" proportion="4" contrast="0" strokeVariation="1" armStyle="1" letterform="1" midline="1" xHeight="1"/>
|
|
20245
20431
|
</hh:font>
|
|
20246
20432
|
<hh:font id="1" face="\uD568\uCD08\uB86C\uB3CB\uC6C0" type="TTF" isEmbedded="0">
|
|
@@ -20309,32 +20495,11 @@ function generateHeaderXml(theme) {
|
|
|
20309
20495
|
<hh:fillInfo/>
|
|
20310
20496
|
</hh:borderFill>
|
|
20311
20497
|
</hh:borderFills>
|
|
20312
|
-
|
|
20313
|
-
${charPr(0, 1e3, false, false, 0, theme.body)}
|
|
20314
|
-
${charPr(1, 1e3, true, false, 0, theme.body)}
|
|
20315
|
-
${charPr(2, 1e3, false, true, 0, theme.body)}
|
|
20316
|
-
${charPr(3, 1e3, true, true, 0, theme.body)}
|
|
20317
|
-
${charPr(4, 900, false, false, 1)}
|
|
20318
|
-
${charPr(5, 1800, true, false, 1, theme.h1)}
|
|
20319
|
-
${charPr(6, 1400, true, false, 1, theme.h2)}
|
|
20320
|
-
${charPr(7, 1200, true, false, 1, theme.h3)}
|
|
20321
|
-
${charPr(8, 1100, true, false, 1, theme.h4)}
|
|
20322
|
-
${charPr(CHAR_TABLE_HEADER, 1e3, theme.tableHeaderBold, false, 0, theme.tableHeader)}
|
|
20323
|
-
${charPr(CHAR_QUOTE, 1e3, false, true, 0, theme.quote)}
|
|
20324
|
-
</hh:charProperties>
|
|
20498
|
+
${charPropsXml}
|
|
20325
20499
|
<hh:tabProperties itemCnt="0"/>
|
|
20326
20500
|
<hh:numberings itemCnt="0"/>
|
|
20327
20501
|
<hh:bullets itemCnt="0"/>
|
|
20328
|
-
|
|
20329
|
-
${paraPr(0)}
|
|
20330
|
-
${paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 })}
|
|
20331
|
-
${paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 })}
|
|
20332
|
-
${paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 })}
|
|
20333
|
-
${paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 })}
|
|
20334
|
-
${paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 })}
|
|
20335
|
-
${paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 })}
|
|
20336
|
-
${paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })}
|
|
20337
|
-
</hh:paraProperties>
|
|
20502
|
+
${paraPropsXml}
|
|
20338
20503
|
<hh:styles itemCnt="1">
|
|
20339
20504
|
<hh:style id="0" type="PARA" name="\uBC14\uD0D5\uAE00" engName="Normal" paraPrIDRef="0" charPrIDRef="0" nextStyleIDRef="0" langIDRef="1042" lockForm="0"/>
|
|
20340
20505
|
</hh:styles>
|
|
@@ -20342,8 +20507,16 @@ ${paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })}
|
|
|
20342
20507
|
<hh:compatibleDocument targetProgram="HWP2018"/>
|
|
20343
20508
|
</hh:head>`;
|
|
20344
20509
|
}
|
|
20345
|
-
function generateSecPr() {
|
|
20346
|
-
|
|
20510
|
+
function generateSecPr(gongmun) {
|
|
20511
|
+
const m = gongmun ? {
|
|
20512
|
+
top: mmToHwpunit(gongmun.margins.top),
|
|
20513
|
+
bottom: mmToHwpunit(gongmun.margins.bottom),
|
|
20514
|
+
left: mmToHwpunit(gongmun.margins.left),
|
|
20515
|
+
right: mmToHwpunit(gongmun.margins.right),
|
|
20516
|
+
header: 0,
|
|
20517
|
+
footer: 0
|
|
20518
|
+
} : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
|
|
20519
|
+
return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="0" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
|
|
20347
20520
|
}
|
|
20348
20521
|
var TABLE_ID_BASE = 1e3;
|
|
20349
20522
|
var tableIdCounter = TABLE_ID_BASE;
|
|
@@ -20374,12 +20547,37 @@ function generateTable(rows, theme) {
|
|
|
20374
20547
|
const tbl = `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="1" noShading="0">${tblInner}</hp:tbl>`;
|
|
20375
20548
|
return `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${tbl}</hp:run></hp:p>`;
|
|
20376
20549
|
}
|
|
20377
|
-
function
|
|
20550
|
+
function precomputeGongmunList(blocks, gongmun) {
|
|
20551
|
+
const result = /* @__PURE__ */ new Map();
|
|
20552
|
+
let i = 0;
|
|
20553
|
+
while (i < blocks.length) {
|
|
20554
|
+
if (blocks[i].type !== "list_item") {
|
|
20555
|
+
i++;
|
|
20556
|
+
continue;
|
|
20557
|
+
}
|
|
20558
|
+
const run = [];
|
|
20559
|
+
while (i < blocks.length && blocks[i].type === "list_item") {
|
|
20560
|
+
run.push(i);
|
|
20561
|
+
i++;
|
|
20562
|
+
}
|
|
20563
|
+
const depths = run.map((bi) => Math.min(Math.max(blocks[bi].indent || 0, 0), GONGMUN_LIST_LEVELS - 1));
|
|
20564
|
+
const suppress = gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
|
|
20565
|
+
const numberer = new GongmunNumberer(gongmun.numbering);
|
|
20566
|
+
run.forEach((bi, k) => {
|
|
20567
|
+
const marker = numberer.next(depths[k], suppress[k]);
|
|
20568
|
+
result.set(bi, { marker, depth: depths[k] });
|
|
20569
|
+
});
|
|
20570
|
+
}
|
|
20571
|
+
return result;
|
|
20572
|
+
}
|
|
20573
|
+
function blocksToSectionXml(blocks, theme, gongmun) {
|
|
20378
20574
|
const paraXmls = [];
|
|
20379
20575
|
let isFirst = true;
|
|
20380
20576
|
const orderedCounters = {};
|
|
20381
20577
|
let prevWasOrdered = false;
|
|
20382
|
-
|
|
20578
|
+
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
20579
|
+
for (let blockIdx = 0; blockIdx < blocks.length; blockIdx++) {
|
|
20580
|
+
const block = blocks[blockIdx];
|
|
20383
20581
|
let xml = "";
|
|
20384
20582
|
if (block.type !== "list_item" || !block.ordered) {
|
|
20385
20583
|
if (prevWasOrdered) {
|
|
@@ -20394,9 +20592,15 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20394
20592
|
xml = generateParagraph(block.text || "", pId, cId);
|
|
20395
20593
|
break;
|
|
20396
20594
|
}
|
|
20397
|
-
case "paragraph":
|
|
20398
|
-
|
|
20595
|
+
case "paragraph": {
|
|
20596
|
+
const ctr = gongmun && /^<center>([\s\S]*)<\/center>$/i.exec((block.text || "").trim());
|
|
20597
|
+
if (ctr) {
|
|
20598
|
+
xml = generateParagraph(ctr[1].trim(), GONGMUN_CENTER);
|
|
20599
|
+
} else {
|
|
20600
|
+
xml = generateParagraph(block.text || "");
|
|
20601
|
+
}
|
|
20399
20602
|
break;
|
|
20603
|
+
}
|
|
20400
20604
|
case "code_block": {
|
|
20401
20605
|
const codeLines = (block.text || "").split("\n");
|
|
20402
20606
|
xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
|
|
@@ -20410,6 +20614,15 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20410
20614
|
);
|
|
20411
20615
|
break;
|
|
20412
20616
|
case "list_item": {
|
|
20617
|
+
if (gongmun && gongmunList) {
|
|
20618
|
+
const info = gongmunList.get(blockIdx);
|
|
20619
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _151 => _151.depth]), () => ( 0));
|
|
20620
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _152 => _152.marker]), () => ( ""));
|
|
20621
|
+
const content = block.text || "";
|
|
20622
|
+
const text = marker2 ? `${marker2} ${content}` : content;
|
|
20623
|
+
xml = generateParagraph(text, GONGMUN_LIST_BASE + depth);
|
|
20624
|
+
break;
|
|
20625
|
+
}
|
|
20413
20626
|
const indent = block.indent || 0;
|
|
20414
20627
|
let marker;
|
|
20415
20628
|
if (block.ordered) {
|
|
@@ -20436,7 +20649,7 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20436
20649
|
case "table":
|
|
20437
20650
|
if (block.rows) {
|
|
20438
20651
|
if (isFirst) {
|
|
20439
|
-
const secRun = `<hp:run charPrIDRef="0">${generateSecPr()}<hp:t></hp:t></hp:run>`;
|
|
20652
|
+
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
|
|
20440
20653
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
20441
20654
|
isFirst = false;
|
|
20442
20655
|
}
|
|
@@ -20448,14 +20661,14 @@ function blocksToSectionXml(blocks, theme) {
|
|
|
20448
20661
|
if (isFirst && block.type !== "table") {
|
|
20449
20662
|
xml = xml.replace(
|
|
20450
20663
|
/<hp:run charPrIDRef="(\d+)">/,
|
|
20451
|
-
`<hp:run charPrIDRef="$1">${generateSecPr()}`
|
|
20664
|
+
`<hp:run charPrIDRef="$1">${generateSecPr(gongmun)}`
|
|
20452
20665
|
);
|
|
20453
20666
|
isFirst = false;
|
|
20454
20667
|
}
|
|
20455
20668
|
paraXmls.push(xml);
|
|
20456
20669
|
}
|
|
20457
20670
|
if (paraXmls.length === 0) {
|
|
20458
|
-
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr()}<hp:t></hp:t></hp:run></hp:p>`);
|
|
20671
|
+
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run></hp:p>`);
|
|
20459
20672
|
}
|
|
20460
20673
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
20461
20674
|
<hs:sec xmlns:hs="${NS_SECTION}" xmlns:hp="${NS_PARA}">
|
|
@@ -20701,7 +20914,7 @@ function escapeGfm(text) {
|
|
|
20701
20914
|
}
|
|
20702
20915
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
20703
20916
|
function sanitizeText(text) {
|
|
20704
|
-
let result =
|
|
20917
|
+
let result = _chunkZY524HB6cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
20705
20918
|
if (result.length <= 30 && result.includes(" ")) {
|
|
20706
20919
|
const tokens = result.split(" ");
|
|
20707
20920
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -20731,7 +20944,7 @@ function replicateGfmTable(table) {
|
|
|
20731
20944
|
for (let r = 0; r < numRows; r++) {
|
|
20732
20945
|
for (let c = 0; c < numCols; c++) {
|
|
20733
20946
|
if (skip.has(`${r},${c}`)) continue;
|
|
20734
|
-
const cell = _optionalChain([cells, 'access',
|
|
20947
|
+
const cell = _optionalChain([cells, 'access', _153 => _153[r], 'optionalAccess', _154 => _154[c]]);
|
|
20735
20948
|
if (!cell) continue;
|
|
20736
20949
|
display[r][c] = {
|
|
20737
20950
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -20785,7 +20998,7 @@ function unescapeGfmCell(text) {
|
|
|
20785
20998
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\~/g, "~");
|
|
20786
20999
|
}
|
|
20787
21000
|
function replicateCellInnerHtml(cell) {
|
|
20788
|
-
if (_optionalChain([cell, 'access',
|
|
21001
|
+
if (_optionalChain([cell, 'access', _155 => _155.blocks, 'optionalAccess', _156 => _156.length])) {
|
|
20789
21002
|
return cell.blocks.map((b) => {
|
|
20790
21003
|
if (b.type === "table" && b.table) {
|
|
20791
21004
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -20824,7 +21037,7 @@ function replicateHtmlTable(table) {
|
|
|
20824
21037
|
const rowCells = [];
|
|
20825
21038
|
for (let c = 0; c < numCols; c++) {
|
|
20826
21039
|
if (skip.has(`${r},${c}`)) continue;
|
|
20827
|
-
const cell = _optionalChain([cells, 'access',
|
|
21040
|
+
const cell = _optionalChain([cells, 'access', _157 => _157[r], 'optionalAccess', _158 => _158[c]]);
|
|
20828
21041
|
if (!cell) continue;
|
|
20829
21042
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
20830
21043
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -20870,8 +21083,8 @@ function parseHtmlTable(raw) {
|
|
|
20870
21083
|
}
|
|
20871
21084
|
} else {
|
|
20872
21085
|
if (!isClose) {
|
|
20873
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
20874
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
21086
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _159 => _159.match, 'call', _160 => _160(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _161 => _161[1]]) || "1", 10);
|
|
21087
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _162 => _162.match, 'call', _163 => _163(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _164 => _164[1]]) || "1", 10);
|
|
20875
21088
|
cellStart = m.index + m[0].length;
|
|
20876
21089
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
20877
21090
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -21033,9 +21246,9 @@ function patchHtmlTableRaw(table, scanTable, origRaw, editedRaw, ctx, skip, dept
|
|
|
21033
21246
|
return applied;
|
|
21034
21247
|
}
|
|
21035
21248
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
21036
|
-
const irCell = _optionalChain([table, 'access',
|
|
21249
|
+
const irCell = _optionalChain([table, 'access', _165 => _165.cells, 'access', _166 => _166[oc.gridR], 'optionalAccess', _167 => _167[oc.gridC]]);
|
|
21037
21250
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
21038
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
21251
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _168 => _168.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
21039
21252
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
21040
21253
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
21041
21254
|
}
|
|
@@ -21103,7 +21316,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21103
21316
|
};
|
|
21104
21317
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
21105
21318
|
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)");
|
|
21106
|
-
const irCell = _optionalChain([table, 'access',
|
|
21319
|
+
const irCell = _optionalChain([table, 'access', _169 => _169.cells, 'access', _170 => _170[gridR], 'optionalAccess', _171 => _171[gridC]]);
|
|
21107
21320
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
21108
21321
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
21109
21322
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -21126,7 +21339,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21126
21339
|
if (newLines.length === 0) return 0;
|
|
21127
21340
|
const target = cell.paragraphs[0];
|
|
21128
21341
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
21129
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
21342
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _172 => _172.scans, 'access', _173 => _173[target.sectionIndex], 'optionalAccess', _174 => _174.xml]));
|
|
21130
21343
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21131
21344
|
splices.push(...sp);
|
|
21132
21345
|
sectionIndex = target.sectionIndex;
|
|
@@ -21147,7 +21360,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21147
21360
|
}
|
|
21148
21361
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
21149
21362
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
21150
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
21363
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _175 => _175.scans, 'access', _176 => _176[nonEmpty[i].sectionIndex], 'optionalAccess', _177 => _177.xml]));
|
|
21151
21364
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21152
21365
|
splices.push(...sp);
|
|
21153
21366
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -21251,6 +21464,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21251
21464
|
try {
|
|
21252
21465
|
for (let i = 0; i < scans.length; i++) {
|
|
21253
21466
|
if (sectionSplices[i].length === 0) continue;
|
|
21467
|
+
sectionSplices[i].push(...allLinesegRemovalSplices(scans[i].xml));
|
|
21254
21468
|
const newXml = applySplices(scans[i].xml, sectionSplices[i]);
|
|
21255
21469
|
replacements.set(sectionPaths[i], encoder.encode(newXml));
|
|
21256
21470
|
}
|
|
@@ -21268,7 +21482,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21268
21482
|
}
|
|
21269
21483
|
}
|
|
21270
21484
|
let verification;
|
|
21271
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
21485
|
+
if (_optionalChain([options, 'optionalAccess', _178 => _178.verify]) !== false) {
|
|
21272
21486
|
try {
|
|
21273
21487
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
21274
21488
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -21286,17 +21500,17 @@ function buildOrigUnits(blocks) {
|
|
|
21286
21500
|
let chunk;
|
|
21287
21501
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
21288
21502
|
const next = blocks[i + 1];
|
|
21289
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
21290
|
-
chunk =
|
|
21503
|
+
if (_optionalChain([next, 'optionalAccess', _179 => _179.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
21504
|
+
chunk = _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
21291
21505
|
} else {
|
|
21292
|
-
chunk =
|
|
21506
|
+
chunk = _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, [block]);
|
|
21293
21507
|
}
|
|
21294
21508
|
if (chunk) {
|
|
21295
21509
|
const subUnits = splitMarkdownUnits(chunk);
|
|
21296
21510
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
21297
21511
|
for (let s = 0; s < subUnits.length; s++) {
|
|
21298
21512
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
21299
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
21513
|
+
if (block.type === "table" && _optionalChain([block, 'access', _180 => _180.table, 'optionalAccess', _181 => _181.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
21300
21514
|
u.role = "caption";
|
|
21301
21515
|
}
|
|
21302
21516
|
units.push(u);
|
|
@@ -21473,7 +21687,7 @@ function handleModifiedUnit(orig, edited, ctx) {
|
|
|
21473
21687
|
}
|
|
21474
21688
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
21475
21689
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
21476
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
21690
|
+
if (!_optionalChain([mapping, 'optionalAccess', _182 => _182.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)");
|
|
21477
21691
|
if (block.text && block.text.includes("\n")) {
|
|
21478
21692
|
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)");
|
|
21479
21693
|
}
|
|
@@ -21504,7 +21718,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
21504
21718
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
21505
21719
|
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");
|
|
21506
21720
|
}
|
|
21507
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
21721
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _183 => _183.scans, 'access', _184 => _184[mapping.para.sectionIndex], 'optionalAccess', _185 => _185.xml]));
|
|
21508
21722
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21509
21723
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
21510
21724
|
return 1;
|
|
@@ -21570,16 +21784,16 @@ function replaceOleStream(file, path, newData) {
|
|
|
21570
21784
|
surgeon.replace(path, newData);
|
|
21571
21785
|
return surgeon.finish();
|
|
21572
21786
|
}
|
|
21573
|
-
var Surgeon = (
|
|
21787
|
+
var Surgeon = (_class3 = class {
|
|
21574
21788
|
|
|
21575
|
-
|
|
21789
|
+
__init5() {this.fat = []}
|
|
21576
21790
|
/** FAT 배열을 구성하는 섹터 번호들 (DIFAT 순서) */
|
|
21577
|
-
|
|
21578
|
-
|
|
21579
|
-
|
|
21580
|
-
|
|
21581
|
-
|
|
21582
|
-
constructor(file) {;
|
|
21791
|
+
__init6() {this.fatSectors = []}
|
|
21792
|
+
__init7() {this.miniFat = []}
|
|
21793
|
+
__init8() {this.miniFatSectors = []}
|
|
21794
|
+
__init9() {this.dirSectors = []}
|
|
21795
|
+
__init10() {this.entries = []}
|
|
21796
|
+
constructor(file) {;_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);
|
|
21583
21797
|
if (file.length < SECTOR || file.readUInt32LE(0) !== 3759263696) {
|
|
21584
21798
|
throw new OleSurgeonError("OLE \uC2DC\uADF8\uB2C8\uCC98\uAC00 \uC544\uB2D9\uB2C8\uB2E4");
|
|
21585
21799
|
}
|
|
@@ -21672,7 +21886,7 @@ var Surgeon = (_class2 = class {
|
|
|
21672
21886
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
21673
21887
|
findEntry(path) {
|
|
21674
21888
|
const parts = path.replace(/^\//, "").split("/");
|
|
21675
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
21889
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _186 => _186.entries, 'access', _187 => _187[0], 'optionalAccess', _188 => _188.child]), () => ( -1));
|
|
21676
21890
|
let current;
|
|
21677
21891
|
for (const part of parts) {
|
|
21678
21892
|
const search = (idx) => {
|
|
@@ -21835,7 +22049,7 @@ var Surgeon = (_class2 = class {
|
|
|
21835
22049
|
this.flushFat();
|
|
21836
22050
|
return this.buf;
|
|
21837
22051
|
}
|
|
21838
|
-
},
|
|
22052
|
+
}, _class3);
|
|
21839
22053
|
|
|
21840
22054
|
// src/roundtrip/hwp5-patch.ts
|
|
21841
22055
|
var require3 = _module.createRequire.call(void 0, _chunkGS7T56RPcjs.importMetaUrl);
|
|
@@ -21878,7 +22092,7 @@ function readRecordsStrict(stream) {
|
|
|
21878
22092
|
function serializeRecords(recs, repl) {
|
|
21879
22093
|
const parts = [];
|
|
21880
22094
|
for (let i = 0; i < recs.length; i++) {
|
|
21881
|
-
const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
22095
|
+
const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _189 => _189.get, 'call', _190 => _190(i)]), () => ( recs[i].data));
|
|
21882
22096
|
const ext = data.length >= 4095;
|
|
21883
22097
|
const header = Buffer.alloc(ext ? 8 : 4);
|
|
21884
22098
|
header.writeUInt32LE((recs[i].tagId & 1023 | (recs[i].level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
|
|
@@ -22001,7 +22215,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22001
22215
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
22002
22216
|
}
|
|
22003
22217
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
22004
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
22218
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _191 => _191.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
22005
22219
|
let flags;
|
|
22006
22220
|
try {
|
|
22007
22221
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -22023,7 +22237,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22023
22237
|
const scans = [];
|
|
22024
22238
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
22025
22239
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
22026
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
22240
|
+
if (!_optionalChain([entry, 'optionalAccess', _192 => _192.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
22027
22241
|
let stream;
|
|
22028
22242
|
try {
|
|
22029
22243
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -22082,7 +22296,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22082
22296
|
}
|
|
22083
22297
|
}
|
|
22084
22298
|
let verification;
|
|
22085
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22299
|
+
if (_optionalChain([options, 'optionalAccess', _193 => _193.verify]) !== false) {
|
|
22086
22300
|
try {
|
|
22087
22301
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
22088
22302
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -22166,7 +22380,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
22166
22380
|
}
|
|
22167
22381
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
22168
22382
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22169
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22383
|
+
if (!_optionalChain([mapping, 'optionalAccess', _194 => _194.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)");
|
|
22170
22384
|
if (block.text && block.text.includes("\n")) {
|
|
22171
22385
|
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)");
|
|
22172
22386
|
}
|
|
@@ -22293,7 +22507,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
22293
22507
|
};
|
|
22294
22508
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
22295
22509
|
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)");
|
|
22296
|
-
const irCell = _optionalChain([table, 'access',
|
|
22510
|
+
const irCell = _optionalChain([table, 'access', _195 => _195.cells, 'access', _196 => _196[gridR], 'optionalAccess', _197 => _197[gridC]]);
|
|
22297
22511
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
22298
22512
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
22299
22513
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -22431,9 +22645,9 @@ function u8ToArrayBuffer2(u8) {
|
|
|
22431
22645
|
function irCellLines(text) {
|
|
22432
22646
|
return stripCellTokens(sanitizeText(text)).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
22433
22647
|
}
|
|
22434
|
-
var HwpxSession = (
|
|
22648
|
+
var HwpxSession = (_class4 = class _HwpxSession {
|
|
22435
22649
|
|
|
22436
|
-
constructor(state) {;
|
|
22650
|
+
constructor(state) {;_class4.prototype.__init11.call(this);
|
|
22437
22651
|
this.state = state;
|
|
22438
22652
|
}
|
|
22439
22653
|
/** HWPX 바이트로 세션을 연다 (입력은 복사되어 외부 변이와 격리) */
|
|
@@ -22459,7 +22673,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22459
22673
|
const block = st.blocks[blockIndex];
|
|
22460
22674
|
if (!block) return void 0;
|
|
22461
22675
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
22462
|
-
const para = _optionalChain([st, 'access',
|
|
22676
|
+
const para = _optionalChain([st, 'access', _198 => _198.paraMap, 'access', _199 => _199.get, 'call', _200 => _200(blockIndex), 'optionalAccess', _201 => _201.para]);
|
|
22463
22677
|
if (!para) return void 0;
|
|
22464
22678
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
22465
22679
|
}
|
|
@@ -22484,7 +22698,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22484
22698
|
if (block.text && block.text.includes("\n")) {
|
|
22485
22699
|
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)" };
|
|
22486
22700
|
}
|
|
22487
|
-
if (!_optionalChain([st, 'access',
|
|
22701
|
+
if (!_optionalChain([st, 'access', _202 => _202.paraMap, 'access', _203 => _203.get, 'call', _204 => _204(blockIndex), 'optionalAccess', _205 => _205.para])) {
|
|
22488
22702
|
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)" };
|
|
22489
22703
|
}
|
|
22490
22704
|
return { capability: "text" };
|
|
@@ -22533,7 +22747,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22533
22747
|
this.opQueue = run.then(() => void 0, () => void 0);
|
|
22534
22748
|
return run;
|
|
22535
22749
|
}
|
|
22536
|
-
|
|
22750
|
+
__init11() {this.opQueue = Promise.resolve()}
|
|
22537
22751
|
async patchBlocksInner(edits, options) {
|
|
22538
22752
|
const st = this.state;
|
|
22539
22753
|
const skipped = [];
|
|
@@ -22550,7 +22764,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22550
22764
|
continue;
|
|
22551
22765
|
}
|
|
22552
22766
|
if (block.type === "table" && block.table) {
|
|
22553
|
-
if (!_optionalChain([edit, 'access',
|
|
22767
|
+
if (!_optionalChain([edit, 'access', _206 => _206.cells, 'optionalAccess', _207 => _207.length])) {
|
|
22554
22768
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
22555
22769
|
continue;
|
|
22556
22770
|
}
|
|
@@ -22570,7 +22784,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22570
22784
|
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) });
|
|
22571
22785
|
continue;
|
|
22572
22786
|
}
|
|
22573
|
-
const irCell = _optionalChain([block, 'access',
|
|
22787
|
+
const irCell = _optionalChain([block, 'access', _208 => _208.table, 'access', _209 => _209.cells, 'access', _210 => _210[cellEdit.row], 'optionalAccess', _211 => _211[cellEdit.col]]);
|
|
22574
22788
|
if (!irCell) {
|
|
22575
22789
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
22576
22790
|
continue;
|
|
@@ -22625,7 +22839,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22625
22839
|
}
|
|
22626
22840
|
if (replacements.size === 0) {
|
|
22627
22841
|
let changes2;
|
|
22628
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22842
|
+
if (_optionalChain([options, 'optionalAccess', _212 => _212.verify]) !== false) {
|
|
22629
22843
|
const units = splitMarkdownUnits(st.markdown);
|
|
22630
22844
|
changes2 = diffUnitLists(units, units);
|
|
22631
22845
|
}
|
|
@@ -22646,7 +22860,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22646
22860
|
}
|
|
22647
22861
|
this.state = newState;
|
|
22648
22862
|
let changes;
|
|
22649
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22863
|
+
if (_optionalChain([options, 'optionalAccess', _213 => _213.verify]) !== false) {
|
|
22650
22864
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
22651
22865
|
}
|
|
22652
22866
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -22666,7 +22880,7 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22666
22880
|
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)");
|
|
22667
22881
|
}
|
|
22668
22882
|
const mapping = st.paraMap.get(blockIndex);
|
|
22669
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22883
|
+
if (!_optionalChain([mapping, 'optionalAccess', _214 => _214.para])) {
|
|
22670
22884
|
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)");
|
|
22671
22885
|
}
|
|
22672
22886
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -22686,14 +22900,14 @@ var HwpxSession = (_class3 = class _HwpxSession {
|
|
|
22686
22900
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
22687
22901
|
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");
|
|
22688
22902
|
}
|
|
22689
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
22903
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _215 => _215.scans, 'access', _216 => _216[mapping.para.sectionIndex], 'optionalAccess', _217 => _217.xml]));
|
|
22690
22904
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22691
22905
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
22692
22906
|
return 1;
|
|
22693
22907
|
}
|
|
22694
|
-
},
|
|
22908
|
+
}, _class4);
|
|
22695
22909
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
22696
|
-
const irCell = _optionalChain([table, 'access',
|
|
22910
|
+
const irCell = _optionalChain([table, 'access', _218 => _218.cells, 'access', _219 => _219[r], 'optionalAccess', _220 => _220[c]]);
|
|
22697
22911
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
22698
22912
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
22699
22913
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -22777,11 +22991,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
22777
22991
|
breaks: false
|
|
22778
22992
|
});
|
|
22779
22993
|
function renderHtml(markdown, options) {
|
|
22780
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
22781
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
22994
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _221 => _221.preset]), () => ( "default"));
|
|
22995
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _222 => _222.extraCss]), () => ( "")));
|
|
22782
22996
|
const body = md.render(markdown);
|
|
22783
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
22784
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
22997
|
+
const watermark = _optionalChain([options, 'optionalAccess', _223 => _223.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
22998
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _224 => _224.watermark]) ? `
|
|
22785
22999
|
.watermark {
|
|
22786
23000
|
position: fixed;
|
|
22787
23001
|
top: 50%; left: 50%;
|
|
@@ -22812,13 +23026,13 @@ async function htmlToPdf(html, options) {
|
|
|
22812
23026
|
try {
|
|
22813
23027
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
22814
23028
|
} catch (e34) {
|
|
22815
|
-
throw new (0,
|
|
23029
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)(
|
|
22816
23030
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
22817
23031
|
);
|
|
22818
23032
|
}
|
|
22819
23033
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
22820
23034
|
if (!executablePath) {
|
|
22821
|
-
throw new (0,
|
|
23035
|
+
throw new (0, _chunkZY524HB6cjs.KordocError)(
|
|
22822
23036
|
"Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
|
|
22823
23037
|
);
|
|
22824
23038
|
}
|
|
@@ -22830,10 +23044,10 @@ async function htmlToPdf(html, options) {
|
|
|
22830
23044
|
try {
|
|
22831
23045
|
const page = await browser.newPage();
|
|
22832
23046
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
22833
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
23047
|
+
const margin = _optionalChain([options, 'optionalAccess', _225 => _225.margin]);
|
|
22834
23048
|
const pdf = await page.pdf({
|
|
22835
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
22836
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
23049
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _226 => _226.pageSize]), () => ( "A4")),
|
|
23050
|
+
landscape: _optionalChain([options, 'optionalAccess', _227 => _227.orientation]) === "landscape",
|
|
22837
23051
|
printBackground: true,
|
|
22838
23052
|
margin: margin ? {
|
|
22839
23053
|
top: toCss(margin.top),
|
|
@@ -22841,9 +23055,9 @@ async function htmlToPdf(html, options) {
|
|
|
22841
23055
|
bottom: toCss(margin.bottom),
|
|
22842
23056
|
left: toCss(margin.left)
|
|
22843
23057
|
} : void 0,
|
|
22844
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
22845
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
22846
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23058
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _228 => _228.header]) || _optionalChain([options, 'optionalAccess', _229 => _229.footer])),
|
|
23059
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.header]), () => ( "<div></div>")),
|
|
23060
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
22847
23061
|
});
|
|
22848
23062
|
return Buffer.from(pdf);
|
|
22849
23063
|
} finally {
|
|
@@ -22877,24 +23091,24 @@ async function markdownToPdf(markdown, options) {
|
|
|
22877
23091
|
return htmlToPdf(html, options);
|
|
22878
23092
|
}
|
|
22879
23093
|
async function blocksToPdf(blocks, options) {
|
|
22880
|
-
const markdown =
|
|
23094
|
+
const markdown = _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, blocks);
|
|
22881
23095
|
return markdownToPdf(markdown, options);
|
|
22882
23096
|
}
|
|
22883
23097
|
|
|
22884
23098
|
// src/index.ts
|
|
22885
23099
|
async function parse(input, options) {
|
|
22886
23100
|
let buffer;
|
|
22887
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
23101
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _232 => _232.filePath]) ? { ...options, filePath: input } : options;
|
|
22888
23102
|
if (typeof input === "string") {
|
|
22889
23103
|
try {
|
|
22890
23104
|
const buf = await _promises.readFile.call(void 0, input);
|
|
22891
|
-
buffer =
|
|
23105
|
+
buffer = _chunkZY524HB6cjs.toArrayBuffer.call(void 0, buf);
|
|
22892
23106
|
} catch (err) {
|
|
22893
23107
|
const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
|
|
22894
23108
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
22895
23109
|
}
|
|
22896
23110
|
} else if (Buffer.isBuffer(input)) {
|
|
22897
|
-
buffer =
|
|
23111
|
+
buffer = _chunkZY524HB6cjs.toArrayBuffer.call(void 0, input);
|
|
22898
23112
|
} else {
|
|
22899
23113
|
buffer = input;
|
|
22900
23114
|
}
|
|
@@ -22929,21 +23143,21 @@ async function parseHwp3(buffer, options) {
|
|
|
22929
23143
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
22930
23144
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
22931
23145
|
} catch (err) {
|
|
22932
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23146
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
22933
23147
|
}
|
|
22934
23148
|
}
|
|
22935
23149
|
async function parseHwpx(buffer, options) {
|
|
22936
23150
|
try {
|
|
22937
23151
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
22938
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23152
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _233 => _233.length]) ? images : void 0 };
|
|
22939
23153
|
} catch (err) {
|
|
22940
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23154
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
22941
23155
|
}
|
|
22942
23156
|
}
|
|
22943
23157
|
async function parseHwp(buffer, options) {
|
|
22944
23158
|
try {
|
|
22945
23159
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
22946
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
23160
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _234 => _234.filePath])) {
|
|
22947
23161
|
try {
|
|
22948
23162
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
22949
23163
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -22960,15 +23174,15 @@ async function parseHwp(buffer, options) {
|
|
|
22960
23174
|
} catch (e35) {
|
|
22961
23175
|
}
|
|
22962
23176
|
}
|
|
22963
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23177
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _235 => _235.length]) ? images : void 0 };
|
|
22964
23178
|
} catch (err) {
|
|
22965
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23179
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
22966
23180
|
}
|
|
22967
23181
|
}
|
|
22968
23182
|
async function parsePdf(buffer, options) {
|
|
22969
23183
|
let parsePdfDocument;
|
|
22970
23184
|
try {
|
|
22971
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
23185
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-CV3FOVOS.cjs")));
|
|
22972
23186
|
parsePdfDocument = mod.parsePdfDocument;
|
|
22973
23187
|
} catch (e36) {
|
|
22974
23188
|
return {
|
|
@@ -22983,7 +23197,7 @@ async function parsePdf(buffer, options) {
|
|
|
22983
23197
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
22984
23198
|
} catch (err) {
|
|
22985
23199
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
22986
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23200
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err), isImageBased };
|
|
22987
23201
|
}
|
|
22988
23202
|
}
|
|
22989
23203
|
async function parseXlsx(buffer, options) {
|
|
@@ -22991,7 +23205,7 @@ async function parseXlsx(buffer, options) {
|
|
|
22991
23205
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
22992
23206
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
22993
23207
|
} catch (err) {
|
|
22994
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23208
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
22995
23209
|
}
|
|
22996
23210
|
}
|
|
22997
23211
|
async function parseXls(buffer, options) {
|
|
@@ -22999,15 +23213,15 @@ async function parseXls(buffer, options) {
|
|
|
22999
23213
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
23000
23214
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
23001
23215
|
} catch (err) {
|
|
23002
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23216
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
23003
23217
|
}
|
|
23004
23218
|
}
|
|
23005
23219
|
async function parseDocx(buffer, options) {
|
|
23006
23220
|
try {
|
|
23007
23221
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
23008
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23222
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _236 => _236.length]) ? images : void 0 };
|
|
23009
23223
|
} catch (err) {
|
|
23010
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23224
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
23011
23225
|
}
|
|
23012
23226
|
}
|
|
23013
23227
|
async function parseHwpml(buffer, options) {
|
|
@@ -23015,16 +23229,16 @@ async function parseHwpml(buffer, options) {
|
|
|
23015
23229
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
23016
23230
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
23017
23231
|
} catch (err) {
|
|
23018
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23232
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZY524HB6cjs.classifyError.call(void 0, err) };
|
|
23019
23233
|
}
|
|
23020
23234
|
}
|
|
23021
23235
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
23022
23236
|
let buffer;
|
|
23023
23237
|
if (typeof input === "string") {
|
|
23024
23238
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23025
|
-
buffer =
|
|
23239
|
+
buffer = _chunkZY524HB6cjs.toArrayBuffer.call(void 0, buf);
|
|
23026
23240
|
} else if (Buffer.isBuffer(input)) {
|
|
23027
|
-
buffer =
|
|
23241
|
+
buffer = _chunkZY524HB6cjs.toArrayBuffer.call(void 0, input);
|
|
23028
23242
|
} else {
|
|
23029
23243
|
buffer = input;
|
|
23030
23244
|
}
|
|
@@ -23050,7 +23264,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23050
23264
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
23051
23265
|
}
|
|
23052
23266
|
const fill = fillFormFields(parsed.blocks, values);
|
|
23053
|
-
const markdown =
|
|
23267
|
+
const markdown = _chunkZY524HB6cjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
23054
23268
|
if (outputFormat === "hwpx") {
|
|
23055
23269
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
23056
23270
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -23098,5 +23312,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23098
23312
|
|
|
23099
23313
|
|
|
23100
23314
|
|
|
23101
|
-
exports.HwpxSession = HwpxSession; exports.VERSION =
|
|
23315
|
+
exports.HwpxSession = HwpxSession; exports.VERSION = _chunkZY524HB6cjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkZY524HB6cjs.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;
|
|
23102
23316
|
//# sourceMappingURL=index.cjs.map
|