kordoc 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -8
- package/dist/{-SXQIZHYA.js → -NFHVGTVM.js} +12 -10
- package/dist/{chunk-FSXLSHCW.js → chunk-2L7MIKOM.js} +3 -3
- package/dist/chunk-2L7MIKOM.js.map +1 -0
- package/dist/{pdf-ocr-2Z7VZIFI.cjs → chunk-DLFZAU4X.cjs} +129 -8
- package/dist/chunk-DLFZAU4X.cjs.map +1 -0
- package/dist/{chunk-CMN3SYZ3.js → chunk-DSL6EVFJ.js} +6 -4
- package/dist/chunk-DSL6EVFJ.js.map +1 -0
- package/dist/{chunk-LHROM2BO.cjs → chunk-EFF2JPPA.cjs} +15 -10
- package/dist/chunk-EFF2JPPA.cjs.map +1 -0
- package/dist/{chunk-V6U6YS5B.js → chunk-FHYLLKIP.js} +3 -3
- package/dist/chunk-FHYLLKIP.js.map +1 -0
- package/dist/{chunk-6SHO3BNV.js → chunk-GHMVNMUN.js} +3 -3
- package/dist/{chunk-JP5YH3Z4.js → chunk-GUYIXVV7.js} +3 -3
- package/dist/chunk-GUYIXVV7.js.map +1 -0
- package/dist/{chunk-WF2E5P2G.js → chunk-IXHBRMDB.js} +6 -4
- package/dist/chunk-IXHBRMDB.js.map +1 -0
- package/dist/{chunk-F2HYH62H.cjs → chunk-KKZATKQW.cjs} +3 -3
- package/dist/chunk-KKZATKQW.cjs.map +1 -0
- package/dist/{chunk-ELOV2GIJ.js → chunk-L5B7PQOP.js} +2 -2
- package/dist/{chunk-WQLHPOMJ.js → chunk-LUJN3VFB.js} +3 -3
- package/dist/{pdf-ocr-FJFXFADQ.js → chunk-MOOVF6CT.js} +129 -7
- package/dist/chunk-MOOVF6CT.js.map +1 -0
- package/dist/{chunk-PLIY23LY.js → chunk-MYD3QLBL.js} +2 -2
- package/dist/{chunk-26AJJCFF.js → chunk-OLDIDBJ2.js} +9 -4
- package/dist/{chunk-26AJJCFF.js.map → chunk-OLDIDBJ2.js.map} +1 -1
- package/dist/{pdf-ocr-VYE4DHD4.js → chunk-T4AWY45Q.js} +128 -9
- package/dist/chunk-T4AWY45Q.js.map +1 -0
- package/dist/{chunk-YOO6ET6M.js → chunk-TCJRGFYY.js} +11 -1
- package/dist/chunk-TCJRGFYY.js.map +1 -0
- package/dist/{chunk-IGGRLWT5.js → chunk-TXYQJXOV.js} +67 -14
- package/dist/chunk-TXYQJXOV.js.map +1 -0
- package/dist/{chunk-XTCT6KQ5.cjs → chunk-WMU2KJHF.cjs} +8 -6
- package/dist/chunk-WMU2KJHF.cjs.map +1 -0
- package/dist/{chunk-4JPPLIIV.js → chunk-X77U36TV.js} +8 -3
- package/dist/{chunk-4JPPLIIV.js.map → chunk-X77U36TV.js.map} +1 -1
- package/dist/{chunk-4VNLZ2GZ.js → chunk-ZF7QL4IY.js} +1 -1
- package/dist/chunk-ZF7QL4IY.js.map +1 -0
- package/dist/chunks-N4CWHTJI.js +10 -0
- package/dist/cli.js +19 -19
- package/dist/cli.js.map +1 -1
- package/dist/{detect-YEZX2XCF.js → detect-FX2ZHKZP.js} +4 -2
- package/dist/image-ocr-3AFBDDJI.cjs +66 -0
- package/dist/image-ocr-3AFBDDJI.cjs.map +1 -0
- package/dist/image-ocr-S4REURLR.js +69 -0
- package/dist/image-ocr-S4REURLR.js.map +1 -0
- package/dist/image-ocr-TGHAMIQL.js +65 -0
- package/dist/image-ocr-TGHAMIQL.js.map +1 -0
- package/dist/index.cjs +471 -409
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +71 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +19 -19
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-RBZHA6SY.js → parser-C3APVZGT.js} +6 -6
- package/dist/{parser-ND2YGQZR.js → parser-KMC4YOZH.js} +5 -5
- package/dist/{parser-WDZOMDG4.cjs → parser-MRM6WICO.cjs} +24 -24
- package/dist/{parser-WDZOMDG4.cjs.map → parser-MRM6WICO.cjs.map} +1 -1
- package/dist/pdf-ocr-5BRMIJAT.cjs +13 -0
- package/dist/pdf-ocr-5BRMIJAT.cjs.map +1 -0
- package/dist/pdf-ocr-UDTEQEWA.js +12 -0
- package/dist/pdf-ocr-UURMV6FD.js +15 -0
- package/dist/{profile-io-TWHDIVPL.js → profile-io-RLQ62KS5.js} +3 -3
- package/dist/{rasterize-W2NEZUSW.js → rasterize-LBABF2WI.js} +2 -2
- package/dist/render-CYXQEHS7.js +10 -0
- package/dist/render-CYXQEHS7.js.map +1 -0
- package/dist/seal-SV6PFFYU.js +10 -0
- package/dist/seal-SV6PFFYU.js.map +1 -0
- package/dist/{watch-VWXJZT2R.js → watch-XEUEGOXW.js} +10 -10
- package/package.json +1 -1
- package/dist/chunk-4VNLZ2GZ.js.map +0 -1
- package/dist/chunk-CMN3SYZ3.js.map +0 -1
- package/dist/chunk-F2HYH62H.cjs.map +0 -1
- package/dist/chunk-FSXLSHCW.js.map +0 -1
- package/dist/chunk-IGGRLWT5.js.map +0 -1
- package/dist/chunk-JP5YH3Z4.js.map +0 -1
- package/dist/chunk-LHROM2BO.cjs.map +0 -1
- package/dist/chunk-V6U6YS5B.js.map +0 -1
- package/dist/chunk-WF2E5P2G.js.map +0 -1
- package/dist/chunk-XTCT6KQ5.cjs.map +0 -1
- package/dist/chunk-YOO6ET6M.js.map +0 -1
- package/dist/chunks-ZQEFAZNC.js +0 -10
- package/dist/pdf-ocr-2Z7VZIFI.cjs.map +0 -1
- package/dist/pdf-ocr-FJFXFADQ.js.map +0 -1
- package/dist/pdf-ocr-VYE4DHD4.js.map +0 -1
- package/dist/render-4MG5QUDG.js +0 -10
- package/dist/seal-D2QNXJVO.js +0 -10
- /package/dist/{-SXQIZHYA.js.map → -NFHVGTVM.js.map} +0 -0
- /package/dist/{chunk-6SHO3BNV.js.map → chunk-GHMVNMUN.js.map} +0 -0
- /package/dist/{chunk-ELOV2GIJ.js.map → chunk-L5B7PQOP.js.map} +0 -0
- /package/dist/{chunk-WQLHPOMJ.js.map → chunk-LUJN3VFB.js.map} +0 -0
- /package/dist/{chunk-PLIY23LY.js.map → chunk-MYD3QLBL.js.map} +0 -0
- /package/dist/{chunks-ZQEFAZNC.js.map → chunks-N4CWHTJI.js.map} +0 -0
- /package/dist/{detect-YEZX2XCF.js.map → detect-FX2ZHKZP.js.map} +0 -0
- /package/dist/{parser-RBZHA6SY.js.map → parser-C3APVZGT.js.map} +0 -0
- /package/dist/{parser-ND2YGQZR.js.map → parser-KMC4YOZH.js.map} +0 -0
- /package/dist/{profile-io-TWHDIVPL.js.map → pdf-ocr-UDTEQEWA.js.map} +0 -0
- /package/dist/{render-4MG5QUDG.js.map → pdf-ocr-UURMV6FD.js.map} +0 -0
- /package/dist/{seal-D2QNXJVO.js.map → profile-io-RLQ62KS5.js.map} +0 -0
- /package/dist/{rasterize-W2NEZUSW.js.map → rasterize-LBABF2WI.js.map} +0 -0
- /package/dist/{watch-VWXJZT2R.js.map → watch-XEUEGOXW.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkWMU2KJHFcjs = require('./chunk-WMU2KJHF.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 _chunkKKZATKQWcjs = require('./chunk-KKZATKQW.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -250,6 +250,14 @@ function isPdfFile(buffer) {
|
|
|
250
250
|
const b = magicBytes(buffer);
|
|
251
251
|
return b[0] === 37 && b[1] === 80 && b[2] === 68 && b[3] === 70;
|
|
252
252
|
}
|
|
253
|
+
function isImageFile(buffer) {
|
|
254
|
+
if (buffer.byteLength < 12) return false;
|
|
255
|
+
const b = new Uint8Array(buffer, 0, 12);
|
|
256
|
+
if (b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) return true;
|
|
257
|
+
if (b[0] === 255 && b[1] === 216 && b[2] === 255) return true;
|
|
258
|
+
if (b[0] === 82 && b[1] === 73 && b[2] === 70 && b[3] === 70 && b[8] === 87 && b[9] === 69 && b[10] === 66 && b[11] === 80) return true;
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
253
261
|
function isHwpmlFile(buffer) {
|
|
254
262
|
const bytes = new Uint8Array(buffer, 0, Math.min(512, buffer.byteLength));
|
|
255
263
|
const head = new TextDecoder("utf-8", { fatal: false }).decode(bytes).replace(/^\uFEFF/, "");
|
|
@@ -262,6 +270,7 @@ function detectFormat(buffer) {
|
|
|
262
270
|
if (isOldHwpFile(buffer)) return "hwp";
|
|
263
271
|
if (isPdfFile(buffer)) return "pdf";
|
|
264
272
|
if (isHwpmlFile(buffer)) return "hwpml";
|
|
273
|
+
if (isImageFile(buffer)) return "image";
|
|
265
274
|
return "unknown";
|
|
266
275
|
}
|
|
267
276
|
function detectOle2Format(buffer) {
|
|
@@ -402,9 +411,9 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
402
411
|
|
|
403
412
|
// src/hwpx/parser-shared.ts
|
|
404
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
405
|
-
var MAX_DECOMPRESS_SIZE =
|
|
414
|
+
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
406
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
407
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkKKZATKQWcjs.KordocError {
|
|
408
417
|
constructor(message) {
|
|
409
418
|
super(message);
|
|
410
419
|
this.name = "ZipBombError";
|
|
@@ -420,7 +429,7 @@ function createSectionShared() {
|
|
|
420
429
|
function createXmlParser(warnings) {
|
|
421
430
|
return new (0, _xmldom.DOMParser)({
|
|
422
431
|
onError(level, msg2) {
|
|
423
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkKKZATKQWcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
424
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
425
434
|
}
|
|
426
435
|
});
|
|
@@ -459,6 +468,26 @@ function extractTextFromNode(node, depth = 0) {
|
|
|
459
468
|
}
|
|
460
469
|
|
|
461
470
|
// src/hwpx/styles.ts
|
|
471
|
+
function isRealStrikeShape(shape) {
|
|
472
|
+
switch (shape) {
|
|
473
|
+
case "SOLID":
|
|
474
|
+
case "DASH":
|
|
475
|
+
case "DOT":
|
|
476
|
+
case "DASH_DOT":
|
|
477
|
+
case "DASH_DOT_DOT":
|
|
478
|
+
case "LONG_DASH":
|
|
479
|
+
case "CIRCLE":
|
|
480
|
+
case "DOUBLE_SLIM":
|
|
481
|
+
case "SLIM_THICK":
|
|
482
|
+
case "THICK_SLIM":
|
|
483
|
+
case "SLIM_THICK_SLIM":
|
|
484
|
+
case "WAVE":
|
|
485
|
+
case "DOUBLE_WAVE":
|
|
486
|
+
return true;
|
|
487
|
+
default:
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
462
491
|
async function extractHwpxStyles(zip, decompressed) {
|
|
463
492
|
const result = {
|
|
464
493
|
charProperties: /* @__PURE__ */ new Map(),
|
|
@@ -477,10 +506,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
477
506
|
const xml = await file.async("text");
|
|
478
507
|
if (decompressed) {
|
|
479
508
|
decompressed.total += xml.length * 2;
|
|
480
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
509
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
481
510
|
}
|
|
482
511
|
const parser = createXmlParser();
|
|
483
|
-
const doc = parser.parseFromString(
|
|
512
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
484
513
|
if (!doc.documentElement) continue;
|
|
485
514
|
const domDoc = doc;
|
|
486
515
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -523,6 +552,10 @@ function parseCharProperties(doc, map) {
|
|
|
523
552
|
const localTag = (k.tagName || "").replace(/^[^:]+:/, "");
|
|
524
553
|
if (localTag === "bold") prop.bold = true;
|
|
525
554
|
else if (localTag === "italic") prop.italic = true;
|
|
555
|
+
else if (localTag === "strikeout") {
|
|
556
|
+
const shape = k.getAttribute("shape") || "";
|
|
557
|
+
if (isRealStrikeShape(shape)) prop.strike = true;
|
|
558
|
+
}
|
|
526
559
|
}
|
|
527
560
|
const fontFaces = el.getElementsByTagName("*");
|
|
528
561
|
for (let j = 0; j < fontFaces.length; j++) {
|
|
@@ -663,9 +696,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
663
696
|
let level = 0;
|
|
664
697
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
665
698
|
const ratio = block.style.fontSize / baseFontSize;
|
|
666
|
-
if (ratio >=
|
|
667
|
-
else if (ratio >=
|
|
668
|
-
else if (ratio >=
|
|
699
|
+
if (ratio >= _chunkKKZATKQWcjs.HEADING_RATIO_H1) level = 1;
|
|
700
|
+
else if (ratio >= _chunkKKZATKQWcjs.HEADING_RATIO_H2) level = 2;
|
|
701
|
+
else if (ratio >= _chunkKKZATKQWcjs.HEADING_RATIO_H3) level = 3;
|
|
669
702
|
}
|
|
670
703
|
const compactText = text.replace(/\s+/g, "");
|
|
671
704
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1590,7 +1623,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1590
1623
|
}
|
|
1591
1624
|
function assertFiniteRange(name, value, min, max) {
|
|
1592
1625
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1593
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1594
1627
|
}
|
|
1595
1628
|
}
|
|
1596
1629
|
function validateGongmunOptions(opts) {
|
|
@@ -1605,10 +1638,10 @@ function validateGongmunOptions(opts) {
|
|
|
1605
1638
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1606
1639
|
}
|
|
1607
1640
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1608
|
-
throw new (0,
|
|
1641
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1609
1642
|
}
|
|
1610
1643
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1611
|
-
throw new (0,
|
|
1644
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1612
1645
|
}
|
|
1613
1646
|
}
|
|
1614
1647
|
if (opts.sizes) {
|
|
@@ -1617,7 +1650,7 @@ function validateGongmunOptions(opts) {
|
|
|
1617
1650
|
}
|
|
1618
1651
|
}
|
|
1619
1652
|
if (opts.approval && opts.approval.length > 6) {
|
|
1620
|
-
throw new (0,
|
|
1653
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("approval must contain at most 6 labels");
|
|
1621
1654
|
}
|
|
1622
1655
|
}
|
|
1623
1656
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1882,7 +1915,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1882
1915
|
|
|
1883
1916
|
// src/hwpx/table-build.ts
|
|
1884
1917
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1885
|
-
const table2 =
|
|
1918
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1886
1919
|
if (state.caption) table2.caption = state.caption;
|
|
1887
1920
|
const anchors = [];
|
|
1888
1921
|
{
|
|
@@ -1952,7 +1985,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1952
1985
|
const cell2 = parentTable.cell;
|
|
1953
1986
|
(cell2.blocks ??= []).push(block);
|
|
1954
1987
|
cell2.hasStructure = true;
|
|
1955
|
-
let flat =
|
|
1988
|
+
let flat = _chunkWMU2KJHFcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1956
1989
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1957
1990
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1958
1991
|
} else {
|
|
@@ -1964,7 +1997,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1964
1997
|
// src/hwpx/section-walker.ts
|
|
1965
1998
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1966
1999
|
const parser = createXmlParser(warnings);
|
|
1967
|
-
const doc = parser.parseFromString(
|
|
2000
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1968
2001
|
if (!doc.documentElement) return [];
|
|
1969
2002
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1970
2003
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2070,8 +2103,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2070
2103
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2071
2104
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2072
2105
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2073
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2074
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2106
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkWMU2KJHFcjs.MAX_COLS);
|
|
2107
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkWMU2KJHFcjs.MAX_ROWS);
|
|
2075
2108
|
}
|
|
2076
2109
|
break;
|
|
2077
2110
|
case "p": {
|
|
@@ -2282,7 +2315,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2282
2315
|
const sink = [];
|
|
2283
2316
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2284
2317
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2285
|
-
let flat =
|
|
2318
|
+
let flat = _chunkWMU2KJHFcjs.convertTableToText.call(void 0, st.rows);
|
|
2286
2319
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2287
2320
|
return flat;
|
|
2288
2321
|
}
|
|
@@ -2415,7 +2448,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2415
2448
|
let url = (ch.textContent || "").trim();
|
|
2416
2449
|
if (!url) continue;
|
|
2417
2450
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2418
|
-
const safe =
|
|
2451
|
+
const safe = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, url);
|
|
2419
2452
|
if (safe) return safe;
|
|
2420
2453
|
}
|
|
2421
2454
|
return void 0;
|
|
@@ -2572,7 +2605,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2572
2605
|
case "hyperlink": {
|
|
2573
2606
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2574
2607
|
if (url) {
|
|
2575
|
-
const safe =
|
|
2608
|
+
const safe = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, url);
|
|
2576
2609
|
if (safe) href = safe;
|
|
2577
2610
|
}
|
|
2578
2611
|
walk(child, depth + 1);
|
|
@@ -2737,21 +2770,22 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2737
2770
|
else {
|
|
2738
2771
|
if (_optionalChain([cp, 'optionalAccess', _61 => _61.bold])) span.bold = true;
|
|
2739
2772
|
if (_optionalChain([cp, 'optionalAccess', _62 => _62.italic])) span.italic = true;
|
|
2773
|
+
if (_optionalChain([cp, 'optionalAccess', _63 => _63.strike])) span.strike = true;
|
|
2740
2774
|
}
|
|
2741
|
-
if (span.bold || span.italic || span.code) styled = true;
|
|
2775
|
+
if (span.bold || span.italic || span.strike || span.code) styled = true;
|
|
2742
2776
|
spans.push(span);
|
|
2743
2777
|
}
|
|
2744
2778
|
if (!styled || spans.length === 0) return null;
|
|
2745
2779
|
const merged = [];
|
|
2746
2780
|
for (const s of spans) {
|
|
2747
2781
|
const last = merged[merged.length - 1];
|
|
2748
|
-
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.code === !!s.code) {
|
|
2782
|
+
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.strike === !!s.strike && !!last.code === !!s.code) {
|
|
2749
2783
|
last.text += s.text;
|
|
2750
2784
|
} else {
|
|
2751
2785
|
merged.push(s);
|
|
2752
2786
|
}
|
|
2753
2787
|
}
|
|
2754
|
-
if (requireMixed && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2788
|
+
if (requireMixed && !merged.some((s) => s.strike) && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2755
2789
|
return merged;
|
|
2756
2790
|
}
|
|
2757
2791
|
function gongmunDepthFromIndent(para2, left, ctx) {
|
|
@@ -2759,12 +2793,12 @@ function gongmunDepthFromIndent(para2, left, ctx) {
|
|
|
2759
2793
|
if (!styleMap) return null;
|
|
2760
2794
|
let unit = 0;
|
|
2761
2795
|
const kids2 = para2.childNodes;
|
|
2762
|
-
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess',
|
|
2796
|
+
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess', _64 => _64.length]), () => ( 0))); i++) {
|
|
2763
2797
|
const child = kids2[i];
|
|
2764
2798
|
if (child.nodeType !== 1) continue;
|
|
2765
2799
|
const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
|
|
2766
2800
|
if (tag !== "run" && tag !== "r") continue;
|
|
2767
|
-
const size = _optionalChain([styleMap, 'access',
|
|
2801
|
+
const size = _optionalChain([styleMap, 'access', _65 => _65.charProperties, 'access', _66 => _66.get, 'call', _67 => _67(_nullishCoalesce(child.getAttribute("charPrIDRef"), () => ( ""))), 'optionalAccess', _68 => _68.fontSize]);
|
|
2768
2802
|
if (size) unit = size * 100;
|
|
2769
2803
|
break;
|
|
2770
2804
|
}
|
|
@@ -2837,7 +2871,7 @@ function decompressStream(data) {
|
|
|
2837
2871
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2838
2872
|
}
|
|
2839
2873
|
function parseFileHeader(data) {
|
|
2840
|
-
if (data.length < 40) throw new (0,
|
|
2874
|
+
if (data.length < 40) throw new (0, _chunkKKZATKQWcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2841
2875
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2842
2876
|
return {
|
|
2843
2877
|
signature: sig,
|
|
@@ -2970,7 +3004,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
2970
3004
|
const resolveAt = (byteOffset, extended) => {
|
|
2971
3005
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2972
3006
|
const idx = extended ? state.ctrlIdx : -1;
|
|
2973
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
3007
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _69 => _69(idx, ctrlId)]);
|
|
2974
3008
|
if (replacement) result += replacement;
|
|
2975
3009
|
if (extended) state.ctrlIdx++;
|
|
2976
3010
|
};
|
|
@@ -3172,7 +3206,7 @@ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
|
|
|
3172
3206
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
3173
3207
|
if (fileIndex) {
|
|
3174
3208
|
for (const entry of fileIndex) {
|
|
3175
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3209
|
+
if (!_optionalChain([entry, 'optionalAccess', _70 => _70.name]) || !entry.content) continue;
|
|
3176
3210
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
3177
3211
|
if (!match) continue;
|
|
3178
3212
|
const idx = parseInt(match[1], 16);
|
|
@@ -3248,7 +3282,7 @@ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
|
|
|
3248
3282
|
} else if (block.type === "table" && block.table) {
|
|
3249
3283
|
for (const row of block.table.cells) {
|
|
3250
3284
|
for (const cell2 of row) {
|
|
3251
|
-
if (_optionalChain([cell2, 'access',
|
|
3285
|
+
if (_optionalChain([cell2, 'access', _71 => _71.blocks, 'optionalAccess', _72 => _72.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
|
|
3252
3286
|
}
|
|
3253
3287
|
}
|
|
3254
3288
|
}
|
|
@@ -3286,13 +3320,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3286
3320
|
}
|
|
3287
3321
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3288
3322
|
for (const path of allCandidates) {
|
|
3289
|
-
if (
|
|
3323
|
+
if (_chunkKKZATKQWcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3290
3324
|
const file = zip.file(path);
|
|
3291
3325
|
if (!file) continue;
|
|
3292
3326
|
try {
|
|
3293
3327
|
const data = await file.async("uint8array");
|
|
3294
3328
|
decompressed.total += data.length;
|
|
3295
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3329
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3296
3330
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3297
3331
|
const mimeType = imageExtToMime(ext);
|
|
3298
3332
|
imageIndex++;
|
|
@@ -3302,10 +3336,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3302
3336
|
usedPaths.add(path);
|
|
3303
3337
|
break;
|
|
3304
3338
|
} catch (err) {
|
|
3305
|
-
if (err instanceof
|
|
3339
|
+
if (err instanceof _chunkKKZATKQWcjs.KordocError) throw err;
|
|
3306
3340
|
}
|
|
3307
3341
|
}
|
|
3308
|
-
if (!img) _optionalChain([warnings, 'optionalAccess',
|
|
3342
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _73 => _73.push, 'call', _74 => _74({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
3309
3343
|
resolved.set(ref, img);
|
|
3310
3344
|
}
|
|
3311
3345
|
if (!img) {
|
|
@@ -3322,11 +3356,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3322
3356
|
if (sweepUnreferenced) {
|
|
3323
3357
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3324
3358
|
for (const file of binEntries) {
|
|
3325
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3359
|
+
if (file.dir || usedPaths.has(file.name) || _chunkKKZATKQWcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3326
3360
|
try {
|
|
3327
3361
|
const data = await file.async("uint8array");
|
|
3328
3362
|
decompressed.total += data.length;
|
|
3329
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3363
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3330
3364
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3331
3365
|
let mimeType = imageExtToMime(ext);
|
|
3332
3366
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3340,8 +3374,8 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3340
3374
|
images.push(img);
|
|
3341
3375
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3342
3376
|
} catch (err) {
|
|
3343
|
-
if (err instanceof
|
|
3344
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
3377
|
+
if (err instanceof _chunkKKZATKQWcjs.KordocError) throw err;
|
|
3378
|
+
_optionalChain([warnings, 'optionalAccess', _75 => _75.push, 'call', _76 => _76({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3345
3379
|
}
|
|
3346
3380
|
}
|
|
3347
3381
|
}
|
|
@@ -3391,7 +3425,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3391
3425
|
}
|
|
3392
3426
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3393
3427
|
const name = new TextDecoder().decode(nameBytes);
|
|
3394
|
-
if (
|
|
3428
|
+
if (_chunkKKZATKQWcjs.isPathTraversal.call(void 0, name)) {
|
|
3395
3429
|
pos = fileStart + compSize;
|
|
3396
3430
|
continue;
|
|
3397
3431
|
}
|
|
@@ -3409,16 +3443,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3409
3443
|
continue;
|
|
3410
3444
|
}
|
|
3411
3445
|
totalDecompressed += content.length * 2;
|
|
3412
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3446
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3413
3447
|
sectionNum++;
|
|
3414
3448
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3415
3449
|
} catch (e16) {
|
|
3416
3450
|
continue;
|
|
3417
3451
|
}
|
|
3418
3452
|
}
|
|
3419
|
-
if (blocks.length === 0) throw new (0,
|
|
3453
|
+
if (blocks.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3420
3454
|
applyPageText(blocks, shared);
|
|
3421
|
-
const markdown =
|
|
3455
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3422
3456
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3423
3457
|
}
|
|
3424
3458
|
async function readKordocLayout(zip) {
|
|
@@ -3427,7 +3461,7 @@ async function readKordocLayout(zip) {
|
|
|
3427
3461
|
try {
|
|
3428
3462
|
const xml = await file.async("text");
|
|
3429
3463
|
if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
|
|
3430
|
-
return _nullishCoalesce(_optionalChain([xml, 'access',
|
|
3464
|
+
return _nullishCoalesce(_optionalChain([xml, 'access', _77 => _77.match, 'call', _78 => _78(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _79 => _79[1]]), () => ( null));
|
|
3431
3465
|
} catch (e17) {
|
|
3432
3466
|
return null;
|
|
3433
3467
|
}
|
|
@@ -3443,18 +3477,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3443
3477
|
if (paths.length > 0) return paths;
|
|
3444
3478
|
}
|
|
3445
3479
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3446
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3480
|
+
return sectionFiles.map((f) => f.name).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
3447
3481
|
}
|
|
3448
3482
|
function parseSectionPathsFromManifest(xml) {
|
|
3449
3483
|
const parser = createXmlParser();
|
|
3450
|
-
const doc = parser.parseFromString(
|
|
3484
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3451
3485
|
const items = doc.getElementsByTagName("opf:item");
|
|
3452
3486
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3453
3487
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3454
3488
|
for (let i = 0; i < items.length; i++) {
|
|
3455
3489
|
const item = items[i];
|
|
3456
3490
|
const id = item.getAttribute("id") || "";
|
|
3457
|
-
const href =
|
|
3491
|
+
const href = _chunkKKZATKQWcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3458
3492
|
if (id && href) idToHref.set(id, href);
|
|
3459
3493
|
}
|
|
3460
3494
|
if (spine.length > 0) {
|
|
@@ -3465,7 +3499,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3465
3499
|
}
|
|
3466
3500
|
if (ordered.length > 0) return ordered;
|
|
3467
3501
|
}
|
|
3468
|
-
return Array.from(idToHref.values()).sort(
|
|
3502
|
+
return Array.from(idToHref.values()).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
3469
3503
|
}
|
|
3470
3504
|
|
|
3471
3505
|
// src/hwpx/metadata.ts
|
|
@@ -3478,7 +3512,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3478
3512
|
const xml = await file.async("text");
|
|
3479
3513
|
if (decompressed) {
|
|
3480
3514
|
decompressed.total += xml.length * 2;
|
|
3481
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3515
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3482
3516
|
}
|
|
3483
3517
|
parseDublinCoreMetadata(xml, metadata);
|
|
3484
3518
|
if (metadata.title || metadata.author) return;
|
|
@@ -3488,13 +3522,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3488
3522
|
}
|
|
3489
3523
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3490
3524
|
const parser = createXmlParser();
|
|
3491
|
-
const doc = parser.parseFromString(
|
|
3525
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3492
3526
|
if (!doc.documentElement) return;
|
|
3493
3527
|
const getText = (tagNames) => {
|
|
3494
3528
|
for (const tag of tagNames) {
|
|
3495
3529
|
const els = doc.getElementsByTagName(tag);
|
|
3496
3530
|
if (els.length > 0) {
|
|
3497
|
-
const text = _optionalChain([els, 'access',
|
|
3531
|
+
const text = _optionalChain([els, 'access', _80 => _80[0], 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]);
|
|
3498
3532
|
if (text) return text;
|
|
3499
3533
|
}
|
|
3500
3534
|
}
|
|
@@ -3513,7 +3547,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3513
3547
|
|
|
3514
3548
|
// src/hwpx/parser.ts
|
|
3515
3549
|
async function parseHwpxDocument(buffer, options) {
|
|
3516
|
-
|
|
3550
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3517
3551
|
let zip;
|
|
3518
3552
|
try {
|
|
3519
3553
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3522,19 +3556,19 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3522
3556
|
}
|
|
3523
3557
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3524
3558
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3525
|
-
throw new (0,
|
|
3559
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3526
3560
|
}
|
|
3527
3561
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3528
3562
|
if (manifestFile) {
|
|
3529
3563
|
const manifestXml = await manifestFile.async("text");
|
|
3530
3564
|
if (isEncryptedHwpx(manifestXml)) {
|
|
3531
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
3565
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _84 => _84.filePath])) {
|
|
3532
3566
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3533
3567
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3534
3568
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3535
3569
|
}
|
|
3536
3570
|
}
|
|
3537
|
-
throw new (0,
|
|
3571
|
+
throw new (0, _chunkKKZATKQWcjs.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.");
|
|
3538
3572
|
}
|
|
3539
3573
|
}
|
|
3540
3574
|
const decompressed = { total: 0 };
|
|
@@ -3543,14 +3577,14 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3543
3577
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3544
3578
|
const warnings = [];
|
|
3545
3579
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3546
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3580
|
+
if (sectionPaths.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3547
3581
|
metadata.pageCount = sectionPaths.length;
|
|
3548
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3582
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _85 => _85.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3549
3583
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3550
3584
|
const blocks = [];
|
|
3551
3585
|
const shared = createSectionShared();
|
|
3552
3586
|
shared.kordocLayout = await readKordocLayout(zip);
|
|
3553
|
-
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
3587
|
+
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _86 => _86.keepTrailingEmptyCols]);
|
|
3554
3588
|
let parsedSections = 0;
|
|
3555
3589
|
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3556
3590
|
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
@@ -3562,7 +3596,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3562
3596
|
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new ZipBombError("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3563
3597
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3564
3598
|
parsedSections++;
|
|
3565
|
-
_optionalChain([options, 'optionalAccess',
|
|
3599
|
+
_optionalChain([options, 'optionalAccess', _87 => _87.onProgress, 'optionalCall', _88 => _88(parsedSections, totalTarget)]);
|
|
3566
3600
|
} catch (secErr) {
|
|
3567
3601
|
if (secErr instanceof ZipBombError) throw secErr;
|
|
3568
3602
|
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" });
|
|
@@ -3572,7 +3606,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3572
3606
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3573
3607
|
detectHwpxHeadings(blocks, styleMap);
|
|
3574
3608
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3575
|
-
const markdown =
|
|
3609
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3576
3610
|
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 };
|
|
3577
3611
|
}
|
|
3578
3612
|
|
|
@@ -4751,22 +4785,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4751
4785
|
lenientCfb = parseLenientCfb(buffer);
|
|
4752
4786
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4753
4787
|
} catch (e22) {
|
|
4754
|
-
throw new (0,
|
|
4788
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4755
4789
|
}
|
|
4756
4790
|
}
|
|
4757
4791
|
const findStream = (path) => {
|
|
4758
4792
|
if (cfb) {
|
|
4759
4793
|
const entry = CFB.find(cfb, path);
|
|
4760
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
4794
|
+
return _optionalChain([entry, 'optionalAccess', _89 => _89.content]) ? Buffer.from(entry.content) : null;
|
|
4761
4795
|
}
|
|
4762
4796
|
return lenientCfb.findStream(path);
|
|
4763
4797
|
};
|
|
4764
4798
|
const headerData = findStream("/FileHeader");
|
|
4765
|
-
if (!headerData) throw new (0,
|
|
4799
|
+
if (!headerData) throw new (0, _chunkKKZATKQWcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4766
4800
|
const header = parseFileHeader(headerData);
|
|
4767
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4768
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4769
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4801
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkKKZATKQWcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4802
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4803
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkKKZATKQWcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4770
4804
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4771
4805
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4772
4806
|
const metadata = {
|
|
@@ -4775,13 +4809,13 @@ function parseHwp5Document(buffer, options) {
|
|
|
4775
4809
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4776
4810
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4777
4811
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4778
|
-
if (sections.length === 0) throw new (0,
|
|
4812
|
+
if (sections.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4779
4813
|
metadata.pageCount = sections.length;
|
|
4780
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4814
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _90 => _90.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4781
4815
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4782
4816
|
const bodyBlocks = [];
|
|
4783
4817
|
const doc = createHwp5DocState();
|
|
4784
|
-
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
4818
|
+
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _91 => _91.keepTrailingEmptyCols]);
|
|
4785
4819
|
let totalDecompressed = 0;
|
|
4786
4820
|
let parsedSections = 0;
|
|
4787
4821
|
for (let si = 0; si < sections.length; si++) {
|
|
@@ -4790,22 +4824,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4790
4824
|
const sectionData = sections[si];
|
|
4791
4825
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4792
4826
|
totalDecompressed += data.length;
|
|
4793
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4827
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4794
4828
|
const records = readRecords(data);
|
|
4795
4829
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4796
4830
|
bodyBlocks.push(...sectionBlocks);
|
|
4797
4831
|
parsedSections++;
|
|
4798
|
-
_optionalChain([options, 'optionalAccess',
|
|
4832
|
+
_optionalChain([options, 'optionalAccess', _92 => _92.onProgress, 'optionalCall', _93 => _93(parsedSections, totalTarget)]);
|
|
4799
4833
|
} catch (secErr) {
|
|
4800
|
-
if (secErr instanceof
|
|
4834
|
+
if (secErr instanceof _chunkKKZATKQWcjs.KordocError) throw secErr;
|
|
4801
4835
|
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" });
|
|
4802
4836
|
}
|
|
4803
4837
|
}
|
|
4804
4838
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4805
4839
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4806
|
-
let flatBlocks =
|
|
4807
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4808
|
-
const deduped =
|
|
4840
|
+
let flatBlocks = _chunkWMU2KJHFcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4841
|
+
if (_optionalChain([options, 'optionalAccess', _94 => _94.dedupeRunningHeaders])) {
|
|
4842
|
+
const deduped = _chunkWMU2KJHFcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4809
4843
|
const removed = flatBlocks.length - deduped.length;
|
|
4810
4844
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4811
4845
|
flatBlocks = deduped;
|
|
@@ -4814,10 +4848,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4814
4848
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4815
4849
|
}
|
|
4816
4850
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4817
|
-
let markdown =
|
|
4818
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4851
|
+
let markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4852
|
+
if (_optionalChain([options, 'optionalAccess', _95 => _95.inlineImages]) && images.length > 0) {
|
|
4819
4853
|
try {
|
|
4820
|
-
markdown =
|
|
4854
|
+
markdown = _chunkWMU2KJHFcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4821
4855
|
} catch (inlineErr) {
|
|
4822
4856
|
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" });
|
|
4823
4857
|
}
|
|
@@ -4827,7 +4861,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4827
4861
|
function parseDocInfoStream(cfb, compressed) {
|
|
4828
4862
|
try {
|
|
4829
4863
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
4830
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4864
|
+
if (!_optionalChain([entry, 'optionalAccess', _96 => _96.content])) return null;
|
|
4831
4865
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
4832
4866
|
const records = readRecords(data);
|
|
4833
4867
|
return parseDocInfo(records);
|
|
@@ -4848,7 +4882,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4848
4882
|
let baseFontSize = 0;
|
|
4849
4883
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
4850
4884
|
for (const b of blocks) {
|
|
4851
|
-
if (_optionalChain([b, 'access',
|
|
4885
|
+
if (_optionalChain([b, 'access', _97 => _97.style, 'optionalAccess', _98 => _98.fontSize]) && b.text) {
|
|
4852
4886
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4853
4887
|
}
|
|
4854
4888
|
}
|
|
@@ -4864,7 +4898,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4864
4898
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4865
4899
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4866
4900
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4867
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4901
|
+
if (_optionalChain([cs, 'optionalAccess', _99 => _99.fontSize]) > 0) {
|
|
4868
4902
|
baseFontSize = cs.fontSize / 10;
|
|
4869
4903
|
break;
|
|
4870
4904
|
}
|
|
@@ -4879,11 +4913,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4879
4913
|
if (text.length === 0 || text.length > 200) continue;
|
|
4880
4914
|
if (/^\d+$/.test(text)) continue;
|
|
4881
4915
|
let level = 0;
|
|
4882
|
-
if (_optionalChain([block, 'access',
|
|
4916
|
+
if (_optionalChain([block, 'access', _100 => _100.style, 'optionalAccess', _101 => _101.fontSize]) && baseFontSize > 0) {
|
|
4883
4917
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4884
|
-
if (ratio >=
|
|
4885
|
-
else if (ratio >=
|
|
4886
|
-
else if (ratio >=
|
|
4918
|
+
if (ratio >= _chunkKKZATKQWcjs.HEADING_RATIO_H1) level = 1;
|
|
4919
|
+
else if (ratio >= _chunkKKZATKQWcjs.HEADING_RATIO_H2) level = 2;
|
|
4920
|
+
else if (ratio >= _chunkKKZATKQWcjs.HEADING_RATIO_H3) level = 3;
|
|
4887
4921
|
}
|
|
4888
4922
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4889
4923
|
if (level === 0) level = 2;
|
|
@@ -4899,7 +4933,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4899
4933
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4900
4934
|
try {
|
|
4901
4935
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4902
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4936
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _102 => _102.content])) return;
|
|
4903
4937
|
const data = Buffer.from(summaryEntry.content);
|
|
4904
4938
|
if (data.length < 48) return;
|
|
4905
4939
|
const numSets = data.readUInt32LE(24);
|
|
@@ -4932,7 +4966,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
4932
4966
|
const sections = [];
|
|
4933
4967
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4934
4968
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
4935
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4969
|
+
if (!_optionalChain([entry, 'optionalAccess', _103 => _103.content])) break;
|
|
4936
4970
|
try {
|
|
4937
4971
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
4938
4972
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -4946,13 +4980,13 @@ function findSections(cfb) {
|
|
|
4946
4980
|
const sections = [];
|
|
4947
4981
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4948
4982
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
4949
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4983
|
+
if (!_optionalChain([entry, 'optionalAccess', _104 => _104.content])) break;
|
|
4950
4984
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
4951
4985
|
}
|
|
4952
4986
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
4953
4987
|
for (const entry of cfb.FileIndex) {
|
|
4954
4988
|
if (sections.length >= MAX_SECTIONS) break;
|
|
4955
|
-
if (_optionalChain([entry, 'access',
|
|
4989
|
+
if (_optionalChain([entry, 'access', _105 => _105.name, 'optionalAccess', _106 => _106.startsWith, 'call', _107 => _107("Section")]) && entry.content) {
|
|
4956
4990
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
4957
4991
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
4958
4992
|
}
|
|
@@ -4968,7 +5002,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4968
5002
|
if (!raw) break;
|
|
4969
5003
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4970
5004
|
totalDecompressed += content.length;
|
|
4971
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5005
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4972
5006
|
sections.push({ idx: i, content });
|
|
4973
5007
|
}
|
|
4974
5008
|
if (sections.length === 0) {
|
|
@@ -4980,7 +5014,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4980
5014
|
if (raw) {
|
|
4981
5015
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4982
5016
|
totalDecompressed += content.length;
|
|
4983
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5017
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4984
5018
|
sections.push({ idx, content });
|
|
4985
5019
|
}
|
|
4986
5020
|
}
|
|
@@ -4997,7 +5031,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4997
5031
|
try {
|
|
4998
5032
|
const content = decryptViewText(raw, compressed);
|
|
4999
5033
|
totalDecompressed += content.length;
|
|
5000
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5034
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5001
5035
|
sections.push({ idx: i, content });
|
|
5002
5036
|
} catch (e27) {
|
|
5003
5037
|
break;
|
|
@@ -5098,9 +5132,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5098
5132
|
const applied = [];
|
|
5099
5133
|
for (const r of ranges) {
|
|
5100
5134
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5101
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
5135
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _108 => _108.href]) || r.end <= r.start) continue;
|
|
5102
5136
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5103
|
-
const href =
|
|
5137
|
+
const href = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5104
5138
|
if (!href) continue;
|
|
5105
5139
|
const anchor = text.slice(r.start, r.end);
|
|
5106
5140
|
if (!anchor.trim()) continue;
|
|
@@ -5118,7 +5152,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5118
5152
|
}
|
|
5119
5153
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
5120
5154
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
5121
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
5155
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _109 => _109.docInfo, 'optionalAccess', _110 => _110.numberings, 'access', _111 => _111[nid - 1]]) : void 0;
|
|
5122
5156
|
if (numbering) {
|
|
5123
5157
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
5124
5158
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -5128,7 +5162,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5128
5162
|
}
|
|
5129
5163
|
}
|
|
5130
5164
|
} else if (ps.headType === 3) {
|
|
5131
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
5165
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _112 => _112.docInfo, 'optionalAccess', _113 => _113.bullets, 'access', _114 => _114[ps.numberingId - 1]]) : void 0;
|
|
5132
5166
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
5133
5167
|
}
|
|
5134
5168
|
}
|
|
@@ -5143,7 +5177,10 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5143
5177
|
if (headingLevel > 0) block.level = headingLevel;
|
|
5144
5178
|
if (ctx.docInfo && charShapeIds.length > 0) {
|
|
5145
5179
|
const style = resolveCharStyle(charShapeIds, ctx.docInfo);
|
|
5146
|
-
if (style)
|
|
5180
|
+
if (style) {
|
|
5181
|
+
block.style = style;
|
|
5182
|
+
if (style.strike) block.text = headMarker ? `${headMarker} ~~${trimmed}~~` : `~~${trimmed}~~`;
|
|
5183
|
+
}
|
|
5147
5184
|
}
|
|
5148
5185
|
if (footnotes.length > 0) block.footnoteText = footnotes.join("; ");
|
|
5149
5186
|
blocks.push(block);
|
|
@@ -5333,8 +5370,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5333
5370
|
let tableIdx = -1;
|
|
5334
5371
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5335
5372
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5336
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5337
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5373
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkWMU2KJHFcjs.MAX_ROWS);
|
|
5374
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkWMU2KJHFcjs.MAX_COLS);
|
|
5338
5375
|
tableIdx = i2;
|
|
5339
5376
|
break;
|
|
5340
5377
|
}
|
|
@@ -5374,7 +5411,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5374
5411
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
5375
5412
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
5376
5413
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
5377
|
-
if (_optionalChain([c, 'access',
|
|
5414
|
+
if (_optionalChain([c, 'access', _115 => _115.blocks, 'optionalAccess', _116 => _116.length])) ir.blocks = c.blocks;
|
|
5378
5415
|
if (c.isHeader) ir.isHeader = true;
|
|
5379
5416
|
return ir;
|
|
5380
5417
|
}));
|
|
@@ -5383,7 +5420,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5383
5420
|
return table3;
|
|
5384
5421
|
}
|
|
5385
5422
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5386
|
-
const table2 =
|
|
5423
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5387
5424
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5388
5425
|
return table2.rows > 0 ? table2 : null;
|
|
5389
5426
|
}
|
|
@@ -5400,8 +5437,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5400
5437
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5401
5438
|
const cs = rec.data.readUInt16LE(12);
|
|
5402
5439
|
const rs = rec.data.readUInt16LE(14);
|
|
5403
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5404
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5440
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkWMU2KJHFcjs.MAX_COLS);
|
|
5441
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkWMU2KJHFcjs.MAX_ROWS);
|
|
5405
5442
|
}
|
|
5406
5443
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5407
5444
|
const parts = [];
|
|
@@ -5411,7 +5448,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5411
5448
|
parts.push(``);
|
|
5412
5449
|
hasStructure = true;
|
|
5413
5450
|
} else if (b.type === "table" && b.table) {
|
|
5414
|
-
const flat =
|
|
5451
|
+
const flat = _chunkWMU2KJHFcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5415
5452
|
if (flat) parts.push(flat);
|
|
5416
5453
|
hasStructure = true;
|
|
5417
5454
|
} else if (b.text) {
|
|
@@ -5508,8 +5545,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
5508
5545
|
if (data.length < 73) return null;
|
|
5509
5546
|
const binDataId = data.readUInt16LE(71);
|
|
5510
5547
|
if (binDataId === 0) return null;
|
|
5511
|
-
const item = _optionalChain([ctx, 'access',
|
|
5512
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
5548
|
+
const item = _optionalChain([ctx, 'access', _117 => _117.docInfo, 'optionalAccess', _118 => _118.binData, 'access', _119 => _119[binDataId - 1]]);
|
|
5549
|
+
if (_optionalChain([item, 'optionalAccess', _120 => _120.kind]) === "link") {
|
|
5513
5550
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
5514
5551
|
return null;
|
|
5515
5552
|
}
|
|
@@ -5534,7 +5571,13 @@ function resolveCharStyle(charShapeIds, docInfo) {
|
|
|
5534
5571
|
if (cs.fontSize > 0) style.fontSize = cs.fontSize / 10;
|
|
5535
5572
|
if (cs.attrFlags & 1) style.italic = true;
|
|
5536
5573
|
if (cs.attrFlags & 2) style.bold = true;
|
|
5537
|
-
|
|
5574
|
+
if (hasRealStrike(cs.attrFlags)) style.strike = true;
|
|
5575
|
+
return style.fontSize || style.bold || style.italic || style.strike ? style : void 0;
|
|
5576
|
+
}
|
|
5577
|
+
function hasRealStrike(attrFlags) {
|
|
5578
|
+
const strikeBits = attrFlags >> 18 & 7;
|
|
5579
|
+
const shapeId = attrFlags >> 26 & 15;
|
|
5580
|
+
return strikeBits !== 0 && shapeId <= 12;
|
|
5538
5581
|
}
|
|
5539
5582
|
|
|
5540
5583
|
// src/hwp3/parser.ts
|
|
@@ -17657,7 +17700,7 @@ function parseHwp3Document(buffer, _options) {
|
|
|
17657
17700
|
try {
|
|
17658
17701
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17659
17702
|
} catch (err) {
|
|
17660
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
17703
|
+
if (_optionalChain([err, 'optionalAccess', _121 => _121.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17661
17704
|
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`);
|
|
17662
17705
|
}
|
|
17663
17706
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
@@ -17892,15 +17935,15 @@ function getElements(parent, tagName) {
|
|
|
17892
17935
|
const result = [];
|
|
17893
17936
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
17894
17937
|
if (result.length > 0) return result;
|
|
17895
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
17938
|
+
const nsNodes = _optionalChain([parent, 'access', _122 => _122.getElementsByTagNameNS, 'optionalCall', _123 => _123("*", tagName)]);
|
|
17896
17939
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
17897
17940
|
return result;
|
|
17898
17941
|
}
|
|
17899
17942
|
function getTextContent(el) {
|
|
17900
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
17943
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _124 => _124.textContent, 'optionalAccess', _125 => _125.trim, 'call', _126 => _126()]), () => ( ""));
|
|
17901
17944
|
}
|
|
17902
17945
|
function parseXml(text) {
|
|
17903
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17946
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17904
17947
|
}
|
|
17905
17948
|
function collectRichText(root) {
|
|
17906
17949
|
let out = "";
|
|
@@ -17909,7 +17952,7 @@ function collectRichText(root) {
|
|
|
17909
17952
|
for (let i = 0; i < children.length; i++) {
|
|
17910
17953
|
if (children[i].nodeType !== 1) continue;
|
|
17911
17954
|
const el = children[i];
|
|
17912
|
-
const local = el.localName || _optionalChain([el, 'access',
|
|
17955
|
+
const local = el.localName || _optionalChain([el, 'access', _127 => _127.tagName, 'optionalAccess', _128 => _128.replace, 'call', _129 => _129(/^[^:]+:/, "")]) || "";
|
|
17913
17956
|
if (local === "rPh") continue;
|
|
17914
17957
|
if (local === "t") out += _nullishCoalesce(el.textContent, () => ( ""));
|
|
17915
17958
|
else walk(el);
|
|
@@ -18128,14 +18171,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18128
18171
|
const merge = mergeMap.get(key);
|
|
18129
18172
|
row.push({
|
|
18130
18173
|
text,
|
|
18131
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18132
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18174
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _130 => _130.colSpan]), () => ( 1)),
|
|
18175
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _131 => _131.rowSpan]), () => ( 1))
|
|
18133
18176
|
});
|
|
18134
18177
|
}
|
|
18135
18178
|
cellRows.push(row);
|
|
18136
18179
|
}
|
|
18137
18180
|
if (cellRows.length > 0) {
|
|
18138
|
-
const table2 =
|
|
18181
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18139
18182
|
if (table2.rows > 0) {
|
|
18140
18183
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18141
18184
|
}
|
|
@@ -18143,12 +18186,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18143
18186
|
return blocks;
|
|
18144
18187
|
}
|
|
18145
18188
|
async function parseXlsxDocument(buffer, options) {
|
|
18146
|
-
|
|
18189
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18147
18190
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18148
18191
|
const warnings = [];
|
|
18149
18192
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18150
18193
|
if (!workbookFile) {
|
|
18151
|
-
throw new (0,
|
|
18194
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18152
18195
|
}
|
|
18153
18196
|
let sharedStrings = [];
|
|
18154
18197
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18157,7 +18200,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18157
18200
|
}
|
|
18158
18201
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18159
18202
|
if (sheets.length === 0) {
|
|
18160
|
-
throw new (0,
|
|
18203
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18161
18204
|
}
|
|
18162
18205
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18163
18206
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18173,7 +18216,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18173
18216
|
relsMap = parseRels(await relsFile.async("text"));
|
|
18174
18217
|
}
|
|
18175
18218
|
let pageFilter = null;
|
|
18176
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18219
|
+
if (_optionalChain([options, 'optionalAccess', _132 => _132.pages])) {
|
|
18177
18220
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18178
18221
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18179
18222
|
}
|
|
@@ -18182,7 +18225,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18182
18225
|
for (let i = 0; i < processedSheets; i++) {
|
|
18183
18226
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18184
18227
|
const sheet = sheets[i];
|
|
18185
|
-
_optionalChain([options, 'optionalAccess',
|
|
18228
|
+
_optionalChain([options, 'optionalAccess', _133 => _133.onProgress, 'optionalCall', _134 => _134(i + 1, processedSheets)]);
|
|
18186
18229
|
let sheetPath = relsMap.get(sheet.rId);
|
|
18187
18230
|
if (sheetPath) {
|
|
18188
18231
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -18205,7 +18248,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18205
18248
|
try {
|
|
18206
18249
|
const sheetXml = await sheetFile.async("text");
|
|
18207
18250
|
const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
|
|
18208
|
-
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess',
|
|
18251
|
+
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess', _135 => _135.keepTrailingEmptyCols]));
|
|
18209
18252
|
blocks.push(...sheetBlocks);
|
|
18210
18253
|
} catch (err) {
|
|
18211
18254
|
warnings.push({
|
|
@@ -18237,7 +18280,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18237
18280
|
} catch (e29) {
|
|
18238
18281
|
}
|
|
18239
18282
|
}
|
|
18240
|
-
const markdown =
|
|
18283
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18241
18284
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18242
18285
|
}
|
|
18243
18286
|
|
|
@@ -18688,11 +18731,11 @@ function processGlobals(records) {
|
|
|
18688
18731
|
const xfFmtIds = [];
|
|
18689
18732
|
const firstBof = records[0];
|
|
18690
18733
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18691
|
-
throw new (0,
|
|
18734
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18692
18735
|
}
|
|
18693
18736
|
const bof = decodeBof(firstBof.data);
|
|
18694
18737
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18695
|
-
throw new (0,
|
|
18738
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18696
18739
|
}
|
|
18697
18740
|
let i = 1;
|
|
18698
18741
|
while (i < records.length) {
|
|
@@ -18820,14 +18863,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18820
18863
|
const merge = mergeMap.get(key);
|
|
18821
18864
|
row.push({
|
|
18822
18865
|
text: grid[r][c],
|
|
18823
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18824
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18866
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _136 => _136.colSpan]), () => ( 1)),
|
|
18867
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _137 => _137.rowSpan]), () => ( 1))
|
|
18825
18868
|
});
|
|
18826
18869
|
}
|
|
18827
18870
|
cellRows.push(row);
|
|
18828
18871
|
}
|
|
18829
18872
|
if (cellRows.length > 0) {
|
|
18830
|
-
const table2 =
|
|
18873
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18831
18874
|
if (table2.rows > 0) {
|
|
18832
18875
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18833
18876
|
}
|
|
@@ -18840,21 +18883,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18840
18883
|
try {
|
|
18841
18884
|
cfb = parseLenientCfb(buf);
|
|
18842
18885
|
} catch (e) {
|
|
18843
|
-
throw new (0,
|
|
18886
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
18844
18887
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18845
18888
|
);
|
|
18846
18889
|
}
|
|
18847
18890
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18848
18891
|
if (!wb) {
|
|
18849
|
-
throw new (0,
|
|
18892
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18850
18893
|
}
|
|
18851
18894
|
const records = readRecords2(wb);
|
|
18852
18895
|
if (records.length === 0) {
|
|
18853
|
-
throw new (0,
|
|
18896
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18854
18897
|
}
|
|
18855
18898
|
const firstBof = decodeBof(records[0].data);
|
|
18856
18899
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18857
|
-
throw new (0,
|
|
18900
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
18858
18901
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18859
18902
|
);
|
|
18860
18903
|
}
|
|
@@ -18883,7 +18926,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18883
18926
|
} : void 0;
|
|
18884
18927
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18885
18928
|
let pageFilter = null;
|
|
18886
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18929
|
+
if (_optionalChain([options, 'optionalAccess', _138 => _138.pages])) {
|
|
18887
18930
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18888
18931
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18889
18932
|
}
|
|
@@ -18892,7 +18935,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18892
18935
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18893
18936
|
const meta = globals.sheets[i];
|
|
18894
18937
|
if (meta.dt !== 0) continue;
|
|
18895
|
-
_optionalChain([options, 'optionalAccess',
|
|
18938
|
+
_optionalChain([options, 'optionalAccess', _139 => _139.onProgress, 'optionalCall', _140 => _140(i + 1, totalSheets)]);
|
|
18896
18939
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
18897
18940
|
if (bofIdx < 0) {
|
|
18898
18941
|
warnings.push({
|
|
@@ -18908,7 +18951,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18908
18951
|
}
|
|
18909
18952
|
try {
|
|
18910
18953
|
const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
|
|
18911
|
-
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess',
|
|
18954
|
+
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess', _141 => _141.keepTrailingEmptyCols]));
|
|
18912
18955
|
allBlocks.push(...blocks);
|
|
18913
18956
|
} catch (e) {
|
|
18914
18957
|
warnings.push({
|
|
@@ -18922,7 +18965,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18922
18965
|
pageCount: totalSheets
|
|
18923
18966
|
};
|
|
18924
18967
|
return {
|
|
18925
|
-
markdown:
|
|
18968
|
+
markdown: _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18926
18969
|
blocks: allBlocks,
|
|
18927
18970
|
metadata,
|
|
18928
18971
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18935,7 +18978,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18935
18978
|
|
|
18936
18979
|
// src/docx/equation.ts
|
|
18937
18980
|
function lname(el) {
|
|
18938
|
-
return el.localName || _optionalChain([el, 'access',
|
|
18981
|
+
return el.localName || _optionalChain([el, 'access', _142 => _142.tagName, 'optionalAccess', _143 => _143.replace, 'call', _144 => _144(/^[^:]+:/, "")]) || "";
|
|
18939
18982
|
}
|
|
18940
18983
|
function kids(parent, name) {
|
|
18941
18984
|
const out = [];
|
|
@@ -19324,7 +19367,7 @@ function isDisplayMath(el) {
|
|
|
19324
19367
|
// src/docx/parser.ts
|
|
19325
19368
|
var MAX_DECOMPRESS_SIZE5 = 100 * 1024 * 1024;
|
|
19326
19369
|
function matchesLocal(el, localName2) {
|
|
19327
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
19370
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _145 => _145.tagName, 'optionalAccess', _146 => _146.endsWith, 'call', _147 => _147(`:${localName2}`)]), () => ( false)));
|
|
19328
19371
|
}
|
|
19329
19372
|
function effectiveChildElements(parent) {
|
|
19330
19373
|
const result = [];
|
|
@@ -19359,7 +19402,7 @@ function findElements(parent, localName2) {
|
|
|
19359
19402
|
const child = children[i];
|
|
19360
19403
|
if (child.nodeType === 1) {
|
|
19361
19404
|
const el = child;
|
|
19362
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
19405
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _148 => _148.tagName, 'optionalAccess', _149 => _149.endsWith, 'call', _150 => _150(`:${localName2}`)])) {
|
|
19363
19406
|
result.push(el);
|
|
19364
19407
|
}
|
|
19365
19408
|
walk(el);
|
|
@@ -19378,7 +19421,7 @@ function getAttr(el, localName2) {
|
|
|
19378
19421
|
return null;
|
|
19379
19422
|
}
|
|
19380
19423
|
function parseXml2(text) {
|
|
19381
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19424
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19382
19425
|
}
|
|
19383
19426
|
function parseStyles(xml) {
|
|
19384
19427
|
const doc = parseXml2(xml);
|
|
@@ -19495,7 +19538,7 @@ function collectOmmlRoots(p) {
|
|
|
19495
19538
|
const child = children[i];
|
|
19496
19539
|
if (child.nodeType !== 1) continue;
|
|
19497
19540
|
const el = child;
|
|
19498
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
19541
|
+
const tag = el.localName || _optionalChain([el, 'access', _151 => _151.tagName, 'optionalAccess', _152 => _152.replace, 'call', _153 => _153(/^[^:]+:/, "")]) || "";
|
|
19499
19542
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
19500
19543
|
out.push(el);
|
|
19501
19544
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -19536,7 +19579,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19536
19579
|
function makeLink(text, rawHref) {
|
|
19537
19580
|
if (!text) return "";
|
|
19538
19581
|
if (!rawHref) return text;
|
|
19539
|
-
const href =
|
|
19582
|
+
const href = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, rawHref);
|
|
19540
19583
|
return href ? `[${text}](${href})` : text;
|
|
19541
19584
|
}
|
|
19542
19585
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19638,7 +19681,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19638
19681
|
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19639
19682
|
if (!text) return null;
|
|
19640
19683
|
const style = styles.get(styleId);
|
|
19641
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
19684
|
+
if (_optionalChain([style, 'optionalAccess', _154 => _154.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
19642
19685
|
return {
|
|
19643
19686
|
type: "heading",
|
|
19644
19687
|
text,
|
|
@@ -19647,8 +19690,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19647
19690
|
}
|
|
19648
19691
|
if (numId && numId !== "0") {
|
|
19649
19692
|
const numDef = numbering.get(numId);
|
|
19650
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
19651
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
19693
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _155 => _155.get, 'call', _156 => _156(ilvl)]);
|
|
19694
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _157 => _157.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
19652
19695
|
return { type: "list", text, listType };
|
|
19653
19696
|
}
|
|
19654
19697
|
const block = { type: "paragraph", text };
|
|
@@ -19730,7 +19773,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19730
19773
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19731
19774
|
})
|
|
19732
19775
|
);
|
|
19733
|
-
const table2 =
|
|
19776
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19734
19777
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19735
19778
|
return { type: "table", table: table2 };
|
|
19736
19779
|
}
|
|
@@ -19740,10 +19783,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19740
19783
|
for (const el of effectiveChildElements(tc2)) {
|
|
19741
19784
|
if (matchesLocal(el, "p")) {
|
|
19742
19785
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19743
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
19786
|
+
if (_optionalChain([block, 'optionalAccess', _158 => _158.text])) parts.push(block.text);
|
|
19744
19787
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19745
19788
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19746
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
19789
|
+
if (_optionalChain([tb, 'optionalAccess', _159 => _159.text])) parts.push(tb.text);
|
|
19747
19790
|
}
|
|
19748
19791
|
} else if (matchesLocal(el, "tbl")) {
|
|
19749
19792
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -19778,7 +19821,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19778
19821
|
try {
|
|
19779
19822
|
const data = await imgFile.async("uint8array");
|
|
19780
19823
|
imgIdx++;
|
|
19781
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
19824
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _160 => _160.split, 'call', _161 => _161("."), 'access', _162 => _162.pop, 'call', _163 => _163(), 'optionalAccess', _164 => _164.toLowerCase, 'call', _165 => _165()]), () => ( "png"));
|
|
19782
19825
|
const mimeMap = {
|
|
19783
19826
|
png: "image/png",
|
|
19784
19827
|
jpg: "image/jpeg",
|
|
@@ -19832,12 +19875,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19832
19875
|
}
|
|
19833
19876
|
}
|
|
19834
19877
|
async function parseDocxDocument(buffer, options) {
|
|
19835
|
-
|
|
19878
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19836
19879
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19837
19880
|
const warnings = [];
|
|
19838
19881
|
const docFile = zip.file("word/document.xml");
|
|
19839
19882
|
if (!docFile) {
|
|
19840
|
-
throw new (0,
|
|
19883
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19841
19884
|
}
|
|
19842
19885
|
let rels = /* @__PURE__ */ new Map();
|
|
19843
19886
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19884,7 +19927,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19884
19927
|
const doc = parseXml2(docXml);
|
|
19885
19928
|
const body = findElements(doc, "body");
|
|
19886
19929
|
if (body.length === 0) {
|
|
19887
|
-
throw new (0,
|
|
19930
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19888
19931
|
}
|
|
19889
19932
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19890
19933
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19892,7 +19935,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19892
19935
|
const bodyEl = body[0];
|
|
19893
19936
|
const topLevel = effectiveChildElements(bodyEl);
|
|
19894
19937
|
for (const el of topLevel) {
|
|
19895
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
19938
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _166 => _166.tagName, 'optionalAccess', _167 => _167.split, 'call', _168 => _168(":"), 'access', _169 => _169.pop, 'call', _170 => _170()])));
|
|
19896
19939
|
if (localName2 === "p") {
|
|
19897
19940
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19898
19941
|
if (block) blocks.push(block);
|
|
@@ -19903,7 +19946,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19903
19946
|
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19904
19947
|
}
|
|
19905
19948
|
} else if (localName2 === "tbl") {
|
|
19906
|
-
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess',
|
|
19949
|
+
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess', _171 => _171.keepTrailingEmptyCols]));
|
|
19907
19950
|
if (block) blocks.push(block);
|
|
19908
19951
|
}
|
|
19909
19952
|
}
|
|
@@ -19935,7 +19978,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19935
19978
|
}
|
|
19936
19979
|
}
|
|
19937
19980
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19938
|
-
const markdown =
|
|
19981
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19939
19982
|
return {
|
|
19940
19983
|
markdown,
|
|
19941
19984
|
blocks,
|
|
@@ -19958,7 +20001,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19958
20001
|
}
|
|
19959
20002
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19960
20003
|
const normalized = text.replace(/ /g, " ");
|
|
19961
|
-
const xml =
|
|
20004
|
+
const xml = _chunkKKZATKQWcjs.stripDtd.call(void 0, normalized);
|
|
19962
20005
|
const warnings = [];
|
|
19963
20006
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19964
20007
|
onError: (_level, msg2) => {
|
|
@@ -19986,7 +20029,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19986
20029
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19987
20030
|
}
|
|
19988
20031
|
const blocks = [];
|
|
19989
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
20032
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _172 => _172.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
19990
20033
|
let sectionIdx = 0;
|
|
19991
20034
|
const children = body.childNodes;
|
|
19992
20035
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -19995,10 +20038,10 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19995
20038
|
if (localName(el) !== "SECTION") continue;
|
|
19996
20039
|
sectionIdx++;
|
|
19997
20040
|
if (pageFilter && !pageFilter.has(sectionIdx)) continue;
|
|
19998
|
-
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
20041
|
+
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _173 => _173.keepTrailingEmptyCols]), () => ( false)));
|
|
19999
20042
|
}
|
|
20000
20043
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20001
|
-
const markdown =
|
|
20044
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20002
20045
|
return {
|
|
20003
20046
|
markdown,
|
|
20004
20047
|
blocks,
|
|
@@ -20084,7 +20127,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
20084
20127
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
20085
20128
|
const text = extractParagraphText(el);
|
|
20086
20129
|
if (!text) return;
|
|
20087
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
20130
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _174 => _174.headingLevel]) != null) {
|
|
20088
20131
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
20089
20132
|
} else {
|
|
20090
20133
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -20143,7 +20186,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20143
20186
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20144
20187
|
cellRows[r].push(cell2);
|
|
20145
20188
|
}
|
|
20146
|
-
const table2 =
|
|
20189
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20147
20190
|
const caption = extractShapeCaption(el);
|
|
20148
20191
|
if (caption.text && caption.before) {
|
|
20149
20192
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20403,7 +20446,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
20403
20446
|
(match, prefix, suffix) => {
|
|
20404
20447
|
const label = prefix + suffix;
|
|
20405
20448
|
const normalizedLabel = normalizeLabel(label);
|
|
20406
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20449
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _175 => _175.has, 'call', _176 => _176(normalizedLabel)])) return match;
|
|
20407
20450
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
20408
20451
|
if (matchKey === void 0) return match;
|
|
20409
20452
|
const newValue = values.consume(matchKey);
|
|
@@ -20482,17 +20525,17 @@ function matchInlineSegment(seg, values, blockedLabels) {
|
|
|
20482
20525
|
const nlabel = normalizeLabel(seg.label);
|
|
20483
20526
|
if (seg.extLabel !== void 0) {
|
|
20484
20527
|
const nExt = normalizeLabel(seg.extLabel);
|
|
20485
|
-
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess',
|
|
20528
|
+
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess', _177 => _177.has, 'call', _178 => _178(nExt)]) && values.has(nExt)) {
|
|
20486
20529
|
return { key: nExt, label: seg.extLabel, viaExt: true };
|
|
20487
20530
|
}
|
|
20488
20531
|
}
|
|
20489
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20532
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _179 => _179.has, 'call', _180 => _180(nlabel)])) return void 0;
|
|
20490
20533
|
const key = findMatchingKey(nlabel, values);
|
|
20491
20534
|
return key !== void 0 ? { key, label: seg.label, viaExt: false } : void 0;
|
|
20492
20535
|
}
|
|
20493
20536
|
function clampSegmentEnd(text, seg, next, nextViaExt) {
|
|
20494
20537
|
let ve = seg.valueEnd;
|
|
20495
|
-
if (nextViaExt && _optionalChain([next, 'optionalAccess',
|
|
20538
|
+
if (nextViaExt && _optionalChain([next, 'optionalAccess', _181 => _181.extStart]) !== void 0 && next.extStart < ve) ve = next.extStart;
|
|
20496
20539
|
while (ve > seg.valueStart && /\s/.test(text[ve - 1])) ve--;
|
|
20497
20540
|
return ve;
|
|
20498
20541
|
}
|
|
@@ -20507,7 +20550,7 @@ function normalizeValues(values, warnings) {
|
|
|
20507
20550
|
const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
|
|
20508
20551
|
const key = normalizeLabel(label);
|
|
20509
20552
|
if (map.has(key)) {
|
|
20510
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
20553
|
+
_optionalChain([warnings, 'optionalAccess', _182 => _182.push, 'call', _183 => _183(`\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`)]);
|
|
20511
20554
|
}
|
|
20512
20555
|
map.set(key, Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
|
|
20513
20556
|
}
|
|
@@ -20682,8 +20725,8 @@ function extractFromTable(table2) {
|
|
|
20682
20725
|
if (table2.cols >= 2) {
|
|
20683
20726
|
for (let r = 0; r < table2.rows; r++) {
|
|
20684
20727
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
20685
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20686
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20728
|
+
const labelCell = _optionalChain([table2, 'access', _184 => _184.cells, 'access', _185 => _185[r], 'optionalAccess', _186 => _186[c]]);
|
|
20729
|
+
const valueCell = _optionalChain([table2, 'access', _187 => _187.cells, 'access', _188 => _188[r], 'optionalAccess', _189 => _189[c + 1]]);
|
|
20687
20730
|
if (!labelCell || !valueCell) continue;
|
|
20688
20731
|
if (isLabelCell(labelCell.text)) {
|
|
20689
20732
|
fields.push({
|
|
@@ -20698,15 +20741,15 @@ function extractFromTable(table2) {
|
|
|
20698
20741
|
}
|
|
20699
20742
|
if (fields.length === 0 && table2.rows >= 2 && table2.cols >= 2) {
|
|
20700
20743
|
const headerRow = table2.cells[0];
|
|
20701
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20702
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20744
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _190 => _190.every, 'call', _191 => _191((cell2) => {
|
|
20745
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _192 => _192.text, 'access', _193 => _193.trim, 'call', _194 => _194()]), () => ( ""));
|
|
20703
20746
|
return t.length > 0 && t.length <= 20;
|
|
20704
20747
|
})]), () => ( false));
|
|
20705
20748
|
if (allLabels) {
|
|
20706
20749
|
for (let r = 1; r < table2.rows; r++) {
|
|
20707
20750
|
for (let c = 0; c < table2.cols; c++) {
|
|
20708
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
20709
|
-
const value = _nullishCoalesce(_optionalChain([table2, 'access',
|
|
20751
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _195 => _195[c], 'optionalAccess', _196 => _196.text, 'access', _197 => _197.trim, 'call', _198 => _198()]), () => ( ""));
|
|
20752
|
+
const value = _nullishCoalesce(_optionalChain([table2, 'access', _199 => _199.cells, 'access', _200 => _200[r], 'optionalAccess', _201 => _201[c], 'optionalAccess', _202 => _202.text, 'access', _203 => _203.trim, 'call', _204 => _204()]), () => ( ""));
|
|
20710
20753
|
if (label && value) {
|
|
20711
20754
|
fields.push({ label, value, row: r, col: c });
|
|
20712
20755
|
}
|
|
@@ -20800,7 +20843,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
20800
20843
|
for (const table2 of allTables) {
|
|
20801
20844
|
for (let r = 0; r < table2.rows; r++) {
|
|
20802
20845
|
for (let c = 0; c < table2.cols; c++) {
|
|
20803
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20846
|
+
const cell2 = _optionalChain([table2, 'access', _205 => _205.cells, 'access', _206 => _206[r], 'optionalAccess', _207 => _207[c]]);
|
|
20804
20847
|
if (!cell2) continue;
|
|
20805
20848
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
20806
20849
|
if (result) {
|
|
@@ -20832,7 +20875,7 @@ function collectIRTables(blocks, depth) {
|
|
|
20832
20875
|
out.push(block.table);
|
|
20833
20876
|
for (const row of block.table.cells) {
|
|
20834
20877
|
for (const cell2 of row) {
|
|
20835
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
20878
|
+
if (_optionalChain([cell2, 'optionalAccess', _208 => _208.blocks, 'optionalAccess', _209 => _209.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
20836
20879
|
}
|
|
20837
20880
|
}
|
|
20838
20881
|
}
|
|
@@ -20843,7 +20886,7 @@ function coveredPositions(table2) {
|
|
|
20843
20886
|
for (let r = 0; r < table2.rows; r++) {
|
|
20844
20887
|
for (let c = 0; c < table2.cols; c++) {
|
|
20845
20888
|
if (covered.has(`${r},${c}`)) continue;
|
|
20846
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20889
|
+
const cell2 = _optionalChain([table2, 'access', _210 => _210.cells, 'access', _211 => _211[r], 'optionalAccess', _212 => _212[c]]);
|
|
20847
20890
|
if (!cell2) continue;
|
|
20848
20891
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
20849
20892
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -20859,15 +20902,15 @@ function coveredPositions(table2) {
|
|
|
20859
20902
|
function isHeaderDataTable(table2, covered) {
|
|
20860
20903
|
if (table2.rows < 2) return false;
|
|
20861
20904
|
const headerRow = table2.cells[0];
|
|
20862
|
-
if (!_optionalChain([headerRow, 'optionalAccess',
|
|
20905
|
+
if (!_optionalChain([headerRow, 'optionalAccess', _213 => _213.length])) return false;
|
|
20863
20906
|
const allLabels = headerRow.every((cell2) => {
|
|
20864
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20907
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _214 => _214.text, 'access', _215 => _215.trim, 'call', _216 => _216()]), () => ( ""));
|
|
20865
20908
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20866
20909
|
});
|
|
20867
20910
|
if (!allLabels) return false;
|
|
20868
20911
|
for (let c = 0; c < table2.cols; c++) {
|
|
20869
20912
|
if (covered.has(`1,${c}`)) continue;
|
|
20870
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20913
|
+
const cell2 = _optionalChain([table2, 'access', _217 => _217.cells, 'access', _218 => _218[1], 'optionalAccess', _219 => _219[c]]);
|
|
20871
20914
|
if (!cell2) break;
|
|
20872
20915
|
return !isLabelCell(cell2.text);
|
|
20873
20916
|
}
|
|
@@ -20880,7 +20923,7 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20880
20923
|
for (let r = skipHeaderRow ? 1 : 0; r < table2.rows; r++) {
|
|
20881
20924
|
for (let c = 0; c < table2.cols; c++) {
|
|
20882
20925
|
if (covered.has(`${r},${c}`)) continue;
|
|
20883
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20926
|
+
const labelCell = _optionalChain([table2, 'access', _220 => _220.cells, 'access', _221 => _221[r], 'optionalAccess', _222 => _222[c]]);
|
|
20884
20927
|
if (!labelCell) continue;
|
|
20885
20928
|
if (!isLabelCell(labelCell.text)) continue;
|
|
20886
20929
|
let vc = c + labelCell.colSpan;
|
|
@@ -20891,12 +20934,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20891
20934
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
20892
20935
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
20893
20936
|
if (!normalizedCellLabel) continue;
|
|
20894
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20937
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _223 => _223.has, 'call', _224 => _224(normalizedCellLabel)])) continue;
|
|
20895
20938
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
20896
20939
|
if (matchKey === void 0) continue;
|
|
20897
20940
|
const newValue = values.consume(matchKey);
|
|
20898
20941
|
if (newValue === void 0) continue;
|
|
20899
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20942
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _225 => _225.has, 'call', _226 => _226(valueCell)])) {
|
|
20900
20943
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20901
20944
|
} else {
|
|
20902
20945
|
valueCell.text = newValue;
|
|
@@ -20913,8 +20956,8 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20913
20956
|
}
|
|
20914
20957
|
if (table2.rows >= 2 && table2.cols >= 2) {
|
|
20915
20958
|
const headerRow = table2.cells[0];
|
|
20916
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20917
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20959
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _227 => _227.every, 'call', _228 => _228((cell2) => {
|
|
20960
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _229 => _229.text, 'access', _230 => _230.trim, 'call', _231 => _231()]), () => ( ""));
|
|
20918
20961
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20919
20962
|
})]), () => ( false));
|
|
20920
20963
|
if (!allLabels) return;
|
|
@@ -20922,16 +20965,16 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20922
20965
|
for (let c = 0; c < table2.cols; c++) {
|
|
20923
20966
|
if (covered.has(`${r},${c}`)) continue;
|
|
20924
20967
|
const headerCell = headerRow[c];
|
|
20925
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20968
|
+
const valueCell = _optionalChain([table2, 'access', _232 => _232.cells, 'access', _233 => _233[r], 'optionalAccess', _234 => _234[c]]);
|
|
20926
20969
|
if (!headerCell || !valueCell) continue;
|
|
20927
20970
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
20928
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20971
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _235 => _235.has, 'call', _236 => _236(headerLabel)])) continue;
|
|
20929
20972
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
20930
20973
|
if (matchKey === void 0) continue;
|
|
20931
20974
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
20932
20975
|
const newValue = values.consume(matchKey);
|
|
20933
20976
|
if (newValue === void 0) continue;
|
|
20934
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20977
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _237 => _237.has, 'call', _238 => _238(valueCell)])) {
|
|
20935
20978
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20936
20979
|
} else {
|
|
20937
20980
|
valueCell.text = newValue;
|
|
@@ -20963,7 +21006,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
20963
21006
|
if (newValue === void 0) continue;
|
|
20964
21007
|
matchedLabels.add(matchKey);
|
|
20965
21008
|
filled.push({ label: matched.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
|
|
20966
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
21009
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _239 => _239[i + 1], 'optionalAccess', _240 => _240.viaExt]), () => ( false)));
|
|
20967
21010
|
out += text.slice(pos, seg.valueStart);
|
|
20968
21011
|
out += seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
20969
21012
|
pos = ve;
|
|
@@ -21525,19 +21568,19 @@ function parseCentralDirectory(buf) {
|
|
|
21525
21568
|
}
|
|
21526
21569
|
}
|
|
21527
21570
|
}
|
|
21528
|
-
if (eocdOffset < 0) throw new (0,
|
|
21571
|
+
if (eocdOffset < 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21529
21572
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21530
21573
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21531
21574
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21532
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21575
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21533
21576
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21534
|
-
throw new (0,
|
|
21577
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21535
21578
|
}
|
|
21536
21579
|
const decoder = new TextDecoder("utf-8");
|
|
21537
21580
|
const entries = [];
|
|
21538
21581
|
let pos = cdOffset;
|
|
21539
21582
|
for (let i = 0; i < totalEntries; i++) {
|
|
21540
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21583
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21541
21584
|
const flags = view.getUint16(pos + 8, true);
|
|
21542
21585
|
const method = view.getUint16(pos + 10, true);
|
|
21543
21586
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21548,7 +21591,7 @@ function parseCentralDirectory(buf) {
|
|
|
21548
21591
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21549
21592
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21550
21593
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21551
|
-
throw new (0,
|
|
21594
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21552
21595
|
}
|
|
21553
21596
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21554
21597
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21577,11 +21620,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21577
21620
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21578
21621
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21579
21622
|
for (const name of replacements.keys()) {
|
|
21580
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21623
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkKKZATKQWcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21581
21624
|
}
|
|
21582
21625
|
if (additions) {
|
|
21583
21626
|
for (const name of additions.keys()) {
|
|
21584
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21627
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkKKZATKQWcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21585
21628
|
}
|
|
21586
21629
|
}
|
|
21587
21630
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21600,7 +21643,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21600
21643
|
offset += seg.length;
|
|
21601
21644
|
continue;
|
|
21602
21645
|
}
|
|
21603
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21646
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21604
21647
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21605
21648
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21606
21649
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21608,7 +21651,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21608
21651
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21609
21652
|
const method = e.method;
|
|
21610
21653
|
if (method !== 0 && method !== 8) {
|
|
21611
|
-
throw new (0,
|
|
21654
|
+
throw new (0, _chunkKKZATKQWcjs.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`);
|
|
21612
21655
|
}
|
|
21613
21656
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21614
21657
|
const crc = crc32(newData);
|
|
@@ -21709,7 +21752,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21709
21752
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21710
21753
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21711
21754
|
if (sectionPaths.length === 0) {
|
|
21712
|
-
throw new (0,
|
|
21755
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21713
21756
|
}
|
|
21714
21757
|
const warnings = [];
|
|
21715
21758
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -21793,7 +21836,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21793
21836
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
21794
21837
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
21795
21838
|
if (!normalizedCellLabel) continue;
|
|
21796
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21839
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _241 => _241.has, 'call', _242 => _242(normalizedCellLabel)])) continue;
|
|
21797
21840
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
21798
21841
|
if (matchKey === void 0) continue;
|
|
21799
21842
|
if (patternApplied.has(valueCell)) {
|
|
@@ -21851,7 +21894,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21851
21894
|
const dataCells = table2.rows[rowIdx];
|
|
21852
21895
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
21853
21896
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
21854
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21897
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _243 => _243.has, 'call', _244 => _244(headerLabel)])) continue;
|
|
21855
21898
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
21856
21899
|
if (matchKey === void 0) continue;
|
|
21857
21900
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -21905,7 +21948,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21905
21948
|
}
|
|
21906
21949
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
21907
21950
|
const existing = ledger.get(para2);
|
|
21908
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
21951
|
+
if (_optionalChain([existing, 'optionalAccess', _245 => _245.fullText]) !== void 0) continue;
|
|
21909
21952
|
const text = matchText(para2);
|
|
21910
21953
|
const segments = scanInlineSegments(text);
|
|
21911
21954
|
const matches = segments.map((seg) => matchInlineSegment(seg, cursor, blockedLabels));
|
|
@@ -21916,7 +21959,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21916
21959
|
const matchKey = matched.key;
|
|
21917
21960
|
const newValue = cursor.consume(matchKey);
|
|
21918
21961
|
if (newValue === void 0) continue;
|
|
21919
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
21962
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _246 => _246[i + 1], 'optionalAccess', _247 => _247.viaExt]), () => ( false)));
|
|
21920
21963
|
const replacement = seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
21921
21964
|
const l = led(para2);
|
|
21922
21965
|
l.ranges.push({ start: seg.valueStart, end: ve, replacement });
|
|
@@ -22022,16 +22065,16 @@ var PARA_LIST = 7;
|
|
|
22022
22065
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
22023
22066
|
function resolveTheme(theme) {
|
|
22024
22067
|
return {
|
|
22025
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22026
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22027
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22028
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22029
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22030
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22068
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _248 => _248.headingColors, 'optionalAccess', _249 => _249[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22069
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _250 => _250.headingColors, 'optionalAccess', _251 => _251[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22070
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _252 => _252.headingColors, 'optionalAccess', _253 => _253[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22071
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _254 => _254.headingColors, 'optionalAccess', _255 => _255[4]]), () => ( _optionalChain([theme, 'optionalAccess', _256 => _256.headingColors, 'optionalAccess', _257 => _257[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22072
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _258 => _258.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22073
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _259 => _259.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22031
22074
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
22032
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
22033
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22034
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
22075
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _260 => _260.quoteColor]) !== void 0,
|
|
22076
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _261 => _261.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _262 => _262.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22077
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _263 => _263.tableHeaderBold])
|
|
22035
22078
|
};
|
|
22036
22079
|
}
|
|
22037
22080
|
function escapeXml(text) {
|
|
@@ -22446,7 +22489,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22446
22489
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22447
22490
|
const got = m ? Number(m[1]) : NaN;
|
|
22448
22491
|
if (got !== startId + i) {
|
|
22449
|
-
throw new (0,
|
|
22492
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
22450
22493
|
`\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)`
|
|
22451
22494
|
);
|
|
22452
22495
|
}
|
|
@@ -22530,7 +22573,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22530
22573
|
}
|
|
22531
22574
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22532
22575
|
if (rows.length !== expectedBase) {
|
|
22533
|
-
throw new (0,
|
|
22576
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
22534
22577
|
`\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`
|
|
22535
22578
|
);
|
|
22536
22579
|
}
|
|
@@ -22757,7 +22800,7 @@ function buildStyles(gongmun) {
|
|
|
22757
22800
|
</hh:styles>`;
|
|
22758
22801
|
}
|
|
22759
22802
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
22760
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
22803
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _264 => _264.fonts, 'access', _265 => _265.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _266 => _266.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
22761
22804
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
22762
22805
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
22763
22806
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22886,8 +22929,8 @@ function parseChartFence(text) {
|
|
|
22886
22929
|
const spec = chartSpec(type);
|
|
22887
22930
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22888
22931
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22889
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22890
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22932
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _267 => _267.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
22933
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _268 => _268[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22891
22934
|
if (!spec.scatter) {
|
|
22892
22935
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22893
22936
|
}
|
|
@@ -22929,7 +22972,7 @@ function serSpPr(color, stroke) {
|
|
|
22929
22972
|
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>`;
|
|
22930
22973
|
}
|
|
22931
22974
|
function dPtXml(pointColors, pie) {
|
|
22932
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
22975
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _269 => _269.length])) return "";
|
|
22933
22976
|
return pointColors.map((col, i) => {
|
|
22934
22977
|
const f = chartColorFill(col);
|
|
22935
22978
|
if (!f) return "";
|
|
@@ -23168,8 +23211,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
23168
23211
|
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 });
|
|
23169
23212
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
23170
23213
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
23171
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23172
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23214
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _270 => _270.cover, 'optionalAccess', _271 => _271.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
23215
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _272 => _272.cover, 'optionalAccess', _273 => _273.org]), () => ( ""));
|
|
23173
23216
|
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>`;
|
|
23174
23217
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
23175
23218
|
return [
|
|
@@ -23425,7 +23468,7 @@ function escapeGfm(text) {
|
|
|
23425
23468
|
}
|
|
23426
23469
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23427
23470
|
function sanitizeText(text) {
|
|
23428
|
-
let result =
|
|
23471
|
+
let result = _chunkWMU2KJHFcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23429
23472
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23430
23473
|
const tokens = result.split(" ");
|
|
23431
23474
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23455,7 +23498,7 @@ function replicateGfmTable(table2) {
|
|
|
23455
23498
|
for (let r = 0; r < numRows; r++) {
|
|
23456
23499
|
for (let c = 0; c < numCols; c++) {
|
|
23457
23500
|
if (skip.has(`${r},${c}`)) continue;
|
|
23458
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23501
|
+
const cell2 = _optionalChain([cells, 'access', _274 => _274[r], 'optionalAccess', _275 => _275[c]]);
|
|
23459
23502
|
if (!cell2) continue;
|
|
23460
23503
|
display[r][c] = {
|
|
23461
23504
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -23509,7 +23552,7 @@ function unescapeGfmCell(text) {
|
|
|
23509
23552
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
|
|
23510
23553
|
}
|
|
23511
23554
|
function replicateCellInnerHtml(cell2) {
|
|
23512
|
-
if (_optionalChain([cell2, 'access',
|
|
23555
|
+
if (_optionalChain([cell2, 'access', _276 => _276.blocks, 'optionalAccess', _277 => _277.length])) {
|
|
23513
23556
|
return cell2.blocks.map((b) => {
|
|
23514
23557
|
if (b.type === "table" && b.table) {
|
|
23515
23558
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -23548,7 +23591,7 @@ function replicateHtmlTable(table2) {
|
|
|
23548
23591
|
const rowCells = [];
|
|
23549
23592
|
for (let c = 0; c < numCols; c++) {
|
|
23550
23593
|
if (skip.has(`${r},${c}`)) continue;
|
|
23551
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23594
|
+
const cell2 = _optionalChain([cells, 'access', _278 => _278[r], 'optionalAccess', _279 => _279[c]]);
|
|
23552
23595
|
if (!cell2) continue;
|
|
23553
23596
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
23554
23597
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -23594,10 +23637,10 @@ function parseHtmlTable(raw) {
|
|
|
23594
23637
|
}
|
|
23595
23638
|
} else {
|
|
23596
23639
|
if (!isClose) {
|
|
23597
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
23598
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
23640
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _280 => _280.match, 'call', _281 => _281(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _282 => _282[1]]) || "1", 10);
|
|
23641
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _283 => _283.match, 'call', _284 => _284(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _285 => _285[1]]) || "1", 10);
|
|
23599
23642
|
cellStart = m.index + m[0].length;
|
|
23600
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23643
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkWMU2KJHFcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkWMU2KJHFcjs.MAX_ROWS) };
|
|
23601
23644
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23602
23645
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23603
23646
|
cellStart = -1;
|
|
@@ -23621,7 +23664,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
23621
23664
|
hadNonText = true;
|
|
23622
23665
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
23623
23666
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
23624
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
23667
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _286 => _286[1]]), () => ( _optionalChain([m, 'optionalAccess', _287 => _287[2]])));
|
|
23625
23668
|
if (src) imgSrcs.push(src);
|
|
23626
23669
|
return "";
|
|
23627
23670
|
});
|
|
@@ -23752,7 +23795,7 @@ function edgeXml(tag, d) {
|
|
|
23752
23795
|
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"/>`;
|
|
23753
23796
|
}
|
|
23754
23797
|
function borderFillDefToXml(id, def) {
|
|
23755
|
-
const fill = _optionalChain([def, 'access',
|
|
23798
|
+
const fill = _optionalChain([def, 'access', _288 => _288.fill, 'optionalAccess', _289 => _289.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
23756
23799
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
23757
23800
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
23758
23801
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -24157,11 +24200,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
24157
24200
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
24158
24201
|
const rowCnt = rows.length;
|
|
24159
24202
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
24160
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24203
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _290 => _290.bfRegistry]), () => ( null));
|
|
24161
24204
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
24162
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24205
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _291 => _291.charHeight]), () => ( 1e3));
|
|
24163
24206
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
24164
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
24207
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _292 => _292[0], 'optionalAccess', _293 => _293[0]]), () => ( ""))), seq, rowAnchor);
|
|
24165
24208
|
const colMax = Array(colCnt).fill(0);
|
|
24166
24209
|
const colMaxBody = Array(colCnt).fill(0);
|
|
24167
24210
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -24189,7 +24232,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24189
24232
|
const k = `${rowIdx},${colIdx}`;
|
|
24190
24233
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
24191
24234
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
24192
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24235
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _294 => _294.cellChar, 'access', _295 => _295.get, 'call', _296 => _296(k)]), () => ( defaultCharPr));
|
|
24193
24236
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
24194
24237
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24195
24238
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -24207,11 +24250,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24207
24250
|
}
|
|
24208
24251
|
}
|
|
24209
24252
|
}
|
|
24210
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
24253
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _297 => _297.cellChar, 'access', _298 => _298.has, 'call', _299 => _299(k)]) ? void 0 : mapId);
|
|
24211
24254
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
24212
24255
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
24213
24256
|
}).join("");
|
|
24214
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24257
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _300 => _300.cellBf, 'access', _301 => _301.get, 'call', _302 => _302(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24215
24258
|
row: rowIdx,
|
|
24216
24259
|
rowEnd: rowIdx,
|
|
24217
24260
|
col: colIdx,
|
|
@@ -24221,7 +24264,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24221
24264
|
headerRows: 1,
|
|
24222
24265
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
24223
24266
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
24224
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24267
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _303 => _303.cellH, 'access', _304 => _304.get, 'call', _305 => _305(k)]), () => ( cellH));
|
|
24225
24268
|
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>`;
|
|
24226
24269
|
}).join("");
|
|
24227
24270
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -24230,7 +24273,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24230
24273
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
24231
24274
|
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;
|
|
24232
24275
|
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>`;
|
|
24233
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
24276
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _306 => _306.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
24234
24277
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
24235
24278
|
}
|
|
24236
24279
|
function layoutHtmlRows(rows) {
|
|
@@ -24241,8 +24284,8 @@ function layoutHtmlRows(rows) {
|
|
|
24241
24284
|
let c = 0;
|
|
24242
24285
|
for (const cell2 of rows[r].cells) {
|
|
24243
24286
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24244
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24245
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24287
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkWMU2KJHFcjs.MAX_COLS);
|
|
24288
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkWMU2KJHFcjs.MAX_ROWS);
|
|
24246
24289
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24247
24290
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24248
24291
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -24270,7 +24313,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24270
24313
|
if (!rows || rows.length === 0) return null;
|
|
24271
24314
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
24272
24315
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
24273
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24316
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _307 => _307.charHeight]), () => ( 1e3));
|
|
24274
24317
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
24275
24318
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
24276
24319
|
for (const cell2 of placed) {
|
|
@@ -24299,7 +24342,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24299
24342
|
const tblId = nextTableId();
|
|
24300
24343
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
24301
24344
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
24302
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24345
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _308 => _308.bfRegistry]), () => ( null));
|
|
24303
24346
|
let htmlHeaderRows = 0;
|
|
24304
24347
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
24305
24348
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -24314,7 +24357,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24314
24357
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
24315
24358
|
if (nestedXml) {
|
|
24316
24359
|
nestedXmls.push(nestedXml);
|
|
24317
|
-
const szH = _optionalChain([nestedXml, 'access',
|
|
24360
|
+
const szH = _optionalChain([nestedXml, 'access', _309 => _309.match, 'call', _310 => _310(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _311 => _311[1]]);
|
|
24318
24361
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
24319
24362
|
}
|
|
24320
24363
|
}
|
|
@@ -24323,7 +24366,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24323
24366
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
24324
24367
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
24325
24368
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
24326
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24369
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _312 => _312.cellH, 'access', _313 => _313.get, 'call', _314 => _314(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
|
|
24327
24370
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
24328
24371
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
24329
24372
|
return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
|
|
@@ -24334,7 +24377,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24334
24377
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
24335
24378
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
24336
24379
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
24337
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24380
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _315 => _315.cellChar, 'access', _316 => _316.get, 'call', _317 => _317(k)]), () => ( defaultCharPr));
|
|
24338
24381
|
const centered = isHeader || colCentered[cell2.c];
|
|
24339
24382
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24340
24383
|
const picUrls = images ? [...imgSrcs] : [];
|
|
@@ -24370,7 +24413,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24370
24413
|
let cellHeight = 0;
|
|
24371
24414
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
24372
24415
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
24373
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24416
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _318 => _318.cellBf, 'access', _319 => _319.get, 'call', _320 => _320(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24374
24417
|
row: cell2.r,
|
|
24375
24418
|
rowEnd,
|
|
24376
24419
|
col: cell2.c,
|
|
@@ -24540,7 +24583,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
24540
24583
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
24541
24584
|
}
|
|
24542
24585
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
24543
|
-
const c = _optionalChain([g, 'access',
|
|
24586
|
+
const c = _optionalChain([g, 'access', _321 => _321.press, 'optionalAccess', _322 => _322.contact]);
|
|
24544
24587
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
24545
24588
|
const w = bodyWidth - 280;
|
|
24546
24589
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -24921,7 +24964,7 @@ function generateSecPr(gongmun) {
|
|
|
24921
24964
|
}
|
|
24922
24965
|
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>`;
|
|
24923
24966
|
const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
|
|
24924
|
-
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess',
|
|
24967
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _323 => _323.pageNumbers]) ? pageNumCtrl() : "");
|
|
24925
24968
|
}
|
|
24926
24969
|
var SectionOpener = (_class6 = class {
|
|
24927
24970
|
constructor(gongmun) {;_class6.prototype.__init12.call(this);
|
|
@@ -24960,19 +25003,19 @@ function buildPreamble(blocks, ctx) {
|
|
|
24960
25003
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
24961
25004
|
const preamble = [];
|
|
24962
25005
|
let hasFrontPages = false;
|
|
24963
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25006
|
+
if (_optionalChain([gongmun, 'optionalAccess', _324 => _324.reportInfo]) && dfIds) {
|
|
24964
25007
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
24965
25008
|
}
|
|
24966
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25009
|
+
if (_optionalChain([gongmun, 'optionalAccess', _325 => _325.approval]) && bfReg) {
|
|
24967
25010
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
24968
25011
|
}
|
|
24969
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25012
|
+
if (_optionalChain([gongmun, 'optionalAccess', _326 => _326.docHead]) && dfIds) {
|
|
24970
25013
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
24971
25014
|
}
|
|
24972
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25015
|
+
if (_optionalChain([gongmun, 'optionalAccess', _327 => _327.noticeHead]) && dfIds) {
|
|
24973
25016
|
preamble.push(...buildNoticeHead(gongmun));
|
|
24974
25017
|
}
|
|
24975
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25018
|
+
if (_optionalChain([gongmun, 'optionalAccess', _328 => _328.press]) && dfIds && bfReg && tableStyle) {
|
|
24976
25019
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
24977
25020
|
}
|
|
24978
25021
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -25001,7 +25044,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
25001
25044
|
}
|
|
25002
25045
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
25003
25046
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25004
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
25047
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _329 => _329.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
25005
25048
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25006
25049
|
}
|
|
25007
25050
|
if (preamble.length > 0) {
|
|
@@ -25016,7 +25059,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
25016
25059
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
25017
25060
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
25018
25061
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
25019
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
25062
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _330 => _330.press, 'optionalAccess', _331 => _331.sub]), () => ( []))) {
|
|
25020
25063
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
25021
25064
|
}
|
|
25022
25065
|
return parts.join("\n ");
|
|
@@ -25110,8 +25153,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25110
25153
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
25111
25154
|
if (gongmun && gongmunList) {
|
|
25112
25155
|
const info = gongmunList.items.get(blockIdx);
|
|
25113
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25114
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25156
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _332 => _332.depth]), () => ( 0));
|
|
25157
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _333 => _333.marker]), () => ( ""));
|
|
25115
25158
|
const content = block.text || "";
|
|
25116
25159
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
25117
25160
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -25120,7 +25163,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25120
25163
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
25121
25164
|
}
|
|
25122
25165
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
25123
|
-
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess',
|
|
25166
|
+
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _334 => _334.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
25124
25167
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
25125
25168
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
25126
25169
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -25179,18 +25222,18 @@ function renderHtmlTable(block, ctx) {
|
|
|
25179
25222
|
}
|
|
25180
25223
|
function appendPostamble(blocks, ctx) {
|
|
25181
25224
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
25182
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25225
|
+
if (_optionalChain([gongmun, 'optionalAccess', _335 => _335.noticeHead]) && dfIds) {
|
|
25183
25226
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
25184
25227
|
}
|
|
25185
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25186
|
-
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access',
|
|
25228
|
+
if (_optionalChain([gongmun, 'optionalAccess', _336 => _336.endMark]) && paraXmls.length > 0) {
|
|
25229
|
+
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _337 => _337.rows, 'optionalAccess', _338 => _338.length]));
|
|
25187
25230
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
25188
25231
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
25189
25232
|
}
|
|
25190
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25233
|
+
if (_optionalChain([gongmun, 'optionalAccess', _339 => _339.docFoot]) && dfIds) {
|
|
25191
25234
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
25192
25235
|
}
|
|
25193
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25236
|
+
if (_optionalChain([gongmun, 'optionalAccess', _340 => _340.press]) && dfIds && bfReg && tableStyle) {
|
|
25194
25237
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25195
25238
|
}
|
|
25196
25239
|
}
|
|
@@ -25210,7 +25253,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25210
25253
|
remap,
|
|
25211
25254
|
dfIds,
|
|
25212
25255
|
images,
|
|
25213
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
25256
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _341 => _341.preset]) === "gaejosik",
|
|
25214
25257
|
measured,
|
|
25215
25258
|
richAssets,
|
|
25216
25259
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -25316,18 +25359,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25316
25359
|
|
|
25317
25360
|
// src/hwpx/generator.ts
|
|
25318
25361
|
async function markdownToHwpx(markdown, options) {
|
|
25319
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
25320
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
25362
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _342 => _342.theme]));
|
|
25363
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _343 => _343.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
25321
25364
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
25322
25365
|
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
25323
25366
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
25324
25367
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
25325
25368
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
25326
25369
|
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
25327
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
25328
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25370
|
+
const remap = _optionalChain([options, 'optionalAccess', _344 => _344.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _345 => _345.variants, 'optionalAccess', _346 => _346.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
|
|
25371
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _347 => _347.borderFillXmls, 'access', _348 => _348.length]), () => ( 0)))) : null;
|
|
25329
25372
|
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
25330
|
-
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25373
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _349 => _349.variants, 'optionalAccess', _350 => _350.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _351 => _351.charPrXmls, 'access', _352 => _352.length]), () => ( 0)));
|
|
25331
25374
|
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
25332
25375
|
const chartParts = [];
|
|
25333
25376
|
const images = new ImageRegistry();
|
|
@@ -25338,7 +25381,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25338
25381
|
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)`);
|
|
25339
25382
|
}
|
|
25340
25383
|
}
|
|
25341
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25384
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _353 => _353.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _354 => _354.emit, 'call', _355 => _355()]), () => ( []))];
|
|
25342
25385
|
const zip = new (0, _jszip2.default)();
|
|
25343
25386
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
25344
25387
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
@@ -25347,11 +25390,11 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25347
25390
|
zip.file("Contents/header.xml", generateHeaderXml(
|
|
25348
25391
|
theme,
|
|
25349
25392
|
gongmun,
|
|
25350
|
-
_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25393
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _356 => _356.variants]), () => ( [])),
|
|
25351
25394
|
extraBorderFills,
|
|
25352
|
-
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25353
|
-
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess',
|
|
25354
|
-
_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25395
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _357 => _357.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
|
|
25396
|
+
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _358 => _358.indentVariants]), () => ( [])),
|
|
25397
|
+
_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _359 => _359.fontFaces]), () => ( []))
|
|
25355
25398
|
));
|
|
25356
25399
|
zip.file("Contents/section0.xml", sectionXml);
|
|
25357
25400
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
@@ -25402,7 +25445,7 @@ function alignBlocks(a, b) {
|
|
|
25402
25445
|
const m = a.length, n = b.length;
|
|
25403
25446
|
if (m * n > 1e7) return fallbackAlign(a, b);
|
|
25404
25447
|
const lenOf = (blk) => {
|
|
25405
|
-
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25448
|
+
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _360 => _360.text]), () => ( ""))).join(" ") : "";
|
|
25406
25449
|
return t.replace(/\s+/g, " ").trim().length;
|
|
25407
25450
|
};
|
|
25408
25451
|
const aLen = a.map(lenOf);
|
|
@@ -25475,8 +25518,8 @@ function blockSimilarity(a, b) {
|
|
|
25475
25518
|
}
|
|
25476
25519
|
function tableSimilarity(a, b) {
|
|
25477
25520
|
const dimSim = 1 - Math.abs(a.rows * a.cols - b.rows * b.cols) / Math.max(a.rows * a.cols, b.rows * b.cols, 1);
|
|
25478
|
-
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25479
|
-
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25521
|
+
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _361 => _361.text]), () => ( ""))).join(" ");
|
|
25522
|
+
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _362 => _362.text]), () => ( ""))).join(" ");
|
|
25480
25523
|
const contentSim = normalizedSimilarity(textsA, textsB);
|
|
25481
25524
|
return dimSim * 0.3 + contentSim * 0.7;
|
|
25482
25525
|
}
|
|
@@ -25487,8 +25530,8 @@ function diffTableCells(a, b) {
|
|
|
25487
25530
|
for (let r = 0; r < maxRows; r++) {
|
|
25488
25531
|
const row = [];
|
|
25489
25532
|
for (let c = 0; c < maxCols; c++) {
|
|
25490
|
-
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access',
|
|
25491
|
-
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access',
|
|
25533
|
+
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access', _363 => _363.cells, 'access', _364 => _364[r], 'optionalAccess', _365 => _365[c], 'optionalAccess', _366 => _366.text]) : void 0;
|
|
25534
|
+
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access', _367 => _367.cells, 'access', _368 => _368[r], 'optionalAccess', _369 => _369[c], 'optionalAccess', _370 => _370.text]) : void 0;
|
|
25492
25535
|
let type;
|
|
25493
25536
|
if (cellA === void 0) type = "added";
|
|
25494
25537
|
else if (cellB === void 0) type = "removed";
|
|
@@ -25654,7 +25697,7 @@ function parseRenderStyles(headXml) {
|
|
|
25654
25697
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
25655
25698
|
const textColor = el.getAttribute("textColor");
|
|
25656
25699
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
25657
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
25700
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _371 => _371.getAttribute, 'call', _372 => _372("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _373 => _373.getAttribute, 'call', _374 => _374("latin")])));
|
|
25658
25701
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
25659
25702
|
styles.charPr.set(id, {
|
|
25660
25703
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -25662,8 +25705,8 @@ function parseRenderStyles(headXml) {
|
|
|
25662
25705
|
italic: findChildByLocalName(el, "italic") != null,
|
|
25663
25706
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
25664
25707
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
25665
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
25666
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
25708
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _375 => _375.getAttribute, 'call', _376 => _376("hangul")])) || 100,
|
|
25709
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _377 => _377.getAttribute, 'call', _378 => _378("hangul")])) || 0,
|
|
25667
25710
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
25668
25711
|
face
|
|
25669
25712
|
});
|
|
@@ -25672,7 +25715,7 @@ function parseRenderStyles(headXml) {
|
|
|
25672
25715
|
const id = el.getAttribute("id");
|
|
25673
25716
|
if (id != null) {
|
|
25674
25717
|
const align = findChildByLocalName(el, "align");
|
|
25675
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
25718
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _379 => _379.getAttribute, 'call', _380 => _380("horizontal")]) || "JUSTIFY");
|
|
25676
25719
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
25677
25720
|
}
|
|
25678
25721
|
} else if (tag === "borderFill") {
|
|
@@ -25686,7 +25729,7 @@ function parseRenderStyles(headXml) {
|
|
|
25686
25729
|
};
|
|
25687
25730
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
25688
25731
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
25689
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
25732
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _381 => _381.getAttribute, 'call', _382 => _382("faceColor")]);
|
|
25690
25733
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
25691
25734
|
styles.borderFill.set(id, bf);
|
|
25692
25735
|
}
|
|
@@ -25758,7 +25801,7 @@ function collectSites(scan) {
|
|
|
25758
25801
|
}
|
|
25759
25802
|
function attrOf(openTag, name) {
|
|
25760
25803
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
25761
|
-
return _optionalChain([m, 'optionalAccess',
|
|
25804
|
+
return _optionalChain([m, 'optionalAccess', _383 => _383[1]]);
|
|
25762
25805
|
}
|
|
25763
25806
|
function paraOpenTag(xml, para2) {
|
|
25764
25807
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -25773,7 +25816,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
25773
25816
|
if (!tr) return null;
|
|
25774
25817
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
25775
25818
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
25776
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
25819
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _384 => _384[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
25777
25820
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
25778
25821
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
25779
25822
|
if (close === -1) return null;
|
|
@@ -25800,7 +25843,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
25800
25843
|
if (width === null) return null;
|
|
25801
25844
|
let content = width;
|
|
25802
25845
|
const win = cellAddrWindow(xml, cell2);
|
|
25803
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
25846
|
+
const mg = _optionalChain([win, 'optionalAccess', _385 => _385.match, 'call', _386 => _386(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
25804
25847
|
if (mg) {
|
|
25805
25848
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
25806
25849
|
}
|
|
@@ -25834,11 +25877,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25834
25877
|
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>`;
|
|
25835
25878
|
}
|
|
25836
25879
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25837
|
-
if (ops.length === 0) throw new (0,
|
|
25880
|
+
if (ops.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25838
25881
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25839
25882
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25840
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
25841
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25883
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _387 => _387.match, 'call', _388 => _388(/(\d+)\.xml$/i), 'optionalAccess', _389 => _389[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _390 => _390.match, 'call', _391 => _391(/(\d+)\.xml$/i), 'optionalAccess', _392 => _392[1]]), () => ( 0))));
|
|
25884
|
+
if (sectionPaths.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25842
25885
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25843
25886
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25844
25887
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25879,11 +25922,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25879
25922
|
const manifestItems = [];
|
|
25880
25923
|
const placed = [];
|
|
25881
25924
|
for (const op of ops) {
|
|
25882
|
-
if (!op.anchor) throw new (0,
|
|
25883
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25925
|
+
if (!op.anchor) throw new (0, _chunkKKZATKQWcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25926
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25884
25927
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25885
|
-
if (!MIME[ext]) throw new (0,
|
|
25886
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25928
|
+
if (!MIME[ext]) throw new (0, _chunkKKZATKQWcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25929
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkKKZATKQWcjs.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)`);
|
|
25887
25930
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25888
25931
|
let found = null;
|
|
25889
25932
|
let total = 0;
|
|
@@ -25916,7 +25959,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25916
25959
|
}
|
|
25917
25960
|
}
|
|
25918
25961
|
}
|
|
25919
|
-
throw new (0,
|
|
25962
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
25920
25963
|
`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)})`
|
|
25921
25964
|
);
|
|
25922
25965
|
}
|
|
@@ -25924,9 +25967,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25924
25967
|
const xml = sectionXmls[si];
|
|
25925
25968
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25926
25969
|
if (!run) {
|
|
25927
|
-
throw new (0,
|
|
25970
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
25928
25971
|
}
|
|
25929
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
25972
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _393 => _393.charPr, 'access', _394 => _394.get, 'call', _395 => _395(run.charPr), 'optionalAccess', _396 => _396.height]), () => ( 1e3));
|
|
25930
25973
|
const fontPt = charPrHeight / 100;
|
|
25931
25974
|
const emMm = fontPt * 25.4 / 72;
|
|
25932
25975
|
const lineHMm = emMm;
|
|
@@ -25935,7 +25978,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25935
25978
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
25936
25979
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
25937
25980
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
25938
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
25981
|
+
const align = _optionalChain([styles, 'optionalAccess', _397 => _397.paraAlign, 'access', _398 => _398.get, 'call', _399 => _399(paraPrId)]);
|
|
25939
25982
|
let alignShiftMm = 0;
|
|
25940
25983
|
if (align === "CENTER" || align === "RIGHT") {
|
|
25941
25984
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -26031,7 +26074,7 @@ function parseBorderFills(headerDoc) {
|
|
|
26031
26074
|
};
|
|
26032
26075
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
26033
26076
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26034
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26077
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _400 => _400.getAttribute, 'call', _401 => _401("faceColor")]);
|
|
26035
26078
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
26036
26079
|
map.set(id, def);
|
|
26037
26080
|
}
|
|
@@ -26063,7 +26106,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
26063
26106
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
26064
26107
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
26065
26108
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
26066
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
26109
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _402 => _402.getAttribute, 'call', _403 => _403("hangul")]);
|
|
26067
26110
|
if (hangul) {
|
|
26068
26111
|
def.fontRef_hangul = hangul;
|
|
26069
26112
|
const face = hangulFonts.get(hangul);
|
|
@@ -26091,7 +26134,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26091
26134
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
26092
26135
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
26093
26136
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
26094
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
26137
|
+
const width = _optionalChain([sz, 'optionalAccess', _404 => _404.getAttribute, 'call', _405 => _405("width")]) || void 0;
|
|
26095
26138
|
const cells = [];
|
|
26096
26139
|
const usedBf = /* @__PURE__ */ new Set();
|
|
26097
26140
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -26104,17 +26147,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26104
26147
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
26105
26148
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
26106
26149
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
26107
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26108
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26150
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _406 => _406.getAttribute, 'call', _407 => _407("rowAddr")])), () => ( 0));
|
|
26151
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _408 => _408.getAttribute, 'call', _409 => _409("colAddr")])), () => ( 0));
|
|
26109
26152
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
26110
26153
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
26111
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26112
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26154
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _410 => _410.getAttribute, 'call', _411 => _411("colSpan")])), () => ( 1));
|
|
26155
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _412 => _412.getAttribute, 'call', _413 => _413("rowSpan")])), () => ( 1));
|
|
26113
26156
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
26114
26157
|
const cpId = firstRunCharPr(tc2);
|
|
26115
26158
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
26116
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
26117
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
26159
|
+
const w = _optionalChain([csz, 'optionalAccess', _414 => _414.getAttribute, 'call', _415 => _415("width")]);
|
|
26160
|
+
const hh = _optionalChain([csz, 'optionalAccess', _416 => _416.getAttribute, 'call', _417 => _417("height")]);
|
|
26118
26161
|
if (w) cell2.width_hwpunit = w;
|
|
26119
26162
|
if (hh) cell2.height_hwpunit = hh;
|
|
26120
26163
|
if (bfId) {
|
|
@@ -26202,16 +26245,16 @@ function pick(map, keys) {
|
|
|
26202
26245
|
return out;
|
|
26203
26246
|
}
|
|
26204
26247
|
async function hwpxToProfile(input) {
|
|
26205
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26248
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, input);
|
|
26206
26249
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26207
26250
|
const parser = createXmlParser();
|
|
26208
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
26251
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _418 => _418.file, 'call', _419 => _419(/[Hh]eader\.xml$/), 'optionalAccess', _420 => _420[0]])));
|
|
26209
26252
|
let headerXml = "<root/>";
|
|
26210
26253
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
26211
26254
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
26212
26255
|
const borderFills = parseBorderFills(headerDoc);
|
|
26213
26256
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
26214
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
26257
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _421 => _421.name, 'access', _422 => _422.match, 'call', _423 => _423(/(\d+)\.xml$/), 'optionalAccess', _424 => _424[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _425 => _425.name, 'access', _426 => _426.match, 'call', _427 => _427(/(\d+)\.xml$/), 'optionalAccess', _428 => _428[1]]), () => ( null))), () => ( 0))));
|
|
26215
26258
|
const tables = [];
|
|
26216
26259
|
let tableIndex = 0;
|
|
26217
26260
|
for (const f of sectionFiles) {
|
|
@@ -26525,7 +26568,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
26525
26568
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
26526
26569
|
function patchTableRows(input) {
|
|
26527
26570
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
26528
|
-
const xml = _optionalChain([ctx, 'access',
|
|
26571
|
+
const xml = _optionalChain([ctx, 'access', _429 => _429.scans, 'access', _430 => _430[scanTable.sectionIndex], 'optionalAccess', _431 => _431.xml]);
|
|
26529
26572
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
26530
26573
|
const numRows = table2.rows;
|
|
26531
26574
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -26692,7 +26735,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
26692
26735
|
const rr = scanTable.rowRanges[template];
|
|
26693
26736
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
26694
26737
|
const scan = scanSectionXml(wrapped, 0);
|
|
26695
|
-
const row = _optionalChain([scan, 'access',
|
|
26738
|
+
const row = _optionalChain([scan, 'access', _432 => _432.tables, 'access', _433 => _433[0], 'optionalAccess', _434 => _434.rows, 'access', _435 => _435[0]]);
|
|
26696
26739
|
if (!row || row.length !== cells.length) return null;
|
|
26697
26740
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
26698
26741
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -26735,7 +26778,7 @@ function rowHeightOf(fragment) {
|
|
|
26735
26778
|
}
|
|
26736
26779
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
26737
26780
|
const from = scanTable.start + tblOpenLen;
|
|
26738
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
26781
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _436 => _436.rowRanges, 'access', _437 => _437[0], 'optionalAccess', _438 => _438.start]), () => ( from));
|
|
26739
26782
|
const slice = xml.slice(from, to);
|
|
26740
26783
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
26741
26784
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -26924,9 +26967,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
26924
26967
|
});
|
|
26925
26968
|
}
|
|
26926
26969
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
26927
|
-
const irCell = _optionalChain([table2, 'access',
|
|
26970
|
+
const irCell = _optionalChain([table2, 'access', _439 => _439.cells, 'access', _440 => _440[oc.gridR], 'optionalAccess', _441 => _441[oc.gridC]]);
|
|
26928
26971
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
26929
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
26972
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _442 => _442.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
26930
26973
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
26931
26974
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
26932
26975
|
}
|
|
@@ -26994,7 +27037,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
26994
27037
|
};
|
|
26995
27038
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
26996
27039
|
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)");
|
|
26997
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27040
|
+
const irCell = _optionalChain([table2, 'access', _443 => _443.cells, 'access', _444 => _444[gridR], 'optionalAccess', _445 => _445[gridC]]);
|
|
26998
27041
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
26999
27042
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27000
27043
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27017,7 +27060,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27017
27060
|
if (newLines.length === 0) return 0;
|
|
27018
27061
|
const target = cell2.paragraphs[0];
|
|
27019
27062
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
27020
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
27063
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _446 => _446.scans, 'access', _447 => _447[target.sectionIndex], 'optionalAccess', _448 => _448.xml]));
|
|
27021
27064
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27022
27065
|
splices.push(...sp);
|
|
27023
27066
|
sectionIndex = target.sectionIndex;
|
|
@@ -27040,7 +27083,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27040
27083
|
}
|
|
27041
27084
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
27042
27085
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
27043
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
27086
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _449 => _449.scans, 'access', _450 => _450[nonEmpty[i].sectionIndex], 'optionalAccess', _451 => _451.xml]));
|
|
27044
27087
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27045
27088
|
splices.push(...sp);
|
|
27046
27089
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -27121,7 +27164,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27121
27164
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27122
27165
|
if (paths.length > 0) return paths;
|
|
27123
27166
|
}
|
|
27124
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27167
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
27125
27168
|
}
|
|
27126
27169
|
function sectionPathsFromManifest(xml) {
|
|
27127
27170
|
const attr = (tag, name) => {
|
|
@@ -27131,7 +27174,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27131
27174
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27132
27175
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27133
27176
|
const id = attr(m[1], "id");
|
|
27134
|
-
const href =
|
|
27177
|
+
const href = _chunkKKZATKQWcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27135
27178
|
if (id && href) idToHref.set(id, href);
|
|
27136
27179
|
}
|
|
27137
27180
|
const ordered = [];
|
|
@@ -27140,7 +27183,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27140
27183
|
if (href) ordered.push(href);
|
|
27141
27184
|
}
|
|
27142
27185
|
if (ordered.length > 0) return ordered;
|
|
27143
|
-
return Array.from(idToHref.values()).sort(
|
|
27186
|
+
return Array.from(idToHref.values()).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
27144
27187
|
}
|
|
27145
27188
|
|
|
27146
27189
|
// src/roundtrip/patcher.ts
|
|
@@ -27232,7 +27275,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
27232
27275
|
}
|
|
27233
27276
|
}
|
|
27234
27277
|
let verification;
|
|
27235
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27278
|
+
if (_optionalChain([options, 'optionalAccess', _452 => _452.verify]) !== false) {
|
|
27236
27279
|
try {
|
|
27237
27280
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
27238
27281
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -27250,17 +27293,17 @@ function buildOrigUnits(blocks) {
|
|
|
27250
27293
|
let chunk;
|
|
27251
27294
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27252
27295
|
const next = blocks[i + 1];
|
|
27253
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
27254
|
-
chunk =
|
|
27296
|
+
if (_optionalChain([next, 'optionalAccess', _453 => _453.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27297
|
+
chunk = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27255
27298
|
} else {
|
|
27256
|
-
chunk =
|
|
27299
|
+
chunk = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27257
27300
|
}
|
|
27258
27301
|
if (chunk) {
|
|
27259
27302
|
const subUnits = splitMarkdownUnits(chunk);
|
|
27260
27303
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
27261
27304
|
for (let s = 0; s < subUnits.length; s++) {
|
|
27262
27305
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
27263
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
27306
|
+
if (block.type === "table" && _optionalChain([block, 'access', _454 => _454.table, 'optionalAccess', _455 => _455.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
27264
27307
|
u.role = "caption";
|
|
27265
27308
|
}
|
|
27266
27309
|
units.push(u);
|
|
@@ -27371,7 +27414,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27371
27414
|
const ti = ctx.tableInsert;
|
|
27372
27415
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
27373
27416
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27374
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27417
|
+
if (!_optionalChain([mapping, 'optionalAccess', _456 => _456.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");
|
|
27375
27418
|
const para2 = mapping.para;
|
|
27376
27419
|
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");
|
|
27377
27420
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -27399,7 +27442,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27399
27442
|
}
|
|
27400
27443
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
27401
27444
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27402
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27445
|
+
if (!_optionalChain([mapping, 'optionalAccess', _457 => _457.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)");
|
|
27403
27446
|
if (block.text && block.text.includes("\n")) {
|
|
27404
27447
|
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)");
|
|
27405
27448
|
}
|
|
@@ -27430,7 +27473,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
27430
27473
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27431
27474
|
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");
|
|
27432
27475
|
}
|
|
27433
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
27476
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _458 => _458.scans, 'access', _459 => _459[mapping.para.sectionIndex], 'optionalAccess', _460 => _460.xml]));
|
|
27434
27477
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27435
27478
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27436
27479
|
return 1;
|
|
@@ -27619,7 +27662,7 @@ var Surgeon = (_class7 = class {
|
|
|
27619
27662
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
27620
27663
|
findEntry(path) {
|
|
27621
27664
|
const parts = path.replace(/^\//, "").split("/");
|
|
27622
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
27665
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _461 => _461.entries, 'access', _462 => _462[0], 'optionalAccess', _463 => _463.child]), () => ( -1));
|
|
27623
27666
|
let current;
|
|
27624
27667
|
for (const part of parts) {
|
|
27625
27668
|
const search = (idx) => {
|
|
@@ -27858,8 +27901,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
27858
27901
|
parts.push(header, data);
|
|
27859
27902
|
};
|
|
27860
27903
|
for (let i = 0; i < recs.length; i++) {
|
|
27861
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
27862
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
27904
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _464 => _464.get, 'call', _465 => _465(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
27905
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _466 => _466.get, 'call', _467 => _467(i)]), () => ( recs[i].data)));
|
|
27863
27906
|
}
|
|
27864
27907
|
return Buffer.concat(parts);
|
|
27865
27908
|
}
|
|
@@ -27977,7 +28020,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27977
28020
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
27978
28021
|
}
|
|
27979
28022
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
27980
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
28023
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _468 => _468.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
27981
28024
|
let flags;
|
|
27982
28025
|
try {
|
|
27983
28026
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -27999,7 +28042,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27999
28042
|
const scans = [];
|
|
28000
28043
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
28001
28044
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
28002
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
28045
|
+
if (!_optionalChain([entry, 'optionalAccess', _469 => _469.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
28003
28046
|
let stream;
|
|
28004
28047
|
try {
|
|
28005
28048
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -28050,7 +28093,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28050
28093
|
}
|
|
28051
28094
|
}
|
|
28052
28095
|
let verification;
|
|
28053
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28096
|
+
if (_optionalChain([options, 'optionalAccess', _470 => _470.verify]) !== false) {
|
|
28054
28097
|
try {
|
|
28055
28098
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
28056
28099
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -28140,7 +28183,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
28140
28183
|
for (const [key, scanCell] of scanTable.cells) {
|
|
28141
28184
|
const comma = key.indexOf(",");
|
|
28142
28185
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
28143
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
28186
|
+
const irCell = _optionalChain([irTable, 'access', _471 => _471.cells, 'access', _472 => _472[r], 'optionalAccess', _473 => _473[c]]);
|
|
28144
28187
|
if (!irCell) continue;
|
|
28145
28188
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
28146
28189
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -28176,7 +28219,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
28176
28219
|
}
|
|
28177
28220
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
28178
28221
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28179
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28222
|
+
if (!_optionalChain([mapping, 'optionalAccess', _474 => _474.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)");
|
|
28180
28223
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
28181
28224
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
28182
28225
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -28375,7 +28418,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
28375
28418
|
};
|
|
28376
28419
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
28377
28420
|
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)");
|
|
28378
|
-
const irCell = _optionalChain([table2, 'access',
|
|
28421
|
+
const irCell = _optionalChain([table2, 'access', _475 => _475.cells, 'access', _476 => _476[gridR], 'optionalAccess', _477 => _477[gridC]]);
|
|
28379
28422
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
28380
28423
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
28381
28424
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -28782,11 +28825,11 @@ var RULES2 = {
|
|
|
28782
28825
|
}
|
|
28783
28826
|
};
|
|
28784
28827
|
function redactText(text, options) {
|
|
28785
|
-
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28828
|
+
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _478 => _478.maskChar]), () => ( "\u25CF"));
|
|
28786
28829
|
if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
|
|
28787
28830
|
throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
|
|
28788
28831
|
}
|
|
28789
|
-
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28832
|
+
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.rules]), () => ( DEFAULT_REDACT_RULES));
|
|
28790
28833
|
const hits = [];
|
|
28791
28834
|
if (text === "" || enabled.length === 0) return { text, hits };
|
|
28792
28835
|
const occupied = [];
|
|
@@ -28841,8 +28884,8 @@ function sameBreadcrumb(a, b) {
|
|
|
28841
28884
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
28842
28885
|
}
|
|
28843
28886
|
function blocksToChunks(blocks, options) {
|
|
28844
|
-
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28845
|
-
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28887
|
+
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _480 => _480.granularity]), () => ( "section"));
|
|
28888
|
+
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _481 => _481.includeTableCells]), () => ( false));
|
|
28846
28889
|
const chunks = [];
|
|
28847
28890
|
const headingStack = [];
|
|
28848
28891
|
const listStack = [];
|
|
@@ -28856,12 +28899,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28856
28899
|
let run = null;
|
|
28857
28900
|
const flushRun = () => {
|
|
28858
28901
|
if (!run) return;
|
|
28859
|
-
push("text", run.breadcrumb,
|
|
28902
|
+
push("text", run.breadcrumb, _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28860
28903
|
run = null;
|
|
28861
28904
|
};
|
|
28862
28905
|
for (let i = 0; i < blocks.length; i++) {
|
|
28863
28906
|
const block = blocks[i];
|
|
28864
|
-
const md2 =
|
|
28907
|
+
const md2 = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28865
28908
|
if (!md2) continue;
|
|
28866
28909
|
if (block.type === "heading") {
|
|
28867
28910
|
flushRun();
|
|
@@ -28977,7 +29020,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28977
29020
|
const block = st.blocks[blockIndex];
|
|
28978
29021
|
if (!block) return void 0;
|
|
28979
29022
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
28980
|
-
const para2 = _optionalChain([st, 'access',
|
|
29023
|
+
const para2 = _optionalChain([st, 'access', _482 => _482.paraMap, 'access', _483 => _483.get, 'call', _484 => _484(blockIndex), 'optionalAccess', _485 => _485.para]);
|
|
28981
29024
|
if (!para2) return void 0;
|
|
28982
29025
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
28983
29026
|
}
|
|
@@ -29002,7 +29045,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29002
29045
|
if (block.text && block.text.includes("\n")) {
|
|
29003
29046
|
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)" };
|
|
29004
29047
|
}
|
|
29005
|
-
if (!_optionalChain([st, 'access',
|
|
29048
|
+
if (!_optionalChain([st, 'access', _486 => _486.paraMap, 'access', _487 => _487.get, 'call', _488 => _488(blockIndex), 'optionalAccess', _489 => _489.para])) {
|
|
29006
29049
|
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)" };
|
|
29007
29050
|
}
|
|
29008
29051
|
return { capability: "text" };
|
|
@@ -29068,7 +29111,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29068
29111
|
continue;
|
|
29069
29112
|
}
|
|
29070
29113
|
if (block.type === "table" && block.table) {
|
|
29071
|
-
if (!_optionalChain([edit, 'access',
|
|
29114
|
+
if (!_optionalChain([edit, 'access', _490 => _490.cells, 'optionalAccess', _491 => _491.length])) {
|
|
29072
29115
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
29073
29116
|
continue;
|
|
29074
29117
|
}
|
|
@@ -29088,7 +29131,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29088
29131
|
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) });
|
|
29089
29132
|
continue;
|
|
29090
29133
|
}
|
|
29091
|
-
const irCell = _optionalChain([block, 'access',
|
|
29134
|
+
const irCell = _optionalChain([block, 'access', _492 => _492.table, 'access', _493 => _493.cells, 'access', _494 => _494[cellEdit.row], 'optionalAccess', _495 => _495[cellEdit.col]]);
|
|
29092
29135
|
if (!irCell) {
|
|
29093
29136
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
29094
29137
|
continue;
|
|
@@ -29144,7 +29187,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29144
29187
|
}
|
|
29145
29188
|
if (replacements.size === 0) {
|
|
29146
29189
|
let changes2;
|
|
29147
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29190
|
+
if (_optionalChain([options, 'optionalAccess', _496 => _496.verify]) !== false) {
|
|
29148
29191
|
const units = splitMarkdownUnits(st.markdown);
|
|
29149
29192
|
changes2 = diffUnitLists(units, units);
|
|
29150
29193
|
}
|
|
@@ -29165,7 +29208,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29165
29208
|
}
|
|
29166
29209
|
this.state = newState;
|
|
29167
29210
|
let changes;
|
|
29168
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29211
|
+
if (_optionalChain([options, 'optionalAccess', _497 => _497.verify]) !== false) {
|
|
29169
29212
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
29170
29213
|
}
|
|
29171
29214
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -29185,7 +29228,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29185
29228
|
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)");
|
|
29186
29229
|
}
|
|
29187
29230
|
const mapping = st.paraMap.get(blockIndex);
|
|
29188
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
29231
|
+
if (!_optionalChain([mapping, 'optionalAccess', _498 => _498.para])) {
|
|
29189
29232
|
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)");
|
|
29190
29233
|
}
|
|
29191
29234
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -29205,14 +29248,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29205
29248
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
29206
29249
|
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");
|
|
29207
29250
|
}
|
|
29208
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
29251
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _499 => _499.scans, 'access', _500 => _500[mapping.para.sectionIndex], 'optionalAccess', _501 => _501.xml]));
|
|
29209
29252
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
29210
29253
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
29211
29254
|
return 1;
|
|
29212
29255
|
}
|
|
29213
29256
|
}, _class8);
|
|
29214
29257
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
29215
|
-
const irCell = _optionalChain([table2, 'access',
|
|
29258
|
+
const irCell = _optionalChain([table2, 'access', _502 => _502.cells, 'access', _503 => _503[r], 'optionalAccess', _504 => _504[c]]);
|
|
29216
29259
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
29217
29260
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
29218
29261
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -29296,11 +29339,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
29296
29339
|
breaks: false
|
|
29297
29340
|
});
|
|
29298
29341
|
function renderHtml(markdown, options) {
|
|
29299
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29300
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29342
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _505 => _505.preset]), () => ( "default"));
|
|
29343
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _506 => _506.extraCss]), () => ( "")));
|
|
29301
29344
|
const body = md.render(markdown);
|
|
29302
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
29303
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
29345
|
+
const watermark = _optionalChain([options, 'optionalAccess', _507 => _507.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
29346
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _508 => _508.watermark]) ? `
|
|
29304
29347
|
.watermark {
|
|
29305
29348
|
position: fixed;
|
|
29306
29349
|
top: 50%; left: 50%;
|
|
@@ -29331,13 +29374,13 @@ async function htmlToPdf(html, options) {
|
|
|
29331
29374
|
try {
|
|
29332
29375
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29333
29376
|
} catch (e32) {
|
|
29334
|
-
throw new (0,
|
|
29377
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
29335
29378
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29336
29379
|
);
|
|
29337
29380
|
}
|
|
29338
29381
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29339
29382
|
if (!executablePath) {
|
|
29340
|
-
throw new (0,
|
|
29383
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
29341
29384
|
"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."
|
|
29342
29385
|
);
|
|
29343
29386
|
}
|
|
@@ -29349,10 +29392,10 @@ async function htmlToPdf(html, options) {
|
|
|
29349
29392
|
try {
|
|
29350
29393
|
const page = await browser.newPage();
|
|
29351
29394
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
29352
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
29395
|
+
const margin = _optionalChain([options, 'optionalAccess', _509 => _509.margin]);
|
|
29353
29396
|
const pdf = await page.pdf({
|
|
29354
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29355
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
29397
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _510 => _510.pageSize]), () => ( "A4")),
|
|
29398
|
+
landscape: _optionalChain([options, 'optionalAccess', _511 => _511.orientation]) === "landscape",
|
|
29356
29399
|
printBackground: true,
|
|
29357
29400
|
margin: margin ? {
|
|
29358
29401
|
top: toCss(margin.top),
|
|
@@ -29360,9 +29403,9 @@ async function htmlToPdf(html, options) {
|
|
|
29360
29403
|
bottom: toCss(margin.bottom),
|
|
29361
29404
|
left: toCss(margin.left)
|
|
29362
29405
|
} : void 0,
|
|
29363
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
29364
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29365
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29406
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _512 => _512.header]) || _optionalChain([options, 'optionalAccess', _513 => _513.footer])),
|
|
29407
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _514 => _514.header]), () => ( "<div></div>")),
|
|
29408
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _515 => _515.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
29366
29409
|
});
|
|
29367
29410
|
return Buffer.from(pdf);
|
|
29368
29411
|
} finally {
|
|
@@ -29396,7 +29439,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29396
29439
|
return htmlToPdf(html, options);
|
|
29397
29440
|
}
|
|
29398
29441
|
async function blocksToPdf(blocks, options) {
|
|
29399
|
-
const markdown =
|
|
29442
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29400
29443
|
return markdownToPdf(markdown, options);
|
|
29401
29444
|
}
|
|
29402
29445
|
|
|
@@ -29575,7 +29618,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
29575
29618
|
}
|
|
29576
29619
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
29577
29620
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
29578
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
29621
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _516 => _516.getAttribute, 'call', _517 => _517("vertRelTo")]), () => ( "PARA"));
|
|
29579
29622
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
29580
29623
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
29581
29624
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -29636,7 +29679,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29636
29679
|
if (ln(p) !== "p") continue;
|
|
29637
29680
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
29638
29681
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
29639
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29682
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _518 => _518.spaceBefore]), () => ( 0)));
|
|
29640
29683
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
29641
29684
|
if (!res) {
|
|
29642
29685
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -29649,7 +29692,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29649
29692
|
}
|
|
29650
29693
|
if (Number.isFinite(bottom)) {
|
|
29651
29694
|
cursorV = bottom;
|
|
29652
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29695
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _519 => _519.spaceAfter]), () => ( 0));
|
|
29653
29696
|
}
|
|
29654
29697
|
}
|
|
29655
29698
|
continue;
|
|
@@ -29759,7 +29802,7 @@ function buildPara(p) {
|
|
|
29759
29802
|
el: ch,
|
|
29760
29803
|
tag: cn,
|
|
29761
29804
|
index: chars.length,
|
|
29762
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
29805
|
+
inline: _optionalChain([pos, 'optionalAccess', _520 => _520.getAttribute, 'call', _521 => _521("treatAsChar")]) === "1",
|
|
29763
29806
|
width: w,
|
|
29764
29807
|
height: h
|
|
29765
29808
|
});
|
|
@@ -30011,15 +30054,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30011
30054
|
const sx = ow > 0 ? w / ow : 1;
|
|
30012
30055
|
const sy = oh > 0 ? h / oh : 1;
|
|
30013
30056
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
30014
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
30015
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
30057
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _522 => _522.getAttribute, 'call', _523 => _523("style")]), () => ( "SOLID"));
|
|
30058
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _524 => _524.getAttribute, 'call', _525 => _525("color")]) || "#000000";
|
|
30016
30059
|
const hasStroke = lstyle !== "NONE";
|
|
30017
30060
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
30018
30061
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
30019
30062
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
30020
30063
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
30021
30064
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
30022
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
30065
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _526 => _526.getAttribute, 'call', _527 => _527("faceColor")]);
|
|
30023
30066
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
30024
30067
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
30025
30068
|
if (o.tag === "rect") {
|
|
@@ -30046,14 +30089,14 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30046
30089
|
}
|
|
30047
30090
|
function cellContentExtent(cell2, memo) {
|
|
30048
30091
|
if (!cell2.sub) return 0;
|
|
30049
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30092
|
+
const hit = _optionalChain([memo, 'optionalAccess', _528 => _528.cell, 'access', _529 => _529.get, 'call', _530 => _530(cell2.el)]);
|
|
30050
30093
|
if (hit !== void 0) return hit;
|
|
30051
30094
|
let ext = 0;
|
|
30052
30095
|
for (const p of elements2(cell2.sub)) {
|
|
30053
30096
|
if (ln2(p) !== "p") continue;
|
|
30054
30097
|
const m = buildPara(p);
|
|
30055
30098
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
30056
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
30099
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _531 => _531.segs, 'access', _532 => _532[0], 'optionalAccess', _533 => _533.vertpos]), () => ( 0));
|
|
30057
30100
|
for (const o of m.objs) {
|
|
30058
30101
|
if (o.inline) {
|
|
30059
30102
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
@@ -30061,14 +30104,14 @@ function cellContentExtent(cell2, memo) {
|
|
|
30061
30104
|
continue;
|
|
30062
30105
|
}
|
|
30063
30106
|
const pos = findChildByLocalName(o.el, "pos");
|
|
30064
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30107
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _534 => _534.getAttribute, 'call', _535 => _535("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
30065
30108
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
30066
30109
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
30067
30110
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
30068
30111
|
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
30069
30112
|
}
|
|
30070
30113
|
}
|
|
30071
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30114
|
+
_optionalChain([memo, 'optionalAccess', _536 => _536.cell, 'access', _537 => _537.set, 'call', _538 => _538(cell2.el, ext)]);
|
|
30072
30115
|
return ext;
|
|
30073
30116
|
}
|
|
30074
30117
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
@@ -30110,7 +30153,7 @@ function collectCells(tbl2) {
|
|
|
30110
30153
|
return cells;
|
|
30111
30154
|
}
|
|
30112
30155
|
function measureTableHeight(tbl2, memo) {
|
|
30113
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30156
|
+
const hit = _optionalChain([memo, 'optionalAccess', _539 => _539.table, 'access', _540 => _540.get, 'call', _541 => _541(tbl2)]);
|
|
30114
30157
|
if (hit !== void 0) return hit;
|
|
30115
30158
|
const cells = collectCells(tbl2);
|
|
30116
30159
|
if (cells.length === 0 || cells.length > 4096) return 0;
|
|
@@ -30121,7 +30164,7 @@ function measureTableHeight(tbl2, memo) {
|
|
|
30121
30164
|
);
|
|
30122
30165
|
let sum = 0;
|
|
30123
30166
|
for (const h of rowH) sum += h;
|
|
30124
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30167
|
+
_optionalChain([memo, 'optionalAccess', _542 => _542.table, 'access', _543 => _543.set, 'call', _544 => _544(tbl2, sum)]);
|
|
30125
30168
|
return sum;
|
|
30126
30169
|
}
|
|
30127
30170
|
function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
@@ -30152,7 +30195,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
30152
30195
|
}));
|
|
30153
30196
|
for (const g of geom) {
|
|
30154
30197
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
30155
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
30198
|
+
if (_optionalChain([bf, 'optionalAccess', _545 => _545.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
30156
30199
|
}
|
|
30157
30200
|
for (const g of geom) {
|
|
30158
30201
|
const { c } = g;
|
|
@@ -30190,7 +30233,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
30190
30233
|
const sz = findChildByLocalName(pic, "sz");
|
|
30191
30234
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
30192
30235
|
const img = findFirst(pic, "img");
|
|
30193
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
30236
|
+
const ref = _optionalChain([img, 'optionalAccess', _546 => _546.getAttribute, 'call', _547 => _547("binaryItemIDRef")]);
|
|
30194
30237
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
30195
30238
|
if (!loaded) {
|
|
30196
30239
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -30230,7 +30273,7 @@ function readSectionGeom(root) {
|
|
|
30230
30273
|
const pagePr = findFirst(root, "pagePr");
|
|
30231
30274
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
30232
30275
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
30233
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
30276
|
+
if (_optionalChain([pagePr, 'optionalAccess', _548 => _548.getAttribute, 'call', _549 => _549("landscape")]) === "NARROWLY" && PW < PH) {
|
|
30234
30277
|
const t = PW;
|
|
30235
30278
|
PW = PH;
|
|
30236
30279
|
PH = t;
|
|
@@ -30288,17 +30331,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30288
30331
|
return { pages: ctx.pages, pageH };
|
|
30289
30332
|
}
|
|
30290
30333
|
async function renderHwpxToSvg(input, options) {
|
|
30291
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30334
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _550 => _550.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30292
30335
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30293
|
-
|
|
30336
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30294
30337
|
let zip;
|
|
30295
30338
|
try {
|
|
30296
30339
|
zip = await _jszip2.default.loadAsync(input);
|
|
30297
30340
|
} catch (e33) {
|
|
30298
|
-
throw new (0,
|
|
30341
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30299
30342
|
}
|
|
30300
30343
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30301
|
-
if (secFiles.length === 0) throw new (0,
|
|
30344
|
+
if (secFiles.length === 0) throw new (0, _chunkKKZATKQWcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30302
30345
|
const warnings = [];
|
|
30303
30346
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30304
30347
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30306,7 +30349,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30306
30349
|
const secXmls = [];
|
|
30307
30350
|
for (const f of secFiles) {
|
|
30308
30351
|
const xml = await f.async("string");
|
|
30309
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30352
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkKKZATKQWcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30310
30353
|
secXmls.push(xml);
|
|
30311
30354
|
}
|
|
30312
30355
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30330,7 +30373,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30330
30373
|
let href = binmap.get(ref);
|
|
30331
30374
|
if (!href) {
|
|
30332
30375
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
30333
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
30376
|
+
href = _optionalChain([cand, 'optionalAccess', _551 => _551.name]);
|
|
30334
30377
|
}
|
|
30335
30378
|
if (!href) continue;
|
|
30336
30379
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -30351,7 +30394,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30351
30394
|
styles,
|
|
30352
30395
|
images,
|
|
30353
30396
|
defs: [],
|
|
30354
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30397
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _552 => _552.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
30355
30398
|
warnings,
|
|
30356
30399
|
warned: /* @__PURE__ */ new Set(),
|
|
30357
30400
|
stats: { texts: 0, images: 0, tables: 0 },
|
|
@@ -30362,7 +30405,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30362
30405
|
for (let si = 0; si < secXmls.length; si++) {
|
|
30363
30406
|
const secXml = secXmls[si];
|
|
30364
30407
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
30365
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
30408
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _553 => _553.reflow])) {
|
|
30366
30409
|
noCacheSkipped = true;
|
|
30367
30410
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
30368
30411
|
continue;
|
|
@@ -30374,14 +30417,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30374
30417
|
continue;
|
|
30375
30418
|
}
|
|
30376
30419
|
const geom = readSectionGeom(root);
|
|
30377
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess',
|
|
30420
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _554 => _554.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.reflowMode]), () => ( "keep")));
|
|
30378
30421
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
30379
30422
|
}
|
|
30380
30423
|
if (rendered.length === 0) {
|
|
30381
30424
|
if (noCacheSkipped) {
|
|
30382
|
-
throw new (0,
|
|
30425
|
+
throw new (0, _chunkKKZATKQWcjs.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)");
|
|
30383
30426
|
}
|
|
30384
|
-
throw new (0,
|
|
30427
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30385
30428
|
}
|
|
30386
30429
|
const GAP = 2400;
|
|
30387
30430
|
const clipDefs = [];
|
|
@@ -30413,17 +30456,17 @@ ${groups.join("\n")}
|
|
|
30413
30456
|
// src/index.ts
|
|
30414
30457
|
async function parse(input, options) {
|
|
30415
30458
|
let buffer;
|
|
30416
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
30459
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _556 => _556.filePath]) ? { ...options, filePath: input } : options;
|
|
30417
30460
|
if (typeof input === "string") {
|
|
30418
30461
|
try {
|
|
30419
30462
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30420
|
-
buffer =
|
|
30463
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, buf);
|
|
30421
30464
|
} catch (err) {
|
|
30422
30465
|
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}`;
|
|
30423
30466
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30424
30467
|
}
|
|
30425
30468
|
} else if (Buffer.isBuffer(input)) {
|
|
30426
|
-
buffer =
|
|
30469
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, input);
|
|
30427
30470
|
} else {
|
|
30428
30471
|
buffer = input;
|
|
30429
30472
|
}
|
|
@@ -30449,30 +30492,48 @@ async function parse(input, options) {
|
|
|
30449
30492
|
return parseHwpml(buffer, opts);
|
|
30450
30493
|
case "pdf":
|
|
30451
30494
|
return parsePdf(buffer, opts);
|
|
30495
|
+
case "image":
|
|
30496
|
+
return parseImage(buffer, opts);
|
|
30452
30497
|
default:
|
|
30453
30498
|
return { success: false, fileType: "unknown", error: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD\uC785\uB2C8\uB2E4.", code: "UNSUPPORTED_FORMAT" };
|
|
30454
30499
|
}
|
|
30455
30500
|
}
|
|
30501
|
+
async function parseImage(buffer, options) {
|
|
30502
|
+
try {
|
|
30503
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-3AFBDDJI.cjs")));
|
|
30504
|
+
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30505
|
+
return {
|
|
30506
|
+
success: true,
|
|
30507
|
+
fileType: "image",
|
|
30508
|
+
markdown: _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30509
|
+
blocks,
|
|
30510
|
+
warnings: warnings.length ? warnings : void 0,
|
|
30511
|
+
pageCount: 1
|
|
30512
|
+
};
|
|
30513
|
+
} catch (err) {
|
|
30514
|
+
return { success: false, fileType: "image", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30515
|
+
}
|
|
30516
|
+
}
|
|
30456
30517
|
async function parseHwp3(buffer, options) {
|
|
30457
30518
|
try {
|
|
30458
30519
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30459
30520
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30460
30521
|
} catch (err) {
|
|
30461
|
-
return { success: false, fileType: "hwp3", error:
|
|
30522
|
+
return { success: false, fileType: "hwp3", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30462
30523
|
}
|
|
30463
30524
|
}
|
|
30464
30525
|
async function parseHwpx(buffer, options) {
|
|
30465
30526
|
try {
|
|
30466
30527
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30467
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30528
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _557 => _557.length]) ? images : void 0 };
|
|
30468
30529
|
} catch (err) {
|
|
30469
|
-
return { success: false, fileType: "hwpx", error:
|
|
30530
|
+
return { success: false, fileType: "hwpx", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30470
30531
|
}
|
|
30471
30532
|
}
|
|
30472
30533
|
async function parseHwp(buffer, options) {
|
|
30473
30534
|
try {
|
|
30474
30535
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
30475
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
30536
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _558 => _558.filePath])) {
|
|
30476
30537
|
try {
|
|
30477
30538
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
30478
30539
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -30489,15 +30550,15 @@ async function parseHwp(buffer, options) {
|
|
|
30489
30550
|
} catch (e34) {
|
|
30490
30551
|
}
|
|
30491
30552
|
}
|
|
30492
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30553
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _559 => _559.length]) ? images : void 0 };
|
|
30493
30554
|
} catch (err) {
|
|
30494
|
-
return { success: false, fileType: "hwp", error:
|
|
30555
|
+
return { success: false, fileType: "hwp", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30495
30556
|
}
|
|
30496
30557
|
}
|
|
30497
30558
|
async function parsePdf(buffer, options) {
|
|
30498
30559
|
let parsePdfDocument;
|
|
30499
30560
|
try {
|
|
30500
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30561
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-MRM6WICO.cjs")));
|
|
30501
30562
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30502
30563
|
} catch (e35) {
|
|
30503
30564
|
return {
|
|
@@ -30512,7 +30573,7 @@ async function parsePdf(buffer, options) {
|
|
|
30512
30573
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30513
30574
|
} catch (err) {
|
|
30514
30575
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30515
|
-
return { success: false, fileType: "pdf", error:
|
|
30576
|
+
return { success: false, fileType: "pdf", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err), isImageBased };
|
|
30516
30577
|
}
|
|
30517
30578
|
}
|
|
30518
30579
|
async function parseXlsx(buffer, options) {
|
|
@@ -30520,7 +30581,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30520
30581
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30521
30582
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30522
30583
|
} catch (err) {
|
|
30523
|
-
return { success: false, fileType: "xlsx", error:
|
|
30584
|
+
return { success: false, fileType: "xlsx", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30524
30585
|
}
|
|
30525
30586
|
}
|
|
30526
30587
|
async function parseXls(buffer, options) {
|
|
@@ -30528,15 +30589,15 @@ async function parseXls(buffer, options) {
|
|
|
30528
30589
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30529
30590
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30530
30591
|
} catch (err) {
|
|
30531
|
-
return { success: false, fileType: "xls", error:
|
|
30592
|
+
return { success: false, fileType: "xls", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30532
30593
|
}
|
|
30533
30594
|
}
|
|
30534
30595
|
async function parseDocx(buffer, options) {
|
|
30535
30596
|
try {
|
|
30536
30597
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30537
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30598
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _560 => _560.length]) ? images : void 0 };
|
|
30538
30599
|
} catch (err) {
|
|
30539
|
-
return { success: false, fileType: "docx", error:
|
|
30600
|
+
return { success: false, fileType: "docx", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30540
30601
|
}
|
|
30541
30602
|
}
|
|
30542
30603
|
async function parseHwpml(buffer, options) {
|
|
@@ -30544,16 +30605,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30544
30605
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30545
30606
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30546
30607
|
} catch (err) {
|
|
30547
|
-
return { success: false, fileType: "hwpml", error:
|
|
30608
|
+
return { success: false, fileType: "hwpml", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30548
30609
|
}
|
|
30549
30610
|
}
|
|
30550
30611
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30551
30612
|
let buffer;
|
|
30552
30613
|
if (typeof input === "string") {
|
|
30553
30614
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30554
|
-
buffer =
|
|
30615
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, buf);
|
|
30555
30616
|
} else if (Buffer.isBuffer(input)) {
|
|
30556
|
-
buffer =
|
|
30617
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, input);
|
|
30557
30618
|
} else {
|
|
30558
30619
|
buffer = input;
|
|
30559
30620
|
}
|
|
@@ -30579,7 +30640,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30579
30640
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30580
30641
|
}
|
|
30581
30642
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30582
|
-
const markdown =
|
|
30643
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30583
30644
|
if (outputFormat === "hwpx") {
|
|
30584
30645
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30585
30646
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30652,5 +30713,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30652
30713
|
|
|
30653
30714
|
|
|
30654
30715
|
|
|
30655
|
-
|
|
30716
|
+
|
|
30717
|
+
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 = _chunkKKZATKQWcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkWMU2KJHFcjs.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;
|
|
30656
30718
|
//# sourceMappingURL=index.cjs.map
|