kordoc 4.2.6 → 4.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-UYYP67I6.js → -SCTT2TBZ.js} +9 -9
- package/dist/{chunk-6XVQSILN.cjs → chunk-2BTKLDNX.cjs} +4 -4
- package/dist/chunk-2BTKLDNX.cjs.map +1 -0
- package/dist/{chunk-YHAB7UP6.js → chunk-4FTXKIGT.js} +2 -2
- package/dist/{chunk-YF6JUAM7.js → chunk-55QIELGV.js} +3 -3
- package/dist/{chunk-O5JOHYCV.js → chunk-7GEBDS6B.js} +2 -2
- package/dist/{chunk-LIG666DX.cjs → chunk-CELJIGBQ.cjs} +3 -3
- package/dist/chunk-CELJIGBQ.cjs.map +1 -0
- package/dist/{chunk-DSCSR6NE.js → chunk-COHHXQSP.js} +2 -2
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-EGQQVYKL.js → chunk-EOVJ27WC.js} +3 -3
- package/dist/{chunk-64DMMXFW.js → chunk-FS3XQ3ZQ.js} +2 -2
- package/dist/{chunk-QPPOC6OL.js → chunk-GKSFNCVP.js} +2 -2
- package/dist/chunk-GKSFNCVP.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/chunk-H7OWEYH2.cjs.map +1 -1
- package/dist/{chunk-NVPCKSNL.js → chunk-IJUAWDOS.js} +3 -3
- package/dist/{chunk-6KT4B4QX.js → chunk-JP5MNHUK.js} +2 -2
- package/dist/{chunk-GJO3ORFW.js → chunk-LM7C6HI2.js} +1 -1
- package/dist/chunk-LM7C6HI2.js.map +1 -0
- package/dist/{chunk-5FS4IZWY.cjs → chunk-OQNFGKRY.cjs} +2 -2
- package/dist/chunk-OQNFGKRY.cjs.map +1 -0
- package/dist/{chunk-5E7ZMWDF.js → chunk-QZCAIFUW.js} +2 -2
- package/dist/{chunk-ZB3WT7XX.cjs → chunk-ROKHZE76.cjs} +9 -9
- package/dist/chunk-ROKHZE76.cjs.map +1 -0
- package/dist/{chunk-N4BFHNLA.js → chunk-UKEZ46VL.js} +2 -2
- package/dist/{chunk-SYJ6FPPQ.js → chunk-URKX77GB.js} +2 -2
- package/dist/{chunk-TZLLCYDN.js → chunk-WP4VD5T7.js} +2 -2
- package/dist/chunk-WP4VD5T7.js.map +1 -0
- package/dist/{chunk-VQ5NQBL2.js → chunk-YNAPK4H6.js} +65 -32
- package/dist/chunk-YNAPK4H6.js.map +1 -0
- package/dist/chunks-KKYJDJT7.js +10 -0
- package/dist/cli.js +17 -17
- package/dist/formula-SB3NHDUM.cjs.map +1 -1
- package/dist/{image-ocr-WN3UO4UY.js → image-ocr-ANSXR5KJ.js} +4 -4
- package/dist/{image-ocr-YOUVLJIH.cjs → image-ocr-GHQ6YKJH.cjs} +9 -9
- package/dist/image-ocr-GHQ6YKJH.cjs.map +1 -0
- package/dist/{image-ocr-FXLX2GM6.js → image-ocr-ORATZW73.js} +5 -5
- package/dist/index.cjs +490 -457
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +60 -27
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +15 -15
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-KIXK2IEX.js → parser-BPVTYM5K.js} +5 -5
- package/dist/{parser-KYSMRSMJ.js → parser-GZDOZCHM.js} +6 -6
- package/dist/{parser-AUMEO4OU.cjs → parser-KTNIUF2N.cjs} +24 -24
- package/dist/parser-KTNIUF2N.cjs.map +1 -0
- package/dist/pdf-ocr-6XKLXZTF.cjs +13 -0
- package/dist/pdf-ocr-6XKLXZTF.cjs.map +1 -0
- package/dist/pdf-ocr-HWPNMKKC.js +12 -0
- package/dist/{pdf-ocr-NQFV46WZ.js → pdf-ocr-W2PA2K3U.js} +5 -5
- package/dist/{profile-io-NKUXEPI4.js → profile-io-I2TH44EO.js} +3 -3
- package/dist/{rasterize-OT5TROD4.js → rasterize-QBA43YAQ.js} +2 -2
- package/dist/render-MDJDKKNH.js +10 -0
- package/dist/seal-Z52JR2GX.js +10 -0
- package/dist/{watch-6KMSCCM5.js → watch-7V6X7LHV.js} +9 -9
- package/package.json +1 -1
- package/dist/chunk-5FS4IZWY.cjs.map +0 -1
- package/dist/chunk-6XVQSILN.cjs.map +0 -1
- package/dist/chunk-GJO3ORFW.js.map +0 -1
- package/dist/chunk-LIG666DX.cjs.map +0 -1
- package/dist/chunk-QPPOC6OL.js.map +0 -1
- package/dist/chunk-TZLLCYDN.js.map +0 -1
- package/dist/chunk-VQ5NQBL2.js.map +0 -1
- package/dist/chunk-ZB3WT7XX.cjs.map +0 -1
- package/dist/chunks-G7YDTLNI.js +0 -10
- package/dist/image-ocr-YOUVLJIH.cjs.map +0 -1
- package/dist/parser-AUMEO4OU.cjs.map +0 -1
- package/dist/pdf-ocr-2QOASWPI.js +0 -12
- package/dist/pdf-ocr-BUKZ5R4P.cjs +0 -13
- package/dist/pdf-ocr-BUKZ5R4P.cjs.map +0 -1
- package/dist/render-HQTKZ3ZE.js +0 -10
- package/dist/seal-KH6IL23B.js +0 -10
- /package/dist/{-UYYP67I6.js.map → -SCTT2TBZ.js.map} +0 -0
- /package/dist/{chunk-YHAB7UP6.js.map → chunk-4FTXKIGT.js.map} +0 -0
- /package/dist/{chunk-YF6JUAM7.js.map → chunk-55QIELGV.js.map} +0 -0
- /package/dist/{chunk-O5JOHYCV.js.map → chunk-7GEBDS6B.js.map} +0 -0
- /package/dist/{chunk-DSCSR6NE.js.map → chunk-COHHXQSP.js.map} +0 -0
- /package/dist/{chunk-EGQQVYKL.js.map → chunk-EOVJ27WC.js.map} +0 -0
- /package/dist/{chunk-64DMMXFW.js.map → chunk-FS3XQ3ZQ.js.map} +0 -0
- /package/dist/{chunk-NVPCKSNL.js.map → chunk-IJUAWDOS.js.map} +0 -0
- /package/dist/{chunk-6KT4B4QX.js.map → chunk-JP5MNHUK.js.map} +0 -0
- /package/dist/{chunk-5E7ZMWDF.js.map → chunk-QZCAIFUW.js.map} +0 -0
- /package/dist/{chunk-N4BFHNLA.js.map → chunk-UKEZ46VL.js.map} +0 -0
- /package/dist/{chunk-SYJ6FPPQ.js.map → chunk-URKX77GB.js.map} +0 -0
- /package/dist/{chunks-G7YDTLNI.js.map → chunks-KKYJDJT7.js.map} +0 -0
- /package/dist/{image-ocr-WN3UO4UY.js.map → image-ocr-ANSXR5KJ.js.map} +0 -0
- /package/dist/{image-ocr-FXLX2GM6.js.map → image-ocr-ORATZW73.js.map} +0 -0
- /package/dist/{parser-KIXK2IEX.js.map → parser-BPVTYM5K.js.map} +0 -0
- /package/dist/{parser-KYSMRSMJ.js.map → parser-GZDOZCHM.js.map} +0 -0
- /package/dist/{pdf-ocr-2QOASWPI.js.map → pdf-ocr-HWPNMKKC.js.map} +0 -0
- /package/dist/{pdf-ocr-NQFV46WZ.js.map → pdf-ocr-W2PA2K3U.js.map} +0 -0
- /package/dist/{profile-io-NKUXEPI4.js.map → profile-io-I2TH44EO.js.map} +0 -0
- /package/dist/{rasterize-OT5TROD4.js.map → rasterize-QBA43YAQ.js.map} +0 -0
- /package/dist/{render-HQTKZ3ZE.js.map → render-MDJDKKNH.js.map} +0 -0
- /package/dist/{seal-KH6IL23B.js.map → seal-Z52JR2GX.js.map} +0 -0
- /package/dist/{watch-6KMSCCM5.js.map → watch-7V6X7LHV.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk2BTKLDNXcjs = require('./chunk-2BTKLDNX.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -27,7 +27,7 @@ var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkOQNFGKRYcjs = require('./chunk-OQNFGKRY.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -413,7 +413,7 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
413
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
414
414
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
415
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
416
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkOQNFGKRYcjs.KordocError {
|
|
417
417
|
constructor(message) {
|
|
418
418
|
super(message);
|
|
419
419
|
this.name = "ZipBombError";
|
|
@@ -429,7 +429,7 @@ function createSectionShared() {
|
|
|
429
429
|
function createXmlParser(warnings) {
|
|
430
430
|
return new (0, _xmldom.DOMParser)({
|
|
431
431
|
onError(level, msg2) {
|
|
432
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkOQNFGKRYcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
433
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -506,10 +506,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
506
506
|
const xml = await file.async("text");
|
|
507
507
|
if (decompressed) {
|
|
508
508
|
decompressed.total += xml.length * 2;
|
|
509
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
509
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
510
510
|
}
|
|
511
511
|
const parser = createXmlParser();
|
|
512
|
-
const doc = parser.parseFromString(
|
|
512
|
+
const doc = parser.parseFromString(_chunkOQNFGKRYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
513
513
|
if (!doc.documentElement) continue;
|
|
514
514
|
const domDoc = doc;
|
|
515
515
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -696,9 +696,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
696
696
|
let level = 0;
|
|
697
697
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
698
698
|
const ratio = block.style.fontSize / baseFontSize;
|
|
699
|
-
if (ratio >=
|
|
700
|
-
else if (ratio >=
|
|
701
|
-
else if (ratio >=
|
|
699
|
+
if (ratio >= _chunkOQNFGKRYcjs.HEADING_RATIO_H1) level = 1;
|
|
700
|
+
else if (ratio >= _chunkOQNFGKRYcjs.HEADING_RATIO_H2) level = 2;
|
|
701
|
+
else if (ratio >= _chunkOQNFGKRYcjs.HEADING_RATIO_H3) level = 3;
|
|
702
702
|
}
|
|
703
703
|
const compactText = text.replace(/\s+/g, "");
|
|
704
704
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1623,7 +1623,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
function assertFiniteRange(name, value, min, max) {
|
|
1625
1625
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1626
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1627
1627
|
}
|
|
1628
1628
|
}
|
|
1629
1629
|
function validateGongmunOptions(opts) {
|
|
@@ -1638,10 +1638,10 @@ function validateGongmunOptions(opts) {
|
|
|
1638
1638
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1639
1639
|
}
|
|
1640
1640
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1641
|
-
throw new (0,
|
|
1641
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1642
1642
|
}
|
|
1643
1643
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1644
|
-
throw new (0,
|
|
1644
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1645
1645
|
}
|
|
1646
1646
|
}
|
|
1647
1647
|
if (opts.sizes) {
|
|
@@ -1650,7 +1650,7 @@ function validateGongmunOptions(opts) {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
if (opts.approval && opts.approval.length > 6) {
|
|
1653
|
-
throw new (0,
|
|
1653
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("approval must contain at most 6 labels");
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1915,15 +1915,16 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1915
1915
|
|
|
1916
1916
|
// src/hwpx/table-build.ts
|
|
1917
1917
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1918
|
-
const table2 =
|
|
1918
|
+
const table2 = _chunk2BTKLDNXcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1919
1919
|
if (state.caption) table2.caption = state.caption;
|
|
1920
|
+
if (_optionalChain([state, 'access', _25 => _25.captionBlocks, 'optionalAccess', _26 => _26.length])) table2.captionBlocks = state.captionBlocks;
|
|
1920
1921
|
const anchors = [];
|
|
1921
1922
|
{
|
|
1922
1923
|
const covered = /* @__PURE__ */ new Set();
|
|
1923
1924
|
for (let r = 0; r < table2.rows; r++) {
|
|
1924
1925
|
for (let c = 0; c < table2.cols; c++) {
|
|
1925
1926
|
if (covered.has(`${r},${c}`)) continue;
|
|
1926
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
1927
|
+
const cell2 = _optionalChain([table2, 'access', _27 => _27.cells, 'access', _28 => _28[r], 'optionalAccess', _29 => _29[c]]);
|
|
1927
1928
|
if (!cell2) continue;
|
|
1928
1929
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
1929
1930
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -1948,7 +1949,7 @@ function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
|
1948
1949
|
let target;
|
|
1949
1950
|
const trimmed = src.text.trim();
|
|
1950
1951
|
if (src.rowAddr !== void 0 && src.colAddr !== void 0) {
|
|
1951
|
-
const cand = _optionalChain([table2, 'access',
|
|
1952
|
+
const cand = _optionalChain([table2, 'access', _30 => _30.cells, 'access', _31 => _31[src.rowAddr], 'optionalAccess', _32 => _32[src.colAddr]]);
|
|
1952
1953
|
if (cand && cand.text === trimmed && !claimed.has(cand)) target = cand;
|
|
1953
1954
|
}
|
|
1954
1955
|
if (!target) {
|
|
@@ -1981,11 +1982,11 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1981
1982
|
}
|
|
1982
1983
|
const ir = buildTableWithCellMeta(newTable, ctx.shared.keepTrailingEmptyCols);
|
|
1983
1984
|
const block = { type: "table", table: ir, pageNumber: ctx.sectionNum };
|
|
1984
|
-
if (_optionalChain([parentTable, 'optionalAccess',
|
|
1985
|
+
if (_optionalChain([parentTable, 'optionalAccess', _33 => _33.cell])) {
|
|
1985
1986
|
const cell2 = parentTable.cell;
|
|
1986
1987
|
(cell2.blocks ??= []).push(block);
|
|
1987
1988
|
cell2.hasStructure = true;
|
|
1988
|
-
let flat =
|
|
1989
|
+
let flat = _chunk2BTKLDNXcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1989
1990
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1990
1991
|
if (flat) {
|
|
1991
1992
|
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
@@ -2001,7 +2002,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
2001
2002
|
// src/hwpx/section-walker.ts
|
|
2002
2003
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
2003
2004
|
const parser = createXmlParser(warnings);
|
|
2004
|
-
const doc = parser.parseFromString(
|
|
2005
|
+
const doc = parser.parseFromString(_chunkOQNFGKRYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2005
2006
|
if (!doc.documentElement) return [];
|
|
2006
2007
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
2007
2008
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2064,12 +2065,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2064
2065
|
}
|
|
2065
2066
|
// 표/도표 캡션 — IRTable.caption으로 보존 (v3.0, 기존 무음 드롭 수정)
|
|
2066
2067
|
case "caption": {
|
|
2067
|
-
const
|
|
2068
|
-
if (
|
|
2068
|
+
const cap = collectSubListContent(el, ctx);
|
|
2069
|
+
if (cap.text) {
|
|
2069
2070
|
if (tableCtx) {
|
|
2070
|
-
tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") +
|
|
2071
|
+
tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + cap.text;
|
|
2072
|
+
if (cap.hasStructure) (tableCtx.captionBlocks ??= []).push(...cap.blocks);
|
|
2071
2073
|
} else {
|
|
2072
|
-
blocks.push({ type: "paragraph", text:
|
|
2074
|
+
blocks.push({ type: "paragraph", text: cap.text, pageNumber: ctx.sectionNum });
|
|
2073
2075
|
}
|
|
2074
2076
|
}
|
|
2075
2077
|
break;
|
|
@@ -2094,7 +2096,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2094
2096
|
}
|
|
2095
2097
|
break;
|
|
2096
2098
|
case "cellAddr":
|
|
2097
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2099
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _34 => _34.cell])) {
|
|
2098
2100
|
const ca = parseInt(el.getAttribute("colAddr") || "", 10);
|
|
2099
2101
|
const ra = parseInt(el.getAttribute("rowAddr") || "", 10);
|
|
2100
2102
|
if (!isNaN(ca)) tableCtx.cell.colAddr = ca;
|
|
@@ -2102,13 +2104,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2102
2104
|
}
|
|
2103
2105
|
break;
|
|
2104
2106
|
case "cellSpan":
|
|
2105
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2107
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _35 => _35.cell])) {
|
|
2106
2108
|
const rawCs = parseInt(el.getAttribute("colSpan") || "1", 10);
|
|
2107
2109
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2108
2110
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2109
2111
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2110
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2111
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2112
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunk2BTKLDNXcjs.MAX_COLS);
|
|
2113
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunk2BTKLDNXcjs.MAX_ROWS);
|
|
2112
2114
|
}
|
|
2113
2115
|
break;
|
|
2114
2116
|
case "p": {
|
|
@@ -2117,14 +2119,14 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2117
2119
|
let headingLevel;
|
|
2118
2120
|
const ph = resolveParaHeading(el, ctx);
|
|
2119
2121
|
if (text) {
|
|
2120
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
2121
|
-
headingLevel = _optionalChain([ph, 'optionalAccess',
|
|
2122
|
+
if (_optionalChain([ph, 'optionalAccess', _36 => _36.prefix])) text = ph.prefix + " " + text;
|
|
2123
|
+
headingLevel = _optionalChain([ph, 'optionalAccess', _37 => _37.headingLevel]);
|
|
2122
2124
|
}
|
|
2123
2125
|
if (segments) {
|
|
2124
|
-
const cell2 = _nullishCoalesce(_optionalChain([tableCtx, 'optionalAccess',
|
|
2126
|
+
const cell2 = _nullishCoalesce(_optionalChain([tableCtx, 'optionalAccess', _38 => _38.cell]), () => ( null));
|
|
2125
2127
|
if (cell2) cell2.lineOpen = false;
|
|
2126
2128
|
const segs = [...segments];
|
|
2127
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
2129
|
+
if (_optionalChain([ph, 'optionalAccess', _39 => _39.prefix])) {
|
|
2128
2130
|
const fi = segs.findIndex((s) => s);
|
|
2129
2131
|
if (fi >= 0) segs[fi] = ph.prefix + " " + segs[fi];
|
|
2130
2132
|
}
|
|
@@ -2152,13 +2154,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2152
2154
|
break;
|
|
2153
2155
|
}
|
|
2154
2156
|
if (text) {
|
|
2155
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2157
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _40 => _40.cell])) {
|
|
2156
2158
|
const cell2 = tableCtx.cell;
|
|
2157
2159
|
if (footnote) text += ` (\uC8FC: ${footnote})`;
|
|
2158
2160
|
cell2.text += (cell2.text ? "\n" : "") + text;
|
|
2159
2161
|
const cellBlock = { type: "paragraph", text, pageNumber: ctx.sectionNum };
|
|
2160
2162
|
const cellSpanMode = spanModeOf(ctx.shared.kordocLayout);
|
|
2161
|
-
if (cellSpanMode && !_optionalChain([ph, 'optionalAccess',
|
|
2163
|
+
if (cellSpanMode && !_optionalChain([ph, 'optionalAccess', _41 => _41.prefix])) {
|
|
2162
2164
|
const spans = extractRunSpans(el, ctx, cellSpanMode, cellSpanMode !== "kordoc");
|
|
2163
2165
|
if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
|
|
2164
2166
|
cellBlock.spans = spans;
|
|
@@ -2177,7 +2179,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2177
2179
|
if (style) block.style = style;
|
|
2178
2180
|
if (href) block.href = href;
|
|
2179
2181
|
if (footnote) block.footnoteText = footnote;
|
|
2180
|
-
const ind = _optionalChain([ctx, 'access',
|
|
2182
|
+
const ind = _optionalChain([ctx, 'access', _42 => _42.styleMap, 'optionalAccess', _43 => _43.paraIndents, 'access', _44 => _44.get, 'call', _45 => _45(_nullishCoalesce(el.getAttribute("paraPrIDRef"), () => ( "")))]);
|
|
2181
2183
|
if (ind) {
|
|
2182
2184
|
const eff = ind.left + Math.max(0, ind.intent);
|
|
2183
2185
|
if (eff > 0) block.indent = eff;
|
|
@@ -2188,7 +2190,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2188
2190
|
}
|
|
2189
2191
|
const spanMode = spanModeOf(ctx.shared.kordocLayout);
|
|
2190
2192
|
if (!headingLevel && spanMode) {
|
|
2191
|
-
if (!_optionalChain([ph, 'optionalAccess',
|
|
2193
|
+
if (!_optionalChain([ph, 'optionalAccess', _46 => _46.prefix])) {
|
|
2192
2194
|
const spans = extractRunSpans(el, ctx, spanMode, spanMode === "gongmun");
|
|
2193
2195
|
if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
|
|
2194
2196
|
block.spans = spans;
|
|
@@ -2208,7 +2210,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2208
2210
|
case "pic":
|
|
2209
2211
|
case "shape":
|
|
2210
2212
|
case "drawingObject": {
|
|
2211
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2213
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _47 => _47.cell])) {
|
|
2212
2214
|
const sink = [];
|
|
2213
2215
|
handleShape(el, sink, ctx);
|
|
2214
2216
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -2313,46 +2315,66 @@ function hasPageAutoNum(el, depth = 0) {
|
|
|
2313
2315
|
const ch = children[i];
|
|
2314
2316
|
if (ch.nodeType !== 1) continue;
|
|
2315
2317
|
const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
|
|
2316
|
-
if (tag === "autoNum" && _optionalChain([ch, 'access',
|
|
2318
|
+
if (tag === "autoNum" && _optionalChain([ch, 'access', _48 => _48.getAttribute, 'optionalCall', _49 => _49("numType")]) === "PAGE") return true;
|
|
2317
2319
|
if (hasPageAutoNum(ch, depth + 1)) return true;
|
|
2318
2320
|
}
|
|
2319
2321
|
return false;
|
|
2320
2322
|
}
|
|
2321
2323
|
function collectSubListText(el, ctx, depth = 0) {
|
|
2322
|
-
|
|
2324
|
+
return collectSubListContent(el, ctx, depth).text;
|
|
2325
|
+
}
|
|
2326
|
+
function collectSubListContent(el, ctx, depth = 0) {
|
|
2327
|
+
const out = { text: "", blocks: [], hasStructure: false };
|
|
2328
|
+
if (depth > 10) return out;
|
|
2323
2329
|
const parts = [];
|
|
2324
2330
|
const children = el.childNodes;
|
|
2325
|
-
if (!children) return
|
|
2331
|
+
if (!children) return out;
|
|
2326
2332
|
for (let i = 0; i < children.length; i++) {
|
|
2327
2333
|
const ch = children[i];
|
|
2328
2334
|
if (ch.nodeType !== 1) continue;
|
|
2329
2335
|
const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
|
|
2330
2336
|
if (tag === "p" || tag === "para") {
|
|
2331
2337
|
const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
|
|
2332
|
-
if (t)
|
|
2338
|
+
if (t) {
|
|
2339
|
+
parts.push(t);
|
|
2340
|
+
out.blocks.push({ type: "paragraph", text: t, pageNumber: ctx.sectionNum });
|
|
2341
|
+
}
|
|
2333
2342
|
const tbls = [];
|
|
2334
2343
|
findTopLevelTbls(ch, tbls);
|
|
2335
2344
|
for (const tbl2 of tbls) {
|
|
2336
|
-
const
|
|
2337
|
-
if (
|
|
2345
|
+
const built = buildSubListTable(tbl2, ctx, depth);
|
|
2346
|
+
if (built.text) parts.push(built.text);
|
|
2347
|
+
if (built.block) {
|
|
2348
|
+
out.blocks.push(built.block);
|
|
2349
|
+
out.hasStructure = true;
|
|
2350
|
+
}
|
|
2338
2351
|
}
|
|
2339
2352
|
} else if (tag === "tbl") {
|
|
2340
|
-
const
|
|
2341
|
-
if (
|
|
2353
|
+
const built = buildSubListTable(ch, ctx, depth);
|
|
2354
|
+
if (built.text) parts.push(built.text);
|
|
2355
|
+
if (built.block) {
|
|
2356
|
+
out.blocks.push(built.block);
|
|
2357
|
+
out.hasStructure = true;
|
|
2358
|
+
}
|
|
2342
2359
|
} else {
|
|
2343
|
-
const
|
|
2344
|
-
if (
|
|
2360
|
+
const sub = collectSubListContent(ch, ctx, depth + 1);
|
|
2361
|
+
if (sub.text) parts.push(sub.text);
|
|
2362
|
+
out.blocks.push(...sub.blocks);
|
|
2363
|
+
if (sub.hasStructure) out.hasStructure = true;
|
|
2345
2364
|
}
|
|
2346
2365
|
}
|
|
2347
|
-
|
|
2366
|
+
out.text = parts.join("\n").trim();
|
|
2367
|
+
return out;
|
|
2348
2368
|
}
|
|
2349
|
-
function
|
|
2369
|
+
function buildSubListTable(el, ctx, depth) {
|
|
2350
2370
|
const sink = [];
|
|
2351
2371
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2352
2372
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2353
|
-
let flat =
|
|
2373
|
+
let flat = _chunk2BTKLDNXcjs.convertTableToText.call(void 0, st.rows);
|
|
2354
2374
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2355
|
-
|
|
2375
|
+
const built = [];
|
|
2376
|
+
completeTable(st, [], built, ctx);
|
|
2377
|
+
return { text: flat, block: _nullishCoalesce(built.find((b) => b.type === "table"), () => ( null)) };
|
|
2356
2378
|
}
|
|
2357
2379
|
function findTopLevelTbls(el, out, depth = 0) {
|
|
2358
2380
|
if (depth > MAX_XML_DEPTH) return;
|
|
@@ -2398,14 +2420,16 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2398
2420
|
walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
|
|
2399
2421
|
tableCtx = completeTable(newTable, tableStack, blocks, ctx);
|
|
2400
2422
|
} else if (localTag === "caption" && !inShape) {
|
|
2401
|
-
const
|
|
2402
|
-
if (
|
|
2403
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2404
|
-
else if (tableCtx)
|
|
2405
|
-
|
|
2423
|
+
const cap = collectSubListContent(el, ctx);
|
|
2424
|
+
if (cap.text) {
|
|
2425
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _50 => _50.cell])) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: cap.text, pageNumber: ctx.sectionNum }]);
|
|
2426
|
+
else if (tableCtx) {
|
|
2427
|
+
tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + cap.text;
|
|
2428
|
+
if (cap.hasStructure) (tableCtx.captionBlocks ??= []).push(...cap.blocks);
|
|
2429
|
+
} else blocks.push({ type: "paragraph", text: cap.text, pageNumber: ctx.sectionNum });
|
|
2406
2430
|
}
|
|
2407
2431
|
} else if (localTag === "pic" || localTag === "shape" || localTag === "drawingObject") {
|
|
2408
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2432
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _51 => _51.cell])) {
|
|
2409
2433
|
const sink = [];
|
|
2410
2434
|
handleShape(el, sink, ctx);
|
|
2411
2435
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -2413,7 +2437,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2413
2437
|
handleShape(el, blocks, ctx);
|
|
2414
2438
|
}
|
|
2415
2439
|
} else if (localTag === "drawText") {
|
|
2416
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2440
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _52 => _52.cell])) {
|
|
2417
2441
|
const sink = [];
|
|
2418
2442
|
extractDrawTextBlocks(el, sink, ctx);
|
|
2419
2443
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -2431,7 +2455,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2431
2455
|
return tableCtx;
|
|
2432
2456
|
}
|
|
2433
2457
|
function isInlineTbl(tbl2) {
|
|
2434
|
-
return _optionalChain([findChildByLocalName, 'call',
|
|
2458
|
+
return _optionalChain([findChildByLocalName, 'call', _53 => _53(tbl2, "pos"), 'optionalAccess', _54 => _54.getAttribute, 'call', _55 => _55("treatAsChar")]) === "1";
|
|
2435
2459
|
}
|
|
2436
2460
|
function findDescendant(node, targetTag, depth = 0) {
|
|
2437
2461
|
if (depth > 5) return null;
|
|
@@ -2462,7 +2486,7 @@ function extractDrawTextBlocks(drawTextNode, blocks, ctx) {
|
|
|
2462
2486
|
let text = info.text.trim();
|
|
2463
2487
|
const ph = resolveParaHeading(child, ctx);
|
|
2464
2488
|
if (text) {
|
|
2465
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
2489
|
+
if (_optionalChain([ph, 'optionalAccess', _56 => _56.prefix])) text = ph.prefix + " " + text;
|
|
2466
2490
|
const block = { type: "paragraph", text, style: _nullishCoalesce(info.style, () => ( void 0)), pageNumber: ctx.sectionNum };
|
|
2467
2491
|
if (info.href) block.href = info.href;
|
|
2468
2492
|
if (info.footnote) block.footnoteText = info.footnote;
|
|
@@ -2487,13 +2511,13 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2487
2511
|
let url = (ch.textContent || "").trim();
|
|
2488
2512
|
if (!url) continue;
|
|
2489
2513
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2490
|
-
const safe =
|
|
2514
|
+
const safe = _chunkOQNFGKRYcjs.sanitizeHref.call(void 0, url);
|
|
2491
2515
|
if (safe) return safe;
|
|
2492
2516
|
}
|
|
2493
2517
|
return void 0;
|
|
2494
2518
|
}
|
|
2495
2519
|
function isInDeletedRange(ctx) {
|
|
2496
|
-
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess',
|
|
2520
|
+
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess', _57 => _57.shared, 'access', _58 => _58.track, 'access', _59 => _59.deleteDepth]), () => ( 0))) > 0;
|
|
2497
2521
|
}
|
|
2498
2522
|
function extractParagraphInfo(para2, styleMap, ctx) {
|
|
2499
2523
|
let text = "";
|
|
@@ -2514,7 +2538,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2514
2538
|
};
|
|
2515
2539
|
const onFieldEnd = () => {
|
|
2516
2540
|
const open = openFields.pop();
|
|
2517
|
-
if (_optionalChain([open, 'optionalAccess',
|
|
2541
|
+
if (_optionalChain([open, 'optionalAccess', _60 => _60.rangeIdx]) !== void 0) linkRanges[open.rangeIdx].end = text.length;
|
|
2518
2542
|
};
|
|
2519
2543
|
const handleCtrl = (ctrlEl) => {
|
|
2520
2544
|
const kids2 = ctrlEl.childNodes;
|
|
@@ -2565,7 +2589,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2565
2589
|
// 삽입분은 최종본에 포함
|
|
2566
2590
|
// 숨은 설명 — 본문 혼입 차단
|
|
2567
2591
|
case "hiddenComment": {
|
|
2568
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
2592
|
+
if (_optionalChain([ctx, 'optionalAccess', _61 => _61.warnings]) && extractTextFromNode(k)) {
|
|
2569
2593
|
ctx.warnings.push({ page: ctx.sectionNum, message: "\uC228\uC740 \uC124\uBA85 \uD14D\uC2A4\uD2B8 \uC81C\uC678: hiddenComment", code: "HIDDEN_TEXT_FILTERED" });
|
|
2570
2594
|
}
|
|
2571
2595
|
break;
|
|
@@ -2585,7 +2609,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2585
2609
|
break;
|
|
2586
2610
|
// 미지원 요소 — 텍스트를 가졌으면 무음 손실 대신 경고
|
|
2587
2611
|
default: {
|
|
2588
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
2612
|
+
if (_optionalChain([ctx, 'optionalAccess', _62 => _62.warnings]) && extractTextFromNode(k)) {
|
|
2589
2613
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uBBF8\uC9C0\uC6D0 \uC81C\uC5B4 \uC694\uC18C\uC758 \uD14D\uC2A4\uD2B8 \uC190\uC2E4: ${ktag}`, code: "UNSUPPORTED_ELEMENT" });
|
|
2590
2614
|
}
|
|
2591
2615
|
}
|
|
@@ -2603,7 +2627,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2603
2627
|
if (isInDeletedRange(ctx)) {
|
|
2604
2628
|
if (t && ctx && !ctx.shared.track.warned) {
|
|
2605
2629
|
ctx.shared.track.warned = true;
|
|
2606
|
-
_optionalChain([ctx, 'access',
|
|
2630
|
+
_optionalChain([ctx, 'access', _63 => _63.warnings, 'optionalAccess', _64 => _64.push, 'call', _65 => _65({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" })]);
|
|
2607
2631
|
}
|
|
2608
2632
|
} else {
|
|
2609
2633
|
text += t.replace(/\x1E/g, "");
|
|
@@ -2647,7 +2671,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2647
2671
|
case "hyperlink": {
|
|
2648
2672
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2649
2673
|
if (url) {
|
|
2650
|
-
const safe =
|
|
2674
|
+
const safe = _chunkOQNFGKRYcjs.sanitizeHref.call(void 0, url);
|
|
2651
2675
|
if (safe) href = safe;
|
|
2652
2676
|
}
|
|
2653
2677
|
walk(child, depth + 1);
|
|
@@ -2794,13 +2818,13 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2794
2818
|
if (tag !== "run" && tag !== "r") return null;
|
|
2795
2819
|
let text = "";
|
|
2796
2820
|
const rkids = child.childNodes;
|
|
2797
|
-
for (let j = 0; j < (_nullishCoalesce(_optionalChain([rkids, 'optionalAccess',
|
|
2821
|
+
for (let j = 0; j < (_nullishCoalesce(_optionalChain([rkids, 'optionalAccess', _66 => _66.length]), () => ( 0))); j++) {
|
|
2798
2822
|
const rc = rkids[j];
|
|
2799
2823
|
if (rc.nodeType !== 1) continue;
|
|
2800
2824
|
const rtag = (rc.tagName || rc.localName || "").replace(/^[^:]+:/, "");
|
|
2801
2825
|
if (rtag === "t") {
|
|
2802
2826
|
const tkids = rc.childNodes;
|
|
2803
|
-
for (let k = 0; k < (_nullishCoalesce(_optionalChain([tkids, 'optionalAccess',
|
|
2827
|
+
for (let k = 0; k < (_nullishCoalesce(_optionalChain([tkids, 'optionalAccess', _67 => _67.length]), () => ( 0))); k++) {
|
|
2804
2828
|
const tk = tkids[k];
|
|
2805
2829
|
if (tk.nodeType === 3) text += tk.textContent || "";
|
|
2806
2830
|
else if (tk.nodeType === 1) return null;
|
|
@@ -2818,9 +2842,9 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2818
2842
|
const span = { text };
|
|
2819
2843
|
if (mode !== "foreign" && prId === KORDOC_CHAR_CODE) span.code = true;
|
|
2820
2844
|
else {
|
|
2821
|
-
if (_optionalChain([cp, 'optionalAccess',
|
|
2822
|
-
if (_optionalChain([cp, 'optionalAccess',
|
|
2823
|
-
if (_optionalChain([cp, 'optionalAccess',
|
|
2845
|
+
if (_optionalChain([cp, 'optionalAccess', _68 => _68.bold])) span.bold = true;
|
|
2846
|
+
if (_optionalChain([cp, 'optionalAccess', _69 => _69.italic])) span.italic = true;
|
|
2847
|
+
if (_optionalChain([cp, 'optionalAccess', _70 => _70.strike])) span.strike = true;
|
|
2824
2848
|
}
|
|
2825
2849
|
if (span.bold || span.italic || span.strike || span.code) styled = true;
|
|
2826
2850
|
spans.push(span);
|
|
@@ -2843,12 +2867,12 @@ function gongmunDepthFromIndent(para2, left, ctx) {
|
|
|
2843
2867
|
if (!styleMap) return null;
|
|
2844
2868
|
let unit = 0;
|
|
2845
2869
|
const kids2 = para2.childNodes;
|
|
2846
|
-
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess',
|
|
2870
|
+
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess', _71 => _71.length]), () => ( 0))); i++) {
|
|
2847
2871
|
const child = kids2[i];
|
|
2848
2872
|
if (child.nodeType !== 1) continue;
|
|
2849
2873
|
const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
|
|
2850
2874
|
if (tag !== "run" && tag !== "r") continue;
|
|
2851
|
-
const size = _optionalChain([styleMap, 'access',
|
|
2875
|
+
const size = _optionalChain([styleMap, 'access', _72 => _72.charProperties, 'access', _73 => _73.get, 'call', _74 => _74(_nullishCoalesce(child.getAttribute("charPrIDRef"), () => ( ""))), 'optionalAccess', _75 => _75.fontSize]);
|
|
2852
2876
|
if (size) unit = size * 100;
|
|
2853
2877
|
break;
|
|
2854
2878
|
}
|
|
@@ -2921,7 +2945,7 @@ function decompressStream(data) {
|
|
|
2921
2945
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2922
2946
|
}
|
|
2923
2947
|
function parseFileHeader(data) {
|
|
2924
|
-
if (data.length < 40) throw new (0,
|
|
2948
|
+
if (data.length < 40) throw new (0, _chunkOQNFGKRYcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2925
2949
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2926
2950
|
return {
|
|
2927
2951
|
signature: sig,
|
|
@@ -3054,7 +3078,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
3054
3078
|
const resolveAt = (byteOffset, extended) => {
|
|
3055
3079
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
3056
3080
|
const idx = extended ? state.ctrlIdx : -1;
|
|
3057
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
3081
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _76 => _76(idx, ctrlId)]);
|
|
3058
3082
|
if (replacement) result += replacement;
|
|
3059
3083
|
if (extended) state.ctrlIdx++;
|
|
3060
3084
|
};
|
|
@@ -3256,7 +3280,7 @@ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
|
|
|
3256
3280
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
3257
3281
|
if (fileIndex) {
|
|
3258
3282
|
for (const entry of fileIndex) {
|
|
3259
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3283
|
+
if (!_optionalChain([entry, 'optionalAccess', _77 => _77.name]) || !entry.content) continue;
|
|
3260
3284
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
3261
3285
|
if (!match) continue;
|
|
3262
3286
|
const idx = parseInt(match[1], 16);
|
|
@@ -3332,7 +3356,7 @@ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
|
|
|
3332
3356
|
} else if (block.type === "table" && block.table) {
|
|
3333
3357
|
for (const row of block.table.cells) {
|
|
3334
3358
|
for (const cell2 of row) {
|
|
3335
|
-
if (_optionalChain([cell2, 'access',
|
|
3359
|
+
if (_optionalChain([cell2, 'access', _78 => _78.blocks, 'optionalAccess', _79 => _79.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
|
|
3336
3360
|
}
|
|
3337
3361
|
}
|
|
3338
3362
|
}
|
|
@@ -3370,13 +3394,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3370
3394
|
}
|
|
3371
3395
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3372
3396
|
for (const path of allCandidates) {
|
|
3373
|
-
if (
|
|
3397
|
+
if (_chunkOQNFGKRYcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3374
3398
|
const file = zip.file(path);
|
|
3375
3399
|
if (!file) continue;
|
|
3376
3400
|
try {
|
|
3377
3401
|
const data = await file.async("uint8array");
|
|
3378
3402
|
decompressed.total += data.length;
|
|
3379
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3403
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3380
3404
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3381
3405
|
const mimeType = imageExtToMime(ext);
|
|
3382
3406
|
imageIndex++;
|
|
@@ -3386,10 +3410,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3386
3410
|
usedPaths.add(path);
|
|
3387
3411
|
break;
|
|
3388
3412
|
} catch (err) {
|
|
3389
|
-
if (err instanceof
|
|
3413
|
+
if (err instanceof _chunkOQNFGKRYcjs.KordocError) throw err;
|
|
3390
3414
|
}
|
|
3391
3415
|
}
|
|
3392
|
-
if (!img) _optionalChain([warnings, 'optionalAccess',
|
|
3416
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
3393
3417
|
resolved.set(ref, img);
|
|
3394
3418
|
}
|
|
3395
3419
|
if (!img) {
|
|
@@ -3406,11 +3430,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3406
3430
|
if (sweepUnreferenced) {
|
|
3407
3431
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3408
3432
|
for (const file of binEntries) {
|
|
3409
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3433
|
+
if (file.dir || usedPaths.has(file.name) || _chunkOQNFGKRYcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3410
3434
|
try {
|
|
3411
3435
|
const data = await file.async("uint8array");
|
|
3412
3436
|
decompressed.total += data.length;
|
|
3413
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3437
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3414
3438
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3415
3439
|
let mimeType = imageExtToMime(ext);
|
|
3416
3440
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3424,8 +3448,8 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3424
3448
|
images.push(img);
|
|
3425
3449
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3426
3450
|
} catch (err) {
|
|
3427
|
-
if (err instanceof
|
|
3428
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
3451
|
+
if (err instanceof _chunkOQNFGKRYcjs.KordocError) throw err;
|
|
3452
|
+
_optionalChain([warnings, 'optionalAccess', _82 => _82.push, 'call', _83 => _83({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3429
3453
|
}
|
|
3430
3454
|
}
|
|
3431
3455
|
}
|
|
@@ -3475,7 +3499,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3475
3499
|
}
|
|
3476
3500
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3477
3501
|
const name = new TextDecoder().decode(nameBytes);
|
|
3478
|
-
if (
|
|
3502
|
+
if (_chunkOQNFGKRYcjs.isPathTraversal.call(void 0, name)) {
|
|
3479
3503
|
pos = fileStart + compSize;
|
|
3480
3504
|
continue;
|
|
3481
3505
|
}
|
|
@@ -3493,16 +3517,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3493
3517
|
continue;
|
|
3494
3518
|
}
|
|
3495
3519
|
totalDecompressed += content.length * 2;
|
|
3496
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3520
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3497
3521
|
sectionNum++;
|
|
3498
3522
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3499
3523
|
} catch (e16) {
|
|
3500
3524
|
continue;
|
|
3501
3525
|
}
|
|
3502
3526
|
}
|
|
3503
|
-
if (blocks.length === 0) throw new (0,
|
|
3527
|
+
if (blocks.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3504
3528
|
applyPageText(blocks, shared);
|
|
3505
|
-
const markdown =
|
|
3529
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3506
3530
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3507
3531
|
}
|
|
3508
3532
|
async function readKordocLayout(zip) {
|
|
@@ -3511,7 +3535,7 @@ async function readKordocLayout(zip) {
|
|
|
3511
3535
|
try {
|
|
3512
3536
|
const xml = await file.async("text");
|
|
3513
3537
|
if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
|
|
3514
|
-
return _nullishCoalesce(_optionalChain([xml, 'access',
|
|
3538
|
+
return _nullishCoalesce(_optionalChain([xml, 'access', _84 => _84.match, 'call', _85 => _85(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _86 => _86[1]]), () => ( null));
|
|
3515
3539
|
} catch (e17) {
|
|
3516
3540
|
return null;
|
|
3517
3541
|
}
|
|
@@ -3527,18 +3551,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3527
3551
|
if (paths.length > 0) return paths;
|
|
3528
3552
|
}
|
|
3529
3553
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3530
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3554
|
+
return sectionFiles.map((f) => f.name).sort(_chunkOQNFGKRYcjs.compareSectionPaths);
|
|
3531
3555
|
}
|
|
3532
3556
|
function parseSectionPathsFromManifest(xml) {
|
|
3533
3557
|
const parser = createXmlParser();
|
|
3534
|
-
const doc = parser.parseFromString(
|
|
3558
|
+
const doc = parser.parseFromString(_chunkOQNFGKRYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3535
3559
|
const items = doc.getElementsByTagName("opf:item");
|
|
3536
3560
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3537
3561
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3538
3562
|
for (let i = 0; i < items.length; i++) {
|
|
3539
3563
|
const item = items[i];
|
|
3540
3564
|
const id = item.getAttribute("id") || "";
|
|
3541
|
-
const href =
|
|
3565
|
+
const href = _chunkOQNFGKRYcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3542
3566
|
if (id && href) idToHref.set(id, href);
|
|
3543
3567
|
}
|
|
3544
3568
|
if (spine.length > 0) {
|
|
@@ -3549,7 +3573,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3549
3573
|
}
|
|
3550
3574
|
if (ordered.length > 0) return ordered;
|
|
3551
3575
|
}
|
|
3552
|
-
return Array.from(idToHref.values()).sort(
|
|
3576
|
+
return Array.from(idToHref.values()).sort(_chunkOQNFGKRYcjs.compareSectionPaths);
|
|
3553
3577
|
}
|
|
3554
3578
|
|
|
3555
3579
|
// src/hwpx/metadata.ts
|
|
@@ -3562,7 +3586,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3562
3586
|
const xml = await file.async("text");
|
|
3563
3587
|
if (decompressed) {
|
|
3564
3588
|
decompressed.total += xml.length * 2;
|
|
3565
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3589
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3566
3590
|
}
|
|
3567
3591
|
parseDublinCoreMetadata(xml, metadata);
|
|
3568
3592
|
if (metadata.title || metadata.author) return;
|
|
@@ -3572,13 +3596,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3572
3596
|
}
|
|
3573
3597
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3574
3598
|
const parser = createXmlParser();
|
|
3575
|
-
const doc = parser.parseFromString(
|
|
3599
|
+
const doc = parser.parseFromString(_chunkOQNFGKRYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3576
3600
|
if (!doc.documentElement) return;
|
|
3577
3601
|
const getText = (tagNames) => {
|
|
3578
3602
|
for (const tag of tagNames) {
|
|
3579
3603
|
const els = doc.getElementsByTagName(tag);
|
|
3580
3604
|
if (els.length > 0) {
|
|
3581
|
-
const text = _optionalChain([els, 'access',
|
|
3605
|
+
const text = _optionalChain([els, 'access', _87 => _87[0], 'access', _88 => _88.textContent, 'optionalAccess', _89 => _89.trim, 'call', _90 => _90()]);
|
|
3582
3606
|
if (text) return text;
|
|
3583
3607
|
}
|
|
3584
3608
|
}
|
|
@@ -3597,7 +3621,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3597
3621
|
|
|
3598
3622
|
// src/hwpx/parser.ts
|
|
3599
3623
|
async function parseHwpxDocument(buffer, options) {
|
|
3600
|
-
|
|
3624
|
+
_chunkOQNFGKRYcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3601
3625
|
let zip;
|
|
3602
3626
|
try {
|
|
3603
3627
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3606,19 +3630,19 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3606
3630
|
}
|
|
3607
3631
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3608
3632
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3609
|
-
throw new (0,
|
|
3633
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3610
3634
|
}
|
|
3611
3635
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3612
3636
|
if (manifestFile) {
|
|
3613
3637
|
const manifestXml = await manifestFile.async("text");
|
|
3614
3638
|
if (isEncryptedHwpx(manifestXml)) {
|
|
3615
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
3639
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _91 => _91.filePath])) {
|
|
3616
3640
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3617
3641
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3618
3642
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3619
3643
|
}
|
|
3620
3644
|
}
|
|
3621
|
-
throw new (0,
|
|
3645
|
+
throw new (0, _chunkOQNFGKRYcjs.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.");
|
|
3622
3646
|
}
|
|
3623
3647
|
}
|
|
3624
3648
|
const decompressed = { total: 0 };
|
|
@@ -3627,14 +3651,14 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3627
3651
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3628
3652
|
const warnings = [];
|
|
3629
3653
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3630
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3654
|
+
if (sectionPaths.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3631
3655
|
metadata.pageCount = sectionPaths.length;
|
|
3632
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3656
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _92 => _92.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3633
3657
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3634
3658
|
const blocks = [];
|
|
3635
3659
|
const shared = createSectionShared();
|
|
3636
3660
|
shared.kordocLayout = await readKordocLayout(zip);
|
|
3637
|
-
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
3661
|
+
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _93 => _93.keepTrailingEmptyCols]);
|
|
3638
3662
|
let parsedSections = 0;
|
|
3639
3663
|
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3640
3664
|
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
@@ -3646,7 +3670,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3646
3670
|
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new ZipBombError("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3647
3671
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3648
3672
|
parsedSections++;
|
|
3649
|
-
_optionalChain([options, 'optionalAccess',
|
|
3673
|
+
_optionalChain([options, 'optionalAccess', _94 => _94.onProgress, 'optionalCall', _95 => _95(parsedSections, totalTarget)]);
|
|
3650
3674
|
} catch (secErr) {
|
|
3651
3675
|
if (secErr instanceof ZipBombError) throw secErr;
|
|
3652
3676
|
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" });
|
|
@@ -3656,7 +3680,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3656
3680
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3657
3681
|
detectHwpxHeadings(blocks, styleMap);
|
|
3658
3682
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3659
|
-
const markdown =
|
|
3683
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3660
3684
|
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 };
|
|
3661
3685
|
}
|
|
3662
3686
|
|
|
@@ -4835,22 +4859,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4835
4859
|
lenientCfb = parseLenientCfb(buffer);
|
|
4836
4860
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4837
4861
|
} catch (e22) {
|
|
4838
|
-
throw new (0,
|
|
4862
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4839
4863
|
}
|
|
4840
4864
|
}
|
|
4841
4865
|
const findStream = (path) => {
|
|
4842
4866
|
if (cfb) {
|
|
4843
4867
|
const entry = CFB.find(cfb, path);
|
|
4844
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
4868
|
+
return _optionalChain([entry, 'optionalAccess', _96 => _96.content]) ? Buffer.from(entry.content) : null;
|
|
4845
4869
|
}
|
|
4846
4870
|
return lenientCfb.findStream(path);
|
|
4847
4871
|
};
|
|
4848
4872
|
const headerData = findStream("/FileHeader");
|
|
4849
|
-
if (!headerData) throw new (0,
|
|
4873
|
+
if (!headerData) throw new (0, _chunkOQNFGKRYcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4850
4874
|
const header = parseFileHeader(headerData);
|
|
4851
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4852
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4853
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4875
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkOQNFGKRYcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4876
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4877
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkOQNFGKRYcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4854
4878
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4855
4879
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4856
4880
|
const metadata = {
|
|
@@ -4859,13 +4883,13 @@ function parseHwp5Document(buffer, options) {
|
|
|
4859
4883
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4860
4884
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4861
4885
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4862
|
-
if (sections.length === 0) throw new (0,
|
|
4886
|
+
if (sections.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4863
4887
|
metadata.pageCount = sections.length;
|
|
4864
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4888
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _97 => _97.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4865
4889
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4866
4890
|
const bodyBlocks = [];
|
|
4867
4891
|
const doc = createHwp5DocState();
|
|
4868
|
-
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
4892
|
+
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _98 => _98.keepTrailingEmptyCols]);
|
|
4869
4893
|
let totalDecompressed = 0;
|
|
4870
4894
|
let parsedSections = 0;
|
|
4871
4895
|
for (let si = 0; si < sections.length; si++) {
|
|
@@ -4874,22 +4898,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4874
4898
|
const sectionData = sections[si];
|
|
4875
4899
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4876
4900
|
totalDecompressed += data.length;
|
|
4877
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4901
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4878
4902
|
const records = readRecords(data);
|
|
4879
4903
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4880
4904
|
bodyBlocks.push(...sectionBlocks);
|
|
4881
4905
|
parsedSections++;
|
|
4882
|
-
_optionalChain([options, 'optionalAccess',
|
|
4906
|
+
_optionalChain([options, 'optionalAccess', _99 => _99.onProgress, 'optionalCall', _100 => _100(parsedSections, totalTarget)]);
|
|
4883
4907
|
} catch (secErr) {
|
|
4884
|
-
if (secErr instanceof
|
|
4908
|
+
if (secErr instanceof _chunkOQNFGKRYcjs.KordocError) throw secErr;
|
|
4885
4909
|
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" });
|
|
4886
4910
|
}
|
|
4887
4911
|
}
|
|
4888
4912
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4889
4913
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4890
|
-
let flatBlocks =
|
|
4891
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4892
|
-
const deduped =
|
|
4914
|
+
let flatBlocks = _chunk2BTKLDNXcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4915
|
+
if (_optionalChain([options, 'optionalAccess', _101 => _101.dedupeRunningHeaders])) {
|
|
4916
|
+
const deduped = _chunk2BTKLDNXcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4893
4917
|
const removed = flatBlocks.length - deduped.length;
|
|
4894
4918
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4895
4919
|
flatBlocks = deduped;
|
|
@@ -4898,10 +4922,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4898
4922
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4899
4923
|
}
|
|
4900
4924
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4901
|
-
let markdown =
|
|
4902
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4925
|
+
let markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4926
|
+
if (_optionalChain([options, 'optionalAccess', _102 => _102.inlineImages]) && images.length > 0) {
|
|
4903
4927
|
try {
|
|
4904
|
-
markdown =
|
|
4928
|
+
markdown = _chunk2BTKLDNXcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4905
4929
|
} catch (inlineErr) {
|
|
4906
4930
|
warnings.push({ message: `\uC774\uBBF8\uC9C0 \uC778\uB77C\uC778 \uC2E4\uD328 \u2014 \uC6D0\uBCF8 \uD30C\uC77C \uCC38\uC870\uB85C \uD3F4\uBC31: ${inlineErr instanceof Error ? inlineErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "SKIPPED_IMAGE" });
|
|
4907
4931
|
}
|
|
@@ -4911,7 +4935,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4911
4935
|
function parseDocInfoStream(cfb, compressed) {
|
|
4912
4936
|
try {
|
|
4913
4937
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
4914
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4938
|
+
if (!_optionalChain([entry, 'optionalAccess', _103 => _103.content])) return null;
|
|
4915
4939
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
4916
4940
|
const records = readRecords(data);
|
|
4917
4941
|
return parseDocInfo(records);
|
|
@@ -4932,7 +4956,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4932
4956
|
let baseFontSize = 0;
|
|
4933
4957
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
4934
4958
|
for (const b of blocks) {
|
|
4935
|
-
if (_optionalChain([b, 'access',
|
|
4959
|
+
if (_optionalChain([b, 'access', _104 => _104.style, 'optionalAccess', _105 => _105.fontSize]) && b.text) {
|
|
4936
4960
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4937
4961
|
}
|
|
4938
4962
|
}
|
|
@@ -4948,7 +4972,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4948
4972
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4949
4973
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4950
4974
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4951
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4975
|
+
if (_optionalChain([cs, 'optionalAccess', _106 => _106.fontSize]) > 0) {
|
|
4952
4976
|
baseFontSize = cs.fontSize / 10;
|
|
4953
4977
|
break;
|
|
4954
4978
|
}
|
|
@@ -4963,11 +4987,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4963
4987
|
if (text.length === 0 || text.length > 200) continue;
|
|
4964
4988
|
if (/^\d+$/.test(text)) continue;
|
|
4965
4989
|
let level = 0;
|
|
4966
|
-
if (_optionalChain([block, 'access',
|
|
4990
|
+
if (_optionalChain([block, 'access', _107 => _107.style, 'optionalAccess', _108 => _108.fontSize]) && baseFontSize > 0) {
|
|
4967
4991
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4968
|
-
if (ratio >=
|
|
4969
|
-
else if (ratio >=
|
|
4970
|
-
else if (ratio >=
|
|
4992
|
+
if (ratio >= _chunkOQNFGKRYcjs.HEADING_RATIO_H1) level = 1;
|
|
4993
|
+
else if (ratio >= _chunkOQNFGKRYcjs.HEADING_RATIO_H2) level = 2;
|
|
4994
|
+
else if (ratio >= _chunkOQNFGKRYcjs.HEADING_RATIO_H3) level = 3;
|
|
4971
4995
|
}
|
|
4972
4996
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4973
4997
|
if (level === 0) level = 2;
|
|
@@ -4983,7 +5007,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4983
5007
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4984
5008
|
try {
|
|
4985
5009
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4986
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
5010
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _109 => _109.content])) return;
|
|
4987
5011
|
const data = Buffer.from(summaryEntry.content);
|
|
4988
5012
|
if (data.length < 48) return;
|
|
4989
5013
|
const numSets = data.readUInt32LE(24);
|
|
@@ -5016,7 +5040,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
5016
5040
|
const sections = [];
|
|
5017
5041
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
5018
5042
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
5019
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
5043
|
+
if (!_optionalChain([entry, 'optionalAccess', _110 => _110.content])) break;
|
|
5020
5044
|
try {
|
|
5021
5045
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
5022
5046
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -5030,13 +5054,13 @@ function findSections(cfb) {
|
|
|
5030
5054
|
const sections = [];
|
|
5031
5055
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
5032
5056
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
5033
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
5057
|
+
if (!_optionalChain([entry, 'optionalAccess', _111 => _111.content])) break;
|
|
5034
5058
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
5035
5059
|
}
|
|
5036
5060
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
5037
5061
|
for (const entry of cfb.FileIndex) {
|
|
5038
5062
|
if (sections.length >= MAX_SECTIONS) break;
|
|
5039
|
-
if (_optionalChain([entry, 'access',
|
|
5063
|
+
if (_optionalChain([entry, 'access', _112 => _112.name, 'optionalAccess', _113 => _113.startsWith, 'call', _114 => _114("Section")]) && entry.content) {
|
|
5040
5064
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
5041
5065
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
5042
5066
|
}
|
|
@@ -5052,7 +5076,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5052
5076
|
if (!raw) break;
|
|
5053
5077
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5054
5078
|
totalDecompressed += content.length;
|
|
5055
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5079
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5056
5080
|
sections.push({ idx: i, content });
|
|
5057
5081
|
}
|
|
5058
5082
|
if (sections.length === 0) {
|
|
@@ -5064,7 +5088,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5064
5088
|
if (raw) {
|
|
5065
5089
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5066
5090
|
totalDecompressed += content.length;
|
|
5067
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5091
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5068
5092
|
sections.push({ idx, content });
|
|
5069
5093
|
}
|
|
5070
5094
|
}
|
|
@@ -5081,7 +5105,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5081
5105
|
try {
|
|
5082
5106
|
const content = decryptViewText(raw, compressed);
|
|
5083
5107
|
totalDecompressed += content.length;
|
|
5084
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5108
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5085
5109
|
sections.push({ idx: i, content });
|
|
5086
5110
|
} catch (e27) {
|
|
5087
5111
|
break;
|
|
@@ -5182,9 +5206,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5182
5206
|
const applied = [];
|
|
5183
5207
|
for (const r of ranges) {
|
|
5184
5208
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5185
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
5209
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _115 => _115.href]) || r.end <= r.start) continue;
|
|
5186
5210
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5187
|
-
const href =
|
|
5211
|
+
const href = _chunkOQNFGKRYcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5188
5212
|
if (!href) continue;
|
|
5189
5213
|
const anchor = text.slice(r.start, r.end);
|
|
5190
5214
|
if (!anchor.trim()) continue;
|
|
@@ -5202,7 +5226,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5202
5226
|
}
|
|
5203
5227
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
5204
5228
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
5205
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
5229
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _116 => _116.docInfo, 'optionalAccess', _117 => _117.numberings, 'access', _118 => _118[nid - 1]]) : void 0;
|
|
5206
5230
|
if (numbering) {
|
|
5207
5231
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
5208
5232
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -5212,7 +5236,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5212
5236
|
}
|
|
5213
5237
|
}
|
|
5214
5238
|
} else if (ps.headType === 3) {
|
|
5215
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
5239
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _119 => _119.docInfo, 'optionalAccess', _120 => _120.bullets, 'access', _121 => _121[ps.numberingId - 1]]) : void 0;
|
|
5216
5240
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
5217
5241
|
}
|
|
5218
5242
|
}
|
|
@@ -5420,8 +5444,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5420
5444
|
let tableIdx = -1;
|
|
5421
5445
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5422
5446
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5423
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5424
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5447
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunk2BTKLDNXcjs.MAX_ROWS);
|
|
5448
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunk2BTKLDNXcjs.MAX_COLS);
|
|
5425
5449
|
tableIdx = i2;
|
|
5426
5450
|
break;
|
|
5427
5451
|
}
|
|
@@ -5461,7 +5485,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5461
5485
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
5462
5486
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
5463
5487
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
5464
|
-
if (_optionalChain([c, 'access',
|
|
5488
|
+
if (_optionalChain([c, 'access', _122 => _122.blocks, 'optionalAccess', _123 => _123.length])) ir.blocks = c.blocks;
|
|
5465
5489
|
if (c.isHeader) ir.isHeader = true;
|
|
5466
5490
|
return ir;
|
|
5467
5491
|
}));
|
|
@@ -5470,7 +5494,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5470
5494
|
return table3;
|
|
5471
5495
|
}
|
|
5472
5496
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5473
|
-
const table2 =
|
|
5497
|
+
const table2 = _chunk2BTKLDNXcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5474
5498
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5475
5499
|
return table2.rows > 0 ? table2 : null;
|
|
5476
5500
|
}
|
|
@@ -5487,8 +5511,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5487
5511
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5488
5512
|
const cs = rec.data.readUInt16LE(12);
|
|
5489
5513
|
const rs = rec.data.readUInt16LE(14);
|
|
5490
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5491
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5514
|
+
if (cs > 0) colSpan = Math.min(cs, _chunk2BTKLDNXcjs.MAX_COLS);
|
|
5515
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunk2BTKLDNXcjs.MAX_ROWS);
|
|
5492
5516
|
}
|
|
5493
5517
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5494
5518
|
const parts = [];
|
|
@@ -5498,7 +5522,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5498
5522
|
parts.push(``);
|
|
5499
5523
|
hasStructure = true;
|
|
5500
5524
|
} else if (b.type === "table" && b.table) {
|
|
5501
|
-
const flat =
|
|
5525
|
+
const flat = _chunk2BTKLDNXcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5502
5526
|
if (flat) parts.push(flat);
|
|
5503
5527
|
hasStructure = true;
|
|
5504
5528
|
} else if (b.text) {
|
|
@@ -5595,8 +5619,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
5595
5619
|
if (data.length < 73) return null;
|
|
5596
5620
|
const binDataId = data.readUInt16LE(71);
|
|
5597
5621
|
if (binDataId === 0) return null;
|
|
5598
|
-
const item = _optionalChain([ctx, 'access',
|
|
5599
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
5622
|
+
const item = _optionalChain([ctx, 'access', _124 => _124.docInfo, 'optionalAccess', _125 => _125.binData, 'access', _126 => _126[binDataId - 1]]);
|
|
5623
|
+
if (_optionalChain([item, 'optionalAccess', _127 => _127.kind]) === "link") {
|
|
5600
5624
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
5601
5625
|
return null;
|
|
5602
5626
|
}
|
|
@@ -17750,7 +17774,7 @@ function parseHwp3Document(buffer, _options) {
|
|
|
17750
17774
|
try {
|
|
17751
17775
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17752
17776
|
} catch (err) {
|
|
17753
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
17777
|
+
if (_optionalChain([err, 'optionalAccess', _128 => _128.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17754
17778
|
throw new Error(`HWP3 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESS_SIZE3 / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`);
|
|
17755
17779
|
}
|
|
17756
17780
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
@@ -17985,15 +18009,15 @@ function getElements(parent, tagName) {
|
|
|
17985
18009
|
const result = [];
|
|
17986
18010
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
17987
18011
|
if (result.length > 0) return result;
|
|
17988
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
18012
|
+
const nsNodes = _optionalChain([parent, 'access', _129 => _129.getElementsByTagNameNS, 'optionalCall', _130 => _130("*", tagName)]);
|
|
17989
18013
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
17990
18014
|
return result;
|
|
17991
18015
|
}
|
|
17992
18016
|
function getTextContent(el) {
|
|
17993
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
18017
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _131 => _131.textContent, 'optionalAccess', _132 => _132.trim, 'call', _133 => _133()]), () => ( ""));
|
|
17994
18018
|
}
|
|
17995
18019
|
function parseXml(text) {
|
|
17996
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18020
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkOQNFGKRYcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17997
18021
|
}
|
|
17998
18022
|
function collectRichText(root) {
|
|
17999
18023
|
let out = "";
|
|
@@ -18002,7 +18026,7 @@ function collectRichText(root) {
|
|
|
18002
18026
|
for (let i = 0; i < children.length; i++) {
|
|
18003
18027
|
if (children[i].nodeType !== 1) continue;
|
|
18004
18028
|
const el = children[i];
|
|
18005
|
-
const local = el.localName || _optionalChain([el, 'access',
|
|
18029
|
+
const local = el.localName || _optionalChain([el, 'access', _134 => _134.tagName, 'optionalAccess', _135 => _135.replace, 'call', _136 => _136(/^[^:]+:/, "")]) || "";
|
|
18006
18030
|
if (local === "rPh") continue;
|
|
18007
18031
|
if (local === "t") out += _nullishCoalesce(el.textContent, () => ( ""));
|
|
18008
18032
|
else walk(el);
|
|
@@ -18221,14 +18245,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18221
18245
|
const merge = mergeMap.get(key);
|
|
18222
18246
|
row.push({
|
|
18223
18247
|
text,
|
|
18224
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18225
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18248
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _137 => _137.colSpan]), () => ( 1)),
|
|
18249
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _138 => _138.rowSpan]), () => ( 1))
|
|
18226
18250
|
});
|
|
18227
18251
|
}
|
|
18228
18252
|
cellRows.push(row);
|
|
18229
18253
|
}
|
|
18230
18254
|
if (cellRows.length > 0) {
|
|
18231
|
-
const table2 =
|
|
18255
|
+
const table2 = _chunk2BTKLDNXcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18232
18256
|
if (table2.rows > 0) {
|
|
18233
18257
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18234
18258
|
}
|
|
@@ -18236,12 +18260,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18236
18260
|
return blocks;
|
|
18237
18261
|
}
|
|
18238
18262
|
async function parseXlsxDocument(buffer, options) {
|
|
18239
|
-
|
|
18263
|
+
_chunkOQNFGKRYcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18240
18264
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18241
18265
|
const warnings = [];
|
|
18242
18266
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18243
18267
|
if (!workbookFile) {
|
|
18244
|
-
throw new (0,
|
|
18268
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18245
18269
|
}
|
|
18246
18270
|
let sharedStrings = [];
|
|
18247
18271
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18250,7 +18274,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18250
18274
|
}
|
|
18251
18275
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18252
18276
|
if (sheets.length === 0) {
|
|
18253
|
-
throw new (0,
|
|
18277
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18254
18278
|
}
|
|
18255
18279
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18256
18280
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18266,7 +18290,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18266
18290
|
relsMap = parseRels(await relsFile.async("text"));
|
|
18267
18291
|
}
|
|
18268
18292
|
let pageFilter = null;
|
|
18269
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18293
|
+
if (_optionalChain([options, 'optionalAccess', _139 => _139.pages])) {
|
|
18270
18294
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18271
18295
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18272
18296
|
}
|
|
@@ -18275,7 +18299,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18275
18299
|
for (let i = 0; i < processedSheets; i++) {
|
|
18276
18300
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18277
18301
|
const sheet = sheets[i];
|
|
18278
|
-
_optionalChain([options, 'optionalAccess',
|
|
18302
|
+
_optionalChain([options, 'optionalAccess', _140 => _140.onProgress, 'optionalCall', _141 => _141(i + 1, processedSheets)]);
|
|
18279
18303
|
let sheetPath = relsMap.get(sheet.rId);
|
|
18280
18304
|
if (sheetPath) {
|
|
18281
18305
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -18298,7 +18322,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18298
18322
|
try {
|
|
18299
18323
|
const sheetXml = await sheetFile.async("text");
|
|
18300
18324
|
const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
|
|
18301
|
-
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess',
|
|
18325
|
+
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess', _142 => _142.keepTrailingEmptyCols]));
|
|
18302
18326
|
blocks.push(...sheetBlocks);
|
|
18303
18327
|
} catch (err) {
|
|
18304
18328
|
warnings.push({
|
|
@@ -18330,7 +18354,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18330
18354
|
} catch (e29) {
|
|
18331
18355
|
}
|
|
18332
18356
|
}
|
|
18333
|
-
const markdown =
|
|
18357
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18334
18358
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18335
18359
|
}
|
|
18336
18360
|
|
|
@@ -18781,11 +18805,11 @@ function processGlobals(records) {
|
|
|
18781
18805
|
const xfFmtIds = [];
|
|
18782
18806
|
const firstBof = records[0];
|
|
18783
18807
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18784
|
-
throw new (0,
|
|
18808
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18785
18809
|
}
|
|
18786
18810
|
const bof = decodeBof(firstBof.data);
|
|
18787
18811
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18788
|
-
throw new (0,
|
|
18812
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18789
18813
|
}
|
|
18790
18814
|
let i = 1;
|
|
18791
18815
|
while (i < records.length) {
|
|
@@ -18913,14 +18937,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18913
18937
|
const merge = mergeMap.get(key);
|
|
18914
18938
|
row.push({
|
|
18915
18939
|
text: grid[r][c],
|
|
18916
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18917
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18940
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _143 => _143.colSpan]), () => ( 1)),
|
|
18941
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _144 => _144.rowSpan]), () => ( 1))
|
|
18918
18942
|
});
|
|
18919
18943
|
}
|
|
18920
18944
|
cellRows.push(row);
|
|
18921
18945
|
}
|
|
18922
18946
|
if (cellRows.length > 0) {
|
|
18923
|
-
const table2 =
|
|
18947
|
+
const table2 = _chunk2BTKLDNXcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18924
18948
|
if (table2.rows > 0) {
|
|
18925
18949
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18926
18950
|
}
|
|
@@ -18933,21 +18957,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18933
18957
|
try {
|
|
18934
18958
|
cfb = parseLenientCfb(buf);
|
|
18935
18959
|
} catch (e) {
|
|
18936
|
-
throw new (0,
|
|
18960
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
18937
18961
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18938
18962
|
);
|
|
18939
18963
|
}
|
|
18940
18964
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18941
18965
|
if (!wb) {
|
|
18942
|
-
throw new (0,
|
|
18966
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18943
18967
|
}
|
|
18944
18968
|
const records = readRecords2(wb);
|
|
18945
18969
|
if (records.length === 0) {
|
|
18946
|
-
throw new (0,
|
|
18970
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18947
18971
|
}
|
|
18948
18972
|
const firstBof = decodeBof(records[0].data);
|
|
18949
18973
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18950
|
-
throw new (0,
|
|
18974
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
18951
18975
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18952
18976
|
);
|
|
18953
18977
|
}
|
|
@@ -18976,7 +19000,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18976
19000
|
} : void 0;
|
|
18977
19001
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18978
19002
|
let pageFilter = null;
|
|
18979
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
19003
|
+
if (_optionalChain([options, 'optionalAccess', _145 => _145.pages])) {
|
|
18980
19004
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18981
19005
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18982
19006
|
}
|
|
@@ -18985,7 +19009,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18985
19009
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18986
19010
|
const meta = globals.sheets[i];
|
|
18987
19011
|
if (meta.dt !== 0) continue;
|
|
18988
|
-
_optionalChain([options, 'optionalAccess',
|
|
19012
|
+
_optionalChain([options, 'optionalAccess', _146 => _146.onProgress, 'optionalCall', _147 => _147(i + 1, totalSheets)]);
|
|
18989
19013
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
18990
19014
|
if (bofIdx < 0) {
|
|
18991
19015
|
warnings.push({
|
|
@@ -19001,7 +19025,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
19001
19025
|
}
|
|
19002
19026
|
try {
|
|
19003
19027
|
const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
|
|
19004
|
-
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess',
|
|
19028
|
+
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess', _148 => _148.keepTrailingEmptyCols]));
|
|
19005
19029
|
allBlocks.push(...blocks);
|
|
19006
19030
|
} catch (e) {
|
|
19007
19031
|
warnings.push({
|
|
@@ -19015,7 +19039,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
19015
19039
|
pageCount: totalSheets
|
|
19016
19040
|
};
|
|
19017
19041
|
return {
|
|
19018
|
-
markdown:
|
|
19042
|
+
markdown: _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
19019
19043
|
blocks: allBlocks,
|
|
19020
19044
|
metadata,
|
|
19021
19045
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19028,7 +19052,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
19028
19052
|
|
|
19029
19053
|
// src/docx/equation.ts
|
|
19030
19054
|
function lname(el) {
|
|
19031
|
-
return el.localName || _optionalChain([el, 'access',
|
|
19055
|
+
return el.localName || _optionalChain([el, 'access', _149 => _149.tagName, 'optionalAccess', _150 => _150.replace, 'call', _151 => _151(/^[^:]+:/, "")]) || "";
|
|
19032
19056
|
}
|
|
19033
19057
|
function kids(parent, name) {
|
|
19034
19058
|
const out = [];
|
|
@@ -19417,7 +19441,7 @@ function isDisplayMath(el) {
|
|
|
19417
19441
|
// src/docx/parser.ts
|
|
19418
19442
|
var MAX_DECOMPRESS_SIZE5 = 100 * 1024 * 1024;
|
|
19419
19443
|
function matchesLocal(el, localName2) {
|
|
19420
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
19444
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _152 => _152.tagName, 'optionalAccess', _153 => _153.endsWith, 'call', _154 => _154(`:${localName2}`)]), () => ( false)));
|
|
19421
19445
|
}
|
|
19422
19446
|
function effectiveChildElements(parent) {
|
|
19423
19447
|
const result = [];
|
|
@@ -19452,7 +19476,7 @@ function findElements(parent, localName2) {
|
|
|
19452
19476
|
const child = children[i];
|
|
19453
19477
|
if (child.nodeType === 1) {
|
|
19454
19478
|
const el = child;
|
|
19455
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
19479
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _155 => _155.tagName, 'optionalAccess', _156 => _156.endsWith, 'call', _157 => _157(`:${localName2}`)])) {
|
|
19456
19480
|
result.push(el);
|
|
19457
19481
|
}
|
|
19458
19482
|
walk(el);
|
|
@@ -19471,7 +19495,7 @@ function getAttr(el, localName2) {
|
|
|
19471
19495
|
return null;
|
|
19472
19496
|
}
|
|
19473
19497
|
function parseXml2(text) {
|
|
19474
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19498
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkOQNFGKRYcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19475
19499
|
}
|
|
19476
19500
|
function parseStyles(xml) {
|
|
19477
19501
|
const doc = parseXml2(xml);
|
|
@@ -19588,7 +19612,7 @@ function collectOmmlRoots(p) {
|
|
|
19588
19612
|
const child = children[i];
|
|
19589
19613
|
if (child.nodeType !== 1) continue;
|
|
19590
19614
|
const el = child;
|
|
19591
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
19615
|
+
const tag = el.localName || _optionalChain([el, 'access', _158 => _158.tagName, 'optionalAccess', _159 => _159.replace, 'call', _160 => _160(/^[^:]+:/, "")]) || "";
|
|
19592
19616
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
19593
19617
|
out.push(el);
|
|
19594
19618
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -19629,7 +19653,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19629
19653
|
function makeLink(text, rawHref) {
|
|
19630
19654
|
if (!text) return "";
|
|
19631
19655
|
if (!rawHref) return text;
|
|
19632
|
-
const href =
|
|
19656
|
+
const href = _chunkOQNFGKRYcjs.sanitizeHref.call(void 0, rawHref);
|
|
19633
19657
|
return href ? `[${text}](${href})` : text;
|
|
19634
19658
|
}
|
|
19635
19659
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19731,7 +19755,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19731
19755
|
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19732
19756
|
if (!text) return null;
|
|
19733
19757
|
const style = styles.get(styleId);
|
|
19734
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
19758
|
+
if (_optionalChain([style, 'optionalAccess', _161 => _161.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
19735
19759
|
return {
|
|
19736
19760
|
type: "heading",
|
|
19737
19761
|
text,
|
|
@@ -19740,8 +19764,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19740
19764
|
}
|
|
19741
19765
|
if (numId && numId !== "0") {
|
|
19742
19766
|
const numDef = numbering.get(numId);
|
|
19743
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
19744
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
19767
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _162 => _162.get, 'call', _163 => _163(ilvl)]);
|
|
19768
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _164 => _164.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
19745
19769
|
return { type: "list", text, listType };
|
|
19746
19770
|
}
|
|
19747
19771
|
const block = { type: "paragraph", text };
|
|
@@ -19823,7 +19847,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19823
19847
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19824
19848
|
})
|
|
19825
19849
|
);
|
|
19826
|
-
const table2 =
|
|
19850
|
+
const table2 = _chunk2BTKLDNXcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19827
19851
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19828
19852
|
return { type: "table", table: table2 };
|
|
19829
19853
|
}
|
|
@@ -19833,10 +19857,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19833
19857
|
for (const el of effectiveChildElements(tc2)) {
|
|
19834
19858
|
if (matchesLocal(el, "p")) {
|
|
19835
19859
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19836
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
19860
|
+
if (_optionalChain([block, 'optionalAccess', _165 => _165.text])) parts.push(block.text);
|
|
19837
19861
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19838
19862
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19839
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
19863
|
+
if (_optionalChain([tb, 'optionalAccess', _166 => _166.text])) parts.push(tb.text);
|
|
19840
19864
|
}
|
|
19841
19865
|
} else if (matchesLocal(el, "tbl")) {
|
|
19842
19866
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -19871,7 +19895,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19871
19895
|
try {
|
|
19872
19896
|
const data = await imgFile.async("uint8array");
|
|
19873
19897
|
imgIdx++;
|
|
19874
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
19898
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _167 => _167.split, 'call', _168 => _168("."), 'access', _169 => _169.pop, 'call', _170 => _170(), 'optionalAccess', _171 => _171.toLowerCase, 'call', _172 => _172()]), () => ( "png"));
|
|
19875
19899
|
const mimeMap = {
|
|
19876
19900
|
png: "image/png",
|
|
19877
19901
|
jpg: "image/jpeg",
|
|
@@ -19925,12 +19949,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19925
19949
|
}
|
|
19926
19950
|
}
|
|
19927
19951
|
async function parseDocxDocument(buffer, options) {
|
|
19928
|
-
|
|
19952
|
+
_chunkOQNFGKRYcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19929
19953
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19930
19954
|
const warnings = [];
|
|
19931
19955
|
const docFile = zip.file("word/document.xml");
|
|
19932
19956
|
if (!docFile) {
|
|
19933
|
-
throw new (0,
|
|
19957
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19934
19958
|
}
|
|
19935
19959
|
let rels = /* @__PURE__ */ new Map();
|
|
19936
19960
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19977,7 +20001,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19977
20001
|
const doc = parseXml2(docXml);
|
|
19978
20002
|
const body = findElements(doc, "body");
|
|
19979
20003
|
if (body.length === 0) {
|
|
19980
|
-
throw new (0,
|
|
20004
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19981
20005
|
}
|
|
19982
20006
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19983
20007
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19985,7 +20009,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19985
20009
|
const bodyEl = body[0];
|
|
19986
20010
|
const topLevel = effectiveChildElements(bodyEl);
|
|
19987
20011
|
for (const el of topLevel) {
|
|
19988
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
20012
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _173 => _173.tagName, 'optionalAccess', _174 => _174.split, 'call', _175 => _175(":"), 'access', _176 => _176.pop, 'call', _177 => _177()])));
|
|
19989
20013
|
if (localName2 === "p") {
|
|
19990
20014
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19991
20015
|
if (block) blocks.push(block);
|
|
@@ -19996,7 +20020,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19996
20020
|
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19997
20021
|
}
|
|
19998
20022
|
} else if (localName2 === "tbl") {
|
|
19999
|
-
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess',
|
|
20023
|
+
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess', _178 => _178.keepTrailingEmptyCols]));
|
|
20000
20024
|
if (block) blocks.push(block);
|
|
20001
20025
|
}
|
|
20002
20026
|
}
|
|
@@ -20028,7 +20052,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
20028
20052
|
}
|
|
20029
20053
|
}
|
|
20030
20054
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
20031
|
-
const markdown =
|
|
20055
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20032
20056
|
return {
|
|
20033
20057
|
markdown,
|
|
20034
20058
|
blocks,
|
|
@@ -20051,7 +20075,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20051
20075
|
}
|
|
20052
20076
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
20053
20077
|
const normalized = text.replace(/ /g, " ");
|
|
20054
|
-
const xml =
|
|
20078
|
+
const xml = _chunkOQNFGKRYcjs.stripDtd.call(void 0, normalized);
|
|
20055
20079
|
const warnings = [];
|
|
20056
20080
|
const parser = new (0, _xmldom.DOMParser)({
|
|
20057
20081
|
onError: (_level, msg2) => {
|
|
@@ -20079,7 +20103,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20079
20103
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
20080
20104
|
}
|
|
20081
20105
|
const blocks = [];
|
|
20082
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
20106
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _179 => _179.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
20083
20107
|
let sectionIdx = 0;
|
|
20084
20108
|
const children = body.childNodes;
|
|
20085
20109
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -20088,10 +20112,10 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20088
20112
|
if (localName(el) !== "SECTION") continue;
|
|
20089
20113
|
sectionIdx++;
|
|
20090
20114
|
if (pageFilter && !pageFilter.has(sectionIdx)) continue;
|
|
20091
|
-
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
20115
|
+
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _180 => _180.keepTrailingEmptyCols]), () => ( false)));
|
|
20092
20116
|
}
|
|
20093
20117
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20094
|
-
const markdown =
|
|
20118
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20095
20119
|
return {
|
|
20096
20120
|
markdown,
|
|
20097
20121
|
blocks,
|
|
@@ -20177,7 +20201,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
20177
20201
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
20178
20202
|
const text = extractParagraphText(el);
|
|
20179
20203
|
if (!text) return;
|
|
20180
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
20204
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _181 => _181.headingLevel]) != null) {
|
|
20181
20205
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
20182
20206
|
} else {
|
|
20183
20207
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -20236,7 +20260,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20236
20260
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20237
20261
|
cellRows[r].push(cell2);
|
|
20238
20262
|
}
|
|
20239
|
-
const table2 =
|
|
20263
|
+
const table2 = _chunk2BTKLDNXcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20240
20264
|
const caption = extractShapeCaption(el);
|
|
20241
20265
|
if (caption.text && caption.before) {
|
|
20242
20266
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20496,7 +20520,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
20496
20520
|
(match, prefix, suffix) => {
|
|
20497
20521
|
const label = prefix + suffix;
|
|
20498
20522
|
const normalizedLabel = normalizeLabel(label);
|
|
20499
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20523
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _182 => _182.has, 'call', _183 => _183(normalizedLabel)])) return match;
|
|
20500
20524
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
20501
20525
|
if (matchKey === void 0) return match;
|
|
20502
20526
|
const newValue = values.consume(matchKey);
|
|
@@ -20575,17 +20599,17 @@ function matchInlineSegment(seg, values, blockedLabels) {
|
|
|
20575
20599
|
const nlabel = normalizeLabel(seg.label);
|
|
20576
20600
|
if (seg.extLabel !== void 0) {
|
|
20577
20601
|
const nExt = normalizeLabel(seg.extLabel);
|
|
20578
|
-
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess',
|
|
20602
|
+
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess', _184 => _184.has, 'call', _185 => _185(nExt)]) && values.has(nExt)) {
|
|
20579
20603
|
return { key: nExt, label: seg.extLabel, viaExt: true };
|
|
20580
20604
|
}
|
|
20581
20605
|
}
|
|
20582
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20606
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _186 => _186.has, 'call', _187 => _187(nlabel)])) return void 0;
|
|
20583
20607
|
const key = findMatchingKey(nlabel, values);
|
|
20584
20608
|
return key !== void 0 ? { key, label: seg.label, viaExt: false } : void 0;
|
|
20585
20609
|
}
|
|
20586
20610
|
function clampSegmentEnd(text, seg, next, nextViaExt) {
|
|
20587
20611
|
let ve = seg.valueEnd;
|
|
20588
|
-
if (nextViaExt && _optionalChain([next, 'optionalAccess',
|
|
20612
|
+
if (nextViaExt && _optionalChain([next, 'optionalAccess', _188 => _188.extStart]) !== void 0 && next.extStart < ve) ve = next.extStart;
|
|
20589
20613
|
while (ve > seg.valueStart && /\s/.test(text[ve - 1])) ve--;
|
|
20590
20614
|
return ve;
|
|
20591
20615
|
}
|
|
@@ -20600,7 +20624,7 @@ function normalizeValues(values, warnings) {
|
|
|
20600
20624
|
const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
|
|
20601
20625
|
const key = normalizeLabel(label);
|
|
20602
20626
|
if (map.has(key)) {
|
|
20603
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
20627
|
+
_optionalChain([warnings, 'optionalAccess', _189 => _189.push, 'call', _190 => _190(`\uC785\uB825 \uB77C\uBCA8 "${label}"\uC774 \uC815\uADDC\uD654 \uD0A4 "${key}"\uC5D0\uC11C \uB2E4\uB978 \uB77C\uBCA8\uACFC \uCDA9\uB3CC \u2014 \uB4A4 \uAC12\uC73C\uB85C \uB36E\uC5B4\uC500`)]);
|
|
20604
20628
|
}
|
|
20605
20629
|
map.set(key, Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
|
|
20606
20630
|
}
|
|
@@ -20775,8 +20799,8 @@ function extractFromTable(table2) {
|
|
|
20775
20799
|
if (table2.cols >= 2) {
|
|
20776
20800
|
for (let r = 0; r < table2.rows; r++) {
|
|
20777
20801
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
20778
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20779
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20802
|
+
const labelCell = _optionalChain([table2, 'access', _191 => _191.cells, 'access', _192 => _192[r], 'optionalAccess', _193 => _193[c]]);
|
|
20803
|
+
const valueCell = _optionalChain([table2, 'access', _194 => _194.cells, 'access', _195 => _195[r], 'optionalAccess', _196 => _196[c + 1]]);
|
|
20780
20804
|
if (!labelCell || !valueCell) continue;
|
|
20781
20805
|
if (isLabelCell(labelCell.text)) {
|
|
20782
20806
|
fields.push({
|
|
@@ -20791,15 +20815,15 @@ function extractFromTable(table2) {
|
|
|
20791
20815
|
}
|
|
20792
20816
|
if (fields.length === 0 && table2.rows >= 2 && table2.cols >= 2) {
|
|
20793
20817
|
const headerRow = table2.cells[0];
|
|
20794
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20795
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20818
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _197 => _197.every, 'call', _198 => _198((cell2) => {
|
|
20819
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _199 => _199.text, 'access', _200 => _200.trim, 'call', _201 => _201()]), () => ( ""));
|
|
20796
20820
|
return t.length > 0 && t.length <= 20;
|
|
20797
20821
|
})]), () => ( false));
|
|
20798
20822
|
if (allLabels) {
|
|
20799
20823
|
for (let r = 1; r < table2.rows; r++) {
|
|
20800
20824
|
for (let c = 0; c < table2.cols; c++) {
|
|
20801
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
20802
|
-
const value = _nullishCoalesce(_optionalChain([table2, 'access',
|
|
20825
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _202 => _202[c], 'optionalAccess', _203 => _203.text, 'access', _204 => _204.trim, 'call', _205 => _205()]), () => ( ""));
|
|
20826
|
+
const value = _nullishCoalesce(_optionalChain([table2, 'access', _206 => _206.cells, 'access', _207 => _207[r], 'optionalAccess', _208 => _208[c], 'optionalAccess', _209 => _209.text, 'access', _210 => _210.trim, 'call', _211 => _211()]), () => ( ""));
|
|
20803
20827
|
if (label && value) {
|
|
20804
20828
|
fields.push({ label, value, row: r, col: c });
|
|
20805
20829
|
}
|
|
@@ -20893,7 +20917,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
20893
20917
|
for (const table2 of allTables) {
|
|
20894
20918
|
for (let r = 0; r < table2.rows; r++) {
|
|
20895
20919
|
for (let c = 0; c < table2.cols; c++) {
|
|
20896
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20920
|
+
const cell2 = _optionalChain([table2, 'access', _212 => _212.cells, 'access', _213 => _213[r], 'optionalAccess', _214 => _214[c]]);
|
|
20897
20921
|
if (!cell2) continue;
|
|
20898
20922
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
20899
20923
|
if (result) {
|
|
@@ -20925,7 +20949,7 @@ function collectIRTables(blocks, depth) {
|
|
|
20925
20949
|
out.push(block.table);
|
|
20926
20950
|
for (const row of block.table.cells) {
|
|
20927
20951
|
for (const cell2 of row) {
|
|
20928
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
20952
|
+
if (_optionalChain([cell2, 'optionalAccess', _215 => _215.blocks, 'optionalAccess', _216 => _216.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
20929
20953
|
}
|
|
20930
20954
|
}
|
|
20931
20955
|
}
|
|
@@ -20936,7 +20960,7 @@ function coveredPositions(table2) {
|
|
|
20936
20960
|
for (let r = 0; r < table2.rows; r++) {
|
|
20937
20961
|
for (let c = 0; c < table2.cols; c++) {
|
|
20938
20962
|
if (covered.has(`${r},${c}`)) continue;
|
|
20939
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20963
|
+
const cell2 = _optionalChain([table2, 'access', _217 => _217.cells, 'access', _218 => _218[r], 'optionalAccess', _219 => _219[c]]);
|
|
20940
20964
|
if (!cell2) continue;
|
|
20941
20965
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
20942
20966
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -20952,15 +20976,15 @@ function coveredPositions(table2) {
|
|
|
20952
20976
|
function isHeaderDataTable(table2, covered) {
|
|
20953
20977
|
if (table2.rows < 2) return false;
|
|
20954
20978
|
const headerRow = table2.cells[0];
|
|
20955
|
-
if (!_optionalChain([headerRow, 'optionalAccess',
|
|
20979
|
+
if (!_optionalChain([headerRow, 'optionalAccess', _220 => _220.length])) return false;
|
|
20956
20980
|
const allLabels = headerRow.every((cell2) => {
|
|
20957
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20981
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _221 => _221.text, 'access', _222 => _222.trim, 'call', _223 => _223()]), () => ( ""));
|
|
20958
20982
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20959
20983
|
});
|
|
20960
20984
|
if (!allLabels) return false;
|
|
20961
20985
|
for (let c = 0; c < table2.cols; c++) {
|
|
20962
20986
|
if (covered.has(`1,${c}`)) continue;
|
|
20963
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20987
|
+
const cell2 = _optionalChain([table2, 'access', _224 => _224.cells, 'access', _225 => _225[1], 'optionalAccess', _226 => _226[c]]);
|
|
20964
20988
|
if (!cell2) break;
|
|
20965
20989
|
return !isLabelCell(cell2.text);
|
|
20966
20990
|
}
|
|
@@ -20973,7 +20997,7 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20973
20997
|
for (let r = skipHeaderRow ? 1 : 0; r < table2.rows; r++) {
|
|
20974
20998
|
for (let c = 0; c < table2.cols; c++) {
|
|
20975
20999
|
if (covered.has(`${r},${c}`)) continue;
|
|
20976
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
21000
|
+
const labelCell = _optionalChain([table2, 'access', _227 => _227.cells, 'access', _228 => _228[r], 'optionalAccess', _229 => _229[c]]);
|
|
20977
21001
|
if (!labelCell) continue;
|
|
20978
21002
|
if (!isLabelCell(labelCell.text)) continue;
|
|
20979
21003
|
let vc = c + labelCell.colSpan;
|
|
@@ -20984,12 +21008,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20984
21008
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
20985
21009
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
20986
21010
|
if (!normalizedCellLabel) continue;
|
|
20987
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21011
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _230 => _230.has, 'call', _231 => _231(normalizedCellLabel)])) continue;
|
|
20988
21012
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
20989
21013
|
if (matchKey === void 0) continue;
|
|
20990
21014
|
const newValue = values.consume(matchKey);
|
|
20991
21015
|
if (newValue === void 0) continue;
|
|
20992
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
21016
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _232 => _232.has, 'call', _233 => _233(valueCell)])) {
|
|
20993
21017
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20994
21018
|
} else {
|
|
20995
21019
|
valueCell.text = newValue;
|
|
@@ -21006,8 +21030,8 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
21006
21030
|
}
|
|
21007
21031
|
if (table2.rows >= 2 && table2.cols >= 2) {
|
|
21008
21032
|
const headerRow = table2.cells[0];
|
|
21009
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
21010
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
21033
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _234 => _234.every, 'call', _235 => _235((cell2) => {
|
|
21034
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _236 => _236.text, 'access', _237 => _237.trim, 'call', _238 => _238()]), () => ( ""));
|
|
21011
21035
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
21012
21036
|
})]), () => ( false));
|
|
21013
21037
|
if (!allLabels) return;
|
|
@@ -21015,16 +21039,16 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
21015
21039
|
for (let c = 0; c < table2.cols; c++) {
|
|
21016
21040
|
if (covered.has(`${r},${c}`)) continue;
|
|
21017
21041
|
const headerCell = headerRow[c];
|
|
21018
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
21042
|
+
const valueCell = _optionalChain([table2, 'access', _239 => _239.cells, 'access', _240 => _240[r], 'optionalAccess', _241 => _241[c]]);
|
|
21019
21043
|
if (!headerCell || !valueCell) continue;
|
|
21020
21044
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
21021
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21045
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _242 => _242.has, 'call', _243 => _243(headerLabel)])) continue;
|
|
21022
21046
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
21023
21047
|
if (matchKey === void 0) continue;
|
|
21024
21048
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
21025
21049
|
const newValue = values.consume(matchKey);
|
|
21026
21050
|
if (newValue === void 0) continue;
|
|
21027
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
21051
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _244 => _244.has, 'call', _245 => _245(valueCell)])) {
|
|
21028
21052
|
valueCell.text = newValue + " " + valueCell.text;
|
|
21029
21053
|
} else {
|
|
21030
21054
|
valueCell.text = newValue;
|
|
@@ -21056,7 +21080,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
21056
21080
|
if (newValue === void 0) continue;
|
|
21057
21081
|
matchedLabels.add(matchKey);
|
|
21058
21082
|
filled.push({ label: matched.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
|
|
21059
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
21083
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _246 => _246[i + 1], 'optionalAccess', _247 => _247.viaExt]), () => ( false)));
|
|
21060
21084
|
out += text.slice(pos, seg.valueStart);
|
|
21061
21085
|
out += seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
21062
21086
|
pos = ve;
|
|
@@ -21618,19 +21642,19 @@ function parseCentralDirectory(buf) {
|
|
|
21618
21642
|
}
|
|
21619
21643
|
}
|
|
21620
21644
|
}
|
|
21621
|
-
if (eocdOffset < 0) throw new (0,
|
|
21645
|
+
if (eocdOffset < 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21622
21646
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21623
21647
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21624
21648
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21625
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21649
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21626
21650
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21627
|
-
throw new (0,
|
|
21651
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21628
21652
|
}
|
|
21629
21653
|
const decoder = new TextDecoder("utf-8");
|
|
21630
21654
|
const entries = [];
|
|
21631
21655
|
let pos = cdOffset;
|
|
21632
21656
|
for (let i = 0; i < totalEntries; i++) {
|
|
21633
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21657
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21634
21658
|
const flags = view.getUint16(pos + 8, true);
|
|
21635
21659
|
const method = view.getUint16(pos + 10, true);
|
|
21636
21660
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21641,7 +21665,7 @@ function parseCentralDirectory(buf) {
|
|
|
21641
21665
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21642
21666
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21643
21667
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21644
|
-
throw new (0,
|
|
21668
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21645
21669
|
}
|
|
21646
21670
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21647
21671
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21670,11 +21694,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21670
21694
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21671
21695
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21672
21696
|
for (const name of replacements.keys()) {
|
|
21673
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21697
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkOQNFGKRYcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21674
21698
|
}
|
|
21675
21699
|
if (additions) {
|
|
21676
21700
|
for (const name of additions.keys()) {
|
|
21677
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21701
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkOQNFGKRYcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21678
21702
|
}
|
|
21679
21703
|
}
|
|
21680
21704
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21693,7 +21717,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21693
21717
|
offset += seg.length;
|
|
21694
21718
|
continue;
|
|
21695
21719
|
}
|
|
21696
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21720
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkOQNFGKRYcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21697
21721
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21698
21722
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21699
21723
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21701,7 +21725,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21701
21725
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21702
21726
|
const method = e.method;
|
|
21703
21727
|
if (method !== 0 && method !== 8) {
|
|
21704
|
-
throw new (0,
|
|
21728
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 ZIP \uC555\uCD95 \uBC29\uC2DD(method=${method}): ${e.name} \u2014 STORE(0)/DEFLATE(8)\uB9CC \uAD50\uCCB4 \uAC00\uB2A5`);
|
|
21705
21729
|
}
|
|
21706
21730
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21707
21731
|
const crc = crc32(newData);
|
|
@@ -21802,7 +21826,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21802
21826
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21803
21827
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21804
21828
|
if (sectionPaths.length === 0) {
|
|
21805
|
-
throw new (0,
|
|
21829
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21806
21830
|
}
|
|
21807
21831
|
const warnings = [];
|
|
21808
21832
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -21886,7 +21910,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21886
21910
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
21887
21911
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
21888
21912
|
if (!normalizedCellLabel) continue;
|
|
21889
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21913
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _248 => _248.has, 'call', _249 => _249(normalizedCellLabel)])) continue;
|
|
21890
21914
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
21891
21915
|
if (matchKey === void 0) continue;
|
|
21892
21916
|
if (patternApplied.has(valueCell)) {
|
|
@@ -21944,7 +21968,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21944
21968
|
const dataCells = table2.rows[rowIdx];
|
|
21945
21969
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
21946
21970
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
21947
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21971
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _250 => _250.has, 'call', _251 => _251(headerLabel)])) continue;
|
|
21948
21972
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
21949
21973
|
if (matchKey === void 0) continue;
|
|
21950
21974
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -21998,7 +22022,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21998
22022
|
}
|
|
21999
22023
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
22000
22024
|
const existing = ledger.get(para2);
|
|
22001
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
22025
|
+
if (_optionalChain([existing, 'optionalAccess', _252 => _252.fullText]) !== void 0) continue;
|
|
22002
22026
|
const text = matchText(para2);
|
|
22003
22027
|
const segments = scanInlineSegments(text);
|
|
22004
22028
|
const matches = segments.map((seg) => matchInlineSegment(seg, cursor, blockedLabels));
|
|
@@ -22009,7 +22033,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
22009
22033
|
const matchKey = matched.key;
|
|
22010
22034
|
const newValue = cursor.consume(matchKey);
|
|
22011
22035
|
if (newValue === void 0) continue;
|
|
22012
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
22036
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _253 => _253[i + 1], 'optionalAccess', _254 => _254.viaExt]), () => ( false)));
|
|
22013
22037
|
const replacement = seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
22014
22038
|
const l = led(para2);
|
|
22015
22039
|
l.ranges.push({ start: seg.valueStart, end: ve, replacement });
|
|
@@ -22115,16 +22139,16 @@ var PARA_LIST = 7;
|
|
|
22115
22139
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
22116
22140
|
function resolveTheme(theme) {
|
|
22117
22141
|
return {
|
|
22118
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22119
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22120
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22121
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22122
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22123
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22142
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _255 => _255.headingColors, 'optionalAccess', _256 => _256[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22143
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _257 => _257.headingColors, 'optionalAccess', _258 => _258[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22144
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _259 => _259.headingColors, 'optionalAccess', _260 => _260[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22145
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _261 => _261.headingColors, 'optionalAccess', _262 => _262[4]]), () => ( _optionalChain([theme, 'optionalAccess', _263 => _263.headingColors, 'optionalAccess', _264 => _264[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22146
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _265 => _265.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22147
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _266 => _266.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22124
22148
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
22125
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
22126
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22127
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
22149
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _267 => _267.quoteColor]) !== void 0,
|
|
22150
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _268 => _268.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _269 => _269.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22151
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _270 => _270.tableHeaderBold])
|
|
22128
22152
|
};
|
|
22129
22153
|
}
|
|
22130
22154
|
function escapeXml(text) {
|
|
@@ -22539,7 +22563,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22539
22563
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22540
22564
|
const got = m ? Number(m[1]) : NaN;
|
|
22541
22565
|
if (got !== startId + i) {
|
|
22542
|
-
throw new (0,
|
|
22566
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
22543
22567
|
`\uB0B4\uBD80 \uC624\uB958: ${label} id \uD30C\uD2F0\uC158 \uB4DC\uB9AC\uD504\uD2B8 \u2014 ${startId + i} \uC704\uCE58\uC5D0 id=${m ? m[1] : "?"} \uBC29\uCD9C. id \uC0C1\uC218(gen-ids)\uC640 \uC2E4\uC81C \uBC29\uCD9C \uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4 (GJ_CHAR_COUNT\uB958 \uCE74\uC6B4\uD2B8\xB7base \uC0B0\uC220 \uD655\uC778)`
|
|
22544
22568
|
);
|
|
22545
22569
|
}
|
|
@@ -22623,7 +22647,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22623
22647
|
}
|
|
22624
22648
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22625
22649
|
if (rows.length !== expectedBase) {
|
|
22626
|
-
throw new (0,
|
|
22650
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
22627
22651
|
`\uB0B4\uBD80 \uC624\uB958: charPr \uAE30\uBCF8 \uBE14\uB85D \uBC29\uCD9C \uC218(${rows.length}) \u2260 charVariantBase(${expectedBase}) \u2014 gen-header \uBC29\uCD9C \uD589\uACFC gen-ids \uCE74\uC6B4\uD2B8 \uC0C1\uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4`
|
|
22628
22652
|
);
|
|
22629
22653
|
}
|
|
@@ -22851,7 +22875,7 @@ function buildStyles(gongmun) {
|
|
|
22851
22875
|
</hh:styles>`;
|
|
22852
22876
|
}
|
|
22853
22877
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
22854
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
22878
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _271 => _271.fonts, 'access', _272 => _272.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _273 => _273.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
22855
22879
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
22856
22880
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
22857
22881
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22980,8 +23004,8 @@ function parseChartFence(text) {
|
|
|
22980
23004
|
const spec = chartSpec(type);
|
|
22981
23005
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22982
23006
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22983
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22984
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
23007
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _274 => _274.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
23008
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _275 => _275[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22985
23009
|
if (!spec.scatter) {
|
|
22986
23010
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22987
23011
|
}
|
|
@@ -23023,7 +23047,7 @@ function serSpPr(color, stroke) {
|
|
|
23023
23047
|
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>`;
|
|
23024
23048
|
}
|
|
23025
23049
|
function dPtXml(pointColors, pie) {
|
|
23026
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
23050
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _276 => _276.length])) return "";
|
|
23027
23051
|
return pointColors.map((col, i) => {
|
|
23028
23052
|
const f = chartColorFill(col);
|
|
23029
23053
|
if (!f) return "";
|
|
@@ -23262,8 +23286,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
23262
23286
|
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 });
|
|
23263
23287
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
23264
23288
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
23265
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23266
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23289
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _277 => _277.cover, 'optionalAccess', _278 => _278.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
23290
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _279 => _279.cover, 'optionalAccess', _280 => _280.org]), () => ( ""));
|
|
23267
23291
|
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>`;
|
|
23268
23292
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
23269
23293
|
return [
|
|
@@ -23519,7 +23543,7 @@ function escapeGfm(text) {
|
|
|
23519
23543
|
}
|
|
23520
23544
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23521
23545
|
function sanitizeText(text) {
|
|
23522
|
-
let result =
|
|
23546
|
+
let result = _chunk2BTKLDNXcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23523
23547
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23524
23548
|
const tokens = result.split(" ");
|
|
23525
23549
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23549,7 +23573,7 @@ function replicateGfmTable(table2) {
|
|
|
23549
23573
|
for (let r = 0; r < numRows; r++) {
|
|
23550
23574
|
for (let c = 0; c < numCols; c++) {
|
|
23551
23575
|
if (skip.has(`${r},${c}`)) continue;
|
|
23552
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23576
|
+
const cell2 = _optionalChain([cells, 'access', _281 => _281[r], 'optionalAccess', _282 => _282[c]]);
|
|
23553
23577
|
if (!cell2) continue;
|
|
23554
23578
|
display[r][c] = {
|
|
23555
23579
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -23603,7 +23627,7 @@ function unescapeGfmCell(text) {
|
|
|
23603
23627
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
|
|
23604
23628
|
}
|
|
23605
23629
|
function replicateCellInnerHtml(cell2) {
|
|
23606
|
-
if (_optionalChain([cell2, 'access',
|
|
23630
|
+
if (_optionalChain([cell2, 'access', _283 => _283.blocks, 'optionalAccess', _284 => _284.length])) {
|
|
23607
23631
|
return cell2.blocks.map((b) => {
|
|
23608
23632
|
if (b.type === "table" && b.table) {
|
|
23609
23633
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -23642,7 +23666,7 @@ function replicateHtmlTable(table2) {
|
|
|
23642
23666
|
const rowCells = [];
|
|
23643
23667
|
for (let c = 0; c < numCols; c++) {
|
|
23644
23668
|
if (skip.has(`${r},${c}`)) continue;
|
|
23645
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23669
|
+
const cell2 = _optionalChain([cells, 'access', _285 => _285[r], 'optionalAccess', _286 => _286[c]]);
|
|
23646
23670
|
if (!cell2) continue;
|
|
23647
23671
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
23648
23672
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -23688,10 +23712,10 @@ function parseHtmlTable(raw) {
|
|
|
23688
23712
|
}
|
|
23689
23713
|
} else {
|
|
23690
23714
|
if (!isClose) {
|
|
23691
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
23692
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
23715
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _287 => _287.match, 'call', _288 => _288(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _289 => _289[1]]) || "1", 10);
|
|
23716
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _290 => _290.match, 'call', _291 => _291(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _292 => _292[1]]) || "1", 10);
|
|
23693
23717
|
cellStart = m.index + m[0].length;
|
|
23694
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23718
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunk2BTKLDNXcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunk2BTKLDNXcjs.MAX_ROWS) };
|
|
23695
23719
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23696
23720
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23697
23721
|
cellStart = -1;
|
|
@@ -23715,7 +23739,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
23715
23739
|
hadNonText = true;
|
|
23716
23740
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
23717
23741
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
23718
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
23742
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _293 => _293[1]]), () => ( _optionalChain([m, 'optionalAccess', _294 => _294[2]])));
|
|
23719
23743
|
if (src) imgSrcs.push(src);
|
|
23720
23744
|
return "";
|
|
23721
23745
|
});
|
|
@@ -23858,7 +23882,7 @@ function edgeXml(tag, d) {
|
|
|
23858
23882
|
return d ? `<hh:${tag} type="${escapeXml(d.type)}" width="${escapeXml(d.width)}" color="${escapeXml(d.color)}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
23859
23883
|
}
|
|
23860
23884
|
function borderFillDefToXml(id, def) {
|
|
23861
|
-
const fill = _optionalChain([def, 'access',
|
|
23885
|
+
const fill = _optionalChain([def, 'access', _295 => _295.fill, 'optionalAccess', _296 => _296.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
23862
23886
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
23863
23887
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
23864
23888
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -24263,11 +24287,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
24263
24287
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
24264
24288
|
const rowCnt = rows.length;
|
|
24265
24289
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
24266
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24290
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _297 => _297.bfRegistry]), () => ( null));
|
|
24267
24291
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
24268
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24292
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _298 => _298.charHeight]), () => ( 1e3));
|
|
24269
24293
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
24270
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
24294
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _299 => _299[0], 'optionalAccess', _300 => _300[0]]), () => ( ""))), seq, rowAnchor);
|
|
24271
24295
|
const colMax = Array(colCnt).fill(0);
|
|
24272
24296
|
const colMaxBody = Array(colCnt).fill(0);
|
|
24273
24297
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -24295,7 +24319,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24295
24319
|
const k = `${rowIdx},${colIdx}`;
|
|
24296
24320
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
24297
24321
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
24298
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24322
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _301 => _301.cellChar, 'access', _302 => _302.get, 'call', _303 => _303(k)]), () => ( defaultCharPr));
|
|
24299
24323
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
24300
24324
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24301
24325
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -24313,11 +24337,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24313
24337
|
}
|
|
24314
24338
|
}
|
|
24315
24339
|
}
|
|
24316
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
24340
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _304 => _304.cellChar, 'access', _305 => _305.has, 'call', _306 => _306(k)]) ? void 0 : mapId);
|
|
24317
24341
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
24318
24342
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
24319
24343
|
}).join("");
|
|
24320
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24344
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _307 => _307.cellBf, 'access', _308 => _308.get, 'call', _309 => _309(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24321
24345
|
row: rowIdx,
|
|
24322
24346
|
rowEnd: rowIdx,
|
|
24323
24347
|
col: colIdx,
|
|
@@ -24327,7 +24351,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24327
24351
|
headerRows: 1,
|
|
24328
24352
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
24329
24353
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
24330
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24354
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _310 => _310.cellH, 'access', _311 => _311.get, 'call', _312 => _312(k)]), () => ( cellH));
|
|
24331
24355
|
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>`;
|
|
24332
24356
|
}).join("");
|
|
24333
24357
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -24336,7 +24360,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24336
24360
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
24337
24361
|
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;
|
|
24338
24362
|
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>`;
|
|
24339
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
24363
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _313 => _313.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
24340
24364
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
24341
24365
|
}
|
|
24342
24366
|
function layoutHtmlRows(rows) {
|
|
@@ -24347,8 +24371,8 @@ function layoutHtmlRows(rows) {
|
|
|
24347
24371
|
let c = 0;
|
|
24348
24372
|
for (const cell2 of rows[r].cells) {
|
|
24349
24373
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24350
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24351
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24374
|
+
const colSpan = clampSpan(cell2.colSpan, _chunk2BTKLDNXcjs.MAX_COLS);
|
|
24375
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunk2BTKLDNXcjs.MAX_ROWS);
|
|
24352
24376
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24353
24377
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24354
24378
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -24376,7 +24400,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24376
24400
|
if (!rows || rows.length === 0) return null;
|
|
24377
24401
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
24378
24402
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
24379
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24403
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _314 => _314.charHeight]), () => ( 1e3));
|
|
24380
24404
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
24381
24405
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
24382
24406
|
for (const cell2 of placed) {
|
|
@@ -24405,7 +24429,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24405
24429
|
const tblId = nextTableId();
|
|
24406
24430
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
24407
24431
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
24408
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24432
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _315 => _315.bfRegistry]), () => ( null));
|
|
24409
24433
|
let htmlHeaderRows = 0;
|
|
24410
24434
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
24411
24435
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -24419,7 +24443,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24419
24443
|
const nestedW = Math.max(Math.min(Math.max(sw - 1020, 4e3), sw - 282), 500);
|
|
24420
24444
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
24421
24445
|
if (nestedXml) {
|
|
24422
|
-
const szH = _optionalChain([nestedXml, 'access',
|
|
24446
|
+
const szH = _optionalChain([nestedXml, 'access', _316 => _316.match, 'call', _317 => _317(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _318 => _318[1]]);
|
|
24423
24447
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
24424
24448
|
}
|
|
24425
24449
|
return nestedXml;
|
|
@@ -24430,7 +24454,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24430
24454
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
24431
24455
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
24432
24456
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
24433
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24457
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _319 => _319.cellH, 'access', _320 => _320.get, 'call', _321 => _321(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
|
|
24434
24458
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
24435
24459
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
24436
24460
|
return { cell: cell2, rowSpan, lines, nestedXmls, segLines, imgSrcs: cellParsed[i].imgSrcs };
|
|
@@ -24441,7 +24465,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24441
24465
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
24442
24466
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
24443
24467
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
24444
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24468
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _322 => _322.cellChar, 'access', _323 => _323.get, 'call', _324 => _324(k)]), () => ( defaultCharPr));
|
|
24445
24469
|
const centered = isHeader || colCentered[cell2.c];
|
|
24446
24470
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24447
24471
|
const picUrls = images ? [...imgSrcs] : [];
|
|
@@ -24481,7 +24505,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24481
24505
|
let cellHeight = 0;
|
|
24482
24506
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
24483
24507
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
24484
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24508
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _325 => _325.cellBf, 'access', _326 => _326.get, 'call', _327 => _327(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24485
24509
|
row: cell2.r,
|
|
24486
24510
|
rowEnd,
|
|
24487
24511
|
col: cell2.c,
|
|
@@ -24651,7 +24675,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
24651
24675
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
24652
24676
|
}
|
|
24653
24677
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
24654
|
-
const c = _optionalChain([g, 'access',
|
|
24678
|
+
const c = _optionalChain([g, 'access', _328 => _328.press, 'optionalAccess', _329 => _329.contact]);
|
|
24655
24679
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
24656
24680
|
const w = bodyWidth - 280;
|
|
24657
24681
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -25032,7 +25056,7 @@ function generateSecPr(gongmun) {
|
|
|
25032
25056
|
}
|
|
25033
25057
|
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="${A4_W_HU}" height="${A4_H_HU}" 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>`;
|
|
25034
25058
|
const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
|
|
25035
|
-
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess',
|
|
25059
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _330 => _330.pageNumbers]) ? pageNumCtrl() : "");
|
|
25036
25060
|
}
|
|
25037
25061
|
var SectionOpener = (_class6 = class {
|
|
25038
25062
|
constructor(gongmun) {;_class6.prototype.__init12.call(this);
|
|
@@ -25071,19 +25095,19 @@ function buildPreamble(blocks, ctx) {
|
|
|
25071
25095
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
25072
25096
|
const preamble = [];
|
|
25073
25097
|
let hasFrontPages = false;
|
|
25074
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25098
|
+
if (_optionalChain([gongmun, 'optionalAccess', _331 => _331.reportInfo]) && dfIds) {
|
|
25075
25099
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
25076
25100
|
}
|
|
25077
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25101
|
+
if (_optionalChain([gongmun, 'optionalAccess', _332 => _332.approval]) && bfReg) {
|
|
25078
25102
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
25079
25103
|
}
|
|
25080
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25104
|
+
if (_optionalChain([gongmun, 'optionalAccess', _333 => _333.docHead]) && dfIds) {
|
|
25081
25105
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
25082
25106
|
}
|
|
25083
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25107
|
+
if (_optionalChain([gongmun, 'optionalAccess', _334 => _334.noticeHead]) && dfIds) {
|
|
25084
25108
|
preamble.push(...buildNoticeHead(gongmun));
|
|
25085
25109
|
}
|
|
25086
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25110
|
+
if (_optionalChain([gongmun, 'optionalAccess', _335 => _335.press]) && dfIds && bfReg && tableStyle) {
|
|
25087
25111
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25088
25112
|
}
|
|
25089
25113
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -25112,7 +25136,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
25112
25136
|
}
|
|
25113
25137
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
25114
25138
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25115
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
25139
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _336 => _336.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
25116
25140
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25117
25141
|
}
|
|
25118
25142
|
if (preamble.length > 0) {
|
|
@@ -25127,7 +25151,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
25127
25151
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
25128
25152
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
25129
25153
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
25130
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
25154
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _337 => _337.press, 'optionalAccess', _338 => _338.sub]), () => ( []))) {
|
|
25131
25155
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
25132
25156
|
}
|
|
25133
25157
|
return parts.join("\n ");
|
|
@@ -25221,8 +25245,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25221
25245
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
25222
25246
|
if (gongmun && gongmunList) {
|
|
25223
25247
|
const info = gongmunList.items.get(blockIdx);
|
|
25224
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25225
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25248
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _339 => _339.depth]), () => ( 0));
|
|
25249
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _340 => _340.marker]), () => ( ""));
|
|
25226
25250
|
const content = block.text || "";
|
|
25227
25251
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
25228
25252
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -25231,7 +25255,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25231
25255
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
25232
25256
|
}
|
|
25233
25257
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
25234
|
-
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess',
|
|
25258
|
+
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _341 => _341.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
25235
25259
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
25236
25260
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
25237
25261
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -25290,18 +25314,18 @@ function renderHtmlTable(block, ctx) {
|
|
|
25290
25314
|
}
|
|
25291
25315
|
function appendPostamble(blocks, ctx) {
|
|
25292
25316
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
25293
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25317
|
+
if (_optionalChain([gongmun, 'optionalAccess', _342 => _342.noticeHead]) && dfIds) {
|
|
25294
25318
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
25295
25319
|
}
|
|
25296
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25297
|
-
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access',
|
|
25320
|
+
if (_optionalChain([gongmun, 'optionalAccess', _343 => _343.endMark]) && paraXmls.length > 0) {
|
|
25321
|
+
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _344 => _344.rows, 'optionalAccess', _345 => _345.length]));
|
|
25298
25322
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
25299
25323
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
25300
25324
|
}
|
|
25301
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25325
|
+
if (_optionalChain([gongmun, 'optionalAccess', _346 => _346.docFoot]) && dfIds) {
|
|
25302
25326
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
25303
25327
|
}
|
|
25304
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25328
|
+
if (_optionalChain([gongmun, 'optionalAccess', _347 => _347.press]) && dfIds && bfReg && tableStyle) {
|
|
25305
25329
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25306
25330
|
}
|
|
25307
25331
|
}
|
|
@@ -25321,7 +25345,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25321
25345
|
remap,
|
|
25322
25346
|
dfIds,
|
|
25323
25347
|
images,
|
|
25324
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
25348
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _348 => _348.preset]) === "gaejosik",
|
|
25325
25349
|
measured,
|
|
25326
25350
|
richAssets,
|
|
25327
25351
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -25427,18 +25451,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25427
25451
|
|
|
25428
25452
|
// src/hwpx/generator.ts
|
|
25429
25453
|
async function markdownToHwpx(markdown, options) {
|
|
25430
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
25431
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
25454
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _349 => _349.theme]));
|
|
25455
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _350 => _350.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
25432
25456
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
25433
25457
|
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
25434
25458
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
25435
25459
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
25436
25460
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
25437
25461
|
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
25438
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
25439
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25462
|
+
const remap = _optionalChain([options, 'optionalAccess', _351 => _351.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _352 => _352.variants, 'optionalAccess', _353 => _353.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
|
|
25463
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _354 => _354.borderFillXmls, 'access', _355 => _355.length]), () => ( 0)))) : null;
|
|
25440
25464
|
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
25441
|
-
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25465
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _356 => _356.variants, 'optionalAccess', _357 => _357.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _358 => _358.charPrXmls, 'access', _359 => _359.length]), () => ( 0)));
|
|
25442
25466
|
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
25443
25467
|
const chartParts = [];
|
|
25444
25468
|
const images = new ImageRegistry();
|
|
@@ -25449,7 +25473,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25449
25473
|
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)`);
|
|
25450
25474
|
}
|
|
25451
25475
|
}
|
|
25452
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25476
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _360 => _360.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _361 => _361.emit, 'call', _362 => _362()]), () => ( []))];
|
|
25453
25477
|
const zip = new (0, _jszip2.default)();
|
|
25454
25478
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
25455
25479
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
@@ -25458,11 +25482,11 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25458
25482
|
zip.file("Contents/header.xml", generateHeaderXml(
|
|
25459
25483
|
theme,
|
|
25460
25484
|
gongmun,
|
|
25461
|
-
_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25485
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _363 => _363.variants]), () => ( [])),
|
|
25462
25486
|
extraBorderFills,
|
|
25463
|
-
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25464
|
-
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess',
|
|
25465
|
-
_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25487
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _364 => _364.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
|
|
25488
|
+
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _365 => _365.indentVariants]), () => ( [])),
|
|
25489
|
+
_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _366 => _366.fontFaces]), () => ( []))
|
|
25466
25490
|
));
|
|
25467
25491
|
zip.file("Contents/section0.xml", sectionXml);
|
|
25468
25492
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
@@ -25513,7 +25537,7 @@ function alignBlocks(a, b) {
|
|
|
25513
25537
|
const m = a.length, n = b.length;
|
|
25514
25538
|
if (m * n > 1e7) return fallbackAlign(a, b);
|
|
25515
25539
|
const lenOf = (blk) => {
|
|
25516
|
-
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25540
|
+
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _367 => _367.text]), () => ( ""))).join(" ") : "";
|
|
25517
25541
|
return t.replace(/\s+/g, " ").trim().length;
|
|
25518
25542
|
};
|
|
25519
25543
|
const aLen = a.map(lenOf);
|
|
@@ -25586,8 +25610,8 @@ function blockSimilarity(a, b) {
|
|
|
25586
25610
|
}
|
|
25587
25611
|
function tableSimilarity(a, b) {
|
|
25588
25612
|
const dimSim = 1 - Math.abs(a.rows * a.cols - b.rows * b.cols) / Math.max(a.rows * a.cols, b.rows * b.cols, 1);
|
|
25589
|
-
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25590
|
-
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25613
|
+
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _368 => _368.text]), () => ( ""))).join(" ");
|
|
25614
|
+
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _369 => _369.text]), () => ( ""))).join(" ");
|
|
25591
25615
|
const contentSim = normalizedSimilarity(textsA, textsB);
|
|
25592
25616
|
return dimSim * 0.3 + contentSim * 0.7;
|
|
25593
25617
|
}
|
|
@@ -25598,8 +25622,8 @@ function diffTableCells(a, b) {
|
|
|
25598
25622
|
for (let r = 0; r < maxRows; r++) {
|
|
25599
25623
|
const row = [];
|
|
25600
25624
|
for (let c = 0; c < maxCols; c++) {
|
|
25601
|
-
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access',
|
|
25602
|
-
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access',
|
|
25625
|
+
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access', _370 => _370.cells, 'access', _371 => _371[r], 'optionalAccess', _372 => _372[c], 'optionalAccess', _373 => _373.text]) : void 0;
|
|
25626
|
+
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access', _374 => _374.cells, 'access', _375 => _375[r], 'optionalAccess', _376 => _376[c], 'optionalAccess', _377 => _377.text]) : void 0;
|
|
25603
25627
|
let type;
|
|
25604
25628
|
if (cellA === void 0) type = "added";
|
|
25605
25629
|
else if (cellB === void 0) type = "removed";
|
|
@@ -25765,7 +25789,7 @@ function parseRenderStyles(headXml) {
|
|
|
25765
25789
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
25766
25790
|
const textColor = el.getAttribute("textColor");
|
|
25767
25791
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
25768
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
25792
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _378 => _378.getAttribute, 'call', _379 => _379("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _380 => _380.getAttribute, 'call', _381 => _381("latin")])));
|
|
25769
25793
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
25770
25794
|
styles.charPr.set(id, {
|
|
25771
25795
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -25773,8 +25797,8 @@ function parseRenderStyles(headXml) {
|
|
|
25773
25797
|
italic: findChildByLocalName(el, "italic") != null,
|
|
25774
25798
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
25775
25799
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
25776
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
25777
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
25800
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _382 => _382.getAttribute, 'call', _383 => _383("hangul")])) || 100,
|
|
25801
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _384 => _384.getAttribute, 'call', _385 => _385("hangul")])) || 0,
|
|
25778
25802
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
25779
25803
|
face
|
|
25780
25804
|
});
|
|
@@ -25783,7 +25807,7 @@ function parseRenderStyles(headXml) {
|
|
|
25783
25807
|
const id = el.getAttribute("id");
|
|
25784
25808
|
if (id != null) {
|
|
25785
25809
|
const align = findChildByLocalName(el, "align");
|
|
25786
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
25810
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _386 => _386.getAttribute, 'call', _387 => _387("horizontal")]) || "JUSTIFY");
|
|
25787
25811
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
25788
25812
|
}
|
|
25789
25813
|
} else if (tag === "borderFill") {
|
|
@@ -25797,7 +25821,7 @@ function parseRenderStyles(headXml) {
|
|
|
25797
25821
|
};
|
|
25798
25822
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
25799
25823
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
25800
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
25824
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _388 => _388.getAttribute, 'call', _389 => _389("faceColor")]);
|
|
25801
25825
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
25802
25826
|
styles.borderFill.set(id, bf);
|
|
25803
25827
|
}
|
|
@@ -25869,7 +25893,7 @@ function collectSites(scan) {
|
|
|
25869
25893
|
}
|
|
25870
25894
|
function attrOf(openTag, name) {
|
|
25871
25895
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
25872
|
-
return _optionalChain([m, 'optionalAccess',
|
|
25896
|
+
return _optionalChain([m, 'optionalAccess', _390 => _390[1]]);
|
|
25873
25897
|
}
|
|
25874
25898
|
function paraOpenTag(xml, para2) {
|
|
25875
25899
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -25884,7 +25908,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
25884
25908
|
if (!tr) return null;
|
|
25885
25909
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
25886
25910
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
25887
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
25911
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _391 => _391[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
25888
25912
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
25889
25913
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
25890
25914
|
if (close === -1) return null;
|
|
@@ -25911,7 +25935,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
25911
25935
|
if (width === null) return null;
|
|
25912
25936
|
let content = width;
|
|
25913
25937
|
const win = cellAddrWindow(xml, cell2);
|
|
25914
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
25938
|
+
const mg = _optionalChain([win, 'optionalAccess', _392 => _392.match, 'call', _393 => _393(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
25915
25939
|
if (mg) {
|
|
25916
25940
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
25917
25941
|
}
|
|
@@ -25945,11 +25969,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25945
25969
|
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>`;
|
|
25946
25970
|
}
|
|
25947
25971
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25948
|
-
if (ops.length === 0) throw new (0,
|
|
25972
|
+
if (ops.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25949
25973
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25950
25974
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25951
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
25952
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25975
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _394 => _394.match, 'call', _395 => _395(/(\d+)\.xml$/i), 'optionalAccess', _396 => _396[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _397 => _397.match, 'call', _398 => _398(/(\d+)\.xml$/i), 'optionalAccess', _399 => _399[1]]), () => ( 0))));
|
|
25976
|
+
if (sectionPaths.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25953
25977
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25954
25978
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25955
25979
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25990,11 +26014,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25990
26014
|
const manifestItems = [];
|
|
25991
26015
|
const placed = [];
|
|
25992
26016
|
for (const op of ops) {
|
|
25993
|
-
if (!op.anchor) throw new (0,
|
|
25994
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
26017
|
+
if (!op.anchor) throw new (0, _chunkOQNFGKRYcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26018
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25995
26019
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25996
|
-
if (!MIME[ext]) throw new (0,
|
|
25997
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
26020
|
+
if (!MIME[ext]) throw new (0, _chunkOQNFGKRYcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
26021
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkOQNFGKRYcjs.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)`);
|
|
25998
26022
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25999
26023
|
let found = null;
|
|
26000
26024
|
let total = 0;
|
|
@@ -26027,7 +26051,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26027
26051
|
}
|
|
26028
26052
|
}
|
|
26029
26053
|
}
|
|
26030
|
-
throw new (0,
|
|
26054
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
26031
26055
|
`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)})`
|
|
26032
26056
|
);
|
|
26033
26057
|
}
|
|
@@ -26035,9 +26059,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26035
26059
|
const xml = sectionXmls[si];
|
|
26036
26060
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26037
26061
|
if (!run) {
|
|
26038
|
-
throw new (0,
|
|
26062
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26039
26063
|
}
|
|
26040
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
26064
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _400 => _400.charPr, 'access', _401 => _401.get, 'call', _402 => _402(run.charPr), 'optionalAccess', _403 => _403.height]), () => ( 1e3));
|
|
26041
26065
|
const fontPt = charPrHeight / 100;
|
|
26042
26066
|
const emMm = fontPt * 25.4 / 72;
|
|
26043
26067
|
const lineHMm = emMm;
|
|
@@ -26046,7 +26070,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26046
26070
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
26047
26071
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
26048
26072
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
26049
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
26073
|
+
const align = _optionalChain([styles, 'optionalAccess', _404 => _404.paraAlign, 'access', _405 => _405.get, 'call', _406 => _406(paraPrId)]);
|
|
26050
26074
|
let alignShiftMm = 0;
|
|
26051
26075
|
if (align === "CENTER" || align === "RIGHT") {
|
|
26052
26076
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -26142,7 +26166,7 @@ function parseBorderFills(headerDoc) {
|
|
|
26142
26166
|
};
|
|
26143
26167
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
26144
26168
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26145
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26169
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _407 => _407.getAttribute, 'call', _408 => _408("faceColor")]);
|
|
26146
26170
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
26147
26171
|
map.set(id, def);
|
|
26148
26172
|
}
|
|
@@ -26174,7 +26198,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
26174
26198
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
26175
26199
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
26176
26200
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
26177
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
26201
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _409 => _409.getAttribute, 'call', _410 => _410("hangul")]);
|
|
26178
26202
|
if (hangul) {
|
|
26179
26203
|
def.fontRef_hangul = hangul;
|
|
26180
26204
|
const face = hangulFonts.get(hangul);
|
|
@@ -26202,7 +26226,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26202
26226
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
26203
26227
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
26204
26228
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
26205
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
26229
|
+
const width = _optionalChain([sz, 'optionalAccess', _411 => _411.getAttribute, 'call', _412 => _412("width")]) || void 0;
|
|
26206
26230
|
const cells = [];
|
|
26207
26231
|
const usedBf = /* @__PURE__ */ new Set();
|
|
26208
26232
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -26215,17 +26239,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26215
26239
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
26216
26240
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
26217
26241
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
26218
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26219
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26242
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _413 => _413.getAttribute, 'call', _414 => _414("rowAddr")])), () => ( 0));
|
|
26243
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _415 => _415.getAttribute, 'call', _416 => _416("colAddr")])), () => ( 0));
|
|
26220
26244
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
26221
26245
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
26222
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26223
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26246
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _417 => _417.getAttribute, 'call', _418 => _418("colSpan")])), () => ( 1));
|
|
26247
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _419 => _419.getAttribute, 'call', _420 => _420("rowSpan")])), () => ( 1));
|
|
26224
26248
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
26225
26249
|
const cpId = firstRunCharPr(tc2);
|
|
26226
26250
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
26227
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
26228
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
26251
|
+
const w = _optionalChain([csz, 'optionalAccess', _421 => _421.getAttribute, 'call', _422 => _422("width")]);
|
|
26252
|
+
const hh = _optionalChain([csz, 'optionalAccess', _423 => _423.getAttribute, 'call', _424 => _424("height")]);
|
|
26229
26253
|
if (w) cell2.width_hwpunit = w;
|
|
26230
26254
|
if (hh) cell2.height_hwpunit = hh;
|
|
26231
26255
|
if (bfId) {
|
|
@@ -26313,16 +26337,16 @@ function pick(map, keys) {
|
|
|
26313
26337
|
return out;
|
|
26314
26338
|
}
|
|
26315
26339
|
async function hwpxToProfile(input) {
|
|
26316
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26340
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkOQNFGKRYcjs.toArrayBuffer.call(void 0, input);
|
|
26317
26341
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26318
26342
|
const parser = createXmlParser();
|
|
26319
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
26343
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _425 => _425.file, 'call', _426 => _426(/[Hh]eader\.xml$/), 'optionalAccess', _427 => _427[0]])));
|
|
26320
26344
|
let headerXml = "<root/>";
|
|
26321
26345
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
26322
26346
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
26323
26347
|
const borderFills = parseBorderFills(headerDoc);
|
|
26324
26348
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
26325
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
26349
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _428 => _428.name, 'access', _429 => _429.match, 'call', _430 => _430(/(\d+)\.xml$/), 'optionalAccess', _431 => _431[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _432 => _432.name, 'access', _433 => _433.match, 'call', _434 => _434(/(\d+)\.xml$/), 'optionalAccess', _435 => _435[1]]), () => ( null))), () => ( 0))));
|
|
26326
26350
|
const tables = [];
|
|
26327
26351
|
let tableIndex = 0;
|
|
26328
26352
|
for (const f of sectionFiles) {
|
|
@@ -26636,7 +26660,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
26636
26660
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
26637
26661
|
function patchTableRows(input) {
|
|
26638
26662
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
26639
|
-
const xml = _optionalChain([ctx, 'access',
|
|
26663
|
+
const xml = _optionalChain([ctx, 'access', _436 => _436.scans, 'access', _437 => _437[scanTable.sectionIndex], 'optionalAccess', _438 => _438.xml]);
|
|
26640
26664
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
26641
26665
|
const numRows = table2.rows;
|
|
26642
26666
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -26803,7 +26827,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
26803
26827
|
const rr = scanTable.rowRanges[template];
|
|
26804
26828
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
26805
26829
|
const scan = scanSectionXml(wrapped, 0);
|
|
26806
|
-
const row = _optionalChain([scan, 'access',
|
|
26830
|
+
const row = _optionalChain([scan, 'access', _439 => _439.tables, 'access', _440 => _440[0], 'optionalAccess', _441 => _441.rows, 'access', _442 => _442[0]]);
|
|
26807
26831
|
if (!row || row.length !== cells.length) return null;
|
|
26808
26832
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
26809
26833
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -26846,7 +26870,7 @@ function rowHeightOf(fragment) {
|
|
|
26846
26870
|
}
|
|
26847
26871
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
26848
26872
|
const from = scanTable.start + tblOpenLen;
|
|
26849
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
26873
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _443 => _443.rowRanges, 'access', _444 => _444[0], 'optionalAccess', _445 => _445.start]), () => ( from));
|
|
26850
26874
|
const slice = xml.slice(from, to);
|
|
26851
26875
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
26852
26876
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -27035,9 +27059,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
27035
27059
|
});
|
|
27036
27060
|
}
|
|
27037
27061
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
27038
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27062
|
+
const irCell = _optionalChain([table2, 'access', _446 => _446.cells, 'access', _447 => _447[oc.gridR], 'optionalAccess', _448 => _448[oc.gridC]]);
|
|
27039
27063
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
27040
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
27064
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _449 => _449.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
27041
27065
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
27042
27066
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
27043
27067
|
}
|
|
@@ -27105,7 +27129,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27105
27129
|
};
|
|
27106
27130
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
27107
27131
|
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)");
|
|
27108
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27132
|
+
const irCell = _optionalChain([table2, 'access', _450 => _450.cells, 'access', _451 => _451[gridR], 'optionalAccess', _452 => _452[gridC]]);
|
|
27109
27133
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
27110
27134
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27111
27135
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27128,8 +27152,17 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27128
27152
|
if (newLines.length === 0) return 0;
|
|
27129
27153
|
const target = cell2.paragraphs[0];
|
|
27130
27154
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
27131
|
-
const
|
|
27132
|
-
|
|
27155
|
+
const value = newLines.join(" ");
|
|
27156
|
+
const xml = _optionalChain([ctx, 'access', _453 => _453.scans, 'access', _454 => _454[target.sectionIndex], 'optionalAccess', _455 => _455.xml]);
|
|
27157
|
+
const rawT = xml ? paraTText(target, xml) : null;
|
|
27158
|
+
let sp;
|
|
27159
|
+
if (xml && rawT !== null && rawT.length > 0 && rawT.trim() === "") {
|
|
27160
|
+
sp = buildRangeSplices(target, xml, 0, 0, value);
|
|
27161
|
+
if (sp === null) return skip("\uBE48 \uC140 \uACF5\uBC31 \uBCF4\uC874 \uC0BD\uC785 \uACBD\uACC4 \uBAA8\uD638 \u2014 \uC6D0\uBB38 \uC190\uC2E4 \uBC29\uC9C0\uB85C \uBBF8\uC801\uC6A9");
|
|
27162
|
+
} else {
|
|
27163
|
+
sp = buildParagraphSplices(target, value, xml);
|
|
27164
|
+
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27165
|
+
}
|
|
27133
27166
|
splices.push(...sp);
|
|
27134
27167
|
sectionIndex = target.sectionIndex;
|
|
27135
27168
|
if (newLines.length > 1) {
|
|
@@ -27151,7 +27184,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27151
27184
|
}
|
|
27152
27185
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
27153
27186
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
27154
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
27187
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _456 => _456.scans, 'access', _457 => _457[nonEmpty[i].sectionIndex], 'optionalAccess', _458 => _458.xml]));
|
|
27155
27188
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27156
27189
|
splices.push(...sp);
|
|
27157
27190
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -27232,7 +27265,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27232
27265
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27233
27266
|
if (paths.length > 0) return paths;
|
|
27234
27267
|
}
|
|
27235
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27268
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkOQNFGKRYcjs.compareSectionPaths);
|
|
27236
27269
|
}
|
|
27237
27270
|
function sectionPathsFromManifest(xml) {
|
|
27238
27271
|
const attr = (tag, name) => {
|
|
@@ -27242,7 +27275,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27242
27275
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27243
27276
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27244
27277
|
const id = attr(m[1], "id");
|
|
27245
|
-
const href =
|
|
27278
|
+
const href = _chunkOQNFGKRYcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27246
27279
|
if (id && href) idToHref.set(id, href);
|
|
27247
27280
|
}
|
|
27248
27281
|
const ordered = [];
|
|
@@ -27251,7 +27284,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27251
27284
|
if (href) ordered.push(href);
|
|
27252
27285
|
}
|
|
27253
27286
|
if (ordered.length > 0) return ordered;
|
|
27254
|
-
return Array.from(idToHref.values()).sort(
|
|
27287
|
+
return Array.from(idToHref.values()).sort(_chunkOQNFGKRYcjs.compareSectionPaths);
|
|
27255
27288
|
}
|
|
27256
27289
|
|
|
27257
27290
|
// src/roundtrip/patcher.ts
|
|
@@ -27343,7 +27376,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
27343
27376
|
}
|
|
27344
27377
|
}
|
|
27345
27378
|
let verification;
|
|
27346
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27379
|
+
if (_optionalChain([options, 'optionalAccess', _459 => _459.verify]) !== false) {
|
|
27347
27380
|
try {
|
|
27348
27381
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
27349
27382
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -27361,17 +27394,17 @@ function buildOrigUnits(blocks) {
|
|
|
27361
27394
|
let chunk;
|
|
27362
27395
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27363
27396
|
const next = blocks[i + 1];
|
|
27364
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
27365
|
-
chunk =
|
|
27397
|
+
if (_optionalChain([next, 'optionalAccess', _460 => _460.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27398
|
+
chunk = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27366
27399
|
} else {
|
|
27367
|
-
chunk =
|
|
27400
|
+
chunk = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27368
27401
|
}
|
|
27369
27402
|
if (chunk) {
|
|
27370
27403
|
const subUnits = splitMarkdownUnits(chunk);
|
|
27371
27404
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
27372
27405
|
for (let s = 0; s < subUnits.length; s++) {
|
|
27373
27406
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
27374
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
27407
|
+
if (block.type === "table" && _optionalChain([block, 'access', _461 => _461.table, 'optionalAccess', _462 => _462.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
27375
27408
|
u.role = "caption";
|
|
27376
27409
|
}
|
|
27377
27410
|
units.push(u);
|
|
@@ -27482,7 +27515,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27482
27515
|
const ti = ctx.tableInsert;
|
|
27483
27516
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
27484
27517
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27485
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27518
|
+
if (!_optionalChain([mapping, 'optionalAccess', _463 => _463.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");
|
|
27486
27519
|
const para2 = mapping.para;
|
|
27487
27520
|
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");
|
|
27488
27521
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -27510,7 +27543,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27510
27543
|
}
|
|
27511
27544
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
27512
27545
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27513
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27546
|
+
if (!_optionalChain([mapping, 'optionalAccess', _464 => _464.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)");
|
|
27514
27547
|
if (block.text && block.text.includes("\n")) {
|
|
27515
27548
|
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)");
|
|
27516
27549
|
}
|
|
@@ -27541,7 +27574,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
27541
27574
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27542
27575
|
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");
|
|
27543
27576
|
}
|
|
27544
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
27577
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _465 => _465.scans, 'access', _466 => _466[mapping.para.sectionIndex], 'optionalAccess', _467 => _467.xml]));
|
|
27545
27578
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27546
27579
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27547
27580
|
return 1;
|
|
@@ -27730,7 +27763,7 @@ var Surgeon = (_class7 = class {
|
|
|
27730
27763
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
27731
27764
|
findEntry(path) {
|
|
27732
27765
|
const parts = path.replace(/^\//, "").split("/");
|
|
27733
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
27766
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _468 => _468.entries, 'access', _469 => _469[0], 'optionalAccess', _470 => _470.child]), () => ( -1));
|
|
27734
27767
|
let current;
|
|
27735
27768
|
for (const part of parts) {
|
|
27736
27769
|
const search = (idx) => {
|
|
@@ -27969,8 +28002,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
27969
28002
|
parts.push(header, data);
|
|
27970
28003
|
};
|
|
27971
28004
|
for (let i = 0; i < recs.length; i++) {
|
|
27972
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
27973
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
28005
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _471 => _471.get, 'call', _472 => _472(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
28006
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _473 => _473.get, 'call', _474 => _474(i)]), () => ( recs[i].data)));
|
|
27974
28007
|
}
|
|
27975
28008
|
return Buffer.concat(parts);
|
|
27976
28009
|
}
|
|
@@ -28088,7 +28121,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28088
28121
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
28089
28122
|
}
|
|
28090
28123
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
28091
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
28124
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _475 => _475.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
28092
28125
|
let flags;
|
|
28093
28126
|
try {
|
|
28094
28127
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -28110,7 +28143,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28110
28143
|
const scans = [];
|
|
28111
28144
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
28112
28145
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
28113
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
28146
|
+
if (!_optionalChain([entry, 'optionalAccess', _476 => _476.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
28114
28147
|
let stream;
|
|
28115
28148
|
try {
|
|
28116
28149
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -28161,7 +28194,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28161
28194
|
}
|
|
28162
28195
|
}
|
|
28163
28196
|
let verification;
|
|
28164
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28197
|
+
if (_optionalChain([options, 'optionalAccess', _477 => _477.verify]) !== false) {
|
|
28165
28198
|
try {
|
|
28166
28199
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
28167
28200
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -28251,7 +28284,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
28251
28284
|
for (const [key, scanCell] of scanTable.cells) {
|
|
28252
28285
|
const comma = key.indexOf(",");
|
|
28253
28286
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
28254
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
28287
|
+
const irCell = _optionalChain([irTable, 'access', _478 => _478.cells, 'access', _479 => _479[r], 'optionalAccess', _480 => _480[c]]);
|
|
28255
28288
|
if (!irCell) continue;
|
|
28256
28289
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
28257
28290
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -28287,7 +28320,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
28287
28320
|
}
|
|
28288
28321
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
28289
28322
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28290
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28323
|
+
if (!_optionalChain([mapping, 'optionalAccess', _481 => _481.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)");
|
|
28291
28324
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
28292
28325
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
28293
28326
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -28486,7 +28519,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
28486
28519
|
};
|
|
28487
28520
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
28488
28521
|
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)");
|
|
28489
|
-
const irCell = _optionalChain([table2, 'access',
|
|
28522
|
+
const irCell = _optionalChain([table2, 'access', _482 => _482.cells, 'access', _483 => _483[gridR], 'optionalAccess', _484 => _484[gridC]]);
|
|
28490
28523
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
28491
28524
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
28492
28525
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -28893,11 +28926,11 @@ var RULES2 = {
|
|
|
28893
28926
|
}
|
|
28894
28927
|
};
|
|
28895
28928
|
function redactText(text, options) {
|
|
28896
|
-
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28929
|
+
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _485 => _485.maskChar]), () => ( "\u25CF"));
|
|
28897
28930
|
if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
|
|
28898
28931
|
throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
|
|
28899
28932
|
}
|
|
28900
|
-
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28933
|
+
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _486 => _486.rules]), () => ( DEFAULT_REDACT_RULES));
|
|
28901
28934
|
const hits = [];
|
|
28902
28935
|
if (text === "" || enabled.length === 0) return { text, hits };
|
|
28903
28936
|
const occupied = [];
|
|
@@ -28952,8 +28985,8 @@ function sameBreadcrumb(a, b) {
|
|
|
28952
28985
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
28953
28986
|
}
|
|
28954
28987
|
function blocksToChunks(blocks, options) {
|
|
28955
|
-
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28956
|
-
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28988
|
+
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _487 => _487.granularity]), () => ( "section"));
|
|
28989
|
+
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _488 => _488.includeTableCells]), () => ( false));
|
|
28957
28990
|
const chunks = [];
|
|
28958
28991
|
const headingStack = [];
|
|
28959
28992
|
const listStack = [];
|
|
@@ -28967,12 +29000,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28967
29000
|
let run = null;
|
|
28968
29001
|
const flushRun = () => {
|
|
28969
29002
|
if (!run) return;
|
|
28970
|
-
push("text", run.breadcrumb,
|
|
29003
|
+
push("text", run.breadcrumb, _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28971
29004
|
run = null;
|
|
28972
29005
|
};
|
|
28973
29006
|
for (let i = 0; i < blocks.length; i++) {
|
|
28974
29007
|
const block = blocks[i];
|
|
28975
|
-
const md2 =
|
|
29008
|
+
const md2 = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28976
29009
|
if (!md2) continue;
|
|
28977
29010
|
if (block.type === "heading") {
|
|
28978
29011
|
flushRun();
|
|
@@ -29088,7 +29121,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29088
29121
|
const block = st.blocks[blockIndex];
|
|
29089
29122
|
if (!block) return void 0;
|
|
29090
29123
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
29091
|
-
const para2 = _optionalChain([st, 'access',
|
|
29124
|
+
const para2 = _optionalChain([st, 'access', _489 => _489.paraMap, 'access', _490 => _490.get, 'call', _491 => _491(blockIndex), 'optionalAccess', _492 => _492.para]);
|
|
29092
29125
|
if (!para2) return void 0;
|
|
29093
29126
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
29094
29127
|
}
|
|
@@ -29113,7 +29146,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29113
29146
|
if (block.text && block.text.includes("\n")) {
|
|
29114
29147
|
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)" };
|
|
29115
29148
|
}
|
|
29116
|
-
if (!_optionalChain([st, 'access',
|
|
29149
|
+
if (!_optionalChain([st, 'access', _493 => _493.paraMap, 'access', _494 => _494.get, 'call', _495 => _495(blockIndex), 'optionalAccess', _496 => _496.para])) {
|
|
29117
29150
|
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)" };
|
|
29118
29151
|
}
|
|
29119
29152
|
return { capability: "text" };
|
|
@@ -29179,7 +29212,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29179
29212
|
continue;
|
|
29180
29213
|
}
|
|
29181
29214
|
if (block.type === "table" && block.table) {
|
|
29182
|
-
if (!_optionalChain([edit, 'access',
|
|
29215
|
+
if (!_optionalChain([edit, 'access', _497 => _497.cells, 'optionalAccess', _498 => _498.length])) {
|
|
29183
29216
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
29184
29217
|
continue;
|
|
29185
29218
|
}
|
|
@@ -29199,7 +29232,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29199
29232
|
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) });
|
|
29200
29233
|
continue;
|
|
29201
29234
|
}
|
|
29202
|
-
const irCell = _optionalChain([block, 'access',
|
|
29235
|
+
const irCell = _optionalChain([block, 'access', _499 => _499.table, 'access', _500 => _500.cells, 'access', _501 => _501[cellEdit.row], 'optionalAccess', _502 => _502[cellEdit.col]]);
|
|
29203
29236
|
if (!irCell) {
|
|
29204
29237
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
29205
29238
|
continue;
|
|
@@ -29255,7 +29288,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29255
29288
|
}
|
|
29256
29289
|
if (replacements.size === 0) {
|
|
29257
29290
|
let changes2;
|
|
29258
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29291
|
+
if (_optionalChain([options, 'optionalAccess', _503 => _503.verify]) !== false) {
|
|
29259
29292
|
const units = splitMarkdownUnits(st.markdown);
|
|
29260
29293
|
changes2 = diffUnitLists(units, units);
|
|
29261
29294
|
}
|
|
@@ -29276,7 +29309,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29276
29309
|
}
|
|
29277
29310
|
this.state = newState;
|
|
29278
29311
|
let changes;
|
|
29279
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29312
|
+
if (_optionalChain([options, 'optionalAccess', _504 => _504.verify]) !== false) {
|
|
29280
29313
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
29281
29314
|
}
|
|
29282
29315
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -29296,7 +29329,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29296
29329
|
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)");
|
|
29297
29330
|
}
|
|
29298
29331
|
const mapping = st.paraMap.get(blockIndex);
|
|
29299
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
29332
|
+
if (!_optionalChain([mapping, 'optionalAccess', _505 => _505.para])) {
|
|
29300
29333
|
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)");
|
|
29301
29334
|
}
|
|
29302
29335
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -29316,14 +29349,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29316
29349
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
29317
29350
|
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");
|
|
29318
29351
|
}
|
|
29319
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
29352
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _506 => _506.scans, 'access', _507 => _507[mapping.para.sectionIndex], 'optionalAccess', _508 => _508.xml]));
|
|
29320
29353
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
29321
29354
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
29322
29355
|
return 1;
|
|
29323
29356
|
}
|
|
29324
29357
|
}, _class8);
|
|
29325
29358
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
29326
|
-
const irCell = _optionalChain([table2, 'access',
|
|
29359
|
+
const irCell = _optionalChain([table2, 'access', _509 => _509.cells, 'access', _510 => _510[r], 'optionalAccess', _511 => _511[c]]);
|
|
29327
29360
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
29328
29361
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
29329
29362
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -29407,11 +29440,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
29407
29440
|
breaks: false
|
|
29408
29441
|
});
|
|
29409
29442
|
function renderHtml(markdown, options) {
|
|
29410
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29411
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29443
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _512 => _512.preset]), () => ( "default"));
|
|
29444
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _513 => _513.extraCss]), () => ( "")));
|
|
29412
29445
|
const body = md.render(markdown);
|
|
29413
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
29414
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
29446
|
+
const watermark = _optionalChain([options, 'optionalAccess', _514 => _514.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
29447
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _515 => _515.watermark]) ? `
|
|
29415
29448
|
.watermark {
|
|
29416
29449
|
position: fixed;
|
|
29417
29450
|
top: 50%; left: 50%;
|
|
@@ -29442,13 +29475,13 @@ async function htmlToPdf(html, options) {
|
|
|
29442
29475
|
try {
|
|
29443
29476
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29444
29477
|
} catch (e32) {
|
|
29445
|
-
throw new (0,
|
|
29478
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
29446
29479
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29447
29480
|
);
|
|
29448
29481
|
}
|
|
29449
29482
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29450
29483
|
if (!executablePath) {
|
|
29451
|
-
throw new (0,
|
|
29484
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)(
|
|
29452
29485
|
"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."
|
|
29453
29486
|
);
|
|
29454
29487
|
}
|
|
@@ -29460,10 +29493,10 @@ async function htmlToPdf(html, options) {
|
|
|
29460
29493
|
try {
|
|
29461
29494
|
const page = await browser.newPage();
|
|
29462
29495
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
29463
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
29496
|
+
const margin = _optionalChain([options, 'optionalAccess', _516 => _516.margin]);
|
|
29464
29497
|
const pdf = await page.pdf({
|
|
29465
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29466
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
29498
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _517 => _517.pageSize]), () => ( "A4")),
|
|
29499
|
+
landscape: _optionalChain([options, 'optionalAccess', _518 => _518.orientation]) === "landscape",
|
|
29467
29500
|
printBackground: true,
|
|
29468
29501
|
margin: margin ? {
|
|
29469
29502
|
top: toCss(margin.top),
|
|
@@ -29471,9 +29504,9 @@ async function htmlToPdf(html, options) {
|
|
|
29471
29504
|
bottom: toCss(margin.bottom),
|
|
29472
29505
|
left: toCss(margin.left)
|
|
29473
29506
|
} : void 0,
|
|
29474
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
29475
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29476
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29507
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _519 => _519.header]) || _optionalChain([options, 'optionalAccess', _520 => _520.footer])),
|
|
29508
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _521 => _521.header]), () => ( "<div></div>")),
|
|
29509
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _522 => _522.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
29477
29510
|
});
|
|
29478
29511
|
return Buffer.from(pdf);
|
|
29479
29512
|
} finally {
|
|
@@ -29507,7 +29540,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29507
29540
|
return htmlToPdf(html, options);
|
|
29508
29541
|
}
|
|
29509
29542
|
async function blocksToPdf(blocks, options) {
|
|
29510
|
-
const markdown =
|
|
29543
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29511
29544
|
return markdownToPdf(markdown, options);
|
|
29512
29545
|
}
|
|
29513
29546
|
|
|
@@ -29686,7 +29719,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
29686
29719
|
}
|
|
29687
29720
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
29688
29721
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
29689
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
29722
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _523 => _523.getAttribute, 'call', _524 => _524("vertRelTo")]), () => ( "PARA"));
|
|
29690
29723
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
29691
29724
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
29692
29725
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -29747,7 +29780,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29747
29780
|
if (ln(p) !== "p") continue;
|
|
29748
29781
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
29749
29782
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
29750
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29783
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _525 => _525.spaceBefore]), () => ( 0)));
|
|
29751
29784
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
29752
29785
|
if (!res) {
|
|
29753
29786
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -29760,7 +29793,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29760
29793
|
}
|
|
29761
29794
|
if (Number.isFinite(bottom)) {
|
|
29762
29795
|
cursorV = bottom;
|
|
29763
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29796
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _526 => _526.spaceAfter]), () => ( 0));
|
|
29764
29797
|
}
|
|
29765
29798
|
}
|
|
29766
29799
|
continue;
|
|
@@ -29870,7 +29903,7 @@ function buildPara(p) {
|
|
|
29870
29903
|
el: ch,
|
|
29871
29904
|
tag: cn,
|
|
29872
29905
|
index: chars.length,
|
|
29873
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
29906
|
+
inline: _optionalChain([pos, 'optionalAccess', _527 => _527.getAttribute, 'call', _528 => _528("treatAsChar")]) === "1",
|
|
29874
29907
|
width: w,
|
|
29875
29908
|
height: h
|
|
29876
29909
|
});
|
|
@@ -30122,15 +30155,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30122
30155
|
const sx = ow > 0 ? w / ow : 1;
|
|
30123
30156
|
const sy = oh > 0 ? h / oh : 1;
|
|
30124
30157
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
30125
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
30126
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
30158
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _529 => _529.getAttribute, 'call', _530 => _530("style")]), () => ( "SOLID"));
|
|
30159
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _531 => _531.getAttribute, 'call', _532 => _532("color")]) || "#000000";
|
|
30127
30160
|
const hasStroke = lstyle !== "NONE";
|
|
30128
30161
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
30129
30162
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
30130
30163
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
30131
30164
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
30132
30165
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
30133
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
30166
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _533 => _533.getAttribute, 'call', _534 => _534("faceColor")]);
|
|
30134
30167
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
30135
30168
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
30136
30169
|
if (o.tag === "rect") {
|
|
@@ -30157,14 +30190,14 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30157
30190
|
}
|
|
30158
30191
|
function cellContentExtent(cell2, memo) {
|
|
30159
30192
|
if (!cell2.sub) return 0;
|
|
30160
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30193
|
+
const hit = _optionalChain([memo, 'optionalAccess', _535 => _535.cell, 'access', _536 => _536.get, 'call', _537 => _537(cell2.el)]);
|
|
30161
30194
|
if (hit !== void 0) return hit;
|
|
30162
30195
|
let ext = 0;
|
|
30163
30196
|
for (const p of elements2(cell2.sub)) {
|
|
30164
30197
|
if (ln2(p) !== "p") continue;
|
|
30165
30198
|
const m = buildPara(p);
|
|
30166
30199
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
30167
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
30200
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _538 => _538.segs, 'access', _539 => _539[0], 'optionalAccess', _540 => _540.vertpos]), () => ( 0));
|
|
30168
30201
|
for (const o of m.objs) {
|
|
30169
30202
|
if (o.inline) {
|
|
30170
30203
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
@@ -30172,14 +30205,14 @@ function cellContentExtent(cell2, memo) {
|
|
|
30172
30205
|
continue;
|
|
30173
30206
|
}
|
|
30174
30207
|
const pos = findChildByLocalName(o.el, "pos");
|
|
30175
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30208
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _541 => _541.getAttribute, 'call', _542 => _542("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
30176
30209
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
30177
30210
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
30178
30211
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
30179
30212
|
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
30180
30213
|
}
|
|
30181
30214
|
}
|
|
30182
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30215
|
+
_optionalChain([memo, 'optionalAccess', _543 => _543.cell, 'access', _544 => _544.set, 'call', _545 => _545(cell2.el, ext)]);
|
|
30183
30216
|
return ext;
|
|
30184
30217
|
}
|
|
30185
30218
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
@@ -30221,7 +30254,7 @@ function collectCells(tbl2) {
|
|
|
30221
30254
|
return cells;
|
|
30222
30255
|
}
|
|
30223
30256
|
function measureTableHeight(tbl2, memo) {
|
|
30224
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30257
|
+
const hit = _optionalChain([memo, 'optionalAccess', _546 => _546.table, 'access', _547 => _547.get, 'call', _548 => _548(tbl2)]);
|
|
30225
30258
|
if (hit !== void 0) return hit;
|
|
30226
30259
|
const cells = collectCells(tbl2);
|
|
30227
30260
|
if (cells.length === 0 || cells.length > 4096) return 0;
|
|
@@ -30232,7 +30265,7 @@ function measureTableHeight(tbl2, memo) {
|
|
|
30232
30265
|
);
|
|
30233
30266
|
let sum = 0;
|
|
30234
30267
|
for (const h of rowH) sum += h;
|
|
30235
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30268
|
+
_optionalChain([memo, 'optionalAccess', _549 => _549.table, 'access', _550 => _550.set, 'call', _551 => _551(tbl2, sum)]);
|
|
30236
30269
|
return sum;
|
|
30237
30270
|
}
|
|
30238
30271
|
function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
@@ -30263,7 +30296,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
30263
30296
|
}));
|
|
30264
30297
|
for (const g of geom) {
|
|
30265
30298
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
30266
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
30299
|
+
if (_optionalChain([bf, 'optionalAccess', _552 => _552.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
30267
30300
|
}
|
|
30268
30301
|
for (const g of geom) {
|
|
30269
30302
|
const { c } = g;
|
|
@@ -30301,7 +30334,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
30301
30334
|
const sz = findChildByLocalName(pic, "sz");
|
|
30302
30335
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
30303
30336
|
const img = findFirst(pic, "img");
|
|
30304
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
30337
|
+
const ref = _optionalChain([img, 'optionalAccess', _553 => _553.getAttribute, 'call', _554 => _554("binaryItemIDRef")]);
|
|
30305
30338
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
30306
30339
|
if (!loaded) {
|
|
30307
30340
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -30341,7 +30374,7 @@ function readSectionGeom(root) {
|
|
|
30341
30374
|
const pagePr = findFirst(root, "pagePr");
|
|
30342
30375
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
30343
30376
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
30344
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
30377
|
+
if (_optionalChain([pagePr, 'optionalAccess', _555 => _555.getAttribute, 'call', _556 => _556("landscape")]) === "NARROWLY" && PW < PH) {
|
|
30345
30378
|
const t = PW;
|
|
30346
30379
|
PW = PH;
|
|
30347
30380
|
PH = t;
|
|
@@ -30399,17 +30432,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30399
30432
|
return { pages: ctx.pages, pageH };
|
|
30400
30433
|
}
|
|
30401
30434
|
async function renderHwpxToSvg(input, options) {
|
|
30402
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30435
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _557 => _557.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30403
30436
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30404
|
-
|
|
30437
|
+
_chunkOQNFGKRYcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30405
30438
|
let zip;
|
|
30406
30439
|
try {
|
|
30407
30440
|
zip = await _jszip2.default.loadAsync(input);
|
|
30408
30441
|
} catch (e33) {
|
|
30409
|
-
throw new (0,
|
|
30442
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30410
30443
|
}
|
|
30411
30444
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30412
|
-
if (secFiles.length === 0) throw new (0,
|
|
30445
|
+
if (secFiles.length === 0) throw new (0, _chunkOQNFGKRYcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30413
30446
|
const warnings = [];
|
|
30414
30447
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30415
30448
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30417,7 +30450,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30417
30450
|
const secXmls = [];
|
|
30418
30451
|
for (const f of secFiles) {
|
|
30419
30452
|
const xml = await f.async("string");
|
|
30420
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30453
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30421
30454
|
secXmls.push(xml);
|
|
30422
30455
|
}
|
|
30423
30456
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30441,7 +30474,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30441
30474
|
let href = binmap.get(ref);
|
|
30442
30475
|
if (!href) {
|
|
30443
30476
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
30444
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
30477
|
+
href = _optionalChain([cand, 'optionalAccess', _558 => _558.name]);
|
|
30445
30478
|
}
|
|
30446
30479
|
if (!href) continue;
|
|
30447
30480
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -30462,7 +30495,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30462
30495
|
styles,
|
|
30463
30496
|
images,
|
|
30464
30497
|
defs: [],
|
|
30465
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30498
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _559 => _559.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
30466
30499
|
warnings,
|
|
30467
30500
|
warned: /* @__PURE__ */ new Set(),
|
|
30468
30501
|
stats: { texts: 0, images: 0, tables: 0 },
|
|
@@ -30473,7 +30506,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30473
30506
|
for (let si = 0; si < secXmls.length; si++) {
|
|
30474
30507
|
const secXml = secXmls[si];
|
|
30475
30508
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
30476
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
30509
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _560 => _560.reflow])) {
|
|
30477
30510
|
noCacheSkipped = true;
|
|
30478
30511
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
30479
30512
|
continue;
|
|
@@ -30485,14 +30518,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30485
30518
|
continue;
|
|
30486
30519
|
}
|
|
30487
30520
|
const geom = readSectionGeom(root);
|
|
30488
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess',
|
|
30521
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _561 => _561.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _562 => _562.reflowMode]), () => ( "keep")));
|
|
30489
30522
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
30490
30523
|
}
|
|
30491
30524
|
if (rendered.length === 0) {
|
|
30492
30525
|
if (noCacheSkipped) {
|
|
30493
|
-
throw new (0,
|
|
30526
|
+
throw new (0, _chunkOQNFGKRYcjs.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)");
|
|
30494
30527
|
}
|
|
30495
|
-
throw new (0,
|
|
30528
|
+
throw new (0, _chunkOQNFGKRYcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30496
30529
|
}
|
|
30497
30530
|
const GAP = 2400;
|
|
30498
30531
|
const clipDefs = [];
|
|
@@ -30524,17 +30557,17 @@ ${groups.join("\n")}
|
|
|
30524
30557
|
// src/index.ts
|
|
30525
30558
|
async function parse(input, options) {
|
|
30526
30559
|
let buffer;
|
|
30527
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
30560
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _563 => _563.filePath]) ? { ...options, filePath: input } : options;
|
|
30528
30561
|
if (typeof input === "string") {
|
|
30529
30562
|
try {
|
|
30530
30563
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30531
|
-
buffer =
|
|
30564
|
+
buffer = _chunkOQNFGKRYcjs.toArrayBuffer.call(void 0, buf);
|
|
30532
30565
|
} catch (err) {
|
|
30533
30566
|
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}`;
|
|
30534
30567
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30535
30568
|
}
|
|
30536
30569
|
} else if (Buffer.isBuffer(input)) {
|
|
30537
|
-
buffer =
|
|
30570
|
+
buffer = _chunkOQNFGKRYcjs.toArrayBuffer.call(void 0, input);
|
|
30538
30571
|
} else {
|
|
30539
30572
|
buffer = input;
|
|
30540
30573
|
}
|
|
@@ -30568,18 +30601,18 @@ async function parse(input, options) {
|
|
|
30568
30601
|
}
|
|
30569
30602
|
async function parseImage(buffer, options) {
|
|
30570
30603
|
try {
|
|
30571
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
30604
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-GHQ6YKJH.cjs")));
|
|
30572
30605
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30573
30606
|
return {
|
|
30574
30607
|
success: true,
|
|
30575
30608
|
fileType: "image",
|
|
30576
|
-
markdown:
|
|
30609
|
+
markdown: _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30577
30610
|
blocks,
|
|
30578
30611
|
warnings: warnings.length ? warnings : void 0,
|
|
30579
30612
|
pageCount: 1
|
|
30580
30613
|
};
|
|
30581
30614
|
} catch (err) {
|
|
30582
|
-
return { success: false, fileType: "image", error:
|
|
30615
|
+
return { success: false, fileType: "image", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30583
30616
|
}
|
|
30584
30617
|
}
|
|
30585
30618
|
async function parseHwp3(buffer, options) {
|
|
@@ -30587,21 +30620,21 @@ async function parseHwp3(buffer, options) {
|
|
|
30587
30620
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30588
30621
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30589
30622
|
} catch (err) {
|
|
30590
|
-
return { success: false, fileType: "hwp3", error:
|
|
30623
|
+
return { success: false, fileType: "hwp3", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30591
30624
|
}
|
|
30592
30625
|
}
|
|
30593
30626
|
async function parseHwpx(buffer, options) {
|
|
30594
30627
|
try {
|
|
30595
30628
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30596
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30629
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _564 => _564.length]) ? images : void 0 };
|
|
30597
30630
|
} catch (err) {
|
|
30598
|
-
return { success: false, fileType: "hwpx", error:
|
|
30631
|
+
return { success: false, fileType: "hwpx", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30599
30632
|
}
|
|
30600
30633
|
}
|
|
30601
30634
|
async function parseHwp(buffer, options) {
|
|
30602
30635
|
try {
|
|
30603
30636
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
30604
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
30637
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _565 => _565.filePath])) {
|
|
30605
30638
|
try {
|
|
30606
30639
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
30607
30640
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -30618,15 +30651,15 @@ async function parseHwp(buffer, options) {
|
|
|
30618
30651
|
} catch (e34) {
|
|
30619
30652
|
}
|
|
30620
30653
|
}
|
|
30621
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30654
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _566 => _566.length]) ? images : void 0 };
|
|
30622
30655
|
} catch (err) {
|
|
30623
|
-
return { success: false, fileType: "hwp", error:
|
|
30656
|
+
return { success: false, fileType: "hwp", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30624
30657
|
}
|
|
30625
30658
|
}
|
|
30626
30659
|
async function parsePdf(buffer, options) {
|
|
30627
30660
|
let parsePdfDocument;
|
|
30628
30661
|
try {
|
|
30629
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30662
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-KTNIUF2N.cjs")));
|
|
30630
30663
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30631
30664
|
} catch (e35) {
|
|
30632
30665
|
return {
|
|
@@ -30641,7 +30674,7 @@ async function parsePdf(buffer, options) {
|
|
|
30641
30674
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30642
30675
|
} catch (err) {
|
|
30643
30676
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30644
|
-
return { success: false, fileType: "pdf", error:
|
|
30677
|
+
return { success: false, fileType: "pdf", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err), isImageBased };
|
|
30645
30678
|
}
|
|
30646
30679
|
}
|
|
30647
30680
|
async function parseXlsx(buffer, options) {
|
|
@@ -30649,7 +30682,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30649
30682
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30650
30683
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30651
30684
|
} catch (err) {
|
|
30652
|
-
return { success: false, fileType: "xlsx", error:
|
|
30685
|
+
return { success: false, fileType: "xlsx", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30653
30686
|
}
|
|
30654
30687
|
}
|
|
30655
30688
|
async function parseXls(buffer, options) {
|
|
@@ -30657,15 +30690,15 @@ async function parseXls(buffer, options) {
|
|
|
30657
30690
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30658
30691
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30659
30692
|
} catch (err) {
|
|
30660
|
-
return { success: false, fileType: "xls", error:
|
|
30693
|
+
return { success: false, fileType: "xls", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30661
30694
|
}
|
|
30662
30695
|
}
|
|
30663
30696
|
async function parseDocx(buffer, options) {
|
|
30664
30697
|
try {
|
|
30665
30698
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30666
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30699
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _567 => _567.length]) ? images : void 0 };
|
|
30667
30700
|
} catch (err) {
|
|
30668
|
-
return { success: false, fileType: "docx", error:
|
|
30701
|
+
return { success: false, fileType: "docx", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30669
30702
|
}
|
|
30670
30703
|
}
|
|
30671
30704
|
async function parseHwpml(buffer, options) {
|
|
@@ -30673,16 +30706,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30673
30706
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30674
30707
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30675
30708
|
} catch (err) {
|
|
30676
|
-
return { success: false, fileType: "hwpml", error:
|
|
30709
|
+
return { success: false, fileType: "hwpml", error: _chunkOQNFGKRYcjs.sanitizeError.call(void 0, err), code: _chunkOQNFGKRYcjs.classifyError.call(void 0, err) };
|
|
30677
30710
|
}
|
|
30678
30711
|
}
|
|
30679
30712
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30680
30713
|
let buffer;
|
|
30681
30714
|
if (typeof input === "string") {
|
|
30682
30715
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30683
|
-
buffer =
|
|
30716
|
+
buffer = _chunkOQNFGKRYcjs.toArrayBuffer.call(void 0, buf);
|
|
30684
30717
|
} else if (Buffer.isBuffer(input)) {
|
|
30685
|
-
buffer =
|
|
30718
|
+
buffer = _chunkOQNFGKRYcjs.toArrayBuffer.call(void 0, input);
|
|
30686
30719
|
} else {
|
|
30687
30720
|
buffer = input;
|
|
30688
30721
|
}
|
|
@@ -30708,7 +30741,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30708
30741
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30709
30742
|
}
|
|
30710
30743
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30711
|
-
const markdown =
|
|
30744
|
+
const markdown = _chunk2BTKLDNXcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30712
30745
|
if (outputFormat === "hwpx") {
|
|
30713
30746
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30714
30747
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30782,5 +30815,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30782
30815
|
|
|
30783
30816
|
|
|
30784
30817
|
|
|
30785
|
-
exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
30818
|
+
exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkOQNFGKRYcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunk2BTKLDNXcjs.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.incompatibleGongmunWarnings = incompatibleGongmunWarnings; 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.parseImage = parseImage; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
30786
30819
|
//# sourceMappingURL=index.cjs.map
|