kordoc 3.8.3 → 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 +7 -0
- package/dist/{-F5IXBLQQ.js → -ZAIG6FWT.js} +3 -3
- package/dist/{chunk-KIWKBRCJ.js → chunk-2UDAEQPW.js} +3 -3
- package/dist/chunk-2UDAEQPW.js.map +1 -0
- package/dist/{chunk-B27QMVL7.js → chunk-6EDNKPXQ.js} +112 -76
- package/dist/chunk-6EDNKPXQ.js.map +1 -0
- package/dist/{chunk-7J73IGMK.js → chunk-T4SGNVVS.js} +3 -3
- package/dist/chunk-T4SGNVVS.js.map +1 -0
- package/dist/{chunk-XL6O3VAY.cjs → chunk-Z3O36LBJ.cjs} +3 -3
- package/dist/{chunk-XL6O3VAY.cjs.map → chunk-Z3O36LBJ.cjs.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +366 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +111 -75
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-TM3AS25T.js → parser-2THIF623.js} +2 -2
- package/dist/{parser-6GP535ZB.js → parser-PR7CPMM4.js} +2 -2
- package/dist/{parser-WWKYMRGJ.cjs → parser-ZVKCFXR3.cjs} +14 -14
- package/dist/{parser-WWKYMRGJ.cjs.map → parser-ZVKCFXR3.cjs.map} +1 -1
- package/dist/{watch-HETTZ7BO.js → watch-2HYPNMOB.js} +3 -3
- package/package.json +2 -2
- package/dist/chunk-7J73IGMK.js.map +0 -1
- package/dist/chunk-B27QMVL7.js.map +0 -1
- package/dist/chunk-KIWKBRCJ.js.map +0 -1
- /package/dist/{-F5IXBLQQ.js.map → -ZAIG6FWT.js.map} +0 -0
- /package/dist/{parser-TM3AS25T.js.map → parser-2THIF623.js.map} +0 -0
- /package/dist/{parser-6GP535ZB.js.map → parser-PR7CPMM4.js.map} +0 -0
- /package/dist/{watch-HETTZ7BO.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
|
}
|
|
@@ -16803,15 +16803,15 @@ function getElements(parent, tagName) {
|
|
|
16803
16803
|
const result = [];
|
|
16804
16804
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
16805
16805
|
if (result.length > 0) return result;
|
|
16806
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
16806
|
+
const nsNodes = _optionalChain([parent, 'access', _79 => _79.getElementsByTagNameNS, 'optionalCall', _80 => _80("*", tagName)]);
|
|
16807
16807
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
16808
16808
|
return result;
|
|
16809
16809
|
}
|
|
16810
16810
|
function getTextContent(el) {
|
|
16811
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
16811
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
|
|
16812
16812
|
}
|
|
16813
16813
|
function parseXml(text) {
|
|
16814
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16814
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16815
16815
|
}
|
|
16816
16816
|
function parseSharedStrings(xml) {
|
|
16817
16817
|
const doc = parseXml(xml);
|
|
@@ -16948,14 +16948,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16948
16948
|
const merge = mergeMap.get(key);
|
|
16949
16949
|
row.push({
|
|
16950
16950
|
text,
|
|
16951
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16952
|
-
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))
|
|
16953
16953
|
});
|
|
16954
16954
|
}
|
|
16955
16955
|
cellRows.push(row);
|
|
16956
16956
|
}
|
|
16957
16957
|
if (cellRows.length > 0) {
|
|
16958
|
-
const table =
|
|
16958
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
16959
16959
|
if (table.rows > 0) {
|
|
16960
16960
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16961
16961
|
}
|
|
@@ -16963,12 +16963,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16963
16963
|
return blocks;
|
|
16964
16964
|
}
|
|
16965
16965
|
async function parseXlsxDocument(buffer, options) {
|
|
16966
|
-
|
|
16966
|
+
_chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16967
16967
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16968
16968
|
const warnings = [];
|
|
16969
16969
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16970
16970
|
if (!workbookFile) {
|
|
16971
|
-
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");
|
|
16972
16972
|
}
|
|
16973
16973
|
let sharedStrings = [];
|
|
16974
16974
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16977,7 +16977,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16977
16977
|
}
|
|
16978
16978
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16979
16979
|
if (sheets.length === 0) {
|
|
16980
|
-
throw new (0,
|
|
16980
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16981
16981
|
}
|
|
16982
16982
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16983
16983
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16985,7 +16985,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16985
16985
|
relsMap = parseRels(await relsFile.async("text"));
|
|
16986
16986
|
}
|
|
16987
16987
|
let pageFilter = null;
|
|
16988
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16988
|
+
if (_optionalChain([options, 'optionalAccess', _86 => _86.pages])) {
|
|
16989
16989
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
16990
16990
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
16991
16991
|
}
|
|
@@ -16994,7 +16994,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16994
16994
|
for (let i = 0; i < processedSheets; i++) {
|
|
16995
16995
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
16996
16996
|
const sheet = sheets[i];
|
|
16997
|
-
_optionalChain([options, 'optionalAccess',
|
|
16997
|
+
_optionalChain([options, 'optionalAccess', _87 => _87.onProgress, 'optionalCall', _88 => _88(i + 1, processedSheets)]);
|
|
16998
16998
|
let sheetPath = relsMap.get(sheet.rId);
|
|
16999
16999
|
if (sheetPath) {
|
|
17000
17000
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17049,7 +17049,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17049
17049
|
} catch (e27) {
|
|
17050
17050
|
}
|
|
17051
17051
|
}
|
|
17052
|
-
const markdown =
|
|
17052
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17053
17053
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17054
17054
|
}
|
|
17055
17055
|
|
|
@@ -17456,11 +17456,11 @@ function processGlobals(records) {
|
|
|
17456
17456
|
let encrypted = false;
|
|
17457
17457
|
const firstBof = records[0];
|
|
17458
17458
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17459
|
-
throw new (0,
|
|
17459
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17460
17460
|
}
|
|
17461
17461
|
const bof = decodeBof(firstBof.data);
|
|
17462
17462
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17463
|
-
throw new (0,
|
|
17463
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17464
17464
|
}
|
|
17465
17465
|
let i = 1;
|
|
17466
17466
|
while (i < records.length) {
|
|
@@ -17568,14 +17568,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17568
17568
|
const merge = mergeMap.get(key);
|
|
17569
17569
|
row.push({
|
|
17570
17570
|
text: grid[r][c],
|
|
17571
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17572
|
-
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))
|
|
17573
17573
|
});
|
|
17574
17574
|
}
|
|
17575
17575
|
cellRows.push(row);
|
|
17576
17576
|
}
|
|
17577
17577
|
if (cellRows.length > 0) {
|
|
17578
|
-
const table =
|
|
17578
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
17579
17579
|
if (table.rows > 0) {
|
|
17580
17580
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17581
17581
|
}
|
|
@@ -17588,21 +17588,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17588
17588
|
try {
|
|
17589
17589
|
cfb = parseLenientCfb(buf);
|
|
17590
17590
|
} catch (e) {
|
|
17591
|
-
throw new (0,
|
|
17591
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
17592
17592
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17593
17593
|
);
|
|
17594
17594
|
}
|
|
17595
17595
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17596
17596
|
if (!wb) {
|
|
17597
|
-
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)");
|
|
17598
17598
|
}
|
|
17599
17599
|
const records = readRecords2(wb);
|
|
17600
17600
|
if (records.length === 0) {
|
|
17601
|
-
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)");
|
|
17602
17602
|
}
|
|
17603
17603
|
const firstBof = decodeBof(records[0].data);
|
|
17604
17604
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17605
|
-
throw new (0,
|
|
17605
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
17606
17606
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17607
17607
|
);
|
|
17608
17608
|
}
|
|
@@ -17623,7 +17623,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17623
17623
|
}
|
|
17624
17624
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17625
17625
|
let pageFilter = null;
|
|
17626
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17626
|
+
if (_optionalChain([options, 'optionalAccess', _91 => _91.pages])) {
|
|
17627
17627
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17628
17628
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17629
17629
|
}
|
|
@@ -17632,7 +17632,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17632
17632
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17633
17633
|
const meta = globals.sheets[i];
|
|
17634
17634
|
if (meta.dt !== 0) continue;
|
|
17635
|
-
_optionalChain([options, 'optionalAccess',
|
|
17635
|
+
_optionalChain([options, 'optionalAccess', _92 => _92.onProgress, 'optionalCall', _93 => _93(i + 1, totalSheets)]);
|
|
17636
17636
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
17637
17637
|
if (bofIdx < 0) {
|
|
17638
17638
|
warnings.push({
|
|
@@ -17662,7 +17662,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17662
17662
|
pageCount: totalSheets
|
|
17663
17663
|
};
|
|
17664
17664
|
return {
|
|
17665
|
-
markdown:
|
|
17665
|
+
markdown: _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17666
17666
|
blocks: allBlocks,
|
|
17667
17667
|
metadata,
|
|
17668
17668
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17675,7 +17675,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17675
17675
|
|
|
17676
17676
|
// src/docx/equation.ts
|
|
17677
17677
|
function lname(el) {
|
|
17678
|
-
return el.localName || _optionalChain([el, 'access',
|
|
17678
|
+
return el.localName || _optionalChain([el, 'access', _94 => _94.tagName, 'optionalAccess', _95 => _95.replace, 'call', _96 => _96(/^[^:]+:/, "")]) || "";
|
|
17679
17679
|
}
|
|
17680
17680
|
function kids(parent, name) {
|
|
17681
17681
|
const out = [];
|
|
@@ -18048,7 +18048,7 @@ function isDisplayMath(el) {
|
|
|
18048
18048
|
// src/docx/parser.ts
|
|
18049
18049
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
18050
18050
|
function matchesLocal(el, localName2) {
|
|
18051
|
-
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)));
|
|
18052
18052
|
}
|
|
18053
18053
|
function effectiveChildElements(parent) {
|
|
18054
18054
|
const result = [];
|
|
@@ -18081,7 +18081,7 @@ function findElements(parent, localName2) {
|
|
|
18081
18081
|
const child = children[i];
|
|
18082
18082
|
if (child.nodeType === 1) {
|
|
18083
18083
|
const el = child;
|
|
18084
|
-
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}`)])) {
|
|
18085
18085
|
result.push(el);
|
|
18086
18086
|
}
|
|
18087
18087
|
walk(el);
|
|
@@ -18100,7 +18100,7 @@ function getAttr(el, localName2) {
|
|
|
18100
18100
|
return null;
|
|
18101
18101
|
}
|
|
18102
18102
|
function parseXml2(text) {
|
|
18103
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18103
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18104
18104
|
}
|
|
18105
18105
|
function parseStyles(xml) {
|
|
18106
18106
|
const doc = parseXml2(xml);
|
|
@@ -18202,7 +18202,7 @@ function collectOmmlRoots(p) {
|
|
|
18202
18202
|
const child = children[i];
|
|
18203
18203
|
if (child.nodeType !== 1) continue;
|
|
18204
18204
|
const el = child;
|
|
18205
|
-
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(/^[^:]+:/, "")]) || "";
|
|
18206
18206
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
18207
18207
|
out.push(el);
|
|
18208
18208
|
} else {
|
|
@@ -18291,7 +18291,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18291
18291
|
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18292
18292
|
if (!text) return null;
|
|
18293
18293
|
const style = styles.get(styleId);
|
|
18294
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
18294
|
+
if (_optionalChain([style, 'optionalAccess', _106 => _106.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
18295
18295
|
return {
|
|
18296
18296
|
type: "heading",
|
|
18297
18297
|
text,
|
|
@@ -18300,8 +18300,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18300
18300
|
}
|
|
18301
18301
|
if (numId && numId !== "0") {
|
|
18302
18302
|
const numDef = numbering.get(numId);
|
|
18303
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
18304
|
-
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";
|
|
18305
18305
|
return { type: "list", text, listType };
|
|
18306
18306
|
}
|
|
18307
18307
|
const block = { type: "paragraph", text };
|
|
@@ -18312,74 +18312,79 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18312
18312
|
if (footnoteText) block.footnoteText = footnoteText;
|
|
18313
18313
|
return block;
|
|
18314
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
|
+
}
|
|
18315
18325
|
function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
18316
18326
|
const trElements = getChildElements(tbl, "tr");
|
|
18317
18327
|
if (trElements.length === 0) return null;
|
|
18318
|
-
const
|
|
18319
|
-
let maxCols = 0;
|
|
18328
|
+
const rawRows = [];
|
|
18320
18329
|
for (const tr of trElements) {
|
|
18321
|
-
const tcElements = getChildElements(tr, "tc");
|
|
18322
18330
|
const row = [];
|
|
18323
|
-
|
|
18331
|
+
let col = 0;
|
|
18332
|
+
for (const tc of getChildElements(tr, "tc")) {
|
|
18324
18333
|
let colSpan = 1;
|
|
18325
|
-
let
|
|
18334
|
+
let vMerge = null;
|
|
18326
18335
|
const tcPrEls = getChildElements(tc, "tcPr");
|
|
18327
18336
|
if (tcPrEls.length > 0) {
|
|
18328
18337
|
const gridSpanEls = getChildElements(tcPrEls[0], "gridSpan");
|
|
18329
18338
|
if (gridSpanEls.length > 0) {
|
|
18330
|
-
colSpan = parseInt(_nullishCoalesce(getAttr(gridSpanEls[0], "val"), () => ( "1")), 10);
|
|
18339
|
+
colSpan = parseInt(_nullishCoalesce(getAttr(gridSpanEls[0], "val"), () => ( "1")), 10) || 1;
|
|
18331
18340
|
}
|
|
18332
18341
|
const vMergeEls = getChildElements(tcPrEls[0], "vMerge");
|
|
18333
18342
|
if (vMergeEls.length > 0) {
|
|
18334
|
-
|
|
18335
|
-
if (val !== "restart" && val !== null) {
|
|
18336
|
-
row.push({ text: "", colSpan, rowSpan: 0 });
|
|
18337
|
-
continue;
|
|
18338
|
-
}
|
|
18343
|
+
vMerge = getAttr(vMergeEls[0], "val") === "restart" ? "restart" : "continue";
|
|
18339
18344
|
}
|
|
18340
18345
|
}
|
|
18341
|
-
const
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
|
|
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
|
+
}
|
|
18346
18360
|
}
|
|
18347
|
-
|
|
18348
|
-
}
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
|
|
18353
|
-
|
|
18354
|
-
|
|
18355
|
-
|
|
18356
|
-
|
|
18357
|
-
|
|
18358
|
-
|
|
18359
|
-
|
|
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
|
+
}
|
|
18360
18384
|
}
|
|
18361
|
-
cell.rowSpan = span;
|
|
18362
18385
|
}
|
|
18363
18386
|
}
|
|
18364
|
-
|
|
18365
|
-
for (const row of rows) {
|
|
18366
|
-
const clean = row.filter((cell) => cell.rowSpan !== 0);
|
|
18367
|
-
cleanRows.push(clean);
|
|
18368
|
-
}
|
|
18369
|
-
if (cleanRows.length === 0) return null;
|
|
18370
|
-
let cols = 0;
|
|
18371
|
-
for (const row of cleanRows) {
|
|
18372
|
-
let c = 0;
|
|
18373
|
-
for (const cell of row) c += cell.colSpan;
|
|
18374
|
-
if (c > cols) cols = c;
|
|
18375
|
-
}
|
|
18376
|
-
const table = {
|
|
18377
|
-
rows: cleanRows.length,
|
|
18378
|
-
cols,
|
|
18379
|
-
cells: cleanRows,
|
|
18380
|
-
hasHeader: cleanRows.length > 1
|
|
18381
|
-
};
|
|
18382
|
-
return { type: "table", table };
|
|
18387
|
+
return parts;
|
|
18383
18388
|
}
|
|
18384
18389
|
async function extractImages(zip, rels, doc, warnings) {
|
|
18385
18390
|
const blocks = [];
|
|
@@ -18399,7 +18404,7 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18399
18404
|
try {
|
|
18400
18405
|
const data = await imgFile.async("uint8array");
|
|
18401
18406
|
imgIdx++;
|
|
18402
|
-
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"));
|
|
18403
18408
|
const mimeMap = {
|
|
18404
18409
|
png: "image/png",
|
|
18405
18410
|
jpg: "image/jpeg",
|
|
@@ -18423,12 +18428,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18423
18428
|
return { blocks, images };
|
|
18424
18429
|
}
|
|
18425
18430
|
async function parseDocxDocument(buffer, options) {
|
|
18426
|
-
|
|
18431
|
+
_chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18427
18432
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18428
18433
|
const warnings = [];
|
|
18429
18434
|
const docFile = zip.file("word/document.xml");
|
|
18430
18435
|
if (!docFile) {
|
|
18431
|
-
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");
|
|
18432
18437
|
}
|
|
18433
18438
|
let rels = /* @__PURE__ */ new Map();
|
|
18434
18439
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18475,16 +18480,20 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18475
18480
|
const doc = parseXml2(docXml);
|
|
18476
18481
|
const body = findElements(doc, "body");
|
|
18477
18482
|
if (body.length === 0) {
|
|
18478
|
-
throw new (0,
|
|
18483
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18479
18484
|
}
|
|
18480
18485
|
const blocks = [];
|
|
18481
18486
|
const bodyEl = body[0];
|
|
18482
18487
|
const topLevel = effectiveChildElements(bodyEl);
|
|
18483
18488
|
for (const el of topLevel) {
|
|
18484
|
-
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()])));
|
|
18485
18490
|
if (localName2 === "p") {
|
|
18486
18491
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18487
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
|
+
}
|
|
18488
18497
|
} else if (localName2 === "tbl") {
|
|
18489
18498
|
const block = parseTable(el, styles, numbering, footnotes, rels);
|
|
18490
18499
|
if (block) blocks.push(block);
|
|
@@ -18516,7 +18525,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18516
18525
|
}
|
|
18517
18526
|
}
|
|
18518
18527
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18519
|
-
const markdown =
|
|
18528
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18520
18529
|
return {
|
|
18521
18530
|
markdown,
|
|
18522
18531
|
blocks,
|
|
@@ -18539,7 +18548,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18539
18548
|
}
|
|
18540
18549
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18541
18550
|
const normalized = text.replace(/ /g, " ");
|
|
18542
|
-
const xml =
|
|
18551
|
+
const xml = _chunkZ3O36LBJcjs.stripDtd.call(void 0, normalized);
|
|
18543
18552
|
const warnings = [];
|
|
18544
18553
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18545
18554
|
onError: (_level, msg2) => {
|
|
@@ -18567,7 +18576,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18567
18576
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18568
18577
|
}
|
|
18569
18578
|
const blocks = [];
|
|
18570
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
18579
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18571
18580
|
let sectionIdx = 0;
|
|
18572
18581
|
const children = body.childNodes;
|
|
18573
18582
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18579,7 +18588,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18579
18588
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18580
18589
|
}
|
|
18581
18590
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18582
|
-
const markdown =
|
|
18591
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18583
18592
|
return {
|
|
18584
18593
|
markdown,
|
|
18585
18594
|
blocks,
|
|
@@ -18665,7 +18674,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
18665
18674
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
18666
18675
|
const text = extractParagraphText(el);
|
|
18667
18676
|
if (!text) return;
|
|
18668
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
18677
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _124 => _124.headingLevel]) != null) {
|
|
18669
18678
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
18670
18679
|
} else {
|
|
18671
18680
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -18737,15 +18746,15 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18737
18746
|
const cellRows = grid.map(
|
|
18738
18747
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18739
18748
|
);
|
|
18740
|
-
const table =
|
|
18749
|
+
const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
|
|
18741
18750
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18742
18751
|
}
|
|
18743
18752
|
function extractCellText(cellEl) {
|
|
18744
18753
|
const textParts = [];
|
|
18745
|
-
|
|
18754
|
+
collectCellText2(cellEl, textParts, 0);
|
|
18746
18755
|
return textParts.filter(Boolean).join("\n").trim();
|
|
18747
18756
|
}
|
|
18748
|
-
function
|
|
18757
|
+
function collectCellText2(node, parts, depth) {
|
|
18749
18758
|
if (depth > 20) return;
|
|
18750
18759
|
const children = node.childNodes;
|
|
18751
18760
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18757,9 +18766,9 @@ function collectCellText(node, parts, depth) {
|
|
|
18757
18766
|
if (t) parts.push(t);
|
|
18758
18767
|
collectNestedTableText(el, parts, depth + 1);
|
|
18759
18768
|
} else if (tag === "TABLE") {
|
|
18760
|
-
|
|
18769
|
+
collectCellText2(el, parts, depth + 1);
|
|
18761
18770
|
} else {
|
|
18762
|
-
|
|
18771
|
+
collectCellText2(el, parts, depth + 1);
|
|
18763
18772
|
}
|
|
18764
18773
|
}
|
|
18765
18774
|
}
|
|
@@ -18771,7 +18780,7 @@ function collectNestedTableText(node, parts, depth) {
|
|
|
18771
18780
|
if (el.nodeType !== 1) continue;
|
|
18772
18781
|
const tag = localName(el);
|
|
18773
18782
|
if (tag === "TABLE") {
|
|
18774
|
-
|
|
18783
|
+
collectCellText2(el, parts, depth + 1);
|
|
18775
18784
|
continue;
|
|
18776
18785
|
}
|
|
18777
18786
|
if (tag === "FOOTNOTE" || tag === "ENDNOTE" || tag === "HEADER" || tag === "FOOTER") continue;
|
|
@@ -19114,8 +19123,8 @@ function extractFromTable(table) {
|
|
|
19114
19123
|
if (table.cols >= 2) {
|
|
19115
19124
|
for (let r = 0; r < table.rows; r++) {
|
|
19116
19125
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
19117
|
-
const labelCell = _optionalChain([table, 'access',
|
|
19118
|
-
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]]);
|
|
19119
19128
|
if (!labelCell || !valueCell) continue;
|
|
19120
19129
|
if (isLabelCell(labelCell.text)) {
|
|
19121
19130
|
fields.push({
|
|
@@ -19137,8 +19146,8 @@ function extractFromTable(table) {
|
|
|
19137
19146
|
if (allLabels) {
|
|
19138
19147
|
for (let r = 1; r < table.rows; r++) {
|
|
19139
19148
|
for (let c = 0; c < table.cols; c++) {
|
|
19140
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19141
|
-
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()]), () => ( ""));
|
|
19142
19151
|
if (label && value) {
|
|
19143
19152
|
fields.push({ label, value, row: r, col: c });
|
|
19144
19153
|
}
|
|
@@ -19231,7 +19240,7 @@ function fillFormFields(blocks, values) {
|
|
|
19231
19240
|
for (const table of allTables) {
|
|
19232
19241
|
for (let r = 0; r < table.rows; r++) {
|
|
19233
19242
|
for (let c = 0; c < table.cols; c++) {
|
|
19234
|
-
const cell = _optionalChain([table, 'access',
|
|
19243
|
+
const cell = _optionalChain([table, 'access', _141 => _141.cells, 'access', _142 => _142[r], 'optionalAccess', _143 => _143[c]]);
|
|
19235
19244
|
if (!cell) continue;
|
|
19236
19245
|
const result = fillInCellPatterns(cell.text, cursor, matchedLabels);
|
|
19237
19246
|
if (result) {
|
|
@@ -19263,7 +19272,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19263
19272
|
out.push(block.table);
|
|
19264
19273
|
for (const row of block.table.cells) {
|
|
19265
19274
|
for (const cell of row) {
|
|
19266
|
-
if (_optionalChain([cell, 'optionalAccess',
|
|
19275
|
+
if (_optionalChain([cell, 'optionalAccess', _144 => _144.blocks, 'optionalAccess', _145 => _145.length])) out.push(...collectIRTables(cell.blocks, depth + 1));
|
|
19267
19276
|
}
|
|
19268
19277
|
}
|
|
19269
19278
|
}
|
|
@@ -19274,7 +19283,7 @@ function coveredPositions(table) {
|
|
|
19274
19283
|
for (let r = 0; r < table.rows; r++) {
|
|
19275
19284
|
for (let c = 0; c < table.cols; c++) {
|
|
19276
19285
|
if (covered.has(`${r},${c}`)) continue;
|
|
19277
|
-
const cell = _optionalChain([table, 'access',
|
|
19286
|
+
const cell = _optionalChain([table, 'access', _146 => _146.cells, 'access', _147 => _147[r], 'optionalAccess', _148 => _148[c]]);
|
|
19278
19287
|
if (!cell) continue;
|
|
19279
19288
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
19280
19289
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -19308,7 +19317,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19308
19317
|
if (matchKey === void 0) continue;
|
|
19309
19318
|
const newValue = values.consume(matchKey);
|
|
19310
19319
|
if (newValue === void 0) continue;
|
|
19311
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19320
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _149 => _149.has, 'call', _150 => _150(valueCell)])) {
|
|
19312
19321
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19313
19322
|
} else {
|
|
19314
19323
|
valueCell.text = newValue;
|
|
@@ -19333,7 +19342,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19333
19342
|
for (let c = 0; c < table.cols; c++) {
|
|
19334
19343
|
if (covered.has(`${r},${c}`)) continue;
|
|
19335
19344
|
const headerCell = headerRow[c];
|
|
19336
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19345
|
+
const valueCell = _optionalChain([table, 'access', _151 => _151.cells, 'access', _152 => _152[r], 'optionalAccess', _153 => _153[c]]);
|
|
19337
19346
|
if (!headerCell || !valueCell) continue;
|
|
19338
19347
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19339
19348
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
@@ -19926,19 +19935,19 @@ function parseCentralDirectory(buf) {
|
|
|
19926
19935
|
}
|
|
19927
19936
|
}
|
|
19928
19937
|
}
|
|
19929
|
-
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");
|
|
19930
19939
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19931
19940
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19932
19941
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19933
|
-
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");
|
|
19934
19943
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19935
|
-
throw new (0,
|
|
19944
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19936
19945
|
}
|
|
19937
19946
|
const decoder = new TextDecoder("utf-8");
|
|
19938
19947
|
const entries = [];
|
|
19939
19948
|
let pos = cdOffset;
|
|
19940
19949
|
for (let i = 0; i < totalEntries; i++) {
|
|
19941
|
-
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");
|
|
19942
19951
|
const flags = view.getUint16(pos + 8, true);
|
|
19943
19952
|
const method = view.getUint16(pos + 10, true);
|
|
19944
19953
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19949,7 +19958,7 @@ function parseCentralDirectory(buf) {
|
|
|
19949
19958
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19950
19959
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19951
19960
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19952
|
-
throw new (0,
|
|
19961
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19953
19962
|
}
|
|
19954
19963
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19955
19964
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19978,7 +19987,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19978
19987
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19979
19988
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19980
19989
|
for (const name of replacements.keys()) {
|
|
19981
|
-
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}`);
|
|
19982
19991
|
}
|
|
19983
19992
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19984
19993
|
const segments = [];
|
|
@@ -19996,7 +20005,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19996
20005
|
offset += seg.length;
|
|
19997
20006
|
continue;
|
|
19998
20007
|
}
|
|
19999
|
-
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");
|
|
20000
20009
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20001
20010
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20002
20011
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20051,7 +20060,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20051
20060
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20052
20061
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20053
20062
|
if (sectionPaths.length === 0) {
|
|
20054
|
-
throw new (0,
|
|
20063
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20055
20064
|
}
|
|
20056
20065
|
const normalizedValues = normalizeValues(values);
|
|
20057
20066
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20210,7 +20219,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20210
20219
|
}
|
|
20211
20220
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20212
20221
|
const existing = ledger.get(para);
|
|
20213
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20222
|
+
if (_optionalChain([existing, 'optionalAccess', _154 => _154.fullText]) !== void 0) continue;
|
|
20214
20223
|
const text = matchText(para);
|
|
20215
20224
|
for (const seg of scanInlineSegments(text)) {
|
|
20216
20225
|
const matchKey = findMatchingKey(normalizeLabel(seg.label), cursor);
|
|
@@ -20449,8 +20458,8 @@ function charWidthEm1000(cp) {
|
|
|
20449
20458
|
var SPACE_EM_FIXED = 500;
|
|
20450
20459
|
var SPACE_EM_FONT = 300;
|
|
20451
20460
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20452
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20453
|
-
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));
|
|
20454
20463
|
let em = 0;
|
|
20455
20464
|
for (const ch of text) {
|
|
20456
20465
|
const cp = ch.codePointAt(0);
|
|
@@ -20463,8 +20472,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20463
20472
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20464
20473
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20465
20474
|
const EPS = 0.5;
|
|
20466
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20467
|
-
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));
|
|
20468
20477
|
const k = height * ratioPct / 100 / 1e3;
|
|
20469
20478
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20470
20479
|
const charW = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20690,16 +20699,16 @@ var PARA_LIST = 7;
|
|
|
20690
20699
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20691
20700
|
function resolveTheme(theme) {
|
|
20692
20701
|
return {
|
|
20693
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20694
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20695
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20696
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20697
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20698
|
-
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)),
|
|
20699
20708
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20700
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20701
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20702
|
-
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])
|
|
20703
20712
|
};
|
|
20704
20713
|
}
|
|
20705
20714
|
function escapeXml(text) {
|
|
@@ -20730,12 +20739,13 @@ function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_C
|
|
|
20730
20739
|
</hh:charPr>`;
|
|
20731
20740
|
}
|
|
20732
20741
|
function paraPr(id, opts = {}) {
|
|
20733
|
-
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;
|
|
20734
20743
|
const breakNonLatin = keepWord ? "KEEP_WORD" : "BREAK_WORD";
|
|
20735
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"/>`;
|
|
20736
20746
|
return ` <hh:paraPr id="${id}" tabPrIDRef="0" condense="0" fontLineHeight="0" snapToGrid="${snapGrid}" suppressLineNumbers="0" checked="0" textDir="AUTO">
|
|
20737
20747
|
<hh:align horizontal="${align}" vertical="BASELINE"/>
|
|
20738
|
-
|
|
20748
|
+
${heading}
|
|
20739
20749
|
<hh:breakSetting breakLatinWord="KEEP_WORD" breakNonLatinWord="${breakNonLatin}" widowOrphan="0" keepWithNext="0" keepLines="0" pageBreakBefore="0" lineWrap="BREAK"/>
|
|
20740
20750
|
<hh:autoSpacing eAsianEng="0" eAsianNum="0"/>
|
|
20741
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>
|
|
@@ -20842,7 +20852,7 @@ function parseMarkdownToBlocks(md2) {
|
|
|
20842
20852
|
if (listMatch) {
|
|
20843
20853
|
const indent = Math.floor(listMatch[1].length / 2);
|
|
20844
20854
|
const ordered = /\d/.test(listMatch[2]);
|
|
20845
|
-
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] });
|
|
20846
20856
|
i++;
|
|
20847
20857
|
continue;
|
|
20848
20858
|
}
|
|
@@ -20852,6 +20862,11 @@ function parseMarkdownToBlocks(md2) {
|
|
|
20852
20862
|
return blocks;
|
|
20853
20863
|
}
|
|
20854
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
|
+
});
|
|
20855
20870
|
text = text.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
|
|
20856
20871
|
text = text.replace(/\[([^\]]*)\]\(([^)]*)\)/g, (_, t, u) => t || u);
|
|
20857
20872
|
text = text.replace(/~~([^~]+)~~/g, "$1");
|
|
@@ -20881,6 +20896,13 @@ function parseInlineMarkdown(text) {
|
|
|
20881
20896
|
if (spans.length === 0) {
|
|
20882
20897
|
spans.push({ text, bold: false, italic: false, code: false });
|
|
20883
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
|
+
}
|
|
20884
20906
|
return spans;
|
|
20885
20907
|
}
|
|
20886
20908
|
function spanToCharPrId(span) {
|
|
@@ -20968,10 +20990,10 @@ function buildParaProperties(gongmun) {
|
|
|
20968
20990
|
if (!gongmun) {
|
|
20969
20991
|
const base2 = [
|
|
20970
20992
|
paraPr(0),
|
|
20971
|
-
paraPr(1, { align: "LEFT", spaceBefore: 800, spaceAfter: 200, lineSpacing: 180 }),
|
|
20972
|
-
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: 170 }),
|
|
20973
|
-
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: 160 }),
|
|
20974
|
-
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 }),
|
|
20975
20997
|
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400 }),
|
|
20976
20998
|
paraPr(6, { align: "LEFT", lineSpacing: 150, indent: 600 }),
|
|
20977
20999
|
paraPr(7, { align: "LEFT", lineSpacing: 160, indent: 600 })
|
|
@@ -20984,10 +21006,10 @@ ${base2.join("\n")}
|
|
|
20984
21006
|
const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
|
|
20985
21007
|
const base = [
|
|
20986
21008
|
paraPr(0, { lineSpacing: ls, keepWord: true }),
|
|
20987
|
-
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls, keepWord: true }),
|
|
20988
|
-
paraPr(2, { align: "LEFT", spaceBefore: 600, spaceAfter: 150, lineSpacing: ls, keepWord: true }),
|
|
20989
|
-
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
20990
|
-
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 }),
|
|
20991
21013
|
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400, keepWord: true }),
|
|
20992
21014
|
paraPr(6, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true }),
|
|
20993
21015
|
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true })
|
|
@@ -21002,8 +21024,19 @@ ${base2.join("\n")}
|
|
|
21002
21024
|
${base.join("\n")}
|
|
21003
21025
|
</hh:paraProperties>`;
|
|
21004
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
|
+
}
|
|
21005
21038
|
function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
21006
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
21039
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _175 => _175.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
21007
21040
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants);
|
|
21008
21041
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21009
21042
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -21079,7 +21112,7 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21079
21112
|
</hh:borderFills>
|
|
21080
21113
|
${charPropsXml}
|
|
21081
21114
|
<hh:tabProperties itemCnt="0"/>
|
|
21082
|
-
|
|
21115
|
+
${buildNumberings()}
|
|
21083
21116
|
<hh:bullets itemCnt="0"/>
|
|
21084
21117
|
${paraPropsXml}
|
|
21085
21118
|
<hh:styles itemCnt="1">
|
|
@@ -21344,11 +21377,11 @@ function bestSimInRange(arr, from, to, target) {
|
|
|
21344
21377
|
return best;
|
|
21345
21378
|
}
|
|
21346
21379
|
function escapeGfm(text) {
|
|
21347
|
-
return text.replace(
|
|
21380
|
+
return text.replace(/([~*])/g, "\\$1");
|
|
21348
21381
|
}
|
|
21349
21382
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21350
21383
|
function sanitizeText(text) {
|
|
21351
|
-
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();
|
|
21352
21385
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21353
21386
|
const tokens = result.split(" ");
|
|
21354
21387
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21362,7 +21395,7 @@ function normForMatch(text) {
|
|
|
21362
21395
|
return sanitizeText(text).replace(/\s+/g, " ").trim();
|
|
21363
21396
|
}
|
|
21364
21397
|
function unescapeGfm(text) {
|
|
21365
|
-
return text.replace(
|
|
21398
|
+
return text.replace(/\\([~*])/g, "$1");
|
|
21366
21399
|
}
|
|
21367
21400
|
function summarize(text) {
|
|
21368
21401
|
const t = text.replace(/\s+/g, " ").trim();
|
|
@@ -21378,7 +21411,7 @@ function replicateGfmTable(table) {
|
|
|
21378
21411
|
for (let r = 0; r < numRows; r++) {
|
|
21379
21412
|
for (let c = 0; c < numCols; c++) {
|
|
21380
21413
|
if (skip.has(`${r},${c}`)) continue;
|
|
21381
|
-
const cell = _optionalChain([cells, 'access',
|
|
21414
|
+
const cell = _optionalChain([cells, 'access', _176 => _176[r], 'optionalAccess', _177 => _177[c]]);
|
|
21382
21415
|
if (!cell) continue;
|
|
21383
21416
|
display[r][c] = {
|
|
21384
21417
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -21429,10 +21462,10 @@ function parseGfmTable(lines) {
|
|
|
21429
21462
|
return rows;
|
|
21430
21463
|
}
|
|
21431
21464
|
function unescapeGfmCell(text) {
|
|
21432
|
-
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(
|
|
21465
|
+
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
21433
21466
|
}
|
|
21434
21467
|
function replicateCellInnerHtml(cell) {
|
|
21435
|
-
if (_optionalChain([cell, 'access',
|
|
21468
|
+
if (_optionalChain([cell, 'access', _178 => _178.blocks, 'optionalAccess', _179 => _179.length])) {
|
|
21436
21469
|
return cell.blocks.map((b) => {
|
|
21437
21470
|
if (b.type === "table" && b.table) {
|
|
21438
21471
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -21471,7 +21504,7 @@ function replicateHtmlTable(table) {
|
|
|
21471
21504
|
const rowCells = [];
|
|
21472
21505
|
for (let c = 0; c < numCols; c++) {
|
|
21473
21506
|
if (skip.has(`${r},${c}`)) continue;
|
|
21474
|
-
const cell = _optionalChain([cells, 'access',
|
|
21507
|
+
const cell = _optionalChain([cells, 'access', _180 => _180[r], 'optionalAccess', _181 => _181[c]]);
|
|
21475
21508
|
if (!cell) continue;
|
|
21476
21509
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
21477
21510
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -21517,8 +21550,8 @@ function parseHtmlTable(raw) {
|
|
|
21517
21550
|
}
|
|
21518
21551
|
} else {
|
|
21519
21552
|
if (!isClose) {
|
|
21520
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
21521
|
-
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);
|
|
21522
21555
|
cellStart = m.index + m[0].length;
|
|
21523
21556
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
21524
21557
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -21688,7 +21721,7 @@ function generateSecPr(gongmun) {
|
|
|
21688
21721
|
header: 0,
|
|
21689
21722
|
footer: 0
|
|
21690
21723
|
} : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
|
|
21691
|
-
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>`;
|
|
21692
21725
|
}
|
|
21693
21726
|
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null) {
|
|
21694
21727
|
const paraXmls = [];
|
|
@@ -21735,8 +21768,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21735
21768
|
case "list_item": {
|
|
21736
21769
|
if (gongmun && gongmunList) {
|
|
21737
21770
|
const info = gongmunList.get(blockIdx);
|
|
21738
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
21739
|
-
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]), () => ( ""));
|
|
21740
21773
|
const content = block.text || "";
|
|
21741
21774
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
21742
21775
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -21745,7 +21778,10 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21745
21778
|
}
|
|
21746
21779
|
const indent = block.indent || 0;
|
|
21747
21780
|
let marker;
|
|
21748
|
-
if (block.
|
|
21781
|
+
if (block.marker) {
|
|
21782
|
+
marker = `${block.marker} `;
|
|
21783
|
+
prevWasOrdered = !!block.ordered;
|
|
21784
|
+
} else if (block.ordered) {
|
|
21749
21785
|
orderedCounters[indent] = (orderedCounters[indent] || 0) + 1;
|
|
21750
21786
|
for (const k of Object.keys(orderedCounters)) {
|
|
21751
21787
|
if (+k > indent) delete orderedCounters[+k];
|
|
@@ -21813,8 +21849,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21813
21849
|
|
|
21814
21850
|
// src/hwpx/generator.ts
|
|
21815
21851
|
async function markdownToHwpx(markdown, options) {
|
|
21816
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
21817
|
-
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;
|
|
21818
21854
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
21819
21855
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
21820
21856
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
@@ -21823,7 +21859,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
21823
21859
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
21824
21860
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
21825
21861
|
zip.file("Contents/content.hpf", generateManifest());
|
|
21826
|
-
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]), () => ( []))));
|
|
21827
21863
|
zip.file("Contents/section0.xml", sectionXml);
|
|
21828
21864
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
21829
21865
|
return await zip.generateAsync({ type: "arraybuffer" });
|
|
@@ -21971,7 +22007,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
21971
22007
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
21972
22008
|
function patchTableRows(input) {
|
|
21973
22009
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
21974
|
-
const xml = _optionalChain([ctx, 'access',
|
|
22010
|
+
const xml = _optionalChain([ctx, 'access', _193 => _193.scans, 'access', _194 => _194[scanTable.sectionIndex], 'optionalAccess', _195 => _195.xml]);
|
|
21975
22011
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
21976
22012
|
const numRows = table.rows;
|
|
21977
22013
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -22138,7 +22174,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
22138
22174
|
const rr = scanTable.rowRanges[template];
|
|
22139
22175
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
22140
22176
|
const scan = scanSectionXml(wrapped, 0);
|
|
22141
|
-
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]]);
|
|
22142
22178
|
if (!row || row.length !== cells.length) return null;
|
|
22143
22179
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
22144
22180
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -22181,7 +22217,7 @@ function rowHeightOf(fragment) {
|
|
|
22181
22217
|
}
|
|
22182
22218
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
22183
22219
|
const from = scanTable.start + tblOpenLen;
|
|
22184
|
-
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));
|
|
22185
22221
|
const slice = xml.slice(from, to);
|
|
22186
22222
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
22187
22223
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -22370,9 +22406,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
22370
22406
|
});
|
|
22371
22407
|
}
|
|
22372
22408
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
22373
|
-
const irCell = _optionalChain([table, 'access',
|
|
22409
|
+
const irCell = _optionalChain([table, 'access', _203 => _203.cells, 'access', _204 => _204[oc.gridR], 'optionalAccess', _205 => _205[oc.gridC]]);
|
|
22374
22410
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
22375
|
-
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);
|
|
22376
22412
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
22377
22413
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
22378
22414
|
}
|
|
@@ -22440,7 +22476,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22440
22476
|
};
|
|
22441
22477
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
22442
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)");
|
|
22443
|
-
const irCell = _optionalChain([table, 'access',
|
|
22479
|
+
const irCell = _optionalChain([table, 'access', _207 => _207.cells, 'access', _208 => _208[gridR], 'optionalAccess', _209 => _209[gridC]]);
|
|
22444
22480
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
22445
22481
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
22446
22482
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -22463,7 +22499,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22463
22499
|
if (newLines.length === 0) return 0;
|
|
22464
22500
|
const target = cell.paragraphs[0];
|
|
22465
22501
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
22466
|
-
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]));
|
|
22467
22503
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22468
22504
|
splices.push(...sp);
|
|
22469
22505
|
sectionIndex = target.sectionIndex;
|
|
@@ -22486,7 +22522,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22486
22522
|
}
|
|
22487
22523
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
22488
22524
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
22489
|
-
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]));
|
|
22490
22526
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22491
22527
|
splices.push(...sp);
|
|
22492
22528
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -22567,7 +22603,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
22567
22603
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
22568
22604
|
if (paths.length > 0) return paths;
|
|
22569
22605
|
}
|
|
22570
|
-
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);
|
|
22571
22607
|
}
|
|
22572
22608
|
function sectionPathsFromManifest(xml) {
|
|
22573
22609
|
const attr = (tag, name) => {
|
|
@@ -22577,7 +22613,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22577
22613
|
const idToHref = /* @__PURE__ */ new Map();
|
|
22578
22614
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
22579
22615
|
const id = attr(m[1], "id");
|
|
22580
|
-
const href =
|
|
22616
|
+
const href = _chunkZ3O36LBJcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
22581
22617
|
if (id && href) idToHref.set(id, href);
|
|
22582
22618
|
}
|
|
22583
22619
|
const ordered = [];
|
|
@@ -22586,7 +22622,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22586
22622
|
if (href) ordered.push(href);
|
|
22587
22623
|
}
|
|
22588
22624
|
if (ordered.length > 0) return ordered;
|
|
22589
|
-
return Array.from(idToHref.values()).sort(
|
|
22625
|
+
return Array.from(idToHref.values()).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
|
|
22590
22626
|
}
|
|
22591
22627
|
|
|
22592
22628
|
// src/roundtrip/patcher.ts
|
|
@@ -22678,7 +22714,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
22678
22714
|
}
|
|
22679
22715
|
}
|
|
22680
22716
|
let verification;
|
|
22681
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22717
|
+
if (_optionalChain([options, 'optionalAccess', _216 => _216.verify]) !== false) {
|
|
22682
22718
|
try {
|
|
22683
22719
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
22684
22720
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -22696,17 +22732,17 @@ function buildOrigUnits(blocks) {
|
|
|
22696
22732
|
let chunk;
|
|
22697
22733
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
22698
22734
|
const next = blocks[i + 1];
|
|
22699
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
22700
|
-
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));
|
|
22701
22737
|
} else {
|
|
22702
|
-
chunk =
|
|
22738
|
+
chunk = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, [block]);
|
|
22703
22739
|
}
|
|
22704
22740
|
if (chunk) {
|
|
22705
22741
|
const subUnits = splitMarkdownUnits(chunk);
|
|
22706
22742
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
22707
22743
|
for (let s = 0; s < subUnits.length; s++) {
|
|
22708
22744
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
22709
|
-
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("**")) {
|
|
22710
22746
|
u.role = "caption";
|
|
22711
22747
|
}
|
|
22712
22748
|
units.push(u);
|
|
@@ -22817,7 +22853,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
22817
22853
|
const ti = ctx.tableInsert;
|
|
22818
22854
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
22819
22855
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22820
|
-
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");
|
|
22821
22857
|
const para = mapping.para;
|
|
22822
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");
|
|
22823
22859
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -22845,7 +22881,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
22845
22881
|
}
|
|
22846
22882
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
22847
22883
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22848
|
-
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)");
|
|
22849
22885
|
if (block.text && block.text.includes("\n")) {
|
|
22850
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)");
|
|
22851
22887
|
}
|
|
@@ -22876,7 +22912,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
22876
22912
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
22877
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");
|
|
22878
22914
|
}
|
|
22879
|
-
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]));
|
|
22880
22916
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22881
22917
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
22882
22918
|
return 1;
|
|
@@ -23062,7 +23098,7 @@ var Surgeon = (_class4 = class {
|
|
|
23062
23098
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
23063
23099
|
findEntry(path) {
|
|
23064
23100
|
const parts = path.replace(/^\//, "").split("/");
|
|
23065
|
-
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));
|
|
23066
23102
|
let current;
|
|
23067
23103
|
for (const part of parts) {
|
|
23068
23104
|
const search = (idx) => {
|
|
@@ -23275,8 +23311,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
23275
23311
|
parts.push(header, data);
|
|
23276
23312
|
};
|
|
23277
23313
|
for (let i = 0; i < recs.length; i++) {
|
|
23278
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
23279
|
-
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)));
|
|
23280
23316
|
}
|
|
23281
23317
|
return Buffer.concat(parts);
|
|
23282
23318
|
}
|
|
@@ -23394,7 +23430,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23394
23430
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
23395
23431
|
}
|
|
23396
23432
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
23397
|
-
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");
|
|
23398
23434
|
let flags;
|
|
23399
23435
|
try {
|
|
23400
23436
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -23416,7 +23452,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23416
23452
|
const scans = [];
|
|
23417
23453
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
23418
23454
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
23419
|
-
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]}`);
|
|
23420
23456
|
let stream;
|
|
23421
23457
|
try {
|
|
23422
23458
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -23467,7 +23503,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23467
23503
|
}
|
|
23468
23504
|
}
|
|
23469
23505
|
let verification;
|
|
23470
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23506
|
+
if (_optionalChain([options, 'optionalAccess', _234 => _234.verify]) !== false) {
|
|
23471
23507
|
try {
|
|
23472
23508
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
23473
23509
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -23556,7 +23592,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
23556
23592
|
for (const [key, scanCell] of scanTable.cells) {
|
|
23557
23593
|
const comma = key.indexOf(",");
|
|
23558
23594
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
23559
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
23595
|
+
const irCell = _optionalChain([irTable, 'access', _235 => _235.cells, 'access', _236 => _236[r], 'optionalAccess', _237 => _237[c]]);
|
|
23560
23596
|
if (!irCell) continue;
|
|
23561
23597
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
23562
23598
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -23592,7 +23628,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
23592
23628
|
}
|
|
23593
23629
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
23594
23630
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
23595
|
-
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)");
|
|
23596
23632
|
if (block.text && block.text.includes("\n")) {
|
|
23597
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)");
|
|
23598
23634
|
}
|
|
@@ -23768,7 +23804,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
23768
23804
|
};
|
|
23769
23805
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
23770
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)");
|
|
23771
|
-
const irCell = _optionalChain([table, 'access',
|
|
23807
|
+
const irCell = _optionalChain([table, 'access', _239 => _239.cells, 'access', _240 => _240[gridR], 'optionalAccess', _241 => _241[gridC]]);
|
|
23772
23808
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
23773
23809
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23774
23810
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -24043,7 +24079,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24043
24079
|
const block = st.blocks[blockIndex];
|
|
24044
24080
|
if (!block) return void 0;
|
|
24045
24081
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
24046
|
-
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]);
|
|
24047
24083
|
if (!para) return void 0;
|
|
24048
24084
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
24049
24085
|
}
|
|
@@ -24068,7 +24104,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24068
24104
|
if (block.text && block.text.includes("\n")) {
|
|
24069
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)" };
|
|
24070
24106
|
}
|
|
24071
|
-
if (!_optionalChain([st, 'access',
|
|
24107
|
+
if (!_optionalChain([st, 'access', _246 => _246.paraMap, 'access', _247 => _247.get, 'call', _248 => _248(blockIndex), 'optionalAccess', _249 => _249.para])) {
|
|
24072
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)" };
|
|
24073
24109
|
}
|
|
24074
24110
|
return { capability: "text" };
|
|
@@ -24134,7 +24170,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24134
24170
|
continue;
|
|
24135
24171
|
}
|
|
24136
24172
|
if (block.type === "table" && block.table) {
|
|
24137
|
-
if (!_optionalChain([edit, 'access',
|
|
24173
|
+
if (!_optionalChain([edit, 'access', _250 => _250.cells, 'optionalAccess', _251 => _251.length])) {
|
|
24138
24174
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
24139
24175
|
continue;
|
|
24140
24176
|
}
|
|
@@ -24154,7 +24190,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24154
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) });
|
|
24155
24191
|
continue;
|
|
24156
24192
|
}
|
|
24157
|
-
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]]);
|
|
24158
24194
|
if (!irCell) {
|
|
24159
24195
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
24160
24196
|
continue;
|
|
@@ -24210,7 +24246,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24210
24246
|
}
|
|
24211
24247
|
if (replacements.size === 0) {
|
|
24212
24248
|
let changes2;
|
|
24213
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24249
|
+
if (_optionalChain([options, 'optionalAccess', _256 => _256.verify]) !== false) {
|
|
24214
24250
|
const units = splitMarkdownUnits(st.markdown);
|
|
24215
24251
|
changes2 = diffUnitLists(units, units);
|
|
24216
24252
|
}
|
|
@@ -24231,7 +24267,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24231
24267
|
}
|
|
24232
24268
|
this.state = newState;
|
|
24233
24269
|
let changes;
|
|
24234
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24270
|
+
if (_optionalChain([options, 'optionalAccess', _257 => _257.verify]) !== false) {
|
|
24235
24271
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
24236
24272
|
}
|
|
24237
24273
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -24251,7 +24287,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24251
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)");
|
|
24252
24288
|
}
|
|
24253
24289
|
const mapping = st.paraMap.get(blockIndex);
|
|
24254
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24290
|
+
if (!_optionalChain([mapping, 'optionalAccess', _258 => _258.para])) {
|
|
24255
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)");
|
|
24256
24292
|
}
|
|
24257
24293
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -24271,14 +24307,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24271
24307
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24272
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");
|
|
24273
24309
|
}
|
|
24274
|
-
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]));
|
|
24275
24311
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24276
24312
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24277
24313
|
return 1;
|
|
24278
24314
|
}
|
|
24279
24315
|
}, _class5);
|
|
24280
24316
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
24281
|
-
const irCell = _optionalChain([table, 'access',
|
|
24317
|
+
const irCell = _optionalChain([table, 'access', _262 => _262.cells, 'access', _263 => _263[r], 'optionalAccess', _264 => _264[c]]);
|
|
24282
24318
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
24283
24319
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
24284
24320
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -24362,11 +24398,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
24362
24398
|
breaks: false
|
|
24363
24399
|
});
|
|
24364
24400
|
function renderHtml(markdown, options) {
|
|
24365
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24366
|
-
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]), () => ( "")));
|
|
24367
24403
|
const body = md.render(markdown);
|
|
24368
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
24369
|
-
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]) ? `
|
|
24370
24406
|
.watermark {
|
|
24371
24407
|
position: fixed;
|
|
24372
24408
|
top: 50%; left: 50%;
|
|
@@ -24397,13 +24433,13 @@ async function htmlToPdf(html, options) {
|
|
|
24397
24433
|
try {
|
|
24398
24434
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
24399
24435
|
} catch (e30) {
|
|
24400
|
-
throw new (0,
|
|
24436
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
24401
24437
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
24402
24438
|
);
|
|
24403
24439
|
}
|
|
24404
24440
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
24405
24441
|
if (!executablePath) {
|
|
24406
|
-
throw new (0,
|
|
24442
|
+
throw new (0, _chunkZ3O36LBJcjs.KordocError)(
|
|
24407
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."
|
|
24408
24444
|
);
|
|
24409
24445
|
}
|
|
@@ -24415,10 +24451,10 @@ async function htmlToPdf(html, options) {
|
|
|
24415
24451
|
try {
|
|
24416
24452
|
const page = await browser.newPage();
|
|
24417
24453
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
24418
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
24454
|
+
const margin = _optionalChain([options, 'optionalAccess', _269 => _269.margin]);
|
|
24419
24455
|
const pdf = await page.pdf({
|
|
24420
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24421
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
24456
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _270 => _270.pageSize]), () => ( "A4")),
|
|
24457
|
+
landscape: _optionalChain([options, 'optionalAccess', _271 => _271.orientation]) === "landscape",
|
|
24422
24458
|
printBackground: true,
|
|
24423
24459
|
margin: margin ? {
|
|
24424
24460
|
top: toCss(margin.top),
|
|
@@ -24426,9 +24462,9 @@ async function htmlToPdf(html, options) {
|
|
|
24426
24462
|
bottom: toCss(margin.bottom),
|
|
24427
24463
|
left: toCss(margin.left)
|
|
24428
24464
|
} : void 0,
|
|
24429
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
24430
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24431
|
-
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>'))
|
|
24432
24468
|
});
|
|
24433
24469
|
return Buffer.from(pdf);
|
|
24434
24470
|
} finally {
|
|
@@ -24462,24 +24498,24 @@ async function markdownToPdf(markdown, options) {
|
|
|
24462
24498
|
return htmlToPdf(html, options);
|
|
24463
24499
|
}
|
|
24464
24500
|
async function blocksToPdf(blocks, options) {
|
|
24465
|
-
const markdown =
|
|
24501
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
|
|
24466
24502
|
return markdownToPdf(markdown, options);
|
|
24467
24503
|
}
|
|
24468
24504
|
|
|
24469
24505
|
// src/index.ts
|
|
24470
24506
|
async function parse(input, options) {
|
|
24471
24507
|
let buffer;
|
|
24472
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
24508
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _276 => _276.filePath]) ? { ...options, filePath: input } : options;
|
|
24473
24509
|
if (typeof input === "string") {
|
|
24474
24510
|
try {
|
|
24475
24511
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24476
|
-
buffer =
|
|
24512
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, buf);
|
|
24477
24513
|
} catch (err) {
|
|
24478
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}`;
|
|
24479
24515
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
24480
24516
|
}
|
|
24481
24517
|
} else if (Buffer.isBuffer(input)) {
|
|
24482
|
-
buffer =
|
|
24518
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, input);
|
|
24483
24519
|
} else {
|
|
24484
24520
|
buffer = input;
|
|
24485
24521
|
}
|
|
@@ -24514,21 +24550,21 @@ async function parseHwp3(buffer, options) {
|
|
|
24514
24550
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
24515
24551
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
24516
24552
|
} catch (err) {
|
|
24517
|
-
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) };
|
|
24518
24554
|
}
|
|
24519
24555
|
}
|
|
24520
24556
|
async function parseHwpx(buffer, options) {
|
|
24521
24557
|
try {
|
|
24522
24558
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
24523
|
-
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 };
|
|
24524
24560
|
} catch (err) {
|
|
24525
|
-
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) };
|
|
24526
24562
|
}
|
|
24527
24563
|
}
|
|
24528
24564
|
async function parseHwp(buffer, options) {
|
|
24529
24565
|
try {
|
|
24530
24566
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
24531
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
24567
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _278 => _278.filePath])) {
|
|
24532
24568
|
try {
|
|
24533
24569
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
24534
24570
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -24545,15 +24581,15 @@ async function parseHwp(buffer, options) {
|
|
|
24545
24581
|
} catch (e31) {
|
|
24546
24582
|
}
|
|
24547
24583
|
}
|
|
24548
|
-
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 };
|
|
24549
24585
|
} catch (err) {
|
|
24550
|
-
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) };
|
|
24551
24587
|
}
|
|
24552
24588
|
}
|
|
24553
24589
|
async function parsePdf(buffer, options) {
|
|
24554
24590
|
let parsePdfDocument;
|
|
24555
24591
|
try {
|
|
24556
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
24592
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ZVKCFXR3.cjs")));
|
|
24557
24593
|
parsePdfDocument = mod.parsePdfDocument;
|
|
24558
24594
|
} catch (e32) {
|
|
24559
24595
|
return {
|
|
@@ -24568,7 +24604,7 @@ async function parsePdf(buffer, options) {
|
|
|
24568
24604
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
24569
24605
|
} catch (err) {
|
|
24570
24606
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
24571
|
-
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 };
|
|
24572
24608
|
}
|
|
24573
24609
|
}
|
|
24574
24610
|
async function parseXlsx(buffer, options) {
|
|
@@ -24576,7 +24612,7 @@ async function parseXlsx(buffer, options) {
|
|
|
24576
24612
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
24577
24613
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
24578
24614
|
} catch (err) {
|
|
24579
|
-
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) };
|
|
24580
24616
|
}
|
|
24581
24617
|
}
|
|
24582
24618
|
async function parseXls(buffer, options) {
|
|
@@ -24584,15 +24620,15 @@ async function parseXls(buffer, options) {
|
|
|
24584
24620
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
24585
24621
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
24586
24622
|
} catch (err) {
|
|
24587
|
-
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) };
|
|
24588
24624
|
}
|
|
24589
24625
|
}
|
|
24590
24626
|
async function parseDocx(buffer, options) {
|
|
24591
24627
|
try {
|
|
24592
24628
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
24593
|
-
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 };
|
|
24594
24630
|
} catch (err) {
|
|
24595
|
-
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) };
|
|
24596
24632
|
}
|
|
24597
24633
|
}
|
|
24598
24634
|
async function parseHwpml(buffer, options) {
|
|
@@ -24600,16 +24636,16 @@ async function parseHwpml(buffer, options) {
|
|
|
24600
24636
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
24601
24637
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
24602
24638
|
} catch (err) {
|
|
24603
|
-
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) };
|
|
24604
24640
|
}
|
|
24605
24641
|
}
|
|
24606
24642
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
24607
24643
|
let buffer;
|
|
24608
24644
|
if (typeof input === "string") {
|
|
24609
24645
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24610
|
-
buffer =
|
|
24646
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, buf);
|
|
24611
24647
|
} else if (Buffer.isBuffer(input)) {
|
|
24612
|
-
buffer =
|
|
24648
|
+
buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, input);
|
|
24613
24649
|
} else {
|
|
24614
24650
|
buffer = input;
|
|
24615
24651
|
}
|
|
@@ -24635,7 +24671,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24635
24671
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
24636
24672
|
}
|
|
24637
24673
|
const fill = fillFormFields(parsed.blocks, values);
|
|
24638
|
-
const markdown =
|
|
24674
|
+
const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
24639
24675
|
if (outputFormat === "hwpx") {
|
|
24640
24676
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
24641
24677
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -24693,5 +24729,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24693
24729
|
|
|
24694
24730
|
|
|
24695
24731
|
|
|
24696
|
-
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;
|
|
24697
24733
|
//# sourceMappingURL=index.cjs.map
|