kordoc 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +792 -768
- package/dist/{-O3AWNVPH.js → -QSF64HNK.js} +8 -8
- package/dist/{chunk-EH2KYFFO.js → chunk-6JSZBSOD.js} +2 -2
- package/dist/chunk-6JSZBSOD.js.map +1 -0
- package/dist/{chunk-YEC7VG6O.js → chunk-AUJICYJG.js} +3 -3
- package/dist/chunk-AUJICYJG.js.map +1 -0
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-SHVV3BD6.js → chunk-K2SETHJ6.js} +426 -111
- package/dist/chunk-K2SETHJ6.js.map +1 -0
- package/dist/{chunk-5CJGKKMZ.js → chunk-MEPHGCPQ.js} +1 -1
- package/dist/chunk-MEPHGCPQ.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-C5ABJ7PB.js → chunk-MQLKSRIK.js} +3 -3
- package/dist/chunk-MQLKSRIK.js.map +1 -0
- package/dist/{chunk-NIZXIVEI.cjs → chunk-OVESZY5R.cjs} +2 -2
- package/dist/chunk-OVESZY5R.cjs.map +1 -0
- package/dist/{chunk-33OUI7HC.js → chunk-PNQDQ3SM.js} +2 -2
- package/dist/chunk-PNQDQ3SM.js.map +1 -0
- package/dist/{chunk-JMLK6NTW.js → chunk-RO2GVZ3I.js} +3 -3
- package/dist/chunk-RO2GVZ3I.js.map +1 -0
- package/dist/{chunk-3H3CVOZ3.js → chunk-TQYX5E32.js} +2 -2
- package/dist/chunk-TQYX5E32.js.map +1 -0
- package/dist/cli.js +37 -15
- package/dist/cli.js.map +1 -1
- package/dist/{detect-PJZMUL2Z.js → detect-RI2MQ33K.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +756 -441
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -6
- package/dist/index.d.ts +60 -6
- package/dist/index.js +421 -106
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +61 -19
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +0 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-ZOMDHCA7.js → parser-AODAQQLQ.js} +5 -5
- package/dist/parser-AODAQQLQ.js.map +1 -0
- package/dist/{parser-44OPXZMP.cjs → parser-FMONFTAN.cjs} +16 -16
- package/dist/parser-FMONFTAN.cjs.map +1 -0
- package/dist/{parser-G433UZMX.js → parser-J7YREDNS.js} +4 -4
- package/dist/parser-J7YREDNS.js.map +1 -0
- package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/provider-4ZJKV3DC.js.map +1 -0
- package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
- package/dist/provider-AKROB7WQ.js.map +1 -0
- package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/render-JPP7YTV3.js +10 -0
- package/dist/seal-MDE4DXZQ.js +10 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-UYT3ZCBM.js → watch-P65Z24AL.js} +8 -8
- package/dist/watch-P65Z24AL.js.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-33OUI7HC.js.map +0 -1
- package/dist/chunk-3H3CVOZ3.js.map +0 -1
- package/dist/chunk-5CJGKKMZ.js.map +0 -1
- package/dist/chunk-C5ABJ7PB.js.map +0 -1
- package/dist/chunk-EH2KYFFO.js.map +0 -1
- package/dist/chunk-JMLK6NTW.js.map +0 -1
- package/dist/chunk-NIZXIVEI.cjs.map +0 -1
- package/dist/chunk-SHVV3BD6.js.map +0 -1
- package/dist/chunk-YEC7VG6O.js.map +0 -1
- package/dist/parser-44OPXZMP.cjs.map +0 -1
- package/dist/parser-G433UZMX.js.map +0 -1
- package/dist/parser-ZOMDHCA7.js.map +0 -1
- package/dist/provider-5K7O3Z2O.cjs.map +0 -1
- package/dist/provider-7H4CPZYS.js.map +0 -1
- package/dist/provider-H4WWSPOV.js.map +0 -1
- package/dist/render-SQVQBORJ.js +0 -10
- package/dist/seal-6E26L45Z.js +0 -10
- package/dist/watch-UYT3ZCBM.js.map +0 -1
- /package/dist/{-O3AWNVPH.js.map → -QSF64HNK.js.map} +0 -0
- /package/dist/{detect-PJZMUL2Z.js.map → detect-RI2MQ33K.js.map} +0 -0
- /package/dist/{render-SQVQBORJ.js.map → render-JPP7YTV3.js.map} +0 -0
- /package/dist/{seal-6E26L45Z.js.map → seal-MDE4DXZQ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkOVESZY5Rcjs = require('./chunk-OVESZY5R.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -406,8 +406,8 @@ function createSectionShared() {
|
|
|
406
406
|
function createXmlParser(warnings) {
|
|
407
407
|
return new (0, _xmldom.DOMParser)({
|
|
408
408
|
onError(level, msg2) {
|
|
409
|
-
if (level === "fatalError") throw new (0,
|
|
410
|
-
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "
|
|
409
|
+
if (level === "fatalError") throw new (0, _chunkOVESZY5Rcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
410
|
+
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
411
411
|
}
|
|
412
412
|
});
|
|
413
413
|
}
|
|
@@ -461,14 +461,14 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
461
461
|
const xml = await file.async("text");
|
|
462
462
|
if (decompressed) {
|
|
463
463
|
decompressed.total += xml.length * 2;
|
|
464
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
464
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
465
465
|
}
|
|
466
466
|
const parser = createXmlParser();
|
|
467
|
-
const doc = parser.parseFromString(
|
|
467
|
+
const doc = parser.parseFromString(_chunkOVESZY5Rcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
468
468
|
if (!doc.documentElement) continue;
|
|
469
|
-
parseCharProperties(doc, result.charProperties);
|
|
470
|
-
parseStyleElements(doc, result.styles);
|
|
471
469
|
const domDoc = doc;
|
|
470
|
+
parseCharProperties(domDoc, result.charProperties);
|
|
471
|
+
parseStyleElements(domDoc, result.styles);
|
|
472
472
|
parseNumberings(domDoc, result.numberings);
|
|
473
473
|
parseBullets(domDoc, result.bullets);
|
|
474
474
|
parseParaHeadings(domDoc, result.paraHeadings);
|
|
@@ -616,9 +616,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
616
616
|
let level = 0;
|
|
617
617
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
|
|
618
618
|
const ratio = block.style.fontSize / baseFontSize;
|
|
619
|
-
if (ratio >=
|
|
620
|
-
else if (ratio >=
|
|
621
|
-
else if (ratio >=
|
|
619
|
+
if (ratio >= _chunkOVESZY5Rcjs.HEADING_RATIO_H1) level = 1;
|
|
620
|
+
else if (ratio >= _chunkOVESZY5Rcjs.HEADING_RATIO_H2) level = 2;
|
|
621
|
+
else if (ratio >= _chunkOVESZY5Rcjs.HEADING_RATIO_H3) level = 3;
|
|
622
622
|
}
|
|
623
623
|
const compactText = text.replace(/\s+/g, "");
|
|
624
624
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1202,7 +1202,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1202
1202
|
|
|
1203
1203
|
// src/hwpx/table-build.ts
|
|
1204
1204
|
function buildTableWithCellMeta(state) {
|
|
1205
|
-
const table2 =
|
|
1205
|
+
const table2 = _chunkOVESZY5Rcjs.buildTable.call(void 0, state.rows);
|
|
1206
1206
|
if (state.caption) table2.caption = state.caption;
|
|
1207
1207
|
const anchors = [];
|
|
1208
1208
|
{
|
|
@@ -1272,7 +1272,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1272
1272
|
const cell2 = parentTable.cell;
|
|
1273
1273
|
(cell2.blocks ??= []).push(block);
|
|
1274
1274
|
cell2.hasStructure = true;
|
|
1275
|
-
let flat =
|
|
1275
|
+
let flat = _chunkOVESZY5Rcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1276
1276
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1277
1277
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1278
1278
|
} else {
|
|
@@ -1284,7 +1284,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1284
1284
|
// src/hwpx/section-walker.ts
|
|
1285
1285
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1286
1286
|
const parser = createXmlParser(warnings);
|
|
1287
|
-
const doc = parser.parseFromString(
|
|
1287
|
+
const doc = parser.parseFromString(_chunkOVESZY5Rcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1288
1288
|
if (!doc.documentElement) return [];
|
|
1289
1289
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1290
1290
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1336,12 +1336,17 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1336
1336
|
break;
|
|
1337
1337
|
}
|
|
1338
1338
|
// 표/도표 캡션 — IRTable.caption으로 보존 (v3.0, 기존 무음 드롭 수정)
|
|
1339
|
-
case "caption":
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
if (
|
|
1339
|
+
case "caption": {
|
|
1340
|
+
const capText = collectSubListText(el, ctx);
|
|
1341
|
+
if (capText) {
|
|
1342
|
+
if (tableCtx) {
|
|
1343
|
+
tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + capText;
|
|
1344
|
+
} else {
|
|
1345
|
+
blocks.push({ type: "paragraph", text: capText, pageNumber: ctx.sectionNum });
|
|
1346
|
+
}
|
|
1343
1347
|
}
|
|
1344
1348
|
break;
|
|
1349
|
+
}
|
|
1345
1350
|
case "tr":
|
|
1346
1351
|
if (tableCtx) {
|
|
1347
1352
|
tableCtx.currentRow = [];
|
|
@@ -1375,8 +1380,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1375
1380
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1376
1381
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1377
1382
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1378
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1379
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1383
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkOVESZY5Rcjs.MAX_COLS);
|
|
1384
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkOVESZY5Rcjs.MAX_ROWS);
|
|
1380
1385
|
}
|
|
1381
1386
|
break;
|
|
1382
1387
|
case "p": {
|
|
@@ -1506,7 +1511,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
1506
1511
|
if (depth > MAX_XML_DEPTH) return tableCtx;
|
|
1507
1512
|
const children = node.childNodes;
|
|
1508
1513
|
if (!children) return tableCtx;
|
|
1509
|
-
const walkChildren = (parent, d) => {
|
|
1514
|
+
const walkChildren = (parent, d, inShape = false) => {
|
|
1510
1515
|
if (d > MAX_XML_DEPTH) return;
|
|
1511
1516
|
const kids2 = parent.childNodes;
|
|
1512
1517
|
if (!kids2) return;
|
|
@@ -1520,8 +1525,15 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
1520
1525
|
const newTable = { rows: [], currentRow: [], cell: null };
|
|
1521
1526
|
walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
|
|
1522
1527
|
tableCtx = completeTable(newTable, tableStack, blocks, ctx);
|
|
1528
|
+
} else if (localTag === "caption" && !inShape) {
|
|
1529
|
+
const capText = collectSubListText(el, ctx);
|
|
1530
|
+
if (capText) {
|
|
1531
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _25 => _25.cell])) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: capText, pageNumber: ctx.sectionNum }]);
|
|
1532
|
+
else if (tableCtx) tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + capText;
|
|
1533
|
+
else blocks.push({ type: "paragraph", text: capText, pageNumber: ctx.sectionNum });
|
|
1534
|
+
}
|
|
1523
1535
|
} else if (localTag === "pic" || localTag === "shape" || localTag === "drawingObject") {
|
|
1524
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1536
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _26 => _26.cell])) {
|
|
1525
1537
|
const sink = [];
|
|
1526
1538
|
handleShape(el, sink, ctx);
|
|
1527
1539
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -1529,15 +1541,17 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
1529
1541
|
handleShape(el, blocks, ctx);
|
|
1530
1542
|
}
|
|
1531
1543
|
} else if (localTag === "drawText") {
|
|
1532
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
1544
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _27 => _27.cell])) {
|
|
1533
1545
|
const sink = [];
|
|
1534
1546
|
extractDrawTextBlocks(el, sink, ctx);
|
|
1535
1547
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
1536
1548
|
} else {
|
|
1537
1549
|
extractDrawTextBlocks(el, blocks, ctx);
|
|
1538
1550
|
}
|
|
1539
|
-
} else if (localTag === "r" || localTag === "run" || localTag === "ctrl"
|
|
1540
|
-
walkChildren(el, d + 1);
|
|
1551
|
+
} else if (localTag === "r" || localTag === "run" || localTag === "ctrl") {
|
|
1552
|
+
walkChildren(el, d + 1, inShape);
|
|
1553
|
+
} else if (localTag === "rect" || localTag === "ellipse" || localTag === "polygon" || localTag === "line" || localTag === "arc" || localTag === "curve" || localTag === "connectLine" || localTag === "container") {
|
|
1554
|
+
walkChildren(el, d + 1, true);
|
|
1541
1555
|
}
|
|
1542
1556
|
}
|
|
1543
1557
|
};
|
|
@@ -1573,7 +1587,7 @@ function extractDrawTextBlocks(drawTextNode, blocks, ctx) {
|
|
|
1573
1587
|
let text = info.text.trim();
|
|
1574
1588
|
if (text) {
|
|
1575
1589
|
const ph = resolveParaHeading(child, ctx);
|
|
1576
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
1590
|
+
if (_optionalChain([ph, 'optionalAccess', _28 => _28.prefix])) text = ph.prefix + " " + text;
|
|
1577
1591
|
const block = { type: "paragraph", text, style: _nullishCoalesce(info.style, () => ( void 0)), pageNumber: ctx.sectionNum };
|
|
1578
1592
|
if (info.href) block.href = info.href;
|
|
1579
1593
|
if (info.footnote) block.footnoteText = info.footnote;
|
|
@@ -1598,13 +1612,13 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1598
1612
|
let url = (ch.textContent || "").trim();
|
|
1599
1613
|
if (!url) continue;
|
|
1600
1614
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1601
|
-
const safe =
|
|
1615
|
+
const safe = _chunkOVESZY5Rcjs.sanitizeHref.call(void 0, url);
|
|
1602
1616
|
if (safe) return safe;
|
|
1603
1617
|
}
|
|
1604
1618
|
return void 0;
|
|
1605
1619
|
}
|
|
1606
1620
|
function isInDeletedRange(ctx) {
|
|
1607
|
-
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess',
|
|
1621
|
+
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess', _29 => _29.shared, 'access', _30 => _30.track, 'access', _31 => _31.deleteDepth]), () => ( 0))) > 0;
|
|
1608
1622
|
}
|
|
1609
1623
|
function extractParagraphInfo(para2, styleMap, ctx) {
|
|
1610
1624
|
let text = "";
|
|
@@ -1658,7 +1672,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
1658
1672
|
// 삽입분은 최종본에 포함
|
|
1659
1673
|
// 숨은 설명 — 본문 혼입 차단
|
|
1660
1674
|
case "hiddenComment": {
|
|
1661
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
1675
|
+
if (_optionalChain([ctx, 'optionalAccess', _32 => _32.warnings]) && extractTextFromNode(k)) {
|
|
1662
1676
|
ctx.warnings.push({ page: ctx.sectionNum, message: "\uC228\uC740 \uC124\uBA85 \uD14D\uC2A4\uD2B8 \uC81C\uC678: hiddenComment", code: "HIDDEN_TEXT_FILTERED" });
|
|
1663
1677
|
}
|
|
1664
1678
|
break;
|
|
@@ -1673,9 +1687,12 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
1673
1687
|
case "indexmark":
|
|
1674
1688
|
case "colPr":
|
|
1675
1689
|
break;
|
|
1690
|
+
// 캡션 — walkParagraphChildren의 caption 분기가 보존하므로 손실 경고 대상 아님
|
|
1691
|
+
case "caption":
|
|
1692
|
+
break;
|
|
1676
1693
|
// 미지원 요소 — 텍스트를 가졌으면 무음 손실 대신 경고
|
|
1677
1694
|
default: {
|
|
1678
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
1695
|
+
if (_optionalChain([ctx, 'optionalAccess', _33 => _33.warnings]) && extractTextFromNode(k)) {
|
|
1679
1696
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uBBF8\uC9C0\uC6D0 \uC81C\uC5B4 \uC694\uC18C\uC758 \uD14D\uC2A4\uD2B8 \uC190\uC2E4: ${ktag}`, code: "UNSUPPORTED_ELEMENT" });
|
|
1680
1697
|
}
|
|
1681
1698
|
}
|
|
@@ -1692,7 +1709,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
1692
1709
|
if (isInDeletedRange(ctx)) {
|
|
1693
1710
|
if (t && ctx && !ctx.shared.track.warned) {
|
|
1694
1711
|
ctx.shared.track.warned = true;
|
|
1695
|
-
_optionalChain([ctx, 'access',
|
|
1712
|
+
_optionalChain([ctx, 'access', _34 => _34.warnings, 'optionalAccess', _35 => _35.push, 'call', _36 => _36({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" })]);
|
|
1696
1713
|
}
|
|
1697
1714
|
} else {
|
|
1698
1715
|
text += t;
|
|
@@ -1733,7 +1750,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
1733
1750
|
case "hyperlink": {
|
|
1734
1751
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1735
1752
|
if (url) {
|
|
1736
|
-
const safe =
|
|
1753
|
+
const safe = _chunkOVESZY5Rcjs.sanitizeHref.call(void 0, url);
|
|
1737
1754
|
if (safe) href = safe;
|
|
1738
1755
|
}
|
|
1739
1756
|
walk(child);
|
|
@@ -1882,7 +1899,7 @@ function collectImageBlocks(blocks, out, ownerCell, depth = 0) {
|
|
|
1882
1899
|
} else if (block.type === "table" && block.table) {
|
|
1883
1900
|
for (const row of block.table.cells) {
|
|
1884
1901
|
for (const cell2 of row) {
|
|
1885
|
-
if (_optionalChain([cell2, 'access',
|
|
1902
|
+
if (_optionalChain([cell2, 'access', _37 => _37.blocks, 'optionalAccess', _38 => _38.length])) collectImageBlocks(cell2.blocks, out, cell2, depth + 1);
|
|
1886
1903
|
}
|
|
1887
1904
|
}
|
|
1888
1905
|
}
|
|
@@ -1919,13 +1936,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1919
1936
|
}
|
|
1920
1937
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1921
1938
|
for (const path of allCandidates) {
|
|
1922
|
-
if (
|
|
1939
|
+
if (_chunkOVESZY5Rcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1923
1940
|
const file = zip.file(path);
|
|
1924
1941
|
if (!file) continue;
|
|
1925
1942
|
try {
|
|
1926
1943
|
const data = await file.async("uint8array");
|
|
1927
1944
|
decompressed.total += data.length;
|
|
1928
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1945
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1929
1946
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1930
1947
|
const mimeType = imageExtToMime(ext);
|
|
1931
1948
|
imageIndex++;
|
|
@@ -1934,10 +1951,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1934
1951
|
images.push(img);
|
|
1935
1952
|
break;
|
|
1936
1953
|
} catch (err) {
|
|
1937
|
-
if (err instanceof
|
|
1954
|
+
if (err instanceof _chunkOVESZY5Rcjs.KordocError) throw err;
|
|
1938
1955
|
}
|
|
1939
1956
|
}
|
|
1940
|
-
if (!img) _optionalChain([warnings, 'optionalAccess',
|
|
1957
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _39 => _39.push, 'call', _40 => _40({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
1941
1958
|
resolved.set(ref, img);
|
|
1942
1959
|
}
|
|
1943
1960
|
if (!img) {
|
|
@@ -1996,7 +2013,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1996
2013
|
}
|
|
1997
2014
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1998
2015
|
const name = new TextDecoder().decode(nameBytes);
|
|
1999
|
-
if (
|
|
2016
|
+
if (_chunkOVESZY5Rcjs.isPathTraversal.call(void 0, name)) {
|
|
2000
2017
|
pos = fileStart + compSize;
|
|
2001
2018
|
continue;
|
|
2002
2019
|
}
|
|
@@ -2014,16 +2031,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2014
2031
|
continue;
|
|
2015
2032
|
}
|
|
2016
2033
|
totalDecompressed += content.length * 2;
|
|
2017
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2034
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2018
2035
|
sectionNum++;
|
|
2019
2036
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2020
2037
|
} catch (e13) {
|
|
2021
2038
|
continue;
|
|
2022
2039
|
}
|
|
2023
2040
|
}
|
|
2024
|
-
if (blocks.length === 0) throw new (0,
|
|
2041
|
+
if (blocks.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2025
2042
|
applyPageText(blocks, shared);
|
|
2026
|
-
const markdown =
|
|
2043
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2027
2044
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2028
2045
|
}
|
|
2029
2046
|
async function resolveSectionPaths(zip) {
|
|
@@ -2037,18 +2054,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2037
2054
|
if (paths.length > 0) return paths;
|
|
2038
2055
|
}
|
|
2039
2056
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2040
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2057
|
+
return sectionFiles.map((f) => f.name).sort(_chunkOVESZY5Rcjs.compareSectionPaths);
|
|
2041
2058
|
}
|
|
2042
2059
|
function parseSectionPathsFromManifest(xml) {
|
|
2043
2060
|
const parser = createXmlParser();
|
|
2044
|
-
const doc = parser.parseFromString(
|
|
2061
|
+
const doc = parser.parseFromString(_chunkOVESZY5Rcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2045
2062
|
const items = doc.getElementsByTagName("opf:item");
|
|
2046
2063
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2047
2064
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2048
2065
|
for (let i = 0; i < items.length; i++) {
|
|
2049
2066
|
const item = items[i];
|
|
2050
2067
|
const id = item.getAttribute("id") || "";
|
|
2051
|
-
const href =
|
|
2068
|
+
const href = _chunkOVESZY5Rcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2052
2069
|
if (id && href) idToHref.set(id, href);
|
|
2053
2070
|
}
|
|
2054
2071
|
if (spine.length > 0) {
|
|
@@ -2059,7 +2076,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2059
2076
|
}
|
|
2060
2077
|
if (ordered.length > 0) return ordered;
|
|
2061
2078
|
}
|
|
2062
|
-
return Array.from(idToHref.values()).sort(
|
|
2079
|
+
return Array.from(idToHref.values()).sort(_chunkOVESZY5Rcjs.compareSectionPaths);
|
|
2063
2080
|
}
|
|
2064
2081
|
|
|
2065
2082
|
// src/hwpx/metadata.ts
|
|
@@ -2072,7 +2089,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2072
2089
|
const xml = await file.async("text");
|
|
2073
2090
|
if (decompressed) {
|
|
2074
2091
|
decompressed.total += xml.length * 2;
|
|
2075
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2092
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2076
2093
|
}
|
|
2077
2094
|
parseDublinCoreMetadata(xml, metadata);
|
|
2078
2095
|
if (metadata.title || metadata.author) return;
|
|
@@ -2082,13 +2099,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2082
2099
|
}
|
|
2083
2100
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2084
2101
|
const parser = createXmlParser();
|
|
2085
|
-
const doc = parser.parseFromString(
|
|
2102
|
+
const doc = parser.parseFromString(_chunkOVESZY5Rcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2086
2103
|
if (!doc.documentElement) return;
|
|
2087
2104
|
const getText = (tagNames) => {
|
|
2088
2105
|
for (const tag of tagNames) {
|
|
2089
2106
|
const els = doc.getElementsByTagName(tag);
|
|
2090
2107
|
if (els.length > 0) {
|
|
2091
|
-
const text = _optionalChain([els, 'access',
|
|
2108
|
+
const text = _optionalChain([els, 'access', _41 => _41[0], 'access', _42 => _42.textContent, 'optionalAccess', _43 => _43.trim, 'call', _44 => _44()]);
|
|
2092
2109
|
if (text) return text;
|
|
2093
2110
|
}
|
|
2094
2111
|
}
|
|
@@ -2107,7 +2124,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2107
2124
|
|
|
2108
2125
|
// src/hwpx/parser.ts
|
|
2109
2126
|
async function parseHwpxDocument(buffer, options) {
|
|
2110
|
-
|
|
2127
|
+
_chunkOVESZY5Rcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2111
2128
|
let zip;
|
|
2112
2129
|
try {
|
|
2113
2130
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2116,19 +2133,19 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2116
2133
|
}
|
|
2117
2134
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2118
2135
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2119
|
-
throw new (0,
|
|
2136
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2120
2137
|
}
|
|
2121
2138
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2122
2139
|
if (manifestFile) {
|
|
2123
2140
|
const manifestXml = await manifestFile.async("text");
|
|
2124
2141
|
if (isEncryptedHwpx(manifestXml)) {
|
|
2125
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
2142
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _45 => _45.filePath])) {
|
|
2126
2143
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
2127
2144
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
2128
2145
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2129
2146
|
}
|
|
2130
2147
|
}
|
|
2131
|
-
throw new (0,
|
|
2148
|
+
throw new (0, _chunkOVESZY5Rcjs.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.");
|
|
2132
2149
|
}
|
|
2133
2150
|
}
|
|
2134
2151
|
const decompressed = { total: 0 };
|
|
@@ -2137,9 +2154,9 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2137
2154
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2138
2155
|
const warnings = [];
|
|
2139
2156
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2140
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2157
|
+
if (sectionPaths.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2141
2158
|
metadata.pageCount = sectionPaths.length;
|
|
2142
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
2159
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _46 => _46.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2143
2160
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
2144
2161
|
const blocks = [];
|
|
2145
2162
|
const shared = createSectionShared();
|
|
@@ -2151,12 +2168,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2151
2168
|
try {
|
|
2152
2169
|
const xml = await file.async("text");
|
|
2153
2170
|
decompressed.total += xml.length * 2;
|
|
2154
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2171
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2155
2172
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2156
2173
|
parsedSections++;
|
|
2157
|
-
_optionalChain([options, 'optionalAccess',
|
|
2174
|
+
_optionalChain([options, 'optionalAccess', _47 => _47.onProgress, 'optionalCall', _48 => _48(parsedSections, totalTarget)]);
|
|
2158
2175
|
} catch (secErr) {
|
|
2159
|
-
if (secErr instanceof
|
|
2176
|
+
if (secErr instanceof _chunkOVESZY5Rcjs.KordocError) throw secErr;
|
|
2160
2177
|
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" });
|
|
2161
2178
|
}
|
|
2162
2179
|
}
|
|
@@ -2164,7 +2181,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2164
2181
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2165
2182
|
detectHwpxHeadings(blocks, styleMap);
|
|
2166
2183
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2167
|
-
const markdown =
|
|
2184
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2168
2185
|
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 };
|
|
2169
2186
|
}
|
|
2170
2187
|
|
|
@@ -2231,7 +2248,7 @@ function decompressStream(data) {
|
|
|
2231
2248
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2232
2249
|
}
|
|
2233
2250
|
function parseFileHeader(data) {
|
|
2234
|
-
if (data.length < 40) throw new (0,
|
|
2251
|
+
if (data.length < 40) throw new (0, _chunkOVESZY5Rcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2235
2252
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2236
2253
|
return {
|
|
2237
2254
|
signature: sig,
|
|
@@ -2364,7 +2381,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
2364
2381
|
const resolveAt = (byteOffset, extended) => {
|
|
2365
2382
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2366
2383
|
const idx = extended ? state.ctrlIdx : -1;
|
|
2367
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
2384
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _49 => _49(idx, ctrlId)]);
|
|
2368
2385
|
if (replacement) result += replacement;
|
|
2369
2386
|
if (extended) state.ctrlIdx++;
|
|
2370
2387
|
};
|
|
@@ -2735,7 +2752,7 @@ function extractHwp5Images(fileIndex, blocks, warnings) {
|
|
|
2735
2752
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
2736
2753
|
if (fileIndex) {
|
|
2737
2754
|
for (const entry of fileIndex) {
|
|
2738
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
2755
|
+
if (!_optionalChain([entry, 'optionalAccess', _50 => _50.name]) || !entry.content) continue;
|
|
2739
2756
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
2740
2757
|
if (!match) continue;
|
|
2741
2758
|
const idx = parseInt(match[1], 16);
|
|
@@ -2881,7 +2898,7 @@ function escapeRegExp(s) {
|
|
|
2881
2898
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2882
2899
|
}
|
|
2883
2900
|
function inlineImagesIntoMarkdown(markdown, images, opts) {
|
|
2884
|
-
const compress = _optionalChain([opts, 'optionalAccess',
|
|
2901
|
+
const compress = _optionalChain([opts, 'optionalAccess', _51 => _51.compress]) !== false;
|
|
2885
2902
|
let out = markdown;
|
|
2886
2903
|
for (const img of images) {
|
|
2887
2904
|
let bytes = img.data;
|
|
@@ -3901,22 +3918,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3901
3918
|
lenientCfb = parseLenientCfb(buffer);
|
|
3902
3919
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3903
3920
|
} catch (e21) {
|
|
3904
|
-
throw new (0,
|
|
3921
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3905
3922
|
}
|
|
3906
3923
|
}
|
|
3907
3924
|
const findStream = (path) => {
|
|
3908
3925
|
if (cfb) {
|
|
3909
3926
|
const entry = CFB.find(cfb, path);
|
|
3910
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
3927
|
+
return _optionalChain([entry, 'optionalAccess', _52 => _52.content]) ? Buffer.from(entry.content) : null;
|
|
3911
3928
|
}
|
|
3912
3929
|
return lenientCfb.findStream(path);
|
|
3913
3930
|
};
|
|
3914
3931
|
const headerData = findStream("/FileHeader");
|
|
3915
|
-
if (!headerData) throw new (0,
|
|
3932
|
+
if (!headerData) throw new (0, _chunkOVESZY5Rcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3916
3933
|
const header = parseFileHeader(headerData);
|
|
3917
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3918
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3919
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3934
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkOVESZY5Rcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3935
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3936
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkOVESZY5Rcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3920
3937
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3921
3938
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3922
3939
|
const metadata = {
|
|
@@ -3925,9 +3942,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
3925
3942
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3926
3943
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3927
3944
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3928
|
-
if (sections.length === 0) throw new (0,
|
|
3945
|
+
if (sections.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3929
3946
|
metadata.pageCount = sections.length;
|
|
3930
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3947
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _53 => _53.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3931
3948
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
3932
3949
|
const bodyBlocks = [];
|
|
3933
3950
|
const doc = createHwp5DocState();
|
|
@@ -3939,22 +3956,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3939
3956
|
const sectionData = sections[si];
|
|
3940
3957
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3941
3958
|
totalDecompressed += data.length;
|
|
3942
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3959
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3943
3960
|
const records = readRecords(data);
|
|
3944
3961
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3945
3962
|
bodyBlocks.push(...sectionBlocks);
|
|
3946
3963
|
parsedSections++;
|
|
3947
|
-
_optionalChain([options, 'optionalAccess',
|
|
3964
|
+
_optionalChain([options, 'optionalAccess', _54 => _54.onProgress, 'optionalCall', _55 => _55(parsedSections, totalTarget)]);
|
|
3948
3965
|
} catch (secErr) {
|
|
3949
|
-
if (secErr instanceof
|
|
3966
|
+
if (secErr instanceof _chunkOVESZY5Rcjs.KordocError) throw secErr;
|
|
3950
3967
|
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" });
|
|
3951
3968
|
}
|
|
3952
3969
|
}
|
|
3953
3970
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3954
3971
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3955
|
-
let flatBlocks =
|
|
3956
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3957
|
-
const deduped =
|
|
3972
|
+
let flatBlocks = _chunkOVESZY5Rcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3973
|
+
if (_optionalChain([options, 'optionalAccess', _56 => _56.dedupeRunningHeaders])) {
|
|
3974
|
+
const deduped = _chunkOVESZY5Rcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
3958
3975
|
const removed = flatBlocks.length - deduped.length;
|
|
3959
3976
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
3960
3977
|
flatBlocks = deduped;
|
|
@@ -3963,8 +3980,8 @@ function parseHwp5Document(buffer, options) {
|
|
|
3963
3980
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3964
3981
|
}
|
|
3965
3982
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3966
|
-
let markdown =
|
|
3967
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3983
|
+
let markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3984
|
+
if (_optionalChain([options, 'optionalAccess', _57 => _57.inlineImages]) && images.length > 0) {
|
|
3968
3985
|
try {
|
|
3969
3986
|
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
3970
3987
|
} catch (inlineErr) {
|
|
@@ -3976,7 +3993,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3976
3993
|
function parseDocInfoStream(cfb, compressed) {
|
|
3977
3994
|
try {
|
|
3978
3995
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
3979
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3996
|
+
if (!_optionalChain([entry, 'optionalAccess', _58 => _58.content])) return null;
|
|
3980
3997
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
3981
3998
|
const records = readRecords(data);
|
|
3982
3999
|
return parseDocInfo(records);
|
|
@@ -3997,7 +4014,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3997
4014
|
let baseFontSize = 0;
|
|
3998
4015
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
3999
4016
|
for (const b of blocks) {
|
|
4000
|
-
if (_optionalChain([b, 'access',
|
|
4017
|
+
if (_optionalChain([b, 'access', _59 => _59.style, 'optionalAccess', _60 => _60.fontSize]) && b.text) {
|
|
4001
4018
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4002
4019
|
}
|
|
4003
4020
|
}
|
|
@@ -4013,7 +4030,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4013
4030
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4014
4031
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4015
4032
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4016
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4033
|
+
if (_optionalChain([cs, 'optionalAccess', _61 => _61.fontSize]) > 0) {
|
|
4017
4034
|
baseFontSize = cs.fontSize / 10;
|
|
4018
4035
|
break;
|
|
4019
4036
|
}
|
|
@@ -4028,11 +4045,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4028
4045
|
if (text.length === 0 || text.length > 200) continue;
|
|
4029
4046
|
if (/^\d+$/.test(text)) continue;
|
|
4030
4047
|
let level = 0;
|
|
4031
|
-
if (_optionalChain([block, 'access',
|
|
4048
|
+
if (_optionalChain([block, 'access', _62 => _62.style, 'optionalAccess', _63 => _63.fontSize]) && baseFontSize > 0) {
|
|
4032
4049
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4033
|
-
if (ratio >=
|
|
4034
|
-
else if (ratio >=
|
|
4035
|
-
else if (ratio >=
|
|
4050
|
+
if (ratio >= _chunkOVESZY5Rcjs.HEADING_RATIO_H1) level = 1;
|
|
4051
|
+
else if (ratio >= _chunkOVESZY5Rcjs.HEADING_RATIO_H2) level = 2;
|
|
4052
|
+
else if (ratio >= _chunkOVESZY5Rcjs.HEADING_RATIO_H3) level = 3;
|
|
4036
4053
|
}
|
|
4037
4054
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4038
4055
|
if (level === 0) level = 2;
|
|
@@ -4048,7 +4065,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4048
4065
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4049
4066
|
try {
|
|
4050
4067
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4051
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4068
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _64 => _64.content])) return;
|
|
4052
4069
|
const data = Buffer.from(summaryEntry.content);
|
|
4053
4070
|
if (data.length < 48) return;
|
|
4054
4071
|
const numSets = data.readUInt32LE(24);
|
|
@@ -4081,7 +4098,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
4081
4098
|
const sections = [];
|
|
4082
4099
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4083
4100
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
4084
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4101
|
+
if (!_optionalChain([entry, 'optionalAccess', _65 => _65.content])) break;
|
|
4085
4102
|
try {
|
|
4086
4103
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
4087
4104
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -4095,13 +4112,13 @@ function findSections(cfb) {
|
|
|
4095
4112
|
const sections = [];
|
|
4096
4113
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4097
4114
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
4098
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4115
|
+
if (!_optionalChain([entry, 'optionalAccess', _66 => _66.content])) break;
|
|
4099
4116
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
4100
4117
|
}
|
|
4101
4118
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
4102
4119
|
for (const entry of cfb.FileIndex) {
|
|
4103
4120
|
if (sections.length >= MAX_SECTIONS) break;
|
|
4104
|
-
if (_optionalChain([entry, 'access',
|
|
4121
|
+
if (_optionalChain([entry, 'access', _67 => _67.name, 'optionalAccess', _68 => _68.startsWith, 'call', _69 => _69("Section")]) && entry.content) {
|
|
4105
4122
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
4106
4123
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
4107
4124
|
}
|
|
@@ -4117,7 +4134,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4117
4134
|
if (!raw) break;
|
|
4118
4135
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4119
4136
|
totalDecompressed += content.length;
|
|
4120
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4137
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4121
4138
|
sections.push({ idx: i, content });
|
|
4122
4139
|
}
|
|
4123
4140
|
if (sections.length === 0) {
|
|
@@ -4129,7 +4146,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4129
4146
|
if (raw) {
|
|
4130
4147
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4131
4148
|
totalDecompressed += content.length;
|
|
4132
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4149
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4133
4150
|
sections.push({ idx, content });
|
|
4134
4151
|
}
|
|
4135
4152
|
}
|
|
@@ -4146,7 +4163,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4146
4163
|
try {
|
|
4147
4164
|
const content = decryptViewText(raw, compressed);
|
|
4148
4165
|
totalDecompressed += content.length;
|
|
4149
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4166
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4150
4167
|
sections.push({ idx: i, content });
|
|
4151
4168
|
} catch (e26) {
|
|
4152
4169
|
break;
|
|
@@ -4247,9 +4264,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4247
4264
|
const applied = [];
|
|
4248
4265
|
for (const r of ranges) {
|
|
4249
4266
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4250
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
4267
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _70 => _70.href]) || r.end <= r.start) continue;
|
|
4251
4268
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4252
|
-
const href =
|
|
4269
|
+
const href = _chunkOVESZY5Rcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4253
4270
|
if (!href) continue;
|
|
4254
4271
|
const anchor = text.slice(r.start, r.end);
|
|
4255
4272
|
if (!anchor.trim()) continue;
|
|
@@ -4267,7 +4284,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4267
4284
|
}
|
|
4268
4285
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
4269
4286
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
4270
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
4287
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _71 => _71.docInfo, 'optionalAccess', _72 => _72.numberings, 'access', _73 => _73[nid - 1]]) : void 0;
|
|
4271
4288
|
if (numbering) {
|
|
4272
4289
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
4273
4290
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -4277,7 +4294,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4277
4294
|
}
|
|
4278
4295
|
}
|
|
4279
4296
|
} else if (ps.headType === 3) {
|
|
4280
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
4297
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _74 => _74.docInfo, 'optionalAccess', _75 => _75.bullets, 'access', _76 => _76[ps.numberingId - 1]]) : void 0;
|
|
4281
4298
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
4282
4299
|
}
|
|
4283
4300
|
}
|
|
@@ -4482,8 +4499,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4482
4499
|
let tableIdx = -1;
|
|
4483
4500
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4484
4501
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4485
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4486
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4502
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkOVESZY5Rcjs.MAX_ROWS);
|
|
4503
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkOVESZY5Rcjs.MAX_COLS);
|
|
4487
4504
|
tableIdx = i2;
|
|
4488
4505
|
break;
|
|
4489
4506
|
}
|
|
@@ -4523,7 +4540,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4523
4540
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
4524
4541
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
4525
4542
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
4526
|
-
if (_optionalChain([c, 'access',
|
|
4543
|
+
if (_optionalChain([c, 'access', _77 => _77.blocks, 'optionalAccess', _78 => _78.length])) ir.blocks = c.blocks;
|
|
4527
4544
|
if (c.isHeader) ir.isHeader = true;
|
|
4528
4545
|
return ir;
|
|
4529
4546
|
}));
|
|
@@ -4532,7 +4549,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4532
4549
|
return table3;
|
|
4533
4550
|
}
|
|
4534
4551
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4535
|
-
const table2 =
|
|
4552
|
+
const table2 = _chunkOVESZY5Rcjs.buildTable.call(void 0, cellRows);
|
|
4536
4553
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
4537
4554
|
return table2.rows > 0 ? table2 : null;
|
|
4538
4555
|
}
|
|
@@ -4549,8 +4566,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4549
4566
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4550
4567
|
const cs = rec.data.readUInt16LE(12);
|
|
4551
4568
|
const rs = rec.data.readUInt16LE(14);
|
|
4552
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4553
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4569
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkOVESZY5Rcjs.MAX_COLS);
|
|
4570
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkOVESZY5Rcjs.MAX_ROWS);
|
|
4554
4571
|
}
|
|
4555
4572
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4556
4573
|
const parts = [];
|
|
@@ -4560,7 +4577,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4560
4577
|
parts.push(``);
|
|
4561
4578
|
hasStructure = true;
|
|
4562
4579
|
} else if (b.type === "table" && b.table) {
|
|
4563
|
-
const flat =
|
|
4580
|
+
const flat = _chunkOVESZY5Rcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4564
4581
|
if (flat) parts.push(flat);
|
|
4565
4582
|
hasStructure = true;
|
|
4566
4583
|
} else if (b.text) {
|
|
@@ -4657,8 +4674,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
4657
4674
|
if (data.length < 73) return null;
|
|
4658
4675
|
const binDataId = data.readUInt16LE(71);
|
|
4659
4676
|
if (binDataId === 0) return null;
|
|
4660
|
-
const item = _optionalChain([ctx, 'access',
|
|
4661
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
4677
|
+
const item = _optionalChain([ctx, 'access', _79 => _79.docInfo, 'optionalAccess', _80 => _80.binData, 'access', _81 => _81[binDataId - 1]]);
|
|
4678
|
+
if (_optionalChain([item, 'optionalAccess', _82 => _82.kind]) === "link") {
|
|
4662
4679
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
4663
4680
|
return null;
|
|
4664
4681
|
}
|
|
@@ -16989,15 +17006,15 @@ function getElements(parent, tagName) {
|
|
|
16989
17006
|
const result = [];
|
|
16990
17007
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
16991
17008
|
if (result.length > 0) return result;
|
|
16992
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
17009
|
+
const nsNodes = _optionalChain([parent, 'access', _83 => _83.getElementsByTagNameNS, 'optionalCall', _84 => _84("*", tagName)]);
|
|
16993
17010
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
16994
17011
|
return result;
|
|
16995
17012
|
}
|
|
16996
17013
|
function getTextContent(el) {
|
|
16997
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
17014
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _85 => _85.textContent, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87()]), () => ( ""));
|
|
16998
17015
|
}
|
|
16999
17016
|
function parseXml(text) {
|
|
17000
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17017
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkOVESZY5Rcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17001
17018
|
}
|
|
17002
17019
|
function parseSharedStrings(xml) {
|
|
17003
17020
|
const doc = parseXml(xml);
|
|
@@ -17134,14 +17151,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17134
17151
|
const merge = mergeMap.get(key);
|
|
17135
17152
|
row.push({
|
|
17136
17153
|
text,
|
|
17137
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17138
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17154
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _88 => _88.colSpan]), () => ( 1)),
|
|
17155
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _89 => _89.rowSpan]), () => ( 1))
|
|
17139
17156
|
});
|
|
17140
17157
|
}
|
|
17141
17158
|
cellRows.push(row);
|
|
17142
17159
|
}
|
|
17143
17160
|
if (cellRows.length > 0) {
|
|
17144
|
-
const table2 =
|
|
17161
|
+
const table2 = _chunkOVESZY5Rcjs.buildTable.call(void 0, cellRows);
|
|
17145
17162
|
if (table2.rows > 0) {
|
|
17146
17163
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17147
17164
|
}
|
|
@@ -17149,12 +17166,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17149
17166
|
return blocks;
|
|
17150
17167
|
}
|
|
17151
17168
|
async function parseXlsxDocument(buffer, options) {
|
|
17152
|
-
|
|
17169
|
+
_chunkOVESZY5Rcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
17153
17170
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
17154
17171
|
const warnings = [];
|
|
17155
17172
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
17156
17173
|
if (!workbookFile) {
|
|
17157
|
-
throw new (0,
|
|
17174
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17158
17175
|
}
|
|
17159
17176
|
let sharedStrings = [];
|
|
17160
17177
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17163,7 +17180,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17163
17180
|
}
|
|
17164
17181
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
17165
17182
|
if (sheets.length === 0) {
|
|
17166
|
-
throw new (0,
|
|
17183
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17167
17184
|
}
|
|
17168
17185
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17169
17186
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17171,7 +17188,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17171
17188
|
relsMap = parseRels(await relsFile.async("text"));
|
|
17172
17189
|
}
|
|
17173
17190
|
let pageFilter = null;
|
|
17174
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17191
|
+
if (_optionalChain([options, 'optionalAccess', _90 => _90.pages])) {
|
|
17175
17192
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17176
17193
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
17177
17194
|
}
|
|
@@ -17180,7 +17197,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17180
17197
|
for (let i = 0; i < processedSheets; i++) {
|
|
17181
17198
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17182
17199
|
const sheet = sheets[i];
|
|
17183
|
-
_optionalChain([options, 'optionalAccess',
|
|
17200
|
+
_optionalChain([options, 'optionalAccess', _91 => _91.onProgress, 'optionalCall', _92 => _92(i + 1, processedSheets)]);
|
|
17184
17201
|
let sheetPath = relsMap.get(sheet.rId);
|
|
17185
17202
|
if (sheetPath) {
|
|
17186
17203
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17235,7 +17252,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17235
17252
|
} catch (e27) {
|
|
17236
17253
|
}
|
|
17237
17254
|
}
|
|
17238
|
-
const markdown =
|
|
17255
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17239
17256
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17240
17257
|
}
|
|
17241
17258
|
|
|
@@ -17642,11 +17659,11 @@ function processGlobals(records) {
|
|
|
17642
17659
|
let encrypted = false;
|
|
17643
17660
|
const firstBof = records[0];
|
|
17644
17661
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17645
|
-
throw new (0,
|
|
17662
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17646
17663
|
}
|
|
17647
17664
|
const bof = decodeBof(firstBof.data);
|
|
17648
17665
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17649
|
-
throw new (0,
|
|
17666
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17650
17667
|
}
|
|
17651
17668
|
let i = 1;
|
|
17652
17669
|
while (i < records.length) {
|
|
@@ -17754,14 +17771,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17754
17771
|
const merge = mergeMap.get(key);
|
|
17755
17772
|
row.push({
|
|
17756
17773
|
text: grid[r][c],
|
|
17757
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17758
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17774
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _93 => _93.colSpan]), () => ( 1)),
|
|
17775
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _94 => _94.rowSpan]), () => ( 1))
|
|
17759
17776
|
});
|
|
17760
17777
|
}
|
|
17761
17778
|
cellRows.push(row);
|
|
17762
17779
|
}
|
|
17763
17780
|
if (cellRows.length > 0) {
|
|
17764
|
-
const table2 =
|
|
17781
|
+
const table2 = _chunkOVESZY5Rcjs.buildTable.call(void 0, cellRows);
|
|
17765
17782
|
if (table2.rows > 0) {
|
|
17766
17783
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17767
17784
|
}
|
|
@@ -17774,21 +17791,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17774
17791
|
try {
|
|
17775
17792
|
cfb = parseLenientCfb(buf);
|
|
17776
17793
|
} catch (e) {
|
|
17777
|
-
throw new (0,
|
|
17794
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(
|
|
17778
17795
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17779
17796
|
);
|
|
17780
17797
|
}
|
|
17781
17798
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17782
17799
|
if (!wb) {
|
|
17783
|
-
throw new (0,
|
|
17800
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17784
17801
|
}
|
|
17785
17802
|
const records = readRecords2(wb);
|
|
17786
17803
|
if (records.length === 0) {
|
|
17787
|
-
throw new (0,
|
|
17804
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17788
17805
|
}
|
|
17789
17806
|
const firstBof = decodeBof(records[0].data);
|
|
17790
17807
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17791
|
-
throw new (0,
|
|
17808
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(
|
|
17792
17809
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17793
17810
|
);
|
|
17794
17811
|
}
|
|
@@ -17809,7 +17826,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17809
17826
|
}
|
|
17810
17827
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17811
17828
|
let pageFilter = null;
|
|
17812
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17829
|
+
if (_optionalChain([options, 'optionalAccess', _95 => _95.pages])) {
|
|
17813
17830
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17814
17831
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17815
17832
|
}
|
|
@@ -17818,7 +17835,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17818
17835
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17819
17836
|
const meta = globals.sheets[i];
|
|
17820
17837
|
if (meta.dt !== 0) continue;
|
|
17821
|
-
_optionalChain([options, 'optionalAccess',
|
|
17838
|
+
_optionalChain([options, 'optionalAccess', _96 => _96.onProgress, 'optionalCall', _97 => _97(i + 1, totalSheets)]);
|
|
17822
17839
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
17823
17840
|
if (bofIdx < 0) {
|
|
17824
17841
|
warnings.push({
|
|
@@ -17848,7 +17865,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17848
17865
|
pageCount: totalSheets
|
|
17849
17866
|
};
|
|
17850
17867
|
return {
|
|
17851
|
-
markdown:
|
|
17868
|
+
markdown: _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17852
17869
|
blocks: allBlocks,
|
|
17853
17870
|
metadata,
|
|
17854
17871
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17861,7 +17878,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17861
17878
|
|
|
17862
17879
|
// src/docx/equation.ts
|
|
17863
17880
|
function lname(el) {
|
|
17864
|
-
return el.localName || _optionalChain([el, 'access',
|
|
17881
|
+
return el.localName || _optionalChain([el, 'access', _98 => _98.tagName, 'optionalAccess', _99 => _99.replace, 'call', _100 => _100(/^[^:]+:/, "")]) || "";
|
|
17865
17882
|
}
|
|
17866
17883
|
function kids(parent, name) {
|
|
17867
17884
|
const out = [];
|
|
@@ -18234,7 +18251,7 @@ function isDisplayMath(el) {
|
|
|
18234
18251
|
// src/docx/parser.ts
|
|
18235
18252
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
18236
18253
|
function matchesLocal(el, localName2) {
|
|
18237
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
18254
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _101 => _101.tagName, 'optionalAccess', _102 => _102.endsWith, 'call', _103 => _103(`:${localName2}`)]), () => ( false)));
|
|
18238
18255
|
}
|
|
18239
18256
|
function effectiveChildElements(parent) {
|
|
18240
18257
|
const result = [];
|
|
@@ -18267,7 +18284,7 @@ function findElements(parent, localName2) {
|
|
|
18267
18284
|
const child = children[i];
|
|
18268
18285
|
if (child.nodeType === 1) {
|
|
18269
18286
|
const el = child;
|
|
18270
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
18287
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _104 => _104.tagName, 'optionalAccess', _105 => _105.endsWith, 'call', _106 => _106(`:${localName2}`)])) {
|
|
18271
18288
|
result.push(el);
|
|
18272
18289
|
}
|
|
18273
18290
|
walk(el);
|
|
@@ -18286,7 +18303,7 @@ function getAttr(el, localName2) {
|
|
|
18286
18303
|
return null;
|
|
18287
18304
|
}
|
|
18288
18305
|
function parseXml2(text) {
|
|
18289
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18306
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkOVESZY5Rcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18290
18307
|
}
|
|
18291
18308
|
function parseStyles(xml) {
|
|
18292
18309
|
const doc = parseXml2(xml);
|
|
@@ -18388,7 +18405,7 @@ function collectOmmlRoots(p) {
|
|
|
18388
18405
|
const child = children[i];
|
|
18389
18406
|
if (child.nodeType !== 1) continue;
|
|
18390
18407
|
const el = child;
|
|
18391
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
18408
|
+
const tag = el.localName || _optionalChain([el, 'access', _107 => _107.tagName, 'optionalAccess', _108 => _108.replace, 'call', _109 => _109(/^[^:]+:/, "")]) || "";
|
|
18392
18409
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
18393
18410
|
out.push(el);
|
|
18394
18411
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -18478,7 +18495,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18478
18495
|
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18479
18496
|
if (!text) return null;
|
|
18480
18497
|
const style = styles.get(styleId);
|
|
18481
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
18498
|
+
if (_optionalChain([style, 'optionalAccess', _110 => _110.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
18482
18499
|
return {
|
|
18483
18500
|
type: "heading",
|
|
18484
18501
|
text,
|
|
@@ -18487,8 +18504,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18487
18504
|
}
|
|
18488
18505
|
if (numId && numId !== "0") {
|
|
18489
18506
|
const numDef = numbering.get(numId);
|
|
18490
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
18491
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
18507
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _111 => _111.get, 'call', _112 => _112(ilvl)]);
|
|
18508
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _113 => _113.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
18492
18509
|
return { type: "list", text, listType };
|
|
18493
18510
|
}
|
|
18494
18511
|
const block = { type: "paragraph", text };
|
|
@@ -18571,7 +18588,7 @@ ${cell2.text}` : cell2.text;
|
|
|
18571
18588
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
18572
18589
|
})
|
|
18573
18590
|
);
|
|
18574
|
-
const table2 =
|
|
18591
|
+
const table2 = _chunkOVESZY5Rcjs.buildTable.call(void 0, cellRows);
|
|
18575
18592
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
18576
18593
|
return { type: "table", table: table2 };
|
|
18577
18594
|
}
|
|
@@ -18581,10 +18598,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
18581
18598
|
for (const el of effectiveChildElements(tc2)) {
|
|
18582
18599
|
if (matchesLocal(el, "p")) {
|
|
18583
18600
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18584
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
18601
|
+
if (_optionalChain([block, 'optionalAccess', _114 => _114.text])) parts.push(block.text);
|
|
18585
18602
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
18586
18603
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
18587
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
18604
|
+
if (_optionalChain([tb, 'optionalAccess', _115 => _115.text])) parts.push(tb.text);
|
|
18588
18605
|
}
|
|
18589
18606
|
} else if (matchesLocal(el, "tbl")) {
|
|
18590
18607
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -18614,7 +18631,7 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18614
18631
|
try {
|
|
18615
18632
|
const data = await imgFile.async("uint8array");
|
|
18616
18633
|
imgIdx++;
|
|
18617
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
18634
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _116 => _116.split, 'call', _117 => _117("."), 'access', _118 => _118.pop, 'call', _119 => _119(), 'optionalAccess', _120 => _120.toLowerCase, 'call', _121 => _121()]), () => ( "png"));
|
|
18618
18635
|
const mimeMap = {
|
|
18619
18636
|
png: "image/png",
|
|
18620
18637
|
jpg: "image/jpeg",
|
|
@@ -18638,12 +18655,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18638
18655
|
return { blocks, images };
|
|
18639
18656
|
}
|
|
18640
18657
|
async function parseDocxDocument(buffer, options) {
|
|
18641
|
-
|
|
18658
|
+
_chunkOVESZY5Rcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18642
18659
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18643
18660
|
const warnings = [];
|
|
18644
18661
|
const docFile = zip.file("word/document.xml");
|
|
18645
18662
|
if (!docFile) {
|
|
18646
|
-
throw new (0,
|
|
18663
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18647
18664
|
}
|
|
18648
18665
|
let rels = /* @__PURE__ */ new Map();
|
|
18649
18666
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18690,13 +18707,13 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18690
18707
|
const doc = parseXml2(docXml);
|
|
18691
18708
|
const body = findElements(doc, "body");
|
|
18692
18709
|
if (body.length === 0) {
|
|
18693
|
-
throw new (0,
|
|
18710
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18694
18711
|
}
|
|
18695
18712
|
const blocks = [];
|
|
18696
18713
|
const bodyEl = body[0];
|
|
18697
18714
|
const topLevel = effectiveChildElements(bodyEl);
|
|
18698
18715
|
for (const el of topLevel) {
|
|
18699
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
18716
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _122 => _122.tagName, 'optionalAccess', _123 => _123.split, 'call', _124 => _124(":"), 'access', _125 => _125.pop, 'call', _126 => _126()])));
|
|
18700
18717
|
if (localName2 === "p") {
|
|
18701
18718
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18702
18719
|
if (block) blocks.push(block);
|
|
@@ -18735,7 +18752,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18735
18752
|
}
|
|
18736
18753
|
}
|
|
18737
18754
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18738
|
-
const markdown =
|
|
18755
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18739
18756
|
return {
|
|
18740
18757
|
markdown,
|
|
18741
18758
|
blocks,
|
|
@@ -18758,7 +18775,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18758
18775
|
}
|
|
18759
18776
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18760
18777
|
const normalized = text.replace(/ /g, " ");
|
|
18761
|
-
const xml =
|
|
18778
|
+
const xml = _chunkOVESZY5Rcjs.stripDtd.call(void 0, normalized);
|
|
18762
18779
|
const warnings = [];
|
|
18763
18780
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18764
18781
|
onError: (_level, msg2) => {
|
|
@@ -18786,7 +18803,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18786
18803
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18787
18804
|
}
|
|
18788
18805
|
const blocks = [];
|
|
18789
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
18806
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _127 => _127.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18790
18807
|
let sectionIdx = 0;
|
|
18791
18808
|
const children = body.childNodes;
|
|
18792
18809
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18798,7 +18815,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18798
18815
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18799
18816
|
}
|
|
18800
18817
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18801
|
-
const markdown =
|
|
18818
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18802
18819
|
return {
|
|
18803
18820
|
markdown,
|
|
18804
18821
|
blocks,
|
|
@@ -18884,7 +18901,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
18884
18901
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
18885
18902
|
const text = extractParagraphText(el);
|
|
18886
18903
|
if (!text) return;
|
|
18887
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
18904
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _128 => _128.headingLevel]) != null) {
|
|
18888
18905
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
18889
18906
|
} else {
|
|
18890
18907
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -18956,7 +18973,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18956
18973
|
const cellRows = grid.map(
|
|
18957
18974
|
(row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18958
18975
|
);
|
|
18959
|
-
const table2 =
|
|
18976
|
+
const table2 = _chunkOVESZY5Rcjs.buildTable.call(void 0, cellRows);
|
|
18960
18977
|
const caption = extractShapeCaption(el);
|
|
18961
18978
|
if (caption.text && caption.before) {
|
|
18962
18979
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -19216,7 +19233,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
19216
19233
|
(match, prefix, suffix) => {
|
|
19217
19234
|
const label = prefix + suffix;
|
|
19218
19235
|
const normalizedLabel = normalizeLabel(label);
|
|
19219
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19236
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _129 => _129.has, 'call', _130 => _130(normalizedLabel)])) return match;
|
|
19220
19237
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
19221
19238
|
if (matchKey === void 0) return match;
|
|
19222
19239
|
const newValue = values.consume(matchKey);
|
|
@@ -19466,8 +19483,8 @@ function extractFromTable(table2) {
|
|
|
19466
19483
|
if (table2.cols >= 2) {
|
|
19467
19484
|
for (let r = 0; r < table2.rows; r++) {
|
|
19468
19485
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
19469
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
19470
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
19486
|
+
const labelCell = _optionalChain([table2, 'access', _131 => _131.cells, 'access', _132 => _132[r], 'optionalAccess', _133 => _133[c]]);
|
|
19487
|
+
const valueCell = _optionalChain([table2, 'access', _134 => _134.cells, 'access', _135 => _135[r], 'optionalAccess', _136 => _136[c + 1]]);
|
|
19471
19488
|
if (!labelCell || !valueCell) continue;
|
|
19472
19489
|
if (isLabelCell(labelCell.text)) {
|
|
19473
19490
|
fields.push({
|
|
@@ -19489,8 +19506,8 @@ function extractFromTable(table2) {
|
|
|
19489
19506
|
if (allLabels) {
|
|
19490
19507
|
for (let r = 1; r < table2.rows; r++) {
|
|
19491
19508
|
for (let c = 0; c < table2.cols; c++) {
|
|
19492
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19493
|
-
const value = _nullishCoalesce(_optionalChain([table2, 'access',
|
|
19509
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _137 => _137[c], 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()]), () => ( ""));
|
|
19510
|
+
const value = _nullishCoalesce(_optionalChain([table2, 'access', _141 => _141.cells, 'access', _142 => _142[r], 'optionalAccess', _143 => _143[c], 'optionalAccess', _144 => _144.text, 'access', _145 => _145.trim, 'call', _146 => _146()]), () => ( ""));
|
|
19494
19511
|
if (label && value) {
|
|
19495
19512
|
fields.push({ label, value, row: r, col: c });
|
|
19496
19513
|
}
|
|
@@ -19583,7 +19600,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
19583
19600
|
for (const table2 of allTables) {
|
|
19584
19601
|
for (let r = 0; r < table2.rows; r++) {
|
|
19585
19602
|
for (let c = 0; c < table2.cols; c++) {
|
|
19586
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
19603
|
+
const cell2 = _optionalChain([table2, 'access', _147 => _147.cells, 'access', _148 => _148[r], 'optionalAccess', _149 => _149[c]]);
|
|
19587
19604
|
if (!cell2) continue;
|
|
19588
19605
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
19589
19606
|
if (result) {
|
|
@@ -19615,7 +19632,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19615
19632
|
out.push(block.table);
|
|
19616
19633
|
for (const row of block.table.cells) {
|
|
19617
19634
|
for (const cell2 of row) {
|
|
19618
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
19635
|
+
if (_optionalChain([cell2, 'optionalAccess', _150 => _150.blocks, 'optionalAccess', _151 => _151.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
19619
19636
|
}
|
|
19620
19637
|
}
|
|
19621
19638
|
}
|
|
@@ -19626,7 +19643,7 @@ function coveredPositions(table2) {
|
|
|
19626
19643
|
for (let r = 0; r < table2.rows; r++) {
|
|
19627
19644
|
for (let c = 0; c < table2.cols; c++) {
|
|
19628
19645
|
if (covered.has(`${r},${c}`)) continue;
|
|
19629
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
19646
|
+
const cell2 = _optionalChain([table2, 'access', _152 => _152.cells, 'access', _153 => _153[r], 'optionalAccess', _154 => _154[c]]);
|
|
19630
19647
|
if (!cell2) continue;
|
|
19631
19648
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
19632
19649
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -19656,12 +19673,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
19656
19673
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
19657
19674
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
19658
19675
|
if (!normalizedCellLabel) continue;
|
|
19659
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19676
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _155 => _155.has, 'call', _156 => _156(normalizedCellLabel)])) continue;
|
|
19660
19677
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
19661
19678
|
if (matchKey === void 0) continue;
|
|
19662
19679
|
const newValue = values.consume(matchKey);
|
|
19663
19680
|
if (newValue === void 0) continue;
|
|
19664
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19681
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _157 => _157.has, 'call', _158 => _158(valueCell)])) {
|
|
19665
19682
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19666
19683
|
} else {
|
|
19667
19684
|
valueCell.text = newValue;
|
|
@@ -19687,10 +19704,10 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
19687
19704
|
for (let c = 0; c < table2.cols; c++) {
|
|
19688
19705
|
if (covered.has(`${r},${c}`)) continue;
|
|
19689
19706
|
const headerCell = headerRow[c];
|
|
19690
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
19707
|
+
const valueCell = _optionalChain([table2, 'access', _159 => _159.cells, 'access', _160 => _160[r], 'optionalAccess', _161 => _161[c]]);
|
|
19691
19708
|
if (!headerCell || !valueCell) continue;
|
|
19692
19709
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19693
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19710
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _162 => _162.has, 'call', _163 => _163(headerLabel)])) continue;
|
|
19694
19711
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
19695
19712
|
if (matchKey === void 0) continue;
|
|
19696
19713
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -19716,7 +19733,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
19716
19733
|
let pos = 0;
|
|
19717
19734
|
for (const seg of segments) {
|
|
19718
19735
|
const nlabel = normalizeLabel(seg.label);
|
|
19719
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19736
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _164 => _164.has, 'call', _165 => _165(nlabel)])) continue;
|
|
19720
19737
|
const matchKey = findMatchingKey(nlabel, values);
|
|
19721
19738
|
if (matchKey === void 0) continue;
|
|
19722
19739
|
const newValue = values.consume(matchKey);
|
|
@@ -20284,19 +20301,19 @@ function parseCentralDirectory(buf) {
|
|
|
20284
20301
|
}
|
|
20285
20302
|
}
|
|
20286
20303
|
}
|
|
20287
|
-
if (eocdOffset < 0) throw new (0,
|
|
20304
|
+
if (eocdOffset < 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20288
20305
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20289
20306
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20290
20307
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20291
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20308
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20292
20309
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20293
|
-
throw new (0,
|
|
20310
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20294
20311
|
}
|
|
20295
20312
|
const decoder = new TextDecoder("utf-8");
|
|
20296
20313
|
const entries = [];
|
|
20297
20314
|
let pos = cdOffset;
|
|
20298
20315
|
for (let i = 0; i < totalEntries; i++) {
|
|
20299
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20316
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20300
20317
|
const flags = view.getUint16(pos + 8, true);
|
|
20301
20318
|
const method = view.getUint16(pos + 10, true);
|
|
20302
20319
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20307,7 +20324,7 @@ function parseCentralDirectory(buf) {
|
|
|
20307
20324
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20308
20325
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20309
20326
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20310
|
-
throw new (0,
|
|
20327
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20311
20328
|
}
|
|
20312
20329
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20313
20330
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20336,11 +20353,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20336
20353
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20337
20354
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20338
20355
|
for (const name of replacements.keys()) {
|
|
20339
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20356
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkOVESZY5Rcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20340
20357
|
}
|
|
20341
20358
|
if (additions) {
|
|
20342
20359
|
for (const name of additions.keys()) {
|
|
20343
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20360
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkOVESZY5Rcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20344
20361
|
}
|
|
20345
20362
|
}
|
|
20346
20363
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20359,7 +20376,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20359
20376
|
offset += seg.length;
|
|
20360
20377
|
continue;
|
|
20361
20378
|
}
|
|
20362
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20379
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkOVESZY5Rcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20363
20380
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20364
20381
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20365
20382
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20465,7 +20482,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20465
20482
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20466
20483
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20467
20484
|
if (sectionPaths.length === 0) {
|
|
20468
|
-
throw new (0,
|
|
20485
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20469
20486
|
}
|
|
20470
20487
|
const normalizedValues = normalizeValues(values);
|
|
20471
20488
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20538,7 +20555,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20538
20555
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
20539
20556
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
20540
20557
|
if (!normalizedCellLabel) continue;
|
|
20541
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20558
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _166 => _166.has, 'call', _167 => _167(normalizedCellLabel)])) continue;
|
|
20542
20559
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
20543
20560
|
if (matchKey === void 0) continue;
|
|
20544
20561
|
if (patternApplied.has(valueCell)) {
|
|
@@ -20596,7 +20613,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20596
20613
|
const dataCells = table2.rows[rowIdx];
|
|
20597
20614
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
20598
20615
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
20599
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20616
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _168 => _168.has, 'call', _169 => _169(headerLabel)])) continue;
|
|
20600
20617
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
20601
20618
|
if (matchKey === void 0) continue;
|
|
20602
20619
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -20629,11 +20646,11 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20629
20646
|
}
|
|
20630
20647
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20631
20648
|
const existing = ledger.get(para2);
|
|
20632
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20649
|
+
if (_optionalChain([existing, 'optionalAccess', _170 => _170.fullText]) !== void 0) continue;
|
|
20633
20650
|
const text = matchText(para2);
|
|
20634
20651
|
for (const seg of scanInlineSegments(text)) {
|
|
20635
20652
|
const nlabel = normalizeLabel(seg.label);
|
|
20636
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20653
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _171 => _171.has, 'call', _172 => _172(nlabel)])) continue;
|
|
20637
20654
|
const matchKey = findMatchingKey(nlabel, cursor);
|
|
20638
20655
|
if (matchKey === void 0) continue;
|
|
20639
20656
|
const newValue = cursor.consume(matchKey);
|
|
@@ -20871,8 +20888,8 @@ function charWidthEm1000(cp) {
|
|
|
20871
20888
|
var SPACE_EM_FIXED = 500;
|
|
20872
20889
|
var SPACE_EM_FONT = 300;
|
|
20873
20890
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20874
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20875
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20891
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _173 => _173.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20892
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _174 => _174.spacingPct]), () => ( 0));
|
|
20876
20893
|
let em = 0;
|
|
20877
20894
|
for (const ch of text) {
|
|
20878
20895
|
const cp = ch.codePointAt(0);
|
|
@@ -20885,8 +20902,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20885
20902
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20886
20903
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20887
20904
|
const EPS = 0.5;
|
|
20888
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20889
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20905
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _175 => _175.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20906
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _176 => _176.spacingPct]), () => ( 0));
|
|
20890
20907
|
const k = height * ratioPct / 100 / 1e3;
|
|
20891
20908
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20892
20909
|
const charW2 = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20954,7 +20971,8 @@ function fitRatioForFewerLines(text, firstWidth, contWidth, height, baseRatio, m
|
|
|
20954
20971
|
|
|
20955
20972
|
// src/hwpx/gaejosik.ts
|
|
20956
20973
|
var GAEJOSIK_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
20957
|
-
function gaejosikMarker(depth) {
|
|
20974
|
+
function gaejosikMarker(depth, bullet2 = "\u25CB") {
|
|
20975
|
+
if (depth === 1) return bullet2;
|
|
20958
20976
|
return GAEJOSIK_BULLETS[Math.min(depth, GAEJOSIK_BULLETS.length - 1)];
|
|
20959
20977
|
}
|
|
20960
20978
|
function gaejosikSizes(bodyHeight, ov = {}) {
|
|
@@ -20990,11 +21008,11 @@ function gaejosikSpaceBefore(depth, bodyHeight) {
|
|
|
20990
21008
|
const ui = [3e3, 2e3, 1200, 600][Math.min(depth, 3)];
|
|
20991
21009
|
return Math.round(ui * s);
|
|
20992
21010
|
}
|
|
20993
|
-
function gaejosikLevelIndent(depth, bodyHeight, sizes = {}) {
|
|
21011
|
+
function gaejosikLevelIndent(depth, bodyHeight, sizes = {}, bullet2 = "\u25CB") {
|
|
20994
21012
|
const lefts = [0, 1, 1.5, 2];
|
|
20995
21013
|
const left = depth <= 3 ? Math.round(lefts[depth] * bodyHeight) : Math.round((2 + (depth - 3) * 0.5) * bodyHeight);
|
|
20996
21014
|
const h = depth === 0 ? gaejosikSizes(bodyHeight, sizes).dae : bodyHeight;
|
|
20997
|
-
return { left, indent: -markerWidth(gaejosikMarker(depth), h) };
|
|
21015
|
+
return { left, indent: -markerWidth(gaejosikMarker(depth, bullet2), h) };
|
|
20998
21016
|
}
|
|
20999
21017
|
function gaejosikChamIndent(bodyHeight, sizes = {}) {
|
|
21000
21018
|
const cham = gaejosikSizes(bodyHeight, sizes).cham;
|
|
@@ -21062,16 +21080,20 @@ function bodyTitleGeom(bodyHeight, ov = {}) {
|
|
|
21062
21080
|
}
|
|
21063
21081
|
|
|
21064
21082
|
// src/hwpx/gongmun.ts
|
|
21065
|
-
var OFFICIAL_MARGINS = { top: 20, bottom:
|
|
21083
|
+
var OFFICIAL_MARGINS = { top: 20, bottom: 15, left: 20, right: 15 };
|
|
21066
21084
|
var GAEJOSIK_MARGINS = { top: 15, bottom: 15, left: 20, right: 20 };
|
|
21067
21085
|
var GAEJOSIK_HEADER_FOOTER = 4251;
|
|
21068
21086
|
var PRESET_DEFAULTS = {
|
|
21069
|
-
|
|
21087
|
+
// 서울시 실결재 104건 중 12pt 64건(13pt 30, 15pt 5) — 지배값을 기본으로 사용.
|
|
21088
|
+
official: { bodyPt: 12, lineSpacing: 160, numbering: "standard" },
|
|
21070
21089
|
report: { bodyPt: 15, lineSpacing: 160, numbering: "report" },
|
|
21071
|
-
|
|
21090
|
+
// 실측 추진계획안: □ → ㅇ → * 계층.
|
|
21091
|
+
plan: { bodyPt: 15, lineSpacing: 160, numbering: "report" },
|
|
21072
21092
|
notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
21073
21093
|
minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" },
|
|
21074
|
-
gaejosik: { bodyPt: 15, lineSpacing: 160, numbering: "gaejosik" }
|
|
21094
|
+
gaejosik: { bodyPt: 15, lineSpacing: 160, numbering: "gaejosik" },
|
|
21095
|
+
// 보도자료 — 실측(국토부 실물): 본문 바탕 14pt 160%, □→ㅇ→*(각주) 부호
|
|
21096
|
+
press: { bodyPt: 14, lineSpacing: 160, numbering: "report" }
|
|
21075
21097
|
};
|
|
21076
21098
|
var PRESET_ALIAS = {
|
|
21077
21099
|
official: "official",
|
|
@@ -21094,7 +21116,9 @@ var PRESET_ALIAS = {
|
|
|
21094
21116
|
\uAC1C\uC870\uC2DD: "gaejosik",
|
|
21095
21117
|
\uAC1C\uC870\uC2DD\uBCF4\uACE0\uC11C: "gaejosik",
|
|
21096
21118
|
\uC815\uBD80\uBCF4\uACE0\uC11C: "gaejosik",
|
|
21097
|
-
\uC815\uBD80\uD45C\uC900\uAC1C\uC870\uC2DD\uBCF4\uACE0\uC11C: "gaejosik"
|
|
21119
|
+
\uC815\uBD80\uD45C\uC900\uAC1C\uC870\uC2DD\uBCF4\uACE0\uC11C: "gaejosik",
|
|
21120
|
+
press: "press",
|
|
21121
|
+
\uBCF4\uB3C4\uC790\uB8CC: "press"
|
|
21098
21122
|
};
|
|
21099
21123
|
function normalizeGongmunPreset(preset) {
|
|
21100
21124
|
if (!preset) return "official";
|
|
@@ -21103,7 +21127,46 @@ function normalizeGongmunPreset(preset) {
|
|
|
21103
21127
|
function usesReportFonts(preset) {
|
|
21104
21128
|
return preset === "gaejosik" || preset === "report" || preset === "plan";
|
|
21105
21129
|
}
|
|
21130
|
+
function usesAsteriskThird(preset) {
|
|
21131
|
+
return preset === "plan" || preset === "press";
|
|
21132
|
+
}
|
|
21133
|
+
function needsGaejosikAssets(gongmun) {
|
|
21134
|
+
return usesReportFonts(gongmun.preset) || gongmun.cover !== null || gongmun.toc;
|
|
21135
|
+
}
|
|
21136
|
+
function assertFiniteRange(name, value, min, max) {
|
|
21137
|
+
if (!Number.isFinite(value) || value < min || value > max) {
|
|
21138
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
21139
|
+
}
|
|
21140
|
+
}
|
|
21141
|
+
function validateGongmunOptions(opts) {
|
|
21142
|
+
if (opts.bodyPt !== void 0) assertFiniteRange("bodyPt", opts.bodyPt, 6, 40);
|
|
21143
|
+
if (opts.lineSpacing !== void 0) assertFiniteRange("lineSpacing", opts.lineSpacing, 50, 300);
|
|
21144
|
+
if (typeof opts.autoFit === "object" && opts.autoFit.minRatio !== void 0) {
|
|
21145
|
+
assertFiniteRange("autoFit.minRatio", opts.autoFit.minRatio, 50, 99);
|
|
21146
|
+
}
|
|
21147
|
+
if (opts.margins) {
|
|
21148
|
+
for (const side of ["top", "bottom", "left", "right"]) {
|
|
21149
|
+
const value = opts.margins[side];
|
|
21150
|
+
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
21151
|
+
}
|
|
21152
|
+
if (opts.margins.left + opts.margins.right >= 210) {
|
|
21153
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
21154
|
+
}
|
|
21155
|
+
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
21156
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
21157
|
+
}
|
|
21158
|
+
}
|
|
21159
|
+
if (opts.sizes) {
|
|
21160
|
+
for (const [key, value] of Object.entries(opts.sizes)) {
|
|
21161
|
+
if (value !== void 0) assertFiniteRange(`sizes.${key}`, value, 6, 60);
|
|
21162
|
+
}
|
|
21163
|
+
}
|
|
21164
|
+
if (opts.approval && opts.approval.length > 6) {
|
|
21165
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("approval must contain at most 6 labels");
|
|
21166
|
+
}
|
|
21167
|
+
}
|
|
21106
21168
|
function resolveGongmun(opts) {
|
|
21169
|
+
validateGongmunOptions(opts);
|
|
21107
21170
|
const preset = normalizeGongmunPreset(opts.preset);
|
|
21108
21171
|
const d = PRESET_DEFAULTS[preset];
|
|
21109
21172
|
const bodyPt = _nullishCoalesce(opts.bodyPt, () => ( d.bodyPt));
|
|
@@ -21111,29 +21174,44 @@ function resolveGongmun(opts) {
|
|
|
21111
21174
|
const coverOn = opts.cover !== void 0 ? opts.cover !== false : preset === "gaejosik";
|
|
21112
21175
|
const coverOpts = typeof opts.cover === "object" ? opts.cover : {};
|
|
21113
21176
|
const gaejosik = preset === "gaejosik";
|
|
21177
|
+
const reportFamily = gaejosik || preset === "report" || preset === "plan" || preset === "notice" || preset === "press";
|
|
21114
21178
|
return {
|
|
21115
21179
|
preset,
|
|
21116
21180
|
bodyFont: _nullishCoalesce(opts.bodyFont, () => ( "myeongjo")),
|
|
21117
21181
|
bodyHeight: Math.round(bodyPt * 100),
|
|
21118
21182
|
lineSpacing: _nullishCoalesce(opts.lineSpacing, () => ( d.lineSpacing)),
|
|
21119
21183
|
numbering: _nullishCoalesce(opts.numbering, () => ( d.numbering)),
|
|
21120
|
-
margins: _nullishCoalesce(opts.margins, () => ( (
|
|
21184
|
+
margins: _nullishCoalesce(opts.margins, () => ( (reportFamily ? GAEJOSIK_MARGINS : OFFICIAL_MARGINS))),
|
|
21121
21185
|
centerTitle: _nullishCoalesce(opts.centerTitle, () => ( true)),
|
|
21122
21186
|
autoFitMinRatio,
|
|
21123
|
-
|
|
21124
|
-
|
|
21187
|
+
// 보도자료는 머리박스가 1페이지 최상단을 차지하는 서식이라 표지·목차와 양립 불가 —
|
|
21188
|
+
// 켜면 머리박스가 표지에 얹히고 25pt 제목·부제가 유실된다 (docHead 프리셋 게이팅과 동일 관례)
|
|
21189
|
+
cover: coverOn && preset !== "press" ? { date: _nullishCoalesce(coverOpts.date, () => ( null)), org: _nullishCoalesce(coverOpts.org, () => ( "")) } : null,
|
|
21190
|
+
toc: preset !== "press" && (_nullishCoalesce(opts.toc, () => ( gaejosik))),
|
|
21125
21191
|
fonts: _nullishCoalesce(opts.fonts, () => ( {})),
|
|
21126
21192
|
sizes: _nullishCoalesce(opts.sizes, () => ( {})),
|
|
21127
21193
|
// 쪽번호 — 보고서 계열 관행(실측: 2_보고서 양식·추진계획·공고문 전부 하단 중앙)
|
|
21128
21194
|
pageNumbers: _nullishCoalesce(opts.pageNumbers, () => ( (gaejosik || preset === "report" || preset === "plan"))),
|
|
21129
|
-
|
|
21195
|
+
// 머리말·꼬리말 — 실측: 보고서 계열 15mm(GT3·t2·춘천·브라더), 공고·보도 10mm,
|
|
21196
|
+
// 기안문 0(실결재 41/60건 h0/f0)
|
|
21197
|
+
headerFooter: usesReportFonts(preset) ? GAEJOSIK_HEADER_FOOTER : preset === "notice" || preset === "press" ? 2835 : 0,
|
|
21130
21198
|
// "끝." — 기안문 규정(본문 끝 2타+"끝."). 그 외는 opt-in
|
|
21131
21199
|
endMark: _nullishCoalesce(opts.endMark, () => ( preset === "official")),
|
|
21132
21200
|
approval: opts.approval && opts.approval.length > 0 ? opts.approval : null,
|
|
21133
21201
|
// 본문 제목박스 — 실측(GT3·GT12): 목차 뒤 본문 시작에 제목 반복. 표지 켜진 개조식 기본
|
|
21134
21202
|
bodyTitleBox: _nullishCoalesce(opts.bodyTitleBox, () => ( (gaejosik && coverOn))),
|
|
21135
|
-
// h2 말머리 —
|
|
21136
|
-
h2Marker: _nullishCoalesce(opts.h2Marker, () => ( (preset === "report" || preset === "plan" ? "box" : "none")))
|
|
21203
|
+
// h2 말머리 — 실측: 보고서 양식 □ 대항목(QA-2), 공고문 아라비아("1. 사업개요", 바이오헬스 실측)
|
|
21204
|
+
h2Marker: _nullishCoalesce(opts.h2Marker, () => ( (preset === "report" || preset === "plan" ? "box" : preset === "notice" ? "number" : "none"))),
|
|
21205
|
+
// 2단계 부호 — 실결재 기안문·공고문 ㅇ 지배(60건 중 ㅇ134:○5), 보고서 양식 계열 ○
|
|
21206
|
+
bullet2: _nullishCoalesce(opts.bullet2, () => ( (preset === "plan" || preset === "notice" || preset === "press" ? "\u3147" : "\u25CB"))),
|
|
21207
|
+
// 단일 형제 부호 생략 — 규정이지만 부호 없는 계단이 실무 눈에 어색 (실무자 QA)
|
|
21208
|
+
suppressSingle: _nullishCoalesce(opts.suppressSingle, () => ( false)),
|
|
21209
|
+
docHead: preset === "official" && opts.docHead ? opts.docHead : null,
|
|
21210
|
+
docFoot: preset === "official" && opts.docFoot ? opts.docFoot : null,
|
|
21211
|
+
reportInfo: _optionalChain([opts, 'access', _177 => _177.reportInfo, 'optionalAccess', _178 => _178.trim, 'call', _179 => _179()]) || null,
|
|
21212
|
+
noticeHead: preset === "notice" && opts.noticeHead ? opts.noticeHead : null,
|
|
21213
|
+
// 보도자료 머리박스는 프리셋 자체가 요구 — 옵션 미지정이어도 빈 객체
|
|
21214
|
+
press: preset === "press" ? _nullishCoalesce(opts.press, () => ( {})) : null
|
|
21137
21215
|
};
|
|
21138
21216
|
}
|
|
21139
21217
|
var HANGUL_INITIALS = [0, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18];
|
|
@@ -21151,6 +21229,7 @@ function circledHangul(n) {
|
|
|
21151
21229
|
return String.fromCodePoint(12910 + n % 14);
|
|
21152
21230
|
}
|
|
21153
21231
|
var REPORT_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
21232
|
+
var ASTERISK_BULLETS = ["\u25A1", "\u25CB", "*", "\u318D"];
|
|
21154
21233
|
function standardMarker(depth, n) {
|
|
21155
21234
|
switch (depth) {
|
|
21156
21235
|
case 0:
|
|
@@ -21173,17 +21252,19 @@ function standardMarker(depth, n) {
|
|
|
21173
21252
|
return circledHangul(n);
|
|
21174
21253
|
}
|
|
21175
21254
|
}
|
|
21176
|
-
function reportMarker(depth) {
|
|
21177
|
-
|
|
21255
|
+
function reportMarker(depth, bullet2 = "\u25CB", asteriskThird = false) {
|
|
21256
|
+
const bullets = asteriskThird ? ASTERISK_BULLETS : REPORT_BULLETS;
|
|
21257
|
+
const m = bullets[Math.min(depth, bullets.length - 1)];
|
|
21258
|
+
return depth === 1 ? bullet2 : m;
|
|
21178
21259
|
}
|
|
21179
21260
|
function markerWidth(marker, bodyHeight) {
|
|
21180
21261
|
let em = SPACE_EM_FIXED;
|
|
21181
21262
|
for (const c of marker) em += charWidthEm1000(c.codePointAt(0));
|
|
21182
21263
|
return Math.round(em / 1e3 * bodyHeight);
|
|
21183
21264
|
}
|
|
21184
|
-
function levelIndent(depth, bodyHeight, numbering, sizes = {}) {
|
|
21185
|
-
if (numbering === "gaejosik") return gaejosikLevelIndent(depth, bodyHeight, sizes);
|
|
21186
|
-
const marker = numbering === "report" ? reportMarker(depth) : standardMarker(depth, 0);
|
|
21265
|
+
function levelIndent(depth, bodyHeight, numbering, sizes = {}, bullet2 = "\u25CB", asteriskThird = false) {
|
|
21266
|
+
if (numbering === "gaejosik") return gaejosikLevelIndent(depth, bodyHeight, sizes, bullet2);
|
|
21267
|
+
const marker = numbering === "report" ? reportMarker(depth, bullet2, asteriskThird) : standardMarker(depth, 0);
|
|
21187
21268
|
return { left: Math.round(depth * bodyHeight), indent: -markerWidth(marker, bodyHeight) };
|
|
21188
21269
|
}
|
|
21189
21270
|
function computeSuppression(depths) {
|
|
@@ -21200,8 +21281,10 @@ function computeSuppression(depths) {
|
|
|
21200
21281
|
return keys.map((k) => (_nullishCoalesce(counts.get(k), () => ( 0))) <= 1);
|
|
21201
21282
|
}
|
|
21202
21283
|
var GongmunNumberer = (_class3 = class {
|
|
21203
|
-
constructor(numbering) {;_class3.prototype.__init5.call(this);
|
|
21284
|
+
constructor(numbering, bullet2 = "\u25CB", asteriskThird = false) {;_class3.prototype.__init5.call(this);
|
|
21204
21285
|
this.numbering = numbering;
|
|
21286
|
+
this.bullet2 = bullet2;
|
|
21287
|
+
this.asteriskThird = asteriskThird;
|
|
21205
21288
|
}
|
|
21206
21289
|
__init5() {this.counts = []}
|
|
21207
21290
|
/** depth 항목 하나에 대한 마커. suppress=true면 빈 문자열(부호 없음) */
|
|
@@ -21210,8 +21293,8 @@ var GongmunNumberer = (_class3 = class {
|
|
|
21210
21293
|
const n = _nullishCoalesce(this.counts[depth], () => ( 0));
|
|
21211
21294
|
this.counts[depth] = n + 1;
|
|
21212
21295
|
if (suppress) return "";
|
|
21213
|
-
if (this.numbering === "gaejosik") return gaejosikMarker(depth);
|
|
21214
|
-
return this.numbering === "report" ? reportMarker(depth) : standardMarker(depth, n);
|
|
21296
|
+
if (this.numbering === "gaejosik") return gaejosikMarker(depth, this.bullet2);
|
|
21297
|
+
return this.numbering === "report" ? reportMarker(depth, this.bullet2, this.asteriskThird) : standardMarker(depth, n);
|
|
21215
21298
|
}
|
|
21216
21299
|
reset() {
|
|
21217
21300
|
this.counts = [];
|
|
@@ -21251,16 +21334,16 @@ var PARA_LIST = 7;
|
|
|
21251
21334
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
21252
21335
|
function resolveTheme(theme) {
|
|
21253
21336
|
return {
|
|
21254
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21255
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21256
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21257
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21258
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21259
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21337
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _180 => _180.headingColors, 'optionalAccess', _181 => _181[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21338
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _182 => _182.headingColors, 'optionalAccess', _183 => _183[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21339
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _184 => _184.headingColors, 'optionalAccess', _185 => _185[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21340
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _186 => _186.headingColors, 'optionalAccess', _187 => _187[4]]), () => ( _optionalChain([theme, 'optionalAccess', _188 => _188.headingColors, 'optionalAccess', _189 => _189[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21341
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _190 => _190.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21342
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _191 => _191.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21260
21343
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
21261
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
21262
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21263
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
21344
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _192 => _192.quoteColor]) !== void 0,
|
|
21345
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _193 => _193.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _194 => _194.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21346
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _195 => _195.tableHeaderBold])
|
|
21264
21347
|
};
|
|
21265
21348
|
}
|
|
21266
21349
|
function escapeXml(text) {
|
|
@@ -21327,12 +21410,16 @@ var GJ_CHAR_TABLE = 22;
|
|
|
21327
21410
|
var GJ_CHAR_TABLE_BOLD = 23;
|
|
21328
21411
|
var GJ_CHAR_BAR = 24;
|
|
21329
21412
|
var GJ_CHAR_BODY_TITLE = 25;
|
|
21330
|
-
var
|
|
21413
|
+
var GJ_CHAR_TITLE_BAR = 26;
|
|
21414
|
+
var GJ_CHAR_APPROVAL = 27;
|
|
21415
|
+
var GJ_CHAR_COUNT = 17;
|
|
21331
21416
|
var GJ_PARA_CHAM = 20;
|
|
21332
21417
|
var GJ_PARA_COVER = 21;
|
|
21333
21418
|
var GJ_PARA_TOC_ITEM = 22;
|
|
21334
21419
|
var GJ_PARA_CHAPTER = 23;
|
|
21335
21420
|
var GJ_PARA_BAR = 24;
|
|
21421
|
+
var GONGMUN_LIST_PLAIN_BASE = 25;
|
|
21422
|
+
var GONGMUN_PARA_APPROVAL = GONGMUN_LIST_PLAIN_BASE + GONGMUN_LIST_LEVELS;
|
|
21336
21423
|
var GJ_BF_CHAPTER_NUM = 3;
|
|
21337
21424
|
var GJ_BF_CHAPTER_GAP = 4;
|
|
21338
21425
|
var GJ_BF_CHAPTER_TITLE = 5;
|
|
@@ -21340,8 +21427,8 @@ var GJ_BF_BAR_DARK = 6;
|
|
|
21340
21427
|
var GJ_BF_BAR_LIGHT = 7;
|
|
21341
21428
|
var GJ_BF_TOC_BOX = 8;
|
|
21342
21429
|
var GJ_BF_TOC_STRIPE = 9;
|
|
21343
|
-
function gongmunTableHeaderBf(
|
|
21344
|
-
return
|
|
21430
|
+
function gongmunTableHeaderBf(richAssets) {
|
|
21431
|
+
return richAssets ? 10 : 3;
|
|
21345
21432
|
}
|
|
21346
21433
|
function borderFillEntry(id, b, fill) {
|
|
21347
21434
|
const side = (name, v) => v ? ` <hh:${name} type="${_nullishCoalesce(v[2], () => ( "SOLID"))}" width="${v[0]}" color="${v[1]}"/>` : ` <hh:${name} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
@@ -21371,9 +21458,15 @@ function newPageNumCtrl(num4 = 1) {
|
|
|
21371
21458
|
function pageHidingCtrl(hideHeader = false) {
|
|
21372
21459
|
return `<hp:ctrl><hp:pageHiding hideHeader="${hideHeader ? 1 : 0}" hideFooter="0" hideMasterPage="0" hideBorder="0" hideFill="0" hidePageNum="1"/></hp:ctrl>`;
|
|
21373
21460
|
}
|
|
21461
|
+
var GONGMUN_TBL_CHAR = 11;
|
|
21462
|
+
var GONGMUN_TBL_CHAR_BOLD = 12;
|
|
21463
|
+
var GONGMUN_TBL_PT = 1200;
|
|
21464
|
+
var GONGMUN_TITLE_BAR_CHAR = 13;
|
|
21465
|
+
var GONGMUN_APPROVAL_CHAR = 14;
|
|
21374
21466
|
var CHAR_VARIANT_BASE = 11;
|
|
21375
|
-
function charVariantBase(
|
|
21376
|
-
|
|
21467
|
+
function charVariantBase(richAssets, isGongmun = true) {
|
|
21468
|
+
if (!isGongmun) return CHAR_VARIANT_BASE;
|
|
21469
|
+
return richAssets ? 11 + GJ_CHAR_COUNT : 11 + 4;
|
|
21377
21470
|
}
|
|
21378
21471
|
var GONGMUN_BODY_RATIO = 95;
|
|
21379
21472
|
|
|
@@ -21622,6 +21715,7 @@ function generateManifest(chartParts = []) {
|
|
|
21622
21715
|
}
|
|
21623
21716
|
function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls = []) {
|
|
21624
21717
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
21718
|
+
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
21625
21719
|
let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
|
|
21626
21720
|
if (gongmun) {
|
|
21627
21721
|
body = gongmun.bodyHeight;
|
|
@@ -21629,9 +21723,9 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21629
21723
|
h1 = gongmun.preset === "report" || gongmun.preset === "plan" ? 2e3 : 1700;
|
|
21630
21724
|
h2 = 1600;
|
|
21631
21725
|
h3 = body;
|
|
21632
|
-
h4 = Math.max(body - 100, 1300);
|
|
21726
|
+
h4 = Math.min(h3, Math.max(body - 100, 1300));
|
|
21633
21727
|
}
|
|
21634
|
-
const bodyFont =
|
|
21728
|
+
const bodyFont = richAssets ? 4 : 0;
|
|
21635
21729
|
const hFont = measured ? 3 : 1;
|
|
21636
21730
|
const hBold = !measured;
|
|
21637
21731
|
const bodyRatio = gongmun ? GONGMUN_BODY_RATIO : 100;
|
|
@@ -21648,7 +21742,15 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21648
21742
|
charPr(CHAR_TABLE_HEADER, body, theme.tableHeaderBold, false, bodyFont, theme.tableHeader),
|
|
21649
21743
|
charPr(CHAR_QUOTE, body, false, true, bodyFont, theme.quote)
|
|
21650
21744
|
];
|
|
21651
|
-
if (
|
|
21745
|
+
if (gongmun && !richAssets) {
|
|
21746
|
+
rows.push(
|
|
21747
|
+
charPr(11, GONGMUN_TBL_PT, false, false, bodyFont, theme.body),
|
|
21748
|
+
charPr(12, GONGMUN_TBL_PT, true, false, bodyFont, theme.body),
|
|
21749
|
+
charPr(GONGMUN_TITLE_BAR_CHAR, 100, false, false, bodyFont, theme.body),
|
|
21750
|
+
charPr(GONGMUN_APPROVAL_CHAR, 1e3, false, false, bodyFont, theme.body)
|
|
21751
|
+
);
|
|
21752
|
+
}
|
|
21753
|
+
if (richAssets) {
|
|
21652
21754
|
const sz = gaejosikSizes(body, gongmun.sizes);
|
|
21653
21755
|
rows.push(
|
|
21654
21756
|
charPr(11, sz.dae, false, false, 3),
|
|
@@ -21679,8 +21781,12 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21679
21781
|
// 표 셀 bold
|
|
21680
21782
|
charPr(24, sz.bar, false, false, 4),
|
|
21681
21783
|
// 표지 바 셀 빈 문단(6pt)
|
|
21682
|
-
charPr(25, sz.bodyTitle, false, false, 3)
|
|
21784
|
+
charPr(25, sz.bodyTitle, false, false, 3),
|
|
21683
21785
|
// 본문 제목박스(HY헤드라인M 22pt, 실측 GT3 표④)
|
|
21786
|
+
charPr(GJ_CHAR_TITLE_BAR, 100, false, false, 4),
|
|
21787
|
+
// 1페이지형 제목박스 바(1pt)
|
|
21788
|
+
charPr(GJ_CHAR_APPROVAL, 1e3, false, false, 7)
|
|
21789
|
+
// 결재란 라벨(맑은 고딕 10pt)
|
|
21684
21790
|
);
|
|
21685
21791
|
}
|
|
21686
21792
|
for (const r of ratioVariants) {
|
|
@@ -21726,16 +21832,16 @@ ${base2.join("\n")}
|
|
|
21726
21832
|
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true })
|
|
21727
21833
|
];
|
|
21728
21834
|
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
21729
|
-
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes);
|
|
21730
|
-
const sectionGap = gongmun.numbering === "gaejosik"
|
|
21731
|
-
const keepNext = gongmun.numbering === "gaejosik" && d === 0;
|
|
21835
|
+
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes, gongmun.bullet2, usesAsteriskThird(gongmun.preset));
|
|
21836
|
+
const sectionGap = gongmun.numbering === "gaejosik" || gongmun.numbering === "report" ? gaejosikSpaceBefore(d, gongmun.bodyHeight) : 0;
|
|
21837
|
+
const keepNext = (gongmun.numbering === "gaejosik" || gongmun.numbering === "report") && d === 0;
|
|
21732
21838
|
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent, spaceBefore: sectionGap, keepWord: true, keepWithNext: keepNext }));
|
|
21733
21839
|
}
|
|
21734
21840
|
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls, keepWord: true }));
|
|
21735
21841
|
base.push(paraPr(GONGMUN_RIGHT, { align: "RIGHT", lineSpacing: ls, keepWord: true }));
|
|
21736
21842
|
base.push(paraPr(GONGMUN_TBL_CENTER, { align: "CENTER", lineSpacing: 130, keepWord: true }));
|
|
21737
21843
|
base.push(paraPr(GONGMUN_TBL_LEFT, { align: "LEFT", lineSpacing: 130, keepWord: true }));
|
|
21738
|
-
|
|
21844
|
+
{
|
|
21739
21845
|
const cham = gaejosikChamIndent(gongmun.bodyHeight, gongmun.sizes);
|
|
21740
21846
|
const toc = gaejosikTocItemIndent(gongmun.bodyHeight, gongmun.sizes);
|
|
21741
21847
|
base.push(
|
|
@@ -21747,12 +21853,13 @@ ${base2.join("\n")}
|
|
|
21747
21853
|
// 표지 장식 바 셀 빈 문단 — 저줄간격(실측 71%)으로 바 높이 818 안에 수납
|
|
21748
21854
|
paraPr(GJ_PARA_BAR, { align: "CENTER", lineSpacing: 70, keepWord: true })
|
|
21749
21855
|
);
|
|
21750
|
-
} else if (usesReportFonts(gongmun.preset)) {
|
|
21751
|
-
const cham = gaejosikChamIndent(gongmun.bodyHeight, gongmun.sizes);
|
|
21752
|
-
base.push(
|
|
21753
|
-
paraPr(GJ_PARA_CHAM, { align: "JUSTIFY", lineSpacing: ls, left: cham.left, indent: cham.indent, spaceBefore: gaejosikSpaceBefore(3, gongmun.bodyHeight), keepWord: true })
|
|
21754
|
-
);
|
|
21755
21856
|
}
|
|
21857
|
+
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
21858
|
+
const { left } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes, gongmun.bullet2, usesAsteriskThird(gongmun.preset));
|
|
21859
|
+
const sectionGap = gongmun.numbering === "gaejosik" || gongmun.numbering === "report" ? gaejosikSpaceBefore(d, gongmun.bodyHeight) : 0;
|
|
21860
|
+
base.push(paraPr(GONGMUN_LIST_PLAIN_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent: 0, spaceBefore: sectionGap, keepWord: true }));
|
|
21861
|
+
}
|
|
21862
|
+
base.push(paraPr(GONGMUN_PARA_APPROVAL, { align: "CENTER", lineSpacing: 100, keepWord: true }));
|
|
21756
21863
|
return `<hh:paraProperties itemCnt="${base.length}">
|
|
21757
21864
|
${base.join("\n")}
|
|
21758
21865
|
</hh:paraProperties>`;
|
|
@@ -21769,14 +21876,14 @@ ${heads}
|
|
|
21769
21876
|
</hh:numberings>`;
|
|
21770
21877
|
}
|
|
21771
21878
|
function fontEntry(id, face, weight = 6) {
|
|
21772
|
-
return ` <hh:font id="${id}" face="${face}" type="TTF" isEmbedded="0">
|
|
21879
|
+
return ` <hh:font id="${id}" face="${escapeXml(face)}" type="TTF" isEmbedded="0">
|
|
21773
21880
|
<hh:typeInfo familyType="FCAT_GOTHIC" weight="${weight}" proportion="4" contrast="0" strokeVariation="1" armStyle="1" letterform="1" midline="1" xHeight="1"/>
|
|
21774
21881
|
</hh:font>`;
|
|
21775
21882
|
}
|
|
21776
21883
|
function buildFontFaces(gongmun, bodyFace) {
|
|
21777
|
-
if (gongmun &&
|
|
21884
|
+
if (gongmun && needsGaejosikAssets(gongmun)) {
|
|
21778
21885
|
const ov = gongmun.fonts;
|
|
21779
|
-
const bodyDefault = gongmun.preset !== "gaejosik" && gongmun.bodyFont === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD734\uBA3C\uBA85\uC870";
|
|
21886
|
+
const bodyDefault = usesReportFonts(gongmun.preset) ? gongmun.preset !== "gaejosik" && gongmun.bodyFont === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD734\uBA3C\uBA85\uC870" : bodyFace;
|
|
21780
21887
|
const faces = [
|
|
21781
21888
|
"\uD568\uCD08\uB86C\uBC14\uD0D5",
|
|
21782
21889
|
"\uD568\uCD08\uB86C\uB3CB\uC6C0",
|
|
@@ -21835,7 +21942,7 @@ function buildBorderFills(gongmun, extra = []) {
|
|
|
21835
21942
|
borderFillEntry(1, {}),
|
|
21836
21943
|
borderFillEntry(2, { l: thin, r: thin, t: thin, b: thin })
|
|
21837
21944
|
];
|
|
21838
|
-
if (
|
|
21945
|
+
if (gongmun && needsGaejosikAssets(gongmun)) {
|
|
21839
21946
|
const c = GAEJOSIK_COLORS;
|
|
21840
21947
|
const edge = ["0.12 mm", c.border];
|
|
21841
21948
|
const grayLine = ["0.1 mm", c.titleLine];
|
|
@@ -21879,7 +21986,7 @@ function buildStyles(gongmun) {
|
|
|
21879
21986
|
</hh:styles>`;
|
|
21880
21987
|
}
|
|
21881
21988
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = []) {
|
|
21882
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
21989
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _196 => _196.fonts, 'access', _197 => _197.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _198 => _198.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
21883
21990
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
21884
21991
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21885
21992
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22009,8 +22116,8 @@ function parseChartFence(text) {
|
|
|
22009
22116
|
const spec = chartSpec(type);
|
|
22010
22117
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22011
22118
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22012
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22013
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22119
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _199 => _199.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
22120
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _200 => _200[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22014
22121
|
if (!spec.scatter) {
|
|
22015
22122
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22016
22123
|
}
|
|
@@ -22052,7 +22159,7 @@ function serSpPr(color, stroke) {
|
|
|
22052
22159
|
return stroke ? `<c:spPr><a:ln w="28575" cap="flat" cmpd="sng" algn="ctr">${f}<a:prstDash val="solid"/><a:round/></a:ln></c:spPr>` : `<c:spPr>${f}</c:spPr>`;
|
|
22053
22160
|
}
|
|
22054
22161
|
function dPtXml(pointColors, pie) {
|
|
22055
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
22162
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _201 => _201.length])) return "";
|
|
22056
22163
|
return pointColors.map((col, i) => {
|
|
22057
22164
|
const f = chartColorFill(col);
|
|
22058
22165
|
if (!f) return "";
|
|
@@ -22132,7 +22239,9 @@ function computeGongmunFitPlan(blocks, gongmun, gongmunList) {
|
|
|
22132
22239
|
if (gongmun.numbering === "gaejosik" && (depth === 0 || (block.text || "").trimStart().startsWith("\u203B"))) continue;
|
|
22133
22240
|
const content = plainRenderText(block.text || "");
|
|
22134
22241
|
text = marker ? `${marker} ${content}` : content;
|
|
22135
|
-
const
|
|
22242
|
+
const li = levelIndent(depth, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes, gongmun.bullet2, usesAsteriskThird(gongmun.preset));
|
|
22243
|
+
const left = li.left;
|
|
22244
|
+
const indent = marker ? li.indent : 0;
|
|
22136
22245
|
firstW = pageW - left - Math.max(indent, 0);
|
|
22137
22246
|
contW = pageW - left - Math.max(-indent, 0);
|
|
22138
22247
|
} else if (block.type === "paragraph") {
|
|
@@ -22160,7 +22269,7 @@ function variantMapper(fit, blockIdx, base = CHAR_VARIANT_BASE) {
|
|
|
22160
22269
|
}
|
|
22161
22270
|
function precomputeGongmunList(blocks, gongmun) {
|
|
22162
22271
|
const result = /* @__PURE__ */ new Map();
|
|
22163
|
-
const depthOffset = gongmun.numbering === "gaejosik" && blocks.some((b) => b.type === "heading" && b.level === 3) ? 1 : 0;
|
|
22272
|
+
const depthOffset = gongmun.numbering === "gaejosik" && blocks.some((b) => b.type === "heading" && b.level === 3) || gongmun.numbering === "standard" && gongmun.h2Marker === "number" && blocks.some((b) => b.type === "heading" && b.level === 2) ? 1 : 0;
|
|
22164
22273
|
let i = 0;
|
|
22165
22274
|
while (i < blocks.length) {
|
|
22166
22275
|
if (blocks[i].type !== "list_item") {
|
|
@@ -22187,8 +22296,8 @@ function precomputeGongmunList(blocks, gongmun) {
|
|
|
22187
22296
|
break;
|
|
22188
22297
|
}
|
|
22189
22298
|
const depths = run.map((bi) => Math.min(Math.max((blocks[bi].indent || 0) + depthOffset, 0), GONGMUN_LIST_LEVELS - 1));
|
|
22190
|
-
const suppress = gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
|
|
22191
|
-
const numberer = new GongmunNumberer(gongmun.numbering);
|
|
22299
|
+
const suppress = gongmun.suppressSingle && gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
|
|
22300
|
+
const numberer = new GongmunNumberer(gongmun.numbering, gongmun.bullet2, usesAsteriskThird(gongmun.preset));
|
|
22192
22301
|
run.forEach((bi, k) => {
|
|
22193
22302
|
const marker = numberer.next(depths[k], suppress[k]);
|
|
22194
22303
|
result.set(bi, { marker, depth: depths[k] });
|
|
@@ -22218,7 +22327,8 @@ function cell(opts) {
|
|
|
22218
22327
|
return `<hp:tc name="" header="0" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${opts.bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="${_nullishCoalesce(opts.vertAlign, () => ( "CENTER"))}" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${paras}</hp:subList><hp:cellAddr colAddr="${opts.col}" rowAddr="${_nullishCoalesce(opts.row, () => ( 0))}"/><hp:cellSpan colSpan="${_nullishCoalesce(opts.colSpan, () => ( 1))}" rowSpan="1"/><hp:cellSz width="${opts.w}" height="${opts.h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22219
22328
|
}
|
|
22220
22329
|
function table(rows, w, h, cols, tblBf = 1) {
|
|
22221
|
-
|
|
22330
|
+
const outLR = w + 566 > 48e3 ? 0 : 283;
|
|
22331
|
+
return `<hp:tbl id="${++gjTableId}" zOrder="0" numberingType="TABLE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" pageBreak="CELL" repeatHeader="0" rowCnt="${rows.length}" colCnt="${cols}" cellSpacing="0" borderFillIDRef="${tblBf}" noAdjust="1"><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="${outLR}" right="${outLR}" top="283" bottom="283"/><hp:inMargin left="141" right="141" top="141" bottom="141"/>` + rows.map((r) => `<hp:tr>${r}</hp:tr>`).join("") + `</hp:tbl>`;
|
|
22222
22332
|
}
|
|
22223
22333
|
function buildGaejosikCover(title, gongmun) {
|
|
22224
22334
|
const g = coverGeom(gongmun.bodyHeight, gongmun.sizes);
|
|
@@ -22232,8 +22342,8 @@ function buildGaejosikCover(title, gongmun) {
|
|
|
22232
22342
|
const botRow = cell({ bf: GJ_BF_BAR_DARK, col: 0, row: 2, w: g.botDarkW, h: g.botBarH, paras: barEmpty }) + cell({ bf: GJ_BF_BAR_LIGHT, col: 1, colSpan: 2, row: 2, w: g.botLightW, h: g.botBarH, paras: barEmpty });
|
|
22233
22343
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3);
|
|
22234
22344
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
22235
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22236
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22345
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _202 => _202.cover, 'optionalAccess', _203 => _203.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
22346
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _204 => _204.cover, 'optionalAccess', _205 => _205.org]), () => ( ""));
|
|
22237
22347
|
const sub = (t) => `<hp:p paraPrIDRef="${GJ_PARA_COVER}" styleIDRef="0"><hp:run charPrIDRef="${GJ_CHAR_COVER_SUB}"><hp:t>${escapeXml(t)}</hp:t></hp:run></hp:p>`;
|
|
22238
22348
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
22239
22349
|
return [
|
|
@@ -22466,7 +22576,7 @@ function escapeGfm(text) {
|
|
|
22466
22576
|
}
|
|
22467
22577
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
22468
22578
|
function sanitizeText(text) {
|
|
22469
|
-
let result =
|
|
22579
|
+
let result = _chunkOVESZY5Rcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
22470
22580
|
if (result.length <= 30 && result.includes(" ")) {
|
|
22471
22581
|
const tokens = result.split(" ");
|
|
22472
22582
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -22496,7 +22606,7 @@ function replicateGfmTable(table2) {
|
|
|
22496
22606
|
for (let r = 0; r < numRows; r++) {
|
|
22497
22607
|
for (let c = 0; c < numCols; c++) {
|
|
22498
22608
|
if (skip.has(`${r},${c}`)) continue;
|
|
22499
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
22609
|
+
const cell2 = _optionalChain([cells, 'access', _206 => _206[r], 'optionalAccess', _207 => _207[c]]);
|
|
22500
22610
|
if (!cell2) continue;
|
|
22501
22611
|
display[r][c] = {
|
|
22502
22612
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -22550,7 +22660,7 @@ function unescapeGfmCell(text) {
|
|
|
22550
22660
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
22551
22661
|
}
|
|
22552
22662
|
function replicateCellInnerHtml(cell2) {
|
|
22553
|
-
if (_optionalChain([cell2, 'access',
|
|
22663
|
+
if (_optionalChain([cell2, 'access', _208 => _208.blocks, 'optionalAccess', _209 => _209.length])) {
|
|
22554
22664
|
return cell2.blocks.map((b) => {
|
|
22555
22665
|
if (b.type === "table" && b.table) {
|
|
22556
22666
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -22589,7 +22699,7 @@ function replicateHtmlTable(table2) {
|
|
|
22589
22699
|
const rowCells = [];
|
|
22590
22700
|
for (let c = 0; c < numCols; c++) {
|
|
22591
22701
|
if (skip.has(`${r},${c}`)) continue;
|
|
22592
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
22702
|
+
const cell2 = _optionalChain([cells, 'access', _210 => _210[r], 'optionalAccess', _211 => _211[c]]);
|
|
22593
22703
|
if (!cell2) continue;
|
|
22594
22704
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
22595
22705
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -22635,8 +22745,8 @@ function parseHtmlTable(raw) {
|
|
|
22635
22745
|
}
|
|
22636
22746
|
} else {
|
|
22637
22747
|
if (!isClose) {
|
|
22638
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
22639
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
22748
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _212 => _212.match, 'call', _213 => _213(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _214 => _214[1]]) || "1", 10);
|
|
22749
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _215 => _215.match, 'call', _216 => _216(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _217 => _217[1]]) || "1", 10);
|
|
22640
22750
|
cellStart = m.index + m[0].length;
|
|
22641
22751
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
22642
22752
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -22781,7 +22891,7 @@ function edgeXml(tag, d) {
|
|
|
22781
22891
|
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22782
22892
|
}
|
|
22783
22893
|
function borderFillDefToXml(id, def) {
|
|
22784
|
-
const fill = _optionalChain([def, 'access',
|
|
22894
|
+
const fill = _optionalChain([def, 'access', _218 => _218.fill, 'optionalAccess', _219 => _219.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22785
22895
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22786
22896
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22787
22897
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -22881,7 +22991,7 @@ function profileColWidths(tp, colCnt) {
|
|
|
22881
22991
|
if (tp.width) return Array(colCnt).fill(Math.floor(tp.width / colCnt));
|
|
22882
22992
|
return null;
|
|
22883
22993
|
}
|
|
22884
|
-
var CELL_PAD =
|
|
22994
|
+
var CELL_PAD = 1200;
|
|
22885
22995
|
function cellContentWidth(text, charHeight) {
|
|
22886
22996
|
let max = 0;
|
|
22887
22997
|
for (const seg of text.replace(/\*\*|__|`/g, "").split(/<br\s*\/?>/i)) {
|
|
@@ -22890,35 +23000,51 @@ function cellContentWidth(text, charHeight) {
|
|
|
22890
23000
|
}
|
|
22891
23001
|
return max;
|
|
22892
23002
|
}
|
|
22893
|
-
function
|
|
23003
|
+
function cellMinWordWidth(text, charHeight) {
|
|
23004
|
+
let max = 0;
|
|
23005
|
+
for (const seg of text.replace(/\*\*|__|`/g, "").split(/<br\s*\/?>/i)) {
|
|
23006
|
+
for (const word of seg.trim().split(/\s+/)) {
|
|
23007
|
+
const w = measureTextWidth(word, charHeight, 100);
|
|
23008
|
+
if (w > max) max = w;
|
|
23009
|
+
}
|
|
23010
|
+
}
|
|
23011
|
+
return max;
|
|
23012
|
+
}
|
|
23013
|
+
function computeColWidths(colMax, totalWidth, colMinWord = []) {
|
|
22894
23014
|
const colCnt = colMax.length;
|
|
22895
23015
|
const minW = Math.min(Math.max(2e3, Math.round(totalWidth * 0.06)), Math.floor(totalWidth / colCnt));
|
|
22896
23016
|
const cap = Math.round(totalWidth * 0.8);
|
|
22897
23017
|
const raw = colMax.map((w) => Math.min(Math.max(w + CELL_PAD, minW), cap));
|
|
23018
|
+
const floor = raw.map((r, i) => Math.min(Math.max(minW, (_nullishCoalesce(colMinWord[i], () => ( 0))) + CELL_PAD), r, cap));
|
|
22898
23019
|
const widths = Array(colCnt).fill(0);
|
|
22899
23020
|
const free = new Set(raw.map((_, i) => i));
|
|
22900
23021
|
let budget = totalWidth;
|
|
22901
|
-
|
|
22902
|
-
for (
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
23022
|
+
let sumFloorFree = floor.reduce((a, b) => a + b, 0);
|
|
23023
|
+
for (const i of [...raw.keys()].sort((a, b) => raw[a] - raw[b])) {
|
|
23024
|
+
if (free.size <= 1) break;
|
|
23025
|
+
const fixed = Math.round(raw[i] * 1.12);
|
|
23026
|
+
if (budget - fixed < sumFloorFree - floor[i]) break;
|
|
23027
|
+
widths[i] = fixed;
|
|
23028
|
+
free.delete(i);
|
|
23029
|
+
budget -= fixed;
|
|
23030
|
+
sumFloorFree -= floor[i];
|
|
23031
|
+
}
|
|
23032
|
+
const sumFreeRaw = [...free].reduce((a, i) => a + raw[i], 0);
|
|
23033
|
+
if (budget > sumFreeRaw * 1.6) {
|
|
22911
23034
|
const sumRaw = raw.reduce((a, b) => a + b, 0);
|
|
22912
|
-
for (let i = 0; i < colCnt; i++) widths[i]
|
|
23035
|
+
for (let i = 0; i < colCnt; i++) widths[i] = raw[i] + Math.floor(raw[i] / sumRaw * (totalWidth - sumRaw));
|
|
23036
|
+
free.clear();
|
|
22913
23037
|
} else {
|
|
22914
23038
|
for (; ; ) {
|
|
22915
23039
|
const sum2 = [...free].reduce((a, i) => a + raw[i], 0);
|
|
22916
|
-
const short = [...free].filter((i) => raw[i] / sum2 * budget <
|
|
23040
|
+
const short = [...free].filter((i) => raw[i] / sum2 * budget < floor[i]);
|
|
22917
23041
|
if (short.length === 0) break;
|
|
23042
|
+
const shortSum = short.reduce((a, i) => a + floor[i], 0);
|
|
23043
|
+
const scale = Math.min(1, (budget - (free.size - short.length) * minW) / shortSum);
|
|
22918
23044
|
for (const i of short) {
|
|
22919
|
-
widths[i] = minW;
|
|
23045
|
+
widths[i] = Math.max(minW, Math.floor(floor[i] * scale));
|
|
22920
23046
|
free.delete(i);
|
|
22921
|
-
budget -=
|
|
23047
|
+
budget -= widths[i];
|
|
22922
23048
|
}
|
|
22923
23049
|
if (free.size === 0) break;
|
|
22924
23050
|
}
|
|
@@ -22945,18 +23071,21 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
22945
23071
|
function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
22946
23072
|
const rowCnt = rows.length;
|
|
22947
23073
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
22948
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23074
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _220 => _220.bfRegistry]), () => ( null));
|
|
22949
23075
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
22950
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
22951
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
23076
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _221 => _221.charHeight]), () => ( 1e3));
|
|
23077
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _222 => _222[0], 'optionalAccess', _223 => _223[0]]), () => ( ""))), seq);
|
|
22952
23078
|
const colMax = Array(colCnt).fill(0);
|
|
22953
23079
|
const colMaxBody = Array(colCnt).fill(0);
|
|
23080
|
+
const colMinWord = Array(colCnt).fill(0);
|
|
22954
23081
|
rows.forEach((row, r) => row.forEach((cell2, c) => {
|
|
22955
23082
|
const w = cellContentWidth(cell2, measureH);
|
|
22956
23083
|
if (w > colMax[c]) colMax[c] = w;
|
|
22957
23084
|
if (r > 0 && w > colMaxBody[c]) colMaxBody[c] = w;
|
|
23085
|
+
const mw = cellMinWordWidth(cell2, measureH);
|
|
23086
|
+
if (mw > colMinWord[c]) colMinWord[c] = mw;
|
|
22958
23087
|
}));
|
|
22959
|
-
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalW)));
|
|
23088
|
+
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalW, colMinWord)));
|
|
22960
23089
|
const colCentered = colWidths.map((w, c) => colMaxBody[c] + CELL_PAD <= w);
|
|
22961
23090
|
const labelCol0 = !!reg && colCnt === 2 && colCentered[0] && rows.every((r) => (_nullishCoalesce(r[0], () => ( ""))).replace(/\*\*|__|`/g, "").length <= 12);
|
|
22962
23091
|
const tblId = nextTableId();
|
|
@@ -22973,14 +23102,14 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22973
23102
|
const k = `${rowIdx},${colIdx}`;
|
|
22974
23103
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
22975
23104
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
22976
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23105
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _224 => _224.cellChar, 'access', _225 => _225.get, 'call', _226 => _226(k)]), () => ( defaultCharPr));
|
|
22977
23106
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
22978
23107
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
22979
23108
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
22980
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
23109
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _227 => _227.cellChar, 'access', _228 => _228.has, 'call', _229 => _229(k)]) ? void 0 : mapId);
|
|
22981
23110
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${runs || `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`}</hp:p>`;
|
|
22982
23111
|
}).join("");
|
|
22983
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23112
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _230 => _230.cellBf, 'access', _231 => _231.get, 'call', _232 => _232(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
22984
23113
|
row: rowIdx,
|
|
22985
23114
|
rowEnd: rowIdx,
|
|
22986
23115
|
col: colIdx,
|
|
@@ -22990,7 +23119,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22990
23119
|
headerRows: 1,
|
|
22991
23120
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
22992
23121
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
22993
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23122
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _233 => _233.cellH, 'access', _234 => _234.get, 'call', _235 => _235(k)]), () => ( cellH));
|
|
22994
23123
|
return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="${style ? "CENTER" : "TOP"}" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${p}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${colWidths[colIdx]}" height="${h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22995
23124
|
}).join("");
|
|
22996
23125
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -22999,7 +23128,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22999
23128
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
23000
23129
|
const tblInner = `<hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${tblH}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trElements;
|
|
23001
23130
|
const tbl2 = `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="${style ? 1 : 0}" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="2" noShading="0">${tblInner}</hp:tbl>`;
|
|
23002
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
23131
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _236 => _236.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
23003
23132
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
23004
23133
|
}
|
|
23005
23134
|
function layoutHtmlRows(rows) {
|
|
@@ -23030,37 +23159,41 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23030
23159
|
if (!rows || rows.length === 0) return null;
|
|
23031
23160
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
23032
23161
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
23033
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23162
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _237 => _237.charHeight]), () => ( 1e3));
|
|
23034
23163
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
23035
23164
|
const prof = takeProfile(remap, rowCnt, colCnt, first ? anchorOfHtmlCell(first.inner) : "", seq);
|
|
23036
23165
|
const colMax = Array(colCnt).fill(0);
|
|
23037
23166
|
const colMaxBody = Array(colCnt).fill(0);
|
|
23167
|
+
const colMinWord = Array(colCnt).fill(0);
|
|
23038
23168
|
const cellLines = placed.map((cell2) => htmlCellInnerToLines(cell2.inner).lines);
|
|
23039
23169
|
placed.forEach((cell2, i) => {
|
|
23040
23170
|
const w = Math.max(...cellLines[i].map((l) => measureTextWidth(unescapeHtml(l).trim(), measureH, 100)), 0) / cell2.colSpan;
|
|
23171
|
+
const mw = cell2.colSpan === 1 ? Math.max(...cellLines[i].map((l) => cellMinWordWidth(unescapeHtml(l), measureH)), 0) : 0;
|
|
23041
23172
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
23042
23173
|
const c = cell2.c + dc;
|
|
23043
23174
|
if (w > colMax[c]) colMax[c] = w;
|
|
23044
23175
|
if (!cell2.isHeader && w > colMaxBody[c]) colMaxBody[c] = w;
|
|
23176
|
+
if (dc === 0 && mw > colMinWord[c]) colMinWord[c] = mw;
|
|
23045
23177
|
}
|
|
23046
23178
|
});
|
|
23047
|
-
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalWidth)));
|
|
23179
|
+
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalWidth, colMinWord)));
|
|
23048
23180
|
const colCentered = colWidths.map((w, c) => colMaxBody[c] + CELL_PAD <= w);
|
|
23049
23181
|
const cellH = style ? Math.round(measureH * 1.6) + 282 : 1500;
|
|
23050
23182
|
const tblW = colWidths.reduce((a, b) => a + b, 0);
|
|
23051
23183
|
const tblId = nextTableId();
|
|
23052
23184
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
23053
23185
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
23054
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23186
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _238 => _238.bfRegistry]), () => ( null));
|
|
23055
23187
|
let htmlHeaderRows = 0;
|
|
23056
23188
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
23189
|
+
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
23057
23190
|
const tcXmls = placed.map((cell2, i) => {
|
|
23058
23191
|
const k = `${cell2.r},${cell2.c}`;
|
|
23059
23192
|
const isHeader = cell2.isHeader;
|
|
23060
23193
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
23061
23194
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
23062
23195
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
23063
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23196
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _239 => _239.cellChar, 'access', _240 => _240.get, 'call', _241 => _241(k)]), () => ( defaultCharPr));
|
|
23064
23197
|
const centered = isHeader || colCentered[cell2.c];
|
|
23065
23198
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
23066
23199
|
const lines = cellLines[i];
|
|
@@ -23080,8 +23213,12 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23080
23213
|
paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
23081
23214
|
}
|
|
23082
23215
|
const contentH = Math.max(cellH * cell2.rowSpan, Math.max(lines.length, 1) * (style ? Math.round(measureH * 1.6) : 800) + nestedH);
|
|
23083
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23084
|
-
const
|
|
23216
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _242 => _242.cellH, 'access', _243 => _243.get, 'call', _244 => _244(k)]), () => ( 0)), contentH);
|
|
23217
|
+
const perRow = Math.ceil(cellHeight / cell2.rowSpan);
|
|
23218
|
+
for (let r = cell2.r; r < Math.min(cell2.r + cell2.rowSpan, rowCnt); r++) {
|
|
23219
|
+
tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
23220
|
+
}
|
|
23221
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _245 => _245.cellBf, 'access', _246 => _246.get, 'call', _247 => _247(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
23085
23222
|
row: cell2.r,
|
|
23086
23223
|
rowEnd: cell2.r + cell2.rowSpan - 1,
|
|
23087
23224
|
col: cell2.c,
|
|
@@ -23098,7 +23235,8 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23098
23235
|
const rowTcs = tcXmls.filter((_, i) => placed[i].r === r);
|
|
23099
23236
|
trXmls.push(`<hp:tr>${rowTcs.join("")}</hp:tr>`);
|
|
23100
23237
|
}
|
|
23101
|
-
|
|
23238
|
+
const tableH = tableRowHeights.reduce((sum, height) => sum + height, 0);
|
|
23239
|
+
return `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="${style ? 1 : 0}" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="2" noShading="0"><hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${tableH}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trXmls.join("") + `</hp:tbl>`;
|
|
23102
23240
|
}
|
|
23103
23241
|
|
|
23104
23242
|
// src/hwpx/gen-gongmun-extra.ts
|
|
@@ -23113,9 +23251,9 @@ function para(text, paraPrId, charPrId) {
|
|
|
23113
23251
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t>${escapeXml(text)}</hp:t></hp:run></hp:p>`;
|
|
23114
23252
|
}
|
|
23115
23253
|
var APPROVAL_COL_W = 7085;
|
|
23116
|
-
var APPROVAL_LABEL_H =
|
|
23254
|
+
var APPROVAL_LABEL_H = 1300;
|
|
23117
23255
|
var APPROVAL_SIGN_H = 4200;
|
|
23118
|
-
function buildApprovalTable(labels,
|
|
23256
|
+
function buildApprovalTable(labels, reg, approvalCharPr) {
|
|
23119
23257
|
const n = labels.length;
|
|
23120
23258
|
const w = APPROVAL_COL_W * n;
|
|
23121
23259
|
const bfAt = (row, col) => reg.get({
|
|
@@ -23125,10 +23263,10 @@ function buildApprovalTable(labels, gongmun, reg) {
|
|
|
23125
23263
|
r: col === n - 1 ? "thick" : "thin"
|
|
23126
23264
|
});
|
|
23127
23265
|
const labelRow = labels.map(
|
|
23128
|
-
(label, c) => tc({ bf: bfAt(0, c), row: 0, col: c, w: APPROVAL_COL_W, h: APPROVAL_LABEL_H, paras: para(label,
|
|
23266
|
+
(label, c) => tc({ bf: bfAt(0, c), row: 0, col: c, w: APPROVAL_COL_W, h: APPROVAL_LABEL_H, paras: para(label, GONGMUN_PARA_APPROVAL, approvalCharPr) })
|
|
23129
23267
|
).join("");
|
|
23130
23268
|
const signRow = labels.map(
|
|
23131
|
-
(_, c) => tc({ bf: bfAt(1, c), row: 1, col: c, w: APPROVAL_COL_W, h: APPROVAL_SIGN_H, paras: para("",
|
|
23269
|
+
(_, c) => tc({ bf: bfAt(1, c), row: 1, col: c, w: APPROVAL_COL_W, h: APPROVAL_SIGN_H, paras: para("", GONGMUN_PARA_APPROVAL, approvalCharPr) })
|
|
23132
23270
|
).join("");
|
|
23133
23271
|
const table2 = tbl([labelRow, signRow], w, APPROVAL_LABEL_H + APPROVAL_SIGN_H, n);
|
|
23134
23272
|
return `<hp:p paraPrIDRef="${GONGMUN_RIGHT}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`;
|
|
@@ -23140,13 +23278,13 @@ function buildEndMark() {
|
|
|
23140
23278
|
return para(" \uB05D.", PARA_NORMAL, CHAR_NORMAL);
|
|
23141
23279
|
}
|
|
23142
23280
|
var TITLE_BOX = { barH: 382, titleH: 2850, color: "#0080C0", gradient: ["#0080C0", "#3CBFFF"] };
|
|
23143
|
-
function buildTitleBox(title, titleCharPr, bodyWidth, reg) {
|
|
23281
|
+
function buildTitleBox(title, titleCharPr, barCharPr, bodyWidth, reg) {
|
|
23144
23282
|
const w = bodyWidth - 280;
|
|
23145
23283
|
const outer = { t: "thin", b: "thin", l: "thin", r: "thin" };
|
|
23146
23284
|
const barTop = reg.get({ ...outer, fill: TITLE_BOX.color });
|
|
23147
23285
|
const barBottom = reg.get({ ...outer, fill: { gradient: TITLE_BOX.gradient } });
|
|
23148
23286
|
const mid = reg.get(outer);
|
|
23149
|
-
const barPara =
|
|
23287
|
+
const barPara = para("", GJ_PARA_BAR, barCharPr);
|
|
23150
23288
|
const rows = [
|
|
23151
23289
|
tc({ bf: barTop, row: 0, col: 0, w, h: TITLE_BOX.barH, paras: barPara }),
|
|
23152
23290
|
tc({ bf: mid, row: 1, col: 0, w, h: TITLE_BOX.titleH, paras: para(title, GONGMUN_TBL_CENTER, titleCharPr) }),
|
|
@@ -23156,6 +23294,118 @@ function buildTitleBox(title, titleCharPr, bodyWidth, reg) {
|
|
|
23156
23294
|
return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`;
|
|
23157
23295
|
}
|
|
23158
23296
|
|
|
23297
|
+
// src/hwpx/gen-docframe.ts
|
|
23298
|
+
function docframeIds(base) {
|
|
23299
|
+
return { org: base, sender: base + 1, foot: base + 2, small: base + 3, pressLabel: base + 4, pressHead: base + 5, pressTitle: base + 6, pressSub: base + 7, pressContact: base + 8 };
|
|
23300
|
+
}
|
|
23301
|
+
function docframeActive(g) {
|
|
23302
|
+
return !!(g.docHead || g.docFoot || g.reportInfo || g.noticeHead || g.press);
|
|
23303
|
+
}
|
|
23304
|
+
function docframeCharPrXmls(base, richAssets) {
|
|
23305
|
+
const body = richAssets ? 4 : 0;
|
|
23306
|
+
const ids = docframeIds(base);
|
|
23307
|
+
return [
|
|
23308
|
+
charPr(ids.org, 1800, true, false, body),
|
|
23309
|
+
charPr(ids.sender, 2200, true, false, body),
|
|
23310
|
+
charPr(ids.foot, 900, false, false, body),
|
|
23311
|
+
charPr(ids.small, 1200, false, false, body),
|
|
23312
|
+
charPr(ids.pressLabel, 2e3, true, false, body),
|
|
23313
|
+
charPr(ids.pressHead, 1e3, true, false, body),
|
|
23314
|
+
charPr(ids.pressTitle, 2500, true, false, body),
|
|
23315
|
+
charPr(ids.pressSub, 1500, true, false, body),
|
|
23316
|
+
charPr(ids.pressContact, 1e3, false, false, body)
|
|
23317
|
+
];
|
|
23318
|
+
}
|
|
23319
|
+
function labeled(label, value, paraPrId) {
|
|
23320
|
+
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_BOLD}"><hp:t>${escapeXml(label)}</hp:t></hp:run><hp:run charPrIDRef="${CHAR_NORMAL}"><hp:t>${escapeXml(value)}</hp:t></hp:run></hp:p>`;
|
|
23321
|
+
}
|
|
23322
|
+
function blank() {
|
|
23323
|
+
return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}"><hp:t></hp:t></hp:run></hp:p>`;
|
|
23324
|
+
}
|
|
23325
|
+
function buildDocHead(g, ids) {
|
|
23326
|
+
const h = g.docHead;
|
|
23327
|
+
const out = [];
|
|
23328
|
+
if (h.org) {
|
|
23329
|
+
out.push(para(h.org, GONGMUN_CENTER, ids.org), blank());
|
|
23330
|
+
}
|
|
23331
|
+
if (h.to !== void 0) out.push(labeled("\uC218\uC2E0 ", h.to, PARA_NORMAL));
|
|
23332
|
+
out.push(para(h.via ? `(\uACBD\uC720) ${h.via}` : "(\uACBD\uC720)", PARA_NORMAL, CHAR_NORMAL));
|
|
23333
|
+
if (h.title !== void 0) out.push(labeled("\uC81C\uBAA9 ", h.title, PARA_NORMAL));
|
|
23334
|
+
out.push(blank());
|
|
23335
|
+
return out;
|
|
23336
|
+
}
|
|
23337
|
+
var FOOT_SEP = "\u2500".repeat(46);
|
|
23338
|
+
function buildDocFoot(g, ids) {
|
|
23339
|
+
const f = g.docFoot;
|
|
23340
|
+
const out = [blank()];
|
|
23341
|
+
if (f.sender) {
|
|
23342
|
+
out.push(para(f.sender, GONGMUN_CENTER, ids.sender), blank());
|
|
23343
|
+
}
|
|
23344
|
+
const foot = (text) => para(text, GONGMUN_TBL_LEFT, ids.foot);
|
|
23345
|
+
out.push(foot(FOOT_SEP));
|
|
23346
|
+
if (f.drafter || f.reviewer || f.approver)
|
|
23347
|
+
out.push(foot(`\uAE30\uC548\uC790 ${_nullishCoalesce(f.drafter, () => ( ""))} \uAC80\uD1A0\uC790 ${_nullishCoalesce(f.reviewer, () => ( ""))} \uACB0\uC7AC\uAD8C\uC790 ${_nullishCoalesce(f.approver, () => ( ""))}`));
|
|
23348
|
+
if (f.cooperator) out.push(foot(`\uD611\uC870\uC790 ${f.cooperator}`));
|
|
23349
|
+
if (f.docNum || f.receive) out.push(foot(`\uC2DC\uD589 ${_nullishCoalesce(f.docNum, () => ( ""))} \uC811\uC218 ${_nullishCoalesce(f.receive, () => ( ""))}`));
|
|
23350
|
+
if (f.address || f.site) out.push(foot(`${_nullishCoalesce(f.address, () => ( ""))} / ${_nullishCoalesce(f.site, () => ( ""))}`));
|
|
23351
|
+
if (f.phone || f.fax || f.email || f.disclosure)
|
|
23352
|
+
out.push(foot(`\uC804\uD654 ${_nullishCoalesce(f.phone, () => ( ""))} \uC804\uC1A1 ${_nullishCoalesce(f.fax, () => ( ""))} / ${_nullishCoalesce(f.email, () => ( ""))} / ${_nullishCoalesce(f.disclosure, () => ( ""))}`));
|
|
23353
|
+
return out;
|
|
23354
|
+
}
|
|
23355
|
+
function buildReportInfo(g, ids) {
|
|
23356
|
+
return para(g.reportInfo, GONGMUN_RIGHT, ids.small);
|
|
23357
|
+
}
|
|
23358
|
+
function buildNoticeHead(g) {
|
|
23359
|
+
const n = g.noticeHead;
|
|
23360
|
+
return n.no ? [para(n.no, PARA_NORMAL, CHAR_BOLD), blank()] : [];
|
|
23361
|
+
}
|
|
23362
|
+
function buildNoticeFoot(g) {
|
|
23363
|
+
const n = g.noticeHead;
|
|
23364
|
+
const out = [];
|
|
23365
|
+
if (n.date) out.push(blank(), para(n.date, GONGMUN_RIGHT, CHAR_NORMAL));
|
|
23366
|
+
if (n.sender) out.push(blank(), para(n.sender, GONGMUN_RIGHT, CHAR_BOLD));
|
|
23367
|
+
return out;
|
|
23368
|
+
}
|
|
23369
|
+
var PRESS_LABEL_H = 3200;
|
|
23370
|
+
var PRESS_HEAD_H = 900;
|
|
23371
|
+
function buildPressHead(g, ids, bodyWidth, reg) {
|
|
23372
|
+
const p = g.press;
|
|
23373
|
+
const w = bodyWidth - 280;
|
|
23374
|
+
const thick = { t: "thick", b: "thick", l: "thick", r: "thick" };
|
|
23375
|
+
const rows = [tc({ bf: reg.get({ ...thick, b: "thin" }), row: 0, col: 0, w, h: PRESS_LABEL_H, paras: para("\uBCF4\uB3C4\uC790\uB8CC", GONGMUN_TBL_CENTER, ids.pressLabel) })];
|
|
23376
|
+
const headLine = [
|
|
23377
|
+
p.release ? `\uBCF4\uB3C4\uC2DC\uC810 : ${p.release}` : "",
|
|
23378
|
+
p.distribute ? `\uBC30\uD3EC : ${p.distribute}` : ""
|
|
23379
|
+
].filter(Boolean).join(" / ");
|
|
23380
|
+
if (headLine) rows.push(tc({ bf: reg.get({ ...thick, t: "thin" }), row: 1, col: 0, w, h: PRESS_HEAD_H, paras: para(headLine, GONGMUN_TBL_CENTER, ids.pressHead) }));
|
|
23381
|
+
const table2 = tbl(rows, w, PRESS_LABEL_H + (headLine ? PRESS_HEAD_H : 0), 1);
|
|
23382
|
+
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
23383
|
+
}
|
|
23384
|
+
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
23385
|
+
const c = _optionalChain([g, 'access', _248 => _248.press, 'optionalAccess', _249 => _249.contact]);
|
|
23386
|
+
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
23387
|
+
const w = bodyWidth - 280;
|
|
23388
|
+
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
23389
|
+
const labelW = Math.round(w * 0.14);
|
|
23390
|
+
const valueW = Math.round(w / 3) - labelW;
|
|
23391
|
+
let col = 0;
|
|
23392
|
+
const row = cells.flatMap(([label, value], i) => {
|
|
23393
|
+
const bf = (first) => reg.get({
|
|
23394
|
+
t: "thick",
|
|
23395
|
+
b: "thick",
|
|
23396
|
+
l: first && i === 0 ? "thick" : "thin",
|
|
23397
|
+
r: !first && i === cells.length - 1 ? "thick" : "thin",
|
|
23398
|
+
fill: first ? "#E6E6E6" : void 0
|
|
23399
|
+
});
|
|
23400
|
+
return [
|
|
23401
|
+
tc({ bf: bf(true), row: 0, col: col++, w: labelW, h: 1100, paras: para(label, GONGMUN_TBL_CENTER, ids.pressHead) }),
|
|
23402
|
+
tc({ bf: bf(false), row: 0, col: col++, w: valueW, h: 1100, paras: para(value, GONGMUN_TBL_CENTER, ids.pressContact) })
|
|
23403
|
+
];
|
|
23404
|
+
});
|
|
23405
|
+
const table2 = tbl([row.join("")], w, 1100, cells.length * 2);
|
|
23406
|
+
return [blank(), `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`];
|
|
23407
|
+
}
|
|
23408
|
+
|
|
23159
23409
|
// src/hwpx/equation-generate.ts
|
|
23160
23410
|
var MAX_EQUATION_SOURCE = 1e4;
|
|
23161
23411
|
var MAX_GROUP_DEPTH = 64;
|
|
@@ -23448,23 +23698,27 @@ function generateSecPr(gongmun) {
|
|
|
23448
23698
|
m.footer = gongmun.headerFooter;
|
|
23449
23699
|
}
|
|
23450
23700
|
const secPr = `<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>`;
|
|
23451
|
-
|
|
23701
|
+
const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
|
|
23702
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _250 => _250.pageNumbers]) ? pageNumCtrl() : "");
|
|
23452
23703
|
}
|
|
23453
|
-
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null) {
|
|
23704
|
+
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null, dfIds = null) {
|
|
23454
23705
|
const paraXmls = [];
|
|
23455
23706
|
let isFirst = true;
|
|
23456
23707
|
let tableSeq = 0;
|
|
23457
23708
|
const orderedCounters = {};
|
|
23458
23709
|
let prevWasOrdered = false;
|
|
23459
|
-
const gaejosik = _optionalChain([gongmun, 'optionalAccess',
|
|
23710
|
+
const gaejosik = _optionalChain([gongmun, 'optionalAccess', _251 => _251.preset]) === "gaejosik";
|
|
23460
23711
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
23461
|
-
const
|
|
23712
|
+
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
23713
|
+
const vBase = charVariantBase(richAssets, !!gongmun);
|
|
23462
23714
|
const tableStyle = gongmun ? {
|
|
23463
23715
|
totalWidth: mmToHwpunit(210 - gongmun.margins.left - gongmun.margins.right),
|
|
23464
|
-
|
|
23465
|
-
|
|
23466
|
-
|
|
23467
|
-
|
|
23716
|
+
// 표 셀 크기 — 실측: 실측 프리셋 맑은 고딕 12pt(22·23), 비실측도 12pt(11·12,
|
|
23717
|
+
// 실결재 지배값 — 본문 크기 셀은 열폭 부족으로 서술 열 세로 신장, v4.0.2 QA)
|
|
23718
|
+
charPr: richAssets ? GJ_CHAR_TABLE : GONGMUN_TBL_CHAR,
|
|
23719
|
+
boldCharPr: richAssets ? GJ_CHAR_TABLE_BOLD : GONGMUN_TBL_CHAR_BOLD,
|
|
23720
|
+
charHeight: richAssets ? gaejosikSizes(gongmun.bodyHeight, gongmun.sizes).table : GONGMUN_TBL_PT,
|
|
23721
|
+
headerBf: gongmunTableHeaderBf(richAssets),
|
|
23468
23722
|
centerParaPr: GONGMUN_CENTER,
|
|
23469
23723
|
tblCenterParaPr: GONGMUN_TBL_CENTER,
|
|
23470
23724
|
tblLeftParaPr: GONGMUN_TBL_LEFT,
|
|
@@ -23478,12 +23732,25 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23478
23732
|
let pendingPageBreak = false;
|
|
23479
23733
|
let pendingNewNum = false;
|
|
23480
23734
|
let titleBoxH1Idx = -1;
|
|
23735
|
+
let pressH1Idx = -1;
|
|
23481
23736
|
let hasFrontPages = false;
|
|
23482
23737
|
const preamble = [];
|
|
23483
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
23484
|
-
preamble.push(
|
|
23738
|
+
if (_optionalChain([gongmun, 'optionalAccess', _252 => _252.reportInfo]) && dfIds) {
|
|
23739
|
+
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
23740
|
+
}
|
|
23741
|
+
if (_optionalChain([gongmun, 'optionalAccess', _253 => _253.approval]) && bfReg) {
|
|
23742
|
+
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
23743
|
+
}
|
|
23744
|
+
if (_optionalChain([gongmun, 'optionalAccess', _254 => _254.docHead]) && dfIds) {
|
|
23745
|
+
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
23746
|
+
}
|
|
23747
|
+
if (_optionalChain([gongmun, 'optionalAccess', _255 => _255.noticeHead]) && dfIds) {
|
|
23748
|
+
preamble.push(...buildNoticeHead(gongmun));
|
|
23485
23749
|
}
|
|
23486
|
-
if (
|
|
23750
|
+
if (_optionalChain([gongmun, 'optionalAccess', _256 => _256.press]) && dfIds && bfReg && tableStyle) {
|
|
23751
|
+
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
23752
|
+
}
|
|
23753
|
+
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
23487
23754
|
const h1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
23488
23755
|
const chapters = blocks.filter((b) => b.type === "heading" && b.level === 2).map((b) => stripChapterNumber(b.text || ""));
|
|
23489
23756
|
let coverTitle = "";
|
|
@@ -23505,8 +23772,11 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23505
23772
|
if (gongmun.bodyTitleBox && coverTitle && hasFrontPages) {
|
|
23506
23773
|
preamble.push(buildGaejosikBodyTitle(coverTitle, gongmun).replace(/^<hp:p /, `<hp:p pageBreak="1" `));
|
|
23507
23774
|
}
|
|
23508
|
-
}
|
|
23775
|
+
}
|
|
23776
|
+
if (gongmun && !gaejosik && coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
23509
23777
|
titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
23778
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _257 => _257.press]) && coverH1Idx < 0 && dfIds) {
|
|
23779
|
+
pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
23510
23780
|
}
|
|
23511
23781
|
if (preamble.length > 0) {
|
|
23512
23782
|
preamble[0] = preamble[0].replace(` pageBreak="1"`, "").replace(/<hp:run charPrIDRef="(\d+)">/, `<hp:run charPrIDRef="$1">${generateSecPr(gongmun)}`);
|
|
@@ -23526,13 +23796,27 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23526
23796
|
}
|
|
23527
23797
|
switch (block.type) {
|
|
23528
23798
|
case "heading": {
|
|
23799
|
+
if (gongmun && blockIdx === coverH1Idx) break;
|
|
23800
|
+
if (gongmun && blockIdx === pressH1Idx && dfIds) {
|
|
23801
|
+
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
23802
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _258 => _258.press, 'optionalAccess', _259 => _259.sub]), () => ( []))) {
|
|
23803
|
+
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
23804
|
+
}
|
|
23805
|
+
xml = parts.join("\n ");
|
|
23806
|
+
break;
|
|
23807
|
+
}
|
|
23529
23808
|
if (gongmun && blockIdx === titleBoxH1Idx && tableStyle && bfReg) {
|
|
23530
|
-
xml = buildTitleBox(
|
|
23809
|
+
xml = buildTitleBox(
|
|
23810
|
+
(block.text || "").trim(),
|
|
23811
|
+
measured ? GJ_CHAR_BODY_TITLE : CHAR_H1,
|
|
23812
|
+
richAssets ? GJ_CHAR_TITLE_BAR : GONGMUN_TITLE_BAR_CHAR,
|
|
23813
|
+
tableStyle.totalWidth,
|
|
23814
|
+
bfReg
|
|
23815
|
+
);
|
|
23531
23816
|
break;
|
|
23532
23817
|
}
|
|
23533
23818
|
if (gaejosik) {
|
|
23534
23819
|
const lvl = block.level || 1;
|
|
23535
|
-
if (blockIdx === coverH1Idx) break;
|
|
23536
23820
|
if (lvl <= 2) {
|
|
23537
23821
|
chapterNo++;
|
|
23538
23822
|
xml = buildGaejosikChapter(chapterNo, stripChapterNumber(block.text || ""), gongmun);
|
|
@@ -23544,7 +23828,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23544
23828
|
(id) => id === CHAR_BOLD ? GJ_CHAR_DAE_BOLD : id
|
|
23545
23829
|
);
|
|
23546
23830
|
} else {
|
|
23547
|
-
xml = generateParagraph(
|
|
23831
|
+
xml = generateParagraph(`${gongmun.bullet2} ${block.text || ""}`, GONGMUN_LIST_BASE + 1, CHAR_NORMAL);
|
|
23548
23832
|
}
|
|
23549
23833
|
break;
|
|
23550
23834
|
}
|
|
@@ -23560,7 +23844,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23560
23844
|
break;
|
|
23561
23845
|
}
|
|
23562
23846
|
case "paragraph": {
|
|
23563
|
-
|
|
23847
|
+
const pTrim = (block.text || "").trimStart();
|
|
23848
|
+
if (measured && (pTrim.startsWith("\u203B") || /^\*\s/.test(pTrim))) {
|
|
23564
23849
|
xml = generateParagraph((block.text || "").trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23565
23850
|
break;
|
|
23566
23851
|
}
|
|
@@ -23620,21 +23905,33 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23620
23905
|
case "list_item": {
|
|
23621
23906
|
if (gongmun && gongmunList) {
|
|
23622
23907
|
const info = gongmunList.get(blockIdx);
|
|
23623
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
23624
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
23908
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _260 => _260.depth]), () => ( 0));
|
|
23909
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _261 => _261.marker]), () => ( ""));
|
|
23625
23910
|
const content = block.text || "";
|
|
23626
23911
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
23627
23912
|
xml = generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23628
23913
|
break;
|
|
23629
23914
|
}
|
|
23915
|
+
if (measured && block.marker === "*") {
|
|
23916
|
+
xml = generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23917
|
+
break;
|
|
23918
|
+
}
|
|
23630
23919
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
23920
|
+
const listParaPr = marker2 ? GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
23631
23921
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
23632
23922
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
23633
23923
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
23634
23924
|
listCharPr = GJ_CHAR_DAE;
|
|
23635
23925
|
mapId = (id) => id === CHAR_BOLD ? GJ_CHAR_DAE_BOLD : id;
|
|
23636
23926
|
}
|
|
23637
|
-
|
|
23927
|
+
if (gongmun.preset === "press") {
|
|
23928
|
+
if (depth === 0) listCharPr = CHAR_NORMAL;
|
|
23929
|
+
if (depth >= 2 && dfIds) {
|
|
23930
|
+
listCharPr = dfIds.small;
|
|
23931
|
+
mapId = void 0;
|
|
23932
|
+
}
|
|
23933
|
+
}
|
|
23934
|
+
xml = generateParagraph(text, listParaPr, listCharPr, mapId);
|
|
23638
23935
|
break;
|
|
23639
23936
|
}
|
|
23640
23937
|
const indent = block.indent || 0;
|
|
@@ -23708,10 +24005,19 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23708
24005
|
}
|
|
23709
24006
|
paraXmls.push(xml);
|
|
23710
24007
|
}
|
|
23711
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
23712
|
-
|
|
24008
|
+
if (_optionalChain([gongmun, 'optionalAccess', _262 => _262.noticeHead]) && dfIds) {
|
|
24009
|
+
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
24010
|
+
}
|
|
24011
|
+
if (_optionalChain([gongmun, 'optionalAccess', _263 => _263.endMark]) && paraXmls.length > 0) {
|
|
24012
|
+
const lastText = _nullishCoalesce(_optionalChain([[...blocks], 'access', _264 => _264.reverse, 'call', _265 => _265(), 'access', _266 => _266.find, 'call', _267 => _267((b) => (b.type === "paragraph" || b.type === "list_item") && (b.text || "").trim()), 'optionalAccess', _268 => _268.text]), () => ( ""));
|
|
23713
24013
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
23714
24014
|
}
|
|
24015
|
+
if (_optionalChain([gongmun, 'optionalAccess', _269 => _269.docFoot]) && dfIds) {
|
|
24016
|
+
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
24017
|
+
}
|
|
24018
|
+
if (_optionalChain([gongmun, 'optionalAccess', _270 => _270.press]) && dfIds && bfReg && tableStyle) {
|
|
24019
|
+
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
24020
|
+
}
|
|
23715
24021
|
if (paraXmls.length === 0) {
|
|
23716
24022
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run></hp:p>`);
|
|
23717
24023
|
}
|
|
@@ -23723,30 +24029,39 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23723
24029
|
|
|
23724
24030
|
// src/hwpx/generator.ts
|
|
23725
24031
|
async function markdownToHwpx(markdown, options) {
|
|
23726
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
23727
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
23728
|
-
const gaejosik = _optionalChain([gongmun, 'optionalAccess', _258 => _258.preset]) === "gaejosik";
|
|
24032
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _271 => _271.theme]));
|
|
24033
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _272 => _272.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
23729
24034
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
24035
|
+
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
23730
24036
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
23731
24037
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
23732
24038
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
23733
|
-
const staticBfEnd = gongmun ?
|
|
23734
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
23735
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
24039
|
+
const staticBfEnd = gongmun ? richAssets ? 11 : 4 : 3;
|
|
24040
|
+
const remap = _optionalChain([options, 'optionalAccess', _273 => _273.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _274 => _274.variants, 'optionalAccess', _275 => _275.length]), () => ( 0))) * 4, staticBfEnd) : null;
|
|
24041
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _276 => _276.borderFillXmls, 'access', _277 => _277.length]), () => ( 0)))) : null;
|
|
24042
|
+
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
24043
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _278 => _278.variants, 'optionalAccess', _279 => _279.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _280 => _280.charPrXmls, 'access', _281 => _281.length]), () => ( 0)));
|
|
24044
|
+
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
23736
24045
|
const chartParts = [];
|
|
23737
|
-
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap);
|
|
24046
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap, dfIds);
|
|
23738
24047
|
if (remap && remap.tables.length > 0) {
|
|
23739
24048
|
const unused = remap.tables.filter((t) => !t.used).length;
|
|
23740
24049
|
if (unused === remap.tables.length) {
|
|
23741
24050
|
console.warn(`[kordoc] format profile: \uD504\uB85C\uD544 \uD45C ${unused}\uAC1C\uAC00 \uBB38\uC11C \uD45C\uC640 \uB9E4\uCE6D\uB418\uC9C0 \uC54A\uC544 \uBBF8\uC801\uC6A9 (\uD589\xB7\uC5F4/\uCCAB \uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
23742
24051
|
}
|
|
23743
24052
|
}
|
|
23744
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
24053
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _282 => _282.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _283 => _283.emit, 'call', _284 => _284()]), () => ( []))];
|
|
23745
24054
|
const zip = new (0, _jszip2.default)();
|
|
23746
24055
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
23747
24056
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
23748
24057
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
23749
|
-
zip.file("Contents/header.xml", generateHeaderXml(
|
|
24058
|
+
zip.file("Contents/header.xml", generateHeaderXml(
|
|
24059
|
+
theme,
|
|
24060
|
+
gongmun,
|
|
24061
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _285 => _285.variants]), () => ( [])),
|
|
24062
|
+
extraBorderFills,
|
|
24063
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _286 => _286.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []]
|
|
24064
|
+
));
|
|
23750
24065
|
zip.file("Contents/section0.xml", sectionXml);
|
|
23751
24066
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
23752
24067
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -24040,7 +24355,7 @@ function parseRenderStyles(headXml) {
|
|
|
24040
24355
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
24041
24356
|
const textColor = el.getAttribute("textColor");
|
|
24042
24357
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
24043
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
24358
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _287 => _287.getAttribute, 'call', _288 => _288("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _289 => _289.getAttribute, 'call', _290 => _290("latin")])));
|
|
24044
24359
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
24045
24360
|
styles.charPr.set(id, {
|
|
24046
24361
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -24048,8 +24363,8 @@ function parseRenderStyles(headXml) {
|
|
|
24048
24363
|
italic: findChildByLocalName(el, "italic") != null,
|
|
24049
24364
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
24050
24365
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
24051
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
24052
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
24366
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _291 => _291.getAttribute, 'call', _292 => _292("hangul")])) || 100,
|
|
24367
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _293 => _293.getAttribute, 'call', _294 => _294("hangul")])) || 0,
|
|
24053
24368
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
24054
24369
|
});
|
|
24055
24370
|
}
|
|
@@ -24057,7 +24372,7 @@ function parseRenderStyles(headXml) {
|
|
|
24057
24372
|
const id = el.getAttribute("id");
|
|
24058
24373
|
if (id != null) {
|
|
24059
24374
|
const align = findChildByLocalName(el, "align");
|
|
24060
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
24375
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _295 => _295.getAttribute, 'call', _296 => _296("horizontal")]) || "JUSTIFY");
|
|
24061
24376
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
24062
24377
|
}
|
|
24063
24378
|
} else if (tag === "borderFill") {
|
|
@@ -24071,7 +24386,7 @@ function parseRenderStyles(headXml) {
|
|
|
24071
24386
|
};
|
|
24072
24387
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
24073
24388
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
24074
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
24389
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _297 => _297.getAttribute, 'call', _298 => _298("faceColor")]);
|
|
24075
24390
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
24076
24391
|
styles.borderFill.set(id, bf);
|
|
24077
24392
|
}
|
|
@@ -24143,7 +24458,7 @@ function collectSites(scan) {
|
|
|
24143
24458
|
}
|
|
24144
24459
|
function attrOf(openTag, name) {
|
|
24145
24460
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
24146
|
-
return _optionalChain([m, 'optionalAccess',
|
|
24461
|
+
return _optionalChain([m, 'optionalAccess', _299 => _299[1]]);
|
|
24147
24462
|
}
|
|
24148
24463
|
function paraOpenTag(xml, para2) {
|
|
24149
24464
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -24158,7 +24473,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
24158
24473
|
if (!tr) return null;
|
|
24159
24474
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
24160
24475
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
24161
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
24476
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _300 => _300[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
24162
24477
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
24163
24478
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
24164
24479
|
if (close === -1) return null;
|
|
@@ -24185,7 +24500,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
24185
24500
|
if (width === null) return null;
|
|
24186
24501
|
let content = width;
|
|
24187
24502
|
const win = cellAddrWindow(xml, cell2);
|
|
24188
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
24503
|
+
const mg = _optionalChain([win, 'optionalAccess', _301 => _301.match, 'call', _302 => _302(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
24189
24504
|
if (mg) {
|
|
24190
24505
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
24191
24506
|
}
|
|
@@ -24219,11 +24534,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
24219
24534
|
return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
|
|
24220
24535
|
}
|
|
24221
24536
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
24222
|
-
if (ops.length === 0) throw new (0,
|
|
24537
|
+
if (ops.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
24223
24538
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
24224
24539
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
24225
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
24226
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
24540
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _303 => _303.match, 'call', _304 => _304(/(\d+)\.xml$/i), 'optionalAccess', _305 => _305[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _306 => _306.match, 'call', _307 => _307(/(\d+)\.xml$/i), 'optionalAccess', _308 => _308[1]]), () => ( 0))));
|
|
24541
|
+
if (sectionPaths.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
24227
24542
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
24228
24543
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
24229
24544
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -24264,11 +24579,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24264
24579
|
const manifestItems = [];
|
|
24265
24580
|
const placed = [];
|
|
24266
24581
|
for (const op of ops) {
|
|
24267
|
-
if (!op.anchor) throw new (0,
|
|
24268
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
24582
|
+
if (!op.anchor) throw new (0, _chunkOVESZY5Rcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
24583
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
24269
24584
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
24270
|
-
if (!MIME[ext]) throw new (0,
|
|
24271
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
24585
|
+
if (!MIME[ext]) throw new (0, _chunkOVESZY5Rcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
24586
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkOVESZY5Rcjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
24272
24587
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
24273
24588
|
let found = null;
|
|
24274
24589
|
let total = 0;
|
|
@@ -24301,7 +24616,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24301
24616
|
}
|
|
24302
24617
|
}
|
|
24303
24618
|
}
|
|
24304
|
-
throw new (0,
|
|
24619
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(
|
|
24305
24620
|
`place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
|
|
24306
24621
|
);
|
|
24307
24622
|
}
|
|
@@ -24309,9 +24624,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24309
24624
|
const xml = sectionXmls[si];
|
|
24310
24625
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
24311
24626
|
if (!run) {
|
|
24312
|
-
throw new (0,
|
|
24627
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
24313
24628
|
}
|
|
24314
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
24629
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _309 => _309.charPr, 'access', _310 => _310.get, 'call', _311 => _311(run.charPr), 'optionalAccess', _312 => _312.height]), () => ( 1e3));
|
|
24315
24630
|
const fontPt = charPrHeight / 100;
|
|
24316
24631
|
const emMm = fontPt * 25.4 / 72;
|
|
24317
24632
|
const lineHMm = emMm;
|
|
@@ -24320,7 +24635,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24320
24635
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
24321
24636
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
24322
24637
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
24323
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
24638
|
+
const align = _optionalChain([styles, 'optionalAccess', _313 => _313.paraAlign, 'access', _314 => _314.get, 'call', _315 => _315(paraPrId)]);
|
|
24324
24639
|
let alignShiftMm = 0;
|
|
24325
24640
|
if (align === "CENTER" || align === "RIGHT") {
|
|
24326
24641
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -24416,7 +24731,7 @@ function parseBorderFills(headerDoc) {
|
|
|
24416
24731
|
};
|
|
24417
24732
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
24418
24733
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
24419
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
24734
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _316 => _316.getAttribute, 'call', _317 => _317("faceColor")]);
|
|
24420
24735
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
24421
24736
|
map.set(id, def);
|
|
24422
24737
|
}
|
|
@@ -24436,7 +24751,7 @@ function parseCharPrs(headerDoc) {
|
|
|
24436
24751
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
24437
24752
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
24438
24753
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
24439
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
24754
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _318 => _318.getAttribute, 'call', _319 => _319("hangul")]);
|
|
24440
24755
|
if (hangul) def.fontRef_hangul = hangul;
|
|
24441
24756
|
map.set(id, def);
|
|
24442
24757
|
}
|
|
@@ -24460,7 +24775,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
24460
24775
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
24461
24776
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
24462
24777
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
24463
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
24778
|
+
const width = _optionalChain([sz, 'optionalAccess', _320 => _320.getAttribute, 'call', _321 => _321("width")]) || void 0;
|
|
24464
24779
|
const cells = [];
|
|
24465
24780
|
const usedBf = /* @__PURE__ */ new Set();
|
|
24466
24781
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -24471,16 +24786,16 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
24471
24786
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
24472
24787
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
24473
24788
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
24474
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
24475
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
24789
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _322 => _322.getAttribute, 'call', _323 => _323("rowAddr")])), () => ( 0));
|
|
24790
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _324 => _324.getAttribute, 'call', _325 => _325("colAddr")])), () => ( 0));
|
|
24476
24791
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
24477
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
24478
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
24792
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _326 => _326.getAttribute, 'call', _327 => _327("colSpan")])), () => ( 1));
|
|
24793
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _328 => _328.getAttribute, 'call', _329 => _329("rowSpan")])), () => ( 1));
|
|
24479
24794
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
24480
24795
|
const cpId = firstRunCharPr(tc2);
|
|
24481
24796
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
24482
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
24483
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
24797
|
+
const w = _optionalChain([csz, 'optionalAccess', _330 => _330.getAttribute, 'call', _331 => _331("width")]);
|
|
24798
|
+
const hh = _optionalChain([csz, 'optionalAccess', _332 => _332.getAttribute, 'call', _333 => _333("height")]);
|
|
24484
24799
|
if (w) cell2.width_hwpunit = w;
|
|
24485
24800
|
if (hh) cell2.height_hwpunit = hh;
|
|
24486
24801
|
if (bfId) {
|
|
@@ -24553,16 +24868,16 @@ function pick(map, keys) {
|
|
|
24553
24868
|
return out;
|
|
24554
24869
|
}
|
|
24555
24870
|
async function hwpxToProfile(input) {
|
|
24556
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
24871
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkOVESZY5Rcjs.toArrayBuffer.call(void 0, input);
|
|
24557
24872
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
24558
24873
|
const parser = createXmlParser();
|
|
24559
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
24874
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _334 => _334.file, 'call', _335 => _335(/[Hh]eader\.xml$/), 'optionalAccess', _336 => _336[0]])));
|
|
24560
24875
|
let headerXml = "<root/>";
|
|
24561
24876
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
24562
24877
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
24563
24878
|
const borderFills = parseBorderFills(headerDoc);
|
|
24564
24879
|
const charPrs = parseCharPrs(headerDoc);
|
|
24565
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
24880
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _337 => _337.name, 'access', _338 => _338.match, 'call', _339 => _339(/(\d+)\.xml$/), 'optionalAccess', _340 => _340[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _341 => _341.name, 'access', _342 => _342.match, 'call', _343 => _343(/(\d+)\.xml$/), 'optionalAccess', _344 => _344[1]]), () => ( null))), () => ( 0))));
|
|
24566
24881
|
const tables = [];
|
|
24567
24882
|
let tableIndex = 0;
|
|
24568
24883
|
for (const f of sectionFiles) {
|
|
@@ -24873,7 +25188,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
24873
25188
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
24874
25189
|
function patchTableRows(input) {
|
|
24875
25190
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
24876
|
-
const xml = _optionalChain([ctx, 'access',
|
|
25191
|
+
const xml = _optionalChain([ctx, 'access', _345 => _345.scans, 'access', _346 => _346[scanTable.sectionIndex], 'optionalAccess', _347 => _347.xml]);
|
|
24877
25192
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
24878
25193
|
const numRows = table2.rows;
|
|
24879
25194
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -25040,7 +25355,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
25040
25355
|
const rr = scanTable.rowRanges[template];
|
|
25041
25356
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
25042
25357
|
const scan = scanSectionXml(wrapped, 0);
|
|
25043
|
-
const row = _optionalChain([scan, 'access',
|
|
25358
|
+
const row = _optionalChain([scan, 'access', _348 => _348.tables, 'access', _349 => _349[0], 'optionalAccess', _350 => _350.rows, 'access', _351 => _351[0]]);
|
|
25044
25359
|
if (!row || row.length !== cells.length) return null;
|
|
25045
25360
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
25046
25361
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -25083,7 +25398,7 @@ function rowHeightOf(fragment) {
|
|
|
25083
25398
|
}
|
|
25084
25399
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
25085
25400
|
const from = scanTable.start + tblOpenLen;
|
|
25086
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
25401
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _352 => _352.rowRanges, 'access', _353 => _353[0], 'optionalAccess', _354 => _354.start]), () => ( from));
|
|
25087
25402
|
const slice = xml.slice(from, to);
|
|
25088
25403
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
25089
25404
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -25272,9 +25587,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
25272
25587
|
});
|
|
25273
25588
|
}
|
|
25274
25589
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
25275
|
-
const irCell = _optionalChain([table2, 'access',
|
|
25590
|
+
const irCell = _optionalChain([table2, 'access', _355 => _355.cells, 'access', _356 => _356[oc.gridR], 'optionalAccess', _357 => _357[oc.gridC]]);
|
|
25276
25591
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
25277
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
25592
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _358 => _358.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
25278
25593
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
25279
25594
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
25280
25595
|
}
|
|
@@ -25342,7 +25657,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25342
25657
|
};
|
|
25343
25658
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
25344
25659
|
if (!cell2) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
25345
|
-
const irCell = _optionalChain([table2, 'access',
|
|
25660
|
+
const irCell = _optionalChain([table2, 'access', _359 => _359.cells, 'access', _360 => _360[gridR], 'optionalAccess', _361 => _361[gridC]]);
|
|
25346
25661
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
25347
25662
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25348
25663
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25365,7 +25680,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25365
25680
|
if (newLines.length === 0) return 0;
|
|
25366
25681
|
const target = cell2.paragraphs[0];
|
|
25367
25682
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
25368
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
25683
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _362 => _362.scans, 'access', _363 => _363[target.sectionIndex], 'optionalAccess', _364 => _364.xml]));
|
|
25369
25684
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25370
25685
|
splices.push(...sp);
|
|
25371
25686
|
sectionIndex = target.sectionIndex;
|
|
@@ -25388,7 +25703,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25388
25703
|
}
|
|
25389
25704
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
25390
25705
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
25391
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
25706
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _365 => _365.scans, 'access', _366 => _366[nonEmpty[i].sectionIndex], 'optionalAccess', _367 => _367.xml]));
|
|
25392
25707
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25393
25708
|
splices.push(...sp);
|
|
25394
25709
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -25469,7 +25784,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
25469
25784
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
25470
25785
|
if (paths.length > 0) return paths;
|
|
25471
25786
|
}
|
|
25472
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
25787
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkOVESZY5Rcjs.compareSectionPaths);
|
|
25473
25788
|
}
|
|
25474
25789
|
function sectionPathsFromManifest(xml) {
|
|
25475
25790
|
const attr = (tag, name) => {
|
|
@@ -25479,7 +25794,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
25479
25794
|
const idToHref = /* @__PURE__ */ new Map();
|
|
25480
25795
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
25481
25796
|
const id = attr(m[1], "id");
|
|
25482
|
-
const href =
|
|
25797
|
+
const href = _chunkOVESZY5Rcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
25483
25798
|
if (id && href) idToHref.set(id, href);
|
|
25484
25799
|
}
|
|
25485
25800
|
const ordered = [];
|
|
@@ -25488,7 +25803,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
25488
25803
|
if (href) ordered.push(href);
|
|
25489
25804
|
}
|
|
25490
25805
|
if (ordered.length > 0) return ordered;
|
|
25491
|
-
return Array.from(idToHref.values()).sort(
|
|
25806
|
+
return Array.from(idToHref.values()).sort(_chunkOVESZY5Rcjs.compareSectionPaths);
|
|
25492
25807
|
}
|
|
25493
25808
|
|
|
25494
25809
|
// src/roundtrip/patcher.ts
|
|
@@ -25580,7 +25895,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
25580
25895
|
}
|
|
25581
25896
|
}
|
|
25582
25897
|
let verification;
|
|
25583
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25898
|
+
if (_optionalChain([options, 'optionalAccess', _368 => _368.verify]) !== false) {
|
|
25584
25899
|
try {
|
|
25585
25900
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
25586
25901
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -25598,17 +25913,17 @@ function buildOrigUnits(blocks) {
|
|
|
25598
25913
|
let chunk2;
|
|
25599
25914
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
25600
25915
|
const next = blocks[i + 1];
|
|
25601
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
25602
|
-
chunk2 =
|
|
25916
|
+
if (_optionalChain([next, 'optionalAccess', _369 => _369.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
25917
|
+
chunk2 = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
25603
25918
|
} else {
|
|
25604
|
-
chunk2 =
|
|
25919
|
+
chunk2 = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, [block]);
|
|
25605
25920
|
}
|
|
25606
25921
|
if (chunk2) {
|
|
25607
25922
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
25608
25923
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
25609
25924
|
for (let s = 0; s < subUnits.length; s++) {
|
|
25610
25925
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
25611
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
25926
|
+
if (block.type === "table" && _optionalChain([block, 'access', _370 => _370.table, 'optionalAccess', _371 => _371.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
25612
25927
|
u.role = "caption";
|
|
25613
25928
|
}
|
|
25614
25929
|
units.push(u);
|
|
@@ -25719,7 +26034,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
25719
26034
|
const ti = ctx.tableInsert;
|
|
25720
26035
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
25721
26036
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25722
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26037
|
+
if (!_optionalChain([mapping, 'optionalAccess', _372 => _372.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");
|
|
25723
26038
|
const para2 = mapping.para;
|
|
25724
26039
|
if (para2.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
|
|
25725
26040
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -25747,7 +26062,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
25747
26062
|
}
|
|
25748
26063
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
25749
26064
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25750
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26065
|
+
if (!_optionalChain([mapping, 'optionalAccess', _373 => _373.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)");
|
|
25751
26066
|
if (block.text && block.text.includes("\n")) {
|
|
25752
26067
|
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)");
|
|
25753
26068
|
}
|
|
@@ -25778,7 +26093,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
25778
26093
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25779
26094
|
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");
|
|
25780
26095
|
}
|
|
25781
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
26096
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _374 => _374.scans, 'access', _375 => _375[mapping.para.sectionIndex], 'optionalAccess', _376 => _376.xml]));
|
|
25782
26097
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25783
26098
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25784
26099
|
return 1;
|
|
@@ -25964,7 +26279,7 @@ var Surgeon = (_class5 = class {
|
|
|
25964
26279
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
25965
26280
|
findEntry(path) {
|
|
25966
26281
|
const parts = path.replace(/^\//, "").split("/");
|
|
25967
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
26282
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _377 => _377.entries, 'access', _378 => _378[0], 'optionalAccess', _379 => _379.child]), () => ( -1));
|
|
25968
26283
|
let current;
|
|
25969
26284
|
for (const part of parts) {
|
|
25970
26285
|
const search = (idx) => {
|
|
@@ -26177,8 +26492,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
26177
26492
|
parts.push(header, data);
|
|
26178
26493
|
};
|
|
26179
26494
|
for (let i = 0; i < recs.length; i++) {
|
|
26180
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
26181
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
26495
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _380 => _380.get, 'call', _381 => _381(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
26496
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _382 => _382.get, 'call', _383 => _383(i)]), () => ( recs[i].data)));
|
|
26182
26497
|
}
|
|
26183
26498
|
return Buffer.concat(parts);
|
|
26184
26499
|
}
|
|
@@ -26296,7 +26611,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26296
26611
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
26297
26612
|
}
|
|
26298
26613
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
26299
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
26614
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _384 => _384.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
26300
26615
|
let flags;
|
|
26301
26616
|
try {
|
|
26302
26617
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -26318,7 +26633,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26318
26633
|
const scans = [];
|
|
26319
26634
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
26320
26635
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
26321
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
26636
|
+
if (!_optionalChain([entry, 'optionalAccess', _385 => _385.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
26322
26637
|
let stream;
|
|
26323
26638
|
try {
|
|
26324
26639
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -26369,7 +26684,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26369
26684
|
}
|
|
26370
26685
|
}
|
|
26371
26686
|
let verification;
|
|
26372
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26687
|
+
if (_optionalChain([options, 'optionalAccess', _386 => _386.verify]) !== false) {
|
|
26373
26688
|
try {
|
|
26374
26689
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
26375
26690
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -26459,7 +26774,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
26459
26774
|
for (const [key, scanCell] of scanTable.cells) {
|
|
26460
26775
|
const comma = key.indexOf(",");
|
|
26461
26776
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
26462
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
26777
|
+
const irCell = _optionalChain([irTable, 'access', _387 => _387.cells, 'access', _388 => _388[r], 'optionalAccess', _389 => _389[c]]);
|
|
26463
26778
|
if (!irCell) continue;
|
|
26464
26779
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
26465
26780
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -26495,7 +26810,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
26495
26810
|
}
|
|
26496
26811
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
26497
26812
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
26498
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26813
|
+
if (!_optionalChain([mapping, 'optionalAccess', _390 => _390.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)");
|
|
26499
26814
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
26500
26815
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
26501
26816
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -26694,7 +27009,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
26694
27009
|
};
|
|
26695
27010
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
26696
27011
|
if (!cell2) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
26697
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27012
|
+
const irCell = _optionalChain([table2, 'access', _391 => _391.cells, 'access', _392 => _392[gridR], 'optionalAccess', _393 => _393[gridC]]);
|
|
26698
27013
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
26699
27014
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
26700
27015
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27086,7 +27401,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27086
27401
|
const block = st.blocks[blockIndex];
|
|
27087
27402
|
if (!block) return void 0;
|
|
27088
27403
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
27089
|
-
const para2 = _optionalChain([st, 'access',
|
|
27404
|
+
const para2 = _optionalChain([st, 'access', _394 => _394.paraMap, 'access', _395 => _395.get, 'call', _396 => _396(blockIndex), 'optionalAccess', _397 => _397.para]);
|
|
27090
27405
|
if (!para2) return void 0;
|
|
27091
27406
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
27092
27407
|
}
|
|
@@ -27111,7 +27426,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27111
27426
|
if (block.text && block.text.includes("\n")) {
|
|
27112
27427
|
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)" };
|
|
27113
27428
|
}
|
|
27114
|
-
if (!_optionalChain([st, 'access',
|
|
27429
|
+
if (!_optionalChain([st, 'access', _398 => _398.paraMap, 'access', _399 => _399.get, 'call', _400 => _400(blockIndex), 'optionalAccess', _401 => _401.para])) {
|
|
27115
27430
|
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)" };
|
|
27116
27431
|
}
|
|
27117
27432
|
return { capability: "text" };
|
|
@@ -27177,7 +27492,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27177
27492
|
continue;
|
|
27178
27493
|
}
|
|
27179
27494
|
if (block.type === "table" && block.table) {
|
|
27180
|
-
if (!_optionalChain([edit, 'access',
|
|
27495
|
+
if (!_optionalChain([edit, 'access', _402 => _402.cells, 'optionalAccess', _403 => _403.length])) {
|
|
27181
27496
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
27182
27497
|
continue;
|
|
27183
27498
|
}
|
|
@@ -27197,7 +27512,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27197
27512
|
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) });
|
|
27198
27513
|
continue;
|
|
27199
27514
|
}
|
|
27200
|
-
const irCell = _optionalChain([block, 'access',
|
|
27515
|
+
const irCell = _optionalChain([block, 'access', _404 => _404.table, 'access', _405 => _405.cells, 'access', _406 => _406[cellEdit.row], 'optionalAccess', _407 => _407[cellEdit.col]]);
|
|
27201
27516
|
if (!irCell) {
|
|
27202
27517
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
27203
27518
|
continue;
|
|
@@ -27253,7 +27568,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27253
27568
|
}
|
|
27254
27569
|
if (replacements.size === 0) {
|
|
27255
27570
|
let changes2;
|
|
27256
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27571
|
+
if (_optionalChain([options, 'optionalAccess', _408 => _408.verify]) !== false) {
|
|
27257
27572
|
const units = splitMarkdownUnits(st.markdown);
|
|
27258
27573
|
changes2 = diffUnitLists(units, units);
|
|
27259
27574
|
}
|
|
@@ -27274,7 +27589,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27274
27589
|
}
|
|
27275
27590
|
this.state = newState;
|
|
27276
27591
|
let changes;
|
|
27277
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27592
|
+
if (_optionalChain([options, 'optionalAccess', _409 => _409.verify]) !== false) {
|
|
27278
27593
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
27279
27594
|
}
|
|
27280
27595
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -27294,7 +27609,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27294
27609
|
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)");
|
|
27295
27610
|
}
|
|
27296
27611
|
const mapping = st.paraMap.get(blockIndex);
|
|
27297
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27612
|
+
if (!_optionalChain([mapping, 'optionalAccess', _410 => _410.para])) {
|
|
27298
27613
|
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)");
|
|
27299
27614
|
}
|
|
27300
27615
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -27314,14 +27629,14 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27314
27629
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27315
27630
|
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");
|
|
27316
27631
|
}
|
|
27317
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
27632
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _411 => _411.scans, 'access', _412 => _412[mapping.para.sectionIndex], 'optionalAccess', _413 => _413.xml]));
|
|
27318
27633
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27319
27634
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27320
27635
|
return 1;
|
|
27321
27636
|
}
|
|
27322
27637
|
}, _class6);
|
|
27323
27638
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
27324
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27639
|
+
const irCell = _optionalChain([table2, 'access', _414 => _414.cells, 'access', _415 => _415[r], 'optionalAccess', _416 => _416[c]]);
|
|
27325
27640
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
27326
27641
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
27327
27642
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -27405,11 +27720,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
27405
27720
|
breaks: false
|
|
27406
27721
|
});
|
|
27407
27722
|
function renderHtml(markdown, options) {
|
|
27408
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27409
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27723
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _417 => _417.preset]), () => ( "default"));
|
|
27724
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _418 => _418.extraCss]), () => ( "")));
|
|
27410
27725
|
const body = md.render(markdown);
|
|
27411
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
27412
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
27726
|
+
const watermark = _optionalChain([options, 'optionalAccess', _419 => _419.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
27727
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _420 => _420.watermark]) ? `
|
|
27413
27728
|
.watermark {
|
|
27414
27729
|
position: fixed;
|
|
27415
27730
|
top: 50%; left: 50%;
|
|
@@ -27440,13 +27755,13 @@ async function htmlToPdf(html, options) {
|
|
|
27440
27755
|
try {
|
|
27441
27756
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
27442
27757
|
} catch (e30) {
|
|
27443
|
-
throw new (0,
|
|
27758
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(
|
|
27444
27759
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
27445
27760
|
);
|
|
27446
27761
|
}
|
|
27447
27762
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
27448
27763
|
if (!executablePath) {
|
|
27449
|
-
throw new (0,
|
|
27764
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)(
|
|
27450
27765
|
"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."
|
|
27451
27766
|
);
|
|
27452
27767
|
}
|
|
@@ -27458,10 +27773,10 @@ async function htmlToPdf(html, options) {
|
|
|
27458
27773
|
try {
|
|
27459
27774
|
const page = await browser.newPage();
|
|
27460
27775
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
27461
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
27776
|
+
const margin = _optionalChain([options, 'optionalAccess', _421 => _421.margin]);
|
|
27462
27777
|
const pdf = await page.pdf({
|
|
27463
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27464
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
27778
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _422 => _422.pageSize]), () => ( "A4")),
|
|
27779
|
+
landscape: _optionalChain([options, 'optionalAccess', _423 => _423.orientation]) === "landscape",
|
|
27465
27780
|
printBackground: true,
|
|
27466
27781
|
margin: margin ? {
|
|
27467
27782
|
top: toCss(margin.top),
|
|
@@ -27469,9 +27784,9 @@ async function htmlToPdf(html, options) {
|
|
|
27469
27784
|
bottom: toCss(margin.bottom),
|
|
27470
27785
|
left: toCss(margin.left)
|
|
27471
27786
|
} : void 0,
|
|
27472
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
27473
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27474
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27787
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _424 => _424.header]) || _optionalChain([options, 'optionalAccess', _425 => _425.footer])),
|
|
27788
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _426 => _426.header]), () => ( "<div></div>")),
|
|
27789
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _427 => _427.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
27475
27790
|
});
|
|
27476
27791
|
return Buffer.from(pdf);
|
|
27477
27792
|
} finally {
|
|
@@ -27505,7 +27820,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
27505
27820
|
return htmlToPdf(html, options);
|
|
27506
27821
|
}
|
|
27507
27822
|
async function blocksToPdf(blocks, options) {
|
|
27508
|
-
const markdown =
|
|
27823
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, blocks);
|
|
27509
27824
|
return markdownToPdf(markdown, options);
|
|
27510
27825
|
}
|
|
27511
27826
|
|
|
@@ -27716,7 +28031,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
27716
28031
|
if (ln(p) !== "p") continue;
|
|
27717
28032
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
27718
28033
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
27719
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
28034
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _428 => _428.spaceBefore]), () => ( 0)));
|
|
27720
28035
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
27721
28036
|
if (res) {
|
|
27722
28037
|
const paraH = res.paraBottom - startV;
|
|
@@ -27825,7 +28140,7 @@ function buildPara(p) {
|
|
|
27825
28140
|
el: ch,
|
|
27826
28141
|
tag: cn,
|
|
27827
28142
|
index: chars.length,
|
|
27828
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
28143
|
+
inline: _optionalChain([pos, 'optionalAccess', _429 => _429.getAttribute, 'call', _430 => _430("treatAsChar")]) === "1",
|
|
27829
28144
|
width: w,
|
|
27830
28145
|
height: h
|
|
27831
28146
|
});
|
|
@@ -28077,15 +28392,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
28077
28392
|
const sx = ow > 0 ? w / ow : 1;
|
|
28078
28393
|
const sy = oh > 0 ? h / oh : 1;
|
|
28079
28394
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
28080
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
28081
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
28395
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _431 => _431.getAttribute, 'call', _432 => _432("style")]), () => ( "SOLID"));
|
|
28396
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _433 => _433.getAttribute, 'call', _434 => _434("color")]) || "#000000";
|
|
28082
28397
|
const hasStroke = lstyle !== "NONE";
|
|
28083
28398
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
28084
28399
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
28085
28400
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
28086
28401
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
28087
28402
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
28088
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
28403
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _435 => _435.getAttribute, 'call', _436 => _436("faceColor")]);
|
|
28089
28404
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
28090
28405
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
28091
28406
|
if (o.tag === "rect") {
|
|
@@ -28117,7 +28432,7 @@ function cellContentExtent(cell2) {
|
|
|
28117
28432
|
if (ln2(p) !== "p") continue;
|
|
28118
28433
|
const m = buildPara(p);
|
|
28119
28434
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
28120
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
28435
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _437 => _437.segs, 'access', _438 => _438[0], 'optionalAccess', _439 => _439.vertpos]), () => ( 0));
|
|
28121
28436
|
for (const o of m.objs) {
|
|
28122
28437
|
if (o.inline) {
|
|
28123
28438
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -28125,7 +28440,7 @@ function cellContentExtent(cell2) {
|
|
|
28125
28440
|
continue;
|
|
28126
28441
|
}
|
|
28127
28442
|
const pos = findChildByLocalName(o.el, "pos");
|
|
28128
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
28443
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _440 => _440.getAttribute, 'call', _441 => _441("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
28129
28444
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
28130
28445
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
28131
28446
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
@@ -28211,7 +28526,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
28211
28526
|
}));
|
|
28212
28527
|
for (const g of geom) {
|
|
28213
28528
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
28214
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
28529
|
+
if (_optionalChain([bf, 'optionalAccess', _442 => _442.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
28215
28530
|
}
|
|
28216
28531
|
for (const g of geom) {
|
|
28217
28532
|
const { c } = g;
|
|
@@ -28249,7 +28564,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
28249
28564
|
const sz = findChildByLocalName(pic, "sz");
|
|
28250
28565
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
28251
28566
|
const img = findFirst(pic, "img");
|
|
28252
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
28567
|
+
const ref = _optionalChain([img, 'optionalAccess', _443 => _443.getAttribute, 'call', _444 => _444("binaryItemIDRef")]);
|
|
28253
28568
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
28254
28569
|
if (!loaded) {
|
|
28255
28570
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -28288,7 +28603,7 @@ function readSectionGeom(root) {
|
|
|
28288
28603
|
const pagePr = findFirst(root, "pagePr");
|
|
28289
28604
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
28290
28605
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
28291
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
28606
|
+
if (_optionalChain([pagePr, 'optionalAccess', _445 => _445.getAttribute, 'call', _446 => _446("landscape")]) === "NARROWLY" && PW < PH) {
|
|
28292
28607
|
const t = PW;
|
|
28293
28608
|
PW = PH;
|
|
28294
28609
|
PH = t;
|
|
@@ -28346,17 +28661,17 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
28346
28661
|
return { pages: ctx.pages, pageH };
|
|
28347
28662
|
}
|
|
28348
28663
|
async function renderHwpxToSvg(input, options) {
|
|
28349
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28664
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _447 => _447.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
28350
28665
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
28351
|
-
|
|
28666
|
+
_chunkOVESZY5Rcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
28352
28667
|
let zip;
|
|
28353
28668
|
try {
|
|
28354
28669
|
zip = await _jszip2.default.loadAsync(input);
|
|
28355
28670
|
} catch (e31) {
|
|
28356
|
-
throw new (0,
|
|
28671
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
28357
28672
|
}
|
|
28358
28673
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
28359
|
-
if (secFiles.length === 0) throw new (0,
|
|
28674
|
+
if (secFiles.length === 0) throw new (0, _chunkOVESZY5Rcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
28360
28675
|
const warnings = [];
|
|
28361
28676
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
28362
28677
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -28364,7 +28679,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28364
28679
|
const secXmls = [];
|
|
28365
28680
|
for (const f of secFiles) {
|
|
28366
28681
|
const xml = await f.async("string");
|
|
28367
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
28682
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
28368
28683
|
secXmls.push(xml);
|
|
28369
28684
|
}
|
|
28370
28685
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -28388,7 +28703,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28388
28703
|
let href = binmap.get(ref);
|
|
28389
28704
|
if (!href) {
|
|
28390
28705
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
28391
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
28706
|
+
href = _optionalChain([cand, 'optionalAccess', _448 => _448.name]);
|
|
28392
28707
|
}
|
|
28393
28708
|
if (!href) continue;
|
|
28394
28709
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -28409,7 +28724,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28409
28724
|
styles,
|
|
28410
28725
|
images,
|
|
28411
28726
|
defs: [],
|
|
28412
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28727
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _449 => _449.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
28413
28728
|
warnings,
|
|
28414
28729
|
warned: /* @__PURE__ */ new Set(),
|
|
28415
28730
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -28419,7 +28734,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28419
28734
|
for (let si = 0; si < secXmls.length; si++) {
|
|
28420
28735
|
const secXml = secXmls[si];
|
|
28421
28736
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
28422
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
28737
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _450 => _450.reflow])) {
|
|
28423
28738
|
noCacheSkipped = true;
|
|
28424
28739
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
28425
28740
|
continue;
|
|
@@ -28431,14 +28746,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28431
28746
|
continue;
|
|
28432
28747
|
}
|
|
28433
28748
|
const geom = readSectionGeom(root);
|
|
28434
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28749
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _451 => _451.reflowMode]), () => ( "keep")));
|
|
28435
28750
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
28436
28751
|
}
|
|
28437
28752
|
if (rendered.length === 0) {
|
|
28438
28753
|
if (noCacheSkipped) {
|
|
28439
|
-
throw new (0,
|
|
28754
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
|
|
28440
28755
|
}
|
|
28441
|
-
throw new (0,
|
|
28756
|
+
throw new (0, _chunkOVESZY5Rcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
28442
28757
|
}
|
|
28443
28758
|
const GAP = 2400;
|
|
28444
28759
|
const clipDefs = [];
|
|
@@ -28470,17 +28785,17 @@ ${groups.join("\n")}
|
|
|
28470
28785
|
// src/index.ts
|
|
28471
28786
|
async function parse(input, options) {
|
|
28472
28787
|
let buffer;
|
|
28473
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
28788
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _452 => _452.filePath]) ? { ...options, filePath: input } : options;
|
|
28474
28789
|
if (typeof input === "string") {
|
|
28475
28790
|
try {
|
|
28476
28791
|
const buf = await _promises.readFile.call(void 0, input);
|
|
28477
|
-
buffer =
|
|
28792
|
+
buffer = _chunkOVESZY5Rcjs.toArrayBuffer.call(void 0, buf);
|
|
28478
28793
|
} catch (err) {
|
|
28479
28794
|
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}`;
|
|
28480
28795
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
28481
28796
|
}
|
|
28482
28797
|
} else if (Buffer.isBuffer(input)) {
|
|
28483
|
-
buffer =
|
|
28798
|
+
buffer = _chunkOVESZY5Rcjs.toArrayBuffer.call(void 0, input);
|
|
28484
28799
|
} else {
|
|
28485
28800
|
buffer = input;
|
|
28486
28801
|
}
|
|
@@ -28515,21 +28830,21 @@ async function parseHwp3(buffer, options) {
|
|
|
28515
28830
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
28516
28831
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
28517
28832
|
} catch (err) {
|
|
28518
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28833
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28519
28834
|
}
|
|
28520
28835
|
}
|
|
28521
28836
|
async function parseHwpx(buffer, options) {
|
|
28522
28837
|
try {
|
|
28523
28838
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
28524
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28839
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _453 => _453.length]) ? images : void 0 };
|
|
28525
28840
|
} catch (err) {
|
|
28526
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28841
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28527
28842
|
}
|
|
28528
28843
|
}
|
|
28529
28844
|
async function parseHwp(buffer, options) {
|
|
28530
28845
|
try {
|
|
28531
28846
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
28532
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
28847
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _454 => _454.filePath])) {
|
|
28533
28848
|
try {
|
|
28534
28849
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
28535
28850
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -28546,15 +28861,15 @@ async function parseHwp(buffer, options) {
|
|
|
28546
28861
|
} catch (e32) {
|
|
28547
28862
|
}
|
|
28548
28863
|
}
|
|
28549
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28864
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _455 => _455.length]) ? images : void 0 };
|
|
28550
28865
|
} catch (err) {
|
|
28551
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28866
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28552
28867
|
}
|
|
28553
28868
|
}
|
|
28554
28869
|
async function parsePdf(buffer, options) {
|
|
28555
28870
|
let parsePdfDocument;
|
|
28556
28871
|
try {
|
|
28557
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
28872
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-FMONFTAN.cjs")));
|
|
28558
28873
|
parsePdfDocument = mod.parsePdfDocument;
|
|
28559
28874
|
} catch (e33) {
|
|
28560
28875
|
return {
|
|
@@ -28569,7 +28884,7 @@ async function parsePdf(buffer, options) {
|
|
|
28569
28884
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
28570
28885
|
} catch (err) {
|
|
28571
28886
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
28572
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28887
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err), isImageBased };
|
|
28573
28888
|
}
|
|
28574
28889
|
}
|
|
28575
28890
|
async function parseXlsx(buffer, options) {
|
|
@@ -28577,7 +28892,7 @@ async function parseXlsx(buffer, options) {
|
|
|
28577
28892
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
28578
28893
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
28579
28894
|
} catch (err) {
|
|
28580
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28895
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28581
28896
|
}
|
|
28582
28897
|
}
|
|
28583
28898
|
async function parseXls(buffer, options) {
|
|
@@ -28585,15 +28900,15 @@ async function parseXls(buffer, options) {
|
|
|
28585
28900
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
28586
28901
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
28587
28902
|
} catch (err) {
|
|
28588
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28903
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28589
28904
|
}
|
|
28590
28905
|
}
|
|
28591
28906
|
async function parseDocx(buffer, options) {
|
|
28592
28907
|
try {
|
|
28593
28908
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
28594
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28909
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _456 => _456.length]) ? images : void 0 };
|
|
28595
28910
|
} catch (err) {
|
|
28596
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28911
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28597
28912
|
}
|
|
28598
28913
|
}
|
|
28599
28914
|
async function parseHwpml(buffer, options) {
|
|
@@ -28601,16 +28916,16 @@ async function parseHwpml(buffer, options) {
|
|
|
28601
28916
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
28602
28917
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
28603
28918
|
} catch (err) {
|
|
28604
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28919
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkOVESZY5Rcjs.classifyError.call(void 0, err) };
|
|
28605
28920
|
}
|
|
28606
28921
|
}
|
|
28607
28922
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
28608
28923
|
let buffer;
|
|
28609
28924
|
if (typeof input === "string") {
|
|
28610
28925
|
const buf = await _promises.readFile.call(void 0, input);
|
|
28611
|
-
buffer =
|
|
28926
|
+
buffer = _chunkOVESZY5Rcjs.toArrayBuffer.call(void 0, buf);
|
|
28612
28927
|
} else if (Buffer.isBuffer(input)) {
|
|
28613
|
-
buffer =
|
|
28928
|
+
buffer = _chunkOVESZY5Rcjs.toArrayBuffer.call(void 0, input);
|
|
28614
28929
|
} else {
|
|
28615
28930
|
buffer = input;
|
|
28616
28931
|
}
|
|
@@ -28636,7 +28951,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
28636
28951
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
28637
28952
|
}
|
|
28638
28953
|
const fill = fillFormFields(parsed.blocks, values);
|
|
28639
|
-
const markdown =
|
|
28954
|
+
const markdown = _chunkOVESZY5Rcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
28640
28955
|
if (outputFormat === "hwpx") {
|
|
28641
28956
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
28642
28957
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -28704,5 +29019,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
28704
29019
|
|
|
28705
29020
|
|
|
28706
29021
|
|
|
28707
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
29022
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkOVESZY5Rcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkOVESZY5Rcjs.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.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; 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.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
28708
29023
|
//# sourceMappingURL=index.cjs.map
|