kordoc 4.2.1 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -2
- package/dist/{-BSO3CDQQ.js → -GJYDKVQD.js} +9 -9
- package/dist/{chunk-LSXXGUWA.cjs → chunk-5AXGFJQO.cjs} +8 -6
- package/dist/chunk-5AXGFJQO.cjs.map +1 -0
- package/dist/{chunk-R22KDUKW.cjs → chunk-AA6UPPZF.cjs} +9 -9
- package/dist/{chunk-R22KDUKW.cjs.map → chunk-AA6UPPZF.cjs.map} +1 -1
- package/dist/{chunk-WJSGYVFD.js → chunk-CGFWS3BQ.js} +3 -3
- package/dist/{chunk-RBUBZ2TA.cjs → chunk-CWP56BRC.cjs} +3 -3
- package/dist/chunk-CWP56BRC.cjs.map +1 -0
- package/dist/{chunk-QSB2RTX5.js → chunk-DE6FORIP.js} +6 -4
- package/dist/chunk-DE6FORIP.js.map +1 -0
- package/dist/{chunk-F5ECB53I.js → chunk-ELRVXOMP.js} +2 -2
- package/dist/{chunk-35U3MVA2.cjs → chunk-FF5QNEKZ.cjs} +3 -3
- package/dist/{chunk-35U3MVA2.cjs.map → chunk-FF5QNEKZ.cjs.map} +1 -1
- package/dist/{chunk-54WVWWT4.js → chunk-GJO3ORFW.js} +1 -1
- package/dist/chunk-GJO3ORFW.js.map +1 -0
- package/dist/{chunk-7IMNZ2BL.js → chunk-K5LGSH5T.js} +6 -4
- package/dist/chunk-K5LGSH5T.js.map +1 -0
- package/dist/{chunk-BKBYTPSL.js → chunk-LMNSIPWZ.js} +2 -2
- package/dist/{chunk-EZHWPKCH.js → chunk-LPWP4FWU.js} +2 -2
- package/dist/{chunk-QOC7S5VE.js → chunk-NIPPOAT6.js} +2 -2
- package/dist/{chunk-KRAYUNFM.js → chunk-NOMNOG74.js} +2 -2
- package/dist/{chunk-HTCKGSSW.js → chunk-QNVZAKUQ.js} +3 -3
- package/dist/chunk-QNVZAKUQ.js.map +1 -0
- package/dist/{chunk-Z6LPEWIX.js → chunk-RAS3HM4X.js} +3 -3
- package/dist/chunk-RAS3HM4X.js.map +1 -0
- package/dist/{chunk-L5JWKIOT.js → chunk-U6XYOV32.js} +3 -3
- package/dist/{chunk-PLTG6ZRF.js → chunk-WTJIRGPN.js} +3 -3
- package/dist/{chunk-WWYAYZ5U.js → chunk-WX75LYAS.js} +128 -35
- package/dist/chunk-WX75LYAS.js.map +1 -0
- package/dist/{chunk-BHILWIE6.js → chunk-X634MXVJ.js} +3 -3
- package/dist/chunk-X634MXVJ.js.map +1 -0
- package/dist/chunks-JOGD2KUK.js +10 -0
- package/dist/cli.js +18 -18
- package/dist/{image-ocr-SLUEM3FA.js → image-ocr-O3YQ3KEN.js} +5 -5
- package/dist/{image-ocr-DALT7PFQ.js → image-ocr-PLTV4NOK.js} +4 -4
- package/dist/{image-ocr-N5Z32R4U.cjs → image-ocr-TCJLNMTG.cjs} +9 -9
- package/dist/{image-ocr-N5Z32R4U.cjs.map → image-ocr-TCJLNMTG.cjs.map} +1 -1
- package/dist/index.cjs +545 -452
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +124 -31
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +15 -15
- package/dist/{parser-F5KY3YSD.js → parser-UX5T6KTZ.js} +6 -6
- package/dist/{parser-R4CXIXRN.cjs → parser-VQIJPCI5.cjs} +24 -24
- package/dist/{parser-R4CXIXRN.cjs.map → parser-VQIJPCI5.cjs.map} +1 -1
- package/dist/{parser-33TK5SMH.js → parser-Y2X4JMAK.js} +5 -5
- package/dist/{pdf-ocr-BXQZKU3N.js → pdf-ocr-DOPZP6QS.js} +5 -5
- package/dist/pdf-ocr-I3Y6YF5K.js +12 -0
- package/dist/pdf-ocr-XMDJ2IF5.cjs +13 -0
- package/dist/{pdf-ocr-WGWZDHMV.cjs.map → pdf-ocr-XMDJ2IF5.cjs.map} +1 -1
- package/dist/{profile-io-CBYHKLFU.js → profile-io-EGVJAZDG.js} +3 -3
- package/dist/{rasterize-AWMM2CSW.js → rasterize-TH26U5E2.js} +2 -2
- package/dist/render-C4R3OJ45.js +10 -0
- package/dist/seal-JF2J4S52.js +10 -0
- package/dist/{setup-Q2PRE7UA.js → setup-GUQT5ELJ.js} +23 -3
- package/dist/setup-GUQT5ELJ.js.map +1 -0
- package/dist/{watch-HKXCISVO.js → watch-4SP7V6SV.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/setup-Q2PRE7UA.js.map +0 -1
- /package/dist/{-BSO3CDQQ.js.map → -GJYDKVQD.js.map} +0 -0
- /package/dist/{chunk-WJSGYVFD.js.map → chunk-CGFWS3BQ.js.map} +0 -0
- /package/dist/{chunk-F5ECB53I.js.map → chunk-ELRVXOMP.js.map} +0 -0
- /package/dist/{chunk-BKBYTPSL.js.map → chunk-LMNSIPWZ.js.map} +0 -0
- /package/dist/{chunk-EZHWPKCH.js.map → chunk-LPWP4FWU.js.map} +0 -0
- /package/dist/{chunk-QOC7S5VE.js.map → chunk-NIPPOAT6.js.map} +0 -0
- /package/dist/{chunk-KRAYUNFM.js.map → chunk-NOMNOG74.js.map} +0 -0
- /package/dist/{chunk-L5JWKIOT.js.map → chunk-U6XYOV32.js.map} +0 -0
- /package/dist/{chunk-PLTG6ZRF.js.map → chunk-WTJIRGPN.js.map} +0 -0
- /package/dist/{chunks-LRFS5NJE.js.map → chunks-JOGD2KUK.js.map} +0 -0
- /package/dist/{image-ocr-SLUEM3FA.js.map → image-ocr-O3YQ3KEN.js.map} +0 -0
- /package/dist/{image-ocr-DALT7PFQ.js.map → image-ocr-PLTV4NOK.js.map} +0 -0
- /package/dist/{parser-F5KY3YSD.js.map → parser-UX5T6KTZ.js.map} +0 -0
- /package/dist/{parser-33TK5SMH.js.map → parser-Y2X4JMAK.js.map} +0 -0
- /package/dist/{pdf-ocr-34F5AQKK.js.map → pdf-ocr-DOPZP6QS.js.map} +0 -0
- /package/dist/{pdf-ocr-BXQZKU3N.js.map → pdf-ocr-I3Y6YF5K.js.map} +0 -0
- /package/dist/{profile-io-CBYHKLFU.js.map → profile-io-EGVJAZDG.js.map} +0 -0
- /package/dist/{rasterize-AWMM2CSW.js.map → rasterize-TH26U5E2.js.map} +0 -0
- /package/dist/{render-Y3IE2FIK.js.map → render-C4R3OJ45.js.map} +0 -0
- /package/dist/{seal-7RXFCRMT.js.map → seal-JF2J4S52.js.map} +0 -0
- /package/dist/{watch-HKXCISVO.js.map → watch-4SP7V6SV.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk5AXGFJQOcjs = require('./chunk-5AXGFJQO.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 _chunkCWP56BRCcjs = require('./chunk-CWP56BRC.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 _chunkCWP56BRCcjs.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, _chunkCWP56BRCcjs.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, _chunkCWP56BRCcjs.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(_chunkCWP56BRCcjs.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 >= _chunkCWP56BRCcjs.HEADING_RATIO_H1) level = 1;
|
|
700
|
+
else if (ratio >= _chunkCWP56BRCcjs.HEADING_RATIO_H2) level = 2;
|
|
701
|
+
else if (ratio >= _chunkCWP56BRCcjs.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, _chunkCWP56BRCcjs.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, _chunkCWP56BRCcjs.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, _chunkCWP56BRCcjs.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, _chunkCWP56BRCcjs.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 = _chunk5AXGFJQOcjs.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 = _chunk5AXGFJQOcjs.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(_chunkCWP56BRCcjs.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,12 +2103,12 @@ 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, _chunk5AXGFJQOcjs.MAX_COLS);
|
|
2107
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunk5AXGFJQOcjs.MAX_ROWS);
|
|
2084
2108
|
}
|
|
2085
2109
|
break;
|
|
2086
2110
|
case "p": {
|
|
2087
|
-
const { text: rawText, href, footnote, style } = extractParagraphInfo(el, ctx.styleMap, ctx);
|
|
2111
|
+
const { text: rawText, href, footnote, style, segments } = extractParagraphInfo(el, ctx.styleMap, ctx);
|
|
2088
2112
|
let text = rawText;
|
|
2089
2113
|
let headingLevel;
|
|
2090
2114
|
const ph = resolveParaHeading(el, ctx);
|
|
@@ -2092,14 +2116,41 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2092
2116
|
if (_optionalChain([ph, 'optionalAccess', _34 => _34.prefix])) text = ph.prefix + " " + text;
|
|
2093
2117
|
headingLevel = _optionalChain([ph, 'optionalAccess', _35 => _35.headingLevel]);
|
|
2094
2118
|
}
|
|
2119
|
+
if (segments) {
|
|
2120
|
+
const cell2 = _nullishCoalesce(_optionalChain([tableCtx, 'optionalAccess', _36 => _36.cell]), () => ( null));
|
|
2121
|
+
if (text && cell2) cell2.text += (cell2.text ? "\n" : "") + (footnote ? `${text} (\uC8FC: ${footnote})` : text);
|
|
2122
|
+
const segs = [...segments];
|
|
2123
|
+
if (_optionalChain([ph, 'optionalAccess', _37 => _37.prefix])) {
|
|
2124
|
+
const fi = segs.findIndex((s) => s);
|
|
2125
|
+
if (fi >= 0) segs[fi] = ph.prefix + " " + segs[fi];
|
|
2126
|
+
}
|
|
2127
|
+
let segIdx = 0;
|
|
2128
|
+
let first = true;
|
|
2129
|
+
const flush = () => {
|
|
2130
|
+
const s = segs[segIdx++];
|
|
2131
|
+
if (!s) return;
|
|
2132
|
+
const block = { type: "paragraph", text: s, pageNumber: ctx.sectionNum };
|
|
2133
|
+
if (first && !cell2) {
|
|
2134
|
+
first = false;
|
|
2135
|
+
if (style) block.style = style;
|
|
2136
|
+
if (href) block.href = href;
|
|
2137
|
+
if (footnote) block.footnoteText = footnote;
|
|
2138
|
+
}
|
|
2139
|
+
if (cell2) (cell2.blocks ??= []).push(block);
|
|
2140
|
+
else blocks.push(block);
|
|
2141
|
+
};
|
|
2142
|
+
tableCtx = walkParagraphChildren(el, blocks, tableCtx, tableStack, ctx, depth + 1, flush);
|
|
2143
|
+
while (segIdx < segs.length) flush();
|
|
2144
|
+
break;
|
|
2145
|
+
}
|
|
2095
2146
|
if (text) {
|
|
2096
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2147
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _38 => _38.cell])) {
|
|
2097
2148
|
const cell2 = tableCtx.cell;
|
|
2098
2149
|
if (footnote) text += ` (\uC8FC: ${footnote})`;
|
|
2099
2150
|
cell2.text += (cell2.text ? "\n" : "") + text;
|
|
2100
2151
|
const cellBlock = { type: "paragraph", text, pageNumber: ctx.sectionNum };
|
|
2101
2152
|
const cellSpanMode = spanModeOf(ctx.shared.kordocLayout);
|
|
2102
|
-
if (cellSpanMode && !_optionalChain([ph, 'optionalAccess',
|
|
2153
|
+
if (cellSpanMode && !_optionalChain([ph, 'optionalAccess', _39 => _39.prefix])) {
|
|
2103
2154
|
const spans = extractRunSpans(el, ctx, cellSpanMode, cellSpanMode !== "kordoc");
|
|
2104
2155
|
if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
|
|
2105
2156
|
cellBlock.spans = spans;
|
|
@@ -2118,7 +2169,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2118
2169
|
if (style) block.style = style;
|
|
2119
2170
|
if (href) block.href = href;
|
|
2120
2171
|
if (footnote) block.footnoteText = footnote;
|
|
2121
|
-
const ind = _optionalChain([ctx, 'access',
|
|
2172
|
+
const ind = _optionalChain([ctx, 'access', _40 => _40.styleMap, 'optionalAccess', _41 => _41.paraIndents, 'access', _42 => _42.get, 'call', _43 => _43(_nullishCoalesce(el.getAttribute("paraPrIDRef"), () => ( "")))]);
|
|
2122
2173
|
if (ind) {
|
|
2123
2174
|
const eff = ind.left + Math.max(0, ind.intent);
|
|
2124
2175
|
if (eff > 0) block.indent = eff;
|
|
@@ -2129,7 +2180,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2129
2180
|
}
|
|
2130
2181
|
const spanMode = spanModeOf(ctx.shared.kordocLayout);
|
|
2131
2182
|
if (!headingLevel && spanMode) {
|
|
2132
|
-
if (!_optionalChain([ph, 'optionalAccess',
|
|
2183
|
+
if (!_optionalChain([ph, 'optionalAccess', _44 => _44.prefix])) {
|
|
2133
2184
|
const spans = extractRunSpans(el, ctx, spanMode, spanMode === "gongmun");
|
|
2134
2185
|
if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
|
|
2135
2186
|
block.spans = spans;
|
|
@@ -2149,7 +2200,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2149
2200
|
case "pic":
|
|
2150
2201
|
case "shape":
|
|
2151
2202
|
case "drawingObject": {
|
|
2152
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2203
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _45 => _45.cell])) {
|
|
2153
2204
|
const sink = [];
|
|
2154
2205
|
handleShape(el, sink, ctx);
|
|
2155
2206
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -2254,7 +2305,7 @@ function hasPageAutoNum(el, depth = 0) {
|
|
|
2254
2305
|
const ch = children[i];
|
|
2255
2306
|
if (ch.nodeType !== 1) continue;
|
|
2256
2307
|
const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
|
|
2257
|
-
if (tag === "autoNum" && _optionalChain([ch, 'access',
|
|
2308
|
+
if (tag === "autoNum" && _optionalChain([ch, 'access', _46 => _46.getAttribute, 'optionalCall', _47 => _47("numType")]) === "PAGE") return true;
|
|
2258
2309
|
if (hasPageAutoNum(ch, depth + 1)) return true;
|
|
2259
2310
|
}
|
|
2260
2311
|
return false;
|
|
@@ -2291,7 +2342,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2291
2342
|
const sink = [];
|
|
2292
2343
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2293
2344
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2294
|
-
let flat =
|
|
2345
|
+
let flat = _chunk5AXGFJQOcjs.convertTableToText.call(void 0, st.rows);
|
|
2295
2346
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2296
2347
|
return flat;
|
|
2297
2348
|
}
|
|
@@ -2310,7 +2361,7 @@ function findTopLevelTbls(el, out, depth = 0) {
|
|
|
2310
2361
|
findTopLevelTbls(ch, out, depth + 1);
|
|
2311
2362
|
}
|
|
2312
2363
|
}
|
|
2313
|
-
function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
2364
|
+
function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0, onTbl) {
|
|
2314
2365
|
if (depth > MAX_XML_DEPTH) return tableCtx;
|
|
2315
2366
|
const children = node.childNodes;
|
|
2316
2367
|
if (!children) return tableCtx;
|
|
@@ -2324,6 +2375,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2324
2375
|
const tag = el.tagName || el.localName || "";
|
|
2325
2376
|
const localTag = tag.replace(/^[^:]+:/, "");
|
|
2326
2377
|
if (localTag === "tbl") {
|
|
2378
|
+
if (onTbl && isInlineTbl(el)) onTbl();
|
|
2327
2379
|
if (!tableCtx) {
|
|
2328
2380
|
const chan = kordocTableChannel(el, ctx);
|
|
2329
2381
|
if (chan) {
|
|
@@ -2340,12 +2392,12 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2340
2392
|
} else if (localTag === "caption" && !inShape) {
|
|
2341
2393
|
const capText = collectSubListText(el, ctx);
|
|
2342
2394
|
if (capText) {
|
|
2343
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2395
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _48 => _48.cell])) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: capText, pageNumber: ctx.sectionNum }]);
|
|
2344
2396
|
else if (tableCtx) tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + capText;
|
|
2345
2397
|
else blocks.push({ type: "paragraph", text: capText, pageNumber: ctx.sectionNum });
|
|
2346
2398
|
}
|
|
2347
2399
|
} else if (localTag === "pic" || localTag === "shape" || localTag === "drawingObject") {
|
|
2348
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2400
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _49 => _49.cell])) {
|
|
2349
2401
|
const sink = [];
|
|
2350
2402
|
handleShape(el, sink, ctx);
|
|
2351
2403
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -2353,7 +2405,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2353
2405
|
handleShape(el, blocks, ctx);
|
|
2354
2406
|
}
|
|
2355
2407
|
} else if (localTag === "drawText") {
|
|
2356
|
-
if (_optionalChain([tableCtx, 'optionalAccess',
|
|
2408
|
+
if (_optionalChain([tableCtx, 'optionalAccess', _50 => _50.cell])) {
|
|
2357
2409
|
const sink = [];
|
|
2358
2410
|
extractDrawTextBlocks(el, sink, ctx);
|
|
2359
2411
|
mergeBlocksIntoCell(tableCtx.cell, sink);
|
|
@@ -2370,6 +2422,9 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2370
2422
|
walkChildren(node, depth);
|
|
2371
2423
|
return tableCtx;
|
|
2372
2424
|
}
|
|
2425
|
+
function isInlineTbl(tbl2) {
|
|
2426
|
+
return _optionalChain([findChildByLocalName, 'call', _51 => _51(tbl2, "pos"), 'optionalAccess', _52 => _52.getAttribute, 'call', _53 => _53("treatAsChar")]) === "1";
|
|
2427
|
+
}
|
|
2373
2428
|
function findDescendant(node, targetTag, depth = 0) {
|
|
2374
2429
|
if (depth > 5) return null;
|
|
2375
2430
|
const children = node.childNodes;
|
|
@@ -2399,7 +2454,7 @@ function extractDrawTextBlocks(drawTextNode, blocks, ctx) {
|
|
|
2399
2454
|
let text = info.text.trim();
|
|
2400
2455
|
const ph = resolveParaHeading(child, ctx);
|
|
2401
2456
|
if (text) {
|
|
2402
|
-
if (_optionalChain([ph, 'optionalAccess',
|
|
2457
|
+
if (_optionalChain([ph, 'optionalAccess', _54 => _54.prefix])) text = ph.prefix + " " + text;
|
|
2403
2458
|
const block = { type: "paragraph", text, style: _nullishCoalesce(info.style, () => ( void 0)), pageNumber: ctx.sectionNum };
|
|
2404
2459
|
if (info.href) block.href = info.href;
|
|
2405
2460
|
if (info.footnote) block.footnoteText = info.footnote;
|
|
@@ -2424,13 +2479,13 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2424
2479
|
let url = (ch.textContent || "").trim();
|
|
2425
2480
|
if (!url) continue;
|
|
2426
2481
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2427
|
-
const safe =
|
|
2482
|
+
const safe = _chunkCWP56BRCcjs.sanitizeHref.call(void 0, url);
|
|
2428
2483
|
if (safe) return safe;
|
|
2429
2484
|
}
|
|
2430
2485
|
return void 0;
|
|
2431
2486
|
}
|
|
2432
2487
|
function isInDeletedRange(ctx) {
|
|
2433
|
-
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess',
|
|
2488
|
+
return (_nullishCoalesce(_optionalChain([ctx, 'optionalAccess', _55 => _55.shared, 'access', _56 => _56.track, 'access', _57 => _57.deleteDepth]), () => ( 0))) > 0;
|
|
2434
2489
|
}
|
|
2435
2490
|
function extractParagraphInfo(para2, styleMap, ctx) {
|
|
2436
2491
|
let text = "";
|
|
@@ -2451,7 +2506,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2451
2506
|
};
|
|
2452
2507
|
const onFieldEnd = () => {
|
|
2453
2508
|
const open = openFields.pop();
|
|
2454
|
-
if (_optionalChain([open, 'optionalAccess',
|
|
2509
|
+
if (_optionalChain([open, 'optionalAccess', _58 => _58.rangeIdx]) !== void 0) linkRanges[open.rangeIdx].end = text.length;
|
|
2455
2510
|
};
|
|
2456
2511
|
const handleCtrl = (ctrlEl) => {
|
|
2457
2512
|
const kids2 = ctrlEl.childNodes;
|
|
@@ -2502,7 +2557,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2502
2557
|
// 삽입분은 최종본에 포함
|
|
2503
2558
|
// 숨은 설명 — 본문 혼입 차단
|
|
2504
2559
|
case "hiddenComment": {
|
|
2505
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
2560
|
+
if (_optionalChain([ctx, 'optionalAccess', _59 => _59.warnings]) && extractTextFromNode(k)) {
|
|
2506
2561
|
ctx.warnings.push({ page: ctx.sectionNum, message: "\uC228\uC740 \uC124\uBA85 \uD14D\uC2A4\uD2B8 \uC81C\uC678: hiddenComment", code: "HIDDEN_TEXT_FILTERED" });
|
|
2507
2562
|
}
|
|
2508
2563
|
break;
|
|
@@ -2522,7 +2577,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2522
2577
|
break;
|
|
2523
2578
|
// 미지원 요소 — 텍스트를 가졌으면 무음 손실 대신 경고
|
|
2524
2579
|
default: {
|
|
2525
|
-
if (_optionalChain([ctx, 'optionalAccess',
|
|
2580
|
+
if (_optionalChain([ctx, 'optionalAccess', _60 => _60.warnings]) && extractTextFromNode(k)) {
|
|
2526
2581
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uBBF8\uC9C0\uC6D0 \uC81C\uC5B4 \uC694\uC18C\uC758 \uD14D\uC2A4\uD2B8 \uC190\uC2E4: ${ktag}`, code: "UNSUPPORTED_ELEMENT" });
|
|
2527
2582
|
}
|
|
2528
2583
|
}
|
|
@@ -2540,10 +2595,10 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2540
2595
|
if (isInDeletedRange(ctx)) {
|
|
2541
2596
|
if (t && ctx && !ctx.shared.track.warned) {
|
|
2542
2597
|
ctx.shared.track.warned = true;
|
|
2543
|
-
_optionalChain([ctx, 'access',
|
|
2598
|
+
_optionalChain([ctx, 'access', _61 => _61.warnings, 'optionalAccess', _62 => _62.push, 'call', _63 => _63({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" })]);
|
|
2544
2599
|
}
|
|
2545
2600
|
} else {
|
|
2546
|
-
text += t;
|
|
2601
|
+
text += t.replace(/\x1E/g, "");
|
|
2547
2602
|
}
|
|
2548
2603
|
continue;
|
|
2549
2604
|
}
|
|
@@ -2574,14 +2629,17 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2574
2629
|
case "hwSpace":
|
|
2575
2630
|
text += " ";
|
|
2576
2631
|
break;
|
|
2632
|
+
// 테이블 자체는 walkSection에서 처리 — 글자취급(inline) 표만 경계 마커를 남겨
|
|
2633
|
+
// 표 앞뒤 텍스트를 문서 순서대로 분할 방출할 수 있게 한다 (#49/#50).
|
|
2634
|
+
// float·페이지 앵커 표는 텍스트 흐름 불참(reflow 모델 정합) — 종전대로 텍스트 뒤 방출
|
|
2577
2635
|
case "tbl":
|
|
2636
|
+
if (isInlineTbl(child)) text += "";
|
|
2578
2637
|
break;
|
|
2579
|
-
// 테이블은 walkSection에서 처리
|
|
2580
2638
|
// 하이퍼링크
|
|
2581
2639
|
case "hyperlink": {
|
|
2582
2640
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2583
2641
|
if (url) {
|
|
2584
|
-
const safe =
|
|
2642
|
+
const safe = _chunkCWP56BRCcjs.sanitizeHref.call(void 0, url);
|
|
2585
2643
|
if (safe) href = safe;
|
|
2586
2644
|
}
|
|
2587
2645
|
walk(child, depth + 1);
|
|
@@ -2671,7 +2729,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2671
2729
|
for (const r of closed) {
|
|
2672
2730
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
2673
2731
|
const anchor = text.slice(r.start, r.end);
|
|
2674
|
-
if (!anchor.trim() || /[\n\x1F\[\]]/.test(anchor)) continue;
|
|
2732
|
+
if (!anchor.trim() || /[\n\x1F\x1E\[\]]/.test(anchor)) continue;
|
|
2675
2733
|
text = text.slice(0, r.start) + `[${anchor}](${r.url})` + text.slice(r.end);
|
|
2676
2734
|
applied.push([r.start, r.end]);
|
|
2677
2735
|
}
|
|
@@ -2679,10 +2737,18 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2679
2737
|
}
|
|
2680
2738
|
const leaderIdx = text.indexOf("");
|
|
2681
2739
|
if (leaderIdx >= 0) text = text.substring(0, leaderIdx);
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2740
|
+
const cleanParaText = (raw) => {
|
|
2741
|
+
let t = raw.replace(/[ \t]+/g, " ").trim();
|
|
2742
|
+
if (/^그림입니다\.?\s*원본\s*그림의\s*(이름|크기)/.test(t)) t = "";
|
|
2743
|
+
t = t.replace(/그림입니다\.?\s*원본\s*그림의\s*(이름|크기)[^\n]*(\n[^\n]*원본\s*그림의\s*(이름|크기)[^\n]*)*/g, "").trim();
|
|
2744
|
+
return t.replace(/^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|선|직선|곡선|화살표|오각형|육각형|팔각형|별|십자|구름|마름모|도넛|평행사변형|사다리꼴|개체|그리기\s?개체|묶음\s?개체|글상자|표|그림|OLE\s?개체)\s?입니다\.?$/gm, "").trim();
|
|
2745
|
+
};
|
|
2746
|
+
let segments;
|
|
2747
|
+
if (text.includes("")) {
|
|
2748
|
+
segments = text.split("").map(cleanParaText);
|
|
2749
|
+
text = text.replace(/\x1E/g, "");
|
|
2750
|
+
}
|
|
2751
|
+
const cleanText = cleanParaText(text);
|
|
2686
2752
|
let style;
|
|
2687
2753
|
if (styleMap && charPrId) {
|
|
2688
2754
|
const charProp = styleMap.charProperties.get(charPrId);
|
|
@@ -2695,7 +2761,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2695
2761
|
if (!style.fontSize && !style.bold && !style.italic) style = void 0;
|
|
2696
2762
|
}
|
|
2697
2763
|
}
|
|
2698
|
-
return { text: cleanText, href, footnote, style };
|
|
2764
|
+
return { text: cleanText, href, footnote, style, segments };
|
|
2699
2765
|
}
|
|
2700
2766
|
var KORDOC_CHAR_CODE = "4";
|
|
2701
2767
|
var KORDOC_PARA_QUOTE = "6";
|
|
@@ -2720,13 +2786,13 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2720
2786
|
if (tag !== "run" && tag !== "r") return null;
|
|
2721
2787
|
let text = "";
|
|
2722
2788
|
const rkids = child.childNodes;
|
|
2723
|
-
for (let j = 0; j < (_nullishCoalesce(_optionalChain([rkids, 'optionalAccess',
|
|
2789
|
+
for (let j = 0; j < (_nullishCoalesce(_optionalChain([rkids, 'optionalAccess', _64 => _64.length]), () => ( 0))); j++) {
|
|
2724
2790
|
const rc = rkids[j];
|
|
2725
2791
|
if (rc.nodeType !== 1) continue;
|
|
2726
2792
|
const rtag = (rc.tagName || rc.localName || "").replace(/^[^:]+:/, "");
|
|
2727
2793
|
if (rtag === "t") {
|
|
2728
2794
|
const tkids = rc.childNodes;
|
|
2729
|
-
for (let k = 0; k < (_nullishCoalesce(_optionalChain([tkids, 'optionalAccess',
|
|
2795
|
+
for (let k = 0; k < (_nullishCoalesce(_optionalChain([tkids, 'optionalAccess', _65 => _65.length]), () => ( 0))); k++) {
|
|
2730
2796
|
const tk = tkids[k];
|
|
2731
2797
|
if (tk.nodeType === 3) text += tk.textContent || "";
|
|
2732
2798
|
else if (tk.nodeType === 1) return null;
|
|
@@ -2744,23 +2810,24 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2744
2810
|
const span = { text };
|
|
2745
2811
|
if (mode !== "foreign" && prId === KORDOC_CHAR_CODE) span.code = true;
|
|
2746
2812
|
else {
|
|
2747
|
-
if (_optionalChain([cp, 'optionalAccess',
|
|
2748
|
-
if (_optionalChain([cp, 'optionalAccess',
|
|
2813
|
+
if (_optionalChain([cp, 'optionalAccess', _66 => _66.bold])) span.bold = true;
|
|
2814
|
+
if (_optionalChain([cp, 'optionalAccess', _67 => _67.italic])) span.italic = true;
|
|
2815
|
+
if (_optionalChain([cp, 'optionalAccess', _68 => _68.strike])) span.strike = true;
|
|
2749
2816
|
}
|
|
2750
|
-
if (span.bold || span.italic || span.code) styled = true;
|
|
2817
|
+
if (span.bold || span.italic || span.strike || span.code) styled = true;
|
|
2751
2818
|
spans.push(span);
|
|
2752
2819
|
}
|
|
2753
2820
|
if (!styled || spans.length === 0) return null;
|
|
2754
2821
|
const merged = [];
|
|
2755
2822
|
for (const s of spans) {
|
|
2756
2823
|
const last = merged[merged.length - 1];
|
|
2757
|
-
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.code === !!s.code) {
|
|
2824
|
+
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.strike === !!s.strike && !!last.code === !!s.code) {
|
|
2758
2825
|
last.text += s.text;
|
|
2759
2826
|
} else {
|
|
2760
2827
|
merged.push(s);
|
|
2761
2828
|
}
|
|
2762
2829
|
}
|
|
2763
|
-
if (requireMixed && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2830
|
+
if (requireMixed && !merged.some((s) => s.strike) && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2764
2831
|
return merged;
|
|
2765
2832
|
}
|
|
2766
2833
|
function gongmunDepthFromIndent(para2, left, ctx) {
|
|
@@ -2768,12 +2835,12 @@ function gongmunDepthFromIndent(para2, left, ctx) {
|
|
|
2768
2835
|
if (!styleMap) return null;
|
|
2769
2836
|
let unit = 0;
|
|
2770
2837
|
const kids2 = para2.childNodes;
|
|
2771
|
-
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess',
|
|
2838
|
+
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids2, 'optionalAccess', _69 => _69.length]), () => ( 0))); i++) {
|
|
2772
2839
|
const child = kids2[i];
|
|
2773
2840
|
if (child.nodeType !== 1) continue;
|
|
2774
2841
|
const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
|
|
2775
2842
|
if (tag !== "run" && tag !== "r") continue;
|
|
2776
|
-
const size = _optionalChain([styleMap, 'access',
|
|
2843
|
+
const size = _optionalChain([styleMap, 'access', _70 => _70.charProperties, 'access', _71 => _71.get, 'call', _72 => _72(_nullishCoalesce(child.getAttribute("charPrIDRef"), () => ( ""))), 'optionalAccess', _73 => _73.fontSize]);
|
|
2777
2844
|
if (size) unit = size * 100;
|
|
2778
2845
|
break;
|
|
2779
2846
|
}
|
|
@@ -2846,7 +2913,7 @@ function decompressStream(data) {
|
|
|
2846
2913
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2847
2914
|
}
|
|
2848
2915
|
function parseFileHeader(data) {
|
|
2849
|
-
if (data.length < 40) throw new (0,
|
|
2916
|
+
if (data.length < 40) throw new (0, _chunkCWP56BRCcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2850
2917
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2851
2918
|
return {
|
|
2852
2919
|
signature: sig,
|
|
@@ -2979,7 +3046,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
2979
3046
|
const resolveAt = (byteOffset, extended) => {
|
|
2980
3047
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2981
3048
|
const idx = extended ? state.ctrlIdx : -1;
|
|
2982
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
3049
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _74 => _74(idx, ctrlId)]);
|
|
2983
3050
|
if (replacement) result += replacement;
|
|
2984
3051
|
if (extended) state.ctrlIdx++;
|
|
2985
3052
|
};
|
|
@@ -3181,7 +3248,7 @@ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
|
|
|
3181
3248
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
3182
3249
|
if (fileIndex) {
|
|
3183
3250
|
for (const entry of fileIndex) {
|
|
3184
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3251
|
+
if (!_optionalChain([entry, 'optionalAccess', _75 => _75.name]) || !entry.content) continue;
|
|
3185
3252
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
3186
3253
|
if (!match) continue;
|
|
3187
3254
|
const idx = parseInt(match[1], 16);
|
|
@@ -3257,7 +3324,7 @@ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
|
|
|
3257
3324
|
} else if (block.type === "table" && block.table) {
|
|
3258
3325
|
for (const row of block.table.cells) {
|
|
3259
3326
|
for (const cell2 of row) {
|
|
3260
|
-
if (_optionalChain([cell2, 'access',
|
|
3327
|
+
if (_optionalChain([cell2, 'access', _76 => _76.blocks, 'optionalAccess', _77 => _77.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
|
|
3261
3328
|
}
|
|
3262
3329
|
}
|
|
3263
3330
|
}
|
|
@@ -3295,13 +3362,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3295
3362
|
}
|
|
3296
3363
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3297
3364
|
for (const path of allCandidates) {
|
|
3298
|
-
if (
|
|
3365
|
+
if (_chunkCWP56BRCcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3299
3366
|
const file = zip.file(path);
|
|
3300
3367
|
if (!file) continue;
|
|
3301
3368
|
try {
|
|
3302
3369
|
const data = await file.async("uint8array");
|
|
3303
3370
|
decompressed.total += data.length;
|
|
3304
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3371
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3305
3372
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3306
3373
|
const mimeType = imageExtToMime(ext);
|
|
3307
3374
|
imageIndex++;
|
|
@@ -3311,10 +3378,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3311
3378
|
usedPaths.add(path);
|
|
3312
3379
|
break;
|
|
3313
3380
|
} catch (err) {
|
|
3314
|
-
if (err instanceof
|
|
3381
|
+
if (err instanceof _chunkCWP56BRCcjs.KordocError) throw err;
|
|
3315
3382
|
}
|
|
3316
3383
|
}
|
|
3317
|
-
if (!img) _optionalChain([warnings, 'optionalAccess',
|
|
3384
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _78 => _78.push, 'call', _79 => _79({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
3318
3385
|
resolved.set(ref, img);
|
|
3319
3386
|
}
|
|
3320
3387
|
if (!img) {
|
|
@@ -3331,11 +3398,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3331
3398
|
if (sweepUnreferenced) {
|
|
3332
3399
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3333
3400
|
for (const file of binEntries) {
|
|
3334
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3401
|
+
if (file.dir || usedPaths.has(file.name) || _chunkCWP56BRCcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3335
3402
|
try {
|
|
3336
3403
|
const data = await file.async("uint8array");
|
|
3337
3404
|
decompressed.total += data.length;
|
|
3338
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3405
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3339
3406
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3340
3407
|
let mimeType = imageExtToMime(ext);
|
|
3341
3408
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3349,8 +3416,8 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3349
3416
|
images.push(img);
|
|
3350
3417
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3351
3418
|
} catch (err) {
|
|
3352
|
-
if (err instanceof
|
|
3353
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
3419
|
+
if (err instanceof _chunkCWP56BRCcjs.KordocError) throw err;
|
|
3420
|
+
_optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3354
3421
|
}
|
|
3355
3422
|
}
|
|
3356
3423
|
}
|
|
@@ -3400,7 +3467,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3400
3467
|
}
|
|
3401
3468
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3402
3469
|
const name = new TextDecoder().decode(nameBytes);
|
|
3403
|
-
if (
|
|
3470
|
+
if (_chunkCWP56BRCcjs.isPathTraversal.call(void 0, name)) {
|
|
3404
3471
|
pos = fileStart + compSize;
|
|
3405
3472
|
continue;
|
|
3406
3473
|
}
|
|
@@ -3418,16 +3485,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3418
3485
|
continue;
|
|
3419
3486
|
}
|
|
3420
3487
|
totalDecompressed += content.length * 2;
|
|
3421
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3488
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3422
3489
|
sectionNum++;
|
|
3423
3490
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3424
3491
|
} catch (e16) {
|
|
3425
3492
|
continue;
|
|
3426
3493
|
}
|
|
3427
3494
|
}
|
|
3428
|
-
if (blocks.length === 0) throw new (0,
|
|
3495
|
+
if (blocks.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3429
3496
|
applyPageText(blocks, shared);
|
|
3430
|
-
const markdown =
|
|
3497
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3431
3498
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3432
3499
|
}
|
|
3433
3500
|
async function readKordocLayout(zip) {
|
|
@@ -3436,7 +3503,7 @@ async function readKordocLayout(zip) {
|
|
|
3436
3503
|
try {
|
|
3437
3504
|
const xml = await file.async("text");
|
|
3438
3505
|
if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
|
|
3439
|
-
return _nullishCoalesce(_optionalChain([xml, 'access',
|
|
3506
|
+
return _nullishCoalesce(_optionalChain([xml, 'access', _82 => _82.match, 'call', _83 => _83(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _84 => _84[1]]), () => ( null));
|
|
3440
3507
|
} catch (e17) {
|
|
3441
3508
|
return null;
|
|
3442
3509
|
}
|
|
@@ -3452,18 +3519,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3452
3519
|
if (paths.length > 0) return paths;
|
|
3453
3520
|
}
|
|
3454
3521
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3455
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3522
|
+
return sectionFiles.map((f) => f.name).sort(_chunkCWP56BRCcjs.compareSectionPaths);
|
|
3456
3523
|
}
|
|
3457
3524
|
function parseSectionPathsFromManifest(xml) {
|
|
3458
3525
|
const parser = createXmlParser();
|
|
3459
|
-
const doc = parser.parseFromString(
|
|
3526
|
+
const doc = parser.parseFromString(_chunkCWP56BRCcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3460
3527
|
const items = doc.getElementsByTagName("opf:item");
|
|
3461
3528
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3462
3529
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3463
3530
|
for (let i = 0; i < items.length; i++) {
|
|
3464
3531
|
const item = items[i];
|
|
3465
3532
|
const id = item.getAttribute("id") || "";
|
|
3466
|
-
const href =
|
|
3533
|
+
const href = _chunkCWP56BRCcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3467
3534
|
if (id && href) idToHref.set(id, href);
|
|
3468
3535
|
}
|
|
3469
3536
|
if (spine.length > 0) {
|
|
@@ -3474,7 +3541,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3474
3541
|
}
|
|
3475
3542
|
if (ordered.length > 0) return ordered;
|
|
3476
3543
|
}
|
|
3477
|
-
return Array.from(idToHref.values()).sort(
|
|
3544
|
+
return Array.from(idToHref.values()).sort(_chunkCWP56BRCcjs.compareSectionPaths);
|
|
3478
3545
|
}
|
|
3479
3546
|
|
|
3480
3547
|
// src/hwpx/metadata.ts
|
|
@@ -3487,7 +3554,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3487
3554
|
const xml = await file.async("text");
|
|
3488
3555
|
if (decompressed) {
|
|
3489
3556
|
decompressed.total += xml.length * 2;
|
|
3490
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3557
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3491
3558
|
}
|
|
3492
3559
|
parseDublinCoreMetadata(xml, metadata);
|
|
3493
3560
|
if (metadata.title || metadata.author) return;
|
|
@@ -3497,13 +3564,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3497
3564
|
}
|
|
3498
3565
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3499
3566
|
const parser = createXmlParser();
|
|
3500
|
-
const doc = parser.parseFromString(
|
|
3567
|
+
const doc = parser.parseFromString(_chunkCWP56BRCcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3501
3568
|
if (!doc.documentElement) return;
|
|
3502
3569
|
const getText = (tagNames) => {
|
|
3503
3570
|
for (const tag of tagNames) {
|
|
3504
3571
|
const els = doc.getElementsByTagName(tag);
|
|
3505
3572
|
if (els.length > 0) {
|
|
3506
|
-
const text = _optionalChain([els, 'access',
|
|
3573
|
+
const text = _optionalChain([els, 'access', _85 => _85[0], 'access', _86 => _86.textContent, 'optionalAccess', _87 => _87.trim, 'call', _88 => _88()]);
|
|
3507
3574
|
if (text) return text;
|
|
3508
3575
|
}
|
|
3509
3576
|
}
|
|
@@ -3522,7 +3589,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3522
3589
|
|
|
3523
3590
|
// src/hwpx/parser.ts
|
|
3524
3591
|
async function parseHwpxDocument(buffer, options) {
|
|
3525
|
-
|
|
3592
|
+
_chunkCWP56BRCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3526
3593
|
let zip;
|
|
3527
3594
|
try {
|
|
3528
3595
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3531,19 +3598,19 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3531
3598
|
}
|
|
3532
3599
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3533
3600
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3534
|
-
throw new (0,
|
|
3601
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3535
3602
|
}
|
|
3536
3603
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3537
3604
|
if (manifestFile) {
|
|
3538
3605
|
const manifestXml = await manifestFile.async("text");
|
|
3539
3606
|
if (isEncryptedHwpx(manifestXml)) {
|
|
3540
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
3607
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _89 => _89.filePath])) {
|
|
3541
3608
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3542
3609
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3543
3610
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3544
3611
|
}
|
|
3545
3612
|
}
|
|
3546
|
-
throw new (0,
|
|
3613
|
+
throw new (0, _chunkCWP56BRCcjs.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
3614
|
}
|
|
3548
3615
|
}
|
|
3549
3616
|
const decompressed = { total: 0 };
|
|
@@ -3552,14 +3619,14 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3552
3619
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3553
3620
|
const warnings = [];
|
|
3554
3621
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3555
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3622
|
+
if (sectionPaths.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3556
3623
|
metadata.pageCount = sectionPaths.length;
|
|
3557
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3624
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _90 => _90.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3558
3625
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3559
3626
|
const blocks = [];
|
|
3560
3627
|
const shared = createSectionShared();
|
|
3561
3628
|
shared.kordocLayout = await readKordocLayout(zip);
|
|
3562
|
-
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
3629
|
+
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _91 => _91.keepTrailingEmptyCols]);
|
|
3563
3630
|
let parsedSections = 0;
|
|
3564
3631
|
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3565
3632
|
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
@@ -3571,7 +3638,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3571
3638
|
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new ZipBombError("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3572
3639
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3573
3640
|
parsedSections++;
|
|
3574
|
-
_optionalChain([options, 'optionalAccess',
|
|
3641
|
+
_optionalChain([options, 'optionalAccess', _92 => _92.onProgress, 'optionalCall', _93 => _93(parsedSections, totalTarget)]);
|
|
3575
3642
|
} catch (secErr) {
|
|
3576
3643
|
if (secErr instanceof ZipBombError) throw secErr;
|
|
3577
3644
|
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 +3648,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3581
3648
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3582
3649
|
detectHwpxHeadings(blocks, styleMap);
|
|
3583
3650
|
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 =
|
|
3651
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3585
3652
|
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
3653
|
}
|
|
3587
3654
|
|
|
@@ -4760,22 +4827,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4760
4827
|
lenientCfb = parseLenientCfb(buffer);
|
|
4761
4828
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4762
4829
|
} catch (e22) {
|
|
4763
|
-
throw new (0,
|
|
4830
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4764
4831
|
}
|
|
4765
4832
|
}
|
|
4766
4833
|
const findStream = (path) => {
|
|
4767
4834
|
if (cfb) {
|
|
4768
4835
|
const entry = CFB.find(cfb, path);
|
|
4769
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
4836
|
+
return _optionalChain([entry, 'optionalAccess', _94 => _94.content]) ? Buffer.from(entry.content) : null;
|
|
4770
4837
|
}
|
|
4771
4838
|
return lenientCfb.findStream(path);
|
|
4772
4839
|
};
|
|
4773
4840
|
const headerData = findStream("/FileHeader");
|
|
4774
|
-
if (!headerData) throw new (0,
|
|
4841
|
+
if (!headerData) throw new (0, _chunkCWP56BRCcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4775
4842
|
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,
|
|
4843
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkCWP56BRCcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4844
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4845
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkCWP56BRCcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4779
4846
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4780
4847
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4781
4848
|
const metadata = {
|
|
@@ -4784,13 +4851,13 @@ function parseHwp5Document(buffer, options) {
|
|
|
4784
4851
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4785
4852
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4786
4853
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4787
|
-
if (sections.length === 0) throw new (0,
|
|
4854
|
+
if (sections.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4788
4855
|
metadata.pageCount = sections.length;
|
|
4789
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4856
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _95 => _95.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4790
4857
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4791
4858
|
const bodyBlocks = [];
|
|
4792
4859
|
const doc = createHwp5DocState();
|
|
4793
|
-
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
4860
|
+
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _96 => _96.keepTrailingEmptyCols]);
|
|
4794
4861
|
let totalDecompressed = 0;
|
|
4795
4862
|
let parsedSections = 0;
|
|
4796
4863
|
for (let si = 0; si < sections.length; si++) {
|
|
@@ -4799,22 +4866,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4799
4866
|
const sectionData = sections[si];
|
|
4800
4867
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4801
4868
|
totalDecompressed += data.length;
|
|
4802
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4869
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4803
4870
|
const records = readRecords(data);
|
|
4804
4871
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4805
4872
|
bodyBlocks.push(...sectionBlocks);
|
|
4806
4873
|
parsedSections++;
|
|
4807
|
-
_optionalChain([options, 'optionalAccess',
|
|
4874
|
+
_optionalChain([options, 'optionalAccess', _97 => _97.onProgress, 'optionalCall', _98 => _98(parsedSections, totalTarget)]);
|
|
4808
4875
|
} catch (secErr) {
|
|
4809
|
-
if (secErr instanceof
|
|
4876
|
+
if (secErr instanceof _chunkCWP56BRCcjs.KordocError) throw secErr;
|
|
4810
4877
|
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
4878
|
}
|
|
4812
4879
|
}
|
|
4813
4880
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4814
4881
|
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 =
|
|
4882
|
+
let flatBlocks = _chunk5AXGFJQOcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4883
|
+
if (_optionalChain([options, 'optionalAccess', _99 => _99.dedupeRunningHeaders])) {
|
|
4884
|
+
const deduped = _chunk5AXGFJQOcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4818
4885
|
const removed = flatBlocks.length - deduped.length;
|
|
4819
4886
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4820
4887
|
flatBlocks = deduped;
|
|
@@ -4823,10 +4890,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4823
4890
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4824
4891
|
}
|
|
4825
4892
|
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',
|
|
4893
|
+
let markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4894
|
+
if (_optionalChain([options, 'optionalAccess', _100 => _100.inlineImages]) && images.length > 0) {
|
|
4828
4895
|
try {
|
|
4829
|
-
markdown =
|
|
4896
|
+
markdown = _chunk5AXGFJQOcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4830
4897
|
} catch (inlineErr) {
|
|
4831
4898
|
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
4899
|
}
|
|
@@ -4836,7 +4903,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4836
4903
|
function parseDocInfoStream(cfb, compressed) {
|
|
4837
4904
|
try {
|
|
4838
4905
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
4839
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4906
|
+
if (!_optionalChain([entry, 'optionalAccess', _101 => _101.content])) return null;
|
|
4840
4907
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
4841
4908
|
const records = readRecords(data);
|
|
4842
4909
|
return parseDocInfo(records);
|
|
@@ -4857,7 +4924,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4857
4924
|
let baseFontSize = 0;
|
|
4858
4925
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
4859
4926
|
for (const b of blocks) {
|
|
4860
|
-
if (_optionalChain([b, 'access',
|
|
4927
|
+
if (_optionalChain([b, 'access', _102 => _102.style, 'optionalAccess', _103 => _103.fontSize]) && b.text) {
|
|
4861
4928
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4862
4929
|
}
|
|
4863
4930
|
}
|
|
@@ -4873,7 +4940,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4873
4940
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4874
4941
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4875
4942
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4876
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4943
|
+
if (_optionalChain([cs, 'optionalAccess', _104 => _104.fontSize]) > 0) {
|
|
4877
4944
|
baseFontSize = cs.fontSize / 10;
|
|
4878
4945
|
break;
|
|
4879
4946
|
}
|
|
@@ -4888,11 +4955,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4888
4955
|
if (text.length === 0 || text.length > 200) continue;
|
|
4889
4956
|
if (/^\d+$/.test(text)) continue;
|
|
4890
4957
|
let level = 0;
|
|
4891
|
-
if (_optionalChain([block, 'access',
|
|
4958
|
+
if (_optionalChain([block, 'access', _105 => _105.style, 'optionalAccess', _106 => _106.fontSize]) && baseFontSize > 0) {
|
|
4892
4959
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4893
|
-
if (ratio >=
|
|
4894
|
-
else if (ratio >=
|
|
4895
|
-
else if (ratio >=
|
|
4960
|
+
if (ratio >= _chunkCWP56BRCcjs.HEADING_RATIO_H1) level = 1;
|
|
4961
|
+
else if (ratio >= _chunkCWP56BRCcjs.HEADING_RATIO_H2) level = 2;
|
|
4962
|
+
else if (ratio >= _chunkCWP56BRCcjs.HEADING_RATIO_H3) level = 3;
|
|
4896
4963
|
}
|
|
4897
4964
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4898
4965
|
if (level === 0) level = 2;
|
|
@@ -4908,7 +4975,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4908
4975
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4909
4976
|
try {
|
|
4910
4977
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4911
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4978
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _107 => _107.content])) return;
|
|
4912
4979
|
const data = Buffer.from(summaryEntry.content);
|
|
4913
4980
|
if (data.length < 48) return;
|
|
4914
4981
|
const numSets = data.readUInt32LE(24);
|
|
@@ -4941,7 +5008,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
4941
5008
|
const sections = [];
|
|
4942
5009
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4943
5010
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
4944
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
5011
|
+
if (!_optionalChain([entry, 'optionalAccess', _108 => _108.content])) break;
|
|
4945
5012
|
try {
|
|
4946
5013
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
4947
5014
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -4955,13 +5022,13 @@ function findSections(cfb) {
|
|
|
4955
5022
|
const sections = [];
|
|
4956
5023
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4957
5024
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
4958
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
5025
|
+
if (!_optionalChain([entry, 'optionalAccess', _109 => _109.content])) break;
|
|
4959
5026
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
4960
5027
|
}
|
|
4961
5028
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
4962
5029
|
for (const entry of cfb.FileIndex) {
|
|
4963
5030
|
if (sections.length >= MAX_SECTIONS) break;
|
|
4964
|
-
if (_optionalChain([entry, 'access',
|
|
5031
|
+
if (_optionalChain([entry, 'access', _110 => _110.name, 'optionalAccess', _111 => _111.startsWith, 'call', _112 => _112("Section")]) && entry.content) {
|
|
4965
5032
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
4966
5033
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
4967
5034
|
}
|
|
@@ -4977,7 +5044,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4977
5044
|
if (!raw) break;
|
|
4978
5045
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4979
5046
|
totalDecompressed += content.length;
|
|
4980
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5047
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4981
5048
|
sections.push({ idx: i, content });
|
|
4982
5049
|
}
|
|
4983
5050
|
if (sections.length === 0) {
|
|
@@ -4989,7 +5056,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4989
5056
|
if (raw) {
|
|
4990
5057
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4991
5058
|
totalDecompressed += content.length;
|
|
4992
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5059
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4993
5060
|
sections.push({ idx, content });
|
|
4994
5061
|
}
|
|
4995
5062
|
}
|
|
@@ -5006,7 +5073,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5006
5073
|
try {
|
|
5007
5074
|
const content = decryptViewText(raw, compressed);
|
|
5008
5075
|
totalDecompressed += content.length;
|
|
5009
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5076
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5010
5077
|
sections.push({ idx: i, content });
|
|
5011
5078
|
} catch (e27) {
|
|
5012
5079
|
break;
|
|
@@ -5107,9 +5174,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5107
5174
|
const applied = [];
|
|
5108
5175
|
for (const r of ranges) {
|
|
5109
5176
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5110
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
5177
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _113 => _113.href]) || r.end <= r.start) continue;
|
|
5111
5178
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5112
|
-
const href =
|
|
5179
|
+
const href = _chunkCWP56BRCcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5113
5180
|
if (!href) continue;
|
|
5114
5181
|
const anchor = text.slice(r.start, r.end);
|
|
5115
5182
|
if (!anchor.trim()) continue;
|
|
@@ -5127,7 +5194,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5127
5194
|
}
|
|
5128
5195
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
5129
5196
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
5130
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
5197
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _114 => _114.docInfo, 'optionalAccess', _115 => _115.numberings, 'access', _116 => _116[nid - 1]]) : void 0;
|
|
5131
5198
|
if (numbering) {
|
|
5132
5199
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
5133
5200
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -5137,7 +5204,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5137
5204
|
}
|
|
5138
5205
|
}
|
|
5139
5206
|
} else if (ps.headType === 3) {
|
|
5140
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
5207
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _117 => _117.docInfo, 'optionalAccess', _118 => _118.bullets, 'access', _119 => _119[ps.numberingId - 1]]) : void 0;
|
|
5141
5208
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
5142
5209
|
}
|
|
5143
5210
|
}
|
|
@@ -5152,7 +5219,10 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5152
5219
|
if (headingLevel > 0) block.level = headingLevel;
|
|
5153
5220
|
if (ctx.docInfo && charShapeIds.length > 0) {
|
|
5154
5221
|
const style = resolveCharStyle(charShapeIds, ctx.docInfo);
|
|
5155
|
-
if (style)
|
|
5222
|
+
if (style) {
|
|
5223
|
+
block.style = style;
|
|
5224
|
+
if (style.strike) block.text = headMarker ? `${headMarker} ~~${trimmed}~~` : `~~${trimmed}~~`;
|
|
5225
|
+
}
|
|
5156
5226
|
}
|
|
5157
5227
|
if (footnotes.length > 0) block.footnoteText = footnotes.join("; ");
|
|
5158
5228
|
blocks.push(block);
|
|
@@ -5342,8 +5412,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5342
5412
|
let tableIdx = -1;
|
|
5343
5413
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5344
5414
|
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),
|
|
5415
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunk5AXGFJQOcjs.MAX_ROWS);
|
|
5416
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunk5AXGFJQOcjs.MAX_COLS);
|
|
5347
5417
|
tableIdx = i2;
|
|
5348
5418
|
break;
|
|
5349
5419
|
}
|
|
@@ -5383,7 +5453,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5383
5453
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
5384
5454
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
5385
5455
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
5386
|
-
if (_optionalChain([c, 'access',
|
|
5456
|
+
if (_optionalChain([c, 'access', _120 => _120.blocks, 'optionalAccess', _121 => _121.length])) ir.blocks = c.blocks;
|
|
5387
5457
|
if (c.isHeader) ir.isHeader = true;
|
|
5388
5458
|
return ir;
|
|
5389
5459
|
}));
|
|
@@ -5392,7 +5462,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5392
5462
|
return table3;
|
|
5393
5463
|
}
|
|
5394
5464
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5395
|
-
const table2 =
|
|
5465
|
+
const table2 = _chunk5AXGFJQOcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5396
5466
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5397
5467
|
return table2.rows > 0 ? table2 : null;
|
|
5398
5468
|
}
|
|
@@ -5409,8 +5479,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5409
5479
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5410
5480
|
const cs = rec.data.readUInt16LE(12);
|
|
5411
5481
|
const rs = rec.data.readUInt16LE(14);
|
|
5412
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5413
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5482
|
+
if (cs > 0) colSpan = Math.min(cs, _chunk5AXGFJQOcjs.MAX_COLS);
|
|
5483
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunk5AXGFJQOcjs.MAX_ROWS);
|
|
5414
5484
|
}
|
|
5415
5485
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5416
5486
|
const parts = [];
|
|
@@ -5420,7 +5490,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5420
5490
|
parts.push(``);
|
|
5421
5491
|
hasStructure = true;
|
|
5422
5492
|
} else if (b.type === "table" && b.table) {
|
|
5423
|
-
const flat =
|
|
5493
|
+
const flat = _chunk5AXGFJQOcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5424
5494
|
if (flat) parts.push(flat);
|
|
5425
5495
|
hasStructure = true;
|
|
5426
5496
|
} else if (b.text) {
|
|
@@ -5517,8 +5587,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
5517
5587
|
if (data.length < 73) return null;
|
|
5518
5588
|
const binDataId = data.readUInt16LE(71);
|
|
5519
5589
|
if (binDataId === 0) return null;
|
|
5520
|
-
const item = _optionalChain([ctx, 'access',
|
|
5521
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
5590
|
+
const item = _optionalChain([ctx, 'access', _122 => _122.docInfo, 'optionalAccess', _123 => _123.binData, 'access', _124 => _124[binDataId - 1]]);
|
|
5591
|
+
if (_optionalChain([item, 'optionalAccess', _125 => _125.kind]) === "link") {
|
|
5522
5592
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
5523
5593
|
return null;
|
|
5524
5594
|
}
|
|
@@ -5543,7 +5613,13 @@ function resolveCharStyle(charShapeIds, docInfo) {
|
|
|
5543
5613
|
if (cs.fontSize > 0) style.fontSize = cs.fontSize / 10;
|
|
5544
5614
|
if (cs.attrFlags & 1) style.italic = true;
|
|
5545
5615
|
if (cs.attrFlags & 2) style.bold = true;
|
|
5546
|
-
|
|
5616
|
+
if (hasRealStrike(cs.attrFlags)) style.strike = true;
|
|
5617
|
+
return style.fontSize || style.bold || style.italic || style.strike ? style : void 0;
|
|
5618
|
+
}
|
|
5619
|
+
function hasRealStrike(attrFlags) {
|
|
5620
|
+
const strikeBits = attrFlags >> 18 & 7;
|
|
5621
|
+
const shapeId = attrFlags >> 26 & 15;
|
|
5622
|
+
return strikeBits !== 0 && shapeId <= 12;
|
|
5547
5623
|
}
|
|
5548
5624
|
|
|
5549
5625
|
// src/hwp3/parser.ts
|
|
@@ -17666,7 +17742,7 @@ function parseHwp3Document(buffer, _options) {
|
|
|
17666
17742
|
try {
|
|
17667
17743
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17668
17744
|
} catch (err) {
|
|
17669
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
17745
|
+
if (_optionalChain([err, 'optionalAccess', _126 => _126.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17670
17746
|
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
17747
|
}
|
|
17672
17748
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
@@ -17901,15 +17977,15 @@ function getElements(parent, tagName) {
|
|
|
17901
17977
|
const result = [];
|
|
17902
17978
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
17903
17979
|
if (result.length > 0) return result;
|
|
17904
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
17980
|
+
const nsNodes = _optionalChain([parent, 'access', _127 => _127.getElementsByTagNameNS, 'optionalCall', _128 => _128("*", tagName)]);
|
|
17905
17981
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
17906
17982
|
return result;
|
|
17907
17983
|
}
|
|
17908
17984
|
function getTextContent(el) {
|
|
17909
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
17985
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _129 => _129.textContent, 'optionalAccess', _130 => _130.trim, 'call', _131 => _131()]), () => ( ""));
|
|
17910
17986
|
}
|
|
17911
17987
|
function parseXml(text) {
|
|
17912
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17988
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkCWP56BRCcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17913
17989
|
}
|
|
17914
17990
|
function collectRichText(root) {
|
|
17915
17991
|
let out = "";
|
|
@@ -17918,7 +17994,7 @@ function collectRichText(root) {
|
|
|
17918
17994
|
for (let i = 0; i < children.length; i++) {
|
|
17919
17995
|
if (children[i].nodeType !== 1) continue;
|
|
17920
17996
|
const el = children[i];
|
|
17921
|
-
const local = el.localName || _optionalChain([el, 'access',
|
|
17997
|
+
const local = el.localName || _optionalChain([el, 'access', _132 => _132.tagName, 'optionalAccess', _133 => _133.replace, 'call', _134 => _134(/^[^:]+:/, "")]) || "";
|
|
17922
17998
|
if (local === "rPh") continue;
|
|
17923
17999
|
if (local === "t") out += _nullishCoalesce(el.textContent, () => ( ""));
|
|
17924
18000
|
else walk(el);
|
|
@@ -18137,14 +18213,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18137
18213
|
const merge = mergeMap.get(key);
|
|
18138
18214
|
row.push({
|
|
18139
18215
|
text,
|
|
18140
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18141
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18216
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _135 => _135.colSpan]), () => ( 1)),
|
|
18217
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _136 => _136.rowSpan]), () => ( 1))
|
|
18142
18218
|
});
|
|
18143
18219
|
}
|
|
18144
18220
|
cellRows.push(row);
|
|
18145
18221
|
}
|
|
18146
18222
|
if (cellRows.length > 0) {
|
|
18147
|
-
const table2 =
|
|
18223
|
+
const table2 = _chunk5AXGFJQOcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18148
18224
|
if (table2.rows > 0) {
|
|
18149
18225
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18150
18226
|
}
|
|
@@ -18152,12 +18228,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18152
18228
|
return blocks;
|
|
18153
18229
|
}
|
|
18154
18230
|
async function parseXlsxDocument(buffer, options) {
|
|
18155
|
-
|
|
18231
|
+
_chunkCWP56BRCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18156
18232
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18157
18233
|
const warnings = [];
|
|
18158
18234
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18159
18235
|
if (!workbookFile) {
|
|
18160
|
-
throw new (0,
|
|
18236
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18161
18237
|
}
|
|
18162
18238
|
let sharedStrings = [];
|
|
18163
18239
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18166,7 +18242,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18166
18242
|
}
|
|
18167
18243
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18168
18244
|
if (sheets.length === 0) {
|
|
18169
|
-
throw new (0,
|
|
18245
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18170
18246
|
}
|
|
18171
18247
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18172
18248
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18182,7 +18258,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18182
18258
|
relsMap = parseRels(await relsFile.async("text"));
|
|
18183
18259
|
}
|
|
18184
18260
|
let pageFilter = null;
|
|
18185
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18261
|
+
if (_optionalChain([options, 'optionalAccess', _137 => _137.pages])) {
|
|
18186
18262
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18187
18263
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18188
18264
|
}
|
|
@@ -18191,7 +18267,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18191
18267
|
for (let i = 0; i < processedSheets; i++) {
|
|
18192
18268
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18193
18269
|
const sheet = sheets[i];
|
|
18194
|
-
_optionalChain([options, 'optionalAccess',
|
|
18270
|
+
_optionalChain([options, 'optionalAccess', _138 => _138.onProgress, 'optionalCall', _139 => _139(i + 1, processedSheets)]);
|
|
18195
18271
|
let sheetPath = relsMap.get(sheet.rId);
|
|
18196
18272
|
if (sheetPath) {
|
|
18197
18273
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -18214,7 +18290,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18214
18290
|
try {
|
|
18215
18291
|
const sheetXml = await sheetFile.async("text");
|
|
18216
18292
|
const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
|
|
18217
|
-
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess',
|
|
18293
|
+
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess', _140 => _140.keepTrailingEmptyCols]));
|
|
18218
18294
|
blocks.push(...sheetBlocks);
|
|
18219
18295
|
} catch (err) {
|
|
18220
18296
|
warnings.push({
|
|
@@ -18246,7 +18322,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18246
18322
|
} catch (e29) {
|
|
18247
18323
|
}
|
|
18248
18324
|
}
|
|
18249
|
-
const markdown =
|
|
18325
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18250
18326
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18251
18327
|
}
|
|
18252
18328
|
|
|
@@ -18697,11 +18773,11 @@ function processGlobals(records) {
|
|
|
18697
18773
|
const xfFmtIds = [];
|
|
18698
18774
|
const firstBof = records[0];
|
|
18699
18775
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18700
|
-
throw new (0,
|
|
18776
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18701
18777
|
}
|
|
18702
18778
|
const bof = decodeBof(firstBof.data);
|
|
18703
18779
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18704
|
-
throw new (0,
|
|
18780
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18705
18781
|
}
|
|
18706
18782
|
let i = 1;
|
|
18707
18783
|
while (i < records.length) {
|
|
@@ -18829,14 +18905,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18829
18905
|
const merge = mergeMap.get(key);
|
|
18830
18906
|
row.push({
|
|
18831
18907
|
text: grid[r][c],
|
|
18832
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18833
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18908
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _141 => _141.colSpan]), () => ( 1)),
|
|
18909
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _142 => _142.rowSpan]), () => ( 1))
|
|
18834
18910
|
});
|
|
18835
18911
|
}
|
|
18836
18912
|
cellRows.push(row);
|
|
18837
18913
|
}
|
|
18838
18914
|
if (cellRows.length > 0) {
|
|
18839
|
-
const table2 =
|
|
18915
|
+
const table2 = _chunk5AXGFJQOcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18840
18916
|
if (table2.rows > 0) {
|
|
18841
18917
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18842
18918
|
}
|
|
@@ -18849,21 +18925,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18849
18925
|
try {
|
|
18850
18926
|
cfb = parseLenientCfb(buf);
|
|
18851
18927
|
} catch (e) {
|
|
18852
|
-
throw new (0,
|
|
18928
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
18853
18929
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18854
18930
|
);
|
|
18855
18931
|
}
|
|
18856
18932
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18857
18933
|
if (!wb) {
|
|
18858
|
-
throw new (0,
|
|
18934
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18859
18935
|
}
|
|
18860
18936
|
const records = readRecords2(wb);
|
|
18861
18937
|
if (records.length === 0) {
|
|
18862
|
-
throw new (0,
|
|
18938
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18863
18939
|
}
|
|
18864
18940
|
const firstBof = decodeBof(records[0].data);
|
|
18865
18941
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18866
|
-
throw new (0,
|
|
18942
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
18867
18943
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18868
18944
|
);
|
|
18869
18945
|
}
|
|
@@ -18892,7 +18968,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18892
18968
|
} : void 0;
|
|
18893
18969
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18894
18970
|
let pageFilter = null;
|
|
18895
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18971
|
+
if (_optionalChain([options, 'optionalAccess', _143 => _143.pages])) {
|
|
18896
18972
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18897
18973
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18898
18974
|
}
|
|
@@ -18901,7 +18977,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18901
18977
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18902
18978
|
const meta = globals.sheets[i];
|
|
18903
18979
|
if (meta.dt !== 0) continue;
|
|
18904
|
-
_optionalChain([options, 'optionalAccess',
|
|
18980
|
+
_optionalChain([options, 'optionalAccess', _144 => _144.onProgress, 'optionalCall', _145 => _145(i + 1, totalSheets)]);
|
|
18905
18981
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
18906
18982
|
if (bofIdx < 0) {
|
|
18907
18983
|
warnings.push({
|
|
@@ -18917,7 +18993,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18917
18993
|
}
|
|
18918
18994
|
try {
|
|
18919
18995
|
const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
|
|
18920
|
-
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess',
|
|
18996
|
+
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess', _146 => _146.keepTrailingEmptyCols]));
|
|
18921
18997
|
allBlocks.push(...blocks);
|
|
18922
18998
|
} catch (e) {
|
|
18923
18999
|
warnings.push({
|
|
@@ -18931,7 +19007,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18931
19007
|
pageCount: totalSheets
|
|
18932
19008
|
};
|
|
18933
19009
|
return {
|
|
18934
|
-
markdown:
|
|
19010
|
+
markdown: _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18935
19011
|
blocks: allBlocks,
|
|
18936
19012
|
metadata,
|
|
18937
19013
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18944,7 +19020,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18944
19020
|
|
|
18945
19021
|
// src/docx/equation.ts
|
|
18946
19022
|
function lname(el) {
|
|
18947
|
-
return el.localName || _optionalChain([el, 'access',
|
|
19023
|
+
return el.localName || _optionalChain([el, 'access', _147 => _147.tagName, 'optionalAccess', _148 => _148.replace, 'call', _149 => _149(/^[^:]+:/, "")]) || "";
|
|
18948
19024
|
}
|
|
18949
19025
|
function kids(parent, name) {
|
|
18950
19026
|
const out = [];
|
|
@@ -19333,7 +19409,7 @@ function isDisplayMath(el) {
|
|
|
19333
19409
|
// src/docx/parser.ts
|
|
19334
19410
|
var MAX_DECOMPRESS_SIZE5 = 100 * 1024 * 1024;
|
|
19335
19411
|
function matchesLocal(el, localName2) {
|
|
19336
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
19412
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _150 => _150.tagName, 'optionalAccess', _151 => _151.endsWith, 'call', _152 => _152(`:${localName2}`)]), () => ( false)));
|
|
19337
19413
|
}
|
|
19338
19414
|
function effectiveChildElements(parent) {
|
|
19339
19415
|
const result = [];
|
|
@@ -19368,7 +19444,7 @@ function findElements(parent, localName2) {
|
|
|
19368
19444
|
const child = children[i];
|
|
19369
19445
|
if (child.nodeType === 1) {
|
|
19370
19446
|
const el = child;
|
|
19371
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
19447
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _153 => _153.tagName, 'optionalAccess', _154 => _154.endsWith, 'call', _155 => _155(`:${localName2}`)])) {
|
|
19372
19448
|
result.push(el);
|
|
19373
19449
|
}
|
|
19374
19450
|
walk(el);
|
|
@@ -19387,7 +19463,7 @@ function getAttr(el, localName2) {
|
|
|
19387
19463
|
return null;
|
|
19388
19464
|
}
|
|
19389
19465
|
function parseXml2(text) {
|
|
19390
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19466
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkCWP56BRCcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19391
19467
|
}
|
|
19392
19468
|
function parseStyles(xml) {
|
|
19393
19469
|
const doc = parseXml2(xml);
|
|
@@ -19504,7 +19580,7 @@ function collectOmmlRoots(p) {
|
|
|
19504
19580
|
const child = children[i];
|
|
19505
19581
|
if (child.nodeType !== 1) continue;
|
|
19506
19582
|
const el = child;
|
|
19507
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
19583
|
+
const tag = el.localName || _optionalChain([el, 'access', _156 => _156.tagName, 'optionalAccess', _157 => _157.replace, 'call', _158 => _158(/^[^:]+:/, "")]) || "";
|
|
19508
19584
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
19509
19585
|
out.push(el);
|
|
19510
19586
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -19545,7 +19621,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19545
19621
|
function makeLink(text, rawHref) {
|
|
19546
19622
|
if (!text) return "";
|
|
19547
19623
|
if (!rawHref) return text;
|
|
19548
|
-
const href =
|
|
19624
|
+
const href = _chunkCWP56BRCcjs.sanitizeHref.call(void 0, rawHref);
|
|
19549
19625
|
return href ? `[${text}](${href})` : text;
|
|
19550
19626
|
}
|
|
19551
19627
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19647,7 +19723,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19647
19723
|
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19648
19724
|
if (!text) return null;
|
|
19649
19725
|
const style = styles.get(styleId);
|
|
19650
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
19726
|
+
if (_optionalChain([style, 'optionalAccess', _159 => _159.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
19651
19727
|
return {
|
|
19652
19728
|
type: "heading",
|
|
19653
19729
|
text,
|
|
@@ -19656,8 +19732,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19656
19732
|
}
|
|
19657
19733
|
if (numId && numId !== "0") {
|
|
19658
19734
|
const numDef = numbering.get(numId);
|
|
19659
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
19660
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
19735
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _160 => _160.get, 'call', _161 => _161(ilvl)]);
|
|
19736
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _162 => _162.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
19661
19737
|
return { type: "list", text, listType };
|
|
19662
19738
|
}
|
|
19663
19739
|
const block = { type: "paragraph", text };
|
|
@@ -19739,7 +19815,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19739
19815
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19740
19816
|
})
|
|
19741
19817
|
);
|
|
19742
|
-
const table2 =
|
|
19818
|
+
const table2 = _chunk5AXGFJQOcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19743
19819
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19744
19820
|
return { type: "table", table: table2 };
|
|
19745
19821
|
}
|
|
@@ -19749,10 +19825,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19749
19825
|
for (const el of effectiveChildElements(tc2)) {
|
|
19750
19826
|
if (matchesLocal(el, "p")) {
|
|
19751
19827
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19752
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
19828
|
+
if (_optionalChain([block, 'optionalAccess', _163 => _163.text])) parts.push(block.text);
|
|
19753
19829
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19754
19830
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19755
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
19831
|
+
if (_optionalChain([tb, 'optionalAccess', _164 => _164.text])) parts.push(tb.text);
|
|
19756
19832
|
}
|
|
19757
19833
|
} else if (matchesLocal(el, "tbl")) {
|
|
19758
19834
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -19787,7 +19863,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19787
19863
|
try {
|
|
19788
19864
|
const data = await imgFile.async("uint8array");
|
|
19789
19865
|
imgIdx++;
|
|
19790
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
19866
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _165 => _165.split, 'call', _166 => _166("."), 'access', _167 => _167.pop, 'call', _168 => _168(), 'optionalAccess', _169 => _169.toLowerCase, 'call', _170 => _170()]), () => ( "png"));
|
|
19791
19867
|
const mimeMap = {
|
|
19792
19868
|
png: "image/png",
|
|
19793
19869
|
jpg: "image/jpeg",
|
|
@@ -19841,12 +19917,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19841
19917
|
}
|
|
19842
19918
|
}
|
|
19843
19919
|
async function parseDocxDocument(buffer, options) {
|
|
19844
|
-
|
|
19920
|
+
_chunkCWP56BRCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19845
19921
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19846
19922
|
const warnings = [];
|
|
19847
19923
|
const docFile = zip.file("word/document.xml");
|
|
19848
19924
|
if (!docFile) {
|
|
19849
|
-
throw new (0,
|
|
19925
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19850
19926
|
}
|
|
19851
19927
|
let rels = /* @__PURE__ */ new Map();
|
|
19852
19928
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19893,7 +19969,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19893
19969
|
const doc = parseXml2(docXml);
|
|
19894
19970
|
const body = findElements(doc, "body");
|
|
19895
19971
|
if (body.length === 0) {
|
|
19896
|
-
throw new (0,
|
|
19972
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19897
19973
|
}
|
|
19898
19974
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19899
19975
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19901,7 +19977,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19901
19977
|
const bodyEl = body[0];
|
|
19902
19978
|
const topLevel = effectiveChildElements(bodyEl);
|
|
19903
19979
|
for (const el of topLevel) {
|
|
19904
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
19980
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _171 => _171.tagName, 'optionalAccess', _172 => _172.split, 'call', _173 => _173(":"), 'access', _174 => _174.pop, 'call', _175 => _175()])));
|
|
19905
19981
|
if (localName2 === "p") {
|
|
19906
19982
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19907
19983
|
if (block) blocks.push(block);
|
|
@@ -19912,7 +19988,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19912
19988
|
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19913
19989
|
}
|
|
19914
19990
|
} else if (localName2 === "tbl") {
|
|
19915
|
-
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess',
|
|
19991
|
+
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess', _176 => _176.keepTrailingEmptyCols]));
|
|
19916
19992
|
if (block) blocks.push(block);
|
|
19917
19993
|
}
|
|
19918
19994
|
}
|
|
@@ -19944,7 +20020,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19944
20020
|
}
|
|
19945
20021
|
}
|
|
19946
20022
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19947
|
-
const markdown =
|
|
20023
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19948
20024
|
return {
|
|
19949
20025
|
markdown,
|
|
19950
20026
|
blocks,
|
|
@@ -19967,7 +20043,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19967
20043
|
}
|
|
19968
20044
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19969
20045
|
const normalized = text.replace(/ /g, " ");
|
|
19970
|
-
const xml =
|
|
20046
|
+
const xml = _chunkCWP56BRCcjs.stripDtd.call(void 0, normalized);
|
|
19971
20047
|
const warnings = [];
|
|
19972
20048
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19973
20049
|
onError: (_level, msg2) => {
|
|
@@ -19995,7 +20071,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19995
20071
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19996
20072
|
}
|
|
19997
20073
|
const blocks = [];
|
|
19998
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
20074
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _177 => _177.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
19999
20075
|
let sectionIdx = 0;
|
|
20000
20076
|
const children = body.childNodes;
|
|
20001
20077
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -20004,10 +20080,10 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20004
20080
|
if (localName(el) !== "SECTION") continue;
|
|
20005
20081
|
sectionIdx++;
|
|
20006
20082
|
if (pageFilter && !pageFilter.has(sectionIdx)) continue;
|
|
20007
|
-
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
20083
|
+
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.keepTrailingEmptyCols]), () => ( false)));
|
|
20008
20084
|
}
|
|
20009
20085
|
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 =
|
|
20086
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20011
20087
|
return {
|
|
20012
20088
|
markdown,
|
|
20013
20089
|
blocks,
|
|
@@ -20093,7 +20169,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
20093
20169
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
20094
20170
|
const text = extractParagraphText(el);
|
|
20095
20171
|
if (!text) return;
|
|
20096
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
20172
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _179 => _179.headingLevel]) != null) {
|
|
20097
20173
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
20098
20174
|
} else {
|
|
20099
20175
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -20152,7 +20228,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20152
20228
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20153
20229
|
cellRows[r].push(cell2);
|
|
20154
20230
|
}
|
|
20155
|
-
const table2 =
|
|
20231
|
+
const table2 = _chunk5AXGFJQOcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20156
20232
|
const caption = extractShapeCaption(el);
|
|
20157
20233
|
if (caption.text && caption.before) {
|
|
20158
20234
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20412,7 +20488,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
20412
20488
|
(match, prefix, suffix) => {
|
|
20413
20489
|
const label = prefix + suffix;
|
|
20414
20490
|
const normalizedLabel = normalizeLabel(label);
|
|
20415
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20491
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _180 => _180.has, 'call', _181 => _181(normalizedLabel)])) return match;
|
|
20416
20492
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
20417
20493
|
if (matchKey === void 0) return match;
|
|
20418
20494
|
const newValue = values.consume(matchKey);
|
|
@@ -20491,17 +20567,17 @@ function matchInlineSegment(seg, values, blockedLabels) {
|
|
|
20491
20567
|
const nlabel = normalizeLabel(seg.label);
|
|
20492
20568
|
if (seg.extLabel !== void 0) {
|
|
20493
20569
|
const nExt = normalizeLabel(seg.extLabel);
|
|
20494
|
-
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess',
|
|
20570
|
+
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess', _182 => _182.has, 'call', _183 => _183(nExt)]) && values.has(nExt)) {
|
|
20495
20571
|
return { key: nExt, label: seg.extLabel, viaExt: true };
|
|
20496
20572
|
}
|
|
20497
20573
|
}
|
|
20498
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20574
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _184 => _184.has, 'call', _185 => _185(nlabel)])) return void 0;
|
|
20499
20575
|
const key = findMatchingKey(nlabel, values);
|
|
20500
20576
|
return key !== void 0 ? { key, label: seg.label, viaExt: false } : void 0;
|
|
20501
20577
|
}
|
|
20502
20578
|
function clampSegmentEnd(text, seg, next, nextViaExt) {
|
|
20503
20579
|
let ve = seg.valueEnd;
|
|
20504
|
-
if (nextViaExt && _optionalChain([next, 'optionalAccess',
|
|
20580
|
+
if (nextViaExt && _optionalChain([next, 'optionalAccess', _186 => _186.extStart]) !== void 0 && next.extStart < ve) ve = next.extStart;
|
|
20505
20581
|
while (ve > seg.valueStart && /\s/.test(text[ve - 1])) ve--;
|
|
20506
20582
|
return ve;
|
|
20507
20583
|
}
|
|
@@ -20516,7 +20592,7 @@ function normalizeValues(values, warnings) {
|
|
|
20516
20592
|
const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
|
|
20517
20593
|
const key = normalizeLabel(label);
|
|
20518
20594
|
if (map.has(key)) {
|
|
20519
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
20595
|
+
_optionalChain([warnings, 'optionalAccess', _187 => _187.push, 'call', _188 => _188(`\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
20596
|
}
|
|
20521
20597
|
map.set(key, Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
|
|
20522
20598
|
}
|
|
@@ -20691,8 +20767,8 @@ function extractFromTable(table2) {
|
|
|
20691
20767
|
if (table2.cols >= 2) {
|
|
20692
20768
|
for (let r = 0; r < table2.rows; r++) {
|
|
20693
20769
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
20694
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20695
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20770
|
+
const labelCell = _optionalChain([table2, 'access', _189 => _189.cells, 'access', _190 => _190[r], 'optionalAccess', _191 => _191[c]]);
|
|
20771
|
+
const valueCell = _optionalChain([table2, 'access', _192 => _192.cells, 'access', _193 => _193[r], 'optionalAccess', _194 => _194[c + 1]]);
|
|
20696
20772
|
if (!labelCell || !valueCell) continue;
|
|
20697
20773
|
if (isLabelCell(labelCell.text)) {
|
|
20698
20774
|
fields.push({
|
|
@@ -20707,15 +20783,15 @@ function extractFromTable(table2) {
|
|
|
20707
20783
|
}
|
|
20708
20784
|
if (fields.length === 0 && table2.rows >= 2 && table2.cols >= 2) {
|
|
20709
20785
|
const headerRow = table2.cells[0];
|
|
20710
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20711
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20786
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _195 => _195.every, 'call', _196 => _196((cell2) => {
|
|
20787
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _197 => _197.text, 'access', _198 => _198.trim, 'call', _199 => _199()]), () => ( ""));
|
|
20712
20788
|
return t.length > 0 && t.length <= 20;
|
|
20713
20789
|
})]), () => ( false));
|
|
20714
20790
|
if (allLabels) {
|
|
20715
20791
|
for (let r = 1; r < table2.rows; r++) {
|
|
20716
20792
|
for (let c = 0; c < table2.cols; c++) {
|
|
20717
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
20718
|
-
const value = _nullishCoalesce(_optionalChain([table2, 'access',
|
|
20793
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _200 => _200[c], 'optionalAccess', _201 => _201.text, 'access', _202 => _202.trim, 'call', _203 => _203()]), () => ( ""));
|
|
20794
|
+
const value = _nullishCoalesce(_optionalChain([table2, 'access', _204 => _204.cells, 'access', _205 => _205[r], 'optionalAccess', _206 => _206[c], 'optionalAccess', _207 => _207.text, 'access', _208 => _208.trim, 'call', _209 => _209()]), () => ( ""));
|
|
20719
20795
|
if (label && value) {
|
|
20720
20796
|
fields.push({ label, value, row: r, col: c });
|
|
20721
20797
|
}
|
|
@@ -20809,7 +20885,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
20809
20885
|
for (const table2 of allTables) {
|
|
20810
20886
|
for (let r = 0; r < table2.rows; r++) {
|
|
20811
20887
|
for (let c = 0; c < table2.cols; c++) {
|
|
20812
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20888
|
+
const cell2 = _optionalChain([table2, 'access', _210 => _210.cells, 'access', _211 => _211[r], 'optionalAccess', _212 => _212[c]]);
|
|
20813
20889
|
if (!cell2) continue;
|
|
20814
20890
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
20815
20891
|
if (result) {
|
|
@@ -20841,7 +20917,7 @@ function collectIRTables(blocks, depth) {
|
|
|
20841
20917
|
out.push(block.table);
|
|
20842
20918
|
for (const row of block.table.cells) {
|
|
20843
20919
|
for (const cell2 of row) {
|
|
20844
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
20920
|
+
if (_optionalChain([cell2, 'optionalAccess', _213 => _213.blocks, 'optionalAccess', _214 => _214.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
20845
20921
|
}
|
|
20846
20922
|
}
|
|
20847
20923
|
}
|
|
@@ -20852,7 +20928,7 @@ function coveredPositions(table2) {
|
|
|
20852
20928
|
for (let r = 0; r < table2.rows; r++) {
|
|
20853
20929
|
for (let c = 0; c < table2.cols; c++) {
|
|
20854
20930
|
if (covered.has(`${r},${c}`)) continue;
|
|
20855
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20931
|
+
const cell2 = _optionalChain([table2, 'access', _215 => _215.cells, 'access', _216 => _216[r], 'optionalAccess', _217 => _217[c]]);
|
|
20856
20932
|
if (!cell2) continue;
|
|
20857
20933
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
20858
20934
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -20868,15 +20944,15 @@ function coveredPositions(table2) {
|
|
|
20868
20944
|
function isHeaderDataTable(table2, covered) {
|
|
20869
20945
|
if (table2.rows < 2) return false;
|
|
20870
20946
|
const headerRow = table2.cells[0];
|
|
20871
|
-
if (!_optionalChain([headerRow, 'optionalAccess',
|
|
20947
|
+
if (!_optionalChain([headerRow, 'optionalAccess', _218 => _218.length])) return false;
|
|
20872
20948
|
const allLabels = headerRow.every((cell2) => {
|
|
20873
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20949
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _219 => _219.text, 'access', _220 => _220.trim, 'call', _221 => _221()]), () => ( ""));
|
|
20874
20950
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20875
20951
|
});
|
|
20876
20952
|
if (!allLabels) return false;
|
|
20877
20953
|
for (let c = 0; c < table2.cols; c++) {
|
|
20878
20954
|
if (covered.has(`1,${c}`)) continue;
|
|
20879
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20955
|
+
const cell2 = _optionalChain([table2, 'access', _222 => _222.cells, 'access', _223 => _223[1], 'optionalAccess', _224 => _224[c]]);
|
|
20880
20956
|
if (!cell2) break;
|
|
20881
20957
|
return !isLabelCell(cell2.text);
|
|
20882
20958
|
}
|
|
@@ -20889,7 +20965,7 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20889
20965
|
for (let r = skipHeaderRow ? 1 : 0; r < table2.rows; r++) {
|
|
20890
20966
|
for (let c = 0; c < table2.cols; c++) {
|
|
20891
20967
|
if (covered.has(`${r},${c}`)) continue;
|
|
20892
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20968
|
+
const labelCell = _optionalChain([table2, 'access', _225 => _225.cells, 'access', _226 => _226[r], 'optionalAccess', _227 => _227[c]]);
|
|
20893
20969
|
if (!labelCell) continue;
|
|
20894
20970
|
if (!isLabelCell(labelCell.text)) continue;
|
|
20895
20971
|
let vc = c + labelCell.colSpan;
|
|
@@ -20900,12 +20976,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20900
20976
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
20901
20977
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
20902
20978
|
if (!normalizedCellLabel) continue;
|
|
20903
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20979
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _228 => _228.has, 'call', _229 => _229(normalizedCellLabel)])) continue;
|
|
20904
20980
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
20905
20981
|
if (matchKey === void 0) continue;
|
|
20906
20982
|
const newValue = values.consume(matchKey);
|
|
20907
20983
|
if (newValue === void 0) continue;
|
|
20908
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20984
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _230 => _230.has, 'call', _231 => _231(valueCell)])) {
|
|
20909
20985
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20910
20986
|
} else {
|
|
20911
20987
|
valueCell.text = newValue;
|
|
@@ -20922,8 +20998,8 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20922
20998
|
}
|
|
20923
20999
|
if (table2.rows >= 2 && table2.cols >= 2) {
|
|
20924
21000
|
const headerRow = table2.cells[0];
|
|
20925
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20926
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
21001
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _232 => _232.every, 'call', _233 => _233((cell2) => {
|
|
21002
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _234 => _234.text, 'access', _235 => _235.trim, 'call', _236 => _236()]), () => ( ""));
|
|
20927
21003
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20928
21004
|
})]), () => ( false));
|
|
20929
21005
|
if (!allLabels) return;
|
|
@@ -20931,16 +21007,16 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20931
21007
|
for (let c = 0; c < table2.cols; c++) {
|
|
20932
21008
|
if (covered.has(`${r},${c}`)) continue;
|
|
20933
21009
|
const headerCell = headerRow[c];
|
|
20934
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
21010
|
+
const valueCell = _optionalChain([table2, 'access', _237 => _237.cells, 'access', _238 => _238[r], 'optionalAccess', _239 => _239[c]]);
|
|
20935
21011
|
if (!headerCell || !valueCell) continue;
|
|
20936
21012
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
20937
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21013
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _240 => _240.has, 'call', _241 => _241(headerLabel)])) continue;
|
|
20938
21014
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
20939
21015
|
if (matchKey === void 0) continue;
|
|
20940
21016
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
20941
21017
|
const newValue = values.consume(matchKey);
|
|
20942
21018
|
if (newValue === void 0) continue;
|
|
20943
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
21019
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _242 => _242.has, 'call', _243 => _243(valueCell)])) {
|
|
20944
21020
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20945
21021
|
} else {
|
|
20946
21022
|
valueCell.text = newValue;
|
|
@@ -20972,7 +21048,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
20972
21048
|
if (newValue === void 0) continue;
|
|
20973
21049
|
matchedLabels.add(matchKey);
|
|
20974
21050
|
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',
|
|
21051
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _244 => _244[i + 1], 'optionalAccess', _245 => _245.viaExt]), () => ( false)));
|
|
20976
21052
|
out += text.slice(pos, seg.valueStart);
|
|
20977
21053
|
out += seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
20978
21054
|
pos = ve;
|
|
@@ -21534,19 +21610,19 @@ function parseCentralDirectory(buf) {
|
|
|
21534
21610
|
}
|
|
21535
21611
|
}
|
|
21536
21612
|
}
|
|
21537
|
-
if (eocdOffset < 0) throw new (0,
|
|
21613
|
+
if (eocdOffset < 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21538
21614
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21539
21615
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21540
21616
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21541
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21617
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21542
21618
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21543
|
-
throw new (0,
|
|
21619
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21544
21620
|
}
|
|
21545
21621
|
const decoder = new TextDecoder("utf-8");
|
|
21546
21622
|
const entries = [];
|
|
21547
21623
|
let pos = cdOffset;
|
|
21548
21624
|
for (let i = 0; i < totalEntries; i++) {
|
|
21549
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21625
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21550
21626
|
const flags = view.getUint16(pos + 8, true);
|
|
21551
21627
|
const method = view.getUint16(pos + 10, true);
|
|
21552
21628
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21557,7 +21633,7 @@ function parseCentralDirectory(buf) {
|
|
|
21557
21633
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21558
21634
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21559
21635
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21560
|
-
throw new (0,
|
|
21636
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21561
21637
|
}
|
|
21562
21638
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21563
21639
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21586,11 +21662,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21586
21662
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21587
21663
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21588
21664
|
for (const name of replacements.keys()) {
|
|
21589
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21665
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkCWP56BRCcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21590
21666
|
}
|
|
21591
21667
|
if (additions) {
|
|
21592
21668
|
for (const name of additions.keys()) {
|
|
21593
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21669
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkCWP56BRCcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21594
21670
|
}
|
|
21595
21671
|
}
|
|
21596
21672
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21609,7 +21685,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21609
21685
|
offset += seg.length;
|
|
21610
21686
|
continue;
|
|
21611
21687
|
}
|
|
21612
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21688
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkCWP56BRCcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21613
21689
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21614
21690
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21615
21691
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21617,7 +21693,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21617
21693
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21618
21694
|
const method = e.method;
|
|
21619
21695
|
if (method !== 0 && method !== 8) {
|
|
21620
|
-
throw new (0,
|
|
21696
|
+
throw new (0, _chunkCWP56BRCcjs.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
21697
|
}
|
|
21622
21698
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21623
21699
|
const crc = crc32(newData);
|
|
@@ -21718,7 +21794,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21718
21794
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21719
21795
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21720
21796
|
if (sectionPaths.length === 0) {
|
|
21721
|
-
throw new (0,
|
|
21797
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21722
21798
|
}
|
|
21723
21799
|
const warnings = [];
|
|
21724
21800
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -21802,7 +21878,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21802
21878
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
21803
21879
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
21804
21880
|
if (!normalizedCellLabel) continue;
|
|
21805
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21881
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _246 => _246.has, 'call', _247 => _247(normalizedCellLabel)])) continue;
|
|
21806
21882
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
21807
21883
|
if (matchKey === void 0) continue;
|
|
21808
21884
|
if (patternApplied.has(valueCell)) {
|
|
@@ -21860,7 +21936,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21860
21936
|
const dataCells = table2.rows[rowIdx];
|
|
21861
21937
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
21862
21938
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
21863
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21939
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _248 => _248.has, 'call', _249 => _249(headerLabel)])) continue;
|
|
21864
21940
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
21865
21941
|
if (matchKey === void 0) continue;
|
|
21866
21942
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -21914,7 +21990,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21914
21990
|
}
|
|
21915
21991
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
21916
21992
|
const existing = ledger.get(para2);
|
|
21917
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
21993
|
+
if (_optionalChain([existing, 'optionalAccess', _250 => _250.fullText]) !== void 0) continue;
|
|
21918
21994
|
const text = matchText(para2);
|
|
21919
21995
|
const segments = scanInlineSegments(text);
|
|
21920
21996
|
const matches = segments.map((seg) => matchInlineSegment(seg, cursor, blockedLabels));
|
|
@@ -21925,7 +22001,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21925
22001
|
const matchKey = matched.key;
|
|
21926
22002
|
const newValue = cursor.consume(matchKey);
|
|
21927
22003
|
if (newValue === void 0) continue;
|
|
21928
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
22004
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _251 => _251[i + 1], 'optionalAccess', _252 => _252.viaExt]), () => ( false)));
|
|
21929
22005
|
const replacement = seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
21930
22006
|
const l = led(para2);
|
|
21931
22007
|
l.ranges.push({ start: seg.valueStart, end: ve, replacement });
|
|
@@ -22031,16 +22107,16 @@ var PARA_LIST = 7;
|
|
|
22031
22107
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
22032
22108
|
function resolveTheme(theme) {
|
|
22033
22109
|
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',
|
|
22110
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _253 => _253.headingColors, 'optionalAccess', _254 => _254[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22111
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _255 => _255.headingColors, 'optionalAccess', _256 => _256[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22112
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _257 => _257.headingColors, 'optionalAccess', _258 => _258[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22113
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _259 => _259.headingColors, 'optionalAccess', _260 => _260[4]]), () => ( _optionalChain([theme, 'optionalAccess', _261 => _261.headingColors, 'optionalAccess', _262 => _262[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22114
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _263 => _263.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22115
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _264 => _264.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22040
22116
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
22041
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
22042
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22043
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
22117
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _265 => _265.quoteColor]) !== void 0,
|
|
22118
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _266 => _266.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _267 => _267.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22119
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _268 => _268.tableHeaderBold])
|
|
22044
22120
|
};
|
|
22045
22121
|
}
|
|
22046
22122
|
function escapeXml(text) {
|
|
@@ -22455,7 +22531,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22455
22531
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22456
22532
|
const got = m ? Number(m[1]) : NaN;
|
|
22457
22533
|
if (got !== startId + i) {
|
|
22458
|
-
throw new (0,
|
|
22534
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
22459
22535
|
`\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
22536
|
);
|
|
22461
22537
|
}
|
|
@@ -22539,7 +22615,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22539
22615
|
}
|
|
22540
22616
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22541
22617
|
if (rows.length !== expectedBase) {
|
|
22542
|
-
throw new (0,
|
|
22618
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
22543
22619
|
`\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
22620
|
);
|
|
22545
22621
|
}
|
|
@@ -22766,7 +22842,7 @@ function buildStyles(gongmun) {
|
|
|
22766
22842
|
</hh:styles>`;
|
|
22767
22843
|
}
|
|
22768
22844
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
22769
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
22845
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _269 => _269.fonts, 'access', _270 => _270.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _271 => _271.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
22770
22846
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
22771
22847
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
22772
22848
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22895,8 +22971,8 @@ function parseChartFence(text) {
|
|
|
22895
22971
|
const spec = chartSpec(type);
|
|
22896
22972
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22897
22973
|
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',
|
|
22974
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _272 => _272.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
22975
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _273 => _273[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22900
22976
|
if (!spec.scatter) {
|
|
22901
22977
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22902
22978
|
}
|
|
@@ -22938,7 +23014,7 @@ function serSpPr(color, stroke) {
|
|
|
22938
23014
|
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
23015
|
}
|
|
22940
23016
|
function dPtXml(pointColors, pie) {
|
|
22941
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
23017
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _274 => _274.length])) return "";
|
|
22942
23018
|
return pointColors.map((col, i) => {
|
|
22943
23019
|
const f = chartColorFill(col);
|
|
22944
23020
|
if (!f) return "";
|
|
@@ -23177,8 +23253,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
23177
23253
|
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
23254
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
23179
23255
|
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',
|
|
23256
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _275 => _275.cover, 'optionalAccess', _276 => _276.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
23257
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _277 => _277.cover, 'optionalAccess', _278 => _278.org]), () => ( ""));
|
|
23182
23258
|
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
23259
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
23184
23260
|
return [
|
|
@@ -23434,7 +23510,7 @@ function escapeGfm(text) {
|
|
|
23434
23510
|
}
|
|
23435
23511
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23436
23512
|
function sanitizeText(text) {
|
|
23437
|
-
let result =
|
|
23513
|
+
let result = _chunk5AXGFJQOcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23438
23514
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23439
23515
|
const tokens = result.split(" ");
|
|
23440
23516
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23464,7 +23540,7 @@ function replicateGfmTable(table2) {
|
|
|
23464
23540
|
for (let r = 0; r < numRows; r++) {
|
|
23465
23541
|
for (let c = 0; c < numCols; c++) {
|
|
23466
23542
|
if (skip.has(`${r},${c}`)) continue;
|
|
23467
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23543
|
+
const cell2 = _optionalChain([cells, 'access', _279 => _279[r], 'optionalAccess', _280 => _280[c]]);
|
|
23468
23544
|
if (!cell2) continue;
|
|
23469
23545
|
display[r][c] = {
|
|
23470
23546
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -23518,7 +23594,7 @@ function unescapeGfmCell(text) {
|
|
|
23518
23594
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
|
|
23519
23595
|
}
|
|
23520
23596
|
function replicateCellInnerHtml(cell2) {
|
|
23521
|
-
if (_optionalChain([cell2, 'access',
|
|
23597
|
+
if (_optionalChain([cell2, 'access', _281 => _281.blocks, 'optionalAccess', _282 => _282.length])) {
|
|
23522
23598
|
return cell2.blocks.map((b) => {
|
|
23523
23599
|
if (b.type === "table" && b.table) {
|
|
23524
23600
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -23557,7 +23633,7 @@ function replicateHtmlTable(table2) {
|
|
|
23557
23633
|
const rowCells = [];
|
|
23558
23634
|
for (let c = 0; c < numCols; c++) {
|
|
23559
23635
|
if (skip.has(`${r},${c}`)) continue;
|
|
23560
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23636
|
+
const cell2 = _optionalChain([cells, 'access', _283 => _283[r], 'optionalAccess', _284 => _284[c]]);
|
|
23561
23637
|
if (!cell2) continue;
|
|
23562
23638
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
23563
23639
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -23603,10 +23679,10 @@ function parseHtmlTable(raw) {
|
|
|
23603
23679
|
}
|
|
23604
23680
|
} else {
|
|
23605
23681
|
if (!isClose) {
|
|
23606
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
23607
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
23682
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _285 => _285.match, 'call', _286 => _286(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _287 => _287[1]]) || "1", 10);
|
|
23683
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _288 => _288.match, 'call', _289 => _289(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _290 => _290[1]]) || "1", 10);
|
|
23608
23684
|
cellStart = m.index + m[0].length;
|
|
23609
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23685
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunk5AXGFJQOcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunk5AXGFJQOcjs.MAX_ROWS) };
|
|
23610
23686
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23611
23687
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23612
23688
|
cellStart = -1;
|
|
@@ -23630,7 +23706,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
23630
23706
|
hadNonText = true;
|
|
23631
23707
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
23632
23708
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
23633
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
23709
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _291 => _291[1]]), () => ( _optionalChain([m, 'optionalAccess', _292 => _292[2]])));
|
|
23634
23710
|
if (src) imgSrcs.push(src);
|
|
23635
23711
|
return "";
|
|
23636
23712
|
});
|
|
@@ -23638,6 +23714,18 @@ function htmlCellInnerToLines(inner) {
|
|
|
23638
23714
|
const lines = work.split(/<br\s*\/?>/gi).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
23639
23715
|
return { lines, hadNonText, imgSrcs };
|
|
23640
23716
|
}
|
|
23717
|
+
function splitCellByTopLevelTables(html) {
|
|
23718
|
+
const tables = extractTopLevelTables(html);
|
|
23719
|
+
const texts = [];
|
|
23720
|
+
let rest = html;
|
|
23721
|
+
for (const t of tables) {
|
|
23722
|
+
const i = rest.indexOf(t);
|
|
23723
|
+
texts.push(rest.slice(0, i));
|
|
23724
|
+
rest = rest.slice(i + t.length);
|
|
23725
|
+
}
|
|
23726
|
+
texts.push(rest);
|
|
23727
|
+
return { texts, tables };
|
|
23728
|
+
}
|
|
23641
23729
|
function extractTopLevelTables(html) {
|
|
23642
23730
|
const result = [];
|
|
23643
23731
|
let depth = 0;
|
|
@@ -23761,7 +23849,7 @@ function edgeXml(tag, d) {
|
|
|
23761
23849
|
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
23850
|
}
|
|
23763
23851
|
function borderFillDefToXml(id, def) {
|
|
23764
|
-
const fill = _optionalChain([def, 'access',
|
|
23852
|
+
const fill = _optionalChain([def, 'access', _293 => _293.fill, 'optionalAccess', _294 => _294.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
23765
23853
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
23766
23854
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
23767
23855
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -24166,11 +24254,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
24166
24254
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
24167
24255
|
const rowCnt = rows.length;
|
|
24168
24256
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
24169
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24257
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _295 => _295.bfRegistry]), () => ( null));
|
|
24170
24258
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
24171
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24259
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _296 => _296.charHeight]), () => ( 1e3));
|
|
24172
24260
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
24173
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
24261
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _297 => _297[0], 'optionalAccess', _298 => _298[0]]), () => ( ""))), seq, rowAnchor);
|
|
24174
24262
|
const colMax = Array(colCnt).fill(0);
|
|
24175
24263
|
const colMaxBody = Array(colCnt).fill(0);
|
|
24176
24264
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -24198,7 +24286,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24198
24286
|
const k = `${rowIdx},${colIdx}`;
|
|
24199
24287
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
24200
24288
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
24201
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24289
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _299 => _299.cellChar, 'access', _300 => _300.get, 'call', _301 => _301(k)]), () => ( defaultCharPr));
|
|
24202
24290
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
24203
24291
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24204
24292
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -24216,11 +24304,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24216
24304
|
}
|
|
24217
24305
|
}
|
|
24218
24306
|
}
|
|
24219
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
24307
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _302 => _302.cellChar, 'access', _303 => _303.has, 'call', _304 => _304(k)]) ? void 0 : mapId);
|
|
24220
24308
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
24221
24309
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
24222
24310
|
}).join("");
|
|
24223
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24311
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _305 => _305.cellBf, 'access', _306 => _306.get, 'call', _307 => _307(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24224
24312
|
row: rowIdx,
|
|
24225
24313
|
rowEnd: rowIdx,
|
|
24226
24314
|
col: colIdx,
|
|
@@ -24230,7 +24318,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24230
24318
|
headerRows: 1,
|
|
24231
24319
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
24232
24320
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
24233
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24321
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _308 => _308.cellH, 'access', _309 => _309.get, 'call', _310 => _310(k)]), () => ( cellH));
|
|
24234
24322
|
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
24323
|
}).join("");
|
|
24236
24324
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -24239,7 +24327,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24239
24327
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
24240
24328
|
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
24329
|
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',
|
|
24330
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _311 => _311.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
24243
24331
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
24244
24332
|
}
|
|
24245
24333
|
function layoutHtmlRows(rows) {
|
|
@@ -24250,8 +24338,8 @@ function layoutHtmlRows(rows) {
|
|
|
24250
24338
|
let c = 0;
|
|
24251
24339
|
for (const cell2 of rows[r].cells) {
|
|
24252
24340
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24253
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24254
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24341
|
+
const colSpan = clampSpan(cell2.colSpan, _chunk5AXGFJQOcjs.MAX_COLS);
|
|
24342
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunk5AXGFJQOcjs.MAX_ROWS);
|
|
24255
24343
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24256
24344
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24257
24345
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -24279,7 +24367,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24279
24367
|
if (!rows || rows.length === 0) return null;
|
|
24280
24368
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
24281
24369
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
24282
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24370
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _312 => _312.charHeight]), () => ( 1e3));
|
|
24283
24371
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
24284
24372
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
24285
24373
|
for (const cell2 of placed) {
|
|
@@ -24308,7 +24396,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24308
24396
|
const tblId = nextTableId();
|
|
24309
24397
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
24310
24398
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
24311
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24399
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _313 => _313.bfRegistry]), () => ( null));
|
|
24312
24400
|
let htmlHeaderRows = 0;
|
|
24313
24401
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
24314
24402
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -24316,39 +24404,40 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24316
24404
|
const rowSpan = Math.min(cell2.rowSpan, rowCnt - cell2.r);
|
|
24317
24405
|
const lines = cellLines[i];
|
|
24318
24406
|
let nestedH = 0;
|
|
24319
|
-
const
|
|
24320
|
-
|
|
24407
|
+
const { texts: segTexts, tables: nestedTables } = splitCellByTopLevelTables(cell2.inner);
|
|
24408
|
+
const nestedXmls = nestedTables.map((nested) => {
|
|
24321
24409
|
const sw = spanW(cell2);
|
|
24322
24410
|
const nestedW = Math.max(Math.min(Math.max(sw - 1020, 4e3), sw - 282), 500);
|
|
24323
24411
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
24324
24412
|
if (nestedXml) {
|
|
24325
|
-
|
|
24326
|
-
const szH = _optionalChain([nestedXml, 'access', _308 => _308.match, 'call', _309 => _309(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _310 => _310[1]]);
|
|
24413
|
+
const szH = _optionalChain([nestedXml, 'access', _314 => _314.match, 'call', _315 => _315(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _316 => _316[1]]);
|
|
24327
24414
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
24328
24415
|
}
|
|
24329
|
-
|
|
24416
|
+
return nestedXml;
|
|
24417
|
+
});
|
|
24418
|
+
const segLines = segTexts.map((t) => htmlCellInnerToLines(t).lines);
|
|
24330
24419
|
const usable = Math.max(spanW(cell2) - CELL_PAD, 1e3);
|
|
24331
24420
|
let wrapLines = 0;
|
|
24332
24421
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
24333
24422
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
24334
24423
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
24335
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24424
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _317 => _317.cellH, 'access', _318 => _318.get, 'call', _319 => _319(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
|
|
24336
24425
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
24337
24426
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
24338
|
-
return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
|
|
24427
|
+
return { cell: cell2, rowSpan, lines, nestedXmls, segLines, imgSrcs: cellParsed[i].imgSrcs };
|
|
24339
24428
|
});
|
|
24340
|
-
const tcXmls = meta.map(({ cell: cell2, rowSpan,
|
|
24429
|
+
const tcXmls = meta.map(({ cell: cell2, rowSpan, nestedXmls, segLines, imgSrcs }) => {
|
|
24341
24430
|
const k = `${cell2.r},${cell2.c}`;
|
|
24342
24431
|
const isHeader = cell2.isHeader;
|
|
24343
24432
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
24344
24433
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
24345
24434
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
24346
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24435
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _320 => _320.cellChar, 'access', _321 => _321.get, 'call', _322 => _322(k)]), () => ( defaultCharPr));
|
|
24347
24436
|
const centered = isHeader || colCentered[cell2.c];
|
|
24348
24437
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24349
24438
|
const picUrls = images ? [...imgSrcs] : [];
|
|
24350
24439
|
const paras = [];
|
|
24351
|
-
|
|
24440
|
+
const pushTextLine = (line) => {
|
|
24352
24441
|
let text = unescapeHtml(line);
|
|
24353
24442
|
if (images) {
|
|
24354
24443
|
const { text: rest, urls } = splitImageRefs(text);
|
|
@@ -24360,7 +24449,14 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24360
24449
|
if (!images || text.trim() || picUrls.length === 0) {
|
|
24361
24450
|
paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t>${escapeXml(text)}</hp:t></hp:run></hp:p>`);
|
|
24362
24451
|
}
|
|
24363
|
-
}
|
|
24452
|
+
};
|
|
24453
|
+
segLines.forEach((seg, si) => {
|
|
24454
|
+
for (const line of seg) pushTextLine(line);
|
|
24455
|
+
const nestedXml = nestedXmls[si];
|
|
24456
|
+
if (nestedXml) {
|
|
24457
|
+
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${nestedXml}</hp:run></hp:p>`);
|
|
24458
|
+
}
|
|
24459
|
+
});
|
|
24364
24460
|
if (images && picUrls.length > 0) {
|
|
24365
24461
|
const pics = picUrls.map((u) => {
|
|
24366
24462
|
const part = images.take(u);
|
|
@@ -24370,16 +24466,13 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24370
24466
|
paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}">${pics.join("")}</hp:run></hp:p>`);
|
|
24371
24467
|
}
|
|
24372
24468
|
}
|
|
24373
|
-
for (const nestedXml of nestedXmls) {
|
|
24374
|
-
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${nestedXml}</hp:run></hp:p>`);
|
|
24375
|
-
}
|
|
24376
24469
|
if (paras.length === 0) {
|
|
24377
24470
|
paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
24378
24471
|
}
|
|
24379
24472
|
let cellHeight = 0;
|
|
24380
24473
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
24381
24474
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
24382
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24475
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _323 => _323.cellBf, 'access', _324 => _324.get, 'call', _325 => _325(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24383
24476
|
row: cell2.r,
|
|
24384
24477
|
rowEnd,
|
|
24385
24478
|
col: cell2.c,
|
|
@@ -24549,7 +24642,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
24549
24642
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
24550
24643
|
}
|
|
24551
24644
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
24552
|
-
const c = _optionalChain([g, 'access',
|
|
24645
|
+
const c = _optionalChain([g, 'access', _326 => _326.press, 'optionalAccess', _327 => _327.contact]);
|
|
24553
24646
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
24554
24647
|
const w = bodyWidth - 280;
|
|
24555
24648
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -24930,7 +25023,7 @@ function generateSecPr(gongmun) {
|
|
|
24930
25023
|
}
|
|
24931
25024
|
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
25025
|
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',
|
|
25026
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _328 => _328.pageNumbers]) ? pageNumCtrl() : "");
|
|
24934
25027
|
}
|
|
24935
25028
|
var SectionOpener = (_class6 = class {
|
|
24936
25029
|
constructor(gongmun) {;_class6.prototype.__init12.call(this);
|
|
@@ -24969,19 +25062,19 @@ function buildPreamble(blocks, ctx) {
|
|
|
24969
25062
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
24970
25063
|
const preamble = [];
|
|
24971
25064
|
let hasFrontPages = false;
|
|
24972
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25065
|
+
if (_optionalChain([gongmun, 'optionalAccess', _329 => _329.reportInfo]) && dfIds) {
|
|
24973
25066
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
24974
25067
|
}
|
|
24975
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25068
|
+
if (_optionalChain([gongmun, 'optionalAccess', _330 => _330.approval]) && bfReg) {
|
|
24976
25069
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
24977
25070
|
}
|
|
24978
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25071
|
+
if (_optionalChain([gongmun, 'optionalAccess', _331 => _331.docHead]) && dfIds) {
|
|
24979
25072
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
24980
25073
|
}
|
|
24981
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25074
|
+
if (_optionalChain([gongmun, 'optionalAccess', _332 => _332.noticeHead]) && dfIds) {
|
|
24982
25075
|
preamble.push(...buildNoticeHead(gongmun));
|
|
24983
25076
|
}
|
|
24984
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25077
|
+
if (_optionalChain([gongmun, 'optionalAccess', _333 => _333.press]) && dfIds && bfReg && tableStyle) {
|
|
24985
25078
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
24986
25079
|
}
|
|
24987
25080
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -25010,7 +25103,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
25010
25103
|
}
|
|
25011
25104
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
25012
25105
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25013
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
25106
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _334 => _334.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
25014
25107
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25015
25108
|
}
|
|
25016
25109
|
if (preamble.length > 0) {
|
|
@@ -25025,7 +25118,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
25025
25118
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
25026
25119
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
25027
25120
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
25028
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
25121
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _335 => _335.press, 'optionalAccess', _336 => _336.sub]), () => ( []))) {
|
|
25029
25122
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
25030
25123
|
}
|
|
25031
25124
|
return parts.join("\n ");
|
|
@@ -25119,8 +25212,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25119
25212
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
25120
25213
|
if (gongmun && gongmunList) {
|
|
25121
25214
|
const info = gongmunList.items.get(blockIdx);
|
|
25122
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25123
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25215
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _337 => _337.depth]), () => ( 0));
|
|
25216
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _338 => _338.marker]), () => ( ""));
|
|
25124
25217
|
const content = block.text || "";
|
|
25125
25218
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
25126
25219
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -25129,7 +25222,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25129
25222
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
25130
25223
|
}
|
|
25131
25224
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
25132
|
-
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess',
|
|
25225
|
+
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _339 => _339.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
25133
25226
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
25134
25227
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
25135
25228
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -25188,18 +25281,18 @@ function renderHtmlTable(block, ctx) {
|
|
|
25188
25281
|
}
|
|
25189
25282
|
function appendPostamble(blocks, ctx) {
|
|
25190
25283
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
25191
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25284
|
+
if (_optionalChain([gongmun, 'optionalAccess', _340 => _340.noticeHead]) && dfIds) {
|
|
25192
25285
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
25193
25286
|
}
|
|
25194
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25195
|
-
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access',
|
|
25287
|
+
if (_optionalChain([gongmun, 'optionalAccess', _341 => _341.endMark]) && paraXmls.length > 0) {
|
|
25288
|
+
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _342 => _342.rows, 'optionalAccess', _343 => _343.length]));
|
|
25196
25289
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
25197
25290
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
25198
25291
|
}
|
|
25199
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25292
|
+
if (_optionalChain([gongmun, 'optionalAccess', _344 => _344.docFoot]) && dfIds) {
|
|
25200
25293
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
25201
25294
|
}
|
|
25202
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25295
|
+
if (_optionalChain([gongmun, 'optionalAccess', _345 => _345.press]) && dfIds && bfReg && tableStyle) {
|
|
25203
25296
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25204
25297
|
}
|
|
25205
25298
|
}
|
|
@@ -25219,7 +25312,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25219
25312
|
remap,
|
|
25220
25313
|
dfIds,
|
|
25221
25314
|
images,
|
|
25222
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
25315
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _346 => _346.preset]) === "gaejosik",
|
|
25223
25316
|
measured,
|
|
25224
25317
|
richAssets,
|
|
25225
25318
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -25325,18 +25418,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25325
25418
|
|
|
25326
25419
|
// src/hwpx/generator.ts
|
|
25327
25420
|
async function markdownToHwpx(markdown, options) {
|
|
25328
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
25329
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
25421
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _347 => _347.theme]));
|
|
25422
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _348 => _348.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
25330
25423
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
25331
25424
|
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
25332
25425
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
25333
25426
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
25334
25427
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
25335
25428
|
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
25336
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
25337
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25429
|
+
const remap = _optionalChain([options, 'optionalAccess', _349 => _349.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _350 => _350.variants, 'optionalAccess', _351 => _351.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
|
|
25430
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _352 => _352.borderFillXmls, 'access', _353 => _353.length]), () => ( 0)))) : null;
|
|
25338
25431
|
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
25339
|
-
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25432
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _354 => _354.variants, 'optionalAccess', _355 => _355.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _356 => _356.charPrXmls, 'access', _357 => _357.length]), () => ( 0)));
|
|
25340
25433
|
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
25341
25434
|
const chartParts = [];
|
|
25342
25435
|
const images = new ImageRegistry();
|
|
@@ -25347,7 +25440,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25347
25440
|
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
25441
|
}
|
|
25349
25442
|
}
|
|
25350
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25443
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _358 => _358.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _359 => _359.emit, 'call', _360 => _360()]), () => ( []))];
|
|
25351
25444
|
const zip = new (0, _jszip2.default)();
|
|
25352
25445
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
25353
25446
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
@@ -25356,11 +25449,11 @@ async function markdownToHwpx(markdown, options) {
|
|
|
25356
25449
|
zip.file("Contents/header.xml", generateHeaderXml(
|
|
25357
25450
|
theme,
|
|
25358
25451
|
gongmun,
|
|
25359
|
-
_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
25452
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _361 => _361.variants]), () => ( [])),
|
|
25360
25453
|
extraBorderFills,
|
|
25361
|
-
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25362
|
-
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess',
|
|
25363
|
-
_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
25454
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _362 => _362.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
|
|
25455
|
+
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _363 => _363.indentVariants]), () => ( [])),
|
|
25456
|
+
_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _364 => _364.fontFaces]), () => ( []))
|
|
25364
25457
|
));
|
|
25365
25458
|
zip.file("Contents/section0.xml", sectionXml);
|
|
25366
25459
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
@@ -25411,7 +25504,7 @@ function alignBlocks(a, b) {
|
|
|
25411
25504
|
const m = a.length, n = b.length;
|
|
25412
25505
|
if (m * n > 1e7) return fallbackAlign(a, b);
|
|
25413
25506
|
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',
|
|
25507
|
+
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _365 => _365.text]), () => ( ""))).join(" ") : "";
|
|
25415
25508
|
return t.replace(/\s+/g, " ").trim().length;
|
|
25416
25509
|
};
|
|
25417
25510
|
const aLen = a.map(lenOf);
|
|
@@ -25484,8 +25577,8 @@ function blockSimilarity(a, b) {
|
|
|
25484
25577
|
}
|
|
25485
25578
|
function tableSimilarity(a, b) {
|
|
25486
25579
|
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',
|
|
25580
|
+
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _366 => _366.text]), () => ( ""))).join(" ");
|
|
25581
|
+
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _367 => _367.text]), () => ( ""))).join(" ");
|
|
25489
25582
|
const contentSim = normalizedSimilarity(textsA, textsB);
|
|
25490
25583
|
return dimSim * 0.3 + contentSim * 0.7;
|
|
25491
25584
|
}
|
|
@@ -25496,8 +25589,8 @@ function diffTableCells(a, b) {
|
|
|
25496
25589
|
for (let r = 0; r < maxRows; r++) {
|
|
25497
25590
|
const row = [];
|
|
25498
25591
|
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',
|
|
25592
|
+
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access', _368 => _368.cells, 'access', _369 => _369[r], 'optionalAccess', _370 => _370[c], 'optionalAccess', _371 => _371.text]) : void 0;
|
|
25593
|
+
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access', _372 => _372.cells, 'access', _373 => _373[r], 'optionalAccess', _374 => _374[c], 'optionalAccess', _375 => _375.text]) : void 0;
|
|
25501
25594
|
let type;
|
|
25502
25595
|
if (cellA === void 0) type = "added";
|
|
25503
25596
|
else if (cellB === void 0) type = "removed";
|
|
@@ -25663,7 +25756,7 @@ function parseRenderStyles(headXml) {
|
|
|
25663
25756
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
25664
25757
|
const textColor = el.getAttribute("textColor");
|
|
25665
25758
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
25666
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
25759
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _376 => _376.getAttribute, 'call', _377 => _377("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _378 => _378.getAttribute, 'call', _379 => _379("latin")])));
|
|
25667
25760
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
25668
25761
|
styles.charPr.set(id, {
|
|
25669
25762
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -25671,8 +25764,8 @@ function parseRenderStyles(headXml) {
|
|
|
25671
25764
|
italic: findChildByLocalName(el, "italic") != null,
|
|
25672
25765
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
25673
25766
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
25674
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
25675
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
25767
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _380 => _380.getAttribute, 'call', _381 => _381("hangul")])) || 100,
|
|
25768
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _382 => _382.getAttribute, 'call', _383 => _383("hangul")])) || 0,
|
|
25676
25769
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
25677
25770
|
face
|
|
25678
25771
|
});
|
|
@@ -25681,7 +25774,7 @@ function parseRenderStyles(headXml) {
|
|
|
25681
25774
|
const id = el.getAttribute("id");
|
|
25682
25775
|
if (id != null) {
|
|
25683
25776
|
const align = findChildByLocalName(el, "align");
|
|
25684
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
25777
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _384 => _384.getAttribute, 'call', _385 => _385("horizontal")]) || "JUSTIFY");
|
|
25685
25778
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
25686
25779
|
}
|
|
25687
25780
|
} else if (tag === "borderFill") {
|
|
@@ -25695,7 +25788,7 @@ function parseRenderStyles(headXml) {
|
|
|
25695
25788
|
};
|
|
25696
25789
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
25697
25790
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
25698
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
25791
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _386 => _386.getAttribute, 'call', _387 => _387("faceColor")]);
|
|
25699
25792
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
25700
25793
|
styles.borderFill.set(id, bf);
|
|
25701
25794
|
}
|
|
@@ -25767,7 +25860,7 @@ function collectSites(scan) {
|
|
|
25767
25860
|
}
|
|
25768
25861
|
function attrOf(openTag, name) {
|
|
25769
25862
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
25770
|
-
return _optionalChain([m, 'optionalAccess',
|
|
25863
|
+
return _optionalChain([m, 'optionalAccess', _388 => _388[1]]);
|
|
25771
25864
|
}
|
|
25772
25865
|
function paraOpenTag(xml, para2) {
|
|
25773
25866
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -25782,7 +25875,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
25782
25875
|
if (!tr) return null;
|
|
25783
25876
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
25784
25877
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
25785
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
25878
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _389 => _389[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
25786
25879
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
25787
25880
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
25788
25881
|
if (close === -1) return null;
|
|
@@ -25809,7 +25902,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
25809
25902
|
if (width === null) return null;
|
|
25810
25903
|
let content = width;
|
|
25811
25904
|
const win = cellAddrWindow(xml, cell2);
|
|
25812
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
25905
|
+
const mg = _optionalChain([win, 'optionalAccess', _390 => _390.match, 'call', _391 => _391(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
25813
25906
|
if (mg) {
|
|
25814
25907
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
25815
25908
|
}
|
|
@@ -25843,11 +25936,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25843
25936
|
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
25937
|
}
|
|
25845
25938
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25846
|
-
if (ops.length === 0) throw new (0,
|
|
25939
|
+
if (ops.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25847
25940
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25848
25941
|
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,
|
|
25942
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _392 => _392.match, 'call', _393 => _393(/(\d+)\.xml$/i), 'optionalAccess', _394 => _394[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _395 => _395.match, 'call', _396 => _396(/(\d+)\.xml$/i), 'optionalAccess', _397 => _397[1]]), () => ( 0))));
|
|
25943
|
+
if (sectionPaths.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25851
25944
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25852
25945
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25853
25946
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25888,11 +25981,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25888
25981
|
const manifestItems = [];
|
|
25889
25982
|
const placed = [];
|
|
25890
25983
|
for (const op of ops) {
|
|
25891
|
-
if (!op.anchor) throw new (0,
|
|
25892
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25984
|
+
if (!op.anchor) throw new (0, _chunkCWP56BRCcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25985
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25893
25986
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25894
|
-
if (!MIME[ext]) throw new (0,
|
|
25895
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25987
|
+
if (!MIME[ext]) throw new (0, _chunkCWP56BRCcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25988
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkCWP56BRCcjs.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
25989
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25897
25990
|
let found = null;
|
|
25898
25991
|
let total = 0;
|
|
@@ -25925,7 +26018,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25925
26018
|
}
|
|
25926
26019
|
}
|
|
25927
26020
|
}
|
|
25928
|
-
throw new (0,
|
|
26021
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
25929
26022
|
`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
26023
|
);
|
|
25931
26024
|
}
|
|
@@ -25933,9 +26026,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25933
26026
|
const xml = sectionXmls[si];
|
|
25934
26027
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25935
26028
|
if (!run) {
|
|
25936
|
-
throw new (0,
|
|
26029
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
25937
26030
|
}
|
|
25938
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
26031
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _398 => _398.charPr, 'access', _399 => _399.get, 'call', _400 => _400(run.charPr), 'optionalAccess', _401 => _401.height]), () => ( 1e3));
|
|
25939
26032
|
const fontPt = charPrHeight / 100;
|
|
25940
26033
|
const emMm = fontPt * 25.4 / 72;
|
|
25941
26034
|
const lineHMm = emMm;
|
|
@@ -25944,7 +26037,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25944
26037
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
25945
26038
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
25946
26039
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
25947
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
26040
|
+
const align = _optionalChain([styles, 'optionalAccess', _402 => _402.paraAlign, 'access', _403 => _403.get, 'call', _404 => _404(paraPrId)]);
|
|
25948
26041
|
let alignShiftMm = 0;
|
|
25949
26042
|
if (align === "CENTER" || align === "RIGHT") {
|
|
25950
26043
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -26040,7 +26133,7 @@ function parseBorderFills(headerDoc) {
|
|
|
26040
26133
|
};
|
|
26041
26134
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
26042
26135
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26043
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26136
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _405 => _405.getAttribute, 'call', _406 => _406("faceColor")]);
|
|
26044
26137
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
26045
26138
|
map.set(id, def);
|
|
26046
26139
|
}
|
|
@@ -26072,7 +26165,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
26072
26165
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
26073
26166
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
26074
26167
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
26075
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
26168
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _407 => _407.getAttribute, 'call', _408 => _408("hangul")]);
|
|
26076
26169
|
if (hangul) {
|
|
26077
26170
|
def.fontRef_hangul = hangul;
|
|
26078
26171
|
const face = hangulFonts.get(hangul);
|
|
@@ -26100,7 +26193,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26100
26193
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
26101
26194
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
26102
26195
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
26103
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
26196
|
+
const width = _optionalChain([sz, 'optionalAccess', _409 => _409.getAttribute, 'call', _410 => _410("width")]) || void 0;
|
|
26104
26197
|
const cells = [];
|
|
26105
26198
|
const usedBf = /* @__PURE__ */ new Set();
|
|
26106
26199
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -26113,17 +26206,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26113
26206
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
26114
26207
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
26115
26208
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
26116
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26117
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26209
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _411 => _411.getAttribute, 'call', _412 => _412("rowAddr")])), () => ( 0));
|
|
26210
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _413 => _413.getAttribute, 'call', _414 => _414("colAddr")])), () => ( 0));
|
|
26118
26211
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
26119
26212
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
26120
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26121
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26213
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _415 => _415.getAttribute, 'call', _416 => _416("colSpan")])), () => ( 1));
|
|
26214
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _417 => _417.getAttribute, 'call', _418 => _418("rowSpan")])), () => ( 1));
|
|
26122
26215
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
26123
26216
|
const cpId = firstRunCharPr(tc2);
|
|
26124
26217
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
26125
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
26126
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
26218
|
+
const w = _optionalChain([csz, 'optionalAccess', _419 => _419.getAttribute, 'call', _420 => _420("width")]);
|
|
26219
|
+
const hh = _optionalChain([csz, 'optionalAccess', _421 => _421.getAttribute, 'call', _422 => _422("height")]);
|
|
26127
26220
|
if (w) cell2.width_hwpunit = w;
|
|
26128
26221
|
if (hh) cell2.height_hwpunit = hh;
|
|
26129
26222
|
if (bfId) {
|
|
@@ -26211,16 +26304,16 @@ function pick(map, keys) {
|
|
|
26211
26304
|
return out;
|
|
26212
26305
|
}
|
|
26213
26306
|
async function hwpxToProfile(input) {
|
|
26214
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26307
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkCWP56BRCcjs.toArrayBuffer.call(void 0, input);
|
|
26215
26308
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26216
26309
|
const parser = createXmlParser();
|
|
26217
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
26310
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _423 => _423.file, 'call', _424 => _424(/[Hh]eader\.xml$/), 'optionalAccess', _425 => _425[0]])));
|
|
26218
26311
|
let headerXml = "<root/>";
|
|
26219
26312
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
26220
26313
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
26221
26314
|
const borderFills = parseBorderFills(headerDoc);
|
|
26222
26315
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
26223
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
26316
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _426 => _426.name, 'access', _427 => _427.match, 'call', _428 => _428(/(\d+)\.xml$/), 'optionalAccess', _429 => _429[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _430 => _430.name, 'access', _431 => _431.match, 'call', _432 => _432(/(\d+)\.xml$/), 'optionalAccess', _433 => _433[1]]), () => ( null))), () => ( 0))));
|
|
26224
26317
|
const tables = [];
|
|
26225
26318
|
let tableIndex = 0;
|
|
26226
26319
|
for (const f of sectionFiles) {
|
|
@@ -26534,7 +26627,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
26534
26627
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
26535
26628
|
function patchTableRows(input) {
|
|
26536
26629
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
26537
|
-
const xml = _optionalChain([ctx, 'access',
|
|
26630
|
+
const xml = _optionalChain([ctx, 'access', _434 => _434.scans, 'access', _435 => _435[scanTable.sectionIndex], 'optionalAccess', _436 => _436.xml]);
|
|
26538
26631
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
26539
26632
|
const numRows = table2.rows;
|
|
26540
26633
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -26701,7 +26794,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
26701
26794
|
const rr = scanTable.rowRanges[template];
|
|
26702
26795
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
26703
26796
|
const scan = scanSectionXml(wrapped, 0);
|
|
26704
|
-
const row = _optionalChain([scan, 'access',
|
|
26797
|
+
const row = _optionalChain([scan, 'access', _437 => _437.tables, 'access', _438 => _438[0], 'optionalAccess', _439 => _439.rows, 'access', _440 => _440[0]]);
|
|
26705
26798
|
if (!row || row.length !== cells.length) return null;
|
|
26706
26799
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
26707
26800
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -26744,7 +26837,7 @@ function rowHeightOf(fragment) {
|
|
|
26744
26837
|
}
|
|
26745
26838
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
26746
26839
|
const from = scanTable.start + tblOpenLen;
|
|
26747
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
26840
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _441 => _441.rowRanges, 'access', _442 => _442[0], 'optionalAccess', _443 => _443.start]), () => ( from));
|
|
26748
26841
|
const slice = xml.slice(from, to);
|
|
26749
26842
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
26750
26843
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -26933,9 +27026,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
26933
27026
|
});
|
|
26934
27027
|
}
|
|
26935
27028
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
26936
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27029
|
+
const irCell = _optionalChain([table2, 'access', _444 => _444.cells, 'access', _445 => _445[oc.gridR], 'optionalAccess', _446 => _446[oc.gridC]]);
|
|
26937
27030
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
26938
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
27031
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _447 => _447.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
26939
27032
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
26940
27033
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
26941
27034
|
}
|
|
@@ -27003,7 +27096,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27003
27096
|
};
|
|
27004
27097
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
27005
27098
|
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',
|
|
27099
|
+
const irCell = _optionalChain([table2, 'access', _448 => _448.cells, 'access', _449 => _449[gridR], 'optionalAccess', _450 => _450[gridC]]);
|
|
27007
27100
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
27008
27101
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27009
27102
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27026,7 +27119,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27026
27119
|
if (newLines.length === 0) return 0;
|
|
27027
27120
|
const target = cell2.paragraphs[0];
|
|
27028
27121
|
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',
|
|
27122
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _451 => _451.scans, 'access', _452 => _452[target.sectionIndex], 'optionalAccess', _453 => _453.xml]));
|
|
27030
27123
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27031
27124
|
splices.push(...sp);
|
|
27032
27125
|
sectionIndex = target.sectionIndex;
|
|
@@ -27049,7 +27142,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27049
27142
|
}
|
|
27050
27143
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
27051
27144
|
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',
|
|
27145
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _454 => _454.scans, 'access', _455 => _455[nonEmpty[i].sectionIndex], 'optionalAccess', _456 => _456.xml]));
|
|
27053
27146
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27054
27147
|
splices.push(...sp);
|
|
27055
27148
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -27130,7 +27223,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27130
27223
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27131
27224
|
if (paths.length > 0) return paths;
|
|
27132
27225
|
}
|
|
27133
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27226
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkCWP56BRCcjs.compareSectionPaths);
|
|
27134
27227
|
}
|
|
27135
27228
|
function sectionPathsFromManifest(xml) {
|
|
27136
27229
|
const attr = (tag, name) => {
|
|
@@ -27140,7 +27233,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27140
27233
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27141
27234
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27142
27235
|
const id = attr(m[1], "id");
|
|
27143
|
-
const href =
|
|
27236
|
+
const href = _chunkCWP56BRCcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27144
27237
|
if (id && href) idToHref.set(id, href);
|
|
27145
27238
|
}
|
|
27146
27239
|
const ordered = [];
|
|
@@ -27149,7 +27242,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27149
27242
|
if (href) ordered.push(href);
|
|
27150
27243
|
}
|
|
27151
27244
|
if (ordered.length > 0) return ordered;
|
|
27152
|
-
return Array.from(idToHref.values()).sort(
|
|
27245
|
+
return Array.from(idToHref.values()).sort(_chunkCWP56BRCcjs.compareSectionPaths);
|
|
27153
27246
|
}
|
|
27154
27247
|
|
|
27155
27248
|
// src/roundtrip/patcher.ts
|
|
@@ -27241,7 +27334,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
27241
27334
|
}
|
|
27242
27335
|
}
|
|
27243
27336
|
let verification;
|
|
27244
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27337
|
+
if (_optionalChain([options, 'optionalAccess', _457 => _457.verify]) !== false) {
|
|
27245
27338
|
try {
|
|
27246
27339
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
27247
27340
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -27259,17 +27352,17 @@ function buildOrigUnits(blocks) {
|
|
|
27259
27352
|
let chunk;
|
|
27260
27353
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27261
27354
|
const next = blocks[i + 1];
|
|
27262
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
27263
|
-
chunk =
|
|
27355
|
+
if (_optionalChain([next, 'optionalAccess', _458 => _458.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27356
|
+
chunk = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27264
27357
|
} else {
|
|
27265
|
-
chunk =
|
|
27358
|
+
chunk = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27266
27359
|
}
|
|
27267
27360
|
if (chunk) {
|
|
27268
27361
|
const subUnits = splitMarkdownUnits(chunk);
|
|
27269
27362
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
27270
27363
|
for (let s = 0; s < subUnits.length; s++) {
|
|
27271
27364
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
27272
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
27365
|
+
if (block.type === "table" && _optionalChain([block, 'access', _459 => _459.table, 'optionalAccess', _460 => _460.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
27273
27366
|
u.role = "caption";
|
|
27274
27367
|
}
|
|
27275
27368
|
units.push(u);
|
|
@@ -27380,7 +27473,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27380
27473
|
const ti = ctx.tableInsert;
|
|
27381
27474
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
27382
27475
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27383
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27476
|
+
if (!_optionalChain([mapping, 'optionalAccess', _461 => _461.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
27477
|
const para2 = mapping.para;
|
|
27385
27478
|
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
27479
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -27408,7 +27501,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27408
27501
|
}
|
|
27409
27502
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
27410
27503
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27411
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27504
|
+
if (!_optionalChain([mapping, 'optionalAccess', _462 => _462.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
27505
|
if (block.text && block.text.includes("\n")) {
|
|
27413
27506
|
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
27507
|
}
|
|
@@ -27439,7 +27532,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
27439
27532
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27440
27533
|
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
27534
|
}
|
|
27442
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
27535
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _463 => _463.scans, 'access', _464 => _464[mapping.para.sectionIndex], 'optionalAccess', _465 => _465.xml]));
|
|
27443
27536
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27444
27537
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27445
27538
|
return 1;
|
|
@@ -27628,7 +27721,7 @@ var Surgeon = (_class7 = class {
|
|
|
27628
27721
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
27629
27722
|
findEntry(path) {
|
|
27630
27723
|
const parts = path.replace(/^\//, "").split("/");
|
|
27631
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
27724
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _466 => _466.entries, 'access', _467 => _467[0], 'optionalAccess', _468 => _468.child]), () => ( -1));
|
|
27632
27725
|
let current;
|
|
27633
27726
|
for (const part of parts) {
|
|
27634
27727
|
const search = (idx) => {
|
|
@@ -27867,8 +27960,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
27867
27960
|
parts.push(header, data);
|
|
27868
27961
|
};
|
|
27869
27962
|
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',
|
|
27963
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _469 => _469.get, 'call', _470 => _470(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
27964
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _471 => _471.get, 'call', _472 => _472(i)]), () => ( recs[i].data)));
|
|
27872
27965
|
}
|
|
27873
27966
|
return Buffer.concat(parts);
|
|
27874
27967
|
}
|
|
@@ -27986,7 +28079,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27986
28079
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
27987
28080
|
}
|
|
27988
28081
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
27989
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
28082
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _473 => _473.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
27990
28083
|
let flags;
|
|
27991
28084
|
try {
|
|
27992
28085
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -28008,7 +28101,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28008
28101
|
const scans = [];
|
|
28009
28102
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
28010
28103
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
28011
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
28104
|
+
if (!_optionalChain([entry, 'optionalAccess', _474 => _474.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
28012
28105
|
let stream;
|
|
28013
28106
|
try {
|
|
28014
28107
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -28059,7 +28152,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28059
28152
|
}
|
|
28060
28153
|
}
|
|
28061
28154
|
let verification;
|
|
28062
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28155
|
+
if (_optionalChain([options, 'optionalAccess', _475 => _475.verify]) !== false) {
|
|
28063
28156
|
try {
|
|
28064
28157
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
28065
28158
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -28149,7 +28242,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
28149
28242
|
for (const [key, scanCell] of scanTable.cells) {
|
|
28150
28243
|
const comma = key.indexOf(",");
|
|
28151
28244
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
28152
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
28245
|
+
const irCell = _optionalChain([irTable, 'access', _476 => _476.cells, 'access', _477 => _477[r], 'optionalAccess', _478 => _478[c]]);
|
|
28153
28246
|
if (!irCell) continue;
|
|
28154
28247
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
28155
28248
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -28185,7 +28278,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
28185
28278
|
}
|
|
28186
28279
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
28187
28280
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28188
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28281
|
+
if (!_optionalChain([mapping, 'optionalAccess', _479 => _479.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
28282
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
28190
28283
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
28191
28284
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -28384,7 +28477,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
28384
28477
|
};
|
|
28385
28478
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
28386
28479
|
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',
|
|
28480
|
+
const irCell = _optionalChain([table2, 'access', _480 => _480.cells, 'access', _481 => _481[gridR], 'optionalAccess', _482 => _482[gridC]]);
|
|
28388
28481
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
28389
28482
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
28390
28483
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -28791,11 +28884,11 @@ var RULES2 = {
|
|
|
28791
28884
|
}
|
|
28792
28885
|
};
|
|
28793
28886
|
function redactText(text, options) {
|
|
28794
|
-
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28887
|
+
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _483 => _483.maskChar]), () => ( "\u25CF"));
|
|
28795
28888
|
if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
|
|
28796
28889
|
throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
|
|
28797
28890
|
}
|
|
28798
|
-
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28891
|
+
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _484 => _484.rules]), () => ( DEFAULT_REDACT_RULES));
|
|
28799
28892
|
const hits = [];
|
|
28800
28893
|
if (text === "" || enabled.length === 0) return { text, hits };
|
|
28801
28894
|
const occupied = [];
|
|
@@ -28850,8 +28943,8 @@ function sameBreadcrumb(a, b) {
|
|
|
28850
28943
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
28851
28944
|
}
|
|
28852
28945
|
function blocksToChunks(blocks, options) {
|
|
28853
|
-
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28854
|
-
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28946
|
+
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _485 => _485.granularity]), () => ( "section"));
|
|
28947
|
+
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _486 => _486.includeTableCells]), () => ( false));
|
|
28855
28948
|
const chunks = [];
|
|
28856
28949
|
const headingStack = [];
|
|
28857
28950
|
const listStack = [];
|
|
@@ -28865,12 +28958,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28865
28958
|
let run = null;
|
|
28866
28959
|
const flushRun = () => {
|
|
28867
28960
|
if (!run) return;
|
|
28868
|
-
push("text", run.breadcrumb,
|
|
28961
|
+
push("text", run.breadcrumb, _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28869
28962
|
run = null;
|
|
28870
28963
|
};
|
|
28871
28964
|
for (let i = 0; i < blocks.length; i++) {
|
|
28872
28965
|
const block = blocks[i];
|
|
28873
|
-
const md2 =
|
|
28966
|
+
const md2 = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28874
28967
|
if (!md2) continue;
|
|
28875
28968
|
if (block.type === "heading") {
|
|
28876
28969
|
flushRun();
|
|
@@ -28986,7 +29079,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28986
29079
|
const block = st.blocks[blockIndex];
|
|
28987
29080
|
if (!block) return void 0;
|
|
28988
29081
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
28989
|
-
const para2 = _optionalChain([st, 'access',
|
|
29082
|
+
const para2 = _optionalChain([st, 'access', _487 => _487.paraMap, 'access', _488 => _488.get, 'call', _489 => _489(blockIndex), 'optionalAccess', _490 => _490.para]);
|
|
28990
29083
|
if (!para2) return void 0;
|
|
28991
29084
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
28992
29085
|
}
|
|
@@ -29011,7 +29104,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29011
29104
|
if (block.text && block.text.includes("\n")) {
|
|
29012
29105
|
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
29106
|
}
|
|
29014
|
-
if (!_optionalChain([st, 'access',
|
|
29107
|
+
if (!_optionalChain([st, 'access', _491 => _491.paraMap, 'access', _492 => _492.get, 'call', _493 => _493(blockIndex), 'optionalAccess', _494 => _494.para])) {
|
|
29015
29108
|
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
29109
|
}
|
|
29017
29110
|
return { capability: "text" };
|
|
@@ -29077,7 +29170,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29077
29170
|
continue;
|
|
29078
29171
|
}
|
|
29079
29172
|
if (block.type === "table" && block.table) {
|
|
29080
|
-
if (!_optionalChain([edit, 'access',
|
|
29173
|
+
if (!_optionalChain([edit, 'access', _495 => _495.cells, 'optionalAccess', _496 => _496.length])) {
|
|
29081
29174
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
29082
29175
|
continue;
|
|
29083
29176
|
}
|
|
@@ -29097,7 +29190,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29097
29190
|
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
29191
|
continue;
|
|
29099
29192
|
}
|
|
29100
|
-
const irCell = _optionalChain([block, 'access',
|
|
29193
|
+
const irCell = _optionalChain([block, 'access', _497 => _497.table, 'access', _498 => _498.cells, 'access', _499 => _499[cellEdit.row], 'optionalAccess', _500 => _500[cellEdit.col]]);
|
|
29101
29194
|
if (!irCell) {
|
|
29102
29195
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
29103
29196
|
continue;
|
|
@@ -29153,7 +29246,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29153
29246
|
}
|
|
29154
29247
|
if (replacements.size === 0) {
|
|
29155
29248
|
let changes2;
|
|
29156
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29249
|
+
if (_optionalChain([options, 'optionalAccess', _501 => _501.verify]) !== false) {
|
|
29157
29250
|
const units = splitMarkdownUnits(st.markdown);
|
|
29158
29251
|
changes2 = diffUnitLists(units, units);
|
|
29159
29252
|
}
|
|
@@ -29174,7 +29267,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29174
29267
|
}
|
|
29175
29268
|
this.state = newState;
|
|
29176
29269
|
let changes;
|
|
29177
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29270
|
+
if (_optionalChain([options, 'optionalAccess', _502 => _502.verify]) !== false) {
|
|
29178
29271
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
29179
29272
|
}
|
|
29180
29273
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -29194,7 +29287,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29194
29287
|
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
29288
|
}
|
|
29196
29289
|
const mapping = st.paraMap.get(blockIndex);
|
|
29197
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
29290
|
+
if (!_optionalChain([mapping, 'optionalAccess', _503 => _503.para])) {
|
|
29198
29291
|
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
29292
|
}
|
|
29200
29293
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -29214,14 +29307,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29214
29307
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
29215
29308
|
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
29309
|
}
|
|
29217
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
29310
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _504 => _504.scans, 'access', _505 => _505[mapping.para.sectionIndex], 'optionalAccess', _506 => _506.xml]));
|
|
29218
29311
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
29219
29312
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
29220
29313
|
return 1;
|
|
29221
29314
|
}
|
|
29222
29315
|
}, _class8);
|
|
29223
29316
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
29224
|
-
const irCell = _optionalChain([table2, 'access',
|
|
29317
|
+
const irCell = _optionalChain([table2, 'access', _507 => _507.cells, 'access', _508 => _508[r], 'optionalAccess', _509 => _509[c]]);
|
|
29225
29318
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
29226
29319
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
29227
29320
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -29305,11 +29398,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
29305
29398
|
breaks: false
|
|
29306
29399
|
});
|
|
29307
29400
|
function renderHtml(markdown, options) {
|
|
29308
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29309
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29401
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _510 => _510.preset]), () => ( "default"));
|
|
29402
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _511 => _511.extraCss]), () => ( "")));
|
|
29310
29403
|
const body = md.render(markdown);
|
|
29311
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
29312
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
29404
|
+
const watermark = _optionalChain([options, 'optionalAccess', _512 => _512.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
29405
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _513 => _513.watermark]) ? `
|
|
29313
29406
|
.watermark {
|
|
29314
29407
|
position: fixed;
|
|
29315
29408
|
top: 50%; left: 50%;
|
|
@@ -29340,13 +29433,13 @@ async function htmlToPdf(html, options) {
|
|
|
29340
29433
|
try {
|
|
29341
29434
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29342
29435
|
} catch (e32) {
|
|
29343
|
-
throw new (0,
|
|
29436
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
29344
29437
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29345
29438
|
);
|
|
29346
29439
|
}
|
|
29347
29440
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29348
29441
|
if (!executablePath) {
|
|
29349
|
-
throw new (0,
|
|
29442
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)(
|
|
29350
29443
|
"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
29444
|
);
|
|
29352
29445
|
}
|
|
@@ -29358,10 +29451,10 @@ async function htmlToPdf(html, options) {
|
|
|
29358
29451
|
try {
|
|
29359
29452
|
const page = await browser.newPage();
|
|
29360
29453
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
29361
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
29454
|
+
const margin = _optionalChain([options, 'optionalAccess', _514 => _514.margin]);
|
|
29362
29455
|
const pdf = await page.pdf({
|
|
29363
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29364
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
29456
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _515 => _515.pageSize]), () => ( "A4")),
|
|
29457
|
+
landscape: _optionalChain([options, 'optionalAccess', _516 => _516.orientation]) === "landscape",
|
|
29365
29458
|
printBackground: true,
|
|
29366
29459
|
margin: margin ? {
|
|
29367
29460
|
top: toCss(margin.top),
|
|
@@ -29369,9 +29462,9 @@ async function htmlToPdf(html, options) {
|
|
|
29369
29462
|
bottom: toCss(margin.bottom),
|
|
29370
29463
|
left: toCss(margin.left)
|
|
29371
29464
|
} : void 0,
|
|
29372
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
29373
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29374
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29465
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _517 => _517.header]) || _optionalChain([options, 'optionalAccess', _518 => _518.footer])),
|
|
29466
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _519 => _519.header]), () => ( "<div></div>")),
|
|
29467
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _520 => _520.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
29375
29468
|
});
|
|
29376
29469
|
return Buffer.from(pdf);
|
|
29377
29470
|
} finally {
|
|
@@ -29405,7 +29498,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29405
29498
|
return htmlToPdf(html, options);
|
|
29406
29499
|
}
|
|
29407
29500
|
async function blocksToPdf(blocks, options) {
|
|
29408
|
-
const markdown =
|
|
29501
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29409
29502
|
return markdownToPdf(markdown, options);
|
|
29410
29503
|
}
|
|
29411
29504
|
|
|
@@ -29584,7 +29677,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
29584
29677
|
}
|
|
29585
29678
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
29586
29679
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
29587
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
29680
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _521 => _521.getAttribute, 'call', _522 => _522("vertRelTo")]), () => ( "PARA"));
|
|
29588
29681
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
29589
29682
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
29590
29683
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -29645,7 +29738,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29645
29738
|
if (ln(p) !== "p") continue;
|
|
29646
29739
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
29647
29740
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
29648
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29741
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _523 => _523.spaceBefore]), () => ( 0)));
|
|
29649
29742
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
29650
29743
|
if (!res) {
|
|
29651
29744
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -29658,7 +29751,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29658
29751
|
}
|
|
29659
29752
|
if (Number.isFinite(bottom)) {
|
|
29660
29753
|
cursorV = bottom;
|
|
29661
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
29754
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _524 => _524.spaceAfter]), () => ( 0));
|
|
29662
29755
|
}
|
|
29663
29756
|
}
|
|
29664
29757
|
continue;
|
|
@@ -29768,7 +29861,7 @@ function buildPara(p) {
|
|
|
29768
29861
|
el: ch,
|
|
29769
29862
|
tag: cn,
|
|
29770
29863
|
index: chars.length,
|
|
29771
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
29864
|
+
inline: _optionalChain([pos, 'optionalAccess', _525 => _525.getAttribute, 'call', _526 => _526("treatAsChar")]) === "1",
|
|
29772
29865
|
width: w,
|
|
29773
29866
|
height: h
|
|
29774
29867
|
});
|
|
@@ -30020,15 +30113,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30020
30113
|
const sx = ow > 0 ? w / ow : 1;
|
|
30021
30114
|
const sy = oh > 0 ? h / oh : 1;
|
|
30022
30115
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
30023
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
30024
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
30116
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _527 => _527.getAttribute, 'call', _528 => _528("style")]), () => ( "SOLID"));
|
|
30117
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _529 => _529.getAttribute, 'call', _530 => _530("color")]) || "#000000";
|
|
30025
30118
|
const hasStroke = lstyle !== "NONE";
|
|
30026
30119
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
30027
30120
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
30028
30121
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
30029
30122
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
30030
30123
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
30031
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
30124
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _531 => _531.getAttribute, 'call', _532 => _532("faceColor")]);
|
|
30032
30125
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
30033
30126
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
30034
30127
|
if (o.tag === "rect") {
|
|
@@ -30055,14 +30148,14 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30055
30148
|
}
|
|
30056
30149
|
function cellContentExtent(cell2, memo) {
|
|
30057
30150
|
if (!cell2.sub) return 0;
|
|
30058
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30151
|
+
const hit = _optionalChain([memo, 'optionalAccess', _533 => _533.cell, 'access', _534 => _534.get, 'call', _535 => _535(cell2.el)]);
|
|
30059
30152
|
if (hit !== void 0) return hit;
|
|
30060
30153
|
let ext = 0;
|
|
30061
30154
|
for (const p of elements2(cell2.sub)) {
|
|
30062
30155
|
if (ln2(p) !== "p") continue;
|
|
30063
30156
|
const m = buildPara(p);
|
|
30064
30157
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
30065
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
30158
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _536 => _536.segs, 'access', _537 => _537[0], 'optionalAccess', _538 => _538.vertpos]), () => ( 0));
|
|
30066
30159
|
for (const o of m.objs) {
|
|
30067
30160
|
if (o.inline) {
|
|
30068
30161
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
@@ -30070,14 +30163,14 @@ function cellContentExtent(cell2, memo) {
|
|
|
30070
30163
|
continue;
|
|
30071
30164
|
}
|
|
30072
30165
|
const pos = findChildByLocalName(o.el, "pos");
|
|
30073
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30166
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _539 => _539.getAttribute, 'call', _540 => _540("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
30074
30167
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
30075
30168
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
30076
30169
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
30077
30170
|
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
30078
30171
|
}
|
|
30079
30172
|
}
|
|
30080
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30173
|
+
_optionalChain([memo, 'optionalAccess', _541 => _541.cell, 'access', _542 => _542.set, 'call', _543 => _543(cell2.el, ext)]);
|
|
30081
30174
|
return ext;
|
|
30082
30175
|
}
|
|
30083
30176
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
@@ -30119,7 +30212,7 @@ function collectCells(tbl2) {
|
|
|
30119
30212
|
return cells;
|
|
30120
30213
|
}
|
|
30121
30214
|
function measureTableHeight(tbl2, memo) {
|
|
30122
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30215
|
+
const hit = _optionalChain([memo, 'optionalAccess', _544 => _544.table, 'access', _545 => _545.get, 'call', _546 => _546(tbl2)]);
|
|
30123
30216
|
if (hit !== void 0) return hit;
|
|
30124
30217
|
const cells = collectCells(tbl2);
|
|
30125
30218
|
if (cells.length === 0 || cells.length > 4096) return 0;
|
|
@@ -30130,7 +30223,7 @@ function measureTableHeight(tbl2, memo) {
|
|
|
30130
30223
|
);
|
|
30131
30224
|
let sum = 0;
|
|
30132
30225
|
for (const h of rowH) sum += h;
|
|
30133
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30226
|
+
_optionalChain([memo, 'optionalAccess', _547 => _547.table, 'access', _548 => _548.set, 'call', _549 => _549(tbl2, sum)]);
|
|
30134
30227
|
return sum;
|
|
30135
30228
|
}
|
|
30136
30229
|
function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
@@ -30161,7 +30254,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
30161
30254
|
}));
|
|
30162
30255
|
for (const g of geom) {
|
|
30163
30256
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
30164
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
30257
|
+
if (_optionalChain([bf, 'optionalAccess', _550 => _550.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
30258
|
}
|
|
30166
30259
|
for (const g of geom) {
|
|
30167
30260
|
const { c } = g;
|
|
@@ -30199,7 +30292,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
30199
30292
|
const sz = findChildByLocalName(pic, "sz");
|
|
30200
30293
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
30201
30294
|
const img = findFirst(pic, "img");
|
|
30202
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
30295
|
+
const ref = _optionalChain([img, 'optionalAccess', _551 => _551.getAttribute, 'call', _552 => _552("binaryItemIDRef")]);
|
|
30203
30296
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
30204
30297
|
if (!loaded) {
|
|
30205
30298
|
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 +30332,7 @@ function readSectionGeom(root) {
|
|
|
30239
30332
|
const pagePr = findFirst(root, "pagePr");
|
|
30240
30333
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
30241
30334
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
30242
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
30335
|
+
if (_optionalChain([pagePr, 'optionalAccess', _553 => _553.getAttribute, 'call', _554 => _554("landscape")]) === "NARROWLY" && PW < PH) {
|
|
30243
30336
|
const t = PW;
|
|
30244
30337
|
PW = PH;
|
|
30245
30338
|
PH = t;
|
|
@@ -30297,17 +30390,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30297
30390
|
return { pages: ctx.pages, pageH };
|
|
30298
30391
|
}
|
|
30299
30392
|
async function renderHwpxToSvg(input, options) {
|
|
30300
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30393
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30301
30394
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30302
|
-
|
|
30395
|
+
_chunkCWP56BRCcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30303
30396
|
let zip;
|
|
30304
30397
|
try {
|
|
30305
30398
|
zip = await _jszip2.default.loadAsync(input);
|
|
30306
30399
|
} catch (e33) {
|
|
30307
|
-
throw new (0,
|
|
30400
|
+
throw new (0, _chunkCWP56BRCcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30308
30401
|
}
|
|
30309
30402
|
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,
|
|
30403
|
+
if (secFiles.length === 0) throw new (0, _chunkCWP56BRCcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30311
30404
|
const warnings = [];
|
|
30312
30405
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30313
30406
|
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 +30408,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30315
30408
|
const secXmls = [];
|
|
30316
30409
|
for (const f of secFiles) {
|
|
30317
30410
|
const xml = await f.async("string");
|
|
30318
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30411
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkCWP56BRCcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30319
30412
|
secXmls.push(xml);
|
|
30320
30413
|
}
|
|
30321
30414
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30339,7 +30432,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30339
30432
|
let href = binmap.get(ref);
|
|
30340
30433
|
if (!href) {
|
|
30341
30434
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
30342
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
30435
|
+
href = _optionalChain([cand, 'optionalAccess', _556 => _556.name]);
|
|
30343
30436
|
}
|
|
30344
30437
|
if (!href) continue;
|
|
30345
30438
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -30360,7 +30453,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30360
30453
|
styles,
|
|
30361
30454
|
images,
|
|
30362
30455
|
defs: [],
|
|
30363
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30456
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _557 => _557.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
30364
30457
|
warnings,
|
|
30365
30458
|
warned: /* @__PURE__ */ new Set(),
|
|
30366
30459
|
stats: { texts: 0, images: 0, tables: 0 },
|
|
@@ -30371,7 +30464,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30371
30464
|
for (let si = 0; si < secXmls.length; si++) {
|
|
30372
30465
|
const secXml = secXmls[si];
|
|
30373
30466
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
30374
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
30467
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _558 => _558.reflow])) {
|
|
30375
30468
|
noCacheSkipped = true;
|
|
30376
30469
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
30377
30470
|
continue;
|
|
@@ -30383,14 +30476,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30383
30476
|
continue;
|
|
30384
30477
|
}
|
|
30385
30478
|
const geom = readSectionGeom(root);
|
|
30386
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess',
|
|
30479
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _559 => _559.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _560 => _560.reflowMode]), () => ( "keep")));
|
|
30387
30480
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
30388
30481
|
}
|
|
30389
30482
|
if (rendered.length === 0) {
|
|
30390
30483
|
if (noCacheSkipped) {
|
|
30391
|
-
throw new (0,
|
|
30484
|
+
throw new (0, _chunkCWP56BRCcjs.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
30485
|
}
|
|
30393
|
-
throw new (0,
|
|
30486
|
+
throw new (0, _chunkCWP56BRCcjs.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
30487
|
}
|
|
30395
30488
|
const GAP = 2400;
|
|
30396
30489
|
const clipDefs = [];
|
|
@@ -30422,17 +30515,17 @@ ${groups.join("\n")}
|
|
|
30422
30515
|
// src/index.ts
|
|
30423
30516
|
async function parse(input, options) {
|
|
30424
30517
|
let buffer;
|
|
30425
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
30518
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _561 => _561.filePath]) ? { ...options, filePath: input } : options;
|
|
30426
30519
|
if (typeof input === "string") {
|
|
30427
30520
|
try {
|
|
30428
30521
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30429
|
-
buffer =
|
|
30522
|
+
buffer = _chunkCWP56BRCcjs.toArrayBuffer.call(void 0, buf);
|
|
30430
30523
|
} catch (err) {
|
|
30431
30524
|
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
30525
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30433
30526
|
}
|
|
30434
30527
|
} else if (Buffer.isBuffer(input)) {
|
|
30435
|
-
buffer =
|
|
30528
|
+
buffer = _chunkCWP56BRCcjs.toArrayBuffer.call(void 0, input);
|
|
30436
30529
|
} else {
|
|
30437
30530
|
buffer = input;
|
|
30438
30531
|
}
|
|
@@ -30466,18 +30559,18 @@ async function parse(input, options) {
|
|
|
30466
30559
|
}
|
|
30467
30560
|
async function parseImage(buffer, options) {
|
|
30468
30561
|
try {
|
|
30469
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
30562
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-TCJLNMTG.cjs")));
|
|
30470
30563
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30471
30564
|
return {
|
|
30472
30565
|
success: true,
|
|
30473
30566
|
fileType: "image",
|
|
30474
|
-
markdown:
|
|
30567
|
+
markdown: _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30475
30568
|
blocks,
|
|
30476
30569
|
warnings: warnings.length ? warnings : void 0,
|
|
30477
30570
|
pageCount: 1
|
|
30478
30571
|
};
|
|
30479
30572
|
} catch (err) {
|
|
30480
|
-
return { success: false, fileType: "image", error:
|
|
30573
|
+
return { success: false, fileType: "image", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30481
30574
|
}
|
|
30482
30575
|
}
|
|
30483
30576
|
async function parseHwp3(buffer, options) {
|
|
@@ -30485,21 +30578,21 @@ async function parseHwp3(buffer, options) {
|
|
|
30485
30578
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30486
30579
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30487
30580
|
} catch (err) {
|
|
30488
|
-
return { success: false, fileType: "hwp3", error:
|
|
30581
|
+
return { success: false, fileType: "hwp3", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30489
30582
|
}
|
|
30490
30583
|
}
|
|
30491
30584
|
async function parseHwpx(buffer, options) {
|
|
30492
30585
|
try {
|
|
30493
30586
|
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',
|
|
30587
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _562 => _562.length]) ? images : void 0 };
|
|
30495
30588
|
} catch (err) {
|
|
30496
|
-
return { success: false, fileType: "hwpx", error:
|
|
30589
|
+
return { success: false, fileType: "hwpx", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30497
30590
|
}
|
|
30498
30591
|
}
|
|
30499
30592
|
async function parseHwp(buffer, options) {
|
|
30500
30593
|
try {
|
|
30501
30594
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
30502
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
30595
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _563 => _563.filePath])) {
|
|
30503
30596
|
try {
|
|
30504
30597
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
30505
30598
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -30516,15 +30609,15 @@ async function parseHwp(buffer, options) {
|
|
|
30516
30609
|
} catch (e34) {
|
|
30517
30610
|
}
|
|
30518
30611
|
}
|
|
30519
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
30612
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _564 => _564.length]) ? images : void 0 };
|
|
30520
30613
|
} catch (err) {
|
|
30521
|
-
return { success: false, fileType: "hwp", error:
|
|
30614
|
+
return { success: false, fileType: "hwp", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30522
30615
|
}
|
|
30523
30616
|
}
|
|
30524
30617
|
async function parsePdf(buffer, options) {
|
|
30525
30618
|
let parsePdfDocument;
|
|
30526
30619
|
try {
|
|
30527
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30620
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-VQIJPCI5.cjs")));
|
|
30528
30621
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30529
30622
|
} catch (e35) {
|
|
30530
30623
|
return {
|
|
@@ -30539,7 +30632,7 @@ async function parsePdf(buffer, options) {
|
|
|
30539
30632
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30540
30633
|
} catch (err) {
|
|
30541
30634
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30542
|
-
return { success: false, fileType: "pdf", error:
|
|
30635
|
+
return { success: false, fileType: "pdf", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err), isImageBased };
|
|
30543
30636
|
}
|
|
30544
30637
|
}
|
|
30545
30638
|
async function parseXlsx(buffer, options) {
|
|
@@ -30547,7 +30640,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30547
30640
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30548
30641
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30549
30642
|
} catch (err) {
|
|
30550
|
-
return { success: false, fileType: "xlsx", error:
|
|
30643
|
+
return { success: false, fileType: "xlsx", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30551
30644
|
}
|
|
30552
30645
|
}
|
|
30553
30646
|
async function parseXls(buffer, options) {
|
|
@@ -30555,15 +30648,15 @@ async function parseXls(buffer, options) {
|
|
|
30555
30648
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30556
30649
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30557
30650
|
} catch (err) {
|
|
30558
|
-
return { success: false, fileType: "xls", error:
|
|
30651
|
+
return { success: false, fileType: "xls", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30559
30652
|
}
|
|
30560
30653
|
}
|
|
30561
30654
|
async function parseDocx(buffer, options) {
|
|
30562
30655
|
try {
|
|
30563
30656
|
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',
|
|
30657
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _565 => _565.length]) ? images : void 0 };
|
|
30565
30658
|
} catch (err) {
|
|
30566
|
-
return { success: false, fileType: "docx", error:
|
|
30659
|
+
return { success: false, fileType: "docx", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30567
30660
|
}
|
|
30568
30661
|
}
|
|
30569
30662
|
async function parseHwpml(buffer, options) {
|
|
@@ -30571,16 +30664,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30571
30664
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30572
30665
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30573
30666
|
} catch (err) {
|
|
30574
|
-
return { success: false, fileType: "hwpml", error:
|
|
30667
|
+
return { success: false, fileType: "hwpml", error: _chunkCWP56BRCcjs.sanitizeError.call(void 0, err), code: _chunkCWP56BRCcjs.classifyError.call(void 0, err) };
|
|
30575
30668
|
}
|
|
30576
30669
|
}
|
|
30577
30670
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30578
30671
|
let buffer;
|
|
30579
30672
|
if (typeof input === "string") {
|
|
30580
30673
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30581
|
-
buffer =
|
|
30674
|
+
buffer = _chunkCWP56BRCcjs.toArrayBuffer.call(void 0, buf);
|
|
30582
30675
|
} else if (Buffer.isBuffer(input)) {
|
|
30583
|
-
buffer =
|
|
30676
|
+
buffer = _chunkCWP56BRCcjs.toArrayBuffer.call(void 0, input);
|
|
30584
30677
|
} else {
|
|
30585
30678
|
buffer = input;
|
|
30586
30679
|
}
|
|
@@ -30606,7 +30699,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30606
30699
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30607
30700
|
}
|
|
30608
30701
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30609
|
-
const markdown =
|
|
30702
|
+
const markdown = _chunk5AXGFJQOcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30610
30703
|
if (outputFormat === "hwpx") {
|
|
30611
30704
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30612
30705
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30680,5 +30773,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30680
30773
|
|
|
30681
30774
|
|
|
30682
30775
|
|
|
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 =
|
|
30776
|
+
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 = _chunkCWP56BRCcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunk5AXGFJQOcjs.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
30777
|
//# sourceMappingURL=index.cjs.map
|