kordoc 4.2.1 → 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 +5 -0
- package/dist/{-BSO3CDQQ.js → -NFHVGTVM.js} +9 -9
- package/dist/{chunk-Z6LPEWIX.js → chunk-2L7MIKOM.js} +3 -3
- package/dist/chunk-2L7MIKOM.js.map +1 -0
- package/dist/{chunk-35U3MVA2.cjs → chunk-DLFZAU4X.cjs} +3 -3
- package/dist/{chunk-35U3MVA2.cjs.map → chunk-DLFZAU4X.cjs.map} +1 -1
- package/dist/{chunk-QSB2RTX5.js → chunk-DSL6EVFJ.js} +6 -4
- package/dist/chunk-DSL6EVFJ.js.map +1 -0
- package/dist/{chunk-R22KDUKW.cjs → chunk-EFF2JPPA.cjs} +9 -9
- package/dist/{chunk-R22KDUKW.cjs.map → chunk-EFF2JPPA.cjs.map} +1 -1
- package/dist/{chunk-BHILWIE6.js → chunk-FHYLLKIP.js} +3 -3
- package/dist/chunk-FHYLLKIP.js.map +1 -0
- package/dist/{chunk-PLTG6ZRF.js → chunk-GHMVNMUN.js} +3 -3
- package/dist/{chunk-HTCKGSSW.js → chunk-GUYIXVV7.js} +3 -3
- package/dist/chunk-GUYIXVV7.js.map +1 -0
- package/dist/{chunk-7IMNZ2BL.js → chunk-IXHBRMDB.js} +6 -4
- package/dist/chunk-IXHBRMDB.js.map +1 -0
- package/dist/{chunk-RBUBZ2TA.cjs → chunk-KKZATKQW.cjs} +3 -3
- package/dist/chunk-KKZATKQW.cjs.map +1 -0
- package/dist/{chunk-QOC7S5VE.js → chunk-L5B7PQOP.js} +2 -2
- package/dist/{chunk-WJSGYVFD.js → chunk-LUJN3VFB.js} +3 -3
- package/dist/{chunk-KRAYUNFM.js → chunk-MOOVF6CT.js} +2 -2
- package/dist/{chunk-BKBYTPSL.js → chunk-MYD3QLBL.js} +2 -2
- package/dist/{chunk-L5JWKIOT.js → chunk-OLDIDBJ2.js} +3 -3
- package/dist/{chunk-F5ECB53I.js → chunk-T4AWY45Q.js} +2 -2
- package/dist/{chunk-WWYAYZ5U.js → chunk-TXYQJXOV.js} +48 -14
- package/dist/chunk-TXYQJXOV.js.map +1 -0
- package/dist/{chunk-LSXXGUWA.cjs → chunk-WMU2KJHF.cjs} +8 -6
- package/dist/chunk-WMU2KJHF.cjs.map +1 -0
- package/dist/{chunk-EZHWPKCH.js → chunk-X77U36TV.js} +2 -2
- package/dist/{chunk-54WVWWT4.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 +17 -17
- package/dist/{image-ocr-N5Z32R4U.cjs → image-ocr-3AFBDDJI.cjs} +9 -9
- package/dist/{image-ocr-N5Z32R4U.cjs.map → image-ocr-3AFBDDJI.cjs.map} +1 -1
- package/dist/{image-ocr-SLUEM3FA.js → image-ocr-S4REURLR.js} +5 -5
- package/dist/{image-ocr-DALT7PFQ.js → image-ocr-TGHAMIQL.js} +4 -4
- package/dist/index.cjs +446 -412
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +44 -10
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +15 -15
- package/dist/{parser-F5KY3YSD.js → parser-C3APVZGT.js} +6 -6
- package/dist/{parser-33TK5SMH.js → parser-KMC4YOZH.js} +5 -5
- package/dist/{parser-R4CXIXRN.cjs → parser-MRM6WICO.cjs} +24 -24
- package/dist/{parser-R4CXIXRN.cjs.map → parser-MRM6WICO.cjs.map} +1 -1
- package/dist/pdf-ocr-5BRMIJAT.cjs +13 -0
- package/dist/{pdf-ocr-WGWZDHMV.cjs.map → pdf-ocr-5BRMIJAT.cjs.map} +1 -1
- package/dist/pdf-ocr-UDTEQEWA.js +12 -0
- package/dist/{pdf-ocr-BXQZKU3N.js → pdf-ocr-UURMV6FD.js} +5 -5
- package/dist/{profile-io-CBYHKLFU.js → profile-io-RLQ62KS5.js} +3 -3
- package/dist/{rasterize-AWMM2CSW.js → rasterize-LBABF2WI.js} +2 -2
- package/dist/render-CYXQEHS7.js +10 -0
- package/dist/seal-SV6PFFYU.js +10 -0
- package/dist/{watch-HKXCISVO.js → watch-XEUEGOXW.js} +9 -9
- package/package.json +1 -1
- package/dist/chunk-54WVWWT4.js.map +0 -1
- package/dist/chunk-7IMNZ2BL.js.map +0 -1
- package/dist/chunk-BHILWIE6.js.map +0 -1
- package/dist/chunk-HTCKGSSW.js.map +0 -1
- package/dist/chunk-LSXXGUWA.cjs.map +0 -1
- package/dist/chunk-QSB2RTX5.js.map +0 -1
- package/dist/chunk-RBUBZ2TA.cjs.map +0 -1
- package/dist/chunk-WWYAYZ5U.js.map +0 -1
- package/dist/chunk-Z6LPEWIX.js.map +0 -1
- package/dist/chunks-LRFS5NJE.js +0 -10
- package/dist/pdf-ocr-34F5AQKK.js +0 -12
- package/dist/pdf-ocr-WGWZDHMV.cjs +0 -13
- package/dist/render-Y3IE2FIK.js +0 -10
- package/dist/seal-7RXFCRMT.js +0 -10
- /package/dist/{-BSO3CDQQ.js.map → -NFHVGTVM.js.map} +0 -0
- /package/dist/{chunk-PLTG6ZRF.js.map → chunk-GHMVNMUN.js.map} +0 -0
- /package/dist/{chunk-QOC7S5VE.js.map → chunk-L5B7PQOP.js.map} +0 -0
- /package/dist/{chunk-WJSGYVFD.js.map → chunk-LUJN3VFB.js.map} +0 -0
- /package/dist/{chunk-KRAYUNFM.js.map → chunk-MOOVF6CT.js.map} +0 -0
- /package/dist/{chunk-BKBYTPSL.js.map → chunk-MYD3QLBL.js.map} +0 -0
- /package/dist/{chunk-L5JWKIOT.js.map → chunk-OLDIDBJ2.js.map} +0 -0
- /package/dist/{chunk-F5ECB53I.js.map → chunk-T4AWY45Q.js.map} +0 -0
- /package/dist/{chunk-EZHWPKCH.js.map → chunk-X77U36TV.js.map} +0 -0
- /package/dist/{chunks-LRFS5NJE.js.map → chunks-N4CWHTJI.js.map} +0 -0
- /package/dist/{image-ocr-SLUEM3FA.js.map → image-ocr-S4REURLR.js.map} +0 -0
- /package/dist/{image-ocr-DALT7PFQ.js.map → image-ocr-TGHAMIQL.js.map} +0 -0
- /package/dist/{parser-F5KY3YSD.js.map → parser-C3APVZGT.js.map} +0 -0
- /package/dist/{parser-33TK5SMH.js.map → parser-KMC4YOZH.js.map} +0 -0
- /package/dist/{pdf-ocr-34F5AQKK.js.map → pdf-ocr-UDTEQEWA.js.map} +0 -0
- /package/dist/{pdf-ocr-BXQZKU3N.js.map → pdf-ocr-UURMV6FD.js.map} +0 -0
- /package/dist/{profile-io-CBYHKLFU.js.map → profile-io-RLQ62KS5.js.map} +0 -0
- /package/dist/{rasterize-AWMM2CSW.js.map → rasterize-LBABF2WI.js.map} +0 -0
- /package/dist/{render-Y3IE2FIK.js.map → render-CYXQEHS7.js.map} +0 -0
- /package/dist/{seal-7RXFCRMT.js.map → seal-SV6PFFYU.js.map} +0 -0
- /package/dist/{watch-HKXCISVO.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');
|
|
@@ -411,9 +411,9 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
411
411
|
|
|
412
412
|
// src/hwpx/parser-shared.ts
|
|
413
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
414
|
-
var MAX_DECOMPRESS_SIZE =
|
|
414
|
+
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
415
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
416
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkKKZATKQWcjs.KordocError {
|
|
417
417
|
constructor(message) {
|
|
418
418
|
super(message);
|
|
419
419
|
this.name = "ZipBombError";
|
|
@@ -429,7 +429,7 @@ function createSectionShared() {
|
|
|
429
429
|
function createXmlParser(warnings) {
|
|
430
430
|
return new (0, _xmldom.DOMParser)({
|
|
431
431
|
onError(level, msg2) {
|
|
432
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkKKZATKQWcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
433
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -468,6 +468,26 @@ function extractTextFromNode(node, depth = 0) {
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
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
|
+
}
|
|
471
491
|
async function extractHwpxStyles(zip, decompressed) {
|
|
472
492
|
const result = {
|
|
473
493
|
charProperties: /* @__PURE__ */ new Map(),
|
|
@@ -486,10 +506,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
486
506
|
const xml = await file.async("text");
|
|
487
507
|
if (decompressed) {
|
|
488
508
|
decompressed.total += xml.length * 2;
|
|
489
|
-
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)");
|
|
490
510
|
}
|
|
491
511
|
const parser = createXmlParser();
|
|
492
|
-
const doc = parser.parseFromString(
|
|
512
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
493
513
|
if (!doc.documentElement) continue;
|
|
494
514
|
const domDoc = doc;
|
|
495
515
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -532,6 +552,10 @@ function parseCharProperties(doc, map) {
|
|
|
532
552
|
const localTag = (k.tagName || "").replace(/^[^:]+:/, "");
|
|
533
553
|
if (localTag === "bold") prop.bold = true;
|
|
534
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
|
+
}
|
|
535
559
|
}
|
|
536
560
|
const fontFaces = el.getElementsByTagName("*");
|
|
537
561
|
for (let j = 0; j < fontFaces.length; j++) {
|
|
@@ -672,9 +696,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
672
696
|
let level = 0;
|
|
673
697
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
674
698
|
const ratio = block.style.fontSize / baseFontSize;
|
|
675
|
-
if (ratio >=
|
|
676
|
-
else if (ratio >=
|
|
677
|
-
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;
|
|
678
702
|
}
|
|
679
703
|
const compactText = text.replace(/\s+/g, "");
|
|
680
704
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1599,7 +1623,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1599
1623
|
}
|
|
1600
1624
|
function assertFiniteRange(name, value, min, max) {
|
|
1601
1625
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1602
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1603
1627
|
}
|
|
1604
1628
|
}
|
|
1605
1629
|
function validateGongmunOptions(opts) {
|
|
@@ -1614,10 +1638,10 @@ function validateGongmunOptions(opts) {
|
|
|
1614
1638
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1615
1639
|
}
|
|
1616
1640
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1617
|
-
throw new (0,
|
|
1641
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1618
1642
|
}
|
|
1619
1643
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1620
|
-
throw new (0,
|
|
1644
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1621
1645
|
}
|
|
1622
1646
|
}
|
|
1623
1647
|
if (opts.sizes) {
|
|
@@ -1626,7 +1650,7 @@ function validateGongmunOptions(opts) {
|
|
|
1626
1650
|
}
|
|
1627
1651
|
}
|
|
1628
1652
|
if (opts.approval && opts.approval.length > 6) {
|
|
1629
|
-
throw new (0,
|
|
1653
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("approval must contain at most 6 labels");
|
|
1630
1654
|
}
|
|
1631
1655
|
}
|
|
1632
1656
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1891,7 +1915,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1891
1915
|
|
|
1892
1916
|
// src/hwpx/table-build.ts
|
|
1893
1917
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1894
|
-
const table2 =
|
|
1918
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1895
1919
|
if (state.caption) table2.caption = state.caption;
|
|
1896
1920
|
const anchors = [];
|
|
1897
1921
|
{
|
|
@@ -1961,7 +1985,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1961
1985
|
const cell2 = parentTable.cell;
|
|
1962
1986
|
(cell2.blocks ??= []).push(block);
|
|
1963
1987
|
cell2.hasStructure = true;
|
|
1964
|
-
let flat =
|
|
1988
|
+
let flat = _chunkWMU2KJHFcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1965
1989
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1966
1990
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1967
1991
|
} else {
|
|
@@ -1973,7 +1997,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1973
1997
|
// src/hwpx/section-walker.ts
|
|
1974
1998
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1975
1999
|
const parser = createXmlParser(warnings);
|
|
1976
|
-
const doc = parser.parseFromString(
|
|
2000
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1977
2001
|
if (!doc.documentElement) return [];
|
|
1978
2002
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1979
2003
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2079,8 +2103,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2079
2103
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2080
2104
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2081
2105
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2082
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2083
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2106
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkWMU2KJHFcjs.MAX_COLS);
|
|
2107
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkWMU2KJHFcjs.MAX_ROWS);
|
|
2084
2108
|
}
|
|
2085
2109
|
break;
|
|
2086
2110
|
case "p": {
|
|
@@ -2291,7 +2315,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2291
2315
|
const sink = [];
|
|
2292
2316
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2293
2317
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2294
|
-
let flat =
|
|
2318
|
+
let flat = _chunkWMU2KJHFcjs.convertTableToText.call(void 0, st.rows);
|
|
2295
2319
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2296
2320
|
return flat;
|
|
2297
2321
|
}
|
|
@@ -2424,7 +2448,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2424
2448
|
let url = (ch.textContent || "").trim();
|
|
2425
2449
|
if (!url) continue;
|
|
2426
2450
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2427
|
-
const safe =
|
|
2451
|
+
const safe = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, url);
|
|
2428
2452
|
if (safe) return safe;
|
|
2429
2453
|
}
|
|
2430
2454
|
return void 0;
|
|
@@ -2581,7 +2605,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2581
2605
|
case "hyperlink": {
|
|
2582
2606
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2583
2607
|
if (url) {
|
|
2584
|
-
const safe =
|
|
2608
|
+
const safe = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, url);
|
|
2585
2609
|
if (safe) href = safe;
|
|
2586
2610
|
}
|
|
2587
2611
|
walk(child, depth + 1);
|
|
@@ -2746,21 +2770,22 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2746
2770
|
else {
|
|
2747
2771
|
if (_optionalChain([cp, 'optionalAccess', _61 => _61.bold])) span.bold = true;
|
|
2748
2772
|
if (_optionalChain([cp, 'optionalAccess', _62 => _62.italic])) span.italic = true;
|
|
2773
|
+
if (_optionalChain([cp, 'optionalAccess', _63 => _63.strike])) span.strike = true;
|
|
2749
2774
|
}
|
|
2750
|
-
if (span.bold || span.italic || span.code) styled = true;
|
|
2775
|
+
if (span.bold || span.italic || span.strike || span.code) styled = true;
|
|
2751
2776
|
spans.push(span);
|
|
2752
2777
|
}
|
|
2753
2778
|
if (!styled || spans.length === 0) return null;
|
|
2754
2779
|
const merged = [];
|
|
2755
2780
|
for (const s of spans) {
|
|
2756
2781
|
const last = merged[merged.length - 1];
|
|
2757
|
-
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) {
|
|
2758
2783
|
last.text += s.text;
|
|
2759
2784
|
} else {
|
|
2760
2785
|
merged.push(s);
|
|
2761
2786
|
}
|
|
2762
2787
|
}
|
|
2763
|
-
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;
|
|
2764
2789
|
return merged;
|
|
2765
2790
|
}
|
|
2766
2791
|
function gongmunDepthFromIndent(para2, left, ctx) {
|
|
@@ -2768,12 +2793,12 @@ function gongmunDepthFromIndent(para2, left, ctx) {
|
|
|
2768
2793
|
if (!styleMap) return null;
|
|
2769
2794
|
let unit = 0;
|
|
2770
2795
|
const kids2 = para2.childNodes;
|
|
2771
|
-
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess',
|
|
2796
|
+
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess', _64 => _64.length]), () => ( 0))); i++) {
|
|
2772
2797
|
const child = kids2[i];
|
|
2773
2798
|
if (child.nodeType !== 1) continue;
|
|
2774
2799
|
const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
|
|
2775
2800
|
if (tag !== "run" && tag !== "r") continue;
|
|
2776
|
-
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]);
|
|
2777
2802
|
if (size) unit = size * 100;
|
|
2778
2803
|
break;
|
|
2779
2804
|
}
|
|
@@ -2846,7 +2871,7 @@ function decompressStream(data) {
|
|
|
2846
2871
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2847
2872
|
}
|
|
2848
2873
|
function parseFileHeader(data) {
|
|
2849
|
-
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)");
|
|
2850
2875
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2851
2876
|
return {
|
|
2852
2877
|
signature: sig,
|
|
@@ -2979,7 +3004,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
2979
3004
|
const resolveAt = (byteOffset, extended) => {
|
|
2980
3005
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2981
3006
|
const idx = extended ? state.ctrlIdx : -1;
|
|
2982
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
3007
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _69 => _69(idx, ctrlId)]);
|
|
2983
3008
|
if (replacement) result += replacement;
|
|
2984
3009
|
if (extended) state.ctrlIdx++;
|
|
2985
3010
|
};
|
|
@@ -3181,7 +3206,7 @@ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
|
|
|
3181
3206
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
3182
3207
|
if (fileIndex) {
|
|
3183
3208
|
for (const entry of fileIndex) {
|
|
3184
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3209
|
+
if (!_optionalChain([entry, 'optionalAccess', _70 => _70.name]) || !entry.content) continue;
|
|
3185
3210
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
3186
3211
|
if (!match) continue;
|
|
3187
3212
|
const idx = parseInt(match[1], 16);
|
|
@@ -3257,7 +3282,7 @@ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
|
|
|
3257
3282
|
} else if (block.type === "table" && block.table) {
|
|
3258
3283
|
for (const row of block.table.cells) {
|
|
3259
3284
|
for (const cell2 of row) {
|
|
3260
|
-
if (_optionalChain([cell2, 'access',
|
|
3285
|
+
if (_optionalChain([cell2, 'access', _71 => _71.blocks, 'optionalAccess', _72 => _72.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
|
|
3261
3286
|
}
|
|
3262
3287
|
}
|
|
3263
3288
|
}
|
|
@@ -3295,13 +3320,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3295
3320
|
}
|
|
3296
3321
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3297
3322
|
for (const path of allCandidates) {
|
|
3298
|
-
if (
|
|
3323
|
+
if (_chunkKKZATKQWcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3299
3324
|
const file = zip.file(path);
|
|
3300
3325
|
if (!file) continue;
|
|
3301
3326
|
try {
|
|
3302
3327
|
const data = await file.async("uint8array");
|
|
3303
3328
|
decompressed.total += data.length;
|
|
3304
|
-
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)");
|
|
3305
3330
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3306
3331
|
const mimeType = imageExtToMime(ext);
|
|
3307
3332
|
imageIndex++;
|
|
@@ -3311,10 +3336,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3311
3336
|
usedPaths.add(path);
|
|
3312
3337
|
break;
|
|
3313
3338
|
} catch (err) {
|
|
3314
|
-
if (err instanceof
|
|
3339
|
+
if (err instanceof _chunkKKZATKQWcjs.KordocError) throw err;
|
|
3315
3340
|
}
|
|
3316
3341
|
}
|
|
3317
|
-
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" })]);
|
|
3318
3343
|
resolved.set(ref, img);
|
|
3319
3344
|
}
|
|
3320
3345
|
if (!img) {
|
|
@@ -3331,11 +3356,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3331
3356
|
if (sweepUnreferenced) {
|
|
3332
3357
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3333
3358
|
for (const file of binEntries) {
|
|
3334
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3359
|
+
if (file.dir || usedPaths.has(file.name) || _chunkKKZATKQWcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3335
3360
|
try {
|
|
3336
3361
|
const data = await file.async("uint8array");
|
|
3337
3362
|
decompressed.total += data.length;
|
|
3338
|
-
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)");
|
|
3339
3364
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3340
3365
|
let mimeType = imageExtToMime(ext);
|
|
3341
3366
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3349,8 +3374,8 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3349
3374
|
images.push(img);
|
|
3350
3375
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3351
3376
|
} catch (err) {
|
|
3352
|
-
if (err instanceof
|
|
3353
|
-
_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" })]);
|
|
3354
3379
|
}
|
|
3355
3380
|
}
|
|
3356
3381
|
}
|
|
@@ -3400,7 +3425,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3400
3425
|
}
|
|
3401
3426
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3402
3427
|
const name = new TextDecoder().decode(nameBytes);
|
|
3403
|
-
if (
|
|
3428
|
+
if (_chunkKKZATKQWcjs.isPathTraversal.call(void 0, name)) {
|
|
3404
3429
|
pos = fileStart + compSize;
|
|
3405
3430
|
continue;
|
|
3406
3431
|
}
|
|
@@ -3418,16 +3443,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3418
3443
|
continue;
|
|
3419
3444
|
}
|
|
3420
3445
|
totalDecompressed += content.length * 2;
|
|
3421
|
-
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");
|
|
3422
3447
|
sectionNum++;
|
|
3423
3448
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3424
3449
|
} catch (e16) {
|
|
3425
3450
|
continue;
|
|
3426
3451
|
}
|
|
3427
3452
|
}
|
|
3428
|
-
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");
|
|
3429
3454
|
applyPageText(blocks, shared);
|
|
3430
|
-
const markdown =
|
|
3455
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3431
3456
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3432
3457
|
}
|
|
3433
3458
|
async function readKordocLayout(zip) {
|
|
@@ -3436,7 +3461,7 @@ async function readKordocLayout(zip) {
|
|
|
3436
3461
|
try {
|
|
3437
3462
|
const xml = await file.async("text");
|
|
3438
3463
|
if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
|
|
3439
|
-
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));
|
|
3440
3465
|
} catch (e17) {
|
|
3441
3466
|
return null;
|
|
3442
3467
|
}
|
|
@@ -3452,18 +3477,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3452
3477
|
if (paths.length > 0) return paths;
|
|
3453
3478
|
}
|
|
3454
3479
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3455
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3480
|
+
return sectionFiles.map((f) => f.name).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
3456
3481
|
}
|
|
3457
3482
|
function parseSectionPathsFromManifest(xml) {
|
|
3458
3483
|
const parser = createXmlParser();
|
|
3459
|
-
const doc = parser.parseFromString(
|
|
3484
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3460
3485
|
const items = doc.getElementsByTagName("opf:item");
|
|
3461
3486
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3462
3487
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3463
3488
|
for (let i = 0; i < items.length; i++) {
|
|
3464
3489
|
const item = items[i];
|
|
3465
3490
|
const id = item.getAttribute("id") || "";
|
|
3466
|
-
const href =
|
|
3491
|
+
const href = _chunkKKZATKQWcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3467
3492
|
if (id && href) idToHref.set(id, href);
|
|
3468
3493
|
}
|
|
3469
3494
|
if (spine.length > 0) {
|
|
@@ -3474,7 +3499,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3474
3499
|
}
|
|
3475
3500
|
if (ordered.length > 0) return ordered;
|
|
3476
3501
|
}
|
|
3477
|
-
return Array.from(idToHref.values()).sort(
|
|
3502
|
+
return Array.from(idToHref.values()).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
3478
3503
|
}
|
|
3479
3504
|
|
|
3480
3505
|
// src/hwpx/metadata.ts
|
|
@@ -3487,7 +3512,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3487
3512
|
const xml = await file.async("text");
|
|
3488
3513
|
if (decompressed) {
|
|
3489
3514
|
decompressed.total += xml.length * 2;
|
|
3490
|
-
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)");
|
|
3491
3516
|
}
|
|
3492
3517
|
parseDublinCoreMetadata(xml, metadata);
|
|
3493
3518
|
if (metadata.title || metadata.author) return;
|
|
@@ -3497,13 +3522,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3497
3522
|
}
|
|
3498
3523
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3499
3524
|
const parser = createXmlParser();
|
|
3500
|
-
const doc = parser.parseFromString(
|
|
3525
|
+
const doc = parser.parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3501
3526
|
if (!doc.documentElement) return;
|
|
3502
3527
|
const getText = (tagNames) => {
|
|
3503
3528
|
for (const tag of tagNames) {
|
|
3504
3529
|
const els = doc.getElementsByTagName(tag);
|
|
3505
3530
|
if (els.length > 0) {
|
|
3506
|
-
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()]);
|
|
3507
3532
|
if (text) return text;
|
|
3508
3533
|
}
|
|
3509
3534
|
}
|
|
@@ -3522,7 +3547,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3522
3547
|
|
|
3523
3548
|
// src/hwpx/parser.ts
|
|
3524
3549
|
async function parseHwpxDocument(buffer, options) {
|
|
3525
|
-
|
|
3550
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3526
3551
|
let zip;
|
|
3527
3552
|
try {
|
|
3528
3553
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3531,19 +3556,19 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3531
3556
|
}
|
|
3532
3557
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3533
3558
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3534
|
-
throw new (0,
|
|
3559
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3535
3560
|
}
|
|
3536
3561
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3537
3562
|
if (manifestFile) {
|
|
3538
3563
|
const manifestXml = await manifestFile.async("text");
|
|
3539
3564
|
if (isEncryptedHwpx(manifestXml)) {
|
|
3540
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
3565
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _84 => _84.filePath])) {
|
|
3541
3566
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3542
3567
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3543
3568
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3544
3569
|
}
|
|
3545
3570
|
}
|
|
3546
|
-
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.");
|
|
3547
3572
|
}
|
|
3548
3573
|
}
|
|
3549
3574
|
const decompressed = { total: 0 };
|
|
@@ -3552,14 +3577,14 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3552
3577
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3553
3578
|
const warnings = [];
|
|
3554
3579
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3555
|
-
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");
|
|
3556
3581
|
metadata.pageCount = sectionPaths.length;
|
|
3557
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3582
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _85 => _85.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3558
3583
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3559
3584
|
const blocks = [];
|
|
3560
3585
|
const shared = createSectionShared();
|
|
3561
3586
|
shared.kordocLayout = await readKordocLayout(zip);
|
|
3562
|
-
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
3587
|
+
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _86 => _86.keepTrailingEmptyCols]);
|
|
3563
3588
|
let parsedSections = 0;
|
|
3564
3589
|
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3565
3590
|
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
@@ -3571,7 +3596,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3571
3596
|
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new ZipBombError("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3572
3597
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3573
3598
|
parsedSections++;
|
|
3574
|
-
_optionalChain([options, 'optionalAccess',
|
|
3599
|
+
_optionalChain([options, 'optionalAccess', _87 => _87.onProgress, 'optionalCall', _88 => _88(parsedSections, totalTarget)]);
|
|
3575
3600
|
} catch (secErr) {
|
|
3576
3601
|
if (secErr instanceof ZipBombError) throw secErr;
|
|
3577
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" });
|
|
@@ -3581,7 +3606,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3581
3606
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3582
3607
|
detectHwpxHeadings(blocks, styleMap);
|
|
3583
3608
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3584
|
-
const markdown =
|
|
3609
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3585
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 };
|
|
3586
3611
|
}
|
|
3587
3612
|
|
|
@@ -4760,22 +4785,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4760
4785
|
lenientCfb = parseLenientCfb(buffer);
|
|
4761
4786
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4762
4787
|
} catch (e22) {
|
|
4763
|
-
throw new (0,
|
|
4788
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4764
4789
|
}
|
|
4765
4790
|
}
|
|
4766
4791
|
const findStream = (path) => {
|
|
4767
4792
|
if (cfb) {
|
|
4768
4793
|
const entry = CFB.find(cfb, path);
|
|
4769
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
4794
|
+
return _optionalChain([entry, 'optionalAccess', _89 => _89.content]) ? Buffer.from(entry.content) : null;
|
|
4770
4795
|
}
|
|
4771
4796
|
return lenientCfb.findStream(path);
|
|
4772
4797
|
};
|
|
4773
4798
|
const headerData = findStream("/FileHeader");
|
|
4774
|
-
if (!headerData) throw new (0,
|
|
4799
|
+
if (!headerData) throw new (0, _chunkKKZATKQWcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4775
4800
|
const header = parseFileHeader(headerData);
|
|
4776
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4777
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4778
|
-
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");
|
|
4779
4804
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4780
4805
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4781
4806
|
const metadata = {
|
|
@@ -4784,13 +4809,13 @@ function parseHwp5Document(buffer, options) {
|
|
|
4784
4809
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4785
4810
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4786
4811
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4787
|
-
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");
|
|
4788
4813
|
metadata.pageCount = sections.length;
|
|
4789
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4814
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _90 => _90.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4790
4815
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4791
4816
|
const bodyBlocks = [];
|
|
4792
4817
|
const doc = createHwp5DocState();
|
|
4793
|
-
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
4818
|
+
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _91 => _91.keepTrailingEmptyCols]);
|
|
4794
4819
|
let totalDecompressed = 0;
|
|
4795
4820
|
let parsedSections = 0;
|
|
4796
4821
|
for (let si = 0; si < sections.length; si++) {
|
|
@@ -4799,22 +4824,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4799
4824
|
const sectionData = sections[si];
|
|
4800
4825
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4801
4826
|
totalDecompressed += data.length;
|
|
4802
|
-
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)");
|
|
4803
4828
|
const records = readRecords(data);
|
|
4804
4829
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4805
4830
|
bodyBlocks.push(...sectionBlocks);
|
|
4806
4831
|
parsedSections++;
|
|
4807
|
-
_optionalChain([options, 'optionalAccess',
|
|
4832
|
+
_optionalChain([options, 'optionalAccess', _92 => _92.onProgress, 'optionalCall', _93 => _93(parsedSections, totalTarget)]);
|
|
4808
4833
|
} catch (secErr) {
|
|
4809
|
-
if (secErr instanceof
|
|
4834
|
+
if (secErr instanceof _chunkKKZATKQWcjs.KordocError) throw secErr;
|
|
4810
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" });
|
|
4811
4836
|
}
|
|
4812
4837
|
}
|
|
4813
4838
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4814
4839
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4815
|
-
let flatBlocks =
|
|
4816
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4817
|
-
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);
|
|
4818
4843
|
const removed = flatBlocks.length - deduped.length;
|
|
4819
4844
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4820
4845
|
flatBlocks = deduped;
|
|
@@ -4823,10 +4848,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4823
4848
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4824
4849
|
}
|
|
4825
4850
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4826
|
-
let markdown =
|
|
4827
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4851
|
+
let markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4852
|
+
if (_optionalChain([options, 'optionalAccess', _95 => _95.inlineImages]) && images.length > 0) {
|
|
4828
4853
|
try {
|
|
4829
|
-
markdown =
|
|
4854
|
+
markdown = _chunkWMU2KJHFcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4830
4855
|
} catch (inlineErr) {
|
|
4831
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" });
|
|
4832
4857
|
}
|
|
@@ -4836,7 +4861,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4836
4861
|
function parseDocInfoStream(cfb, compressed) {
|
|
4837
4862
|
try {
|
|
4838
4863
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
4839
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4864
|
+
if (!_optionalChain([entry, 'optionalAccess', _96 => _96.content])) return null;
|
|
4840
4865
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
4841
4866
|
const records = readRecords(data);
|
|
4842
4867
|
return parseDocInfo(records);
|
|
@@ -4857,7 +4882,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4857
4882
|
let baseFontSize = 0;
|
|
4858
4883
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
4859
4884
|
for (const b of blocks) {
|
|
4860
|
-
if (_optionalChain([b, 'access',
|
|
4885
|
+
if (_optionalChain([b, 'access', _97 => _97.style, 'optionalAccess', _98 => _98.fontSize]) && b.text) {
|
|
4861
4886
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4862
4887
|
}
|
|
4863
4888
|
}
|
|
@@ -4873,7 +4898,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4873
4898
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4874
4899
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4875
4900
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4876
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4901
|
+
if (_optionalChain([cs, 'optionalAccess', _99 => _99.fontSize]) > 0) {
|
|
4877
4902
|
baseFontSize = cs.fontSize / 10;
|
|
4878
4903
|
break;
|
|
4879
4904
|
}
|
|
@@ -4888,11 +4913,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4888
4913
|
if (text.length === 0 || text.length > 200) continue;
|
|
4889
4914
|
if (/^\d+$/.test(text)) continue;
|
|
4890
4915
|
let level = 0;
|
|
4891
|
-
if (_optionalChain([block, 'access',
|
|
4916
|
+
if (_optionalChain([block, 'access', _100 => _100.style, 'optionalAccess', _101 => _101.fontSize]) && baseFontSize > 0) {
|
|
4892
4917
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4893
|
-
if (ratio >=
|
|
4894
|
-
else if (ratio >=
|
|
4895
|
-
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;
|
|
4896
4921
|
}
|
|
4897
4922
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4898
4923
|
if (level === 0) level = 2;
|
|
@@ -4908,7 +4933,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4908
4933
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4909
4934
|
try {
|
|
4910
4935
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4911
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4936
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _102 => _102.content])) return;
|
|
4912
4937
|
const data = Buffer.from(summaryEntry.content);
|
|
4913
4938
|
if (data.length < 48) return;
|
|
4914
4939
|
const numSets = data.readUInt32LE(24);
|
|
@@ -4941,7 +4966,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
4941
4966
|
const sections = [];
|
|
4942
4967
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4943
4968
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
4944
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4969
|
+
if (!_optionalChain([entry, 'optionalAccess', _103 => _103.content])) break;
|
|
4945
4970
|
try {
|
|
4946
4971
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
4947
4972
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -4955,13 +4980,13 @@ function findSections(cfb) {
|
|
|
4955
4980
|
const sections = [];
|
|
4956
4981
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4957
4982
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
4958
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4983
|
+
if (!_optionalChain([entry, 'optionalAccess', _104 => _104.content])) break;
|
|
4959
4984
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
4960
4985
|
}
|
|
4961
4986
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
4962
4987
|
for (const entry of cfb.FileIndex) {
|
|
4963
4988
|
if (sections.length >= MAX_SECTIONS) break;
|
|
4964
|
-
if (_optionalChain([entry, 'access',
|
|
4989
|
+
if (_optionalChain([entry, 'access', _105 => _105.name, 'optionalAccess', _106 => _106.startsWith, 'call', _107 => _107("Section")]) && entry.content) {
|
|
4965
4990
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
4966
4991
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
4967
4992
|
}
|
|
@@ -4977,7 +5002,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4977
5002
|
if (!raw) break;
|
|
4978
5003
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4979
5004
|
totalDecompressed += content.length;
|
|
4980
|
-
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)");
|
|
4981
5006
|
sections.push({ idx: i, content });
|
|
4982
5007
|
}
|
|
4983
5008
|
if (sections.length === 0) {
|
|
@@ -4989,7 +5014,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4989
5014
|
if (raw) {
|
|
4990
5015
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4991
5016
|
totalDecompressed += content.length;
|
|
4992
|
-
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)");
|
|
4993
5018
|
sections.push({ idx, content });
|
|
4994
5019
|
}
|
|
4995
5020
|
}
|
|
@@ -5006,7 +5031,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5006
5031
|
try {
|
|
5007
5032
|
const content = decryptViewText(raw, compressed);
|
|
5008
5033
|
totalDecompressed += content.length;
|
|
5009
|
-
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)");
|
|
5010
5035
|
sections.push({ idx: i, content });
|
|
5011
5036
|
} catch (e27) {
|
|
5012
5037
|
break;
|
|
@@ -5107,9 +5132,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5107
5132
|
const applied = [];
|
|
5108
5133
|
for (const r of ranges) {
|
|
5109
5134
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5110
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
5135
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _108 => _108.href]) || r.end <= r.start) continue;
|
|
5111
5136
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5112
|
-
const href =
|
|
5137
|
+
const href = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5113
5138
|
if (!href) continue;
|
|
5114
5139
|
const anchor = text.slice(r.start, r.end);
|
|
5115
5140
|
if (!anchor.trim()) continue;
|
|
@@ -5127,7 +5152,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5127
5152
|
}
|
|
5128
5153
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
5129
5154
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
5130
|
-
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;
|
|
5131
5156
|
if (numbering) {
|
|
5132
5157
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
5133
5158
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -5137,7 +5162,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5137
5162
|
}
|
|
5138
5163
|
}
|
|
5139
5164
|
} else if (ps.headType === 3) {
|
|
5140
|
-
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;
|
|
5141
5166
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
5142
5167
|
}
|
|
5143
5168
|
}
|
|
@@ -5152,7 +5177,10 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5152
5177
|
if (headingLevel > 0) block.level = headingLevel;
|
|
5153
5178
|
if (ctx.docInfo && charShapeIds.length > 0) {
|
|
5154
5179
|
const style = resolveCharStyle(charShapeIds, ctx.docInfo);
|
|
5155
|
-
if (style)
|
|
5180
|
+
if (style) {
|
|
5181
|
+
block.style = style;
|
|
5182
|
+
if (style.strike) block.text = headMarker ? `${headMarker} ~~${trimmed}~~` : `~~${trimmed}~~`;
|
|
5183
|
+
}
|
|
5156
5184
|
}
|
|
5157
5185
|
if (footnotes.length > 0) block.footnoteText = footnotes.join("; ");
|
|
5158
5186
|
blocks.push(block);
|
|
@@ -5342,8 +5370,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5342
5370
|
let tableIdx = -1;
|
|
5343
5371
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5344
5372
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5345
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5346
|
-
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);
|
|
5347
5375
|
tableIdx = i2;
|
|
5348
5376
|
break;
|
|
5349
5377
|
}
|
|
@@ -5383,7 +5411,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5383
5411
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
5384
5412
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
5385
5413
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
5386
|
-
if (_optionalChain([c, 'access',
|
|
5414
|
+
if (_optionalChain([c, 'access', _115 => _115.blocks, 'optionalAccess', _116 => _116.length])) ir.blocks = c.blocks;
|
|
5387
5415
|
if (c.isHeader) ir.isHeader = true;
|
|
5388
5416
|
return ir;
|
|
5389
5417
|
}));
|
|
@@ -5392,7 +5420,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5392
5420
|
return table3;
|
|
5393
5421
|
}
|
|
5394
5422
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5395
|
-
const table2 =
|
|
5423
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5396
5424
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5397
5425
|
return table2.rows > 0 ? table2 : null;
|
|
5398
5426
|
}
|
|
@@ -5409,8 +5437,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5409
5437
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5410
5438
|
const cs = rec.data.readUInt16LE(12);
|
|
5411
5439
|
const rs = rec.data.readUInt16LE(14);
|
|
5412
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5413
|
-
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);
|
|
5414
5442
|
}
|
|
5415
5443
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5416
5444
|
const parts = [];
|
|
@@ -5420,7 +5448,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5420
5448
|
parts.push(``);
|
|
5421
5449
|
hasStructure = true;
|
|
5422
5450
|
} else if (b.type === "table" && b.table) {
|
|
5423
|
-
const flat =
|
|
5451
|
+
const flat = _chunkWMU2KJHFcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5424
5452
|
if (flat) parts.push(flat);
|
|
5425
5453
|
hasStructure = true;
|
|
5426
5454
|
} else if (b.text) {
|
|
@@ -5517,8 +5545,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
5517
5545
|
if (data.length < 73) return null;
|
|
5518
5546
|
const binDataId = data.readUInt16LE(71);
|
|
5519
5547
|
if (binDataId === 0) return null;
|
|
5520
|
-
const item = _optionalChain([ctx, 'access',
|
|
5521
|
-
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") {
|
|
5522
5550
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
5523
5551
|
return null;
|
|
5524
5552
|
}
|
|
@@ -5543,7 +5571,13 @@ function resolveCharStyle(charShapeIds, docInfo) {
|
|
|
5543
5571
|
if (cs.fontSize > 0) style.fontSize = cs.fontSize / 10;
|
|
5544
5572
|
if (cs.attrFlags & 1) style.italic = true;
|
|
5545
5573
|
if (cs.attrFlags & 2) style.bold = true;
|
|
5546
|
-
|
|
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;
|
|
5547
5581
|
}
|
|
5548
5582
|
|
|
5549
5583
|
// src/hwp3/parser.ts
|
|
@@ -17666,7 +17700,7 @@ function parseHwp3Document(buffer, _options) {
|
|
|
17666
17700
|
try {
|
|
17667
17701
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17668
17702
|
} catch (err) {
|
|
17669
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
17703
|
+
if (_optionalChain([err, 'optionalAccess', _121 => _121.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17670
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`);
|
|
17671
17705
|
}
|
|
17672
17706
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
@@ -17901,15 +17935,15 @@ function getElements(parent, tagName) {
|
|
|
17901
17935
|
const result = [];
|
|
17902
17936
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
17903
17937
|
if (result.length > 0) return result;
|
|
17904
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
17938
|
+
const nsNodes = _optionalChain([parent, 'access', _122 => _122.getElementsByTagNameNS, 'optionalCall', _123 => _123("*", tagName)]);
|
|
17905
17939
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
17906
17940
|
return result;
|
|
17907
17941
|
}
|
|
17908
17942
|
function getTextContent(el) {
|
|
17909
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
17943
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _124 => _124.textContent, 'optionalAccess', _125 => _125.trim, 'call', _126 => _126()]), () => ( ""));
|
|
17910
17944
|
}
|
|
17911
17945
|
function parseXml(text) {
|
|
17912
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17946
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17913
17947
|
}
|
|
17914
17948
|
function collectRichText(root) {
|
|
17915
17949
|
let out = "";
|
|
@@ -17918,7 +17952,7 @@ function collectRichText(root) {
|
|
|
17918
17952
|
for (let i = 0; i < children.length; i++) {
|
|
17919
17953
|
if (children[i].nodeType !== 1) continue;
|
|
17920
17954
|
const el = children[i];
|
|
17921
|
-
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(/^[^:]+:/, "")]) || "";
|
|
17922
17956
|
if (local === "rPh") continue;
|
|
17923
17957
|
if (local === "t") out += _nullishCoalesce(el.textContent, () => ( ""));
|
|
17924
17958
|
else walk(el);
|
|
@@ -18137,14 +18171,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18137
18171
|
const merge = mergeMap.get(key);
|
|
18138
18172
|
row.push({
|
|
18139
18173
|
text,
|
|
18140
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18141
|
-
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))
|
|
18142
18176
|
});
|
|
18143
18177
|
}
|
|
18144
18178
|
cellRows.push(row);
|
|
18145
18179
|
}
|
|
18146
18180
|
if (cellRows.length > 0) {
|
|
18147
|
-
const table2 =
|
|
18181
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18148
18182
|
if (table2.rows > 0) {
|
|
18149
18183
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18150
18184
|
}
|
|
@@ -18152,12 +18186,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18152
18186
|
return blocks;
|
|
18153
18187
|
}
|
|
18154
18188
|
async function parseXlsxDocument(buffer, options) {
|
|
18155
|
-
|
|
18189
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18156
18190
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18157
18191
|
const warnings = [];
|
|
18158
18192
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18159
18193
|
if (!workbookFile) {
|
|
18160
|
-
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");
|
|
18161
18195
|
}
|
|
18162
18196
|
let sharedStrings = [];
|
|
18163
18197
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18166,7 +18200,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18166
18200
|
}
|
|
18167
18201
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18168
18202
|
if (sheets.length === 0) {
|
|
18169
|
-
throw new (0,
|
|
18203
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18170
18204
|
}
|
|
18171
18205
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18172
18206
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18182,7 +18216,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18182
18216
|
relsMap = parseRels(await relsFile.async("text"));
|
|
18183
18217
|
}
|
|
18184
18218
|
let pageFilter = null;
|
|
18185
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18219
|
+
if (_optionalChain([options, 'optionalAccess', _132 => _132.pages])) {
|
|
18186
18220
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18187
18221
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18188
18222
|
}
|
|
@@ -18191,7 +18225,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18191
18225
|
for (let i = 0; i < processedSheets; i++) {
|
|
18192
18226
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18193
18227
|
const sheet = sheets[i];
|
|
18194
|
-
_optionalChain([options, 'optionalAccess',
|
|
18228
|
+
_optionalChain([options, 'optionalAccess', _133 => _133.onProgress, 'optionalCall', _134 => _134(i + 1, processedSheets)]);
|
|
18195
18229
|
let sheetPath = relsMap.get(sheet.rId);
|
|
18196
18230
|
if (sheetPath) {
|
|
18197
18231
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -18214,7 +18248,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18214
18248
|
try {
|
|
18215
18249
|
const sheetXml = await sheetFile.async("text");
|
|
18216
18250
|
const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
|
|
18217
|
-
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]));
|
|
18218
18252
|
blocks.push(...sheetBlocks);
|
|
18219
18253
|
} catch (err) {
|
|
18220
18254
|
warnings.push({
|
|
@@ -18246,7 +18280,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18246
18280
|
} catch (e29) {
|
|
18247
18281
|
}
|
|
18248
18282
|
}
|
|
18249
|
-
const markdown =
|
|
18283
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18250
18284
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18251
18285
|
}
|
|
18252
18286
|
|
|
@@ -18697,11 +18731,11 @@ function processGlobals(records) {
|
|
|
18697
18731
|
const xfFmtIds = [];
|
|
18698
18732
|
const firstBof = records[0];
|
|
18699
18733
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18700
|
-
throw new (0,
|
|
18734
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18701
18735
|
}
|
|
18702
18736
|
const bof = decodeBof(firstBof.data);
|
|
18703
18737
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18704
|
-
throw new (0,
|
|
18738
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18705
18739
|
}
|
|
18706
18740
|
let i = 1;
|
|
18707
18741
|
while (i < records.length) {
|
|
@@ -18829,14 +18863,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18829
18863
|
const merge = mergeMap.get(key);
|
|
18830
18864
|
row.push({
|
|
18831
18865
|
text: grid[r][c],
|
|
18832
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18833
|
-
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))
|
|
18834
18868
|
});
|
|
18835
18869
|
}
|
|
18836
18870
|
cellRows.push(row);
|
|
18837
18871
|
}
|
|
18838
18872
|
if (cellRows.length > 0) {
|
|
18839
|
-
const table2 =
|
|
18873
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18840
18874
|
if (table2.rows > 0) {
|
|
18841
18875
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18842
18876
|
}
|
|
@@ -18849,21 +18883,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18849
18883
|
try {
|
|
18850
18884
|
cfb = parseLenientCfb(buf);
|
|
18851
18885
|
} catch (e) {
|
|
18852
|
-
throw new (0,
|
|
18886
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
18853
18887
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18854
18888
|
);
|
|
18855
18889
|
}
|
|
18856
18890
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18857
18891
|
if (!wb) {
|
|
18858
|
-
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)");
|
|
18859
18893
|
}
|
|
18860
18894
|
const records = readRecords2(wb);
|
|
18861
18895
|
if (records.length === 0) {
|
|
18862
|
-
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)");
|
|
18863
18897
|
}
|
|
18864
18898
|
const firstBof = decodeBof(records[0].data);
|
|
18865
18899
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18866
|
-
throw new (0,
|
|
18900
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
18867
18901
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18868
18902
|
);
|
|
18869
18903
|
}
|
|
@@ -18892,7 +18926,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18892
18926
|
} : void 0;
|
|
18893
18927
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18894
18928
|
let pageFilter = null;
|
|
18895
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18929
|
+
if (_optionalChain([options, 'optionalAccess', _138 => _138.pages])) {
|
|
18896
18930
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18897
18931
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18898
18932
|
}
|
|
@@ -18901,7 +18935,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18901
18935
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18902
18936
|
const meta = globals.sheets[i];
|
|
18903
18937
|
if (meta.dt !== 0) continue;
|
|
18904
|
-
_optionalChain([options, 'optionalAccess',
|
|
18938
|
+
_optionalChain([options, 'optionalAccess', _139 => _139.onProgress, 'optionalCall', _140 => _140(i + 1, totalSheets)]);
|
|
18905
18939
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
18906
18940
|
if (bofIdx < 0) {
|
|
18907
18941
|
warnings.push({
|
|
@@ -18917,7 +18951,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18917
18951
|
}
|
|
18918
18952
|
try {
|
|
18919
18953
|
const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
|
|
18920
|
-
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess',
|
|
18954
|
+
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess', _141 => _141.keepTrailingEmptyCols]));
|
|
18921
18955
|
allBlocks.push(...blocks);
|
|
18922
18956
|
} catch (e) {
|
|
18923
18957
|
warnings.push({
|
|
@@ -18931,7 +18965,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18931
18965
|
pageCount: totalSheets
|
|
18932
18966
|
};
|
|
18933
18967
|
return {
|
|
18934
|
-
markdown:
|
|
18968
|
+
markdown: _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18935
18969
|
blocks: allBlocks,
|
|
18936
18970
|
metadata,
|
|
18937
18971
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18944,7 +18978,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18944
18978
|
|
|
18945
18979
|
// src/docx/equation.ts
|
|
18946
18980
|
function lname(el) {
|
|
18947
|
-
return el.localName || _optionalChain([el, 'access',
|
|
18981
|
+
return el.localName || _optionalChain([el, 'access', _142 => _142.tagName, 'optionalAccess', _143 => _143.replace, 'call', _144 => _144(/^[^:]+:/, "")]) || "";
|
|
18948
18982
|
}
|
|
18949
18983
|
function kids(parent, name) {
|
|
18950
18984
|
const out = [];
|
|
@@ -19333,7 +19367,7 @@ function isDisplayMath(el) {
|
|
|
19333
19367
|
// src/docx/parser.ts
|
|
19334
19368
|
var MAX_DECOMPRESS_SIZE5 = 100 * 1024 * 1024;
|
|
19335
19369
|
function matchesLocal(el, localName2) {
|
|
19336
|
-
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)));
|
|
19337
19371
|
}
|
|
19338
19372
|
function effectiveChildElements(parent) {
|
|
19339
19373
|
const result = [];
|
|
@@ -19368,7 +19402,7 @@ function findElements(parent, localName2) {
|
|
|
19368
19402
|
const child = children[i];
|
|
19369
19403
|
if (child.nodeType === 1) {
|
|
19370
19404
|
const el = child;
|
|
19371
|
-
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}`)])) {
|
|
19372
19406
|
result.push(el);
|
|
19373
19407
|
}
|
|
19374
19408
|
walk(el);
|
|
@@ -19387,7 +19421,7 @@ function getAttr(el, localName2) {
|
|
|
19387
19421
|
return null;
|
|
19388
19422
|
}
|
|
19389
19423
|
function parseXml2(text) {
|
|
19390
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19424
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkKKZATKQWcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19391
19425
|
}
|
|
19392
19426
|
function parseStyles(xml) {
|
|
19393
19427
|
const doc = parseXml2(xml);
|
|
@@ -19504,7 +19538,7 @@ function collectOmmlRoots(p) {
|
|
|
19504
19538
|
const child = children[i];
|
|
19505
19539
|
if (child.nodeType !== 1) continue;
|
|
19506
19540
|
const el = child;
|
|
19507
|
-
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(/^[^:]+:/, "")]) || "";
|
|
19508
19542
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
19509
19543
|
out.push(el);
|
|
19510
19544
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -19545,7 +19579,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19545
19579
|
function makeLink(text, rawHref) {
|
|
19546
19580
|
if (!text) return "";
|
|
19547
19581
|
if (!rawHref) return text;
|
|
19548
|
-
const href =
|
|
19582
|
+
const href = _chunkKKZATKQWcjs.sanitizeHref.call(void 0, rawHref);
|
|
19549
19583
|
return href ? `[${text}](${href})` : text;
|
|
19550
19584
|
}
|
|
19551
19585
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19647,7 +19681,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19647
19681
|
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19648
19682
|
if (!text) return null;
|
|
19649
19683
|
const style = styles.get(styleId);
|
|
19650
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
19684
|
+
if (_optionalChain([style, 'optionalAccess', _154 => _154.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
19651
19685
|
return {
|
|
19652
19686
|
type: "heading",
|
|
19653
19687
|
text,
|
|
@@ -19656,8 +19690,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19656
19690
|
}
|
|
19657
19691
|
if (numId && numId !== "0") {
|
|
19658
19692
|
const numDef = numbering.get(numId);
|
|
19659
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
19660
|
-
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";
|
|
19661
19695
|
return { type: "list", text, listType };
|
|
19662
19696
|
}
|
|
19663
19697
|
const block = { type: "paragraph", text };
|
|
@@ -19739,7 +19773,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19739
19773
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19740
19774
|
})
|
|
19741
19775
|
);
|
|
19742
|
-
const table2 =
|
|
19776
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19743
19777
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19744
19778
|
return { type: "table", table: table2 };
|
|
19745
19779
|
}
|
|
@@ -19749,10 +19783,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19749
19783
|
for (const el of effectiveChildElements(tc2)) {
|
|
19750
19784
|
if (matchesLocal(el, "p")) {
|
|
19751
19785
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19752
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
19786
|
+
if (_optionalChain([block, 'optionalAccess', _158 => _158.text])) parts.push(block.text);
|
|
19753
19787
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19754
19788
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19755
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
19789
|
+
if (_optionalChain([tb, 'optionalAccess', _159 => _159.text])) parts.push(tb.text);
|
|
19756
19790
|
}
|
|
19757
19791
|
} else if (matchesLocal(el, "tbl")) {
|
|
19758
19792
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -19787,7 +19821,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19787
19821
|
try {
|
|
19788
19822
|
const data = await imgFile.async("uint8array");
|
|
19789
19823
|
imgIdx++;
|
|
19790
|
-
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"));
|
|
19791
19825
|
const mimeMap = {
|
|
19792
19826
|
png: "image/png",
|
|
19793
19827
|
jpg: "image/jpeg",
|
|
@@ -19841,12 +19875,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19841
19875
|
}
|
|
19842
19876
|
}
|
|
19843
19877
|
async function parseDocxDocument(buffer, options) {
|
|
19844
|
-
|
|
19878
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19845
19879
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19846
19880
|
const warnings = [];
|
|
19847
19881
|
const docFile = zip.file("word/document.xml");
|
|
19848
19882
|
if (!docFile) {
|
|
19849
|
-
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");
|
|
19850
19884
|
}
|
|
19851
19885
|
let rels = /* @__PURE__ */ new Map();
|
|
19852
19886
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19893,7 +19927,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19893
19927
|
const doc = parseXml2(docXml);
|
|
19894
19928
|
const body = findElements(doc, "body");
|
|
19895
19929
|
if (body.length === 0) {
|
|
19896
|
-
throw new (0,
|
|
19930
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19897
19931
|
}
|
|
19898
19932
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19899
19933
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19901,7 +19935,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19901
19935
|
const bodyEl = body[0];
|
|
19902
19936
|
const topLevel = effectiveChildElements(bodyEl);
|
|
19903
19937
|
for (const el of topLevel) {
|
|
19904
|
-
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()])));
|
|
19905
19939
|
if (localName2 === "p") {
|
|
19906
19940
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19907
19941
|
if (block) blocks.push(block);
|
|
@@ -19912,7 +19946,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19912
19946
|
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19913
19947
|
}
|
|
19914
19948
|
} else if (localName2 === "tbl") {
|
|
19915
|
-
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]));
|
|
19916
19950
|
if (block) blocks.push(block);
|
|
19917
19951
|
}
|
|
19918
19952
|
}
|
|
@@ -19944,7 +19978,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19944
19978
|
}
|
|
19945
19979
|
}
|
|
19946
19980
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19947
|
-
const markdown =
|
|
19981
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19948
19982
|
return {
|
|
19949
19983
|
markdown,
|
|
19950
19984
|
blocks,
|
|
@@ -19967,7 +20001,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19967
20001
|
}
|
|
19968
20002
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19969
20003
|
const normalized = text.replace(/ /g, " ");
|
|
19970
|
-
const xml =
|
|
20004
|
+
const xml = _chunkKKZATKQWcjs.stripDtd.call(void 0, normalized);
|
|
19971
20005
|
const warnings = [];
|
|
19972
20006
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19973
20007
|
onError: (_level, msg2) => {
|
|
@@ -19995,7 +20029,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19995
20029
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19996
20030
|
}
|
|
19997
20031
|
const blocks = [];
|
|
19998
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
20032
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _172 => _172.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
19999
20033
|
let sectionIdx = 0;
|
|
20000
20034
|
const children = body.childNodes;
|
|
20001
20035
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -20004,10 +20038,10 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20004
20038
|
if (localName(el) !== "SECTION") continue;
|
|
20005
20039
|
sectionIdx++;
|
|
20006
20040
|
if (pageFilter && !pageFilter.has(sectionIdx)) continue;
|
|
20007
|
-
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)));
|
|
20008
20042
|
}
|
|
20009
20043
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20010
|
-
const markdown =
|
|
20044
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20011
20045
|
return {
|
|
20012
20046
|
markdown,
|
|
20013
20047
|
blocks,
|
|
@@ -20093,7 +20127,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
20093
20127
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
20094
20128
|
const text = extractParagraphText(el);
|
|
20095
20129
|
if (!text) return;
|
|
20096
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
20130
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _174 => _174.headingLevel]) != null) {
|
|
20097
20131
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
20098
20132
|
} else {
|
|
20099
20133
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -20152,7 +20186,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20152
20186
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20153
20187
|
cellRows[r].push(cell2);
|
|
20154
20188
|
}
|
|
20155
|
-
const table2 =
|
|
20189
|
+
const table2 = _chunkWMU2KJHFcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20156
20190
|
const caption = extractShapeCaption(el);
|
|
20157
20191
|
if (caption.text && caption.before) {
|
|
20158
20192
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20412,7 +20446,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
20412
20446
|
(match, prefix, suffix) => {
|
|
20413
20447
|
const label = prefix + suffix;
|
|
20414
20448
|
const normalizedLabel = normalizeLabel(label);
|
|
20415
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20449
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _175 => _175.has, 'call', _176 => _176(normalizedLabel)])) return match;
|
|
20416
20450
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
20417
20451
|
if (matchKey === void 0) return match;
|
|
20418
20452
|
const newValue = values.consume(matchKey);
|
|
@@ -20491,17 +20525,17 @@ function matchInlineSegment(seg, values, blockedLabels) {
|
|
|
20491
20525
|
const nlabel = normalizeLabel(seg.label);
|
|
20492
20526
|
if (seg.extLabel !== void 0) {
|
|
20493
20527
|
const nExt = normalizeLabel(seg.extLabel);
|
|
20494
|
-
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess',
|
|
20528
|
+
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess', _177 => _177.has, 'call', _178 => _178(nExt)]) && values.has(nExt)) {
|
|
20495
20529
|
return { key: nExt, label: seg.extLabel, viaExt: true };
|
|
20496
20530
|
}
|
|
20497
20531
|
}
|
|
20498
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20532
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _179 => _179.has, 'call', _180 => _180(nlabel)])) return void 0;
|
|
20499
20533
|
const key = findMatchingKey(nlabel, values);
|
|
20500
20534
|
return key !== void 0 ? { key, label: seg.label, viaExt: false } : void 0;
|
|
20501
20535
|
}
|
|
20502
20536
|
function clampSegmentEnd(text, seg, next, nextViaExt) {
|
|
20503
20537
|
let ve = seg.valueEnd;
|
|
20504
|
-
if (nextViaExt && _optionalChain([next, 'optionalAccess',
|
|
20538
|
+
if (nextViaExt && _optionalChain([next, 'optionalAccess', _181 => _181.extStart]) !== void 0 && next.extStart < ve) ve = next.extStart;
|
|
20505
20539
|
while (ve > seg.valueStart && /\s/.test(text[ve - 1])) ve--;
|
|
20506
20540
|
return ve;
|
|
20507
20541
|
}
|
|
@@ -20516,7 +20550,7 @@ function normalizeValues(values, warnings) {
|
|
|
20516
20550
|
const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
|
|
20517
20551
|
const key = normalizeLabel(label);
|
|
20518
20552
|
if (map.has(key)) {
|
|
20519
|
-
_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`)]);
|
|
20520
20554
|
}
|
|
20521
20555
|
map.set(key, Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
|
|
20522
20556
|
}
|
|
@@ -20691,8 +20725,8 @@ function extractFromTable(table2) {
|
|
|
20691
20725
|
if (table2.cols >= 2) {
|
|
20692
20726
|
for (let r = 0; r < table2.rows; r++) {
|
|
20693
20727
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
20694
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20695
|
-
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]]);
|
|
20696
20730
|
if (!labelCell || !valueCell) continue;
|
|
20697
20731
|
if (isLabelCell(labelCell.text)) {
|
|
20698
20732
|
fields.push({
|
|
@@ -20707,15 +20741,15 @@ function extractFromTable(table2) {
|
|
|
20707
20741
|
}
|
|
20708
20742
|
if (fields.length === 0 && table2.rows >= 2 && table2.cols >= 2) {
|
|
20709
20743
|
const headerRow = table2.cells[0];
|
|
20710
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20711
|
-
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()]), () => ( ""));
|
|
20712
20746
|
return t.length > 0 && t.length <= 20;
|
|
20713
20747
|
})]), () => ( false));
|
|
20714
20748
|
if (allLabels) {
|
|
20715
20749
|
for (let r = 1; r < table2.rows; r++) {
|
|
20716
20750
|
for (let c = 0; c < table2.cols; c++) {
|
|
20717
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
20718
|
-
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()]), () => ( ""));
|
|
20719
20753
|
if (label && value) {
|
|
20720
20754
|
fields.push({ label, value, row: r, col: c });
|
|
20721
20755
|
}
|
|
@@ -20809,7 +20843,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
20809
20843
|
for (const table2 of allTables) {
|
|
20810
20844
|
for (let r = 0; r < table2.rows; r++) {
|
|
20811
20845
|
for (let c = 0; c < table2.cols; c++) {
|
|
20812
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20846
|
+
const cell2 = _optionalChain([table2, 'access', _205 => _205.cells, 'access', _206 => _206[r], 'optionalAccess', _207 => _207[c]]);
|
|
20813
20847
|
if (!cell2) continue;
|
|
20814
20848
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
20815
20849
|
if (result) {
|
|
@@ -20841,7 +20875,7 @@ function collectIRTables(blocks, depth) {
|
|
|
20841
20875
|
out.push(block.table);
|
|
20842
20876
|
for (const row of block.table.cells) {
|
|
20843
20877
|
for (const cell2 of row) {
|
|
20844
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
20878
|
+
if (_optionalChain([cell2, 'optionalAccess', _208 => _208.blocks, 'optionalAccess', _209 => _209.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
20845
20879
|
}
|
|
20846
20880
|
}
|
|
20847
20881
|
}
|
|
@@ -20852,7 +20886,7 @@ function coveredPositions(table2) {
|
|
|
20852
20886
|
for (let r = 0; r < table2.rows; r++) {
|
|
20853
20887
|
for (let c = 0; c < table2.cols; c++) {
|
|
20854
20888
|
if (covered.has(`${r},${c}`)) continue;
|
|
20855
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20889
|
+
const cell2 = _optionalChain([table2, 'access', _210 => _210.cells, 'access', _211 => _211[r], 'optionalAccess', _212 => _212[c]]);
|
|
20856
20890
|
if (!cell2) continue;
|
|
20857
20891
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
20858
20892
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -20868,15 +20902,15 @@ function coveredPositions(table2) {
|
|
|
20868
20902
|
function isHeaderDataTable(table2, covered) {
|
|
20869
20903
|
if (table2.rows < 2) return false;
|
|
20870
20904
|
const headerRow = table2.cells[0];
|
|
20871
|
-
if (!_optionalChain([headerRow, 'optionalAccess',
|
|
20905
|
+
if (!_optionalChain([headerRow, 'optionalAccess', _213 => _213.length])) return false;
|
|
20872
20906
|
const allLabels = headerRow.every((cell2) => {
|
|
20873
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20907
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _214 => _214.text, 'access', _215 => _215.trim, 'call', _216 => _216()]), () => ( ""));
|
|
20874
20908
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20875
20909
|
});
|
|
20876
20910
|
if (!allLabels) return false;
|
|
20877
20911
|
for (let c = 0; c < table2.cols; c++) {
|
|
20878
20912
|
if (covered.has(`1,${c}`)) continue;
|
|
20879
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20913
|
+
const cell2 = _optionalChain([table2, 'access', _217 => _217.cells, 'access', _218 => _218[1], 'optionalAccess', _219 => _219[c]]);
|
|
20880
20914
|
if (!cell2) break;
|
|
20881
20915
|
return !isLabelCell(cell2.text);
|
|
20882
20916
|
}
|
|
@@ -20889,7 +20923,7 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20889
20923
|
for (let r = skipHeaderRow ? 1 : 0; r < table2.rows; r++) {
|
|
20890
20924
|
for (let c = 0; c < table2.cols; c++) {
|
|
20891
20925
|
if (covered.has(`${r},${c}`)) continue;
|
|
20892
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20926
|
+
const labelCell = _optionalChain([table2, 'access', _220 => _220.cells, 'access', _221 => _221[r], 'optionalAccess', _222 => _222[c]]);
|
|
20893
20927
|
if (!labelCell) continue;
|
|
20894
20928
|
if (!isLabelCell(labelCell.text)) continue;
|
|
20895
20929
|
let vc = c + labelCell.colSpan;
|
|
@@ -20900,12 +20934,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20900
20934
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
20901
20935
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
20902
20936
|
if (!normalizedCellLabel) continue;
|
|
20903
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20937
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _223 => _223.has, 'call', _224 => _224(normalizedCellLabel)])) continue;
|
|
20904
20938
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
20905
20939
|
if (matchKey === void 0) continue;
|
|
20906
20940
|
const newValue = values.consume(matchKey);
|
|
20907
20941
|
if (newValue === void 0) continue;
|
|
20908
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20942
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _225 => _225.has, 'call', _226 => _226(valueCell)])) {
|
|
20909
20943
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20910
20944
|
} else {
|
|
20911
20945
|
valueCell.text = newValue;
|
|
@@ -20922,8 +20956,8 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20922
20956
|
}
|
|
20923
20957
|
if (table2.rows >= 2 && table2.cols >= 2) {
|
|
20924
20958
|
const headerRow = table2.cells[0];
|
|
20925
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20926
|
-
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()]), () => ( ""));
|
|
20927
20961
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20928
20962
|
})]), () => ( false));
|
|
20929
20963
|
if (!allLabels) return;
|
|
@@ -20931,16 +20965,16 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20931
20965
|
for (let c = 0; c < table2.cols; c++) {
|
|
20932
20966
|
if (covered.has(`${r},${c}`)) continue;
|
|
20933
20967
|
const headerCell = headerRow[c];
|
|
20934
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20968
|
+
const valueCell = _optionalChain([table2, 'access', _232 => _232.cells, 'access', _233 => _233[r], 'optionalAccess', _234 => _234[c]]);
|
|
20935
20969
|
if (!headerCell || !valueCell) continue;
|
|
20936
20970
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
20937
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20971
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _235 => _235.has, 'call', _236 => _236(headerLabel)])) continue;
|
|
20938
20972
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
20939
20973
|
if (matchKey === void 0) continue;
|
|
20940
20974
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
20941
20975
|
const newValue = values.consume(matchKey);
|
|
20942
20976
|
if (newValue === void 0) continue;
|
|
20943
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20977
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _237 => _237.has, 'call', _238 => _238(valueCell)])) {
|
|
20944
20978
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20945
20979
|
} else {
|
|
20946
20980
|
valueCell.text = newValue;
|
|
@@ -20972,7 +21006,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
20972
21006
|
if (newValue === void 0) continue;
|
|
20973
21007
|
matchedLabels.add(matchKey);
|
|
20974
21008
|
filled.push({ label: matched.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
|
|
20975
|
-
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)));
|
|
20976
21010
|
out += text.slice(pos, seg.valueStart);
|
|
20977
21011
|
out += seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
20978
21012
|
pos = ve;
|
|
@@ -21534,19 +21568,19 @@ function parseCentralDirectory(buf) {
|
|
|
21534
21568
|
}
|
|
21535
21569
|
}
|
|
21536
21570
|
}
|
|
21537
|
-
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");
|
|
21538
21572
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21539
21573
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21540
21574
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21541
|
-
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");
|
|
21542
21576
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21543
|
-
throw new (0,
|
|
21577
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21544
21578
|
}
|
|
21545
21579
|
const decoder = new TextDecoder("utf-8");
|
|
21546
21580
|
const entries = [];
|
|
21547
21581
|
let pos = cdOffset;
|
|
21548
21582
|
for (let i = 0; i < totalEntries; i++) {
|
|
21549
|
-
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");
|
|
21550
21584
|
const flags = view.getUint16(pos + 8, true);
|
|
21551
21585
|
const method = view.getUint16(pos + 10, true);
|
|
21552
21586
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21557,7 +21591,7 @@ function parseCentralDirectory(buf) {
|
|
|
21557
21591
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21558
21592
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21559
21593
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21560
|
-
throw new (0,
|
|
21594
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21561
21595
|
}
|
|
21562
21596
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21563
21597
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21586,11 +21620,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21586
21620
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21587
21621
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21588
21622
|
for (const name of replacements.keys()) {
|
|
21589
|
-
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}`);
|
|
21590
21624
|
}
|
|
21591
21625
|
if (additions) {
|
|
21592
21626
|
for (const name of additions.keys()) {
|
|
21593
|
-
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}`);
|
|
21594
21628
|
}
|
|
21595
21629
|
}
|
|
21596
21630
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21609,7 +21643,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21609
21643
|
offset += seg.length;
|
|
21610
21644
|
continue;
|
|
21611
21645
|
}
|
|
21612
|
-
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");
|
|
21613
21647
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21614
21648
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21615
21649
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21617,7 +21651,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21617
21651
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21618
21652
|
const method = e.method;
|
|
21619
21653
|
if (method !== 0 && method !== 8) {
|
|
21620
|
-
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`);
|
|
21621
21655
|
}
|
|
21622
21656
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21623
21657
|
const crc = crc32(newData);
|
|
@@ -21718,7 +21752,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21718
21752
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21719
21753
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21720
21754
|
if (sectionPaths.length === 0) {
|
|
21721
|
-
throw new (0,
|
|
21755
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21722
21756
|
}
|
|
21723
21757
|
const warnings = [];
|
|
21724
21758
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -21802,7 +21836,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21802
21836
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
21803
21837
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
21804
21838
|
if (!normalizedCellLabel) continue;
|
|
21805
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21839
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _241 => _241.has, 'call', _242 => _242(normalizedCellLabel)])) continue;
|
|
21806
21840
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
21807
21841
|
if (matchKey === void 0) continue;
|
|
21808
21842
|
if (patternApplied.has(valueCell)) {
|
|
@@ -21860,7 +21894,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21860
21894
|
const dataCells = table2.rows[rowIdx];
|
|
21861
21895
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
21862
21896
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
21863
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21897
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _243 => _243.has, 'call', _244 => _244(headerLabel)])) continue;
|
|
21864
21898
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
21865
21899
|
if (matchKey === void 0) continue;
|
|
21866
21900
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -21914,7 +21948,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21914
21948
|
}
|
|
21915
21949
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
21916
21950
|
const existing = ledger.get(para2);
|
|
21917
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
21951
|
+
if (_optionalChain([existing, 'optionalAccess', _245 => _245.fullText]) !== void 0) continue;
|
|
21918
21952
|
const text = matchText(para2);
|
|
21919
21953
|
const segments = scanInlineSegments(text);
|
|
21920
21954
|
const matches = segments.map((seg) => matchInlineSegment(seg, cursor, blockedLabels));
|
|
@@ -21925,7 +21959,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21925
21959
|
const matchKey = matched.key;
|
|
21926
21960
|
const newValue = cursor.consume(matchKey);
|
|
21927
21961
|
if (newValue === void 0) continue;
|
|
21928
|
-
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)));
|
|
21929
21963
|
const replacement = seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
21930
21964
|
const l = led(para2);
|
|
21931
21965
|
l.ranges.push({ start: seg.valueStart, end: ve, replacement });
|
|
@@ -22031,16 +22065,16 @@ var PARA_LIST = 7;
|
|
|
22031
22065
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
22032
22066
|
function resolveTheme(theme) {
|
|
22033
22067
|
return {
|
|
22034
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22035
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22036
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22037
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22038
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22039
|
-
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)),
|
|
22040
22074
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
22041
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
22042
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22043
|
-
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])
|
|
22044
22078
|
};
|
|
22045
22079
|
}
|
|
22046
22080
|
function escapeXml(text) {
|
|
@@ -22455,7 +22489,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22455
22489
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22456
22490
|
const got = m ? Number(m[1]) : NaN;
|
|
22457
22491
|
if (got !== startId + i) {
|
|
22458
|
-
throw new (0,
|
|
22492
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
22459
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)`
|
|
22460
22494
|
);
|
|
22461
22495
|
}
|
|
@@ -22539,7 +22573,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22539
22573
|
}
|
|
22540
22574
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22541
22575
|
if (rows.length !== expectedBase) {
|
|
22542
|
-
throw new (0,
|
|
22576
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
22543
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`
|
|
22544
22578
|
);
|
|
22545
22579
|
}
|
|
@@ -22766,7 +22800,7 @@ function buildStyles(gongmun) {
|
|
|
22766
22800
|
</hh:styles>`;
|
|
22767
22801
|
}
|
|
22768
22802
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
22769
|
-
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")));
|
|
22770
22804
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
22771
22805
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
22772
22806
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22895,8 +22929,8 @@ function parseChartFence(text) {
|
|
|
22895
22929
|
const spec = chartSpec(type);
|
|
22896
22930
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22897
22931
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22898
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22899
|
-
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}`)));
|
|
22900
22934
|
if (!spec.scatter) {
|
|
22901
22935
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22902
22936
|
}
|
|
@@ -22938,7 +22972,7 @@ function serSpPr(color, stroke) {
|
|
|
22938
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>`;
|
|
22939
22973
|
}
|
|
22940
22974
|
function dPtXml(pointColors, pie) {
|
|
22941
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
22975
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _269 => _269.length])) return "";
|
|
22942
22976
|
return pointColors.map((col, i) => {
|
|
22943
22977
|
const f = chartColorFill(col);
|
|
22944
22978
|
if (!f) return "";
|
|
@@ -23177,8 +23211,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
23177
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 });
|
|
23178
23212
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
23179
23213
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
23180
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23181
|
-
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]), () => ( ""));
|
|
23182
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>`;
|
|
23183
23217
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
23184
23218
|
return [
|
|
@@ -23434,7 +23468,7 @@ function escapeGfm(text) {
|
|
|
23434
23468
|
}
|
|
23435
23469
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23436
23470
|
function sanitizeText(text) {
|
|
23437
|
-
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();
|
|
23438
23472
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23439
23473
|
const tokens = result.split(" ");
|
|
23440
23474
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23464,7 +23498,7 @@ function replicateGfmTable(table2) {
|
|
|
23464
23498
|
for (let r = 0; r < numRows; r++) {
|
|
23465
23499
|
for (let c = 0; c < numCols; c++) {
|
|
23466
23500
|
if (skip.has(`${r},${c}`)) continue;
|
|
23467
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23501
|
+
const cell2 = _optionalChain([cells, 'access', _274 => _274[r], 'optionalAccess', _275 => _275[c]]);
|
|
23468
23502
|
if (!cell2) continue;
|
|
23469
23503
|
display[r][c] = {
|
|
23470
23504
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -23518,7 +23552,7 @@ function unescapeGfmCell(text) {
|
|
|
23518
23552
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
|
|
23519
23553
|
}
|
|
23520
23554
|
function replicateCellInnerHtml(cell2) {
|
|
23521
|
-
if (_optionalChain([cell2, 'access',
|
|
23555
|
+
if (_optionalChain([cell2, 'access', _276 => _276.blocks, 'optionalAccess', _277 => _277.length])) {
|
|
23522
23556
|
return cell2.blocks.map((b) => {
|
|
23523
23557
|
if (b.type === "table" && b.table) {
|
|
23524
23558
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -23557,7 +23591,7 @@ function replicateHtmlTable(table2) {
|
|
|
23557
23591
|
const rowCells = [];
|
|
23558
23592
|
for (let c = 0; c < numCols; c++) {
|
|
23559
23593
|
if (skip.has(`${r},${c}`)) continue;
|
|
23560
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23594
|
+
const cell2 = _optionalChain([cells, 'access', _278 => _278[r], 'optionalAccess', _279 => _279[c]]);
|
|
23561
23595
|
if (!cell2) continue;
|
|
23562
23596
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
23563
23597
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -23603,10 +23637,10 @@ function parseHtmlTable(raw) {
|
|
|
23603
23637
|
}
|
|
23604
23638
|
} else {
|
|
23605
23639
|
if (!isClose) {
|
|
23606
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
23607
|
-
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);
|
|
23608
23642
|
cellStart = m.index + m[0].length;
|
|
23609
|
-
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) };
|
|
23610
23644
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23611
23645
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23612
23646
|
cellStart = -1;
|
|
@@ -23630,7 +23664,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
23630
23664
|
hadNonText = true;
|
|
23631
23665
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
23632
23666
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
23633
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
23667
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _286 => _286[1]]), () => ( _optionalChain([m, 'optionalAccess', _287 => _287[2]])));
|
|
23634
23668
|
if (src) imgSrcs.push(src);
|
|
23635
23669
|
return "";
|
|
23636
23670
|
});
|
|
@@ -23761,7 +23795,7 @@ function edgeXml(tag, d) {
|
|
|
23761
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"/>`;
|
|
23762
23796
|
}
|
|
23763
23797
|
function borderFillDefToXml(id, def) {
|
|
23764
|
-
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>` : "";
|
|
23765
23799
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
23766
23800
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
23767
23801
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -24166,11 +24200,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
24166
24200
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
24167
24201
|
const rowCnt = rows.length;
|
|
24168
24202
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
24169
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24203
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _290 => _290.bfRegistry]), () => ( null));
|
|
24170
24204
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
24171
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24205
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _291 => _291.charHeight]), () => ( 1e3));
|
|
24172
24206
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
24173
|
-
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);
|
|
24174
24208
|
const colMax = Array(colCnt).fill(0);
|
|
24175
24209
|
const colMaxBody = Array(colCnt).fill(0);
|
|
24176
24210
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -24198,7 +24232,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24198
24232
|
const k = `${rowIdx},${colIdx}`;
|
|
24199
24233
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
24200
24234
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
24201
|
-
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));
|
|
24202
24236
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
24203
24237
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24204
24238
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -24216,11 +24250,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24216
24250
|
}
|
|
24217
24251
|
}
|
|
24218
24252
|
}
|
|
24219
|
-
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);
|
|
24220
24254
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
24221
24255
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
24222
24256
|
}).join("");
|
|
24223
|
-
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({
|
|
24224
24258
|
row: rowIdx,
|
|
24225
24259
|
rowEnd: rowIdx,
|
|
24226
24260
|
col: colIdx,
|
|
@@ -24230,7 +24264,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24230
24264
|
headerRows: 1,
|
|
24231
24265
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
24232
24266
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
24233
|
-
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));
|
|
24234
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>`;
|
|
24235
24269
|
}).join("");
|
|
24236
24270
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -24239,7 +24273,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24239
24273
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
24240
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;
|
|
24241
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>`;
|
|
24242
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
24276
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _306 => _306.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
24243
24277
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
24244
24278
|
}
|
|
24245
24279
|
function layoutHtmlRows(rows) {
|
|
@@ -24250,8 +24284,8 @@ function layoutHtmlRows(rows) {
|
|
|
24250
24284
|
let c = 0;
|
|
24251
24285
|
for (const cell2 of rows[r].cells) {
|
|
24252
24286
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24253
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24254
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24287
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkWMU2KJHFcjs.MAX_COLS);
|
|
24288
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkWMU2KJHFcjs.MAX_ROWS);
|
|
24255
24289
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24256
24290
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24257
24291
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -24279,7 +24313,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24279
24313
|
if (!rows || rows.length === 0) return null;
|
|
24280
24314
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
24281
24315
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
24282
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24316
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _307 => _307.charHeight]), () => ( 1e3));
|
|
24283
24317
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
24284
24318
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
24285
24319
|
for (const cell2 of placed) {
|
|
@@ -24308,7 +24342,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24308
24342
|
const tblId = nextTableId();
|
|
24309
24343
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
24310
24344
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
24311
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24345
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _308 => _308.bfRegistry]), () => ( null));
|
|
24312
24346
|
let htmlHeaderRows = 0;
|
|
24313
24347
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
24314
24348
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -24323,7 +24357,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24323
24357
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
24324
24358
|
if (nestedXml) {
|
|
24325
24359
|
nestedXmls.push(nestedXml);
|
|
24326
|
-
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]]);
|
|
24327
24361
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
24328
24362
|
}
|
|
24329
24363
|
}
|
|
@@ -24332,7 +24366,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24332
24366
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
24333
24367
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
24334
24368
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
24335
|
-
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);
|
|
24336
24370
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
24337
24371
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
24338
24372
|
return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
|
|
@@ -24343,7 +24377,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24343
24377
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
24344
24378
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
24345
24379
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
24346
|
-
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));
|
|
24347
24381
|
const centered = isHeader || colCentered[cell2.c];
|
|
24348
24382
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24349
24383
|
const picUrls = images ? [...imgSrcs] : [];
|
|
@@ -24379,7 +24413,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24379
24413
|
let cellHeight = 0;
|
|
24380
24414
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
24381
24415
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
24382
|
-
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({
|
|
24383
24417
|
row: cell2.r,
|
|
24384
24418
|
rowEnd,
|
|
24385
24419
|
col: cell2.c,
|
|
@@ -24549,7 +24583,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
24549
24583
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
24550
24584
|
}
|
|
24551
24585
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
24552
|
-
const c = _optionalChain([g, 'access',
|
|
24586
|
+
const c = _optionalChain([g, 'access', _321 => _321.press, 'optionalAccess', _322 => _322.contact]);
|
|
24553
24587
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
24554
24588
|
const w = bodyWidth - 280;
|
|
24555
24589
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -24930,7 +24964,7 @@ function generateSecPr(gongmun) {
|
|
|
24930
24964
|
}
|
|
24931
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>`;
|
|
24932
24966
|
const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
|
|
24933
|
-
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess',
|
|
24967
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _323 => _323.pageNumbers]) ? pageNumCtrl() : "");
|
|
24934
24968
|
}
|
|
24935
24969
|
var SectionOpener = (_class6 = class {
|
|
24936
24970
|
constructor(gongmun) {;_class6.prototype.__init12.call(this);
|
|
@@ -24969,19 +25003,19 @@ function buildPreamble(blocks, ctx) {
|
|
|
24969
25003
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
24970
25004
|
const preamble = [];
|
|
24971
25005
|
let hasFrontPages = false;
|
|
24972
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25006
|
+
if (_optionalChain([gongmun, 'optionalAccess', _324 => _324.reportInfo]) && dfIds) {
|
|
24973
25007
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
24974
25008
|
}
|
|
24975
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25009
|
+
if (_optionalChain([gongmun, 'optionalAccess', _325 => _325.approval]) && bfReg) {
|
|
24976
25010
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
24977
25011
|
}
|
|
24978
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25012
|
+
if (_optionalChain([gongmun, 'optionalAccess', _326 => _326.docHead]) && dfIds) {
|
|
24979
25013
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
24980
25014
|
}
|
|
24981
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25015
|
+
if (_optionalChain([gongmun, 'optionalAccess', _327 => _327.noticeHead]) && dfIds) {
|
|
24982
25016
|
preamble.push(...buildNoticeHead(gongmun));
|
|
24983
25017
|
}
|
|
24984
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25018
|
+
if (_optionalChain([gongmun, 'optionalAccess', _328 => _328.press]) && dfIds && bfReg && tableStyle) {
|
|
24985
25019
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
24986
25020
|
}
|
|
24987
25021
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -25010,7 +25044,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
25010
25044
|
}
|
|
25011
25045
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
25012
25046
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25013
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
25047
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _329 => _329.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
25014
25048
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25015
25049
|
}
|
|
25016
25050
|
if (preamble.length > 0) {
|
|
@@ -25025,7 +25059,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
25025
25059
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
25026
25060
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
25027
25061
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
25028
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
25062
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _330 => _330.press, 'optionalAccess', _331 => _331.sub]), () => ( []))) {
|
|
25029
25063
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
25030
25064
|
}
|
|
25031
25065
|
return parts.join("\n ");
|
|
@@ -25119,8 +25153,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25119
25153
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
25120
25154
|
if (gongmun && gongmunList) {
|
|
25121
25155
|
const info = gongmunList.items.get(blockIdx);
|
|
25122
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25123
|
-
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]), () => ( ""));
|
|
25124
25158
|
const content = block.text || "";
|
|
25125
25159
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
25126
25160
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -25129,7 +25163,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25129
25163
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
25130
25164
|
}
|
|
25131
25165
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
25132
|
-
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;
|
|
25133
25167
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
25134
25168
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
25135
25169
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -25188,18 +25222,18 @@ function renderHtmlTable(block, ctx) {
|
|
|
25188
25222
|
}
|
|
25189
25223
|
function appendPostamble(blocks, ctx) {
|
|
25190
25224
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
25191
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25225
|
+
if (_optionalChain([gongmun, 'optionalAccess', _335 => _335.noticeHead]) && dfIds) {
|
|
25192
25226
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
25193
25227
|
}
|
|
25194
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25195
|
-
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]));
|
|
25196
25230
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
25197
25231
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
25198
25232
|
}
|
|
25199
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25233
|
+
if (_optionalChain([gongmun, 'optionalAccess', _339 => _339.docFoot]) && dfIds) {
|
|
25200
25234
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
25201
25235
|
}
|
|
25202
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25236
|
+
if (_optionalChain([gongmun, 'optionalAccess', _340 => _340.press]) && dfIds && bfReg && tableStyle) {
|
|
25203
25237
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25204
25238
|
}
|
|
25205
25239
|
}
|
|
@@ -25219,7 +25253,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25219
25253
|
remap,
|
|
25220
25254
|
dfIds,
|
|
25221
25255
|
images,
|
|
25222
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
25256
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _341 => _341.preset]) === "gaejosik",
|
|
25223
25257
|
measured,
|
|
25224
25258
|
richAssets,
|
|
25225
25259
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -25325,18 +25359,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25325
25359
|
|
|
25326
25360
|
// src/hwpx/generator.ts
|
|
25327
25361
|
async function markdownToHwpx(markdown, options) {
|
|
25328
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
25329
|
-
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;
|
|
25330
25364
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
25331
25365
|
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
25332
25366
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
25333
25367
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
25334
25368
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
25335
25369
|
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
25336
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
25337
|
-
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;
|
|
25338
25372
|
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
25339
|
-
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)));
|
|
25340
25374
|
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
25341
25375
|
const chartParts = [];
|
|
25342
25376
|
const images = new ImageRegistry();
|
|
@@ -25347,7 +25381,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25347
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)`);
|
|
25348
25382
|
}
|
|
25349
25383
|
}
|
|
25350
|
-
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()]), () => ( []))];
|
|
25351
25385
|
const zip = new (0, _jszip2.default)();
|
|
25352
25386
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
25353
25387
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
@@ -25356,11 +25390,11 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25356
25390
|
zip.file("Contents/header.xml", generateHeaderXml(
|
|
25357
25391
|
theme,
|
|
25358
25392
|
gongmun,
|
|
25359
|
-
_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25393
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _356 => _356.variants]), () => ( [])),
|
|
25360
25394
|
extraBorderFills,
|
|
25361
|
-
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25362
|
-
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess',
|
|
25363
|
-
_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]), () => ( []))
|
|
25364
25398
|
));
|
|
25365
25399
|
zip.file("Contents/section0.xml", sectionXml);
|
|
25366
25400
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
@@ -25411,7 +25445,7 @@ function alignBlocks(a, b) {
|
|
|
25411
25445
|
const m = a.length, n = b.length;
|
|
25412
25446
|
if (m * n > 1e7) return fallbackAlign(a, b);
|
|
25413
25447
|
const lenOf = (blk) => {
|
|
25414
|
-
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(" ") : "";
|
|
25415
25449
|
return t.replace(/\s+/g, " ").trim().length;
|
|
25416
25450
|
};
|
|
25417
25451
|
const aLen = a.map(lenOf);
|
|
@@ -25484,8 +25518,8 @@ function blockSimilarity(a, b) {
|
|
|
25484
25518
|
}
|
|
25485
25519
|
function tableSimilarity(a, b) {
|
|
25486
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);
|
|
25487
|
-
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
25488
|
-
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(" ");
|
|
25489
25523
|
const contentSim = normalizedSimilarity(textsA, textsB);
|
|
25490
25524
|
return dimSim * 0.3 + contentSim * 0.7;
|
|
25491
25525
|
}
|
|
@@ -25496,8 +25530,8 @@ function diffTableCells(a, b) {
|
|
|
25496
25530
|
for (let r = 0; r < maxRows; r++) {
|
|
25497
25531
|
const row = [];
|
|
25498
25532
|
for (let c = 0; c < maxCols; c++) {
|
|
25499
|
-
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access',
|
|
25500
|
-
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;
|
|
25501
25535
|
let type;
|
|
25502
25536
|
if (cellA === void 0) type = "added";
|
|
25503
25537
|
else if (cellB === void 0) type = "removed";
|
|
@@ -25663,7 +25697,7 @@ function parseRenderStyles(headXml) {
|
|
|
25663
25697
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
25664
25698
|
const textColor = el.getAttribute("textColor");
|
|
25665
25699
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
25666
|
-
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")])));
|
|
25667
25701
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
25668
25702
|
styles.charPr.set(id, {
|
|
25669
25703
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -25671,8 +25705,8 @@ function parseRenderStyles(headXml) {
|
|
|
25671
25705
|
italic: findChildByLocalName(el, "italic") != null,
|
|
25672
25706
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
25673
25707
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
25674
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
25675
|
-
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,
|
|
25676
25710
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
25677
25711
|
face
|
|
25678
25712
|
});
|
|
@@ -25681,7 +25715,7 @@ function parseRenderStyles(headXml) {
|
|
|
25681
25715
|
const id = el.getAttribute("id");
|
|
25682
25716
|
if (id != null) {
|
|
25683
25717
|
const align = findChildByLocalName(el, "align");
|
|
25684
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
25718
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _379 => _379.getAttribute, 'call', _380 => _380("horizontal")]) || "JUSTIFY");
|
|
25685
25719
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
25686
25720
|
}
|
|
25687
25721
|
} else if (tag === "borderFill") {
|
|
@@ -25695,7 +25729,7 @@ function parseRenderStyles(headXml) {
|
|
|
25695
25729
|
};
|
|
25696
25730
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
25697
25731
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
25698
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
25732
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _381 => _381.getAttribute, 'call', _382 => _382("faceColor")]);
|
|
25699
25733
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
25700
25734
|
styles.borderFill.set(id, bf);
|
|
25701
25735
|
}
|
|
@@ -25767,7 +25801,7 @@ function collectSites(scan) {
|
|
|
25767
25801
|
}
|
|
25768
25802
|
function attrOf(openTag, name) {
|
|
25769
25803
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
25770
|
-
return _optionalChain([m, 'optionalAccess',
|
|
25804
|
+
return _optionalChain([m, 'optionalAccess', _383 => _383[1]]);
|
|
25771
25805
|
}
|
|
25772
25806
|
function paraOpenTag(xml, para2) {
|
|
25773
25807
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -25782,7 +25816,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
25782
25816
|
if (!tr) return null;
|
|
25783
25817
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
25784
25818
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
25785
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
25819
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _384 => _384[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
25786
25820
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
25787
25821
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
25788
25822
|
if (close === -1) return null;
|
|
@@ -25809,7 +25843,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
25809
25843
|
if (width === null) return null;
|
|
25810
25844
|
let content = width;
|
|
25811
25845
|
const win = cellAddrWindow(xml, cell2);
|
|
25812
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
25846
|
+
const mg = _optionalChain([win, 'optionalAccess', _385 => _385.match, 'call', _386 => _386(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
25813
25847
|
if (mg) {
|
|
25814
25848
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
25815
25849
|
}
|
|
@@ -25843,11 +25877,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25843
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>`;
|
|
25844
25878
|
}
|
|
25845
25879
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25846
|
-
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");
|
|
25847
25881
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25848
25882
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25849
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
25850
|
-
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");
|
|
25851
25885
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25852
25886
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25853
25887
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25888,11 +25922,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25888
25922
|
const manifestItems = [];
|
|
25889
25923
|
const placed = [];
|
|
25890
25924
|
for (const op of ops) {
|
|
25891
|
-
if (!op.anchor) throw new (0,
|
|
25892
|
-
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");
|
|
25893
25927
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25894
|
-
if (!MIME[ext]) throw new (0,
|
|
25895
|
-
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)`);
|
|
25896
25930
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25897
25931
|
let found = null;
|
|
25898
25932
|
let total = 0;
|
|
@@ -25925,7 +25959,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25925
25959
|
}
|
|
25926
25960
|
}
|
|
25927
25961
|
}
|
|
25928
|
-
throw new (0,
|
|
25962
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
25929
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)})`
|
|
25930
25964
|
);
|
|
25931
25965
|
}
|
|
@@ -25933,9 +25967,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25933
25967
|
const xml = sectionXmls[si];
|
|
25934
25968
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25935
25969
|
if (!run) {
|
|
25936
|
-
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`);
|
|
25937
25971
|
}
|
|
25938
|
-
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));
|
|
25939
25973
|
const fontPt = charPrHeight / 100;
|
|
25940
25974
|
const emMm = fontPt * 25.4 / 72;
|
|
25941
25975
|
const lineHMm = emMm;
|
|
@@ -25944,7 +25978,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25944
25978
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
25945
25979
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
25946
25980
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
25947
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
25981
|
+
const align = _optionalChain([styles, 'optionalAccess', _397 => _397.paraAlign, 'access', _398 => _398.get, 'call', _399 => _399(paraPrId)]);
|
|
25948
25982
|
let alignShiftMm = 0;
|
|
25949
25983
|
if (align === "CENTER" || align === "RIGHT") {
|
|
25950
25984
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -26040,7 +26074,7 @@ function parseBorderFills(headerDoc) {
|
|
|
26040
26074
|
};
|
|
26041
26075
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
26042
26076
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26043
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26077
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _400 => _400.getAttribute, 'call', _401 => _401("faceColor")]);
|
|
26044
26078
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
26045
26079
|
map.set(id, def);
|
|
26046
26080
|
}
|
|
@@ -26072,7 +26106,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
26072
26106
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
26073
26107
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
26074
26108
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
26075
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
26109
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _402 => _402.getAttribute, 'call', _403 => _403("hangul")]);
|
|
26076
26110
|
if (hangul) {
|
|
26077
26111
|
def.fontRef_hangul = hangul;
|
|
26078
26112
|
const face = hangulFonts.get(hangul);
|
|
@@ -26100,7 +26134,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26100
26134
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
26101
26135
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
26102
26136
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
26103
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
26137
|
+
const width = _optionalChain([sz, 'optionalAccess', _404 => _404.getAttribute, 'call', _405 => _405("width")]) || void 0;
|
|
26104
26138
|
const cells = [];
|
|
26105
26139
|
const usedBf = /* @__PURE__ */ new Set();
|
|
26106
26140
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -26113,17 +26147,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26113
26147
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
26114
26148
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
26115
26149
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
26116
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26117
|
-
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));
|
|
26118
26152
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
26119
26153
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
26120
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26121
|
-
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));
|
|
26122
26156
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
26123
26157
|
const cpId = firstRunCharPr(tc2);
|
|
26124
26158
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
26125
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
26126
|
-
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")]);
|
|
26127
26161
|
if (w) cell2.width_hwpunit = w;
|
|
26128
26162
|
if (hh) cell2.height_hwpunit = hh;
|
|
26129
26163
|
if (bfId) {
|
|
@@ -26211,16 +26245,16 @@ function pick(map, keys) {
|
|
|
26211
26245
|
return out;
|
|
26212
26246
|
}
|
|
26213
26247
|
async function hwpxToProfile(input) {
|
|
26214
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26248
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, input);
|
|
26215
26249
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26216
26250
|
const parser = createXmlParser();
|
|
26217
|
-
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]])));
|
|
26218
26252
|
let headerXml = "<root/>";
|
|
26219
26253
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
26220
26254
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
26221
26255
|
const borderFills = parseBorderFills(headerDoc);
|
|
26222
26256
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
26223
|
-
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))));
|
|
26224
26258
|
const tables = [];
|
|
26225
26259
|
let tableIndex = 0;
|
|
26226
26260
|
for (const f of sectionFiles) {
|
|
@@ -26534,7 +26568,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
26534
26568
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
26535
26569
|
function patchTableRows(input) {
|
|
26536
26570
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
26537
|
-
const xml = _optionalChain([ctx, 'access',
|
|
26571
|
+
const xml = _optionalChain([ctx, 'access', _429 => _429.scans, 'access', _430 => _430[scanTable.sectionIndex], 'optionalAccess', _431 => _431.xml]);
|
|
26538
26572
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
26539
26573
|
const numRows = table2.rows;
|
|
26540
26574
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -26701,7 +26735,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
26701
26735
|
const rr = scanTable.rowRanges[template];
|
|
26702
26736
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
26703
26737
|
const scan = scanSectionXml(wrapped, 0);
|
|
26704
|
-
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]]);
|
|
26705
26739
|
if (!row || row.length !== cells.length) return null;
|
|
26706
26740
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
26707
26741
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -26744,7 +26778,7 @@ function rowHeightOf(fragment) {
|
|
|
26744
26778
|
}
|
|
26745
26779
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
26746
26780
|
const from = scanTable.start + tblOpenLen;
|
|
26747
|
-
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));
|
|
26748
26782
|
const slice = xml.slice(from, to);
|
|
26749
26783
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
26750
26784
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -26933,9 +26967,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
26933
26967
|
});
|
|
26934
26968
|
}
|
|
26935
26969
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
26936
|
-
const irCell = _optionalChain([table2, 'access',
|
|
26970
|
+
const irCell = _optionalChain([table2, 'access', _439 => _439.cells, 'access', _440 => _440[oc.gridR], 'optionalAccess', _441 => _441[oc.gridC]]);
|
|
26937
26971
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
26938
|
-
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);
|
|
26939
26973
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
26940
26974
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
26941
26975
|
}
|
|
@@ -27003,7 +27037,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27003
27037
|
};
|
|
27004
27038
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
27005
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)");
|
|
27006
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27040
|
+
const irCell = _optionalChain([table2, 'access', _443 => _443.cells, 'access', _444 => _444[gridR], 'optionalAccess', _445 => _445[gridC]]);
|
|
27007
27041
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
27008
27042
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27009
27043
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27026,7 +27060,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27026
27060
|
if (newLines.length === 0) return 0;
|
|
27027
27061
|
const target = cell2.paragraphs[0];
|
|
27028
27062
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
27029
|
-
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]));
|
|
27030
27064
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27031
27065
|
splices.push(...sp);
|
|
27032
27066
|
sectionIndex = target.sectionIndex;
|
|
@@ -27049,7 +27083,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27049
27083
|
}
|
|
27050
27084
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
27051
27085
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
27052
|
-
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]));
|
|
27053
27087
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27054
27088
|
splices.push(...sp);
|
|
27055
27089
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -27130,7 +27164,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27130
27164
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27131
27165
|
if (paths.length > 0) return paths;
|
|
27132
27166
|
}
|
|
27133
|
-
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);
|
|
27134
27168
|
}
|
|
27135
27169
|
function sectionPathsFromManifest(xml) {
|
|
27136
27170
|
const attr = (tag, name) => {
|
|
@@ -27140,7 +27174,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27140
27174
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27141
27175
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27142
27176
|
const id = attr(m[1], "id");
|
|
27143
|
-
const href =
|
|
27177
|
+
const href = _chunkKKZATKQWcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27144
27178
|
if (id && href) idToHref.set(id, href);
|
|
27145
27179
|
}
|
|
27146
27180
|
const ordered = [];
|
|
@@ -27149,7 +27183,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27149
27183
|
if (href) ordered.push(href);
|
|
27150
27184
|
}
|
|
27151
27185
|
if (ordered.length > 0) return ordered;
|
|
27152
|
-
return Array.from(idToHref.values()).sort(
|
|
27186
|
+
return Array.from(idToHref.values()).sort(_chunkKKZATKQWcjs.compareSectionPaths);
|
|
27153
27187
|
}
|
|
27154
27188
|
|
|
27155
27189
|
// src/roundtrip/patcher.ts
|
|
@@ -27241,7 +27275,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
27241
27275
|
}
|
|
27242
27276
|
}
|
|
27243
27277
|
let verification;
|
|
27244
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27278
|
+
if (_optionalChain([options, 'optionalAccess', _452 => _452.verify]) !== false) {
|
|
27245
27279
|
try {
|
|
27246
27280
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
27247
27281
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -27259,17 +27293,17 @@ function buildOrigUnits(blocks) {
|
|
|
27259
27293
|
let chunk;
|
|
27260
27294
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27261
27295
|
const next = blocks[i + 1];
|
|
27262
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
27263
|
-
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));
|
|
27264
27298
|
} else {
|
|
27265
|
-
chunk =
|
|
27299
|
+
chunk = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27266
27300
|
}
|
|
27267
27301
|
if (chunk) {
|
|
27268
27302
|
const subUnits = splitMarkdownUnits(chunk);
|
|
27269
27303
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
27270
27304
|
for (let s = 0; s < subUnits.length; s++) {
|
|
27271
27305
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
27272
|
-
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("**")) {
|
|
27273
27307
|
u.role = "caption";
|
|
27274
27308
|
}
|
|
27275
27309
|
units.push(u);
|
|
@@ -27380,7 +27414,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27380
27414
|
const ti = ctx.tableInsert;
|
|
27381
27415
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
27382
27416
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27383
|
-
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");
|
|
27384
27418
|
const para2 = mapping.para;
|
|
27385
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");
|
|
27386
27420
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -27408,7 +27442,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27408
27442
|
}
|
|
27409
27443
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
27410
27444
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27411
|
-
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)");
|
|
27412
27446
|
if (block.text && block.text.includes("\n")) {
|
|
27413
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)");
|
|
27414
27448
|
}
|
|
@@ -27439,7 +27473,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
27439
27473
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27440
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");
|
|
27441
27475
|
}
|
|
27442
|
-
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]));
|
|
27443
27477
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27444
27478
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27445
27479
|
return 1;
|
|
@@ -27628,7 +27662,7 @@ var Surgeon = (_class7 = class {
|
|
|
27628
27662
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
27629
27663
|
findEntry(path) {
|
|
27630
27664
|
const parts = path.replace(/^\//, "").split("/");
|
|
27631
|
-
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));
|
|
27632
27666
|
let current;
|
|
27633
27667
|
for (const part of parts) {
|
|
27634
27668
|
const search = (idx) => {
|
|
@@ -27867,8 +27901,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
27867
27901
|
parts.push(header, data);
|
|
27868
27902
|
};
|
|
27869
27903
|
for (let i = 0; i < recs.length; i++) {
|
|
27870
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
27871
|
-
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)));
|
|
27872
27906
|
}
|
|
27873
27907
|
return Buffer.concat(parts);
|
|
27874
27908
|
}
|
|
@@ -27986,7 +28020,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27986
28020
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
27987
28021
|
}
|
|
27988
28022
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
27989
|
-
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");
|
|
27990
28024
|
let flags;
|
|
27991
28025
|
try {
|
|
27992
28026
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -28008,7 +28042,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28008
28042
|
const scans = [];
|
|
28009
28043
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
28010
28044
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
28011
|
-
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]}`);
|
|
28012
28046
|
let stream;
|
|
28013
28047
|
try {
|
|
28014
28048
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -28059,7 +28093,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28059
28093
|
}
|
|
28060
28094
|
}
|
|
28061
28095
|
let verification;
|
|
28062
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28096
|
+
if (_optionalChain([options, 'optionalAccess', _470 => _470.verify]) !== false) {
|
|
28063
28097
|
try {
|
|
28064
28098
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
28065
28099
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -28149,7 +28183,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
28149
28183
|
for (const [key, scanCell] of scanTable.cells) {
|
|
28150
28184
|
const comma = key.indexOf(",");
|
|
28151
28185
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
28152
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
28186
|
+
const irCell = _optionalChain([irTable, 'access', _471 => _471.cells, 'access', _472 => _472[r], 'optionalAccess', _473 => _473[c]]);
|
|
28153
28187
|
if (!irCell) continue;
|
|
28154
28188
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
28155
28189
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -28185,7 +28219,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
28185
28219
|
}
|
|
28186
28220
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
28187
28221
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28188
|
-
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)");
|
|
28189
28223
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
28190
28224
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
28191
28225
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -28384,7 +28418,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
28384
28418
|
};
|
|
28385
28419
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
28386
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)");
|
|
28387
|
-
const irCell = _optionalChain([table2, 'access',
|
|
28421
|
+
const irCell = _optionalChain([table2, 'access', _475 => _475.cells, 'access', _476 => _476[gridR], 'optionalAccess', _477 => _477[gridC]]);
|
|
28388
28422
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
28389
28423
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
28390
28424
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -28791,11 +28825,11 @@ var RULES2 = {
|
|
|
28791
28825
|
}
|
|
28792
28826
|
};
|
|
28793
28827
|
function redactText(text, options) {
|
|
28794
|
-
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28828
|
+
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _478 => _478.maskChar]), () => ( "\u25CF"));
|
|
28795
28829
|
if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
|
|
28796
28830
|
throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
|
|
28797
28831
|
}
|
|
28798
|
-
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28832
|
+
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _479 => _479.rules]), () => ( DEFAULT_REDACT_RULES));
|
|
28799
28833
|
const hits = [];
|
|
28800
28834
|
if (text === "" || enabled.length === 0) return { text, hits };
|
|
28801
28835
|
const occupied = [];
|
|
@@ -28850,8 +28884,8 @@ function sameBreadcrumb(a, b) {
|
|
|
28850
28884
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
28851
28885
|
}
|
|
28852
28886
|
function blocksToChunks(blocks, options) {
|
|
28853
|
-
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28854
|
-
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));
|
|
28855
28889
|
const chunks = [];
|
|
28856
28890
|
const headingStack = [];
|
|
28857
28891
|
const listStack = [];
|
|
@@ -28865,12 +28899,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28865
28899
|
let run = null;
|
|
28866
28900
|
const flushRun = () => {
|
|
28867
28901
|
if (!run) return;
|
|
28868
|
-
push("text", run.breadcrumb,
|
|
28902
|
+
push("text", run.breadcrumb, _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28869
28903
|
run = null;
|
|
28870
28904
|
};
|
|
28871
28905
|
for (let i = 0; i < blocks.length; i++) {
|
|
28872
28906
|
const block = blocks[i];
|
|
28873
|
-
const md2 =
|
|
28907
|
+
const md2 = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28874
28908
|
if (!md2) continue;
|
|
28875
28909
|
if (block.type === "heading") {
|
|
28876
28910
|
flushRun();
|
|
@@ -28986,7 +29020,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28986
29020
|
const block = st.blocks[blockIndex];
|
|
28987
29021
|
if (!block) return void 0;
|
|
28988
29022
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
28989
|
-
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]);
|
|
28990
29024
|
if (!para2) return void 0;
|
|
28991
29025
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
28992
29026
|
}
|
|
@@ -29011,7 +29045,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29011
29045
|
if (block.text && block.text.includes("\n")) {
|
|
29012
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)" };
|
|
29013
29047
|
}
|
|
29014
|
-
if (!_optionalChain([st, 'access',
|
|
29048
|
+
if (!_optionalChain([st, 'access', _486 => _486.paraMap, 'access', _487 => _487.get, 'call', _488 => _488(blockIndex), 'optionalAccess', _489 => _489.para])) {
|
|
29015
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)" };
|
|
29016
29050
|
}
|
|
29017
29051
|
return { capability: "text" };
|
|
@@ -29077,7 +29111,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29077
29111
|
continue;
|
|
29078
29112
|
}
|
|
29079
29113
|
if (block.type === "table" && block.table) {
|
|
29080
|
-
if (!_optionalChain([edit, 'access',
|
|
29114
|
+
if (!_optionalChain([edit, 'access', _490 => _490.cells, 'optionalAccess', _491 => _491.length])) {
|
|
29081
29115
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
29082
29116
|
continue;
|
|
29083
29117
|
}
|
|
@@ -29097,7 +29131,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29097
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) });
|
|
29098
29132
|
continue;
|
|
29099
29133
|
}
|
|
29100
|
-
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]]);
|
|
29101
29135
|
if (!irCell) {
|
|
29102
29136
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
29103
29137
|
continue;
|
|
@@ -29153,7 +29187,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29153
29187
|
}
|
|
29154
29188
|
if (replacements.size === 0) {
|
|
29155
29189
|
let changes2;
|
|
29156
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29190
|
+
if (_optionalChain([options, 'optionalAccess', _496 => _496.verify]) !== false) {
|
|
29157
29191
|
const units = splitMarkdownUnits(st.markdown);
|
|
29158
29192
|
changes2 = diffUnitLists(units, units);
|
|
29159
29193
|
}
|
|
@@ -29174,7 +29208,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29174
29208
|
}
|
|
29175
29209
|
this.state = newState;
|
|
29176
29210
|
let changes;
|
|
29177
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29211
|
+
if (_optionalChain([options, 'optionalAccess', _497 => _497.verify]) !== false) {
|
|
29178
29212
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
29179
29213
|
}
|
|
29180
29214
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -29194,7 +29228,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29194
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)");
|
|
29195
29229
|
}
|
|
29196
29230
|
const mapping = st.paraMap.get(blockIndex);
|
|
29197
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
29231
|
+
if (!_optionalChain([mapping, 'optionalAccess', _498 => _498.para])) {
|
|
29198
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)");
|
|
29199
29233
|
}
|
|
29200
29234
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -29214,14 +29248,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29214
29248
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
29215
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");
|
|
29216
29250
|
}
|
|
29217
|
-
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]));
|
|
29218
29252
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
29219
29253
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
29220
29254
|
return 1;
|
|
29221
29255
|
}
|
|
29222
29256
|
}, _class8);
|
|
29223
29257
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
29224
|
-
const irCell = _optionalChain([table2, 'access',
|
|
29258
|
+
const irCell = _optionalChain([table2, 'access', _502 => _502.cells, 'access', _503 => _503[r], 'optionalAccess', _504 => _504[c]]);
|
|
29225
29259
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
29226
29260
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
29227
29261
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -29305,11 +29339,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
29305
29339
|
breaks: false
|
|
29306
29340
|
});
|
|
29307
29341
|
function renderHtml(markdown, options) {
|
|
29308
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29309
|
-
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]), () => ( "")));
|
|
29310
29344
|
const body = md.render(markdown);
|
|
29311
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
29312
|
-
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]) ? `
|
|
29313
29347
|
.watermark {
|
|
29314
29348
|
position: fixed;
|
|
29315
29349
|
top: 50%; left: 50%;
|
|
@@ -29340,13 +29374,13 @@ async function htmlToPdf(html, options) {
|
|
|
29340
29374
|
try {
|
|
29341
29375
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29342
29376
|
} catch (e32) {
|
|
29343
|
-
throw new (0,
|
|
29377
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
29344
29378
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29345
29379
|
);
|
|
29346
29380
|
}
|
|
29347
29381
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29348
29382
|
if (!executablePath) {
|
|
29349
|
-
throw new (0,
|
|
29383
|
+
throw new (0, _chunkKKZATKQWcjs.KordocError)(
|
|
29350
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."
|
|
29351
29385
|
);
|
|
29352
29386
|
}
|
|
@@ -29358,10 +29392,10 @@ async function htmlToPdf(html, options) {
|
|
|
29358
29392
|
try {
|
|
29359
29393
|
const page = await browser.newPage();
|
|
29360
29394
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
29361
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
29395
|
+
const margin = _optionalChain([options, 'optionalAccess', _509 => _509.margin]);
|
|
29362
29396
|
const pdf = await page.pdf({
|
|
29363
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29364
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
29397
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _510 => _510.pageSize]), () => ( "A4")),
|
|
29398
|
+
landscape: _optionalChain([options, 'optionalAccess', _511 => _511.orientation]) === "landscape",
|
|
29365
29399
|
printBackground: true,
|
|
29366
29400
|
margin: margin ? {
|
|
29367
29401
|
top: toCss(margin.top),
|
|
@@ -29369,9 +29403,9 @@ async function htmlToPdf(html, options) {
|
|
|
29369
29403
|
bottom: toCss(margin.bottom),
|
|
29370
29404
|
left: toCss(margin.left)
|
|
29371
29405
|
} : void 0,
|
|
29372
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
29373
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29374
|
-
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>'))
|
|
29375
29409
|
});
|
|
29376
29410
|
return Buffer.from(pdf);
|
|
29377
29411
|
} finally {
|
|
@@ -29405,7 +29439,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29405
29439
|
return htmlToPdf(html, options);
|
|
29406
29440
|
}
|
|
29407
29441
|
async function blocksToPdf(blocks, options) {
|
|
29408
|
-
const markdown =
|
|
29442
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29409
29443
|
return markdownToPdf(markdown, options);
|
|
29410
29444
|
}
|
|
29411
29445
|
|
|
@@ -29584,7 +29618,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
29584
29618
|
}
|
|
29585
29619
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
29586
29620
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
29587
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
29621
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _516 => _516.getAttribute, 'call', _517 => _517("vertRelTo")]), () => ( "PARA"));
|
|
29588
29622
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
29589
29623
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
29590
29624
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -29645,7 +29679,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29645
29679
|
if (ln(p) !== "p") continue;
|
|
29646
29680
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
29647
29681
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
29648
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29682
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _518 => _518.spaceBefore]), () => ( 0)));
|
|
29649
29683
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
29650
29684
|
if (!res) {
|
|
29651
29685
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -29658,7 +29692,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29658
29692
|
}
|
|
29659
29693
|
if (Number.isFinite(bottom)) {
|
|
29660
29694
|
cursorV = bottom;
|
|
29661
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29695
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _519 => _519.spaceAfter]), () => ( 0));
|
|
29662
29696
|
}
|
|
29663
29697
|
}
|
|
29664
29698
|
continue;
|
|
@@ -29768,7 +29802,7 @@ function buildPara(p) {
|
|
|
29768
29802
|
el: ch,
|
|
29769
29803
|
tag: cn,
|
|
29770
29804
|
index: chars.length,
|
|
29771
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
29805
|
+
inline: _optionalChain([pos, 'optionalAccess', _520 => _520.getAttribute, 'call', _521 => _521("treatAsChar")]) === "1",
|
|
29772
29806
|
width: w,
|
|
29773
29807
|
height: h
|
|
29774
29808
|
});
|
|
@@ -30020,15 +30054,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30020
30054
|
const sx = ow > 0 ? w / ow : 1;
|
|
30021
30055
|
const sy = oh > 0 ? h / oh : 1;
|
|
30022
30056
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
30023
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
30024
|
-
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";
|
|
30025
30059
|
const hasStroke = lstyle !== "NONE";
|
|
30026
30060
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
30027
30061
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
30028
30062
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
30029
30063
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
30030
30064
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
30031
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
30065
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _526 => _526.getAttribute, 'call', _527 => _527("faceColor")]);
|
|
30032
30066
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
30033
30067
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
30034
30068
|
if (o.tag === "rect") {
|
|
@@ -30055,14 +30089,14 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30055
30089
|
}
|
|
30056
30090
|
function cellContentExtent(cell2, memo) {
|
|
30057
30091
|
if (!cell2.sub) return 0;
|
|
30058
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30092
|
+
const hit = _optionalChain([memo, 'optionalAccess', _528 => _528.cell, 'access', _529 => _529.get, 'call', _530 => _530(cell2.el)]);
|
|
30059
30093
|
if (hit !== void 0) return hit;
|
|
30060
30094
|
let ext = 0;
|
|
30061
30095
|
for (const p of elements2(cell2.sub)) {
|
|
30062
30096
|
if (ln2(p) !== "p") continue;
|
|
30063
30097
|
const m = buildPara(p);
|
|
30064
30098
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
30065
|
-
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));
|
|
30066
30100
|
for (const o of m.objs) {
|
|
30067
30101
|
if (o.inline) {
|
|
30068
30102
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
@@ -30070,14 +30104,14 @@ function cellContentExtent(cell2, memo) {
|
|
|
30070
30104
|
continue;
|
|
30071
30105
|
}
|
|
30072
30106
|
const pos = findChildByLocalName(o.el, "pos");
|
|
30073
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30107
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _534 => _534.getAttribute, 'call', _535 => _535("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
30074
30108
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
30075
30109
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
30076
30110
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
30077
30111
|
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
30078
30112
|
}
|
|
30079
30113
|
}
|
|
30080
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30114
|
+
_optionalChain([memo, 'optionalAccess', _536 => _536.cell, 'access', _537 => _537.set, 'call', _538 => _538(cell2.el, ext)]);
|
|
30081
30115
|
return ext;
|
|
30082
30116
|
}
|
|
30083
30117
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
@@ -30119,7 +30153,7 @@ function collectCells(tbl2) {
|
|
|
30119
30153
|
return cells;
|
|
30120
30154
|
}
|
|
30121
30155
|
function measureTableHeight(tbl2, memo) {
|
|
30122
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30156
|
+
const hit = _optionalChain([memo, 'optionalAccess', _539 => _539.table, 'access', _540 => _540.get, 'call', _541 => _541(tbl2)]);
|
|
30123
30157
|
if (hit !== void 0) return hit;
|
|
30124
30158
|
const cells = collectCells(tbl2);
|
|
30125
30159
|
if (cells.length === 0 || cells.length > 4096) return 0;
|
|
@@ -30130,7 +30164,7 @@ function measureTableHeight(tbl2, memo) {
|
|
|
30130
30164
|
);
|
|
30131
30165
|
let sum = 0;
|
|
30132
30166
|
for (const h of rowH) sum += h;
|
|
30133
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30167
|
+
_optionalChain([memo, 'optionalAccess', _542 => _542.table, 'access', _543 => _543.set, 'call', _544 => _544(tbl2, sum)]);
|
|
30134
30168
|
return sum;
|
|
30135
30169
|
}
|
|
30136
30170
|
function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
@@ -30161,7 +30195,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
30161
30195
|
}));
|
|
30162
30196
|
for (const g of geom) {
|
|
30163
30197
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
30164
|
-
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)}"/>`);
|
|
30165
30199
|
}
|
|
30166
30200
|
for (const g of geom) {
|
|
30167
30201
|
const { c } = g;
|
|
@@ -30199,7 +30233,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
30199
30233
|
const sz = findChildByLocalName(pic, "sz");
|
|
30200
30234
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
30201
30235
|
const img = findFirst(pic, "img");
|
|
30202
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
30236
|
+
const ref = _optionalChain([img, 'optionalAccess', _546 => _546.getAttribute, 'call', _547 => _547("binaryItemIDRef")]);
|
|
30203
30237
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
30204
30238
|
if (!loaded) {
|
|
30205
30239
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -30239,7 +30273,7 @@ function readSectionGeom(root) {
|
|
|
30239
30273
|
const pagePr = findFirst(root, "pagePr");
|
|
30240
30274
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
30241
30275
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
30242
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
30276
|
+
if (_optionalChain([pagePr, 'optionalAccess', _548 => _548.getAttribute, 'call', _549 => _549("landscape")]) === "NARROWLY" && PW < PH) {
|
|
30243
30277
|
const t = PW;
|
|
30244
30278
|
PW = PH;
|
|
30245
30279
|
PH = t;
|
|
@@ -30297,17 +30331,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30297
30331
|
return { pages: ctx.pages, pageH };
|
|
30298
30332
|
}
|
|
30299
30333
|
async function renderHwpxToSvg(input, options) {
|
|
30300
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30334
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _550 => _550.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30301
30335
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30302
|
-
|
|
30336
|
+
_chunkKKZATKQWcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30303
30337
|
let zip;
|
|
30304
30338
|
try {
|
|
30305
30339
|
zip = await _jszip2.default.loadAsync(input);
|
|
30306
30340
|
} catch (e33) {
|
|
30307
|
-
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");
|
|
30308
30342
|
}
|
|
30309
30343
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30310
|
-
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");
|
|
30311
30345
|
const warnings = [];
|
|
30312
30346
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30313
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() };
|
|
@@ -30315,7 +30349,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30315
30349
|
const secXmls = [];
|
|
30316
30350
|
for (const f of secFiles) {
|
|
30317
30351
|
const xml = await f.async("string");
|
|
30318
|
-
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");
|
|
30319
30353
|
secXmls.push(xml);
|
|
30320
30354
|
}
|
|
30321
30355
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30339,7 +30373,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30339
30373
|
let href = binmap.get(ref);
|
|
30340
30374
|
if (!href) {
|
|
30341
30375
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
30342
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
30376
|
+
href = _optionalChain([cand, 'optionalAccess', _551 => _551.name]);
|
|
30343
30377
|
}
|
|
30344
30378
|
if (!href) continue;
|
|
30345
30379
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -30360,7 +30394,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30360
30394
|
styles,
|
|
30361
30395
|
images,
|
|
30362
30396
|
defs: [],
|
|
30363
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30397
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _552 => _552.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
30364
30398
|
warnings,
|
|
30365
30399
|
warned: /* @__PURE__ */ new Set(),
|
|
30366
30400
|
stats: { texts: 0, images: 0, tables: 0 },
|
|
@@ -30371,7 +30405,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30371
30405
|
for (let si = 0; si < secXmls.length; si++) {
|
|
30372
30406
|
const secXml = secXmls[si];
|
|
30373
30407
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
30374
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
30408
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _553 => _553.reflow])) {
|
|
30375
30409
|
noCacheSkipped = true;
|
|
30376
30410
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
30377
30411
|
continue;
|
|
@@ -30383,14 +30417,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30383
30417
|
continue;
|
|
30384
30418
|
}
|
|
30385
30419
|
const geom = readSectionGeom(root);
|
|
30386
|
-
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")));
|
|
30387
30421
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
30388
30422
|
}
|
|
30389
30423
|
if (rendered.length === 0) {
|
|
30390
30424
|
if (noCacheSkipped) {
|
|
30391
|
-
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)");
|
|
30392
30426
|
}
|
|
30393
|
-
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");
|
|
30394
30428
|
}
|
|
30395
30429
|
const GAP = 2400;
|
|
30396
30430
|
const clipDefs = [];
|
|
@@ -30422,17 +30456,17 @@ ${groups.join("\n")}
|
|
|
30422
30456
|
// src/index.ts
|
|
30423
30457
|
async function parse(input, options) {
|
|
30424
30458
|
let buffer;
|
|
30425
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
30459
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _556 => _556.filePath]) ? { ...options, filePath: input } : options;
|
|
30426
30460
|
if (typeof input === "string") {
|
|
30427
30461
|
try {
|
|
30428
30462
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30429
|
-
buffer =
|
|
30463
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, buf);
|
|
30430
30464
|
} catch (err) {
|
|
30431
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}`;
|
|
30432
30466
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30433
30467
|
}
|
|
30434
30468
|
} else if (Buffer.isBuffer(input)) {
|
|
30435
|
-
buffer =
|
|
30469
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, input);
|
|
30436
30470
|
} else {
|
|
30437
30471
|
buffer = input;
|
|
30438
30472
|
}
|
|
@@ -30466,18 +30500,18 @@ async function parse(input, options) {
|
|
|
30466
30500
|
}
|
|
30467
30501
|
async function parseImage(buffer, options) {
|
|
30468
30502
|
try {
|
|
30469
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
30503
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-3AFBDDJI.cjs")));
|
|
30470
30504
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30471
30505
|
return {
|
|
30472
30506
|
success: true,
|
|
30473
30507
|
fileType: "image",
|
|
30474
|
-
markdown:
|
|
30508
|
+
markdown: _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30475
30509
|
blocks,
|
|
30476
30510
|
warnings: warnings.length ? warnings : void 0,
|
|
30477
30511
|
pageCount: 1
|
|
30478
30512
|
};
|
|
30479
30513
|
} catch (err) {
|
|
30480
|
-
return { success: false, fileType: "image", error:
|
|
30514
|
+
return { success: false, fileType: "image", error: _chunkKKZATKQWcjs.sanitizeError.call(void 0, err), code: _chunkKKZATKQWcjs.classifyError.call(void 0, err) };
|
|
30481
30515
|
}
|
|
30482
30516
|
}
|
|
30483
30517
|
async function parseHwp3(buffer, options) {
|
|
@@ -30485,21 +30519,21 @@ async function parseHwp3(buffer, options) {
|
|
|
30485
30519
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30486
30520
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30487
30521
|
} catch (err) {
|
|
30488
|
-
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) };
|
|
30489
30523
|
}
|
|
30490
30524
|
}
|
|
30491
30525
|
async function parseHwpx(buffer, options) {
|
|
30492
30526
|
try {
|
|
30493
30527
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30494
|
-
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 };
|
|
30495
30529
|
} catch (err) {
|
|
30496
|
-
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) };
|
|
30497
30531
|
}
|
|
30498
30532
|
}
|
|
30499
30533
|
async function parseHwp(buffer, options) {
|
|
30500
30534
|
try {
|
|
30501
30535
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
30502
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
30536
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _558 => _558.filePath])) {
|
|
30503
30537
|
try {
|
|
30504
30538
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
30505
30539
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -30516,15 +30550,15 @@ async function parseHwp(buffer, options) {
|
|
|
30516
30550
|
} catch (e34) {
|
|
30517
30551
|
}
|
|
30518
30552
|
}
|
|
30519
|
-
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 };
|
|
30520
30554
|
} catch (err) {
|
|
30521
|
-
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) };
|
|
30522
30556
|
}
|
|
30523
30557
|
}
|
|
30524
30558
|
async function parsePdf(buffer, options) {
|
|
30525
30559
|
let parsePdfDocument;
|
|
30526
30560
|
try {
|
|
30527
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30561
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-MRM6WICO.cjs")));
|
|
30528
30562
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30529
30563
|
} catch (e35) {
|
|
30530
30564
|
return {
|
|
@@ -30539,7 +30573,7 @@ async function parsePdf(buffer, options) {
|
|
|
30539
30573
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30540
30574
|
} catch (err) {
|
|
30541
30575
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30542
|
-
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 };
|
|
30543
30577
|
}
|
|
30544
30578
|
}
|
|
30545
30579
|
async function parseXlsx(buffer, options) {
|
|
@@ -30547,7 +30581,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30547
30581
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30548
30582
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30549
30583
|
} catch (err) {
|
|
30550
|
-
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) };
|
|
30551
30585
|
}
|
|
30552
30586
|
}
|
|
30553
30587
|
async function parseXls(buffer, options) {
|
|
@@ -30555,15 +30589,15 @@ async function parseXls(buffer, options) {
|
|
|
30555
30589
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30556
30590
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30557
30591
|
} catch (err) {
|
|
30558
|
-
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) };
|
|
30559
30593
|
}
|
|
30560
30594
|
}
|
|
30561
30595
|
async function parseDocx(buffer, options) {
|
|
30562
30596
|
try {
|
|
30563
30597
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30564
|
-
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 };
|
|
30565
30599
|
} catch (err) {
|
|
30566
|
-
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) };
|
|
30567
30601
|
}
|
|
30568
30602
|
}
|
|
30569
30603
|
async function parseHwpml(buffer, options) {
|
|
@@ -30571,16 +30605,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30571
30605
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30572
30606
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30573
30607
|
} catch (err) {
|
|
30574
|
-
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) };
|
|
30575
30609
|
}
|
|
30576
30610
|
}
|
|
30577
30611
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30578
30612
|
let buffer;
|
|
30579
30613
|
if (typeof input === "string") {
|
|
30580
30614
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30581
|
-
buffer =
|
|
30615
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, buf);
|
|
30582
30616
|
} else if (Buffer.isBuffer(input)) {
|
|
30583
|
-
buffer =
|
|
30617
|
+
buffer = _chunkKKZATKQWcjs.toArrayBuffer.call(void 0, input);
|
|
30584
30618
|
} else {
|
|
30585
30619
|
buffer = input;
|
|
30586
30620
|
}
|
|
@@ -30606,7 +30640,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30606
30640
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30607
30641
|
}
|
|
30608
30642
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30609
|
-
const markdown =
|
|
30643
|
+
const markdown = _chunkWMU2KJHFcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30610
30644
|
if (outputFormat === "hwpx") {
|
|
30611
30645
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30612
30646
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30680,5 +30714,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30680
30714
|
|
|
30681
30715
|
|
|
30682
30716
|
|
|
30683
|
-
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 =
|
|
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;
|
|
30684
30718
|
//# sourceMappingURL=index.cjs.map
|