kordoc 3.8.2 → 3.8.4
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 +14 -0
- package/dist/{-FEHSMPVO.js → -ZAIG6FWT.js} +3 -3
- package/dist/{chunk-JHZUFBUV.js → chunk-2UDAEQPW.js} +3 -3
- package/dist/chunk-2UDAEQPW.js.map +1 -0
- package/dist/{chunk-DP37KF2X.js → chunk-6EDNKPXQ.js} +146 -75
- package/dist/chunk-6EDNKPXQ.js.map +1 -0
- package/dist/{chunk-553VTUVP.js → chunk-T4SGNVVS.js} +3 -3
- package/dist/chunk-T4SGNVVS.js.map +1 -0
- package/dist/{chunk-YBPNKFJW.cjs → chunk-Z3O36LBJ.cjs} +3 -3
- package/dist/{chunk-YBPNKFJW.cjs.map → chunk-Z3O36LBJ.cjs.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +399 -328
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +145 -74
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-NR2TYGO3.js → parser-2THIF623.js} +153 -7
- package/dist/parser-2THIF623.js.map +1 -0
- package/dist/{parser-KNQDRLZQ.js → parser-PR7CPMM4.js} +153 -7
- package/dist/parser-PR7CPMM4.js.map +1 -0
- package/dist/{parser-NS4ZPD7B.cjs → parser-ZVKCFXR3.cjs} +177 -31
- package/dist/parser-ZVKCFXR3.cjs.map +1 -0
- package/dist/{watch-XCWADLPU.js → watch-2HYPNMOB.js} +3 -3
- package/package.json +2 -1
- package/dist/chunk-553VTUVP.js.map +0 -1
- package/dist/chunk-DP37KF2X.js.map +0 -1
- package/dist/chunk-JHZUFBUV.js.map +0 -1
- package/dist/parser-KNQDRLZQ.js.map +0 -1
- package/dist/parser-NR2TYGO3.js.map +0 -1
- package/dist/parser-NS4ZPD7B.cjs.map +0 -1
- /package/dist/{-FEHSMPVO.js.map → -ZAIG6FWT.js.map} +0 -0
- /package/dist/{watch-XCWADLPU.js.map → watch-2HYPNMOB.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkZ3O36LBJcjs = require('./chunk-Z3O36LBJ.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -405,7 +405,7 @@ function createSectionShared() {
|
|
|
405
405
|
function createXmlParser(warnings) {
|
|
406
406
|
return new (0, _xmldom.DOMParser)({
|
|
407
407
|
onError(level, msg2) {
|
|
408
|
-
if (level === "fatalError") throw new (0,
|
|
408
|
+
if (level === "fatalError") throw new (0, _chunkZ3O36LBJcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
409
409
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
410
410
|
}
|
|
411
411
|
});
|
|
@@ -460,10 +460,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
460
460
|
const xml = await file.async("text");
|
|
461
461
|
if (decompressed) {
|
|
462
462
|
decompressed.total += xml.length * 2;
|
|
463
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
463
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
464
464
|
}
|
|
465
465
|
const parser = createXmlParser();
|
|
466
|
-
const doc = parser.parseFromString(
|
|
466
|
+
const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
467
467
|
if (!doc.documentElement) continue;
|
|
468
468
|
parseCharProperties(doc, result.charProperties);
|
|
469
469
|
parseStyleElements(doc, result.styles);
|
|
@@ -615,9 +615,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
615
615
|
let level = 0;
|
|
616
616
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
|
|
617
617
|
const ratio = block.style.fontSize / baseFontSize;
|
|
618
|
-
if (ratio >=
|
|
619
|
-
else if (ratio >=
|
|
620
|
-
else if (ratio >=
|
|
618
|
+
if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H1) level = 1;
|
|
619
|
+
else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H2) level = 2;
|
|
620
|
+
else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H3) level = 3;
|
|
621
621
|
}
|
|
622
622
|
const compactText = text.replace(/\s+/g, "");
|
|
623
623
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1153,19 +1153,19 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1153
1153
|
const head = numDef.heads.get(level);
|
|
1154
1154
|
counters[level] = counters[level] === 0 ? _nullishCoalesce(_optionalChain([head, 'optionalAccess', _9 => _9.start]), () => ( 1)) : counters[level] + 1;
|
|
1155
1155
|
for (let l = level + 1; l <= 10; l++) counters[l] = 0;
|
|
1156
|
-
const fmtText =
|
|
1156
|
+
const fmtText = head ? head.text.trim() : `^${level}.`;
|
|
1157
1157
|
const prefix = fmtText.replace(/\^(10|[1-9])/g, (_, d) => {
|
|
1158
1158
|
const lv = parseInt(d, 10);
|
|
1159
1159
|
const refHead = numDef.heads.get(lv);
|
|
1160
|
-
const n = counters[lv] || _optionalChain([refHead, 'optionalAccess',
|
|
1161
|
-
return formatHeadNumber(n, _optionalChain([refHead, 'optionalAccess',
|
|
1160
|
+
const n = counters[lv] || _optionalChain([refHead, 'optionalAccess', _10 => _10.start]) || 1;
|
|
1161
|
+
return formatHeadNumber(n, _optionalChain([refHead, 'optionalAccess', _11 => _11.numFormat]) || "DIGIT");
|
|
1162
1162
|
});
|
|
1163
|
-
return { prefix, headingLevel };
|
|
1163
|
+
return { prefix: prefix || void 0, headingLevel };
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
1166
|
// src/hwpx/table-build.ts
|
|
1167
1167
|
function buildTableWithCellMeta(state) {
|
|
1168
|
-
const table =
|
|
1168
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, state.rows);
|
|
1169
1169
|
if (state.caption) table.caption = state.caption;
|
|
1170
1170
|
const anchors = [];
|
|
1171
1171
|
{
|
|
@@ -1173,7 +1173,7 @@ function buildTableWithCellMeta(state) {
|
|
|
1173
1173
|
for (let r = 0; r < table.rows; r++) {
|
|
1174
1174
|
for (let c = 0; c < table.cols; c++) {
|
|
1175
1175
|
if (covered.has(`${r},${c}`)) continue;
|
|
1176
|
-
const cell = _optionalChain([table, 'access',
|
|
1176
|
+
const cell = _optionalChain([table, 'access', _12 => _12.cells, 'access', _13 => _13[r], 'optionalAccess', _14 => _14[c]]);
|
|
1177
1177
|
if (!cell) continue;
|
|
1178
1178
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
1179
1179
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -1198,7 +1198,7 @@ function buildTableWithCellMeta(state) {
|
|
|
1198
1198
|
let target;
|
|
1199
1199
|
const trimmed = src.text.trim();
|
|
1200
1200
|
if (src.rowAddr !== void 0 && src.colAddr !== void 0) {
|
|
1201
|
-
const cand = _optionalChain([table, 'access',
|
|
1201
|
+
const cand = _optionalChain([table, 'access', _15 => _15.cells, 'access', _16 => _16[src.rowAddr], 'optionalAccess', _17 => _17[src.colAddr]]);
|
|
1202
1202
|
if (cand && cand.text === trimmed && !claimed.has(cand)) target = cand;
|
|
1203
1203
|
}
|
|
1204
1204
|
if (!target) {
|
|
@@ -1231,11 +1231,11 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1231
1231
|
}
|
|
1232
1232
|
const ir = buildTableWithCellMeta(newTable);
|
|
1233
1233
|
const block = { type: "table", table: ir, pageNumber: ctx.sectionNum };
|
|
1234
|
-
if (_optionalChain([parentTable, 'optionalAccess',
|
|
1234
|
+
if (_optionalChain([parentTable, 'optionalAccess', _18 => _18.cell])) {
|
|
1235
1235
|
const cell = parentTable.cell;
|
|
1236
1236
|
(cell.blocks ??= []).push(block);
|
|
1237
1237
|
cell.hasStructure = true;
|
|
1238
|
-
let flat =
|
|
1238
|
+
let flat = _chunkZ3O36LBJcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1239
1239
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1240
1240
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1241
1241
|
} else {
|
|
@@ -1247,7 +1247,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1247
1247
|
// src/hwpx/section-walker.ts
|
|
1248
1248
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1249
1249
|
const parser = createXmlParser(warnings);
|
|
1250
|
-
const doc = parser.parseFromString(
|
|
1250
|
+
const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1251
1251
|
if (!doc.documentElement) return [];
|
|
1252
1252
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1253
1253
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1325,7 +1325,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
break;
|
|
1327
1327
|
case "cellAddr":
|
|
1328
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1328
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _19 => _19.cell])) {
|
|
1329
1329
|
const ca = parseInt(el.getAttribute("colAddr") || "", 10);
|
|
1330
1330
|
const ra = parseInt(el.getAttribute("rowAddr") || "", 10);
|
|
1331
1331
|
if (!isNaN(ca)) tableCtx.cell.colAddr = ca;
|
|
@@ -1333,13 +1333,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
break;
|
|
1335
1335
|
case "cellSpan":
|
|
1336
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1336
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _20 => _20.cell])) {
|
|
1337
1337
|
const rawCs = parseInt(el.getAttribute("colSpan") || "1", 10);
|
|
1338
1338
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1339
1339
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1340
1340
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1341
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1342
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1341
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkZ3O36LBJcjs.MAX_COLS);
|
|
1342
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkZ3O36LBJcjs.MAX_ROWS);
|
|
1343
1343
|
}
|
|
1344
1344
|
break;
|
|
1345
1345
|
case "p": {
|
|
@@ -1348,11 +1348,11 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1348
1348
|
let headingLevel;
|
|
1349
1349
|
if (text) {
|
|
1350
1350
|
const ph = resolveParaHeading(el, ctx);
|
|
1351
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
1352
|
-
headingLevel = _optionalChain([ph, 'optionalAccess',
|
|
1351
|
+
if (_optionalChain([ph, 'optionalAccess', _21 => _21.prefix])) text = ph.prefix + " " + text;
|
|
1352
|
+
headingLevel = _optionalChain([ph, 'optionalAccess', _22 => _22.headingLevel]);
|
|
1353
1353
|
}
|
|
1354
1354
|
if (text) {
|
|
1355
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1355
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _23 => _23.cell])) {
|
|
1356
1356
|
const cell = tableCtx.cell;
|
|
1357
1357
|
if (footnote) text += ` (\uC8FC: ${footnote})`;
|
|
1358
1358
|
cell.text += (cell.text ? "\n" : "") + text;
|
|
@@ -1375,7 +1375,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1375
1375
|
case "pic":
|
|
1376
1376
|
case "shape":
|
|
1377
1377
|
case "drawingObject": {
|
|
1378
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1378
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _24 => _24.cell])) {
|
|
1379
1379
|
const sink = [];
|
|
1380
1380
|
handleShape(el, sink, ctx);
|
|
1381
1381
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -1484,7 +1484,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
1484
1484
|
walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
|
|
1485
1485
|
tableCtx = completeTable(newTable, tableStack, blocks, ctx);
|
|
1486
1486
|
} else if (localTag === "pic" || localTag === "shape" || localTag === "drawingObject") {
|
|
1487
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1487
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _25 => _25.cell])) {
|
|
1488
1488
|
const sink = [];
|
|
1489
1489
|
handleShape(el, sink, ctx);
|
|
1490
1490
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -1492,7 +1492,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
1492
1492
|
handleShape(el, blocks, ctx);
|
|
1493
1493
|
}
|
|
1494
1494
|
} else if (localTag === "drawText") {
|
|
1495
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1495
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _26 => _26.cell])) {
|
|
1496
1496
|
const sink = [];
|
|
1497
1497
|
extractDrawTextBlocks(el, sink, ctx);
|
|
1498
1498
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -1536,7 +1536,7 @@ function extractDrawTextBlocks(drawTextNode, blocks, ctx) {
|
|
|
1536
1536
|
let text = info.text.trim();
|
|
1537
1537
|
if (text) {
|
|
1538
1538
|
const ph = resolveParaHeading(child, ctx);
|
|
1539
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
1539
|
+
if (_optionalChain([ph, 'optionalAccess', _27 => _27.prefix])) text = ph.prefix + " " + text;
|
|
1540
1540
|
const block = { type: "paragraph", text, style: _nullishCoalesce(info.style, () => ( void 0)), pageNumber: ctx.sectionNum };
|
|
1541
1541
|
if (info.href) block.href = info.href;
|
|
1542
1542
|
if (info.footnote) block.footnoteText = info.footnote;
|
|
@@ -1561,13 +1561,13 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1561
1561
|
let url = (ch.textContent || "").trim();
|
|
1562
1562
|
if (!url) continue;
|
|
1563
1563
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1564
|
-
const safe =
|
|
1564
|
+
const safe = _chunkZ3O36LBJcjs.sanitizeHref.call(void 0, url);
|
|
1565
1565
|
if (safe) return safe;
|
|
1566
1566
|
}
|
|
1567
1567
|
return void 0;
|
|
1568
1568
|
}
|
|
1569
1569
|
function isInDeletedRange(ctx) {
|
|
1570
|
-
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess',
|
|
1570
|
+
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess', _28 => _28.shared, 'access', _29 => _29.track, 'access', _30 => _30.deleteDepth]), () => ( 0))) > 0;
|
|
1571
1571
|
}
|
|
1572
1572
|
function extractParagraphInfo(para, styleMap, ctx) {
|
|
1573
1573
|
let text = "";
|
|
@@ -1621,7 +1621,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1621
1621
|
// 삽입분은 최종본에 포함
|
|
1622
1622
|
// 숨은 설명 — 본문 혼입 차단
|
|
1623
1623
|
case "hiddenComment": {
|
|
1624
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
1624
|
+
if (_optionalChain([ctx, 'optionalAccess', _31 => _31.warnings]) && extractTextFromNode(k)) {
|
|
1625
1625
|
ctx.warnings.push({ page: ctx.sectionNum, message: "\uC228\uC740 \uC124\uBA85 \uD14D\uC2A4\uD2B8 \uC81C\uC678: hiddenComment", code: "HIDDEN_TEXT_FILTERED" });
|
|
1626
1626
|
}
|
|
1627
1627
|
break;
|
|
@@ -1638,7 +1638,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1638
1638
|
break;
|
|
1639
1639
|
// 미지원 요소 — 텍스트를 가졌으면 무음 손실 대신 경고
|
|
1640
1640
|
default: {
|
|
1641
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
1641
|
+
if (_optionalChain([ctx, 'optionalAccess', _32 => _32.warnings]) && extractTextFromNode(k)) {
|
|
1642
1642
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uBBF8\uC9C0\uC6D0 \uC81C\uC5B4 \uC694\uC18C\uC758 \uD14D\uC2A4\uD2B8 \uC190\uC2E4: ${ktag}`, code: "UNSUPPORTED_ELEMENT" });
|
|
1643
1643
|
}
|
|
1644
1644
|
}
|
|
@@ -1655,7 +1655,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1655
1655
|
if (isInDeletedRange(ctx)) {
|
|
1656
1656
|
if (t && ctx && !ctx.shared.track.warned) {
|
|
1657
1657
|
ctx.shared.track.warned = true;
|
|
1658
|
-
_optionalChain([ctx, 'access',
|
|
1658
|
+
_optionalChain([ctx, 'access', _33 => _33.warnings, 'optionalAccess', _34 => _34.push, 'call', _35 => _35({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" })]);
|
|
1659
1659
|
}
|
|
1660
1660
|
} else {
|
|
1661
1661
|
text += t;
|
|
@@ -1696,7 +1696,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1696
1696
|
case "hyperlink": {
|
|
1697
1697
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1698
1698
|
if (url) {
|
|
1699
|
-
const safe =
|
|
1699
|
+
const safe = _chunkZ3O36LBJcjs.sanitizeHref.call(void 0, url);
|
|
1700
1700
|
if (safe) href = safe;
|
|
1701
1701
|
}
|
|
1702
1702
|
walk(child);
|
|
@@ -1845,7 +1845,7 @@ function collectImageBlocks(blocks, out, ownerCell, depth = 0) {
|
|
|
1845
1845
|
} else if (block.type === "table" && block.table) {
|
|
1846
1846
|
for (const row of block.table.cells) {
|
|
1847
1847
|
for (const cell of row) {
|
|
1848
|
-
if (_optionalChain([cell, 'access',
|
|
1848
|
+
if (_optionalChain([cell, 'access', _36 => _36.blocks, 'optionalAccess', _37 => _37.length])) collectImageBlocks(cell.blocks, out, cell, depth + 1);
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
1851
|
}
|
|
@@ -1882,13 +1882,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1882
1882
|
}
|
|
1883
1883
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1884
1884
|
for (const path of allCandidates) {
|
|
1885
|
-
if (
|
|
1885
|
+
if (_chunkZ3O36LBJcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1886
1886
|
const file = zip.file(path);
|
|
1887
1887
|
if (!file) continue;
|
|
1888
1888
|
try {
|
|
1889
1889
|
const data = await file.async("uint8array");
|
|
1890
1890
|
decompressed.total += data.length;
|
|
1891
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1891
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1892
1892
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1893
1893
|
const mimeType = imageExtToMime(ext);
|
|
1894
1894
|
imageIndex++;
|
|
@@ -1897,10 +1897,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1897
1897
|
images.push(img);
|
|
1898
1898
|
break;
|
|
1899
1899
|
} catch (err) {
|
|
1900
|
-
if (err instanceof
|
|
1900
|
+
if (err instanceof _chunkZ3O36LBJcjs.KordocError) throw err;
|
|
1901
1901
|
}
|
|
1902
1902
|
}
|
|
1903
|
-
if (!img) _optionalChain([warnings, 'optionalAccess',
|
|
1903
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _38 => _38.push, 'call', _39 => _39({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
1904
1904
|
resolved.set(ref, img);
|
|
1905
1905
|
}
|
|
1906
1906
|
if (!img) {
|
|
@@ -1959,7 +1959,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1959
1959
|
}
|
|
1960
1960
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1961
1961
|
const name = new TextDecoder().decode(nameBytes);
|
|
1962
|
-
if (
|
|
1962
|
+
if (_chunkZ3O36LBJcjs.isPathTraversal.call(void 0, name)) {
|
|
1963
1963
|
pos = fileStart + compSize;
|
|
1964
1964
|
continue;
|
|
1965
1965
|
}
|
|
@@ -1977,16 +1977,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1977
1977
|
continue;
|
|
1978
1978
|
}
|
|
1979
1979
|
totalDecompressed += content.length * 2;
|
|
1980
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1980
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1981
1981
|
sectionNum++;
|
|
1982
1982
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1983
1983
|
} catch (e13) {
|
|
1984
1984
|
continue;
|
|
1985
1985
|
}
|
|
1986
1986
|
}
|
|
1987
|
-
if (blocks.length === 0) throw new (0,
|
|
1987
|
+
if (blocks.length === 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1988
1988
|
applyPageText(blocks, shared);
|
|
1989
|
-
const markdown =
|
|
1989
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1990
1990
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1991
1991
|
}
|
|
1992
1992
|
async function resolveSectionPaths(zip) {
|
|
@@ -2000,18 +2000,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2000
2000
|
if (paths.length > 0) return paths;
|
|
2001
2001
|
}
|
|
2002
2002
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2003
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2003
|
+
return sectionFiles.map((f) => f.name).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
|
|
2004
2004
|
}
|
|
2005
2005
|
function parseSectionPathsFromManifest(xml) {
|
|
2006
2006
|
const parser = createXmlParser();
|
|
2007
|
-
const doc = parser.parseFromString(
|
|
2007
|
+
const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2008
2008
|
const items = doc.getElementsByTagName("opf:item");
|
|
2009
2009
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2010
2010
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2011
2011
|
for (let i = 0; i < items.length; i++) {
|
|
2012
2012
|
const item = items[i];
|
|
2013
2013
|
const id = item.getAttribute("id") || "";
|
|
2014
|
-
const href =
|
|
2014
|
+
const href = _chunkZ3O36LBJcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2015
2015
|
if (id && href) idToHref.set(id, href);
|
|
2016
2016
|
}
|
|
2017
2017
|
if (spine.length > 0) {
|
|
@@ -2022,7 +2022,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
if (ordered.length > 0) return ordered;
|
|
2024
2024
|
}
|
|
2025
|
-
return Array.from(idToHref.values()).sort(
|
|
2025
|
+
return Array.from(idToHref.values()).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
|
|
2026
2026
|
}
|
|
2027
2027
|
|
|
2028
2028
|
// src/hwpx/metadata.ts
|
|
@@ -2035,7 +2035,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2035
2035
|
const xml = await file.async("text");
|
|
2036
2036
|
if (decompressed) {
|
|
2037
2037
|
decompressed.total += xml.length * 2;
|
|
2038
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2038
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2039
2039
|
}
|
|
2040
2040
|
parseDublinCoreMetadata(xml, metadata);
|
|
2041
2041
|
if (metadata.title || metadata.author) return;
|
|
@@ -2045,13 +2045,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2047
2047
|
const parser = createXmlParser();
|
|
2048
|
-
const doc = parser.parseFromString(
|
|
2048
|
+
const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2049
2049
|
if (!doc.documentElement) return;
|
|
2050
2050
|
const getText = (tagNames) => {
|
|
2051
2051
|
for (const tag of tagNames) {
|
|
2052
2052
|
const els = doc.getElementsByTagName(tag);
|
|
2053
2053
|
if (els.length > 0) {
|
|
2054
|
-
const text = _optionalChain([els, 'access',
|
|
2054
|
+
const text = _optionalChain([els, 'access', _40 => _40[0], 'access', _41 => _41.textContent, 'optionalAccess', _42 => _42.trim, 'call', _43 => _43()]);
|
|
2055
2055
|
if (text) return text;
|
|
2056
2056
|
}
|
|
2057
2057
|
}
|
|
@@ -2070,7 +2070,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2070
2070
|
|
|
2071
2071
|
// src/hwpx/parser.ts
|
|
2072
2072
|
async function parseHwpxDocument(buffer, options) {
|
|
2073
|
-
|
|
2073
|
+
_chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2074
2074
|
let zip;
|
|
2075
2075
|
try {
|
|
2076
2076
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2079,19 +2079,19 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2079
2079
|
}
|
|
2080
2080
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2081
2081
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2082
|
-
throw new (0,
|
|
2082
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2083
2083
|
}
|
|
2084
2084
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2085
2085
|
if (manifestFile) {
|
|
2086
2086
|
const manifestXml = await manifestFile.async("text");
|
|
2087
2087
|
if (isEncryptedHwpx(manifestXml)) {
|
|
2088
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
2088
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _44 => _44.filePath])) {
|
|
2089
2089
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
2090
2090
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
2091
2091
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2092
2092
|
}
|
|
2093
2093
|
}
|
|
2094
|
-
throw new (0,
|
|
2094
|
+
throw new (0, _chunkZ3O36LBJcjs.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.");
|
|
2095
2095
|
}
|
|
2096
2096
|
}
|
|
2097
2097
|
const decompressed = { total: 0 };
|
|
@@ -2100,9 +2100,9 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2100
2100
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2101
2101
|
const warnings = [];
|
|
2102
2102
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2103
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2103
|
+
if (sectionPaths.length === 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2104
2104
|
metadata.pageCount = sectionPaths.length;
|
|
2105
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
2105
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2106
2106
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
2107
2107
|
const blocks = [];
|
|
2108
2108
|
const shared = createSectionShared();
|
|
@@ -2114,12 +2114,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2114
2114
|
try {
|
|
2115
2115
|
const xml = await file.async("text");
|
|
2116
2116
|
decompressed.total += xml.length * 2;
|
|
2117
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2117
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2118
2118
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2119
2119
|
parsedSections++;
|
|
2120
|
-
_optionalChain([options, 'optionalAccess',
|
|
2120
|
+
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2121
2121
|
} catch (secErr) {
|
|
2122
|
-
if (secErr instanceof
|
|
2122
|
+
if (secErr instanceof _chunkZ3O36LBJcjs.KordocError) throw secErr;
|
|
2123
2123
|
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" });
|
|
2124
2124
|
}
|
|
2125
2125
|
}
|
|
@@ -2127,7 +2127,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2127
2127
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2128
2128
|
detectHwpxHeadings(blocks, styleMap);
|
|
2129
2129
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2130
|
-
const markdown =
|
|
2130
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2131
2131
|
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 };
|
|
2132
2132
|
}
|
|
2133
2133
|
|
|
@@ -2194,7 +2194,7 @@ function decompressStream(data) {
|
|
|
2194
2194
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2195
2195
|
}
|
|
2196
2196
|
function parseFileHeader(data) {
|
|
2197
|
-
if (data.length < 40) throw new (0,
|
|
2197
|
+
if (data.length < 40) throw new (0, _chunkZ3O36LBJcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2198
2198
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2199
2199
|
return {
|
|
2200
2200
|
signature: sig,
|
|
@@ -2327,7 +2327,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
2327
2327
|
const resolveAt = (byteOffset, extended) => {
|
|
2328
2328
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2329
2329
|
const idx = extended ? state.ctrlIdx : -1;
|
|
2330
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
2330
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _48 => _48(idx, ctrlId)]);
|
|
2331
2331
|
if (replacement) result += replacement;
|
|
2332
2332
|
if (extended) state.ctrlIdx++;
|
|
2333
2333
|
};
|
|
@@ -2699,7 +2699,7 @@ function extractHwp5Images(fileIndex, blocks, warnings) {
|
|
|
2699
2699
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
2700
2700
|
if (fileIndex) {
|
|
2701
2701
|
for (const entry of fileIndex) {
|
|
2702
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
2702
|
+
if (!_optionalChain([entry, 'optionalAccess', _49 => _49.name]) || !entry.content) continue;
|
|
2703
2703
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
2704
2704
|
if (!match) continue;
|
|
2705
2705
|
const idx = parseInt(match[1], 16);
|
|
@@ -3728,22 +3728,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3728
3728
|
lenientCfb = parseLenientCfb(buffer);
|
|
3729
3729
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3730
3730
|
} catch (e21) {
|
|
3731
|
-
throw new (0,
|
|
3731
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3732
3732
|
}
|
|
3733
3733
|
}
|
|
3734
3734
|
const findStream = (path) => {
|
|
3735
3735
|
if (cfb) {
|
|
3736
3736
|
const entry = CFB.find(cfb, path);
|
|
3737
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
3737
|
+
return _optionalChain([entry, 'optionalAccess', _50 => _50.content]) ? Buffer.from(entry.content) : null;
|
|
3738
3738
|
}
|
|
3739
3739
|
return lenientCfb.findStream(path);
|
|
3740
3740
|
};
|
|
3741
3741
|
const headerData = findStream("/FileHeader");
|
|
3742
|
-
if (!headerData) throw new (0,
|
|
3742
|
+
if (!headerData) throw new (0, _chunkZ3O36LBJcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3743
3743
|
const header = parseFileHeader(headerData);
|
|
3744
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3745
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3746
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3744
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3745
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3746
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkZ3O36LBJcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3747
3747
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3748
3748
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3749
3749
|
const metadata = {
|
|
@@ -3752,9 +3752,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
3752
3752
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3753
3753
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3754
3754
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3755
|
-
if (sections.length === 0) throw new (0,
|
|
3755
|
+
if (sections.length === 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3756
3756
|
metadata.pageCount = sections.length;
|
|
3757
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3757
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3758
3758
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
3759
3759
|
const bodyBlocks = [];
|
|
3760
3760
|
const doc = createHwp5DocState();
|
|
@@ -3766,31 +3766,31 @@ function parseHwp5Document(buffer, options) {
|
|
|
3766
3766
|
const sectionData = sections[si];
|
|
3767
3767
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3768
3768
|
totalDecompressed += data.length;
|
|
3769
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3769
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3770
3770
|
const records = readRecords(data);
|
|
3771
3771
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3772
3772
|
bodyBlocks.push(...sectionBlocks);
|
|
3773
3773
|
parsedSections++;
|
|
3774
|
-
_optionalChain([options, 'optionalAccess',
|
|
3774
|
+
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3775
3775
|
} catch (secErr) {
|
|
3776
|
-
if (secErr instanceof
|
|
3776
|
+
if (secErr instanceof _chunkZ3O36LBJcjs.KordocError) throw secErr;
|
|
3777
3777
|
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" });
|
|
3778
3778
|
}
|
|
3779
3779
|
}
|
|
3780
3780
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3781
3781
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3782
|
-
const flatBlocks =
|
|
3782
|
+
const flatBlocks = _chunkZ3O36LBJcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3783
3783
|
if (docInfo) {
|
|
3784
3784
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3785
3785
|
}
|
|
3786
3786
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3787
|
-
const markdown =
|
|
3787
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3788
3788
|
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 };
|
|
3789
3789
|
}
|
|
3790
3790
|
function parseDocInfoStream(cfb, compressed) {
|
|
3791
3791
|
try {
|
|
3792
3792
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
3793
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3793
|
+
if (!_optionalChain([entry, 'optionalAccess', _54 => _54.content])) return null;
|
|
3794
3794
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
3795
3795
|
const records = readRecords(data);
|
|
3796
3796
|
return parseDocInfo(records);
|
|
@@ -3811,7 +3811,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3811
3811
|
let baseFontSize = 0;
|
|
3812
3812
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
3813
3813
|
for (const b of blocks) {
|
|
3814
|
-
if (_optionalChain([b, 'access',
|
|
3814
|
+
if (_optionalChain([b, 'access', _55 => _55.style, 'optionalAccess', _56 => _56.fontSize]) && b.text) {
|
|
3815
3815
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
3816
3816
|
}
|
|
3817
3817
|
}
|
|
@@ -3827,7 +3827,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3827
3827
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
3828
3828
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
3829
3829
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
3830
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
3830
|
+
if (_optionalChain([cs, 'optionalAccess', _57 => _57.fontSize]) > 0) {
|
|
3831
3831
|
baseFontSize = cs.fontSize / 10;
|
|
3832
3832
|
break;
|
|
3833
3833
|
}
|
|
@@ -3842,11 +3842,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3842
3842
|
if (text.length === 0 || text.length > 200) continue;
|
|
3843
3843
|
if (/^\d+$/.test(text)) continue;
|
|
3844
3844
|
let level = 0;
|
|
3845
|
-
if (_optionalChain([block, 'access',
|
|
3845
|
+
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3846
3846
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3847
|
-
if (ratio >=
|
|
3848
|
-
else if (ratio >=
|
|
3849
|
-
else if (ratio >=
|
|
3847
|
+
if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H1) level = 1;
|
|
3848
|
+
else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H2) level = 2;
|
|
3849
|
+
else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H3) level = 3;
|
|
3850
3850
|
}
|
|
3851
3851
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3852
3852
|
if (level === 0) level = 2;
|
|
@@ -3862,7 +3862,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3862
3862
|
function extractHwp5Metadata(cfb, metadata) {
|
|
3863
3863
|
try {
|
|
3864
3864
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
3865
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
3865
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _60 => _60.content])) return;
|
|
3866
3866
|
const data = Buffer.from(summaryEntry.content);
|
|
3867
3867
|
if (data.length < 48) return;
|
|
3868
3868
|
const numSets = data.readUInt32LE(24);
|
|
@@ -3895,7 +3895,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
3895
3895
|
const sections = [];
|
|
3896
3896
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
3897
3897
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
3898
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3898
|
+
if (!_optionalChain([entry, 'optionalAccess', _61 => _61.content])) break;
|
|
3899
3899
|
try {
|
|
3900
3900
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
3901
3901
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -3909,13 +3909,13 @@ function findSections(cfb) {
|
|
|
3909
3909
|
const sections = [];
|
|
3910
3910
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
3911
3911
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
3912
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3912
|
+
if (!_optionalChain([entry, 'optionalAccess', _62 => _62.content])) break;
|
|
3913
3913
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
3914
3914
|
}
|
|
3915
3915
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
3916
3916
|
for (const entry of cfb.FileIndex) {
|
|
3917
3917
|
if (sections.length >= MAX_SECTIONS) break;
|
|
3918
|
-
if (_optionalChain([entry, 'access',
|
|
3918
|
+
if (_optionalChain([entry, 'access', _63 => _63.name, 'optionalAccess', _64 => _64.startsWith, 'call', _65 => _65("Section")]) && entry.content) {
|
|
3919
3919
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
3920
3920
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
3921
3921
|
}
|
|
@@ -3931,7 +3931,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3931
3931
|
if (!raw) break;
|
|
3932
3932
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3933
3933
|
totalDecompressed += content.length;
|
|
3934
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3934
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3935
3935
|
sections.push({ idx: i, content });
|
|
3936
3936
|
}
|
|
3937
3937
|
if (sections.length === 0) {
|
|
@@ -3943,7 +3943,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3943
3943
|
if (raw) {
|
|
3944
3944
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3945
3945
|
totalDecompressed += content.length;
|
|
3946
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3946
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3947
3947
|
sections.push({ idx, content });
|
|
3948
3948
|
}
|
|
3949
3949
|
}
|
|
@@ -3960,7 +3960,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3960
3960
|
try {
|
|
3961
3961
|
const content = decryptViewText(raw, compressed);
|
|
3962
3962
|
totalDecompressed += content.length;
|
|
3963
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3963
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3964
3964
|
sections.push({ idx: i, content });
|
|
3965
3965
|
} catch (e26) {
|
|
3966
3966
|
break;
|
|
@@ -4061,9 +4061,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4061
4061
|
const applied = [];
|
|
4062
4062
|
for (const r of ranges) {
|
|
4063
4063
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4064
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
4064
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
4065
4065
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4066
|
-
const href =
|
|
4066
|
+
const href = _chunkZ3O36LBJcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4067
4067
|
if (!href) continue;
|
|
4068
4068
|
const anchor = text.slice(r.start, r.end);
|
|
4069
4069
|
if (!anchor.trim()) continue;
|
|
@@ -4081,7 +4081,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4081
4081
|
}
|
|
4082
4082
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
4083
4083
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
4084
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
4084
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _67 => _67.docInfo, 'optionalAccess', _68 => _68.numberings, 'access', _69 => _69[nid - 1]]) : void 0;
|
|
4085
4085
|
if (numbering) {
|
|
4086
4086
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
4087
4087
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -4091,7 +4091,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4091
4091
|
}
|
|
4092
4092
|
}
|
|
4093
4093
|
} else if (ps.headType === 3) {
|
|
4094
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
4094
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _70 => _70.docInfo, 'optionalAccess', _71 => _71.bullets, 'access', _72 => _72[ps.numberingId - 1]]) : void 0;
|
|
4095
4095
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
4096
4096
|
}
|
|
4097
4097
|
}
|
|
@@ -4296,8 +4296,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4296
4296
|
let tableIdx = -1;
|
|
4297
4297
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4298
4298
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4299
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4300
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4299
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkZ3O36LBJcjs.MAX_ROWS);
|
|
4300
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkZ3O36LBJcjs.MAX_COLS);
|
|
4301
4301
|
tableIdx = i2;
|
|
4302
4302
|
break;
|
|
4303
4303
|
}
|
|
@@ -4337,7 +4337,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4337
4337
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
4338
4338
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
4339
4339
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
4340
|
-
if (_optionalChain([c, 'access',
|
|
4340
|
+
if (_optionalChain([c, 'access', _73 => _73.blocks, 'optionalAccess', _74 => _74.length])) ir.blocks = c.blocks;
|
|
4341
4341
|
if (c.isHeader) ir.isHeader = true;
|
|
4342
4342
|
return ir;
|
|
4343
4343
|
}));
|
|
@@ -4346,7 +4346,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4346
4346
|
return table2;
|
|
4347
4347
|
}
|
|
4348
4348
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4349
|
-
const table =
|
|
4349
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
4350
4350
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4351
4351
|
return table.rows > 0 ? table : null;
|
|
4352
4352
|
}
|
|
@@ -4363,8 +4363,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4363
4363
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4364
4364
|
const cs = rec.data.readUInt16LE(12);
|
|
4365
4365
|
const rs = rec.data.readUInt16LE(14);
|
|
4366
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4367
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4366
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkZ3O36LBJcjs.MAX_COLS);
|
|
4367
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkZ3O36LBJcjs.MAX_ROWS);
|
|
4368
4368
|
}
|
|
4369
4369
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4370
4370
|
const parts = [];
|
|
@@ -4374,7 +4374,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4374
4374
|
parts.push(``);
|
|
4375
4375
|
hasStructure = true;
|
|
4376
4376
|
} else if (b.type === "table" && b.table) {
|
|
4377
|
-
const flat =
|
|
4377
|
+
const flat = _chunkZ3O36LBJcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4378
4378
|
if (flat) parts.push(flat);
|
|
4379
4379
|
hasStructure = true;
|
|
4380
4380
|
} else if (b.text) {
|
|
@@ -4471,8 +4471,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
4471
4471
|
if (data.length < 73) return null;
|
|
4472
4472
|
const binDataId = data.readUInt16LE(71);
|
|
4473
4473
|
if (binDataId === 0) return null;
|
|
4474
|
-
const item = _optionalChain([ctx, 'access',
|
|
4475
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
4474
|
+
const item = _optionalChain([ctx, 'access', _75 => _75.docInfo, 'optionalAccess', _76 => _76.binData, 'access', _77 => _77[binDataId - 1]]);
|
|
4475
|
+
if (_optionalChain([item, 'optionalAccess', _78 => _78.kind]) === "link") {
|
|
4476
4476
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
4477
4477
|
return null;
|
|
4478
4478
|
}
|
|
@@ -16802,13 +16802,16 @@ function getElements(parent, tagName) {
|
|
|
16802
16802
|
const nodes = parent.getElementsByTagName(tagName);
|
|
16803
16803
|
const result = [];
|
|
16804
16804
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
16805
|
+
if (result.length > 0) return result;
|
|
16806
|
+
const nsNodes = _optionalChain([parent, 'access', _79 => _79.getElementsByTagNameNS, 'optionalCall', _80 => _80("*", tagName)]);
|
|
16807
|
+
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
16805
16808
|
return result;
|
|
16806
16809
|
}
|
|
16807
16810
|
function getTextContent(el) {
|
|
16808
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
16811
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
|
|
16809
16812
|
}
|
|
16810
16813
|
function parseXml(text) {
|
|
16811
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16814
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16812
16815
|
}
|
|
16813
16816
|
function parseSharedStrings(xml) {
|
|
16814
16817
|
const doc = parseXml(xml);
|
|
@@ -16945,14 +16948,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16945
16948
|
const merge = mergeMap.get(key);
|
|
16946
16949
|
row.push({
|
|
16947
16950
|
text,
|
|
16948
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16949
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16951
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _84 => _84.colSpan]), () => ( 1)),
|
|
16952
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _85 => _85.rowSpan]), () => ( 1))
|
|
16950
16953
|
});
|
|
16951
16954
|
}
|
|
16952
16955
|
cellRows.push(row);
|
|
16953
16956
|
}
|
|
16954
16957
|
if (cellRows.length > 0) {
|
|
16955
|
-
const table =
|
|
16958
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
16956
16959
|
if (table.rows > 0) {
|
|
16957
16960
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16958
16961
|
}
|
|
@@ -16960,12 +16963,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16960
16963
|
return blocks;
|
|
16961
16964
|
}
|
|
16962
16965
|
async function parseXlsxDocument(buffer, options) {
|
|
16963
|
-
|
|
16966
|
+
_chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16964
16967
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16965
16968
|
const warnings = [];
|
|
16966
16969
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16967
16970
|
if (!workbookFile) {
|
|
16968
|
-
throw new (0,
|
|
16971
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16969
16972
|
}
|
|
16970
16973
|
let sharedStrings = [];
|
|
16971
16974
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16974,7 +16977,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16974
16977
|
}
|
|
16975
16978
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16976
16979
|
if (sheets.length === 0) {
|
|
16977
|
-
throw new (0,
|
|
16980
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16978
16981
|
}
|
|
16979
16982
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16980
16983
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16982,7 +16985,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16982
16985
|
relsMap = parseRels(await relsFile.async("text"));
|
|
16983
16986
|
}
|
|
16984
16987
|
let pageFilter = null;
|
|
16985
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16988
|
+
if (_optionalChain([options, 'optionalAccess', _86 => _86.pages])) {
|
|
16986
16989
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
16987
16990
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
16988
16991
|
}
|
|
@@ -16991,7 +16994,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16991
16994
|
for (let i = 0; i < processedSheets; i++) {
|
|
16992
16995
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
16993
16996
|
const sheet = sheets[i];
|
|
16994
|
-
_optionalChain([options, 'optionalAccess',
|
|
16997
|
+
_optionalChain([options, 'optionalAccess', _87 => _87.onProgress, 'optionalCall', _88 => _88(i + 1, processedSheets)]);
|
|
16995
16998
|
let sheetPath = relsMap.get(sheet.rId);
|
|
16996
16999
|
if (sheetPath) {
|
|
16997
17000
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17046,7 +17049,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17046
17049
|
} catch (e27) {
|
|
17047
17050
|
}
|
|
17048
17051
|
}
|
|
17049
|
-
const markdown =
|
|
17052
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17050
17053
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17051
17054
|
}
|
|
17052
17055
|
|
|
@@ -17453,11 +17456,11 @@ function processGlobals(records) {
|
|
|
17453
17456
|
let encrypted = false;
|
|
17454
17457
|
const firstBof = records[0];
|
|
17455
17458
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17456
|
-
throw new (0,
|
|
17459
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17457
17460
|
}
|
|
17458
17461
|
const bof = decodeBof(firstBof.data);
|
|
17459
17462
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17460
|
-
throw new (0,
|
|
17463
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17461
17464
|
}
|
|
17462
17465
|
let i = 1;
|
|
17463
17466
|
while (i < records.length) {
|
|
@@ -17565,14 +17568,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17565
17568
|
const merge = mergeMap.get(key);
|
|
17566
17569
|
row.push({
|
|
17567
17570
|
text: grid[r][c],
|
|
17568
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17569
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17571
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _89 => _89.colSpan]), () => ( 1)),
|
|
17572
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _90 => _90.rowSpan]), () => ( 1))
|
|
17570
17573
|
});
|
|
17571
17574
|
}
|
|
17572
17575
|
cellRows.push(row);
|
|
17573
17576
|
}
|
|
17574
17577
|
if (cellRows.length > 0) {
|
|
17575
|
-
const table =
|
|
17578
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
17576
17579
|
if (table.rows > 0) {
|
|
17577
17580
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17578
17581
|
}
|
|
@@ -17585,21 +17588,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17585
17588
|
try {
|
|
17586
17589
|
cfb = parseLenientCfb(buf);
|
|
17587
17590
|
} catch (e) {
|
|
17588
|
-
throw new (0,
|
|
17591
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
17589
17592
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17590
17593
|
);
|
|
17591
17594
|
}
|
|
17592
17595
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17593
17596
|
if (!wb) {
|
|
17594
|
-
throw new (0,
|
|
17597
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17595
17598
|
}
|
|
17596
17599
|
const records = readRecords2(wb);
|
|
17597
17600
|
if (records.length === 0) {
|
|
17598
|
-
throw new (0,
|
|
17601
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17599
17602
|
}
|
|
17600
17603
|
const firstBof = decodeBof(records[0].data);
|
|
17601
17604
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17602
|
-
throw new (0,
|
|
17605
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
17603
17606
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17604
17607
|
);
|
|
17605
17608
|
}
|
|
@@ -17620,7 +17623,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17620
17623
|
}
|
|
17621
17624
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17622
17625
|
let pageFilter = null;
|
|
17623
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17626
|
+
if (_optionalChain([options, 'optionalAccess', _91 => _91.pages])) {
|
|
17624
17627
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17625
17628
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17626
17629
|
}
|
|
@@ -17629,7 +17632,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17629
17632
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17630
17633
|
const meta = globals.sheets[i];
|
|
17631
17634
|
if (meta.dt !== 0) continue;
|
|
17632
|
-
_optionalChain([options, 'optionalAccess',
|
|
17635
|
+
_optionalChain([options, 'optionalAccess', _92 => _92.onProgress, 'optionalCall', _93 => _93(i + 1, totalSheets)]);
|
|
17633
17636
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
17634
17637
|
if (bofIdx < 0) {
|
|
17635
17638
|
warnings.push({
|
|
@@ -17659,7 +17662,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17659
17662
|
pageCount: totalSheets
|
|
17660
17663
|
};
|
|
17661
17664
|
return {
|
|
17662
|
-
markdown:
|
|
17665
|
+
markdown: _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17663
17666
|
blocks: allBlocks,
|
|
17664
17667
|
metadata,
|
|
17665
17668
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17672,7 +17675,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17672
17675
|
|
|
17673
17676
|
// src/docx/equation.ts
|
|
17674
17677
|
function lname(el) {
|
|
17675
|
-
return el.localName || _optionalChain([el, 'access',
|
|
17678
|
+
return el.localName || _optionalChain([el, 'access', _94 => _94.tagName, 'optionalAccess', _95 => _95.replace, 'call', _96 => _96(/^[^:]+:/, "")]) || "";
|
|
17676
17679
|
}
|
|
17677
17680
|
function kids(parent, name) {
|
|
17678
17681
|
const out = [];
|
|
@@ -18045,7 +18048,7 @@ function isDisplayMath(el) {
|
|
|
18045
18048
|
// src/docx/parser.ts
|
|
18046
18049
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
18047
18050
|
function matchesLocal(el, localName2) {
|
|
18048
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
18051
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _97 => _97.tagName, 'optionalAccess', _98 => _98.endsWith, 'call', _99 => _99(`:${localName2}`)]), () => ( false)));
|
|
18049
18052
|
}
|
|
18050
18053
|
function effectiveChildElements(parent) {
|
|
18051
18054
|
const result = [];
|
|
@@ -18078,7 +18081,7 @@ function findElements(parent, localName2) {
|
|
|
18078
18081
|
const child = children[i];
|
|
18079
18082
|
if (child.nodeType === 1) {
|
|
18080
18083
|
const el = child;
|
|
18081
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
18084
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _100 => _100.tagName, 'optionalAccess', _101 => _101.endsWith, 'call', _102 => _102(`:${localName2}`)])) {
|
|
18082
18085
|
result.push(el);
|
|
18083
18086
|
}
|
|
18084
18087
|
walk(el);
|
|
@@ -18097,7 +18100,7 @@ function getAttr(el, localName2) {
|
|
|
18097
18100
|
return null;
|
|
18098
18101
|
}
|
|
18099
18102
|
function parseXml2(text) {
|
|
18100
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18103
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18101
18104
|
}
|
|
18102
18105
|
function parseStyles(xml) {
|
|
18103
18106
|
const doc = parseXml2(xml);
|
|
@@ -18199,7 +18202,7 @@ function collectOmmlRoots(p) {
|
|
|
18199
18202
|
const child = children[i];
|
|
18200
18203
|
if (child.nodeType !== 1) continue;
|
|
18201
18204
|
const el = child;
|
|
18202
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
18205
|
+
const tag = el.localName || _optionalChain([el, 'access', _103 => _103.tagName, 'optionalAccess', _104 => _104.replace, 'call', _105 => _105(/^[^:]+:/, "")]) || "";
|
|
18203
18206
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
18204
18207
|
out.push(el);
|
|
18205
18208
|
} else {
|
|
@@ -18288,7 +18291,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18288
18291
|
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18289
18292
|
if (!text) return null;
|
|
18290
18293
|
const style = styles.get(styleId);
|
|
18291
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
18294
|
+
if (_optionalChain([style, 'optionalAccess', _106 => _106.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
18292
18295
|
return {
|
|
18293
18296
|
type: "heading",
|
|
18294
18297
|
text,
|
|
@@ -18297,8 +18300,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18297
18300
|
}
|
|
18298
18301
|
if (numId && numId !== "0") {
|
|
18299
18302
|
const numDef = numbering.get(numId);
|
|
18300
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
18301
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
18303
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _107 => _107.get, 'call', _108 => _108(ilvl)]);
|
|
18304
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _109 => _109.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
18302
18305
|
return { type: "list", text, listType };
|
|
18303
18306
|
}
|
|
18304
18307
|
const block = { type: "paragraph", text };
|
|
@@ -18309,74 +18312,79 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18309
18312
|
if (footnoteText) block.footnoteText = footnoteText;
|
|
18310
18313
|
return block;
|
|
18311
18314
|
}
|
|
18315
|
+
function collectTextboxParagraphs(node, inTxbx = false, out = [], depth = 0) {
|
|
18316
|
+
if (depth > 40) return out;
|
|
18317
|
+
for (const el of effectiveChildElements(node)) {
|
|
18318
|
+
if (matchesLocal(el, "Fallback")) continue;
|
|
18319
|
+
const nowIn = inTxbx || matchesLocal(el, "txbxContent");
|
|
18320
|
+
if (nowIn && matchesLocal(el, "p")) out.push(el);
|
|
18321
|
+
collectTextboxParagraphs(el, nowIn, out, depth + 1);
|
|
18322
|
+
}
|
|
18323
|
+
return out;
|
|
18324
|
+
}
|
|
18312
18325
|
function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
18313
18326
|
const trElements = getChildElements(tbl, "tr");
|
|
18314
18327
|
if (trElements.length === 0) return null;
|
|
18315
|
-
const
|
|
18316
|
-
let maxCols = 0;
|
|
18328
|
+
const rawRows = [];
|
|
18317
18329
|
for (const tr of trElements) {
|
|
18318
|
-
const tcElements = getChildElements(tr, "tc");
|
|
18319
18330
|
const row = [];
|
|
18320
|
-
|
|
18331
|
+
let col = 0;
|
|
18332
|
+
for (const tc of getChildElements(tr, "tc")) {
|
|
18321
18333
|
let colSpan = 1;
|
|
18322
|
-
let
|
|
18334
|
+
let vMerge = null;
|
|
18323
18335
|
const tcPrEls = getChildElements(tc, "tcPr");
|
|
18324
18336
|
if (tcPrEls.length > 0) {
|
|
18325
18337
|
const gridSpanEls = getChildElements(tcPrEls[0], "gridSpan");
|
|
18326
18338
|
if (gridSpanEls.length > 0) {
|
|
18327
|
-
colSpan = parseInt(_nullishCoalesce(getAttr(gridSpanEls[0], "val"), () => ( "1")), 10);
|
|
18339
|
+
colSpan = parseInt(_nullishCoalesce(getAttr(gridSpanEls[0], "val"), () => ( "1")), 10) || 1;
|
|
18328
18340
|
}
|
|
18329
18341
|
const vMergeEls = getChildElements(tcPrEls[0], "vMerge");
|
|
18330
18342
|
if (vMergeEls.length > 0) {
|
|
18331
|
-
|
|
18332
|
-
if (val !== "restart" && val !== null) {
|
|
18333
|
-
row.push({ text: "", colSpan, rowSpan: 0 });
|
|
18334
|
-
continue;
|
|
18335
|
-
}
|
|
18343
|
+
vMerge = getAttr(vMergeEls[0], "val") === "restart" ? "restart" : "continue";
|
|
18336
18344
|
}
|
|
18337
18345
|
}
|
|
18338
|
-
const
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
|
|
18346
|
+
const text = vMerge === "continue" ? "" : collectCellText(tc, styles, numbering, footnotes, rels, 0).join("\n");
|
|
18347
|
+
row.push({ col, colSpan, vMerge, text });
|
|
18348
|
+
col += colSpan;
|
|
18349
|
+
}
|
|
18350
|
+
rawRows.push(row);
|
|
18351
|
+
}
|
|
18352
|
+
const cellRows = rawRows.map(
|
|
18353
|
+
(row, r) => row.filter((cell) => cell.vMerge !== "continue").map((cell) => {
|
|
18354
|
+
let rowSpan = 1;
|
|
18355
|
+
if (cell.vMerge === "restart") {
|
|
18356
|
+
for (let nr = r + 1; nr < rawRows.length; nr++) {
|
|
18357
|
+
if (!rawRows[nr].some((nc) => nc.col === cell.col && nc.vMerge === "continue")) break;
|
|
18358
|
+
rowSpan++;
|
|
18359
|
+
}
|
|
18343
18360
|
}
|
|
18344
|
-
|
|
18345
|
-
}
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
|
|
18353
|
-
|
|
18354
|
-
|
|
18355
|
-
|
|
18356
|
-
|
|
18361
|
+
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18362
|
+
})
|
|
18363
|
+
);
|
|
18364
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
18365
|
+
if (table.rows === 0 || table.cols === 0) return null;
|
|
18366
|
+
return { type: "table", table };
|
|
18367
|
+
}
|
|
18368
|
+
function collectCellText(tc, styles, numbering, footnotes, rels, depth) {
|
|
18369
|
+
const parts = [];
|
|
18370
|
+
if (depth > 20) return parts;
|
|
18371
|
+
for (const el of effectiveChildElements(tc)) {
|
|
18372
|
+
if (matchesLocal(el, "p")) {
|
|
18373
|
+
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18374
|
+
if (_optionalChain([block, 'optionalAccess', _110 => _110.text])) parts.push(block.text);
|
|
18375
|
+
for (const tp of collectTextboxParagraphs(el)) {
|
|
18376
|
+
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
18377
|
+
if (_optionalChain([tb, 'optionalAccess', _111 => _111.text])) parts.push(tb.text);
|
|
18378
|
+
}
|
|
18379
|
+
} else if (matchesLocal(el, "tbl")) {
|
|
18380
|
+
for (const tr of getChildElements(el, "tr")) {
|
|
18381
|
+
for (const nestedTc of getChildElements(tr, "tc")) {
|
|
18382
|
+
parts.push(...collectCellText(nestedTc, styles, numbering, footnotes, rels, depth + 1));
|
|
18383
|
+
}
|
|
18357
18384
|
}
|
|
18358
|
-
cell.rowSpan = span;
|
|
18359
18385
|
}
|
|
18360
18386
|
}
|
|
18361
|
-
|
|
18362
|
-
for (const row of rows) {
|
|
18363
|
-
const clean = row.filter((cell) => cell.rowSpan !== 0);
|
|
18364
|
-
cleanRows.push(clean);
|
|
18365
|
-
}
|
|
18366
|
-
if (cleanRows.length === 0) return null;
|
|
18367
|
-
let cols = 0;
|
|
18368
|
-
for (const row of cleanRows) {
|
|
18369
|
-
let c = 0;
|
|
18370
|
-
for (const cell of row) c += cell.colSpan;
|
|
18371
|
-
if (c > cols) cols = c;
|
|
18372
|
-
}
|
|
18373
|
-
const table = {
|
|
18374
|
-
rows: cleanRows.length,
|
|
18375
|
-
cols,
|
|
18376
|
-
cells: cleanRows,
|
|
18377
|
-
hasHeader: cleanRows.length > 1
|
|
18378
|
-
};
|
|
18379
|
-
return { type: "table", table };
|
|
18387
|
+
return parts;
|
|
18380
18388
|
}
|
|
18381
18389
|
async function extractImages(zip, rels, doc, warnings) {
|
|
18382
18390
|
const blocks = [];
|
|
@@ -18396,7 +18404,7 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18396
18404
|
try {
|
|
18397
18405
|
const data = await imgFile.async("uint8array");
|
|
18398
18406
|
imgIdx++;
|
|
18399
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
18407
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _112 => _112.split, 'call', _113 => _113("."), 'access', _114 => _114.pop, 'call', _115 => _115(), 'optionalAccess', _116 => _116.toLowerCase, 'call', _117 => _117()]), () => ( "png"));
|
|
18400
18408
|
const mimeMap = {
|
|
18401
18409
|
png: "image/png",
|
|
18402
18410
|
jpg: "image/jpeg",
|
|
@@ -18420,12 +18428,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18420
18428
|
return { blocks, images };
|
|
18421
18429
|
}
|
|
18422
18430
|
async function parseDocxDocument(buffer, options) {
|
|
18423
|
-
|
|
18431
|
+
_chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18424
18432
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18425
18433
|
const warnings = [];
|
|
18426
18434
|
const docFile = zip.file("word/document.xml");
|
|
18427
18435
|
if (!docFile) {
|
|
18428
|
-
throw new (0,
|
|
18436
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18429
18437
|
}
|
|
18430
18438
|
let rels = /* @__PURE__ */ new Map();
|
|
18431
18439
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18472,16 +18480,20 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18472
18480
|
const doc = parseXml2(docXml);
|
|
18473
18481
|
const body = findElements(doc, "body");
|
|
18474
18482
|
if (body.length === 0) {
|
|
18475
|
-
throw new (0,
|
|
18483
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18476
18484
|
}
|
|
18477
18485
|
const blocks = [];
|
|
18478
18486
|
const bodyEl = body[0];
|
|
18479
18487
|
const topLevel = effectiveChildElements(bodyEl);
|
|
18480
18488
|
for (const el of topLevel) {
|
|
18481
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
18489
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _118 => _118.tagName, 'optionalAccess', _119 => _119.split, 'call', _120 => _120(":"), 'access', _121 => _121.pop, 'call', _122 => _122()])));
|
|
18482
18490
|
if (localName2 === "p") {
|
|
18483
18491
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18484
18492
|
if (block) blocks.push(block);
|
|
18493
|
+
for (const tp of collectTextboxParagraphs(el)) {
|
|
18494
|
+
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
18495
|
+
if (tb) blocks.push(tb);
|
|
18496
|
+
}
|
|
18485
18497
|
} else if (localName2 === "tbl") {
|
|
18486
18498
|
const block = parseTable(el, styles, numbering, footnotes, rels);
|
|
18487
18499
|
if (block) blocks.push(block);
|
|
@@ -18513,7 +18525,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18513
18525
|
}
|
|
18514
18526
|
}
|
|
18515
18527
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18516
|
-
const markdown =
|
|
18528
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18517
18529
|
return {
|
|
18518
18530
|
markdown,
|
|
18519
18531
|
blocks,
|
|
@@ -18536,7 +18548,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18536
18548
|
}
|
|
18537
18549
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18538
18550
|
const normalized = text.replace(/ /g, " ");
|
|
18539
|
-
const xml =
|
|
18551
|
+
const xml = _chunkZ3O36LBJcjs.stripDtd.call(void 0, normalized);
|
|
18540
18552
|
const warnings = [];
|
|
18541
18553
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18542
18554
|
onError: (_level, msg2) => {
|
|
@@ -18564,7 +18576,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18564
18576
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18565
18577
|
}
|
|
18566
18578
|
const blocks = [];
|
|
18567
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
18579
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18568
18580
|
let sectionIdx = 0;
|
|
18569
18581
|
const children = body.childNodes;
|
|
18570
18582
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18576,7 +18588,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18576
18588
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18577
18589
|
}
|
|
18578
18590
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18579
|
-
const markdown =
|
|
18591
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18580
18592
|
return {
|
|
18581
18593
|
markdown,
|
|
18582
18594
|
blocks,
|
|
@@ -18625,6 +18637,7 @@ function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderF
|
|
|
18625
18637
|
if (tag === "P") {
|
|
18626
18638
|
if (!inHeaderFooter) {
|
|
18627
18639
|
parseParagraph3(el, blocks, paraShapeMap, sectionNum);
|
|
18640
|
+
walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings);
|
|
18628
18641
|
}
|
|
18629
18642
|
continue;
|
|
18630
18643
|
}
|
|
@@ -18641,12 +18654,27 @@ function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderF
|
|
|
18641
18654
|
walkContent(el, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, depth + 1);
|
|
18642
18655
|
}
|
|
18643
18656
|
}
|
|
18657
|
+
function walkTablesInP(node, blocks, paraShapeMap, sectionNum, warnings, depth = 0) {
|
|
18658
|
+
if (depth > MAX_XML_DEPTH2) return;
|
|
18659
|
+
const children = node.childNodes;
|
|
18660
|
+
for (let i = 0; i < children.length; i++) {
|
|
18661
|
+
const el = children[i];
|
|
18662
|
+
if (el.nodeType !== 1) continue;
|
|
18663
|
+
const tag = localName(el);
|
|
18664
|
+
if (tag === "TABLE") {
|
|
18665
|
+
parseTable2(el, blocks, paraShapeMap, sectionNum, warnings);
|
|
18666
|
+
continue;
|
|
18667
|
+
}
|
|
18668
|
+
if (tag === "FOOTNOTE" || tag === "ENDNOTE" || tag === "HEADER" || tag === "FOOTER") continue;
|
|
18669
|
+
walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings, depth + 1);
|
|
18670
|
+
}
|
|
18671
|
+
}
|
|
18644
18672
|
function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
18645
18673
|
const paraShapeId = _nullishCoalesce(el.getAttribute("ParaShape"), () => ( ""));
|
|
18646
18674
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
18647
18675
|
const text = extractParagraphText(el);
|
|
18648
18676
|
if (!text) return;
|
|
18649
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
18677
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _124 => _124.headingLevel]) != null) {
|
|
18650
18678
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
18651
18679
|
} else {
|
|
18652
18680
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -18718,15 +18746,15 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18718
18746
|
const cellRows = grid.map(
|
|
18719
18747
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18720
18748
|
);
|
|
18721
|
-
const table =
|
|
18749
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
18722
18750
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18723
18751
|
}
|
|
18724
18752
|
function extractCellText(cellEl) {
|
|
18725
18753
|
const textParts = [];
|
|
18726
|
-
|
|
18754
|
+
collectCellText2(cellEl, textParts, 0);
|
|
18727
18755
|
return textParts.filter(Boolean).join("\n").trim();
|
|
18728
18756
|
}
|
|
18729
|
-
function
|
|
18757
|
+
function collectCellText2(node, parts, depth) {
|
|
18730
18758
|
if (depth > 20) return;
|
|
18731
18759
|
const children = node.childNodes;
|
|
18732
18760
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18736,11 +18764,27 @@ function collectCellText(node, parts, depth) {
|
|
|
18736
18764
|
if (tag === "P") {
|
|
18737
18765
|
const t = extractParagraphText(el);
|
|
18738
18766
|
if (t) parts.push(t);
|
|
18767
|
+
collectNestedTableText(el, parts, depth + 1);
|
|
18739
18768
|
} else if (tag === "TABLE") {
|
|
18740
|
-
|
|
18769
|
+
collectCellText2(el, parts, depth + 1);
|
|
18741
18770
|
} else {
|
|
18742
|
-
|
|
18771
|
+
collectCellText2(el, parts, depth + 1);
|
|
18772
|
+
}
|
|
18773
|
+
}
|
|
18774
|
+
}
|
|
18775
|
+
function collectNestedTableText(node, parts, depth) {
|
|
18776
|
+
if (depth > 20) return;
|
|
18777
|
+
const children = node.childNodes;
|
|
18778
|
+
for (let i = 0; i < children.length; i++) {
|
|
18779
|
+
const el = children[i];
|
|
18780
|
+
if (el.nodeType !== 1) continue;
|
|
18781
|
+
const tag = localName(el);
|
|
18782
|
+
if (tag === "TABLE") {
|
|
18783
|
+
collectCellText2(el, parts, depth + 1);
|
|
18784
|
+
continue;
|
|
18743
18785
|
}
|
|
18786
|
+
if (tag === "FOOTNOTE" || tag === "ENDNOTE" || tag === "HEADER" || tag === "FOOTER") continue;
|
|
18787
|
+
collectNestedTableText(el, parts, depth + 1);
|
|
18744
18788
|
}
|
|
18745
18789
|
}
|
|
18746
18790
|
function localName(el) {
|
|
@@ -19079,8 +19123,8 @@ function extractFromTable(table) {
|
|
|
19079
19123
|
if (table.cols >= 2) {
|
|
19080
19124
|
for (let r = 0; r < table.rows; r++) {
|
|
19081
19125
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
19082
|
-
const labelCell = _optionalChain([table, 'access',
|
|
19083
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19126
|
+
const labelCell = _optionalChain([table, 'access', _125 => _125.cells, 'access', _126 => _126[r], 'optionalAccess', _127 => _127[c]]);
|
|
19127
|
+
const valueCell = _optionalChain([table, 'access', _128 => _128.cells, 'access', _129 => _129[r], 'optionalAccess', _130 => _130[c + 1]]);
|
|
19084
19128
|
if (!labelCell || !valueCell) continue;
|
|
19085
19129
|
if (isLabelCell(labelCell.text)) {
|
|
19086
19130
|
fields.push({
|
|
@@ -19102,8 +19146,8 @@ function extractFromTable(table) {
|
|
|
19102
19146
|
if (allLabels) {
|
|
19103
19147
|
for (let r = 1; r < table.rows; r++) {
|
|
19104
19148
|
for (let c = 0; c < table.cols; c++) {
|
|
19105
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19106
|
-
const value = _nullishCoalesce(_optionalChain([table, 'access',
|
|
19149
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _131 => _131[c], 'optionalAccess', _132 => _132.text, 'access', _133 => _133.trim, 'call', _134 => _134()]), () => ( ""));
|
|
19150
|
+
const value = _nullishCoalesce(_optionalChain([table, 'access', _135 => _135.cells, 'access', _136 => _136[r], 'optionalAccess', _137 => _137[c], 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()]), () => ( ""));
|
|
19107
19151
|
if (label && value) {
|
|
19108
19152
|
fields.push({ label, value, row: r, col: c });
|
|
19109
19153
|
}
|
|
@@ -19196,7 +19240,7 @@ function fillFormFields(blocks, values) {
|
|
|
19196
19240
|
for (const table of allTables) {
|
|
19197
19241
|
for (let r = 0; r < table.rows; r++) {
|
|
19198
19242
|
for (let c = 0; c < table.cols; c++) {
|
|
19199
|
-
const cell = _optionalChain([table, 'access',
|
|
19243
|
+
const cell = _optionalChain([table, 'access', _141 => _141.cells, 'access', _142 => _142[r], 'optionalAccess', _143 => _143[c]]);
|
|
19200
19244
|
if (!cell) continue;
|
|
19201
19245
|
const result = fillInCellPatterns(cell.text, cursor, matchedLabels);
|
|
19202
19246
|
if (result) {
|
|
@@ -19228,7 +19272,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19228
19272
|
out.push(block.table);
|
|
19229
19273
|
for (const row of block.table.cells) {
|
|
19230
19274
|
for (const cell of row) {
|
|
19231
|
-
if (_optionalChain([cell, 'optionalAccess',
|
|
19275
|
+
if (_optionalChain([cell, 'optionalAccess', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) out.push(...collectIRTables(cell.blocks, depth + 1));
|
|
19232
19276
|
}
|
|
19233
19277
|
}
|
|
19234
19278
|
}
|
|
@@ -19239,7 +19283,7 @@ function coveredPositions(table) {
|
|
|
19239
19283
|
for (let r = 0; r < table.rows; r++) {
|
|
19240
19284
|
for (let c = 0; c < table.cols; c++) {
|
|
19241
19285
|
if (covered.has(`${r},${c}`)) continue;
|
|
19242
|
-
const cell = _optionalChain([table, 'access',
|
|
19286
|
+
const cell = _optionalChain([table, 'access', _146 => _146.cells, 'access', _147 => _147[r], 'optionalAccess', _148 => _148[c]]);
|
|
19243
19287
|
if (!cell) continue;
|
|
19244
19288
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
19245
19289
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -19273,7 +19317,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19273
19317
|
if (matchKey === void 0) continue;
|
|
19274
19318
|
const newValue = values.consume(matchKey);
|
|
19275
19319
|
if (newValue === void 0) continue;
|
|
19276
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19320
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _149 => _149.has, 'call', _150 => _150(valueCell)])) {
|
|
19277
19321
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19278
19322
|
} else {
|
|
19279
19323
|
valueCell.text = newValue;
|
|
@@ -19298,7 +19342,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19298
19342
|
for (let c = 0; c < table.cols; c++) {
|
|
19299
19343
|
if (covered.has(`${r},${c}`)) continue;
|
|
19300
19344
|
const headerCell = headerRow[c];
|
|
19301
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19345
|
+
const valueCell = _optionalChain([table, 'access', _151 => _151.cells, 'access', _152 => _152[r], 'optionalAccess', _153 => _153[c]]);
|
|
19302
19346
|
if (!headerCell || !valueCell) continue;
|
|
19303
19347
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19304
19348
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
@@ -19891,19 +19935,19 @@ function parseCentralDirectory(buf) {
|
|
|
19891
19935
|
}
|
|
19892
19936
|
}
|
|
19893
19937
|
}
|
|
19894
|
-
if (eocdOffset < 0) throw new (0,
|
|
19938
|
+
if (eocdOffset < 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19895
19939
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19896
19940
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19897
19941
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19898
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19942
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19899
19943
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19900
|
-
throw new (0,
|
|
19944
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19901
19945
|
}
|
|
19902
19946
|
const decoder = new TextDecoder("utf-8");
|
|
19903
19947
|
const entries = [];
|
|
19904
19948
|
let pos = cdOffset;
|
|
19905
19949
|
for (let i = 0; i < totalEntries; i++) {
|
|
19906
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19950
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19907
19951
|
const flags = view.getUint16(pos + 8, true);
|
|
19908
19952
|
const method = view.getUint16(pos + 10, true);
|
|
19909
19953
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19914,7 +19958,7 @@ function parseCentralDirectory(buf) {
|
|
|
19914
19958
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19915
19959
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19916
19960
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19917
|
-
throw new (0,
|
|
19961
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19918
19962
|
}
|
|
19919
19963
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19920
19964
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19943,7 +19987,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19943
19987
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19944
19988
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19945
19989
|
for (const name of replacements.keys()) {
|
|
19946
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19990
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkZ3O36LBJcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19947
19991
|
}
|
|
19948
19992
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19949
19993
|
const segments = [];
|
|
@@ -19961,7 +20005,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19961
20005
|
offset += seg.length;
|
|
19962
20006
|
continue;
|
|
19963
20007
|
}
|
|
19964
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20008
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19965
20009
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19966
20010
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19967
20011
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20016,7 +20060,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20016
20060
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20017
20061
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20018
20062
|
if (sectionPaths.length === 0) {
|
|
20019
|
-
throw new (0,
|
|
20063
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20020
20064
|
}
|
|
20021
20065
|
const normalizedValues = normalizeValues(values);
|
|
20022
20066
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20175,7 +20219,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20175
20219
|
}
|
|
20176
20220
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20177
20221
|
const existing = ledger.get(para);
|
|
20178
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20222
|
+
if (_optionalChain([existing, 'optionalAccess', _154 => _154.fullText]) !== void 0) continue;
|
|
20179
20223
|
const text = matchText(para);
|
|
20180
20224
|
for (const seg of scanInlineSegments(text)) {
|
|
20181
20225
|
const matchKey = findMatchingKey(normalizeLabel(seg.label), cursor);
|
|
@@ -20414,8 +20458,8 @@ function charWidthEm1000(cp) {
|
|
|
20414
20458
|
var SPACE_EM_FIXED = 500;
|
|
20415
20459
|
var SPACE_EM_FONT = 300;
|
|
20416
20460
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20417
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20418
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20461
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _155 => _155.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20462
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _156 => _156.spacingPct]), () => ( 0));
|
|
20419
20463
|
let em = 0;
|
|
20420
20464
|
for (const ch of text) {
|
|
20421
20465
|
const cp = ch.codePointAt(0);
|
|
@@ -20428,8 +20472,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20428
20472
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20429
20473
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20430
20474
|
const EPS = 0.5;
|
|
20431
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20432
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20475
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _157 => _157.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20476
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _158 => _158.spacingPct]), () => ( 0));
|
|
20433
20477
|
const k = height * ratioPct / 100 / 1e3;
|
|
20434
20478
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20435
20479
|
const charW = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20655,16 +20699,16 @@ var PARA_LIST = 7;
|
|
|
20655
20699
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20656
20700
|
function resolveTheme(theme) {
|
|
20657
20701
|
return {
|
|
20658
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20659
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20660
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20661
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20662
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20663
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20702
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _159 => _159.headingColors, 'optionalAccess', _160 => _160[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20703
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _161 => _161.headingColors, 'optionalAccess', _162 => _162[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20704
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _163 => _163.headingColors, 'optionalAccess', _164 => _164[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20705
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _165 => _165.headingColors, 'optionalAccess', _166 => _166[4]]), () => ( _optionalChain([theme, 'optionalAccess', _167 => _167.headingColors, 'optionalAccess', _168 => _168[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20706
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _169 => _169.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20707
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _170 => _170.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20664
20708
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20665
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20666
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20667
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
20709
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _171 => _171.quoteColor]) !== void 0,
|
|
20710
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _172 => _172.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _173 => _173.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20711
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _174 => _174.tableHeaderBold])
|
|
20668
20712
|
};
|
|
20669
20713
|
}
|
|
20670
20714
|
function escapeXml(text) {
|
|
@@ -20695,12 +20739,13 @@ function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_C
|
|
|
20695
20739
|
</hh:charPr>`;
|
|
20696
20740
|
}
|
|
20697
20741
|
function paraPr(id, opts = {}) {
|
|
20698
|
-
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0, keepWord = false } = opts;
|
|
20742
|
+
const { align = "JUSTIFY", spaceBefore = 0, spaceAfter = 0, lineSpacing = 160, indent = 0, left = 0, keepWord = false, outlineLevel } = opts;
|
|
20699
20743
|
const breakNonLatin = keepWord ? "KEEP_WORD" : "BREAK_WORD";
|
|
20700
20744
|
const snapGrid = keepWord ? "0" : "1";
|
|
20745
|
+
const heading = outlineLevel !== void 0 ? `<hh:heading type="OUTLINE" idRef="0" level="${outlineLevel}"/>` : `<hh:heading type="NONE" idRef="0" level="0"/>`;
|
|
20701
20746
|
return ` <hh:paraPr id="${id}" tabPrIDRef="0" condense="0" fontLineHeight="0" snapToGrid="${snapGrid}" suppressLineNumbers="0" checked="0" textDir="AUTO">
|
|
20702
20747
|
<hh:align horizontal="${align}" vertical="BASELINE"/>
|
|
20703
|
-
|
|
20748
|
+
${heading}
|
|
20704
20749
|
<hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="${breakNonLatin}" widowOrphan="0" keepWithNext="0" keepLines="0" pageBreakBefore="0" lineWrap="BREAK"/>
|
|
20705
20750
|
<hh:autoSpacing eAsianEng="0" eAsianNum="0"/>
|
|
20706
20751
|
<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>
|
|
@@ -20807,7 +20852,7 @@ function parseMarkdownToBlocks(md2) {
|
|
|
20807
20852
|
if (listMatch) {
|
|
20808
20853
|
const indent = Math.floor(listMatch[1].length / 2);
|
|
20809
20854
|
const ordered = /\d/.test(listMatch[2]);
|
|
20810
|
-
blocks.push({ type: "list_item", text: listMatch[3].trim(), ordered, indent });
|
|
20855
|
+
blocks.push({ type: "list_item", text: listMatch[3].trim(), ordered, indent, marker: listMatch[2] });
|
|
20811
20856
|
i++;
|
|
20812
20857
|
continue;
|
|
20813
20858
|
}
|
|
@@ -20817,6 +20862,11 @@ function parseMarkdownToBlocks(md2) {
|
|
|
20817
20862
|
return blocks;
|
|
20818
20863
|
}
|
|
20819
20864
|
function parseInlineMarkdown(text) {
|
|
20865
|
+
const literals = [];
|
|
20866
|
+
text = text.replace(/\x00/g, "").replace(/\\([\\`*_{}[\]()#+\-.!|>~])/g, (_, c) => {
|
|
20867
|
+
literals.push(c);
|
|
20868
|
+
return `\0${literals.length - 1}\0`;
|
|
20869
|
+
});
|
|
20820
20870
|
text = text.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
|
|
20821
20871
|
text = text.replace(/\[([^\]]*)\]\(([^)]*)\)/g, (_, t, u) => t || u);
|
|
20822
20872
|
text = text.replace(/~~([^~]+)~~/g, "$1");
|
|
@@ -20846,6 +20896,13 @@ function parseInlineMarkdown(text) {
|
|
|
20846
20896
|
if (spans.length === 0) {
|
|
20847
20897
|
spans.push({ text, bold: false, italic: false, code: false });
|
|
20848
20898
|
}
|
|
20899
|
+
for (const span of spans) {
|
|
20900
|
+
if (!span.text.includes("\0")) continue;
|
|
20901
|
+
span.text = span.text.replace(/\x00(\d+)\x00/g, (_, i) => {
|
|
20902
|
+
const c = _nullishCoalesce(literals[+i], () => ( ""));
|
|
20903
|
+
return span.code ? "\\" + c : c;
|
|
20904
|
+
});
|
|
20905
|
+
}
|
|
20849
20906
|
return spans;
|
|
20850
20907
|
}
|
|
20851
20908
|
function spanToCharPrId(span) {
|
|
@@ -20933,10 +20990,10 @@ function buildParaProperties(gongmun) {
|
|
|
20933
20990
|
if (!gongmun) {
|
|
20934
20991
|
const base2 = [
|
|
20935
20992
|
paraPr(0),
|
|
20936
|
-
paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 }),
|
|
20937
|
-
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 }),
|
|
20938
|
-
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 }),
|
|
20939
|
-
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160 }),
|
|
20993
|
+
paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180, outlineLevel: 0 }),
|
|
20994
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170, outlineLevel: 1 }),
|
|
20995
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160, outlineLevel: 2 }),
|
|
20996
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: 160, outlineLevel: 3 }),
|
|
20940
20997
|
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20941
20998
|
paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 }),
|
|
20942
20999
|
paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })
|
|
@@ -20949,10 +21006,10 @@ ${base2.join("\n")}
|
|
|
20949
21006
|
const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
|
|
20950
21007
|
const base = [
|
|
20951
21008
|
paraPr(0, { lineSpacing: ls, keepWord: true }),
|
|
20952
|
-
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls, keepWord: true }),
|
|
20953
|
-
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls, keepWord: true }),
|
|
20954
|
-
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
20955
|
-
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
21009
|
+
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls, keepWord: true, outlineLevel: 0 }),
|
|
21010
|
+
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls, keepWord: true, outlineLevel: 1 }),
|
|
21011
|
+
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls, keepWord: true, outlineLevel: 2 }),
|
|
21012
|
+
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls, keepWord: true, outlineLevel: 3 }),
|
|
20956
21013
|
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400, keepWord: true }),
|
|
20957
21014
|
paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true }),
|
|
20958
21015
|
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true })
|
|
@@ -20967,8 +21024,19 @@ ${base2.join("\n")}
|
|
|
20967
21024
|
${base.join("\n")}
|
|
20968
21025
|
</hh:paraProperties>`;
|
|
20969
21026
|
}
|
|
21027
|
+
function buildNumberings() {
|
|
21028
|
+
const heads = Array.from(
|
|
21029
|
+
{ length: 7 },
|
|
21030
|
+
(_, i) => ` <hh:paraHead start="1" level="${i + 1}" align="LEFT" useInstWidth="1" autoIndent="1" widthAdjust="0" textOffsetType="PERCENT" textOffset="50" numFormat="DIGIT" charPrIDRef="4294967295" checkable="0"/>`
|
|
21031
|
+
).join("\n");
|
|
21032
|
+
return `<hh:numberings itemCnt="1">
|
|
21033
|
+
<hh:numbering id="1" start="0">
|
|
21034
|
+
${heads}
|
|
21035
|
+
</hh:numbering>
|
|
21036
|
+
</hh:numberings>`;
|
|
21037
|
+
}
|
|
20970
21038
|
function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
20971
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
21039
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _175 => _175.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
20972
21040
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants);
|
|
20973
21041
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
20974
21042
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -21044,7 +21112,7 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21044
21112
|
</hh:borderFills>
|
|
21045
21113
|
${charPropsXml}
|
|
21046
21114
|
<hh:tabProperties itemCnt="0"/>
|
|
21047
|
-
|
|
21115
|
+
${buildNumberings()}
|
|
21048
21116
|
<hh:bullets itemCnt="0"/>
|
|
21049
21117
|
${paraPropsXml}
|
|
21050
21118
|
<hh:styles itemCnt="1">
|
|
@@ -21309,11 +21377,11 @@ function bestSimInRange(arr, from, to, target) {
|
|
|
21309
21377
|
return best;
|
|
21310
21378
|
}
|
|
21311
21379
|
function escapeGfm(text) {
|
|
21312
|
-
return text.replace(
|
|
21380
|
+
return text.replace(/([~*])/g, "\\$1");
|
|
21313
21381
|
}
|
|
21314
21382
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21315
21383
|
function sanitizeText(text) {
|
|
21316
|
-
let result =
|
|
21384
|
+
let result = _chunkZ3O36LBJcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21317
21385
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21318
21386
|
const tokens = result.split(" ");
|
|
21319
21387
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21327,7 +21395,7 @@ function normForMatch(text) {
|
|
|
21327
21395
|
return sanitizeText(text).replace(/\s+/g, " ").trim();
|
|
21328
21396
|
}
|
|
21329
21397
|
function unescapeGfm(text) {
|
|
21330
|
-
return text.replace(
|
|
21398
|
+
return text.replace(/\\([~*])/g, "$1");
|
|
21331
21399
|
}
|
|
21332
21400
|
function summarize(text) {
|
|
21333
21401
|
const t = text.replace(/\s+/g, " ").trim();
|
|
@@ -21343,7 +21411,7 @@ function replicateGfmTable(table) {
|
|
|
21343
21411
|
for (let r = 0; r < numRows; r++) {
|
|
21344
21412
|
for (let c = 0; c < numCols; c++) {
|
|
21345
21413
|
if (skip.has(`${r},${c}`)) continue;
|
|
21346
|
-
const cell = _optionalChain([cells, 'access',
|
|
21414
|
+
const cell = _optionalChain([cells, 'access', _176 => _176[r], 'optionalAccess', _177 => _177[c]]);
|
|
21347
21415
|
if (!cell) continue;
|
|
21348
21416
|
display[r][c] = {
|
|
21349
21417
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -21394,10 +21462,10 @@ function parseGfmTable(lines) {
|
|
|
21394
21462
|
return rows;
|
|
21395
21463
|
}
|
|
21396
21464
|
function unescapeGfmCell(text) {
|
|
21397
|
-
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(
|
|
21465
|
+
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
21398
21466
|
}
|
|
21399
21467
|
function replicateCellInnerHtml(cell) {
|
|
21400
|
-
if (_optionalChain([cell, 'access',
|
|
21468
|
+
if (_optionalChain([cell, 'access', _178 => _178.blocks, 'optionalAccess', _179 => _179.length])) {
|
|
21401
21469
|
return cell.blocks.map((b) => {
|
|
21402
21470
|
if (b.type === "table" && b.table) {
|
|
21403
21471
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -21436,7 +21504,7 @@ function replicateHtmlTable(table) {
|
|
|
21436
21504
|
const rowCells = [];
|
|
21437
21505
|
for (let c = 0; c < numCols; c++) {
|
|
21438
21506
|
if (skip.has(`${r},${c}`)) continue;
|
|
21439
|
-
const cell = _optionalChain([cells, 'access',
|
|
21507
|
+
const cell = _optionalChain([cells, 'access', _180 => _180[r], 'optionalAccess', _181 => _181[c]]);
|
|
21440
21508
|
if (!cell) continue;
|
|
21441
21509
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
21442
21510
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -21482,8 +21550,8 @@ function parseHtmlTable(raw) {
|
|
|
21482
21550
|
}
|
|
21483
21551
|
} else {
|
|
21484
21552
|
if (!isClose) {
|
|
21485
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
21486
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
21553
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _182 => _182.match, 'call', _183 => _183(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _184 => _184[1]]) || "1", 10);
|
|
21554
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _185 => _185.match, 'call', _186 => _186(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _187 => _187[1]]) || "1", 10);
|
|
21487
21555
|
cellStart = m.index + m[0].length;
|
|
21488
21556
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
21489
21557
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -21653,7 +21721,7 @@ function generateSecPr(gongmun) {
|
|
|
21653
21721
|
header: 0,
|
|
21654
21722
|
footer: 0
|
|
21655
21723
|
} : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
|
|
21656
|
-
return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="
|
|
21724
|
+
return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" 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>`;
|
|
21657
21725
|
}
|
|
21658
21726
|
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null) {
|
|
21659
21727
|
const paraXmls = [];
|
|
@@ -21700,8 +21768,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21700
21768
|
case "list_item": {
|
|
21701
21769
|
if (gongmun && gongmunList) {
|
|
21702
21770
|
const info = gongmunList.get(blockIdx);
|
|
21703
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
21704
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
21771
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _188 => _188.depth]), () => ( 0));
|
|
21772
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _189 => _189.marker]), () => ( ""));
|
|
21705
21773
|
const content = block.text || "";
|
|
21706
21774
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
21707
21775
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -21710,7 +21778,10 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21710
21778
|
}
|
|
21711
21779
|
const indent = block.indent || 0;
|
|
21712
21780
|
let marker;
|
|
21713
|
-
if (block.
|
|
21781
|
+
if (block.marker) {
|
|
21782
|
+
marker = `${block.marker} `;
|
|
21783
|
+
prevWasOrdered = !!block.ordered;
|
|
21784
|
+
} else if (block.ordered) {
|
|
21714
21785
|
orderedCounters[indent] = (orderedCounters[indent] || 0) + 1;
|
|
21715
21786
|
for (const k of Object.keys(orderedCounters)) {
|
|
21716
21787
|
if (+k > indent) delete orderedCounters[+k];
|
|
@@ -21778,8 +21849,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21778
21849
|
|
|
21779
21850
|
// src/hwpx/generator.ts
|
|
21780
21851
|
async function markdownToHwpx(markdown, options) {
|
|
21781
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
21782
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
21852
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _190 => _190.theme]));
|
|
21853
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _191 => _191.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
21783
21854
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
21784
21855
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
21785
21856
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
@@ -21788,7 +21859,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
21788
21859
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
21789
21860
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
21790
21861
|
zip.file("Contents/content.hpf", generateManifest());
|
|
21791
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
21862
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _192 => _192.variants]), () => ( []))));
|
|
21792
21863
|
zip.file("Contents/section0.xml", sectionXml);
|
|
21793
21864
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
21794
21865
|
return await zip.generateAsync({ type: "arraybuffer" });
|
|
@@ -21936,7 +22007,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
21936
22007
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
21937
22008
|
function patchTableRows(input) {
|
|
21938
22009
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
21939
|
-
const xml = _optionalChain([ctx, 'access',
|
|
22010
|
+
const xml = _optionalChain([ctx, 'access', _193 => _193.scans, 'access', _194 => _194[scanTable.sectionIndex], 'optionalAccess', _195 => _195.xml]);
|
|
21940
22011
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
21941
22012
|
const numRows = table.rows;
|
|
21942
22013
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -22103,7 +22174,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
22103
22174
|
const rr = scanTable.rowRanges[template];
|
|
22104
22175
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
22105
22176
|
const scan = scanSectionXml(wrapped, 0);
|
|
22106
|
-
const row = _optionalChain([scan, 'access',
|
|
22177
|
+
const row = _optionalChain([scan, 'access', _196 => _196.tables, 'access', _197 => _197[0], 'optionalAccess', _198 => _198.rows, 'access', _199 => _199[0]]);
|
|
22107
22178
|
if (!row || row.length !== cells.length) return null;
|
|
22108
22179
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
22109
22180
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -22146,7 +22217,7 @@ function rowHeightOf(fragment) {
|
|
|
22146
22217
|
}
|
|
22147
22218
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
22148
22219
|
const from = scanTable.start + tblOpenLen;
|
|
22149
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
22220
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _200 => _200.rowRanges, 'access', _201 => _201[0], 'optionalAccess', _202 => _202.start]), () => ( from));
|
|
22150
22221
|
const slice = xml.slice(from, to);
|
|
22151
22222
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
22152
22223
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -22335,9 +22406,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
22335
22406
|
});
|
|
22336
22407
|
}
|
|
22337
22408
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
22338
|
-
const irCell = _optionalChain([table, 'access',
|
|
22409
|
+
const irCell = _optionalChain([table, 'access', _203 => _203.cells, 'access', _204 => _204[oc.gridR], 'optionalAccess', _205 => _205[oc.gridC]]);
|
|
22339
22410
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
22340
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
22411
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _206 => _206.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
22341
22412
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
22342
22413
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
22343
22414
|
}
|
|
@@ -22405,7 +22476,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22405
22476
|
};
|
|
22406
22477
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
22407
22478
|
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)");
|
|
22408
|
-
const irCell = _optionalChain([table, 'access',
|
|
22479
|
+
const irCell = _optionalChain([table, 'access', _207 => _207.cells, 'access', _208 => _208[gridR], 'optionalAccess', _209 => _209[gridC]]);
|
|
22409
22480
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
22410
22481
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
22411
22482
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -22428,7 +22499,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22428
22499
|
if (newLines.length === 0) return 0;
|
|
22429
22500
|
const target = cell.paragraphs[0];
|
|
22430
22501
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
22431
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
22502
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _210 => _210.scans, 'access', _211 => _211[target.sectionIndex], 'optionalAccess', _212 => _212.xml]));
|
|
22432
22503
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22433
22504
|
splices.push(...sp);
|
|
22434
22505
|
sectionIndex = target.sectionIndex;
|
|
@@ -22451,7 +22522,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22451
22522
|
}
|
|
22452
22523
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
22453
22524
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
22454
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
22525
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _213 => _213.scans, 'access', _214 => _214[nonEmpty[i].sectionIndex], 'optionalAccess', _215 => _215.xml]));
|
|
22455
22526
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22456
22527
|
splices.push(...sp);
|
|
22457
22528
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -22532,7 +22603,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
22532
22603
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
22533
22604
|
if (paths.length > 0) return paths;
|
|
22534
22605
|
}
|
|
22535
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
22606
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
|
|
22536
22607
|
}
|
|
22537
22608
|
function sectionPathsFromManifest(xml) {
|
|
22538
22609
|
const attr = (tag, name) => {
|
|
@@ -22542,7 +22613,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22542
22613
|
const idToHref = /* @__PURE__ */ new Map();
|
|
22543
22614
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
22544
22615
|
const id = attr(m[1], "id");
|
|
22545
|
-
const href =
|
|
22616
|
+
const href = _chunkZ3O36LBJcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
22546
22617
|
if (id && href) idToHref.set(id, href);
|
|
22547
22618
|
}
|
|
22548
22619
|
const ordered = [];
|
|
@@ -22551,7 +22622,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22551
22622
|
if (href) ordered.push(href);
|
|
22552
22623
|
}
|
|
22553
22624
|
if (ordered.length > 0) return ordered;
|
|
22554
|
-
return Array.from(idToHref.values()).sort(
|
|
22625
|
+
return Array.from(idToHref.values()).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
|
|
22555
22626
|
}
|
|
22556
22627
|
|
|
22557
22628
|
// src/roundtrip/patcher.ts
|
|
@@ -22643,7 +22714,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
22643
22714
|
}
|
|
22644
22715
|
}
|
|
22645
22716
|
let verification;
|
|
22646
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22717
|
+
if (_optionalChain([options, 'optionalAccess', _216 => _216.verify]) !== false) {
|
|
22647
22718
|
try {
|
|
22648
22719
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
22649
22720
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -22661,17 +22732,17 @@ function buildOrigUnits(blocks) {
|
|
|
22661
22732
|
let chunk;
|
|
22662
22733
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
22663
22734
|
const next = blocks[i + 1];
|
|
22664
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
22665
|
-
chunk =
|
|
22735
|
+
if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
22736
|
+
chunk = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
22666
22737
|
} else {
|
|
22667
|
-
chunk =
|
|
22738
|
+
chunk = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, [block]);
|
|
22668
22739
|
}
|
|
22669
22740
|
if (chunk) {
|
|
22670
22741
|
const subUnits = splitMarkdownUnits(chunk);
|
|
22671
22742
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
22672
22743
|
for (let s = 0; s < subUnits.length; s++) {
|
|
22673
22744
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
22674
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
22745
|
+
if (block.type === "table" && _optionalChain([block, 'access', _218 => _218.table, 'optionalAccess', _219 => _219.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
22675
22746
|
u.role = "caption";
|
|
22676
22747
|
}
|
|
22677
22748
|
units.push(u);
|
|
@@ -22782,7 +22853,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
22782
22853
|
const ti = ctx.tableInsert;
|
|
22783
22854
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
22784
22855
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22785
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22856
|
+
if (!_optionalChain([mapping, 'optionalAccess', _220 => _220.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
|
|
22786
22857
|
const para = mapping.para;
|
|
22787
22858
|
if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
|
|
22788
22859
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -22810,7 +22881,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
22810
22881
|
}
|
|
22811
22882
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
22812
22883
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22813
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22884
|
+
if (!_optionalChain([mapping, 'optionalAccess', _221 => _221.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)");
|
|
22814
22885
|
if (block.text && block.text.includes("\n")) {
|
|
22815
22886
|
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)");
|
|
22816
22887
|
}
|
|
@@ -22841,7 +22912,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
22841
22912
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
22842
22913
|
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");
|
|
22843
22914
|
}
|
|
22844
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
22915
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _222 => _222.scans, 'access', _223 => _223[mapping.para.sectionIndex], 'optionalAccess', _224 => _224.xml]));
|
|
22845
22916
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22846
22917
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
22847
22918
|
return 1;
|
|
@@ -23027,7 +23098,7 @@ var Surgeon = (_class4 = class {
|
|
|
23027
23098
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
23028
23099
|
findEntry(path) {
|
|
23029
23100
|
const parts = path.replace(/^\//, "").split("/");
|
|
23030
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
23101
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _225 => _225.entries, 'access', _226 => _226[0], 'optionalAccess', _227 => _227.child]), () => ( -1));
|
|
23031
23102
|
let current;
|
|
23032
23103
|
for (const part of parts) {
|
|
23033
23104
|
const search = (idx) => {
|
|
@@ -23240,8 +23311,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
23240
23311
|
parts.push(header, data);
|
|
23241
23312
|
};
|
|
23242
23313
|
for (let i = 0; i < recs.length; i++) {
|
|
23243
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
23244
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
23314
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _228 => _228.get, 'call', _229 => _229(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
23315
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _230 => _230.get, 'call', _231 => _231(i)]), () => ( recs[i].data)));
|
|
23245
23316
|
}
|
|
23246
23317
|
return Buffer.concat(parts);
|
|
23247
23318
|
}
|
|
@@ -23359,7 +23430,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23359
23430
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
23360
23431
|
}
|
|
23361
23432
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
23362
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
23433
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _232 => _232.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
23363
23434
|
let flags;
|
|
23364
23435
|
try {
|
|
23365
23436
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -23381,7 +23452,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23381
23452
|
const scans = [];
|
|
23382
23453
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
23383
23454
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
23384
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
23455
|
+
if (!_optionalChain([entry, 'optionalAccess', _233 => _233.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
23385
23456
|
let stream;
|
|
23386
23457
|
try {
|
|
23387
23458
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -23432,7 +23503,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23432
23503
|
}
|
|
23433
23504
|
}
|
|
23434
23505
|
let verification;
|
|
23435
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23506
|
+
if (_optionalChain([options, 'optionalAccess', _234 => _234.verify]) !== false) {
|
|
23436
23507
|
try {
|
|
23437
23508
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
23438
23509
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -23521,7 +23592,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
23521
23592
|
for (const [key, scanCell] of scanTable.cells) {
|
|
23522
23593
|
const comma = key.indexOf(",");
|
|
23523
23594
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
23524
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
23595
|
+
const irCell = _optionalChain([irTable, 'access', _235 => _235.cells, 'access', _236 => _236[r], 'optionalAccess', _237 => _237[c]]);
|
|
23525
23596
|
if (!irCell) continue;
|
|
23526
23597
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
23527
23598
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -23557,7 +23628,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
23557
23628
|
}
|
|
23558
23629
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
23559
23630
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
23560
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
23631
|
+
if (!_optionalChain([mapping, 'optionalAccess', _238 => _238.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)");
|
|
23561
23632
|
if (block.text && block.text.includes("\n")) {
|
|
23562
23633
|
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)");
|
|
23563
23634
|
}
|
|
@@ -23733,7 +23804,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
23733
23804
|
};
|
|
23734
23805
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
23735
23806
|
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)");
|
|
23736
|
-
const irCell = _optionalChain([table, 'access',
|
|
23807
|
+
const irCell = _optionalChain([table, 'access', _239 => _239.cells, 'access', _240 => _240[gridR], 'optionalAccess', _241 => _241[gridC]]);
|
|
23737
23808
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
23738
23809
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23739
23810
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -24008,7 +24079,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24008
24079
|
const block = st.blocks[blockIndex];
|
|
24009
24080
|
if (!block) return void 0;
|
|
24010
24081
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
24011
|
-
const para = _optionalChain([st, 'access',
|
|
24082
|
+
const para = _optionalChain([st, 'access', _242 => _242.paraMap, 'access', _243 => _243.get, 'call', _244 => _244(blockIndex), 'optionalAccess', _245 => _245.para]);
|
|
24012
24083
|
if (!para) return void 0;
|
|
24013
24084
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
24014
24085
|
}
|
|
@@ -24033,7 +24104,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24033
24104
|
if (block.text && block.text.includes("\n")) {
|
|
24034
24105
|
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)" };
|
|
24035
24106
|
}
|
|
24036
|
-
if (!_optionalChain([st, 'access',
|
|
24107
|
+
if (!_optionalChain([st, 'access', _246 => _246.paraMap, 'access', _247 => _247.get, 'call', _248 => _248(blockIndex), 'optionalAccess', _249 => _249.para])) {
|
|
24037
24108
|
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)" };
|
|
24038
24109
|
}
|
|
24039
24110
|
return { capability: "text" };
|
|
@@ -24099,7 +24170,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24099
24170
|
continue;
|
|
24100
24171
|
}
|
|
24101
24172
|
if (block.type === "table" && block.table) {
|
|
24102
|
-
if (!_optionalChain([edit, 'access',
|
|
24173
|
+
if (!_optionalChain([edit, 'access', _250 => _250.cells, 'optionalAccess', _251 => _251.length])) {
|
|
24103
24174
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
24104
24175
|
continue;
|
|
24105
24176
|
}
|
|
@@ -24119,7 +24190,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24119
24190
|
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) });
|
|
24120
24191
|
continue;
|
|
24121
24192
|
}
|
|
24122
|
-
const irCell = _optionalChain([block, 'access',
|
|
24193
|
+
const irCell = _optionalChain([block, 'access', _252 => _252.table, 'access', _253 => _253.cells, 'access', _254 => _254[cellEdit.row], 'optionalAccess', _255 => _255[cellEdit.col]]);
|
|
24123
24194
|
if (!irCell) {
|
|
24124
24195
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
24125
24196
|
continue;
|
|
@@ -24175,7 +24246,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24175
24246
|
}
|
|
24176
24247
|
if (replacements.size === 0) {
|
|
24177
24248
|
let changes2;
|
|
24178
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24249
|
+
if (_optionalChain([options, 'optionalAccess', _256 => _256.verify]) !== false) {
|
|
24179
24250
|
const units = splitMarkdownUnits(st.markdown);
|
|
24180
24251
|
changes2 = diffUnitLists(units, units);
|
|
24181
24252
|
}
|
|
@@ -24196,7 +24267,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24196
24267
|
}
|
|
24197
24268
|
this.state = newState;
|
|
24198
24269
|
let changes;
|
|
24199
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24270
|
+
if (_optionalChain([options, 'optionalAccess', _257 => _257.verify]) !== false) {
|
|
24200
24271
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
24201
24272
|
}
|
|
24202
24273
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -24216,7 +24287,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24216
24287
|
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)");
|
|
24217
24288
|
}
|
|
24218
24289
|
const mapping = st.paraMap.get(blockIndex);
|
|
24219
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24290
|
+
if (!_optionalChain([mapping, 'optionalAccess', _258 => _258.para])) {
|
|
24220
24291
|
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)");
|
|
24221
24292
|
}
|
|
24222
24293
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -24236,14 +24307,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24236
24307
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24237
24308
|
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");
|
|
24238
24309
|
}
|
|
24239
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
24310
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _259 => _259.scans, 'access', _260 => _260[mapping.para.sectionIndex], 'optionalAccess', _261 => _261.xml]));
|
|
24240
24311
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24241
24312
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24242
24313
|
return 1;
|
|
24243
24314
|
}
|
|
24244
24315
|
}, _class5);
|
|
24245
24316
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
24246
|
-
const irCell = _optionalChain([table, 'access',
|
|
24317
|
+
const irCell = _optionalChain([table, 'access', _262 => _262.cells, 'access', _263 => _263[r], 'optionalAccess', _264 => _264[c]]);
|
|
24247
24318
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
24248
24319
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
24249
24320
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -24327,11 +24398,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
24327
24398
|
breaks: false
|
|
24328
24399
|
});
|
|
24329
24400
|
function renderHtml(markdown, options) {
|
|
24330
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24331
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24401
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _265 => _265.preset]), () => ( "default"));
|
|
24402
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _266 => _266.extraCss]), () => ( "")));
|
|
24332
24403
|
const body = md.render(markdown);
|
|
24333
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
24334
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
24404
|
+
const watermark = _optionalChain([options, 'optionalAccess', _267 => _267.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
24405
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _268 => _268.watermark]) ? `
|
|
24335
24406
|
.watermark {
|
|
24336
24407
|
position: fixed;
|
|
24337
24408
|
top: 50%; left: 50%;
|
|
@@ -24362,13 +24433,13 @@ async function htmlToPdf(html, options) {
|
|
|
24362
24433
|
try {
|
|
24363
24434
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
24364
24435
|
} catch (e30) {
|
|
24365
|
-
throw new (0,
|
|
24436
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
24366
24437
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
24367
24438
|
);
|
|
24368
24439
|
}
|
|
24369
24440
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
24370
24441
|
if (!executablePath) {
|
|
24371
|
-
throw new (0,
|
|
24442
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
24372
24443
|
"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."
|
|
24373
24444
|
);
|
|
24374
24445
|
}
|
|
@@ -24380,10 +24451,10 @@ async function htmlToPdf(html, options) {
|
|
|
24380
24451
|
try {
|
|
24381
24452
|
const page = await browser.newPage();
|
|
24382
24453
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
24383
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
24454
|
+
const margin = _optionalChain([options, 'optionalAccess', _269 => _269.margin]);
|
|
24384
24455
|
const pdf = await page.pdf({
|
|
24385
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24386
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
24456
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _270 => _270.pageSize]), () => ( "A4")),
|
|
24457
|
+
landscape: _optionalChain([options, 'optionalAccess', _271 => _271.orientation]) === "landscape",
|
|
24387
24458
|
printBackground: true,
|
|
24388
24459
|
margin: margin ? {
|
|
24389
24460
|
top: toCss(margin.top),
|
|
@@ -24391,9 +24462,9 @@ async function htmlToPdf(html, options) {
|
|
|
24391
24462
|
bottom: toCss(margin.bottom),
|
|
24392
24463
|
left: toCss(margin.left)
|
|
24393
24464
|
} : void 0,
|
|
24394
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
24395
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24396
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24465
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _272 => _272.header]) || _optionalChain([options, 'optionalAccess', _273 => _273.footer])),
|
|
24466
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _274 => _274.header]), () => ( "<div></div>")),
|
|
24467
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _275 => _275.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
24397
24468
|
});
|
|
24398
24469
|
return Buffer.from(pdf);
|
|
24399
24470
|
} finally {
|
|
@@ -24427,24 +24498,24 @@ async function markdownToPdf(markdown, options) {
|
|
|
24427
24498
|
return htmlToPdf(html, options);
|
|
24428
24499
|
}
|
|
24429
24500
|
async function blocksToPdf(blocks, options) {
|
|
24430
|
-
const markdown =
|
|
24501
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
24431
24502
|
return markdownToPdf(markdown, options);
|
|
24432
24503
|
}
|
|
24433
24504
|
|
|
24434
24505
|
// src/index.ts
|
|
24435
24506
|
async function parse(input, options) {
|
|
24436
24507
|
let buffer;
|
|
24437
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
24508
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _276 => _276.filePath]) ? { ...options, filePath: input } : options;
|
|
24438
24509
|
if (typeof input === "string") {
|
|
24439
24510
|
try {
|
|
24440
24511
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24441
|
-
buffer =
|
|
24512
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, buf);
|
|
24442
24513
|
} catch (err) {
|
|
24443
24514
|
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}`;
|
|
24444
24515
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
24445
24516
|
}
|
|
24446
24517
|
} else if (Buffer.isBuffer(input)) {
|
|
24447
|
-
buffer =
|
|
24518
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, input);
|
|
24448
24519
|
} else {
|
|
24449
24520
|
buffer = input;
|
|
24450
24521
|
}
|
|
@@ -24479,21 +24550,21 @@ async function parseHwp3(buffer, options) {
|
|
|
24479
24550
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
24480
24551
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
24481
24552
|
} catch (err) {
|
|
24482
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24553
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24483
24554
|
}
|
|
24484
24555
|
}
|
|
24485
24556
|
async function parseHwpx(buffer, options) {
|
|
24486
24557
|
try {
|
|
24487
24558
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
24488
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
24559
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _277 => _277.length]) ? images : void 0 };
|
|
24489
24560
|
} catch (err) {
|
|
24490
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24561
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24491
24562
|
}
|
|
24492
24563
|
}
|
|
24493
24564
|
async function parseHwp(buffer, options) {
|
|
24494
24565
|
try {
|
|
24495
24566
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
24496
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
24567
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _278 => _278.filePath])) {
|
|
24497
24568
|
try {
|
|
24498
24569
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
24499
24570
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -24510,15 +24581,15 @@ async function parseHwp(buffer, options) {
|
|
|
24510
24581
|
} catch (e31) {
|
|
24511
24582
|
}
|
|
24512
24583
|
}
|
|
24513
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
24584
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _279 => _279.length]) ? images : void 0 };
|
|
24514
24585
|
} catch (err) {
|
|
24515
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24586
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24516
24587
|
}
|
|
24517
24588
|
}
|
|
24518
24589
|
async function parsePdf(buffer, options) {
|
|
24519
24590
|
let parsePdfDocument;
|
|
24520
24591
|
try {
|
|
24521
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
24592
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ZVKCFXR3.cjs")));
|
|
24522
24593
|
parsePdfDocument = mod.parsePdfDocument;
|
|
24523
24594
|
} catch (e32) {
|
|
24524
24595
|
return {
|
|
@@ -24533,7 +24604,7 @@ async function parsePdf(buffer, options) {
|
|
|
24533
24604
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
24534
24605
|
} catch (err) {
|
|
24535
24606
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
24536
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24607
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err), isImageBased };
|
|
24537
24608
|
}
|
|
24538
24609
|
}
|
|
24539
24610
|
async function parseXlsx(buffer, options) {
|
|
@@ -24541,7 +24612,7 @@ async function parseXlsx(buffer, options) {
|
|
|
24541
24612
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
24542
24613
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
24543
24614
|
} catch (err) {
|
|
24544
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24615
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24545
24616
|
}
|
|
24546
24617
|
}
|
|
24547
24618
|
async function parseXls(buffer, options) {
|
|
@@ -24549,15 +24620,15 @@ async function parseXls(buffer, options) {
|
|
|
24549
24620
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
24550
24621
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
24551
24622
|
} catch (err) {
|
|
24552
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24623
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24553
24624
|
}
|
|
24554
24625
|
}
|
|
24555
24626
|
async function parseDocx(buffer, options) {
|
|
24556
24627
|
try {
|
|
24557
24628
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
24558
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
24629
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _280 => _280.length]) ? images : void 0 };
|
|
24559
24630
|
} catch (err) {
|
|
24560
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24631
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24561
24632
|
}
|
|
24562
24633
|
}
|
|
24563
24634
|
async function parseHwpml(buffer, options) {
|
|
@@ -24565,16 +24636,16 @@ async function parseHwpml(buffer, options) {
|
|
|
24565
24636
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
24566
24637
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
24567
24638
|
} catch (err) {
|
|
24568
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24639
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
|
|
24569
24640
|
}
|
|
24570
24641
|
}
|
|
24571
24642
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
24572
24643
|
let buffer;
|
|
24573
24644
|
if (typeof input === "string") {
|
|
24574
24645
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24575
|
-
buffer =
|
|
24646
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, buf);
|
|
24576
24647
|
} else if (Buffer.isBuffer(input)) {
|
|
24577
|
-
buffer =
|
|
24648
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, input);
|
|
24578
24649
|
} else {
|
|
24579
24650
|
buffer = input;
|
|
24580
24651
|
}
|
|
@@ -24600,7 +24671,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24600
24671
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
24601
24672
|
}
|
|
24602
24673
|
const fill = fillFormFields(parsed.blocks, values);
|
|
24603
|
-
const markdown =
|
|
24674
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
24604
24675
|
if (outputFormat === "hwpx") {
|
|
24605
24676
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
24606
24677
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -24658,5 +24729,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24658
24729
|
|
|
24659
24730
|
|
|
24660
24731
|
|
|
24661
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
24732
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkZ3O36LBJcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkZ3O36LBJcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fitRatioForFewerLines = fitRatioForFewerLines; 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.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord;
|
|
24662
24733
|
//# sourceMappingURL=index.cjs.map
|