kordoc 4.7.0 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-MK2223RL.js → -O42BMYNX.js} +9 -9
- package/dist/{chunk-GIWKBPII.js → chunk-3UIT4PPQ.js} +2 -2
- package/dist/{chunk-MVTX6ODZ.js → chunk-4VNUQYUE.js} +1 -1
- package/dist/chunk-4VNUQYUE.js.map +1 -0
- package/dist/{chunk-6PIR74EA.js → chunk-5KPNXBNR.js} +26 -14
- package/dist/chunk-5KPNXBNR.js.map +1 -0
- package/dist/{chunk-AEYNY6FG.js → chunk-6663UXPE.js} +2 -2
- package/dist/{chunk-AFPD74JJ.js → chunk-7ZIOZ6PU.js} +2 -2
- package/dist/{chunk-XZDJXYUC.js → chunk-AFX6ZXER.js} +2 -2
- package/dist/{chunk-PEVPKD6Z.js → chunk-BQENBAUC.js} +3 -3
- package/dist/{chunk-TUU535RB.cjs → chunk-DJKLOLBT.cjs} +2 -2
- package/dist/chunk-DJKLOLBT.cjs.map +1 -0
- package/dist/{chunk-BCG2PKQU.js → chunk-IMEMTJ76.js} +11 -5
- package/dist/chunk-IMEMTJ76.js.map +1 -0
- package/dist/{chunk-YUVKU5CW.js → chunk-IZEUWEEY.js} +2 -2
- package/dist/chunk-IZEUWEEY.js.map +1 -0
- package/dist/{chunk-ZYVULRYF.js → chunk-J3W6Q3AX.js} +2 -2
- package/dist/{chunk-PV2EXXGI.js → chunk-JEX5P66D.js} +3 -3
- package/dist/{chunk-P2NWNJMR.js → chunk-PLEGO474.js} +2 -2
- package/dist/{chunk-5QTHHQQE.cjs → chunk-TZ3WCAJZ.cjs} +3 -3
- package/dist/{chunk-5QTHHQQE.cjs.map → chunk-TZ3WCAJZ.cjs.map} +1 -1
- package/dist/{chunk-W5KRKBYR.cjs → chunk-USGC3ZKU.cjs} +13 -7
- package/dist/chunk-USGC3ZKU.cjs.map +1 -0
- package/dist/{chunk-YXXHH6WC.js → chunk-UZB3UGC5.js} +2 -2
- package/dist/{chunk-IDHBO6AG.js → chunk-VECVLIWE.js} +3 -3
- package/dist/{chunk-3VTMSSDW.js → chunk-YWDN5PQC.js} +11 -5
- package/dist/chunk-YWDN5PQC.js.map +1 -0
- package/dist/{chunk-C27PPXRZ.cjs → chunk-ZDWP3LLY.cjs} +10 -10
- package/dist/{chunk-C27PPXRZ.cjs.map → chunk-ZDWP3LLY.cjs.map} +1 -1
- package/dist/chunks-C7DJL4RE.js +10 -0
- package/dist/cli.js +17 -17
- package/dist/{image-ocr-4MHEX4MN.js → image-ocr-5QRZBNOF.js} +5 -5
- package/dist/{image-ocr-OB5PCQUU.cjs → image-ocr-MKD6MKWO.cjs} +10 -10
- package/dist/{image-ocr-OB5PCQUU.cjs.map → image-ocr-MKD6MKWO.cjs.map} +1 -1
- package/dist/{image-ocr-3A3HZX6O.js → image-ocr-TAJHRZ5T.js} +4 -4
- package/dist/index.cjs +479 -467
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +15 -15
- package/dist/{parser-EQN4YKU4.js → parser-RCEHB2EV.js} +49 -6
- package/dist/parser-RCEHB2EV.js.map +1 -0
- package/dist/{parser-VACM3DFR.cjs → parser-SWY4RKGD.cjs} +69 -26
- package/dist/parser-SWY4RKGD.cjs.map +1 -0
- package/dist/{parser-EIVCD4NS.js → parser-UMFBJG2D.js} +50 -7
- package/dist/parser-UMFBJG2D.js.map +1 -0
- package/dist/pdf-ocr-3NTV3MYP.js +12 -0
- package/dist/{pdf-ocr-NPYDUIC5.js → pdf-ocr-7BOO4JA7.js} +5 -5
- package/dist/pdf-ocr-JDHELYBY.cjs +13 -0
- package/dist/{pdf-ocr-OBPQ4F4D.cjs.map → pdf-ocr-JDHELYBY.cjs.map} +1 -1
- package/dist/{profile-io-L5EH4JAD.js → profile-io-HT62OAEU.js} +3 -3
- package/dist/{rasterize-7AR662AL.js → rasterize-GL67HQC7.js} +2 -2
- package/dist/render-IQ4IZLY4.js +10 -0
- package/dist/seal-AGSZ6MUR.js +10 -0
- package/dist/{watch-MONT6CGI.js → watch-5ST75Q7Q.js} +9 -9
- package/package.json +1 -1
- package/dist/chunk-3VTMSSDW.js.map +0 -1
- package/dist/chunk-6PIR74EA.js.map +0 -1
- package/dist/chunk-BCG2PKQU.js.map +0 -1
- package/dist/chunk-MVTX6ODZ.js.map +0 -1
- package/dist/chunk-TUU535RB.cjs.map +0 -1
- package/dist/chunk-W5KRKBYR.cjs.map +0 -1
- package/dist/chunk-YUVKU5CW.js.map +0 -1
- package/dist/chunks-4HEG6ZPG.js +0 -10
- package/dist/parser-EIVCD4NS.js.map +0 -1
- package/dist/parser-EQN4YKU4.js.map +0 -1
- package/dist/parser-VACM3DFR.cjs.map +0 -1
- package/dist/pdf-ocr-N62EWEX4.js +0 -12
- package/dist/pdf-ocr-OBPQ4F4D.cjs +0 -13
- package/dist/render-CAFQT7S4.js +0 -10
- package/dist/seal-ESAC3IZR.js +0 -10
- /package/dist/{-MK2223RL.js.map → -O42BMYNX.js.map} +0 -0
- /package/dist/{chunk-GIWKBPII.js.map → chunk-3UIT4PPQ.js.map} +0 -0
- /package/dist/{chunk-AEYNY6FG.js.map → chunk-6663UXPE.js.map} +0 -0
- /package/dist/{chunk-AFPD74JJ.js.map → chunk-7ZIOZ6PU.js.map} +0 -0
- /package/dist/{chunk-XZDJXYUC.js.map → chunk-AFX6ZXER.js.map} +0 -0
- /package/dist/{chunk-PEVPKD6Z.js.map → chunk-BQENBAUC.js.map} +0 -0
- /package/dist/{chunk-ZYVULRYF.js.map → chunk-J3W6Q3AX.js.map} +0 -0
- /package/dist/{chunk-PV2EXXGI.js.map → chunk-JEX5P66D.js.map} +0 -0
- /package/dist/{chunk-P2NWNJMR.js.map → chunk-PLEGO474.js.map} +0 -0
- /package/dist/{chunk-YXXHH6WC.js.map → chunk-UZB3UGC5.js.map} +0 -0
- /package/dist/{chunk-IDHBO6AG.js.map → chunk-VECVLIWE.js.map} +0 -0
- /package/dist/{chunks-4HEG6ZPG.js.map → chunks-C7DJL4RE.js.map} +0 -0
- /package/dist/{image-ocr-4MHEX4MN.js.map → image-ocr-5QRZBNOF.js.map} +0 -0
- /package/dist/{image-ocr-3A3HZX6O.js.map → image-ocr-TAJHRZ5T.js.map} +0 -0
- /package/dist/{pdf-ocr-N62EWEX4.js.map → pdf-ocr-3NTV3MYP.js.map} +0 -0
- /package/dist/{pdf-ocr-NPYDUIC5.js.map → pdf-ocr-7BOO4JA7.js.map} +0 -0
- /package/dist/{profile-io-L5EH4JAD.js.map → profile-io-HT62OAEU.js.map} +0 -0
- /package/dist/{rasterize-7AR662AL.js.map → rasterize-GL67HQC7.js.map} +0 -0
- /package/dist/{render-CAFQT7S4.js.map → render-IQ4IZLY4.js.map} +0 -0
- /package/dist/{seal-ESAC3IZR.js.map → seal-AGSZ6MUR.js.map} +0 -0
- /package/dist/{watch-MONT6CGI.js.map → watch-5ST75Q7Q.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkUSGC3ZKUcjs = require('./chunk-USGC3ZKU.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 _chunkDJKLOLBTcjs = require('./chunk-DJKLOLBT.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -482,7 +482,7 @@ function rawTextContent(node, depth = 0) {
|
|
|
482
482
|
// src/hwpx/parser-shared.ts
|
|
483
483
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
484
484
|
var MAX_ZIP_ENTRIES = 500;
|
|
485
|
-
var ZipBombError = class extends
|
|
485
|
+
var ZipBombError = class extends _chunkDJKLOLBTcjs.KordocError {
|
|
486
486
|
constructor(message) {
|
|
487
487
|
super(message);
|
|
488
488
|
this.name = "ZipBombError";
|
|
@@ -497,7 +497,7 @@ function createSectionShared() {
|
|
|
497
497
|
function createXmlParser(warnings) {
|
|
498
498
|
return new (0, _xmldom.DOMParser)({
|
|
499
499
|
onError(level, msg2) {
|
|
500
|
-
if (level === "fatalError") throw new (0,
|
|
500
|
+
if (level === "fatalError") throw new (0, _chunkDJKLOLBTcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
501
501
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
502
502
|
}
|
|
503
503
|
});
|
|
@@ -532,13 +532,13 @@ function parseEncryptionManifest(manifestXml) {
|
|
|
532
532
|
const startKey = attrOf(inner, "start-key-generation-name");
|
|
533
533
|
const checksumType = attrOf(inner, "checksum-type");
|
|
534
534
|
if (algorithm !== AES256_CBC) {
|
|
535
|
-
throw new (0,
|
|
535
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uC554\uD638\uD654 \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(algorithm, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
536
536
|
}
|
|
537
537
|
if (startKey !== START_KEY_SHA256) {
|
|
538
|
-
throw new (0,
|
|
538
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uC2DC\uC791\uD0A4 \uC0DD\uC131 \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(startKey, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
539
539
|
}
|
|
540
540
|
if (!_optionalChain([checksumType, 'optionalAccess', _8 => _8.endsWith, 'call', _9 => _9(CHECKSUM_SHA256_1K)])) {
|
|
541
|
-
throw new (0,
|
|
541
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uCCB4\uD06C\uC12C \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(checksumType, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
542
542
|
}
|
|
543
543
|
const iterations = parseInt(_nullishCoalesce(attrOf(inner, "iteration-count"), () => ( "")), 10);
|
|
544
544
|
const keySize = parseInt(_nullishCoalesce(attrOf(inner, "key-size"), () => ( "")), 10);
|
|
@@ -546,10 +546,10 @@ function parseEncryptionManifest(manifestXml) {
|
|
|
546
546
|
const salt = Buffer.from(_nullishCoalesce(attrOf(inner, "salt"), () => ( "")), "base64");
|
|
547
547
|
const checksum = Buffer.from(_nullishCoalesce(attrOf(inner, "checksum"), () => ( "")), "base64");
|
|
548
548
|
if (!(iterations > 0 && iterations <= MAX_ITERATION_COUNT)) {
|
|
549
|
-
throw new (0,
|
|
549
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`HWPX \uC554\uD638\uD654 \uBC18\uBCF5 \uD69F\uC218\uAC00 \uD5C8\uC6A9 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4: ${iterations}`);
|
|
550
550
|
}
|
|
551
551
|
if (keySize !== 32 || iv.length !== 16 || salt.length === 0 || checksum.length !== 32) {
|
|
552
|
-
throw new (0,
|
|
552
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`HWPX \uC554\uD638\uD654 \uD30C\uB77C\uBBF8\uD130\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4 (${path})`);
|
|
553
553
|
}
|
|
554
554
|
entries.push({ path, checksum, iv, salt, iterations, keySize });
|
|
555
555
|
}
|
|
@@ -582,11 +582,11 @@ async function decryptHwpxInPlace(zip, manifestXml, password) {
|
|
|
582
582
|
for (const entry of entries) {
|
|
583
583
|
const file = zip.file(entry.path);
|
|
584
584
|
if (!file) {
|
|
585
|
-
throw new (0,
|
|
585
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`\uC554\uD638 \uBAA9\uB85D\uC5D0 \uC788\uB294 \uD30C\uC77C\uC774 \uBB38\uC11C\uC5D0 \uC5C6\uC2B5\uB2C8\uB2E4: ${entry.path}`);
|
|
586
586
|
}
|
|
587
587
|
const plain = decryptEntry(await file.async("nodebuffer"), entry, startKey);
|
|
588
588
|
if (!plain) {
|
|
589
|
-
throw new (0,
|
|
589
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
590
590
|
}
|
|
591
591
|
decrypted.push({ path: entry.path, plain });
|
|
592
592
|
}
|
|
@@ -634,10 +634,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
634
634
|
const xml = await file.async("text");
|
|
635
635
|
if (decompressed) {
|
|
636
636
|
decompressed.total += xml.length * 2;
|
|
637
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
637
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
638
638
|
}
|
|
639
639
|
const parser = createXmlParser();
|
|
640
|
-
const doc = parser.parseFromString(
|
|
640
|
+
const doc = parser.parseFromString(_chunkDJKLOLBTcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
641
641
|
if (!doc.documentElement) continue;
|
|
642
642
|
const domDoc = doc;
|
|
643
643
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -683,6 +683,8 @@ function parseCharProperties(doc, map) {
|
|
|
683
683
|
else if (localTag === "strikeout") {
|
|
684
684
|
const shape = k.getAttribute("shape") || "";
|
|
685
685
|
if (isRealStrikeShape(shape)) prop.strike = true;
|
|
686
|
+
} else if (localTag === "underline") {
|
|
687
|
+
if (k.getAttribute("type") === "BOTTOM") prop.underline = true;
|
|
686
688
|
}
|
|
687
689
|
}
|
|
688
690
|
const fontFaces = el.getElementsByTagName("*");
|
|
@@ -824,9 +826,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
824
826
|
let level = 0;
|
|
825
827
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _16 => _16.style, 'optionalAccess', _17 => _17.fontSize])) {
|
|
826
828
|
const ratio = block.style.fontSize / baseFontSize;
|
|
827
|
-
if (ratio >=
|
|
828
|
-
else if (ratio >=
|
|
829
|
-
else if (ratio >=
|
|
829
|
+
if (ratio >= _chunkDJKLOLBTcjs.HEADING_RATIO_H1) level = 1;
|
|
830
|
+
else if (ratio >= _chunkDJKLOLBTcjs.HEADING_RATIO_H2) level = 2;
|
|
831
|
+
else if (ratio >= _chunkDJKLOLBTcjs.HEADING_RATIO_H3) level = 3;
|
|
830
832
|
}
|
|
831
833
|
const compactText = text.replace(/\s+/g, "");
|
|
832
834
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1419,7 +1421,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1419
1421
|
|
|
1420
1422
|
// src/hwpx/table-build.ts
|
|
1421
1423
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols, keepEmptyParagraphs) {
|
|
1422
|
-
const table2 =
|
|
1424
|
+
const table2 = _chunkUSGC3ZKUcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols, keepEmptyParagraphs });
|
|
1423
1425
|
if (state.caption) table2.caption = state.caption;
|
|
1424
1426
|
if (_optionalChain([state, 'access', _21 => _21.captionBlocks, 'optionalAccess', _22 => _22.length])) table2.captionBlocks = state.captionBlocks;
|
|
1425
1427
|
const anchors = [];
|
|
@@ -1490,7 +1492,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1490
1492
|
const cell2 = parentTable.cell;
|
|
1491
1493
|
(cell2.blocks ??= []).push(block);
|
|
1492
1494
|
cell2.hasStructure = true;
|
|
1493
|
-
let flat =
|
|
1495
|
+
let flat = _chunkUSGC3ZKUcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1494
1496
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1495
1497
|
if (flat) {
|
|
1496
1498
|
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
@@ -1506,7 +1508,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1506
1508
|
// src/hwpx/section-walker.ts
|
|
1507
1509
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1508
1510
|
const parser = createXmlParser(warnings);
|
|
1509
|
-
const doc = parser.parseFromString(
|
|
1511
|
+
const doc = parser.parseFromString(_chunkDJKLOLBTcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1510
1512
|
if (!doc.documentElement) return [];
|
|
1511
1513
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1512
1514
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1613,8 +1615,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1613
1615
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1614
1616
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1615
1617
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1616
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1617
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1618
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkUSGC3ZKUcjs.MAX_COLS);
|
|
1619
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkUSGC3ZKUcjs.MAX_ROWS);
|
|
1618
1620
|
}
|
|
1619
1621
|
break;
|
|
1620
1622
|
case "p": {
|
|
@@ -1885,7 +1887,7 @@ function buildSubListTable(el, ctx, depth) {
|
|
|
1885
1887
|
const sink = [];
|
|
1886
1888
|
const st = { rows: [], currentRow: [], cell: null };
|
|
1887
1889
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
1888
|
-
let flat =
|
|
1890
|
+
let flat = _chunkUSGC3ZKUcjs.convertTableToText.call(void 0, st.rows);
|
|
1889
1891
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
1890
1892
|
const built = [];
|
|
1891
1893
|
completeTable(st, [], built, ctx);
|
|
@@ -2040,7 +2042,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2040
2042
|
let url = (ch.textContent || "").trim();
|
|
2041
2043
|
if (!url) continue;
|
|
2042
2044
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2043
|
-
const safe =
|
|
2045
|
+
const safe = _chunkDJKLOLBTcjs.sanitizeHref.call(void 0, url);
|
|
2044
2046
|
if (safe) return safe;
|
|
2045
2047
|
}
|
|
2046
2048
|
return void 0;
|
|
@@ -2200,7 +2202,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2200
2202
|
case "hyperlink": {
|
|
2201
2203
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2202
2204
|
if (url) {
|
|
2203
|
-
const safe =
|
|
2205
|
+
const safe = _chunkDJKLOLBTcjs.sanitizeHref.call(void 0, url);
|
|
2204
2206
|
if (safe) href = safe;
|
|
2205
2207
|
}
|
|
2206
2208
|
walk(child, depth + 1);
|
|
@@ -2381,21 +2383,22 @@ function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
|
2381
2383
|
if (_optionalChain([cp, 'optionalAccess', _66 => _66.bold])) span.bold = true;
|
|
2382
2384
|
if (_optionalChain([cp, 'optionalAccess', _67 => _67.italic])) span.italic = true;
|
|
2383
2385
|
if (_optionalChain([cp, 'optionalAccess', _68 => _68.strike])) span.strike = true;
|
|
2386
|
+
if (_optionalChain([cp, 'optionalAccess', _69 => _69.underline])) span.underline = true;
|
|
2384
2387
|
}
|
|
2385
|
-
if (span.bold || span.italic || span.strike || span.code) styled = true;
|
|
2388
|
+
if (span.bold || span.italic || span.strike || span.underline || span.code) styled = true;
|
|
2386
2389
|
spans.push(span);
|
|
2387
2390
|
}
|
|
2388
2391
|
if (!styled || spans.length === 0) return null;
|
|
2389
2392
|
const merged = [];
|
|
2390
2393
|
for (const s of spans) {
|
|
2391
2394
|
const last = merged[merged.length - 1];
|
|
2392
|
-
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.strike === !!s.strike && !!last.code === !!s.code) {
|
|
2395
|
+
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.strike === !!s.strike && !!last.underline === !!s.underline && !!last.code === !!s.code) {
|
|
2393
2396
|
last.text += s.text;
|
|
2394
2397
|
} else {
|
|
2395
2398
|
merged.push(s);
|
|
2396
2399
|
}
|
|
2397
2400
|
}
|
|
2398
|
-
if (requireMixed && !merged.some((s) => s.strike) && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2401
|
+
if (requireMixed && !merged.some((s) => s.strike || s.underline) && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2399
2402
|
return merged;
|
|
2400
2403
|
}
|
|
2401
2404
|
function gongmunDepthFromIndent(para2, left, ctx) {
|
|
@@ -2403,12 +2406,12 @@ function gongmunDepthFromIndent(para2, left, ctx) {
|
|
|
2403
2406
|
if (!styleMap) return null;
|
|
2404
2407
|
let unit = 0;
|
|
2405
2408
|
const kids = para2.childNodes;
|
|
2406
|
-
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids, 'optionalAccess',
|
|
2409
|
+
for (let i = 0; i < (_nullishCoalesce(_optionalChain([kids, 'optionalAccess', _70 => _70.length]), () => ( 0))); i++) {
|
|
2407
2410
|
const child = kids[i];
|
|
2408
2411
|
if (child.nodeType !== 1) continue;
|
|
2409
2412
|
const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
|
|
2410
2413
|
if (tag !== "run" && tag !== "r") continue;
|
|
2411
|
-
const size = _optionalChain([styleMap, 'access',
|
|
2414
|
+
const size = _optionalChain([styleMap, 'access', _71 => _71.charProperties, 'access', _72 => _72.get, 'call', _73 => _73(_nullishCoalesce(child.getAttribute("charPrIDRef"), () => ( ""))), 'optionalAccess', _74 => _74.fontSize]);
|
|
2412
2415
|
if (size) unit = size * 100;
|
|
2413
2416
|
break;
|
|
2414
2417
|
}
|
|
@@ -2481,7 +2484,7 @@ function decompressStream(data) {
|
|
|
2481
2484
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2482
2485
|
}
|
|
2483
2486
|
function parseFileHeader(data) {
|
|
2484
|
-
if (data.length < 40) throw new (0,
|
|
2487
|
+
if (data.length < 40) throw new (0, _chunkDJKLOLBTcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2485
2488
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2486
2489
|
return {
|
|
2487
2490
|
signature: sig,
|
|
@@ -2614,7 +2617,7 @@ function appendParaText(state, data, resolveControl) {
|
|
|
2614
2617
|
const resolveAt = (byteOffset, extended) => {
|
|
2615
2618
|
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2616
2619
|
const idx = extended ? state.ctrlIdx : -1;
|
|
2617
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall',
|
|
2620
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _75 => _75(idx, ctrlId)]);
|
|
2618
2621
|
if (replacement) result += replacement;
|
|
2619
2622
|
if (extended) state.ctrlIdx++;
|
|
2620
2623
|
};
|
|
@@ -2818,7 +2821,7 @@ function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
|
|
|
2818
2821
|
const binDataMap = /* @__PURE__ */ new Map();
|
|
2819
2822
|
if (fileIndex) {
|
|
2820
2823
|
for (const entry of fileIndex) {
|
|
2821
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
2824
|
+
if (!_optionalChain([entry, 'optionalAccess', _76 => _76.name]) || !entry.content) continue;
|
|
2822
2825
|
const match = entry.name.match(BIN_ENTRY_RE);
|
|
2823
2826
|
if (!match) continue;
|
|
2824
2827
|
const idx = parseInt(match[1], 16);
|
|
@@ -2894,11 +2897,11 @@ function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
|
|
|
2894
2897
|
} else if (block.type === "table" && block.table) {
|
|
2895
2898
|
for (const row of block.table.cells) {
|
|
2896
2899
|
for (const cell2 of row) {
|
|
2897
|
-
if (_optionalChain([cell2, 'access',
|
|
2900
|
+
if (_optionalChain([cell2, 'access', _77 => _77.blocks, 'optionalAccess', _78 => _78.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
|
|
2898
2901
|
}
|
|
2899
2902
|
}
|
|
2900
2903
|
}
|
|
2901
|
-
if (_optionalChain([block, 'access',
|
|
2904
|
+
if (_optionalChain([block, 'access', _79 => _79.children, 'optionalAccess', _80 => _80.length])) collectImageBlocks2(block.children, out, ownerCell, depth + 1);
|
|
2902
2905
|
}
|
|
2903
2906
|
}
|
|
2904
2907
|
async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUnreferenced) {
|
|
@@ -2933,13 +2936,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2933
2936
|
}
|
|
2934
2937
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
2935
2938
|
for (const path of allCandidates) {
|
|
2936
|
-
if (
|
|
2939
|
+
if (_chunkDJKLOLBTcjs.isPathTraversal.call(void 0, path)) continue;
|
|
2937
2940
|
const file = zip.file(path);
|
|
2938
2941
|
if (!file) continue;
|
|
2939
2942
|
try {
|
|
2940
2943
|
const data = await file.async("uint8array");
|
|
2941
2944
|
decompressed.total += data.length;
|
|
2942
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2945
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2943
2946
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
2944
2947
|
const mimeType = imageExtToMime(ext);
|
|
2945
2948
|
imageIndex++;
|
|
@@ -2949,10 +2952,10 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2949
2952
|
usedPaths.add(path);
|
|
2950
2953
|
break;
|
|
2951
2954
|
} catch (err) {
|
|
2952
|
-
if (err instanceof
|
|
2955
|
+
if (err instanceof _chunkDJKLOLBTcjs.KordocError) throw err;
|
|
2953
2956
|
}
|
|
2954
2957
|
}
|
|
2955
|
-
if (!img) _optionalChain([warnings, 'optionalAccess',
|
|
2958
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _81 => _81.push, 'call', _82 => _82({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
2956
2959
|
resolved.set(ref, img);
|
|
2957
2960
|
}
|
|
2958
2961
|
if (!img) {
|
|
@@ -2969,11 +2972,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2969
2972
|
if (sweepUnreferenced) {
|
|
2970
2973
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
2971
2974
|
for (const file of binEntries) {
|
|
2972
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
2975
|
+
if (file.dir || usedPaths.has(file.name) || _chunkDJKLOLBTcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
2973
2976
|
try {
|
|
2974
2977
|
const data = await file.async("uint8array");
|
|
2975
2978
|
decompressed.total += data.length;
|
|
2976
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2979
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2977
2980
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
2978
2981
|
let mimeType = imageExtToMime(ext);
|
|
2979
2982
|
if (mimeType === "application/octet-stream") {
|
|
@@ -2987,8 +2990,8 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2987
2990
|
images.push(img);
|
|
2988
2991
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
2989
2992
|
} catch (err) {
|
|
2990
|
-
if (err instanceof
|
|
2991
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
2993
|
+
if (err instanceof _chunkDJKLOLBTcjs.KordocError) throw err;
|
|
2994
|
+
_optionalChain([warnings, 'optionalAccess', _83 => _83.push, 'call', _84 => _84({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
2992
2995
|
}
|
|
2993
2996
|
}
|
|
2994
2997
|
}
|
|
@@ -3038,7 +3041,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3038
3041
|
}
|
|
3039
3042
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3040
3043
|
const name = new TextDecoder().decode(nameBytes);
|
|
3041
|
-
if (
|
|
3044
|
+
if (_chunkDJKLOLBTcjs.isPathTraversal.call(void 0, name)) {
|
|
3042
3045
|
pos = fileStart + compSize;
|
|
3043
3046
|
continue;
|
|
3044
3047
|
}
|
|
@@ -3056,16 +3059,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3056
3059
|
continue;
|
|
3057
3060
|
}
|
|
3058
3061
|
totalDecompressed += content.length * 2;
|
|
3059
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3062
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3060
3063
|
sectionNum++;
|
|
3061
3064
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3062
3065
|
} catch (e17) {
|
|
3063
3066
|
continue;
|
|
3064
3067
|
}
|
|
3065
3068
|
}
|
|
3066
|
-
if (blocks.length === 0) throw new (0,
|
|
3069
|
+
if (blocks.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3067
3070
|
applyPageText(blocks, shared);
|
|
3068
|
-
const markdown =
|
|
3071
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3069
3072
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3070
3073
|
}
|
|
3071
3074
|
async function readKordocLayout(zip) {
|
|
@@ -3074,7 +3077,7 @@ async function readKordocLayout(zip) {
|
|
|
3074
3077
|
try {
|
|
3075
3078
|
const xml = await file.async("text");
|
|
3076
3079
|
if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
|
|
3077
|
-
return _nullishCoalesce(_optionalChain([xml, 'access',
|
|
3080
|
+
return _nullishCoalesce(_optionalChain([xml, 'access', _85 => _85.match, 'call', _86 => _86(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _87 => _87[1]]), () => ( null));
|
|
3078
3081
|
} catch (e18) {
|
|
3079
3082
|
return null;
|
|
3080
3083
|
}
|
|
@@ -3090,18 +3093,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3090
3093
|
if (paths.length > 0) return paths;
|
|
3091
3094
|
}
|
|
3092
3095
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3093
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3096
|
+
return sectionFiles.map((f) => f.name).sort(_chunkDJKLOLBTcjs.compareSectionPaths);
|
|
3094
3097
|
}
|
|
3095
3098
|
function parseSectionPathsFromManifest(xml) {
|
|
3096
3099
|
const parser = createXmlParser();
|
|
3097
|
-
const doc = parser.parseFromString(
|
|
3100
|
+
const doc = parser.parseFromString(_chunkDJKLOLBTcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3098
3101
|
const items = doc.getElementsByTagName("opf:item");
|
|
3099
3102
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3100
3103
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3101
3104
|
for (let i = 0; i < items.length; i++) {
|
|
3102
3105
|
const item = items[i];
|
|
3103
3106
|
const id = item.getAttribute("id") || "";
|
|
3104
|
-
const href =
|
|
3107
|
+
const href = _chunkDJKLOLBTcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3105
3108
|
if (id && href) idToHref.set(id, href);
|
|
3106
3109
|
}
|
|
3107
3110
|
if (spine.length > 0) {
|
|
@@ -3112,7 +3115,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3112
3115
|
}
|
|
3113
3116
|
if (ordered.length > 0) return ordered;
|
|
3114
3117
|
}
|
|
3115
|
-
return Array.from(idToHref.values()).sort(
|
|
3118
|
+
return Array.from(idToHref.values()).sort(_chunkDJKLOLBTcjs.compareSectionPaths);
|
|
3116
3119
|
}
|
|
3117
3120
|
|
|
3118
3121
|
// src/hwpx/metadata.ts
|
|
@@ -3125,7 +3128,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3125
3128
|
const xml = await file.async("text");
|
|
3126
3129
|
if (decompressed) {
|
|
3127
3130
|
decompressed.total += xml.length * 2;
|
|
3128
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3131
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3129
3132
|
}
|
|
3130
3133
|
parseDublinCoreMetadata(xml, metadata);
|
|
3131
3134
|
if (metadata.title || metadata.author) return;
|
|
@@ -3135,13 +3138,13 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3135
3138
|
}
|
|
3136
3139
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3137
3140
|
const parser = createXmlParser();
|
|
3138
|
-
const doc = parser.parseFromString(
|
|
3141
|
+
const doc = parser.parseFromString(_chunkDJKLOLBTcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3139
3142
|
if (!doc.documentElement) return;
|
|
3140
3143
|
const getText = (tagNames) => {
|
|
3141
3144
|
for (const tag of tagNames) {
|
|
3142
3145
|
const els = doc.getElementsByTagName(tag);
|
|
3143
3146
|
if (els.length > 0) {
|
|
3144
|
-
const text = _optionalChain([els, 'access',
|
|
3147
|
+
const text = _optionalChain([els, 'access', _88 => _88[0], 'access', _89 => _89.textContent, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]);
|
|
3145
3148
|
if (text) return text;
|
|
3146
3149
|
}
|
|
3147
3150
|
}
|
|
@@ -3160,7 +3163,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3160
3163
|
|
|
3161
3164
|
// src/hwpx/parser.ts
|
|
3162
3165
|
async function parseHwpxDocument(buffer, options) {
|
|
3163
|
-
|
|
3166
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3164
3167
|
let zip;
|
|
3165
3168
|
try {
|
|
3166
3169
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3169,22 +3172,22 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3169
3172
|
}
|
|
3170
3173
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3171
3174
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3172
|
-
throw new (0,
|
|
3175
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3173
3176
|
}
|
|
3174
3177
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3175
3178
|
if (manifestFile) {
|
|
3176
3179
|
const manifestXml = await manifestFile.async("text");
|
|
3177
3180
|
if (isEncryptedHwpx(manifestXml)) {
|
|
3178
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3181
|
+
if (_optionalChain([options, 'optionalAccess', _92 => _92.password])) {
|
|
3179
3182
|
await decryptHwpxInPlace(zip, manifestXml, options.password);
|
|
3180
3183
|
} else {
|
|
3181
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
3184
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _93 => _93.filePath])) {
|
|
3182
3185
|
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3183
3186
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3184
3187
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3185
3188
|
}
|
|
3186
3189
|
}
|
|
3187
|
-
throw new (0,
|
|
3190
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
3188
3191
|
"\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694."
|
|
3189
3192
|
);
|
|
3190
3193
|
}
|
|
@@ -3196,15 +3199,15 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3196
3199
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3197
3200
|
const warnings = [];
|
|
3198
3201
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3199
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3202
|
+
if (sectionPaths.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3200
3203
|
metadata.pageCount = sectionPaths.length;
|
|
3201
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3204
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _94 => _94.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3202
3205
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3203
3206
|
const blocks = [];
|
|
3204
3207
|
const shared = createSectionShared();
|
|
3205
3208
|
shared.kordocLayout = await readKordocLayout(zip);
|
|
3206
|
-
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
3207
|
-
shared.keepEmptyParagraphs = _optionalChain([options, 'optionalAccess',
|
|
3209
|
+
shared.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _95 => _95.keepTrailingEmptyCols]);
|
|
3210
|
+
shared.keepEmptyParagraphs = _optionalChain([options, 'optionalAccess', _96 => _96.keepEmptyParagraphs]);
|
|
3208
3211
|
let parsedSections = 0;
|
|
3209
3212
|
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3210
3213
|
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
@@ -3216,7 +3219,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3216
3219
|
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new ZipBombError("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3217
3220
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3218
3221
|
parsedSections++;
|
|
3219
|
-
_optionalChain([options, 'optionalAccess',
|
|
3222
|
+
_optionalChain([options, 'optionalAccess', _97 => _97.onProgress, 'optionalCall', _98 => _98(parsedSections, totalTarget)]);
|
|
3220
3223
|
} catch (secErr) {
|
|
3221
3224
|
if (secErr instanceof ZipBombError) throw secErr;
|
|
3222
3225
|
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" });
|
|
@@ -3226,7 +3229,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3226
3229
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3227
3230
|
detectHwpxHeadings(blocks, styleMap);
|
|
3228
3231
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3229
|
-
const markdown =
|
|
3232
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3230
3233
|
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 };
|
|
3231
3234
|
}
|
|
3232
3235
|
|
|
@@ -4226,19 +4229,19 @@ function decryptPasswordStream(raw, password) {
|
|
|
4226
4229
|
var TAG_DOCUMENT_PROPERTIES = 16;
|
|
4227
4230
|
var TAG_ID_MAPPINGS = 17;
|
|
4228
4231
|
function assertDecryptedDocInfo(data, readRecords3) {
|
|
4229
|
-
const wrong = () => new (0,
|
|
4232
|
+
const wrong = () => new (0, _chunkDJKLOLBTcjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
4230
4233
|
let records;
|
|
4231
4234
|
try {
|
|
4232
4235
|
records = readRecords3(data);
|
|
4233
4236
|
} catch (e22) {
|
|
4234
4237
|
throw wrong();
|
|
4235
4238
|
}
|
|
4236
|
-
if (_optionalChain([records, 'access',
|
|
4239
|
+
if (_optionalChain([records, 'access', _99 => _99[0], 'optionalAccess', _100 => _100.tagId]) !== TAG_DOCUMENT_PROPERTIES) throw wrong();
|
|
4237
4240
|
if (!records.some((r) => r.tagId === TAG_ID_MAPPINGS)) throw wrong();
|
|
4238
4241
|
}
|
|
4239
4242
|
function assertSupportedEncryptVersion(version) {
|
|
4240
4243
|
if (version !== SUPPORTED_ENCRYPT_VERSION) {
|
|
4241
|
-
throw new (0,
|
|
4244
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
4242
4245
|
`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP \uC554\uD638\uD654 \uBC84\uC804\uC785\uB2C8\uB2E4 (EncryptVersion=${version}, \uC9C0\uC6D0: ${SUPPORTED_ENCRYPT_VERSION})`
|
|
4243
4246
|
);
|
|
4244
4247
|
}
|
|
@@ -4321,25 +4324,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
4321
4324
|
lenientCfb = parseLenientCfb(buffer);
|
|
4322
4325
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4323
4326
|
} catch (e24) {
|
|
4324
|
-
throw new (0,
|
|
4327
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4325
4328
|
}
|
|
4326
4329
|
}
|
|
4327
4330
|
const readRawStream = (path) => {
|
|
4328
4331
|
if (cfb) {
|
|
4329
4332
|
const entry = CFB.find(cfb, path);
|
|
4330
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
4333
|
+
return _optionalChain([entry, 'optionalAccess', _101 => _101.content]) ? Buffer.from(entry.content) : null;
|
|
4331
4334
|
}
|
|
4332
4335
|
return lenientCfb.findStream(path);
|
|
4333
4336
|
};
|
|
4334
4337
|
const headerData = readRawStream("/FileHeader");
|
|
4335
|
-
if (!headerData) throw new (0,
|
|
4338
|
+
if (!headerData) throw new (0, _chunkDJKLOLBTcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4336
4339
|
const header = parseFileHeader(headerData);
|
|
4337
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4338
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4340
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4341
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkDJKLOLBTcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4339
4342
|
const encrypted = (header.flags & FLAG_ENCRYPTED) !== 0;
|
|
4340
4343
|
if (encrypted) {
|
|
4341
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
4342
|
-
throw new (0,
|
|
4344
|
+
if (!_optionalChain([options, 'optionalAccess', _102 => _102.password])) {
|
|
4345
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWP \uBB38\uC11C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694.");
|
|
4343
4346
|
}
|
|
4344
4347
|
assertSupportedEncryptVersion(readEncryptVersion(headerData));
|
|
4345
4348
|
}
|
|
@@ -4357,24 +4360,24 @@ function parseHwp5Document(buffer, options) {
|
|
|
4357
4360
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4358
4361
|
if (encrypted) {
|
|
4359
4362
|
const rawDocInfo = findStream("/DocInfo");
|
|
4360
|
-
if (!rawDocInfo) throw new (0,
|
|
4363
|
+
if (!rawDocInfo) throw new (0, _chunkDJKLOLBTcjs.KordocError)("DocInfo \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4361
4364
|
let docInfoData;
|
|
4362
4365
|
try {
|
|
4363
4366
|
docInfoData = compressed ? decompressStream(rawDocInfo) : rawDocInfo;
|
|
4364
4367
|
} catch (e25) {
|
|
4365
|
-
throw new (0,
|
|
4368
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
4366
4369
|
}
|
|
4367
4370
|
assertDecryptedDocInfo(docInfoData, readRecords);
|
|
4368
4371
|
}
|
|
4369
4372
|
const docInfo = cfb && !encrypted ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4370
4373
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : encrypted ? findSectionsVia(findStream) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4371
|
-
if (sections.length === 0) throw new (0,
|
|
4374
|
+
if (sections.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4372
4375
|
metadata.pageCount = sections.length;
|
|
4373
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4376
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _103 => _103.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4374
4377
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4375
4378
|
const bodyBlocks = [];
|
|
4376
4379
|
const doc = createHwp5DocState();
|
|
4377
|
-
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess',
|
|
4380
|
+
doc.keepTrailingEmptyCols = _optionalChain([options, 'optionalAccess', _104 => _104.keepTrailingEmptyCols]);
|
|
4378
4381
|
let totalDecompressed = 0;
|
|
4379
4382
|
let parsedSections = 0;
|
|
4380
4383
|
for (let si = 0; si < sections.length; si++) {
|
|
@@ -4383,22 +4386,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4383
4386
|
const sectionData = sections[si];
|
|
4384
4387
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4385
4388
|
totalDecompressed += data.length;
|
|
4386
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4389
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4387
4390
|
const records = readRecords(data);
|
|
4388
4391
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4389
4392
|
bodyBlocks.push(...sectionBlocks);
|
|
4390
4393
|
parsedSections++;
|
|
4391
|
-
_optionalChain([options, 'optionalAccess',
|
|
4394
|
+
_optionalChain([options, 'optionalAccess', _105 => _105.onProgress, 'optionalCall', _106 => _106(parsedSections, totalTarget)]);
|
|
4392
4395
|
} catch (secErr) {
|
|
4393
|
-
if (secErr instanceof
|
|
4396
|
+
if (secErr instanceof _chunkDJKLOLBTcjs.KordocError) throw secErr;
|
|
4394
4397
|
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" });
|
|
4395
4398
|
}
|
|
4396
4399
|
}
|
|
4397
4400
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4398
4401
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4399
|
-
let flatBlocks =
|
|
4400
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4401
|
-
const deduped =
|
|
4402
|
+
let flatBlocks = _chunkUSGC3ZKUcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4403
|
+
if (_optionalChain([options, 'optionalAccess', _107 => _107.dedupeRunningHeaders])) {
|
|
4404
|
+
const deduped = _chunkUSGC3ZKUcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4402
4405
|
const removed = flatBlocks.length - deduped.length;
|
|
4403
4406
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4404
4407
|
flatBlocks = deduped;
|
|
@@ -4407,10 +4410,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4407
4410
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4408
4411
|
}
|
|
4409
4412
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4410
|
-
let markdown =
|
|
4411
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4413
|
+
let markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4414
|
+
if (_optionalChain([options, 'optionalAccess', _108 => _108.inlineImages]) && images.length > 0) {
|
|
4412
4415
|
try {
|
|
4413
|
-
markdown =
|
|
4416
|
+
markdown = _chunkUSGC3ZKUcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4414
4417
|
} catch (inlineErr) {
|
|
4415
4418
|
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" });
|
|
4416
4419
|
}
|
|
@@ -4420,7 +4423,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4420
4423
|
function parseDocInfoStream(cfb, compressed) {
|
|
4421
4424
|
try {
|
|
4422
4425
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
4423
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4426
|
+
if (!_optionalChain([entry, 'optionalAccess', _109 => _109.content])) return null;
|
|
4424
4427
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
4425
4428
|
const records = readRecords(data);
|
|
4426
4429
|
return parseDocInfo(records);
|
|
@@ -4441,7 +4444,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4441
4444
|
let baseFontSize = 0;
|
|
4442
4445
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
4443
4446
|
for (const b of blocks) {
|
|
4444
|
-
if (_optionalChain([b, 'access',
|
|
4447
|
+
if (_optionalChain([b, 'access', _110 => _110.style, 'optionalAccess', _111 => _111.fontSize]) && b.text) {
|
|
4445
4448
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4446
4449
|
}
|
|
4447
4450
|
}
|
|
@@ -4457,7 +4460,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4457
4460
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4458
4461
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4459
4462
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4460
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4463
|
+
if (_optionalChain([cs, 'optionalAccess', _112 => _112.fontSize]) > 0) {
|
|
4461
4464
|
baseFontSize = cs.fontSize / 10;
|
|
4462
4465
|
break;
|
|
4463
4466
|
}
|
|
@@ -4472,11 +4475,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4472
4475
|
if (text.length === 0 || text.length > 200) continue;
|
|
4473
4476
|
if (/^\d+$/.test(text)) continue;
|
|
4474
4477
|
let level = 0;
|
|
4475
|
-
if (_optionalChain([block, 'access',
|
|
4478
|
+
if (_optionalChain([block, 'access', _113 => _113.style, 'optionalAccess', _114 => _114.fontSize]) && baseFontSize > 0) {
|
|
4476
4479
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4477
|
-
if (ratio >=
|
|
4478
|
-
else if (ratio >=
|
|
4479
|
-
else if (ratio >=
|
|
4480
|
+
if (ratio >= _chunkDJKLOLBTcjs.HEADING_RATIO_H1) level = 1;
|
|
4481
|
+
else if (ratio >= _chunkDJKLOLBTcjs.HEADING_RATIO_H2) level = 2;
|
|
4482
|
+
else if (ratio >= _chunkDJKLOLBTcjs.HEADING_RATIO_H3) level = 3;
|
|
4480
4483
|
}
|
|
4481
4484
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4482
4485
|
if (level === 0) level = 2;
|
|
@@ -4492,7 +4495,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4492
4495
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4493
4496
|
try {
|
|
4494
4497
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4495
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4498
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _115 => _115.content])) return;
|
|
4496
4499
|
const data = Buffer.from(summaryEntry.content);
|
|
4497
4500
|
if (data.length < 48) return;
|
|
4498
4501
|
const numSets = data.readUInt32LE(24);
|
|
@@ -4525,7 +4528,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
4525
4528
|
const sections = [];
|
|
4526
4529
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4527
4530
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
4528
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4531
|
+
if (!_optionalChain([entry, 'optionalAccess', _116 => _116.content])) break;
|
|
4529
4532
|
try {
|
|
4530
4533
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
4531
4534
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -4548,13 +4551,13 @@ function findSections(cfb) {
|
|
|
4548
4551
|
const sections = [];
|
|
4549
4552
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4550
4553
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
4551
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4554
|
+
if (!_optionalChain([entry, 'optionalAccess', _117 => _117.content])) break;
|
|
4552
4555
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
4553
4556
|
}
|
|
4554
4557
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
4555
4558
|
for (const entry of cfb.FileIndex) {
|
|
4556
4559
|
if (sections.length >= MAX_SECTIONS) break;
|
|
4557
|
-
if (_optionalChain([entry, 'access',
|
|
4560
|
+
if (_optionalChain([entry, 'access', _118 => _118.name, 'optionalAccess', _119 => _119.startsWith, 'call', _120 => _120("Section")]) && entry.content) {
|
|
4558
4561
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
4559
4562
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
4560
4563
|
}
|
|
@@ -4570,7 +4573,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4570
4573
|
if (!raw) break;
|
|
4571
4574
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4572
4575
|
totalDecompressed += content.length;
|
|
4573
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4576
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4574
4577
|
sections.push({ idx: i, content });
|
|
4575
4578
|
}
|
|
4576
4579
|
if (sections.length === 0) {
|
|
@@ -4582,7 +4585,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4582
4585
|
if (raw) {
|
|
4583
4586
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4584
4587
|
totalDecompressed += content.length;
|
|
4585
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4588
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4586
4589
|
sections.push({ idx, content });
|
|
4587
4590
|
}
|
|
4588
4591
|
}
|
|
@@ -4599,7 +4602,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4599
4602
|
try {
|
|
4600
4603
|
const content = decryptViewText(raw, compressed);
|
|
4601
4604
|
totalDecompressed += content.length;
|
|
4602
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4605
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4603
4606
|
sections.push({ idx: i, content });
|
|
4604
4607
|
} catch (e30) {
|
|
4605
4608
|
break;
|
|
@@ -4700,9 +4703,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4700
4703
|
const applied = [];
|
|
4701
4704
|
for (const r of ranges) {
|
|
4702
4705
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4703
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
4706
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _121 => _121.href]) || r.end <= r.start) continue;
|
|
4704
4707
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4705
|
-
const href =
|
|
4708
|
+
const href = _chunkDJKLOLBTcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4706
4709
|
if (!href) continue;
|
|
4707
4710
|
const anchor = text.slice(r.start, r.end);
|
|
4708
4711
|
if (!anchor.trim()) continue;
|
|
@@ -4720,7 +4723,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4720
4723
|
}
|
|
4721
4724
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
4722
4725
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
4723
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
4726
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _122 => _122.docInfo, 'optionalAccess', _123 => _123.numberings, 'access', _124 => _124[nid - 1]]) : void 0;
|
|
4724
4727
|
if (numbering) {
|
|
4725
4728
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
4726
4729
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -4730,7 +4733,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4730
4733
|
}
|
|
4731
4734
|
}
|
|
4732
4735
|
} else if (ps.headType === 3) {
|
|
4733
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
4736
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _125 => _125.docInfo, 'optionalAccess', _126 => _126.bullets, 'access', _127 => _127[ps.numberingId - 1]]) : void 0;
|
|
4734
4737
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
4735
4738
|
}
|
|
4736
4739
|
}
|
|
@@ -4747,7 +4750,11 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4747
4750
|
const style = resolveCharStyle(charShapeIds, ctx.docInfo);
|
|
4748
4751
|
if (style) {
|
|
4749
4752
|
block.style = style;
|
|
4750
|
-
if (style.strike
|
|
4753
|
+
if (style.strike || style.underline) {
|
|
4754
|
+
let deco = style.strike ? `~~${trimmed}~~` : trimmed;
|
|
4755
|
+
if (style.underline) deco = `<u>${deco}</u>`;
|
|
4756
|
+
block.text = headMarker ? `${headMarker} ${deco}` : deco;
|
|
4757
|
+
}
|
|
4751
4758
|
}
|
|
4752
4759
|
}
|
|
4753
4760
|
if (footnotes.length > 0) block.footnoteText = footnotes.join("; ");
|
|
@@ -4938,8 +4945,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4938
4945
|
let tableIdx = -1;
|
|
4939
4946
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4940
4947
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4941
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4942
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4948
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkUSGC3ZKUcjs.MAX_ROWS);
|
|
4949
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkUSGC3ZKUcjs.MAX_COLS);
|
|
4943
4950
|
tableIdx = i2;
|
|
4944
4951
|
break;
|
|
4945
4952
|
}
|
|
@@ -4979,7 +4986,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4979
4986
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
4980
4987
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
4981
4988
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
4982
|
-
if (_optionalChain([c, 'access',
|
|
4989
|
+
if (_optionalChain([c, 'access', _128 => _128.blocks, 'optionalAccess', _129 => _129.length])) ir.blocks = c.blocks;
|
|
4983
4990
|
if (c.isHeader) ir.isHeader = true;
|
|
4984
4991
|
return ir;
|
|
4985
4992
|
}));
|
|
@@ -4988,7 +4995,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4988
4995
|
return table3;
|
|
4989
4996
|
}
|
|
4990
4997
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4991
|
-
const table2 =
|
|
4998
|
+
const table2 = _chunkUSGC3ZKUcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
4992
4999
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
4993
5000
|
return table2.rows > 0 ? table2 : null;
|
|
4994
5001
|
}
|
|
@@ -5005,8 +5012,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5005
5012
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5006
5013
|
const cs = rec.data.readUInt16LE(12);
|
|
5007
5014
|
const rs = rec.data.readUInt16LE(14);
|
|
5008
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5009
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5015
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkUSGC3ZKUcjs.MAX_COLS);
|
|
5016
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkUSGC3ZKUcjs.MAX_ROWS);
|
|
5010
5017
|
}
|
|
5011
5018
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5012
5019
|
const parts = [];
|
|
@@ -5016,7 +5023,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5016
5023
|
parts.push(``);
|
|
5017
5024
|
hasStructure = true;
|
|
5018
5025
|
} else if (b.type === "table" && b.table) {
|
|
5019
|
-
const flat =
|
|
5026
|
+
const flat = _chunkUSGC3ZKUcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5020
5027
|
if (flat) parts.push(flat);
|
|
5021
5028
|
hasStructure = true;
|
|
5022
5029
|
} else if (b.text) {
|
|
@@ -5113,8 +5120,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
5113
5120
|
if (data.length < 73) return null;
|
|
5114
5121
|
const binDataId = data.readUInt16LE(71);
|
|
5115
5122
|
if (binDataId === 0) return null;
|
|
5116
|
-
const item = _optionalChain([ctx, 'access',
|
|
5117
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
5123
|
+
const item = _optionalChain([ctx, 'access', _130 => _130.docInfo, 'optionalAccess', _131 => _131.binData, 'access', _132 => _132[binDataId - 1]]);
|
|
5124
|
+
if (_optionalChain([item, 'optionalAccess', _133 => _133.kind]) === "link") {
|
|
5118
5125
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
5119
5126
|
return null;
|
|
5120
5127
|
}
|
|
@@ -5140,13 +5147,17 @@ function resolveCharStyle(charShapeIds, docInfo) {
|
|
|
5140
5147
|
if (cs.attrFlags & 1) style.italic = true;
|
|
5141
5148
|
if (cs.attrFlags & 2) style.bold = true;
|
|
5142
5149
|
if (hasRealStrike(cs.attrFlags)) style.strike = true;
|
|
5143
|
-
|
|
5150
|
+
if (hasRealUnderline(cs.attrFlags)) style.underline = true;
|
|
5151
|
+
return style.fontSize || style.bold || style.italic || style.strike || style.underline ? style : void 0;
|
|
5144
5152
|
}
|
|
5145
5153
|
function hasRealStrike(attrFlags) {
|
|
5146
5154
|
const strikeBits = attrFlags >> 18 & 7;
|
|
5147
5155
|
const shapeId = attrFlags >> 26 & 15;
|
|
5148
5156
|
return strikeBits !== 0 && shapeId <= 12;
|
|
5149
5157
|
}
|
|
5158
|
+
function hasRealUnderline(attrFlags) {
|
|
5159
|
+
return (attrFlags >> 2 & 3) === 1;
|
|
5160
|
+
}
|
|
5150
5161
|
|
|
5151
5162
|
// src/hwp3/parser.ts
|
|
5152
5163
|
|
|
@@ -17287,40 +17298,40 @@ function desEcbDecrypt(data, key) {
|
|
|
17287
17298
|
}
|
|
17288
17299
|
function readLayout(data) {
|
|
17289
17300
|
if (data.length < FIXED_HEADER_BYTES) {
|
|
17290
|
-
throw new (0,
|
|
17301
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uD5E4\uB354\uAC00 \uC798\uB838\uC2B5\uB2C8\uB2E4");
|
|
17291
17302
|
}
|
|
17292
17303
|
const infoBlockLength = data[INFO_BLOCK_LENGTH_OFFSET] | data[INFO_BLOCK_LENGTH_OFFSET + 1] << 8;
|
|
17293
17304
|
const payloadOffset = FIXED_HEADER_BYTES + infoBlockLength;
|
|
17294
17305
|
if (payloadOffset >= data.length) {
|
|
17295
|
-
throw new (0,
|
|
17306
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17296
17307
|
}
|
|
17297
17308
|
return { payloadOffset, compressed: data[COMPRESSION_FLAG_OFFSET] !== 0 };
|
|
17298
17309
|
}
|
|
17299
17310
|
function decryptHwp3Document(input, password) {
|
|
17300
17311
|
const { payloadOffset, compressed } = readLayout(input);
|
|
17301
17312
|
if (!compressed) {
|
|
17302
|
-
throw new (0,
|
|
17313
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP3 \uC554\uD638\uD654 \uBC29\uC2DD\uC785\uB2C8\uB2E4 (\uC555\uCD95\uB418\uC9C0 \uC54A\uC740 \uC554\uD638 \uBCF8\uBB38)");
|
|
17303
17314
|
}
|
|
17304
17315
|
const source = Buffer.from(input);
|
|
17305
17316
|
const payload = source.subarray(payloadOffset);
|
|
17306
17317
|
const aligned = payload.subarray(0, payload.length - payload.length % 8);
|
|
17307
17318
|
if (aligned.length === 0) {
|
|
17308
|
-
throw new (0,
|
|
17319
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4");
|
|
17309
17320
|
}
|
|
17310
17321
|
const decrypted = desEcbDecrypt(aligned, deriveDesKey(password));
|
|
17311
17322
|
let inflated;
|
|
17312
17323
|
try {
|
|
17313
17324
|
inflated = _zlib.inflateRawSync.call(void 0, decrypted, { maxOutputLength: MAX_DECOMPRESSED_BYTES });
|
|
17314
17325
|
} catch (err) {
|
|
17315
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
17316
|
-
throw new (0,
|
|
17326
|
+
if (_optionalChain([err, 'optionalAccess', _134 => _134.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17327
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
17317
17328
|
`HWP3 \uC554\uD638 \uBCF8\uBB38\uC758 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESSED_BYTES / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`
|
|
17318
17329
|
);
|
|
17319
17330
|
}
|
|
17320
|
-
throw new (0,
|
|
17331
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
17321
17332
|
}
|
|
17322
17333
|
if (inflated.length <= PASSWORD_PREFIX_BYTES) {
|
|
17323
|
-
throw new (0,
|
|
17334
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
17324
17335
|
}
|
|
17325
17336
|
const body = inflated.subarray(PASSWORD_PREFIX_BYTES);
|
|
17326
17337
|
const out = Buffer.concat([source.subarray(0, payloadOffset), body]);
|
|
@@ -17354,8 +17365,8 @@ var SIMPLE_CTRL = /* @__PURE__ */ new Map([
|
|
|
17354
17365
|
function parseHwp3Document(buffer, options) {
|
|
17355
17366
|
let source = Buffer.from(buffer);
|
|
17356
17367
|
if (isEncryptedHwp3(source)) {
|
|
17357
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
17358
|
-
throw new (0,
|
|
17368
|
+
if (!_optionalChain([options, 'optionalAccess', _135 => _135.password])) {
|
|
17369
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
17359
17370
|
"\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWP3 \uBB38\uC11C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694."
|
|
17360
17371
|
);
|
|
17361
17372
|
}
|
|
@@ -17371,11 +17382,11 @@ function parseHwp3Document(buffer, options) {
|
|
|
17371
17382
|
try {
|
|
17372
17383
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17373
17384
|
} catch (err) {
|
|
17374
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
17375
|
-
throw new (0,
|
|
17385
|
+
if (_optionalChain([err, 'optionalAccess', _136 => _136.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17386
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`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`);
|
|
17376
17387
|
}
|
|
17377
17388
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
17378
|
-
throw new (0,
|
|
17389
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`HWP3 \uC555\uCD95 \uD574\uC81C \uC2E4\uD328: ${msg2}`);
|
|
17379
17390
|
}
|
|
17380
17391
|
} else {
|
|
17381
17392
|
body = tail;
|
|
@@ -17609,15 +17620,15 @@ function getElements(parent, tagName) {
|
|
|
17609
17620
|
const result = [];
|
|
17610
17621
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
17611
17622
|
if (result.length > 0) return result;
|
|
17612
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
17623
|
+
const nsNodes = _optionalChain([parent, 'access', _137 => _137.getElementsByTagNameNS, 'optionalCall', _138 => _138("*", tagName)]);
|
|
17613
17624
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
17614
17625
|
return result;
|
|
17615
17626
|
}
|
|
17616
17627
|
function getTextContent(el) {
|
|
17617
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
17628
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _139 => _139.textContent, 'optionalAccess', _140 => _140.trim, 'call', _141 => _141()]), () => ( ""));
|
|
17618
17629
|
}
|
|
17619
17630
|
function parseXml(text) {
|
|
17620
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17631
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkDJKLOLBTcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17621
17632
|
}
|
|
17622
17633
|
function collectRichText(root) {
|
|
17623
17634
|
let out = "";
|
|
@@ -17626,7 +17637,7 @@ function collectRichText(root) {
|
|
|
17626
17637
|
for (let i = 0; i < children.length; i++) {
|
|
17627
17638
|
if (children[i].nodeType !== 1) continue;
|
|
17628
17639
|
const el = children[i];
|
|
17629
|
-
const local = el.localName || _optionalChain([el, 'access',
|
|
17640
|
+
const local = el.localName || _optionalChain([el, 'access', _142 => _142.tagName, 'optionalAccess', _143 => _143.replace, 'call', _144 => _144(/^[^:]+:/, "")]) || "";
|
|
17630
17641
|
if (local === "rPh") continue;
|
|
17631
17642
|
if (local === "t") out += _nullishCoalesce(el.textContent, () => ( ""));
|
|
17632
17643
|
else walk(el);
|
|
@@ -17845,14 +17856,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
17845
17856
|
const merge = mergeMap.get(key);
|
|
17846
17857
|
row.push({
|
|
17847
17858
|
text,
|
|
17848
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17849
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17859
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _145 => _145.colSpan]), () => ( 1)),
|
|
17860
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _146 => _146.rowSpan]), () => ( 1))
|
|
17850
17861
|
});
|
|
17851
17862
|
}
|
|
17852
17863
|
cellRows.push(row);
|
|
17853
17864
|
}
|
|
17854
17865
|
if (cellRows.length > 0) {
|
|
17855
|
-
const table2 =
|
|
17866
|
+
const table2 = _chunkUSGC3ZKUcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
17856
17867
|
if (table2.rows > 0) {
|
|
17857
17868
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17858
17869
|
}
|
|
@@ -17860,12 +17871,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
17860
17871
|
return blocks;
|
|
17861
17872
|
}
|
|
17862
17873
|
async function parseXlsxDocument(buffer, options) {
|
|
17863
|
-
|
|
17874
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
17864
17875
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
17865
17876
|
const warnings = [];
|
|
17866
17877
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
17867
17878
|
if (!workbookFile) {
|
|
17868
|
-
throw new (0,
|
|
17879
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17869
17880
|
}
|
|
17870
17881
|
let sharedStrings = [];
|
|
17871
17882
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17874,7 +17885,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17874
17885
|
}
|
|
17875
17886
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
17876
17887
|
if (sheets.length === 0) {
|
|
17877
|
-
throw new (0,
|
|
17888
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17878
17889
|
}
|
|
17879
17890
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
17880
17891
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -17894,7 +17905,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17894
17905
|
relsMap = parseRels(await relsFile.async("text"));
|
|
17895
17906
|
}
|
|
17896
17907
|
let pageFilter = null;
|
|
17897
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17908
|
+
if (_optionalChain([options, 'optionalAccess', _147 => _147.pages])) {
|
|
17898
17909
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17899
17910
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
17900
17911
|
}
|
|
@@ -17903,7 +17914,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17903
17914
|
for (let i = 0; i < processedSheets; i++) {
|
|
17904
17915
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17905
17916
|
const sheet = sheets[i];
|
|
17906
|
-
_optionalChain([options, 'optionalAccess',
|
|
17917
|
+
_optionalChain([options, 'optionalAccess', _148 => _148.onProgress, 'optionalCall', _149 => _149(i + 1, processedSheets)]);
|
|
17907
17918
|
let sheetPath = relsMap.get(sheet.rId);
|
|
17908
17919
|
if (sheetPath) {
|
|
17909
17920
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17926,7 +17937,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17926
17937
|
try {
|
|
17927
17938
|
const sheetXml = await sheetFile.async("text");
|
|
17928
17939
|
const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
|
|
17929
|
-
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess',
|
|
17940
|
+
const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, _optionalChain([options, 'optionalAccess', _150 => _150.keepTrailingEmptyCols]));
|
|
17930
17941
|
blocks.push(...sheetBlocks);
|
|
17931
17942
|
} catch (err) {
|
|
17932
17943
|
warnings.push({
|
|
@@ -17958,7 +17969,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17958
17969
|
} catch (e32) {
|
|
17959
17970
|
}
|
|
17960
17971
|
}
|
|
17961
|
-
const markdown =
|
|
17972
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17962
17973
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17963
17974
|
}
|
|
17964
17975
|
|
|
@@ -18409,11 +18420,11 @@ function processGlobals(records) {
|
|
|
18409
18420
|
const xfFmtIds = [];
|
|
18410
18421
|
const firstBof = records[0];
|
|
18411
18422
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18412
|
-
throw new (0,
|
|
18423
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18413
18424
|
}
|
|
18414
18425
|
const bof = decodeBof(firstBof.data);
|
|
18415
18426
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18416
|
-
throw new (0,
|
|
18427
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18417
18428
|
}
|
|
18418
18429
|
let i = 1;
|
|
18419
18430
|
while (i < records.length) {
|
|
@@ -18541,14 +18552,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18541
18552
|
const merge = mergeMap.get(key);
|
|
18542
18553
|
row.push({
|
|
18543
18554
|
text: grid[r][c],
|
|
18544
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18545
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18555
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _151 => _151.colSpan]), () => ( 1)),
|
|
18556
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _152 => _152.rowSpan]), () => ( 1))
|
|
18546
18557
|
});
|
|
18547
18558
|
}
|
|
18548
18559
|
cellRows.push(row);
|
|
18549
18560
|
}
|
|
18550
18561
|
if (cellRows.length > 0) {
|
|
18551
|
-
const table2 =
|
|
18562
|
+
const table2 = _chunkUSGC3ZKUcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18552
18563
|
if (table2.rows > 0) {
|
|
18553
18564
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18554
18565
|
}
|
|
@@ -18561,28 +18572,28 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18561
18572
|
try {
|
|
18562
18573
|
cfb = parseLenientCfb(buf);
|
|
18563
18574
|
} catch (e) {
|
|
18564
|
-
throw new (0,
|
|
18575
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
18565
18576
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18566
18577
|
);
|
|
18567
18578
|
}
|
|
18568
18579
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18569
18580
|
if (!wb) {
|
|
18570
|
-
throw new (0,
|
|
18581
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18571
18582
|
}
|
|
18572
18583
|
const records = readRecords2(wb);
|
|
18573
18584
|
if (records.length === 0) {
|
|
18574
|
-
throw new (0,
|
|
18585
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18575
18586
|
}
|
|
18576
18587
|
const firstBof = decodeBof(records[0].data);
|
|
18577
18588
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18578
|
-
throw new (0,
|
|
18589
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
18579
18590
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18580
18591
|
);
|
|
18581
18592
|
}
|
|
18582
18593
|
const globals = processGlobals(records);
|
|
18583
18594
|
const warnings = [];
|
|
18584
18595
|
if (globals.encrypted) {
|
|
18585
|
-
throw new (0,
|
|
18596
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("XLS \uD30C\uC77C\uC774 \uC554\uD638\uD654\uB418\uC5B4 \uC788\uC5B4 \uD30C\uC2F1\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18586
18597
|
}
|
|
18587
18598
|
const convertNum = globals.dateXfs.size > 0 ? (n, ixfe) => {
|
|
18588
18599
|
const kind = globals.dateXfs.get(ixfe);
|
|
@@ -18594,7 +18605,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18594
18605
|
} : void 0;
|
|
18595
18606
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18596
18607
|
let pageFilter = null;
|
|
18597
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18608
|
+
if (_optionalChain([options, 'optionalAccess', _153 => _153.pages])) {
|
|
18598
18609
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18599
18610
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18600
18611
|
}
|
|
@@ -18603,7 +18614,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18603
18614
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18604
18615
|
const meta = globals.sheets[i];
|
|
18605
18616
|
if (meta.dt !== 0) continue;
|
|
18606
|
-
_optionalChain([options, 'optionalAccess',
|
|
18617
|
+
_optionalChain([options, 'optionalAccess', _154 => _154.onProgress, 'optionalCall', _155 => _155(i + 1, totalSheets)]);
|
|
18607
18618
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
18608
18619
|
if (bofIdx < 0) {
|
|
18609
18620
|
warnings.push({
|
|
@@ -18619,7 +18630,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18619
18630
|
}
|
|
18620
18631
|
try {
|
|
18621
18632
|
const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
|
|
18622
|
-
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess',
|
|
18633
|
+
const blocks = sheetToBlocks2(meta.name, sheet, i, _optionalChain([options, 'optionalAccess', _156 => _156.keepTrailingEmptyCols]));
|
|
18623
18634
|
allBlocks.push(...blocks);
|
|
18624
18635
|
} catch (e) {
|
|
18625
18636
|
warnings.push({
|
|
@@ -18633,7 +18644,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18633
18644
|
pageCount: totalSheets
|
|
18634
18645
|
};
|
|
18635
18646
|
return {
|
|
18636
|
-
markdown:
|
|
18647
|
+
markdown: _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18637
18648
|
blocks: allBlocks,
|
|
18638
18649
|
metadata,
|
|
18639
18650
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19007,7 +19018,7 @@ function isDisplayMath(el) {
|
|
|
19007
19018
|
// src/docx/parser.ts
|
|
19008
19019
|
var MAX_DECOMPRESS_SIZE5 = 100 * 1024 * 1024;
|
|
19009
19020
|
function matchesLocal(el, localName2) {
|
|
19010
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
19021
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _157 => _157.tagName, 'optionalAccess', _158 => _158.endsWith, 'call', _159 => _159(`:${localName2}`)]), () => ( false)));
|
|
19011
19022
|
}
|
|
19012
19023
|
function effectiveChildElements(parent) {
|
|
19013
19024
|
const result = [];
|
|
@@ -19042,7 +19053,7 @@ function findElements(parent, localName2) {
|
|
|
19042
19053
|
const child = children[i];
|
|
19043
19054
|
if (child.nodeType === 1) {
|
|
19044
19055
|
const el = child;
|
|
19045
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
19056
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _160 => _160.tagName, 'optionalAccess', _161 => _161.endsWith, 'call', _162 => _162(`:${localName2}`)])) {
|
|
19046
19057
|
result.push(el);
|
|
19047
19058
|
}
|
|
19048
19059
|
walk(el);
|
|
@@ -19061,7 +19072,7 @@ function getAttr(el, localName2) {
|
|
|
19061
19072
|
return null;
|
|
19062
19073
|
}
|
|
19063
19074
|
function parseXml2(text) {
|
|
19064
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19075
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkDJKLOLBTcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19065
19076
|
}
|
|
19066
19077
|
function parseStyles(xml) {
|
|
19067
19078
|
const doc = parseXml2(xml);
|
|
@@ -19178,7 +19189,7 @@ function collectOmmlRoots(p) {
|
|
|
19178
19189
|
const child = children[i];
|
|
19179
19190
|
if (child.nodeType !== 1) continue;
|
|
19180
19191
|
const el = child;
|
|
19181
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
19192
|
+
const tag = el.localName || _optionalChain([el, 'access', _163 => _163.tagName, 'optionalAccess', _164 => _164.replace, 'call', _165 => _165(/^[^:]+:/, "")]) || "";
|
|
19182
19193
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
19183
19194
|
out.push(el);
|
|
19184
19195
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -19219,7 +19230,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19219
19230
|
function makeLink(text, rawHref) {
|
|
19220
19231
|
if (!text) return "";
|
|
19221
19232
|
if (!rawHref) return text;
|
|
19222
|
-
const href =
|
|
19233
|
+
const href = _chunkDJKLOLBTcjs.sanitizeHref.call(void 0, rawHref);
|
|
19223
19234
|
return href ? `[${text}](${href})` : text;
|
|
19224
19235
|
}
|
|
19225
19236
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19321,7 +19332,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19321
19332
|
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19322
19333
|
if (!text) return null;
|
|
19323
19334
|
const style = styles.get(styleId);
|
|
19324
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
19335
|
+
if (_optionalChain([style, 'optionalAccess', _166 => _166.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
19325
19336
|
return {
|
|
19326
19337
|
type: "heading",
|
|
19327
19338
|
text,
|
|
@@ -19330,8 +19341,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19330
19341
|
}
|
|
19331
19342
|
if (numId && numId !== "0") {
|
|
19332
19343
|
const numDef = numbering.get(numId);
|
|
19333
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
19334
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
19344
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _167 => _167.get, 'call', _168 => _168(ilvl)]);
|
|
19345
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _169 => _169.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
19335
19346
|
return { type: "list", text, listType };
|
|
19336
19347
|
}
|
|
19337
19348
|
const block = { type: "paragraph", text };
|
|
@@ -19413,7 +19424,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19413
19424
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19414
19425
|
})
|
|
19415
19426
|
);
|
|
19416
|
-
const table2 =
|
|
19427
|
+
const table2 = _chunkUSGC3ZKUcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19417
19428
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19418
19429
|
return { type: "table", table: table2 };
|
|
19419
19430
|
}
|
|
@@ -19423,10 +19434,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19423
19434
|
for (const el of effectiveChildElements(tc2)) {
|
|
19424
19435
|
if (matchesLocal(el, "p")) {
|
|
19425
19436
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19426
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
19437
|
+
if (_optionalChain([block, 'optionalAccess', _170 => _170.text])) parts.push(block.text);
|
|
19427
19438
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19428
19439
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19429
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
19440
|
+
if (_optionalChain([tb, 'optionalAccess', _171 => _171.text])) parts.push(tb.text);
|
|
19430
19441
|
}
|
|
19431
19442
|
} else if (matchesLocal(el, "tbl")) {
|
|
19432
19443
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -19461,7 +19472,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19461
19472
|
try {
|
|
19462
19473
|
const data = await imgFile.async("uint8array");
|
|
19463
19474
|
imgIdx++;
|
|
19464
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
19475
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _172 => _172.split, 'call', _173 => _173("."), 'access', _174 => _174.pop, 'call', _175 => _175(), 'optionalAccess', _176 => _176.toLowerCase, 'call', _177 => _177()]), () => ( "png"));
|
|
19465
19476
|
const mimeMap = {
|
|
19466
19477
|
png: "image/png",
|
|
19467
19478
|
jpg: "image/jpeg",
|
|
@@ -19515,12 +19526,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19515
19526
|
}
|
|
19516
19527
|
}
|
|
19517
19528
|
async function parseDocxDocument(buffer, options) {
|
|
19518
|
-
|
|
19529
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19519
19530
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19520
19531
|
const warnings = [];
|
|
19521
19532
|
const docFile = zip.file("word/document.xml");
|
|
19522
19533
|
if (!docFile) {
|
|
19523
|
-
throw new (0,
|
|
19534
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19524
19535
|
}
|
|
19525
19536
|
let rels = /* @__PURE__ */ new Map();
|
|
19526
19537
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19567,7 +19578,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19567
19578
|
const doc = parseXml2(docXml);
|
|
19568
19579
|
const body = findElements(doc, "body");
|
|
19569
19580
|
if (body.length === 0) {
|
|
19570
|
-
throw new (0,
|
|
19581
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19571
19582
|
}
|
|
19572
19583
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19573
19584
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19575,7 +19586,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19575
19586
|
const bodyEl = body[0];
|
|
19576
19587
|
const topLevel = effectiveChildElements(bodyEl);
|
|
19577
19588
|
for (const el of topLevel) {
|
|
19578
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
19589
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _178 => _178.tagName, 'optionalAccess', _179 => _179.split, 'call', _180 => _180(":"), 'access', _181 => _181.pop, 'call', _182 => _182()])));
|
|
19579
19590
|
if (localName2 === "p") {
|
|
19580
19591
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19581
19592
|
if (block) blocks.push(block);
|
|
@@ -19586,7 +19597,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19586
19597
|
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19587
19598
|
}
|
|
19588
19599
|
} else if (localName2 === "tbl") {
|
|
19589
|
-
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess',
|
|
19600
|
+
const block = parseTable(el, styles, numbering, footnotes, rels, _optionalChain([options, 'optionalAccess', _183 => _183.keepTrailingEmptyCols]));
|
|
19590
19601
|
if (block) blocks.push(block);
|
|
19591
19602
|
}
|
|
19592
19603
|
}
|
|
@@ -19618,7 +19629,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19618
19629
|
}
|
|
19619
19630
|
}
|
|
19620
19631
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19621
|
-
const markdown =
|
|
19632
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19622
19633
|
return {
|
|
19623
19634
|
markdown,
|
|
19624
19635
|
blocks,
|
|
@@ -19636,11 +19647,11 @@ var MAX_TABLE_COLS = 500;
|
|
|
19636
19647
|
var MAX_HWPML_BYTES = 50 * 1024 * 1024;
|
|
19637
19648
|
function parseHwpmlDocument(buffer, options) {
|
|
19638
19649
|
if (buffer.byteLength > MAX_HWPML_BYTES) {
|
|
19639
|
-
throw new (0,
|
|
19650
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`HWPML \uD30C\uC77C \uD06C\uAE30 \uCD08\uACFC (${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB > 50MB)`);
|
|
19640
19651
|
}
|
|
19641
19652
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19642
19653
|
const normalized = text.replace(/ /g, " ");
|
|
19643
|
-
const xml =
|
|
19654
|
+
const xml = _chunkDJKLOLBTcjs.stripDtd.call(void 0, normalized);
|
|
19644
19655
|
const warnings = [];
|
|
19645
19656
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19646
19657
|
onError: (_level, msg2) => {
|
|
@@ -19668,7 +19679,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19668
19679
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19669
19680
|
}
|
|
19670
19681
|
const blocks = [];
|
|
19671
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
19682
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _184 => _184.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
19672
19683
|
let sectionIdx = 0;
|
|
19673
19684
|
const children = body.childNodes;
|
|
19674
19685
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -19677,10 +19688,10 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19677
19688
|
if (localName(el) !== "SECTION") continue;
|
|
19678
19689
|
sectionIdx++;
|
|
19679
19690
|
if (pageFilter && !pageFilter.has(sectionIdx)) continue;
|
|
19680
|
-
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
19691
|
+
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _185 => _185.keepTrailingEmptyCols]), () => ( false)));
|
|
19681
19692
|
}
|
|
19682
19693
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
19683
|
-
const markdown =
|
|
19694
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19684
19695
|
return {
|
|
19685
19696
|
markdown,
|
|
19686
19697
|
blocks,
|
|
@@ -19766,7 +19777,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
19766
19777
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
19767
19778
|
const text = extractParagraphText(el);
|
|
19768
19779
|
if (!text) return;
|
|
19769
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
19780
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _186 => _186.headingLevel]) != null) {
|
|
19770
19781
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
19771
19782
|
} else {
|
|
19772
19783
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -19845,11 +19856,11 @@ function buildHmlTable(el, warnings, keep, tableDepth) {
|
|
|
19845
19856
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
19846
19857
|
cellRows[r].push(cell2);
|
|
19847
19858
|
}
|
|
19848
|
-
const table2 =
|
|
19859
|
+
const table2 = _chunkUSGC3ZKUcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
19849
19860
|
if (structured.length > 0) {
|
|
19850
19861
|
const claimed = /* @__PURE__ */ new Set();
|
|
19851
19862
|
for (const { ctx, cellBlocks } of structured) {
|
|
19852
|
-
let target = _optionalChain([table2, 'access',
|
|
19863
|
+
let target = _optionalChain([table2, 'access', _187 => _187.cells, 'access', _188 => _188[_nullishCoalesce(ctx.rowAddr, () => ( -1))], 'optionalAccess', _189 => _189[_nullishCoalesce(ctx.colAddr, () => ( -1))]]);
|
|
19853
19864
|
if (!target || claimed.has(target) || target.text !== ctx.text) {
|
|
19854
19865
|
target = void 0;
|
|
19855
19866
|
outer: for (const irRow of table2.cells) {
|
|
@@ -20153,7 +20164,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
20153
20164
|
(match, prefix, suffix) => {
|
|
20154
20165
|
const label = prefix + suffix;
|
|
20155
20166
|
const normalizedLabel = normalizeLabel(label);
|
|
20156
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20167
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _190 => _190.has, 'call', _191 => _191(normalizedLabel)])) return match;
|
|
20157
20168
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
20158
20169
|
if (matchKey === void 0) return match;
|
|
20159
20170
|
const newValue = values.consume(matchKey);
|
|
@@ -20232,17 +20243,17 @@ function matchInlineSegment(seg, values, blockedLabels) {
|
|
|
20232
20243
|
const nlabel = normalizeLabel(seg.label);
|
|
20233
20244
|
if (seg.extLabel !== void 0) {
|
|
20234
20245
|
const nExt = normalizeLabel(seg.extLabel);
|
|
20235
|
-
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess',
|
|
20246
|
+
if (nExt !== nlabel && !_optionalChain([blockedLabels, 'optionalAccess', _192 => _192.has, 'call', _193 => _193(nExt)]) && values.has(nExt)) {
|
|
20236
20247
|
return { key: nExt, label: seg.extLabel, viaExt: true };
|
|
20237
20248
|
}
|
|
20238
20249
|
}
|
|
20239
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20250
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _194 => _194.has, 'call', _195 => _195(nlabel)])) return void 0;
|
|
20240
20251
|
const key = findMatchingKey(nlabel, values);
|
|
20241
20252
|
return key !== void 0 ? { key, label: seg.label, viaExt: false } : void 0;
|
|
20242
20253
|
}
|
|
20243
20254
|
function clampSegmentEnd(text, seg, next, nextViaExt) {
|
|
20244
20255
|
let ve = seg.valueEnd;
|
|
20245
|
-
if (nextViaExt && _optionalChain([next, 'optionalAccess',
|
|
20256
|
+
if (nextViaExt && _optionalChain([next, 'optionalAccess', _196 => _196.extStart]) !== void 0 && next.extStart < ve) ve = next.extStart;
|
|
20246
20257
|
while (ve > seg.valueStart && /\s/.test(text[ve - 1])) ve--;
|
|
20247
20258
|
return ve;
|
|
20248
20259
|
}
|
|
@@ -20257,7 +20268,7 @@ function normalizeValues(values, warnings) {
|
|
|
20257
20268
|
const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
|
|
20258
20269
|
const key = normalizeLabel(label);
|
|
20259
20270
|
if (map.has(key)) {
|
|
20260
|
-
_optionalChain([warnings, 'optionalAccess',
|
|
20271
|
+
_optionalChain([warnings, 'optionalAccess', _197 => _197.push, 'call', _198 => _198(`\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`)]);
|
|
20261
20272
|
}
|
|
20262
20273
|
map.set(key, Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
|
|
20263
20274
|
}
|
|
@@ -20434,8 +20445,8 @@ function extractFromTable(table2) {
|
|
|
20434
20445
|
if (table2.cols >= 2) {
|
|
20435
20446
|
for (let r = 0; r < table2.rows; r++) {
|
|
20436
20447
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
20437
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20438
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20448
|
+
const labelCell = _optionalChain([table2, 'access', _199 => _199.cells, 'access', _200 => _200[r], 'optionalAccess', _201 => _201[c]]);
|
|
20449
|
+
const valueCell = _optionalChain([table2, 'access', _202 => _202.cells, 'access', _203 => _203[r], 'optionalAccess', _204 => _204[c + 1]]);
|
|
20439
20450
|
if (!labelCell || !valueCell) continue;
|
|
20440
20451
|
if (isLabelCell(labelCell.text)) {
|
|
20441
20452
|
fields.push({
|
|
@@ -20450,15 +20461,15 @@ function extractFromTable(table2) {
|
|
|
20450
20461
|
}
|
|
20451
20462
|
if (fields.length === 0 && table2.rows >= 2 && table2.cols >= 2) {
|
|
20452
20463
|
const headerRow = table2.cells[0];
|
|
20453
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20454
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20464
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _205 => _205.every, 'call', _206 => _206((cell2) => {
|
|
20465
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _207 => _207.text, 'access', _208 => _208.trim, 'call', _209 => _209()]), () => ( ""));
|
|
20455
20466
|
return t.length > 0 && t.length <= 20;
|
|
20456
20467
|
})]), () => ( false));
|
|
20457
20468
|
if (allLabels) {
|
|
20458
20469
|
for (let r = 1; r < table2.rows; r++) {
|
|
20459
20470
|
for (let c = 0; c < table2.cols; c++) {
|
|
20460
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
20461
|
-
const value = _nullishCoalesce(_optionalChain([table2, 'access',
|
|
20471
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _210 => _210[c], 'optionalAccess', _211 => _211.text, 'access', _212 => _212.trim, 'call', _213 => _213()]), () => ( ""));
|
|
20472
|
+
const value = _nullishCoalesce(_optionalChain([table2, 'access', _214 => _214.cells, 'access', _215 => _215[r], 'optionalAccess', _216 => _216[c], 'optionalAccess', _217 => _217.text, 'access', _218 => _218.trim, 'call', _219 => _219()]), () => ( ""));
|
|
20462
20473
|
if (label && value) {
|
|
20463
20474
|
fields.push({ label, value, row: r, col: c });
|
|
20464
20475
|
}
|
|
@@ -20552,7 +20563,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
20552
20563
|
for (const table2 of allTables) {
|
|
20553
20564
|
for (let r = 0; r < table2.rows; r++) {
|
|
20554
20565
|
for (let c = 0; c < table2.cols; c++) {
|
|
20555
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20566
|
+
const cell2 = _optionalChain([table2, 'access', _220 => _220.cells, 'access', _221 => _221[r], 'optionalAccess', _222 => _222[c]]);
|
|
20556
20567
|
if (!cell2) continue;
|
|
20557
20568
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
20558
20569
|
if (result) {
|
|
@@ -20584,7 +20595,7 @@ function collectIRTables(blocks, depth) {
|
|
|
20584
20595
|
out.push(block.table);
|
|
20585
20596
|
for (const row of block.table.cells) {
|
|
20586
20597
|
for (const cell2 of row) {
|
|
20587
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
20598
|
+
if (_optionalChain([cell2, 'optionalAccess', _223 => _223.blocks, 'optionalAccess', _224 => _224.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
20588
20599
|
}
|
|
20589
20600
|
}
|
|
20590
20601
|
}
|
|
@@ -20595,7 +20606,7 @@ function coveredPositions(table2) {
|
|
|
20595
20606
|
for (let r = 0; r < table2.rows; r++) {
|
|
20596
20607
|
for (let c = 0; c < table2.cols; c++) {
|
|
20597
20608
|
if (covered.has(`${r},${c}`)) continue;
|
|
20598
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20609
|
+
const cell2 = _optionalChain([table2, 'access', _225 => _225.cells, 'access', _226 => _226[r], 'optionalAccess', _227 => _227[c]]);
|
|
20599
20610
|
if (!cell2) continue;
|
|
20600
20611
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
20601
20612
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -20611,15 +20622,15 @@ function coveredPositions(table2) {
|
|
|
20611
20622
|
function isHeaderDataTable(table2, covered) {
|
|
20612
20623
|
if (table2.rows < 2) return false;
|
|
20613
20624
|
const headerRow = table2.cells[0];
|
|
20614
|
-
if (!_optionalChain([headerRow, 'optionalAccess',
|
|
20625
|
+
if (!_optionalChain([headerRow, 'optionalAccess', _228 => _228.length])) return false;
|
|
20615
20626
|
const allLabels = headerRow.every((cell2) => {
|
|
20616
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20627
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _229 => _229.text, 'access', _230 => _230.trim, 'call', _231 => _231()]), () => ( ""));
|
|
20617
20628
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20618
20629
|
});
|
|
20619
20630
|
if (!allLabels) return false;
|
|
20620
20631
|
for (let c = 0; c < table2.cols; c++) {
|
|
20621
20632
|
if (covered.has(`1,${c}`)) continue;
|
|
20622
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20633
|
+
const cell2 = _optionalChain([table2, 'access', _232 => _232.cells, 'access', _233 => _233[1], 'optionalAccess', _234 => _234[c]]);
|
|
20623
20634
|
if (!cell2) break;
|
|
20624
20635
|
return !isLabelCell(cell2.text);
|
|
20625
20636
|
}
|
|
@@ -20632,7 +20643,7 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20632
20643
|
for (let r = skipHeaderRow ? 1 : 0; r < table2.rows; r++) {
|
|
20633
20644
|
for (let c = 0; c < table2.cols; c++) {
|
|
20634
20645
|
if (covered.has(`${r},${c}`)) continue;
|
|
20635
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20646
|
+
const labelCell = _optionalChain([table2, 'access', _235 => _235.cells, 'access', _236 => _236[r], 'optionalAccess', _237 => _237[c]]);
|
|
20636
20647
|
if (!labelCell) continue;
|
|
20637
20648
|
if (!isLabelCell(labelCell.text)) continue;
|
|
20638
20649
|
let vc = c + labelCell.colSpan;
|
|
@@ -20643,12 +20654,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20643
20654
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
20644
20655
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
20645
20656
|
if (!normalizedCellLabel) continue;
|
|
20646
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20657
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _238 => _238.has, 'call', _239 => _239(normalizedCellLabel)])) continue;
|
|
20647
20658
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
20648
20659
|
if (matchKey === void 0) continue;
|
|
20649
20660
|
const newValue = values.consume(matchKey);
|
|
20650
20661
|
if (newValue === void 0) continue;
|
|
20651
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20662
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _240 => _240.has, 'call', _241 => _241(valueCell)])) {
|
|
20652
20663
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20653
20664
|
} else {
|
|
20654
20665
|
valueCell.text = newValue;
|
|
@@ -20665,8 +20676,8 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20665
20676
|
}
|
|
20666
20677
|
if (table2.rows >= 2 && table2.cols >= 2) {
|
|
20667
20678
|
const headerRow = table2.cells[0];
|
|
20668
|
-
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess',
|
|
20669
|
-
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess',
|
|
20679
|
+
const allLabels = _nullishCoalesce(_optionalChain([headerRow, 'optionalAccess', _242 => _242.every, 'call', _243 => _243((cell2) => {
|
|
20680
|
+
const t = _nullishCoalesce(_optionalChain([cell2, 'optionalAccess', _244 => _244.text, 'access', _245 => _245.trim, 'call', _246 => _246()]), () => ( ""));
|
|
20670
20681
|
return t.length > 0 && t.length <= 20 && isLabelCell(t);
|
|
20671
20682
|
})]), () => ( false));
|
|
20672
20683
|
if (!allLabels) return;
|
|
@@ -20674,16 +20685,16 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20674
20685
|
for (let c = 0; c < table2.cols; c++) {
|
|
20675
20686
|
if (covered.has(`${r},${c}`)) continue;
|
|
20676
20687
|
const headerCell = headerRow[c];
|
|
20677
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20688
|
+
const valueCell = _optionalChain([table2, 'access', _247 => _247.cells, 'access', _248 => _248[r], 'optionalAccess', _249 => _249[c]]);
|
|
20678
20689
|
if (!headerCell || !valueCell) continue;
|
|
20679
20690
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
20680
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20691
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _250 => _250.has, 'call', _251 => _251(headerLabel)])) continue;
|
|
20681
20692
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
20682
20693
|
if (matchKey === void 0) continue;
|
|
20683
20694
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
20684
20695
|
const newValue = values.consume(matchKey);
|
|
20685
20696
|
if (newValue === void 0) continue;
|
|
20686
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20697
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _252 => _252.has, 'call', _253 => _253(valueCell)])) {
|
|
20687
20698
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20688
20699
|
} else {
|
|
20689
20700
|
valueCell.text = newValue;
|
|
@@ -20715,7 +20726,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
20715
20726
|
if (newValue === void 0) continue;
|
|
20716
20727
|
matchedLabels.add(matchKey);
|
|
20717
20728
|
filled.push({ label: matched.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
|
|
20718
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
20729
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _254 => _254[i + 1], 'optionalAccess', _255 => _255.viaExt]), () => ( false)));
|
|
20719
20730
|
out += text.slice(pos, seg.valueStart);
|
|
20720
20731
|
out += seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
20721
20732
|
pos = ve;
|
|
@@ -21338,7 +21349,7 @@ function fillClickHereInXml(xml, cursor, blockedLabels) {
|
|
|
21338
21349
|
const splices = [];
|
|
21339
21350
|
for (const region of scanClickHereRegions(xml)) {
|
|
21340
21351
|
const key = normalizeLabel(region.name);
|
|
21341
|
-
if (!key || _optionalChain([blockedLabels, 'optionalAccess',
|
|
21352
|
+
if (!key || _optionalChain([blockedLabels, 'optionalAccess', _256 => _256.has, 'call', _257 => _257(key)])) continue;
|
|
21342
21353
|
if (!cursor.has(key)) continue;
|
|
21343
21354
|
const value = cursor.consume(key);
|
|
21344
21355
|
if (value === void 0) continue;
|
|
@@ -21356,7 +21367,7 @@ function fillClickHereInXml(xml, cursor, blockedLabels) {
|
|
|
21356
21367
|
};
|
|
21357
21368
|
}
|
|
21358
21369
|
async function extractClickHereFields(hwpxBuffer) {
|
|
21359
|
-
|
|
21370
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21360
21371
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21361
21372
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21362
21373
|
const fields = [];
|
|
@@ -21404,19 +21415,19 @@ function parseCentralDirectory(buf) {
|
|
|
21404
21415
|
}
|
|
21405
21416
|
}
|
|
21406
21417
|
}
|
|
21407
|
-
if (eocdOffset < 0) throw new (0,
|
|
21418
|
+
if (eocdOffset < 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21408
21419
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21409
21420
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21410
21421
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21411
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21422
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21412
21423
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21413
|
-
throw new (0,
|
|
21424
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21414
21425
|
}
|
|
21415
21426
|
const decoder = new TextDecoder("utf-8");
|
|
21416
21427
|
const entries = [];
|
|
21417
21428
|
let pos = cdOffset;
|
|
21418
21429
|
for (let i = 0; i < totalEntries; i++) {
|
|
21419
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21430
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21420
21431
|
const flags = view.getUint16(pos + 8, true);
|
|
21421
21432
|
const method = view.getUint16(pos + 10, true);
|
|
21422
21433
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21427,7 +21438,7 @@ function parseCentralDirectory(buf) {
|
|
|
21427
21438
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21428
21439
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21429
21440
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21430
|
-
throw new (0,
|
|
21441
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21431
21442
|
}
|
|
21432
21443
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21433
21444
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21456,11 +21467,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21456
21467
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21457
21468
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21458
21469
|
for (const name of replacements.keys()) {
|
|
21459
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21470
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkDJKLOLBTcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21460
21471
|
}
|
|
21461
21472
|
if (additions) {
|
|
21462
21473
|
for (const name of additions.keys()) {
|
|
21463
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21474
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkDJKLOLBTcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21464
21475
|
}
|
|
21465
21476
|
}
|
|
21466
21477
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21479,7 +21490,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21479
21490
|
offset += seg.length;
|
|
21480
21491
|
continue;
|
|
21481
21492
|
}
|
|
21482
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21493
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkDJKLOLBTcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21483
21494
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21484
21495
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21485
21496
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21487,7 +21498,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21487
21498
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21488
21499
|
const method = e.method;
|
|
21489
21500
|
if (method !== 0 && method !== 8) {
|
|
21490
|
-
throw new (0,
|
|
21501
|
+
throw new (0, _chunkDJKLOLBTcjs.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`);
|
|
21491
21502
|
}
|
|
21492
21503
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21493
21504
|
const crc = crc32(newData);
|
|
@@ -21585,11 +21596,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21585
21596
|
// src/form/filler-hwpx.ts
|
|
21586
21597
|
async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
21587
21598
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
21588
|
-
|
|
21599
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21589
21600
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21590
21601
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21591
21602
|
if (sectionPaths.length === 0) {
|
|
21592
|
-
throw new (0,
|
|
21603
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21593
21604
|
}
|
|
21594
21605
|
const warnings = [];
|
|
21595
21606
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -21688,7 +21699,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21688
21699
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
21689
21700
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
21690
21701
|
if (!normalizedCellLabel) continue;
|
|
21691
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21702
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _258 => _258.has, 'call', _259 => _259(normalizedCellLabel)])) continue;
|
|
21692
21703
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
21693
21704
|
if (matchKey === void 0) continue;
|
|
21694
21705
|
if (patternApplied.has(valueCell)) {
|
|
@@ -21746,7 +21757,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21746
21757
|
const dataCells = table2.rows[rowIdx];
|
|
21747
21758
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
21748
21759
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
21749
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21760
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _260 => _260.has, 'call', _261 => _261(headerLabel)])) continue;
|
|
21750
21761
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
21751
21762
|
if (matchKey === void 0) continue;
|
|
21752
21763
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -21800,7 +21811,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21800
21811
|
}
|
|
21801
21812
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
21802
21813
|
const existing = ledger.get(para2);
|
|
21803
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
21814
|
+
if (_optionalChain([existing, 'optionalAccess', _262 => _262.fullText]) !== void 0) continue;
|
|
21804
21815
|
const text = matchText(para2);
|
|
21805
21816
|
const segments = scanInlineSegments(text);
|
|
21806
21817
|
const matches = segments.map((seg) => matchInlineSegment(seg, cursor, blockedLabels));
|
|
@@ -21811,7 +21822,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21811
21822
|
const matchKey = matched.key;
|
|
21812
21823
|
const newValue = cursor.consume(matchKey);
|
|
21813
21824
|
if (newValue === void 0) continue;
|
|
21814
|
-
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access',
|
|
21825
|
+
const ve = clampSegmentEnd(text, seg, segments[i + 1], _nullishCoalesce(_optionalChain([matches, 'access', _263 => _263[i + 1], 'optionalAccess', _264 => _264.viaExt]), () => ( false)));
|
|
21815
21826
|
const replacement = seg.valueStart === ve ? padInsertion(text, seg.valueStart, newValue) : newValue;
|
|
21816
21827
|
const l = led(para2);
|
|
21817
21828
|
l.ranges.push({ start: seg.valueStart, end: ve, replacement });
|
|
@@ -22052,9 +22063,9 @@ function fixedPitchWidthEm1000(cp) {
|
|
|
22052
22063
|
return cp < 128 ? 500 : 1e3;
|
|
22053
22064
|
}
|
|
22054
22065
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
22055
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
22056
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
22057
|
-
const widthEm = _optionalChain([opts, 'optionalAccess',
|
|
22066
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _265 => _265.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
22067
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _266 => _266.spacingPct]), () => ( 0));
|
|
22068
|
+
const widthEm = _optionalChain([opts, 'optionalAccess', _267 => _267.faceClass]) === "fixedPitch" ? fixedPitchWidthEm1000 : charWidthEm1000;
|
|
22058
22069
|
let em = 0;
|
|
22059
22070
|
for (const ch of text) {
|
|
22060
22071
|
const cp = ch.codePointAt(0);
|
|
@@ -22067,9 +22078,9 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
22067
22078
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
22068
22079
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
22069
22080
|
const EPS = 0.5;
|
|
22070
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
22071
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
22072
|
-
const widthEm = _optionalChain([opts, 'optionalAccess',
|
|
22081
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _268 => _268.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
22082
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _269 => _269.spacingPct]), () => ( 0));
|
|
22083
|
+
const widthEm = _optionalChain([opts, 'optionalAccess', _270 => _270.faceClass]) === "fixedPitch" ? fixedPitchWidthEm1000 : charWidthEm1000;
|
|
22073
22084
|
const k = height * ratioPct / 100 / 1e3;
|
|
22074
22085
|
const cwCp = (cp) => (cp === 32 ? spaceEm : widthEm(cp)) * (1 + spacing / 100) * k;
|
|
22075
22086
|
const charW2 = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -22331,7 +22342,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
22331
22342
|
}
|
|
22332
22343
|
function assertFiniteRange(name, value, min, max) {
|
|
22333
22344
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
22334
|
-
throw new (0,
|
|
22345
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
22335
22346
|
}
|
|
22336
22347
|
}
|
|
22337
22348
|
function validateGongmunOptions(opts) {
|
|
@@ -22346,10 +22357,10 @@ function validateGongmunOptions(opts) {
|
|
|
22346
22357
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
22347
22358
|
}
|
|
22348
22359
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
22349
|
-
throw new (0,
|
|
22360
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
22350
22361
|
}
|
|
22351
22362
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
22352
|
-
throw new (0,
|
|
22363
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
22353
22364
|
}
|
|
22354
22365
|
}
|
|
22355
22366
|
if (opts.sizes) {
|
|
@@ -22358,7 +22369,7 @@ function validateGongmunOptions(opts) {
|
|
|
22358
22369
|
}
|
|
22359
22370
|
}
|
|
22360
22371
|
if (opts.approval && opts.approval.length > 6) {
|
|
22361
|
-
throw new (0,
|
|
22372
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("approval must contain at most 6 labels");
|
|
22362
22373
|
}
|
|
22363
22374
|
}
|
|
22364
22375
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -22422,7 +22433,7 @@ function resolveGongmun(opts) {
|
|
|
22422
22433
|
suppressSingle: _nullishCoalesce(opts.suppressSingle, () => ( false)),
|
|
22423
22434
|
docHead: preset === "official" && opts.docHead ? opts.docHead : null,
|
|
22424
22435
|
docFoot: preset === "official" && opts.docFoot ? opts.docFoot : null,
|
|
22425
|
-
reportInfo: _optionalChain([opts, 'access',
|
|
22436
|
+
reportInfo: _optionalChain([opts, 'access', _271 => _271.reportInfo, 'optionalAccess', _272 => _272.trim, 'call', _273 => _273()]) || null,
|
|
22426
22437
|
noticeHead: preset === "notice" && opts.noticeHead ? opts.noticeHead : null,
|
|
22427
22438
|
// 보도자료 머리박스는 프리셋 자체가 요구 — 옵션 미지정이어도 빈 객체
|
|
22428
22439
|
press: preset === "press" ? _nullishCoalesce(opts.press, () => ( {})) : null
|
|
@@ -22531,16 +22542,16 @@ var PARA_LIST = 7;
|
|
|
22531
22542
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
22532
22543
|
function resolveTheme(theme) {
|
|
22533
22544
|
return {
|
|
22534
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22535
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22536
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22537
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22538
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22539
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22545
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _274 => _274.headingColors, 'optionalAccess', _275 => _275[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22546
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _276 => _276.headingColors, 'optionalAccess', _277 => _277[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22547
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _278 => _278.headingColors, 'optionalAccess', _279 => _279[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22548
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _280 => _280.headingColors, 'optionalAccess', _281 => _281[4]]), () => ( _optionalChain([theme, 'optionalAccess', _282 => _282.headingColors, 'optionalAccess', _283 => _283[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22549
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _284 => _284.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22550
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _285 => _285.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
22540
22551
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
22541
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
22542
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
22543
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
22552
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _286 => _286.quoteColor]) !== void 0,
|
|
22553
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _287 => _287.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _288 => _288.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
22554
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _289 => _289.tableHeaderBold])
|
|
22544
22555
|
};
|
|
22545
22556
|
}
|
|
22546
22557
|
function escapeXml(text) {
|
|
@@ -22881,6 +22892,7 @@ function parseInlineMarkdown(text) {
|
|
|
22881
22892
|
});
|
|
22882
22893
|
text = text.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
|
|
22883
22894
|
text = text.replace(/~~([^~]+)~~/g, "$1");
|
|
22895
|
+
text = text.replace(/<u>([^<]*)<\/u>/g, "$1");
|
|
22884
22896
|
let spans;
|
|
22885
22897
|
if (inlineDoc) {
|
|
22886
22898
|
spans = [];
|
|
@@ -22895,7 +22907,7 @@ function parseInlineMarkdown(text) {
|
|
|
22895
22907
|
else spans.push(...emphasisSpans(m[0]));
|
|
22896
22908
|
} else {
|
|
22897
22909
|
const anchor = m[2] || m[3];
|
|
22898
|
-
const href = _nullishCoalesce(
|
|
22910
|
+
const href = _nullishCoalesce(_chunkDJKLOLBTcjs.sanitizeHref.call(void 0, m[3].trim()), () => ( void 0));
|
|
22899
22911
|
const sub = emphasisSpans(anchor);
|
|
22900
22912
|
if (href) for (const s of sub) s.href = href;
|
|
22901
22913
|
spans.push(...sub);
|
|
@@ -23061,8 +23073,8 @@ function resolvePage(opts) {
|
|
|
23061
23073
|
// 실측: 용지 치수는 방향과 무관하게 유지, 방향은 landscape 속성만 바뀐다
|
|
23062
23074
|
landscape: orientation === "landscape" ? "NARROWLY" : "WIDELY",
|
|
23063
23075
|
columns: cols,
|
|
23064
|
-
header: _optionalChain([header, 'optionalAccess',
|
|
23065
|
-
footer: _optionalChain([footer, 'optionalAccess',
|
|
23076
|
+
header: _optionalChain([header, 'optionalAccess', _290 => _290.trim, 'call', _291 => _291()]) ? header.trim() : null,
|
|
23077
|
+
footer: _optionalChain([footer, 'optionalAccess', _292 => _292.trim, 'call', _293 => _293()]) ? footer.trim() : null
|
|
23066
23078
|
};
|
|
23067
23079
|
}
|
|
23068
23080
|
function columnColPrXml(columns) {
|
|
@@ -23109,7 +23121,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
23109
23121
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
23110
23122
|
const got = m ? Number(m[1]) : NaN;
|
|
23111
23123
|
if (got !== startId + i) {
|
|
23112
|
-
throw new (0,
|
|
23124
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
23113
23125
|
`\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)`
|
|
23114
23126
|
);
|
|
23115
23127
|
}
|
|
@@ -23193,7 +23205,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
23193
23205
|
}
|
|
23194
23206
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
23195
23207
|
if (rows.length !== expectedBase) {
|
|
23196
|
-
throw new (0,
|
|
23208
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
23197
23209
|
`\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`
|
|
23198
23210
|
);
|
|
23199
23211
|
}
|
|
@@ -23421,7 +23433,7 @@ function buildStyles(gongmun) {
|
|
|
23421
23433
|
</hh:styles>`;
|
|
23422
23434
|
}
|
|
23423
23435
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
23424
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
23436
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _294 => _294.fonts, 'access', _295 => _295.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _296 => _296.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
23425
23437
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
23426
23438
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
23427
23439
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -23550,8 +23562,8 @@ function parseChartFence(text) {
|
|
|
23550
23562
|
const spec = chartSpec(type);
|
|
23551
23563
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
23552
23564
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
23553
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
23554
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
23565
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _297 => _297.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
23566
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _298 => _298[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
23555
23567
|
if (!spec.scatter) {
|
|
23556
23568
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
23557
23569
|
}
|
|
@@ -23593,7 +23605,7 @@ function serSpPr(color, stroke) {
|
|
|
23593
23605
|
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>`;
|
|
23594
23606
|
}
|
|
23595
23607
|
function dPtXml(pointColors, pie) {
|
|
23596
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
23608
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _299 => _299.length])) return "";
|
|
23597
23609
|
return pointColors.map((col, i) => {
|
|
23598
23610
|
const f = chartColorFill(col);
|
|
23599
23611
|
if (!f) return "";
|
|
@@ -23832,8 +23844,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
23832
23844
|
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 });
|
|
23833
23845
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
23834
23846
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
23835
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23836
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23847
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _300 => _300.cover, 'optionalAccess', _301 => _301.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
23848
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _302 => _302.cover, 'optionalAccess', _303 => _303.org]), () => ( ""));
|
|
23837
23849
|
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>`;
|
|
23838
23850
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
23839
23851
|
return [
|
|
@@ -24089,7 +24101,7 @@ function escapeGfm(text) {
|
|
|
24089
24101
|
}
|
|
24090
24102
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
24091
24103
|
function sanitizeText(text) {
|
|
24092
|
-
let result =
|
|
24104
|
+
let result = _chunkUSGC3ZKUcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
24093
24105
|
if (result.length <= 30 && result.includes(" ")) {
|
|
24094
24106
|
const tokens = result.split(" ");
|
|
24095
24107
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -24119,7 +24131,7 @@ function replicateGfmTable(table2) {
|
|
|
24119
24131
|
for (let r = 0; r < numRows; r++) {
|
|
24120
24132
|
for (let c = 0; c < numCols; c++) {
|
|
24121
24133
|
if (skip.has(`${r},${c}`)) continue;
|
|
24122
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
24134
|
+
const cell2 = _optionalChain([cells, 'access', _304 => _304[r], 'optionalAccess', _305 => _305[c]]);
|
|
24123
24135
|
if (!cell2) continue;
|
|
24124
24136
|
display[r][c] = {
|
|
24125
24137
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -24173,7 +24185,7 @@ function unescapeGfmCell(text) {
|
|
|
24173
24185
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
|
|
24174
24186
|
}
|
|
24175
24187
|
function replicateCellInnerHtml(cell2) {
|
|
24176
|
-
if (_optionalChain([cell2, 'access',
|
|
24188
|
+
if (_optionalChain([cell2, 'access', _306 => _306.blocks, 'optionalAccess', _307 => _307.length])) {
|
|
24177
24189
|
return cell2.blocks.map((b) => {
|
|
24178
24190
|
if (b.type === "table" && b.table) {
|
|
24179
24191
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -24212,7 +24224,7 @@ function replicateHtmlTable(table2) {
|
|
|
24212
24224
|
const rowCells = [];
|
|
24213
24225
|
for (let c = 0; c < numCols; c++) {
|
|
24214
24226
|
if (skip.has(`${r},${c}`)) continue;
|
|
24215
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
24227
|
+
const cell2 = _optionalChain([cells, 'access', _308 => _308[r], 'optionalAccess', _309 => _309[c]]);
|
|
24216
24228
|
if (!cell2) continue;
|
|
24217
24229
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
24218
24230
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -24258,10 +24270,10 @@ function parseHtmlTable(raw) {
|
|
|
24258
24270
|
}
|
|
24259
24271
|
} else {
|
|
24260
24272
|
if (!isClose) {
|
|
24261
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
24262
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
24273
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _310 => _310.match, 'call', _311 => _311(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _312 => _312[1]]) || "1", 10);
|
|
24274
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _313 => _313.match, 'call', _314 => _314(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _315 => _315[1]]) || "1", 10);
|
|
24263
24275
|
cellStart = m.index + m[0].length;
|
|
24264
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
24276
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkUSGC3ZKUcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkUSGC3ZKUcjs.MAX_ROWS) };
|
|
24265
24277
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
24266
24278
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
24267
24279
|
cellStart = -1;
|
|
@@ -24285,7 +24297,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
24285
24297
|
hadNonText = true;
|
|
24286
24298
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
24287
24299
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
24288
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
24300
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _316 => _316[1]]), () => ( _optionalChain([m, 'optionalAccess', _317 => _317[2]])));
|
|
24289
24301
|
if (src) imgSrcs.push(src);
|
|
24290
24302
|
return "";
|
|
24291
24303
|
});
|
|
@@ -24428,7 +24440,7 @@ function edgeXml(tag, d) {
|
|
|
24428
24440
|
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"/>`;
|
|
24429
24441
|
}
|
|
24430
24442
|
function borderFillDefToXml(id, def) {
|
|
24431
|
-
const fill = _optionalChain([def, 'access',
|
|
24443
|
+
const fill = _optionalChain([def, 'access', _318 => _318.fill, 'optionalAccess', _319 => _319.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
24432
24444
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
24433
24445
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
24434
24446
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -24744,7 +24756,7 @@ var ImageRegistry = (_class5 = class {
|
|
|
24744
24756
|
}
|
|
24745
24757
|
/** 실데이터 등록 — images 맵 바이트·data: URI. 포맷 미상(webp 등)은 null → placeholder 폴백 */
|
|
24746
24758
|
takeReal(url) {
|
|
24747
|
-
let bytes = _optionalChain([this, 'access',
|
|
24759
|
+
let bytes = _optionalChain([this, 'access', _320 => _320.supplied, 'optionalAccess', _321 => _321.get, 'call', _322 => _322(url)]);
|
|
24748
24760
|
if (!bytes && url.startsWith("data:")) {
|
|
24749
24761
|
const m = /^data:image\/[a-z+]+;base64,([A-Za-z0-9+/=\s]+)$/i.exec(url);
|
|
24750
24762
|
if (m) {
|
|
@@ -24919,11 +24931,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
24919
24931
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
24920
24932
|
const rowCnt = rows.length;
|
|
24921
24933
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
24922
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24934
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _323 => _323.bfRegistry]), () => ( null));
|
|
24923
24935
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
24924
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24936
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _324 => _324.charHeight]), () => ( 1e3));
|
|
24925
24937
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
24926
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
24938
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _325 => _325[0], 'optionalAccess', _326 => _326[0]]), () => ( ""))), seq, rowAnchor);
|
|
24927
24939
|
const colMax = Array(colCnt).fill(0);
|
|
24928
24940
|
const colMaxBody = Array(colCnt).fill(0);
|
|
24929
24941
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -24951,7 +24963,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24951
24963
|
const k = `${rowIdx},${colIdx}`;
|
|
24952
24964
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
24953
24965
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
24954
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24966
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _327 => _327.cellChar, 'access', _328 => _328.get, 'call', _329 => _329(k)]), () => ( defaultCharPr));
|
|
24955
24967
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
24956
24968
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24957
24969
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -24969,11 +24981,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24969
24981
|
}
|
|
24970
24982
|
}
|
|
24971
24983
|
}
|
|
24972
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
24984
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _330 => _330.cellChar, 'access', _331 => _331.has, 'call', _332 => _332(k)]) ? void 0 : mapId);
|
|
24973
24985
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
24974
24986
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
24975
24987
|
}).join("");
|
|
24976
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24988
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _333 => _333.cellBf, 'access', _334 => _334.get, 'call', _335 => _335(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24977
24989
|
row: rowIdx,
|
|
24978
24990
|
rowEnd: rowIdx,
|
|
24979
24991
|
col: colIdx,
|
|
@@ -24983,7 +24995,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24983
24995
|
headerRows: 1,
|
|
24984
24996
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
24985
24997
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
24986
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24998
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _336 => _336.cellH, 'access', _337 => _337.get, 'call', _338 => _338(k)]), () => ( cellH));
|
|
24987
24999
|
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>`;
|
|
24988
25000
|
}).join("");
|
|
24989
25001
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -24992,7 +25004,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24992
25004
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
24993
25005
|
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;
|
|
24994
25006
|
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>`;
|
|
24995
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
25007
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _339 => _339.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
24996
25008
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
24997
25009
|
}
|
|
24998
25010
|
function layoutHtmlRows(rows) {
|
|
@@ -25003,8 +25015,8 @@ function layoutHtmlRows(rows) {
|
|
|
25003
25015
|
let c = 0;
|
|
25004
25016
|
for (const cell2 of rows[r].cells) {
|
|
25005
25017
|
while (occupied.has(`${r},${c}`)) c++;
|
|
25006
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
25007
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
25018
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkUSGC3ZKUcjs.MAX_COLS);
|
|
25019
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkUSGC3ZKUcjs.MAX_ROWS);
|
|
25008
25020
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
25009
25021
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
25010
25022
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -25032,7 +25044,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
25032
25044
|
if (!rows || rows.length === 0) return null;
|
|
25033
25045
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
25034
25046
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
25035
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
25047
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _340 => _340.charHeight]), () => ( 1e3));
|
|
25036
25048
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
25037
25049
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
25038
25050
|
for (const cell2 of placed) {
|
|
@@ -25061,7 +25073,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
25061
25073
|
const tblId = nextTableId();
|
|
25062
25074
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
25063
25075
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
25064
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
25076
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _341 => _341.bfRegistry]), () => ( null));
|
|
25065
25077
|
let htmlHeaderRows = 0;
|
|
25066
25078
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
25067
25079
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -25075,7 +25087,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
25075
25087
|
const nestedW = Math.max(Math.min(Math.max(sw - 1020, 4e3), sw - 282), 500);
|
|
25076
25088
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
25077
25089
|
if (nestedXml) {
|
|
25078
|
-
const szH = _optionalChain([nestedXml, 'access',
|
|
25090
|
+
const szH = _optionalChain([nestedXml, 'access', _342 => _342.match, 'call', _343 => _343(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _344 => _344[1]]);
|
|
25079
25091
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
25080
25092
|
}
|
|
25081
25093
|
return nestedXml;
|
|
@@ -25086,7 +25098,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
25086
25098
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
25087
25099
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
25088
25100
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
25089
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
25101
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _345 => _345.cellH, 'access', _346 => _346.get, 'call', _347 => _347(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
|
|
25090
25102
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
25091
25103
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
25092
25104
|
return { cell: cell2, rowSpan, lines, nestedXmls, segLines, imgSrcs: cellParsed[i].imgSrcs };
|
|
@@ -25097,7 +25109,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
25097
25109
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
25098
25110
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
25099
25111
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
25100
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
25112
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _348 => _348.cellChar, 'access', _349 => _349.get, 'call', _350 => _350(k)]), () => ( defaultCharPr));
|
|
25101
25113
|
const centered = isHeader || colCentered[cell2.c];
|
|
25102
25114
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
25103
25115
|
const picUrls = images ? [...imgSrcs] : [];
|
|
@@ -25137,7 +25149,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
25137
25149
|
let cellHeight = 0;
|
|
25138
25150
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
25139
25151
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
25140
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
25152
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _351 => _351.cellBf, 'access', _352 => _352.get, 'call', _353 => _353(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
25141
25153
|
row: cell2.r,
|
|
25142
25154
|
rowEnd,
|
|
25143
25155
|
col: cell2.c,
|
|
@@ -25307,7 +25319,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
25307
25319
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
25308
25320
|
}
|
|
25309
25321
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
25310
|
-
const c = _optionalChain([g, 'access',
|
|
25322
|
+
const c = _optionalChain([g, 'access', _354 => _354.press, 'optionalAccess', _355 => _355.contact]);
|
|
25311
25323
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
25312
25324
|
const w = bodyWidth - 280;
|
|
25313
25325
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -25686,10 +25698,10 @@ function generateSecPr(gongmun, page = null) {
|
|
|
25686
25698
|
m.header = gongmun.headerFooter;
|
|
25687
25699
|
m.footer = gongmun.headerFooter;
|
|
25688
25700
|
}
|
|
25689
|
-
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="${_nullishCoalesce(_optionalChain([page, 'optionalAccess',
|
|
25690
|
-
const colPr = columnColPrXml(_nullishCoalesce(_optionalChain([page, 'optionalAccess',
|
|
25691
|
-
const hf = (_optionalChain([page, 'optionalAccess',
|
|
25692
|
-
return secPr + colPr + hf + (_optionalChain([gongmun, 'optionalAccess',
|
|
25701
|
+
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="${_nullishCoalesce(_optionalChain([page, 'optionalAccess', _356 => _356.landscape]), () => ( "WIDELY"))}" width="${_nullishCoalesce(_optionalChain([page, 'optionalAccess', _357 => _357.widthHU]), () => ( A4_W_HU))}" height="${_nullishCoalesce(_optionalChain([page, 'optionalAccess', _358 => _358.heightHU]), () => ( 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>`;
|
|
25702
|
+
const colPr = columnColPrXml(_nullishCoalesce(_optionalChain([page, 'optionalAccess', _359 => _359.columns]), () => ( 1)));
|
|
25703
|
+
const hf = (_optionalChain([page, 'optionalAccess', _360 => _360.header]) ? headerFooterCtrl("header", page.header, 1) : "") + (_optionalChain([page, 'optionalAccess', _361 => _361.footer]) ? headerFooterCtrl("footer", page.footer, 2) : "");
|
|
25704
|
+
return secPr + colPr + hf + (_optionalChain([gongmun, 'optionalAccess', _362 => _362.pageNumbers]) ? pageNumCtrl() : "");
|
|
25693
25705
|
}
|
|
25694
25706
|
var SectionOpener = (_class6 = class {
|
|
25695
25707
|
constructor(gongmun, page = null) {;_class6.prototype.__init13.call(this);
|
|
@@ -25729,19 +25741,19 @@ function buildPreamble(blocks, ctx) {
|
|
|
25729
25741
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
25730
25742
|
const preamble = [];
|
|
25731
25743
|
let hasFrontPages = false;
|
|
25732
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25744
|
+
if (_optionalChain([gongmun, 'optionalAccess', _363 => _363.reportInfo]) && dfIds) {
|
|
25733
25745
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
25734
25746
|
}
|
|
25735
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25747
|
+
if (_optionalChain([gongmun, 'optionalAccess', _364 => _364.approval]) && bfReg) {
|
|
25736
25748
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
25737
25749
|
}
|
|
25738
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25750
|
+
if (_optionalChain([gongmun, 'optionalAccess', _365 => _365.docHead]) && dfIds) {
|
|
25739
25751
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
25740
25752
|
}
|
|
25741
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25753
|
+
if (_optionalChain([gongmun, 'optionalAccess', _366 => _366.noticeHead]) && dfIds) {
|
|
25742
25754
|
preamble.push(...buildNoticeHead(gongmun));
|
|
25743
25755
|
}
|
|
25744
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25756
|
+
if (_optionalChain([gongmun, 'optionalAccess', _367 => _367.press]) && dfIds && bfReg && tableStyle) {
|
|
25745
25757
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25746
25758
|
}
|
|
25747
25759
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -25770,7 +25782,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
25770
25782
|
}
|
|
25771
25783
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
25772
25784
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25773
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
25785
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _368 => _368.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
25774
25786
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25775
25787
|
}
|
|
25776
25788
|
if (preamble.length > 0) {
|
|
@@ -25785,7 +25797,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
25785
25797
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
25786
25798
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
25787
25799
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
25788
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
25800
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _369 => _369.press, 'optionalAccess', _370 => _370.sub]), () => ( []))) {
|
|
25789
25801
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
25790
25802
|
}
|
|
25791
25803
|
return parts.join("\n ");
|
|
@@ -25879,8 +25891,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25879
25891
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
25880
25892
|
if (gongmun && gongmunList) {
|
|
25881
25893
|
const info = gongmunList.items.get(blockIdx);
|
|
25882
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25883
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25894
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _371 => _371.depth]), () => ( 0));
|
|
25895
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _372 => _372.marker]), () => ( ""));
|
|
25884
25896
|
const content = block.text || "";
|
|
25885
25897
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
25886
25898
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -25889,7 +25901,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25889
25901
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
25890
25902
|
}
|
|
25891
25903
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
25892
|
-
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess',
|
|
25904
|
+
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _373 => _373.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
25893
25905
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
25894
25906
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
25895
25907
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -25948,18 +25960,18 @@ function renderHtmlTable(block, ctx) {
|
|
|
25948
25960
|
}
|
|
25949
25961
|
function appendPostamble(blocks, ctx) {
|
|
25950
25962
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
25951
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25963
|
+
if (_optionalChain([gongmun, 'optionalAccess', _374 => _374.noticeHead]) && dfIds) {
|
|
25952
25964
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
25953
25965
|
}
|
|
25954
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25955
|
-
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access',
|
|
25966
|
+
if (_optionalChain([gongmun, 'optionalAccess', _375 => _375.endMark]) && paraXmls.length > 0) {
|
|
25967
|
+
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _376 => _376.rows, 'optionalAccess', _377 => _377.length]));
|
|
25956
25968
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
25957
25969
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
25958
25970
|
}
|
|
25959
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25971
|
+
if (_optionalChain([gongmun, 'optionalAccess', _378 => _378.docFoot]) && dfIds) {
|
|
25960
25972
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
25961
25973
|
}
|
|
25962
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25974
|
+
if (_optionalChain([gongmun, 'optionalAccess', _379 => _379.press]) && dfIds && bfReg && tableStyle) {
|
|
25963
25975
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25964
25976
|
}
|
|
25965
25977
|
}
|
|
@@ -25979,7 +25991,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25979
25991
|
remap,
|
|
25980
25992
|
dfIds,
|
|
25981
25993
|
images,
|
|
25982
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
25994
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _380 => _380.preset]) === "gaejosik",
|
|
25983
25995
|
measured,
|
|
25984
25996
|
richAssets,
|
|
25985
25997
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -26085,9 +26097,9 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
26085
26097
|
|
|
26086
26098
|
// src/hwpx/generator.ts
|
|
26087
26099
|
async function markdownToHwpx(markdown, options) {
|
|
26088
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
26089
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
26090
|
-
const page = resolvePage(_optionalChain([options, 'optionalAccess',
|
|
26100
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _381 => _381.theme]));
|
|
26101
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _382 => _382.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
26102
|
+
const page = resolvePage(_optionalChain([options, 'optionalAccess', _383 => _383.page]));
|
|
26091
26103
|
const { md: md2, defs } = extractFootnoteDefs(markdown);
|
|
26092
26104
|
beginInlineDoc(defs);
|
|
26093
26105
|
try {
|
|
@@ -26097,13 +26109,13 @@ async function markdownToHwpx(markdown, options) {
|
|
|
26097
26109
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
26098
26110
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
26099
26111
|
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
26100
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
26101
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
26112
|
+
const remap = _optionalChain([options, 'optionalAccess', _384 => _384.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _385 => _385.variants, 'optionalAccess', _386 => _386.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
|
|
26113
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _387 => _387.borderFillXmls, 'access', _388 => _388.length]), () => ( 0)))) : null;
|
|
26102
26114
|
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
26103
|
-
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
26115
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _389 => _389.variants, 'optionalAccess', _390 => _390.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _391 => _391.charPrXmls, 'access', _392 => _392.length]), () => ( 0)));
|
|
26104
26116
|
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
26105
26117
|
const chartParts = [];
|
|
26106
|
-
const supplied = _optionalChain([options, 'optionalAccess',
|
|
26118
|
+
const supplied = _optionalChain([options, 'optionalAccess', _393 => _393.images]) ? new Map(Object.entries(options.images).map(([k, v]) => [k, v instanceof Uint8Array ? v : new Uint8Array(v)])) : void 0;
|
|
26107
26119
|
const images = new ImageRegistry(supplied);
|
|
26108
26120
|
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap, dfIds, images, page);
|
|
26109
26121
|
if (remap && remap.tables.length > 0) {
|
|
@@ -26112,7 +26124,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
26112
26124
|
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)`);
|
|
26113
26125
|
}
|
|
26114
26126
|
}
|
|
26115
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
26127
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _394 => _394.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _395 => _395.emit, 'call', _396 => _396()]), () => ( []))];
|
|
26116
26128
|
const zip = new (0, _jszip2.default)();
|
|
26117
26129
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
26118
26130
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
@@ -26121,11 +26133,11 @@ async function markdownToHwpx(markdown, options) {
|
|
|
26121
26133
|
zip.file("Contents/header.xml", generateHeaderXml(
|
|
26122
26134
|
theme,
|
|
26123
26135
|
gongmun,
|
|
26124
|
-
_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
26136
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _397 => _397.variants]), () => ( [])),
|
|
26125
26137
|
extraBorderFills,
|
|
26126
|
-
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
26127
|
-
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess',
|
|
26128
|
-
_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
26138
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _398 => _398.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
|
|
26139
|
+
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _399 => _399.indentVariants]), () => ( [])),
|
|
26140
|
+
_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _400 => _400.fontFaces]), () => ( []))
|
|
26129
26141
|
));
|
|
26130
26142
|
zip.file("Contents/section0.xml", sectionXml);
|
|
26131
26143
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
@@ -26179,7 +26191,7 @@ function alignBlocks(a, b) {
|
|
|
26179
26191
|
const m = a.length, n = b.length;
|
|
26180
26192
|
if (m * n > 1e7) return fallbackAlign(a, b);
|
|
26181
26193
|
const lenOf = (blk) => {
|
|
26182
|
-
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
26194
|
+
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _401 => _401.text]), () => ( ""))).join(" ") : "";
|
|
26183
26195
|
return t.replace(/\s+/g, " ").trim().length;
|
|
26184
26196
|
};
|
|
26185
26197
|
const aLen = a.map(lenOf);
|
|
@@ -26252,8 +26264,8 @@ function blockSimilarity(a, b) {
|
|
|
26252
26264
|
}
|
|
26253
26265
|
function tableSimilarity(a, b) {
|
|
26254
26266
|
const dimSim = 1 - Math.abs(a.rows * a.cols - b.rows * b.cols) / Math.max(a.rows * a.cols, b.rows * b.cols, 1);
|
|
26255
|
-
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
26256
|
-
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
26267
|
+
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _402 => _402.text]), () => ( ""))).join(" ");
|
|
26268
|
+
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _403 => _403.text]), () => ( ""))).join(" ");
|
|
26257
26269
|
const contentSim = normalizedSimilarity(textsA, textsB);
|
|
26258
26270
|
return dimSim * 0.3 + contentSim * 0.7;
|
|
26259
26271
|
}
|
|
@@ -26264,8 +26276,8 @@ function diffTableCells(a, b) {
|
|
|
26264
26276
|
for (let r = 0; r < maxRows; r++) {
|
|
26265
26277
|
const row = [];
|
|
26266
26278
|
for (let c = 0; c < maxCols; c++) {
|
|
26267
|
-
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access',
|
|
26268
|
-
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access',
|
|
26279
|
+
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access', _404 => _404.cells, 'access', _405 => _405[r], 'optionalAccess', _406 => _406[c], 'optionalAccess', _407 => _407.text]) : void 0;
|
|
26280
|
+
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access', _408 => _408.cells, 'access', _409 => _409[r], 'optionalAccess', _410 => _410[c], 'optionalAccess', _411 => _411.text]) : void 0;
|
|
26269
26281
|
let type;
|
|
26270
26282
|
if (cellA === void 0) type = "added";
|
|
26271
26283
|
else if (cellB === void 0) type = "removed";
|
|
@@ -26315,7 +26327,7 @@ function builtinTemplateDir() {
|
|
|
26315
26327
|
for (const c of candidates) {
|
|
26316
26328
|
if (_fs.existsSync.call(void 0, _path.join.call(void 0, c, BUILTIN_TEMPLATES[0].file))) return c;
|
|
26317
26329
|
}
|
|
26318
|
-
throw new (0,
|
|
26330
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uB0B4\uC7A5 templates \uB514\uB809\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 (\uD328\uD0A4\uC9C0 \uC124\uCE58\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4)");
|
|
26319
26331
|
}
|
|
26320
26332
|
function readBuiltinTemplate(t) {
|
|
26321
26333
|
const buf = _fs.readFileSync.call(void 0, _path.join.call(void 0, builtinTemplateDir(), t.file));
|
|
@@ -26478,7 +26490,7 @@ function parseRenderStyles(headXml) {
|
|
|
26478
26490
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
26479
26491
|
const textColor = el.getAttribute("textColor");
|
|
26480
26492
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
26481
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
26493
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _412 => _412.getAttribute, 'call', _413 => _413("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _414 => _414.getAttribute, 'call', _415 => _415("latin")])));
|
|
26482
26494
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
26483
26495
|
styles.charPr.set(id, {
|
|
26484
26496
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -26486,8 +26498,8 @@ function parseRenderStyles(headXml) {
|
|
|
26486
26498
|
italic: findChildByLocalName(el, "italic") != null,
|
|
26487
26499
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
26488
26500
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
26489
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
26490
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
26501
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _416 => _416.getAttribute, 'call', _417 => _417("hangul")])) || 100,
|
|
26502
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _418 => _418.getAttribute, 'call', _419 => _419("hangul")])) || 0,
|
|
26491
26503
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
26492
26504
|
face
|
|
26493
26505
|
});
|
|
@@ -26496,7 +26508,7 @@ function parseRenderStyles(headXml) {
|
|
|
26496
26508
|
const id = el.getAttribute("id");
|
|
26497
26509
|
if (id != null) {
|
|
26498
26510
|
const align = findChildByLocalName(el, "align");
|
|
26499
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
26511
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _420 => _420.getAttribute, 'call', _421 => _421("horizontal")]) || "JUSTIFY");
|
|
26500
26512
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
26501
26513
|
}
|
|
26502
26514
|
} else if (tag === "borderFill") {
|
|
@@ -26510,7 +26522,7 @@ function parseRenderStyles(headXml) {
|
|
|
26510
26522
|
};
|
|
26511
26523
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26512
26524
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26513
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26525
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _422 => _422.getAttribute, 'call', _423 => _423("faceColor")]);
|
|
26514
26526
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
26515
26527
|
styles.borderFill.set(id, bf);
|
|
26516
26528
|
}
|
|
@@ -26582,7 +26594,7 @@ function collectSites(scan) {
|
|
|
26582
26594
|
}
|
|
26583
26595
|
function attrOf3(openTag, name) {
|
|
26584
26596
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
26585
|
-
return _optionalChain([m, 'optionalAccess',
|
|
26597
|
+
return _optionalChain([m, 'optionalAccess', _424 => _424[1]]);
|
|
26586
26598
|
}
|
|
26587
26599
|
function paraOpenTag(xml, para2) {
|
|
26588
26600
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -26597,7 +26609,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
26597
26609
|
if (!tr) return null;
|
|
26598
26610
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
26599
26611
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
26600
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
26612
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _425 => _425[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
26601
26613
|
const charPr2 = runOpen && attrOf3(runOpen[0], "charPrIDRef") || "0";
|
|
26602
26614
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
26603
26615
|
if (close === -1) return null;
|
|
@@ -26624,7 +26636,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
26624
26636
|
if (width === null) return null;
|
|
26625
26637
|
let content = width;
|
|
26626
26638
|
const win = cellAddrWindow(xml, cell2);
|
|
26627
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
26639
|
+
const mg = _optionalChain([win, 'optionalAccess', _426 => _426.match, 'call', _427 => _427(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
26628
26640
|
if (mg) {
|
|
26629
26641
|
content -= Number(_nullishCoalesce(attrOf3(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf3(mg[0], "right"), () => ( 0)));
|
|
26630
26642
|
}
|
|
@@ -26658,12 +26670,12 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
26658
26670
|
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>`;
|
|
26659
26671
|
}
|
|
26660
26672
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
26661
|
-
if (ops.length === 0) throw new (0,
|
|
26673
|
+
if (ops.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
26662
26674
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
26663
|
-
|
|
26675
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
26664
26676
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
26665
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
26666
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
26677
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _428 => _428.match, 'call', _429 => _429(/(\d+)\.xml$/i), 'optionalAccess', _430 => _430[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _431 => _431.match, 'call', _432 => _432(/(\d+)\.xml$/i), 'optionalAccess', _433 => _433[1]]), () => ( 0))));
|
|
26678
|
+
if (sectionPaths.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
26667
26679
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
26668
26680
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
26669
26681
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -26704,11 +26716,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26704
26716
|
const manifestItems = [];
|
|
26705
26717
|
const placed = [];
|
|
26706
26718
|
for (const op of ops) {
|
|
26707
|
-
if (!op.anchor) throw new (0,
|
|
26708
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
26719
|
+
if (!op.anchor) throw new (0, _chunkDJKLOLBTcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26720
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26709
26721
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
26710
|
-
if (!MIME[ext]) throw new (0,
|
|
26711
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
26722
|
+
if (!MIME[ext]) throw new (0, _chunkDJKLOLBTcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
26723
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkDJKLOLBTcjs.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)`);
|
|
26712
26724
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
26713
26725
|
let found = null;
|
|
26714
26726
|
let total = 0;
|
|
@@ -26741,7 +26753,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26741
26753
|
}
|
|
26742
26754
|
}
|
|
26743
26755
|
}
|
|
26744
|
-
throw new (0,
|
|
26756
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
26745
26757
|
`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)})`
|
|
26746
26758
|
);
|
|
26747
26759
|
}
|
|
@@ -26749,9 +26761,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26749
26761
|
const xml = sectionXmls[si];
|
|
26750
26762
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26751
26763
|
if (!run) {
|
|
26752
|
-
throw new (0,
|
|
26764
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26753
26765
|
}
|
|
26754
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
26766
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _434 => _434.charPr, 'access', _435 => _435.get, 'call', _436 => _436(run.charPr), 'optionalAccess', _437 => _437.height]), () => ( 1e3));
|
|
26755
26767
|
const fontPt = charPrHeight / 100;
|
|
26756
26768
|
const emMm = fontPt * 25.4 / 72;
|
|
26757
26769
|
const lineHMm = emMm;
|
|
@@ -26760,7 +26772,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26760
26772
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
26761
26773
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
26762
26774
|
const paraPrId = _nullishCoalesce(attrOf3(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
26763
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
26775
|
+
const align = _optionalChain([styles, 'optionalAccess', _438 => _438.paraAlign, 'access', _439 => _439.get, 'call', _440 => _440(paraPrId)]);
|
|
26764
26776
|
let alignShiftMm = 0;
|
|
26765
26777
|
if (align === "CENTER" || align === "RIGHT") {
|
|
26766
26778
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -26856,7 +26868,7 @@ function parseBorderFills(headerDoc) {
|
|
|
26856
26868
|
};
|
|
26857
26869
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
26858
26870
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26859
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26871
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _441 => _441.getAttribute, 'call', _442 => _442("faceColor")]);
|
|
26860
26872
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
26861
26873
|
map.set(id, def);
|
|
26862
26874
|
}
|
|
@@ -26888,7 +26900,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
26888
26900
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
26889
26901
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
26890
26902
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
26891
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
26903
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _443 => _443.getAttribute, 'call', _444 => _444("hangul")]);
|
|
26892
26904
|
if (hangul) {
|
|
26893
26905
|
def.fontRef_hangul = hangul;
|
|
26894
26906
|
const face = hangulFonts.get(hangul);
|
|
@@ -26916,7 +26928,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26916
26928
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
26917
26929
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
26918
26930
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
26919
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
26931
|
+
const width = _optionalChain([sz, 'optionalAccess', _445 => _445.getAttribute, 'call', _446 => _446("width")]) || void 0;
|
|
26920
26932
|
const cells = [];
|
|
26921
26933
|
const usedBf = /* @__PURE__ */ new Set();
|
|
26922
26934
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -26929,17 +26941,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26929
26941
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
26930
26942
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
26931
26943
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
26932
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26933
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26944
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _447 => _447.getAttribute, 'call', _448 => _448("rowAddr")])), () => ( 0));
|
|
26945
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _449 => _449.getAttribute, 'call', _450 => _450("colAddr")])), () => ( 0));
|
|
26934
26946
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
26935
26947
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
26936
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26937
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26948
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _451 => _451.getAttribute, 'call', _452 => _452("colSpan")])), () => ( 1));
|
|
26949
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _453 => _453.getAttribute, 'call', _454 => _454("rowSpan")])), () => ( 1));
|
|
26938
26950
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
26939
26951
|
const cpId = firstRunCharPr(tc2);
|
|
26940
26952
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
26941
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
26942
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
26953
|
+
const w = _optionalChain([csz, 'optionalAccess', _455 => _455.getAttribute, 'call', _456 => _456("width")]);
|
|
26954
|
+
const hh = _optionalChain([csz, 'optionalAccess', _457 => _457.getAttribute, 'call', _458 => _458("height")]);
|
|
26943
26955
|
if (w) cell2.width_hwpunit = w;
|
|
26944
26956
|
if (hh) cell2.height_hwpunit = hh;
|
|
26945
26957
|
if (bfId) {
|
|
@@ -27027,16 +27039,16 @@ function pick(map, keys) {
|
|
|
27027
27039
|
return out;
|
|
27028
27040
|
}
|
|
27029
27041
|
async function hwpxToProfile(input) {
|
|
27030
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
27042
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkDJKLOLBTcjs.toArrayBuffer.call(void 0, input);
|
|
27031
27043
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
27032
27044
|
const parser = createXmlParser();
|
|
27033
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
27045
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _459 => _459.file, 'call', _460 => _460(/[Hh]eader\.xml$/), 'optionalAccess', _461 => _461[0]])));
|
|
27034
27046
|
let headerXml = "<root/>";
|
|
27035
27047
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
27036
27048
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
27037
27049
|
const borderFills = parseBorderFills(headerDoc);
|
|
27038
27050
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
27039
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
27051
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _462 => _462.name, 'access', _463 => _463.match, 'call', _464 => _464(/(\d+)\.xml$/), 'optionalAccess', _465 => _465[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _466 => _466.name, 'access', _467 => _467.match, 'call', _468 => _468(/(\d+)\.xml$/), 'optionalAccess', _469 => _469[1]]), () => ( null))), () => ( 0))));
|
|
27040
27052
|
const tables = [];
|
|
27041
27053
|
let tableIndex = 0;
|
|
27042
27054
|
for (const f of sectionFiles) {
|
|
@@ -27350,7 +27362,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
27350
27362
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
27351
27363
|
function patchTableRows(input) {
|
|
27352
27364
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
27353
|
-
const xml = _optionalChain([ctx, 'access',
|
|
27365
|
+
const xml = _optionalChain([ctx, 'access', _470 => _470.scans, 'access', _471 => _471[scanTable.sectionIndex], 'optionalAccess', _472 => _472.xml]);
|
|
27354
27366
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
27355
27367
|
const numRows = table2.rows;
|
|
27356
27368
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -27517,7 +27529,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
27517
27529
|
const rr = scanTable.rowRanges[template];
|
|
27518
27530
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
27519
27531
|
const scan = scanSectionXml(wrapped, 0);
|
|
27520
|
-
const row = _optionalChain([scan, 'access',
|
|
27532
|
+
const row = _optionalChain([scan, 'access', _473 => _473.tables, 'access', _474 => _474[0], 'optionalAccess', _475 => _475.rows, 'access', _476 => _476[0]]);
|
|
27521
27533
|
if (!row || row.length !== cells.length) return null;
|
|
27522
27534
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
27523
27535
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -27560,7 +27572,7 @@ function rowHeightOf(fragment) {
|
|
|
27560
27572
|
}
|
|
27561
27573
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
27562
27574
|
const from = scanTable.start + tblOpenLen;
|
|
27563
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
27575
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _477 => _477.rowRanges, 'access', _478 => _478[0], 'optionalAccess', _479 => _479.start]), () => ( from));
|
|
27564
27576
|
const slice = xml.slice(from, to);
|
|
27565
27577
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
27566
27578
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -27749,9 +27761,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
27749
27761
|
});
|
|
27750
27762
|
}
|
|
27751
27763
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
27752
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27764
|
+
const irCell = _optionalChain([table2, 'access', _480 => _480.cells, 'access', _481 => _481[oc.gridR], 'optionalAccess', _482 => _482[oc.gridC]]);
|
|
27753
27765
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
27754
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
27766
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _483 => _483.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
27755
27767
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
27756
27768
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
27757
27769
|
}
|
|
@@ -27819,7 +27831,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27819
27831
|
};
|
|
27820
27832
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
27821
27833
|
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)");
|
|
27822
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27834
|
+
const irCell = _optionalChain([table2, 'access', _484 => _484.cells, 'access', _485 => _485[gridR], 'optionalAccess', _486 => _486[gridC]]);
|
|
27823
27835
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
27824
27836
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27825
27837
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27843,7 +27855,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27843
27855
|
const target = cell2.paragraphs[0];
|
|
27844
27856
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
27845
27857
|
const value = newLines.join(" ");
|
|
27846
|
-
const xml = _optionalChain([ctx, 'access',
|
|
27858
|
+
const xml = _optionalChain([ctx, 'access', _487 => _487.scans, 'access', _488 => _488[target.sectionIndex], 'optionalAccess', _489 => _489.xml]);
|
|
27847
27859
|
const rawT = xml ? paraTText(target, xml) : null;
|
|
27848
27860
|
let sp;
|
|
27849
27861
|
if (xml && rawT === null) {
|
|
@@ -27877,7 +27889,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27877
27889
|
}
|
|
27878
27890
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
27879
27891
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
27880
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
27892
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _490 => _490.scans, 'access', _491 => _491[nonEmpty[i].sectionIndex], 'optionalAccess', _492 => _492.xml]));
|
|
27881
27893
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27882
27894
|
splices.push(...sp);
|
|
27883
27895
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -27958,7 +27970,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27958
27970
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27959
27971
|
if (paths.length > 0) return paths;
|
|
27960
27972
|
}
|
|
27961
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27973
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkDJKLOLBTcjs.compareSectionPaths);
|
|
27962
27974
|
}
|
|
27963
27975
|
function sectionPathsFromManifest(xml) {
|
|
27964
27976
|
const attr = (tag, name) => {
|
|
@@ -27968,7 +27980,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27968
27980
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27969
27981
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27970
27982
|
const id = attr(m[1], "id");
|
|
27971
|
-
const href =
|
|
27983
|
+
const href = _chunkDJKLOLBTcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27972
27984
|
if (id && href) idToHref.set(id, href);
|
|
27973
27985
|
}
|
|
27974
27986
|
const ordered = [];
|
|
@@ -27977,7 +27989,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27977
27989
|
if (href) ordered.push(href);
|
|
27978
27990
|
}
|
|
27979
27991
|
if (ordered.length > 0) return ordered;
|
|
27980
|
-
return Array.from(idToHref.values()).sort(
|
|
27992
|
+
return Array.from(idToHref.values()).sort(_chunkDJKLOLBTcjs.compareSectionPaths);
|
|
27981
27993
|
}
|
|
27982
27994
|
|
|
27983
27995
|
// src/roundtrip/patcher.ts
|
|
@@ -28069,7 +28081,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
28069
28081
|
}
|
|
28070
28082
|
}
|
|
28071
28083
|
let verification;
|
|
28072
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28084
|
+
if (_optionalChain([options, 'optionalAccess', _493 => _493.verify]) !== false) {
|
|
28073
28085
|
try {
|
|
28074
28086
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
28075
28087
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -28087,17 +28099,17 @@ function buildOrigUnits(blocks) {
|
|
|
28087
28099
|
let chunk;
|
|
28088
28100
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
28089
28101
|
const next = blocks[i + 1];
|
|
28090
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
28091
|
-
chunk =
|
|
28102
|
+
if (_optionalChain([next, 'optionalAccess', _494 => _494.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
28103
|
+
chunk = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
28092
28104
|
} else {
|
|
28093
|
-
chunk =
|
|
28105
|
+
chunk = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28094
28106
|
}
|
|
28095
28107
|
if (chunk) {
|
|
28096
28108
|
const subUnits = splitMarkdownUnits(chunk);
|
|
28097
28109
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
28098
28110
|
for (let s = 0; s < subUnits.length; s++) {
|
|
28099
28111
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
28100
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
28112
|
+
if (block.type === "table" && _optionalChain([block, 'access', _495 => _495.table, 'optionalAccess', _496 => _496.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
28101
28113
|
u.role = "caption";
|
|
28102
28114
|
}
|
|
28103
28115
|
units.push(u);
|
|
@@ -28208,7 +28220,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
28208
28220
|
const ti = ctx.tableInsert;
|
|
28209
28221
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
28210
28222
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28211
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28223
|
+
if (!_optionalChain([mapping, 'optionalAccess', _497 => _497.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");
|
|
28212
28224
|
const para2 = mapping.para;
|
|
28213
28225
|
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");
|
|
28214
28226
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -28236,7 +28248,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
28236
28248
|
}
|
|
28237
28249
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
28238
28250
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28239
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28251
|
+
if (!_optionalChain([mapping, 'optionalAccess', _498 => _498.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)");
|
|
28240
28252
|
if (block.text && block.text.includes("\n")) {
|
|
28241
28253
|
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)");
|
|
28242
28254
|
}
|
|
@@ -28267,7 +28279,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
28267
28279
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
28268
28280
|
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");
|
|
28269
28281
|
}
|
|
28270
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
28282
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _499 => _499.scans, 'access', _500 => _500[mapping.para.sectionIndex], 'optionalAccess', _501 => _501.xml]));
|
|
28271
28283
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
28272
28284
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
28273
28285
|
return 1;
|
|
@@ -28459,7 +28471,7 @@ var Surgeon = (_class7 = class {
|
|
|
28459
28471
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
28460
28472
|
findEntry(path) {
|
|
28461
28473
|
const parts = path.replace(/^\//, "").split("/");
|
|
28462
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
28474
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _502 => _502.entries, 'access', _503 => _503[0], 'optionalAccess', _504 => _504.child]), () => ( -1));
|
|
28463
28475
|
let current;
|
|
28464
28476
|
for (const part of parts) {
|
|
28465
28477
|
const search = (idx) => {
|
|
@@ -28712,8 +28724,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
28712
28724
|
parts.push(header, data);
|
|
28713
28725
|
};
|
|
28714
28726
|
for (let i = 0; i < recs.length; i++) {
|
|
28715
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
28716
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
28727
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _505 => _505.get, 'call', _506 => _506(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
28728
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _507 => _507.get, 'call', _508 => _508(i)]), () => ( recs[i].data)));
|
|
28717
28729
|
}
|
|
28718
28730
|
return Buffer.concat(parts);
|
|
28719
28731
|
}
|
|
@@ -28831,7 +28843,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28831
28843
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
28832
28844
|
}
|
|
28833
28845
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
28834
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
28846
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _509 => _509.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
28835
28847
|
let flags;
|
|
28836
28848
|
try {
|
|
28837
28849
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -28853,7 +28865,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28853
28865
|
const scans = [];
|
|
28854
28866
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
28855
28867
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
28856
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
28868
|
+
if (!_optionalChain([entry, 'optionalAccess', _510 => _510.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
28857
28869
|
let stream;
|
|
28858
28870
|
try {
|
|
28859
28871
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -28904,7 +28916,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28904
28916
|
}
|
|
28905
28917
|
}
|
|
28906
28918
|
let verification;
|
|
28907
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28919
|
+
if (_optionalChain([options, 'optionalAccess', _511 => _511.verify]) !== false) {
|
|
28908
28920
|
try {
|
|
28909
28921
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
28910
28922
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -28994,7 +29006,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
28994
29006
|
for (const [key, scanCell] of scanTable.cells) {
|
|
28995
29007
|
const comma = key.indexOf(",");
|
|
28996
29008
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
28997
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
29009
|
+
const irCell = _optionalChain([irTable, 'access', _512 => _512.cells, 'access', _513 => _513[r], 'optionalAccess', _514 => _514[c]]);
|
|
28998
29010
|
if (!irCell) continue;
|
|
28999
29011
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
29000
29012
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -29030,7 +29042,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
29030
29042
|
}
|
|
29031
29043
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
29032
29044
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
29033
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
29045
|
+
if (!_optionalChain([mapping, 'optionalAccess', _515 => _515.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)");
|
|
29034
29046
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
29035
29047
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
29036
29048
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -29229,7 +29241,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
29229
29241
|
};
|
|
29230
29242
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
29231
29243
|
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)");
|
|
29232
|
-
const irCell = _optionalChain([table2, 'access',
|
|
29244
|
+
const irCell = _optionalChain([table2, 'access', _516 => _516.cells, 'access', _517 => _517[gridR], 'optionalAccess', _518 => _518[gridC]]);
|
|
29233
29245
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
29234
29246
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
29235
29247
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -29636,11 +29648,11 @@ var RULES2 = {
|
|
|
29636
29648
|
}
|
|
29637
29649
|
};
|
|
29638
29650
|
function redactText(text, options) {
|
|
29639
|
-
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29651
|
+
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _519 => _519.maskChar]), () => ( "\u25CF"));
|
|
29640
29652
|
if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
|
|
29641
29653
|
throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
|
|
29642
29654
|
}
|
|
29643
|
-
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29655
|
+
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _520 => _520.rules]), () => ( DEFAULT_REDACT_RULES));
|
|
29644
29656
|
const hits = [];
|
|
29645
29657
|
if (text === "" || enabled.length === 0) return { text, hits };
|
|
29646
29658
|
const occupied = [];
|
|
@@ -29695,8 +29707,8 @@ function sameBreadcrumb(a, b) {
|
|
|
29695
29707
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
29696
29708
|
}
|
|
29697
29709
|
function blocksToChunks(blocks, options) {
|
|
29698
|
-
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29699
|
-
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29710
|
+
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _521 => _521.granularity]), () => ( "section"));
|
|
29711
|
+
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _522 => _522.includeTableCells]), () => ( false));
|
|
29700
29712
|
const chunks = [];
|
|
29701
29713
|
const headingStack = [];
|
|
29702
29714
|
const listStack = [];
|
|
@@ -29710,12 +29722,12 @@ function blocksToChunks(blocks, options) {
|
|
|
29710
29722
|
let run = null;
|
|
29711
29723
|
const flushRun = () => {
|
|
29712
29724
|
if (!run) return;
|
|
29713
|
-
push("text", run.breadcrumb,
|
|
29725
|
+
push("text", run.breadcrumb, _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
29714
29726
|
run = null;
|
|
29715
29727
|
};
|
|
29716
29728
|
for (let i = 0; i < blocks.length; i++) {
|
|
29717
29729
|
const block = blocks[i];
|
|
29718
|
-
const md2 =
|
|
29730
|
+
const md2 = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, [block]);
|
|
29719
29731
|
if (!md2) continue;
|
|
29720
29732
|
if (block.type === "heading") {
|
|
29721
29733
|
flushRun();
|
|
@@ -29831,7 +29843,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29831
29843
|
const block = st.blocks[blockIndex];
|
|
29832
29844
|
if (!block) return void 0;
|
|
29833
29845
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
29834
|
-
const para2 = _optionalChain([st, 'access',
|
|
29846
|
+
const para2 = _optionalChain([st, 'access', _523 => _523.paraMap, 'access', _524 => _524.get, 'call', _525 => _525(blockIndex), 'optionalAccess', _526 => _526.para]);
|
|
29835
29847
|
if (!para2) return void 0;
|
|
29836
29848
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
29837
29849
|
}
|
|
@@ -29856,7 +29868,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29856
29868
|
if (block.text && block.text.includes("\n")) {
|
|
29857
29869
|
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)" };
|
|
29858
29870
|
}
|
|
29859
|
-
if (!_optionalChain([st, 'access',
|
|
29871
|
+
if (!_optionalChain([st, 'access', _527 => _527.paraMap, 'access', _528 => _528.get, 'call', _529 => _529(blockIndex), 'optionalAccess', _530 => _530.para])) {
|
|
29860
29872
|
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)" };
|
|
29861
29873
|
}
|
|
29862
29874
|
return { capability: "text" };
|
|
@@ -29922,7 +29934,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29922
29934
|
continue;
|
|
29923
29935
|
}
|
|
29924
29936
|
if (block.type === "table" && block.table) {
|
|
29925
|
-
if (!_optionalChain([edit, 'access',
|
|
29937
|
+
if (!_optionalChain([edit, 'access', _531 => _531.cells, 'optionalAccess', _532 => _532.length])) {
|
|
29926
29938
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
29927
29939
|
continue;
|
|
29928
29940
|
}
|
|
@@ -29942,7 +29954,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29942
29954
|
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) });
|
|
29943
29955
|
continue;
|
|
29944
29956
|
}
|
|
29945
|
-
const irCell = _optionalChain([block, 'access',
|
|
29957
|
+
const irCell = _optionalChain([block, 'access', _533 => _533.table, 'access', _534 => _534.cells, 'access', _535 => _535[cellEdit.row], 'optionalAccess', _536 => _536[cellEdit.col]]);
|
|
29946
29958
|
if (!irCell) {
|
|
29947
29959
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
29948
29960
|
continue;
|
|
@@ -29998,7 +30010,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29998
30010
|
}
|
|
29999
30011
|
if (replacements.size === 0) {
|
|
30000
30012
|
let changes2;
|
|
30001
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
30013
|
+
if (_optionalChain([options, 'optionalAccess', _537 => _537.verify]) !== false) {
|
|
30002
30014
|
const units = splitMarkdownUnits(st.markdown);
|
|
30003
30015
|
changes2 = diffUnitLists(units, units);
|
|
30004
30016
|
}
|
|
@@ -30019,7 +30031,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
30019
30031
|
}
|
|
30020
30032
|
this.state = newState;
|
|
30021
30033
|
let changes;
|
|
30022
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
30034
|
+
if (_optionalChain([options, 'optionalAccess', _538 => _538.verify]) !== false) {
|
|
30023
30035
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
30024
30036
|
}
|
|
30025
30037
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -30039,7 +30051,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
30039
30051
|
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)");
|
|
30040
30052
|
}
|
|
30041
30053
|
const mapping = st.paraMap.get(blockIndex);
|
|
30042
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
30054
|
+
if (!_optionalChain([mapping, 'optionalAccess', _539 => _539.para])) {
|
|
30043
30055
|
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)");
|
|
30044
30056
|
}
|
|
30045
30057
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -30059,14 +30071,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
30059
30071
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
30060
30072
|
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");
|
|
30061
30073
|
}
|
|
30062
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
30074
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _540 => _540.scans, 'access', _541 => _541[mapping.para.sectionIndex], 'optionalAccess', _542 => _542.xml]));
|
|
30063
30075
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
30064
30076
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
30065
30077
|
return 1;
|
|
30066
30078
|
}
|
|
30067
30079
|
}, _class8);
|
|
30068
30080
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
30069
|
-
const irCell = _optionalChain([table2, 'access',
|
|
30081
|
+
const irCell = _optionalChain([table2, 'access', _543 => _543.cells, 'access', _544 => _544[r], 'optionalAccess', _545 => _545[c]]);
|
|
30070
30082
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
30071
30083
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
30072
30084
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -30150,11 +30162,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
30150
30162
|
breaks: false
|
|
30151
30163
|
});
|
|
30152
30164
|
function renderHtml(markdown, options) {
|
|
30153
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30154
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30165
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _546 => _546.preset]), () => ( "default"));
|
|
30166
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _547 => _547.extraCss]), () => ( "")));
|
|
30155
30167
|
const body = md.render(markdown);
|
|
30156
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
30157
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
30168
|
+
const watermark = _optionalChain([options, 'optionalAccess', _548 => _548.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
30169
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _549 => _549.watermark]) ? `
|
|
30158
30170
|
.watermark {
|
|
30159
30171
|
position: fixed;
|
|
30160
30172
|
top: 50%; left: 50%;
|
|
@@ -30185,13 +30197,13 @@ async function htmlToPdf(html, options) {
|
|
|
30185
30197
|
try {
|
|
30186
30198
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
30187
30199
|
} catch (e37) {
|
|
30188
|
-
throw new (0,
|
|
30200
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
30189
30201
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
30190
30202
|
);
|
|
30191
30203
|
}
|
|
30192
30204
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
30193
30205
|
if (!executablePath) {
|
|
30194
|
-
throw new (0,
|
|
30206
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)(
|
|
30195
30207
|
"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."
|
|
30196
30208
|
);
|
|
30197
30209
|
}
|
|
@@ -30203,10 +30215,10 @@ async function htmlToPdf(html, options) {
|
|
|
30203
30215
|
try {
|
|
30204
30216
|
const page = await browser.newPage();
|
|
30205
30217
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
30206
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
30218
|
+
const margin = _optionalChain([options, 'optionalAccess', _550 => _550.margin]);
|
|
30207
30219
|
const pdf = await page.pdf({
|
|
30208
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30209
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
30220
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _551 => _551.pageSize]), () => ( "A4")),
|
|
30221
|
+
landscape: _optionalChain([options, 'optionalAccess', _552 => _552.orientation]) === "landscape",
|
|
30210
30222
|
printBackground: true,
|
|
30211
30223
|
margin: margin ? {
|
|
30212
30224
|
top: toCss(margin.top),
|
|
@@ -30214,9 +30226,9 @@ async function htmlToPdf(html, options) {
|
|
|
30214
30226
|
bottom: toCss(margin.bottom),
|
|
30215
30227
|
left: toCss(margin.left)
|
|
30216
30228
|
} : void 0,
|
|
30217
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
30218
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30219
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30229
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _553 => _553.header]) || _optionalChain([options, 'optionalAccess', _554 => _554.footer])),
|
|
30230
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.header]), () => ( "<div></div>")),
|
|
30231
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _556 => _556.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
30220
30232
|
});
|
|
30221
30233
|
return Buffer.from(pdf);
|
|
30222
30234
|
} finally {
|
|
@@ -30250,7 +30262,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
30250
30262
|
return htmlToPdf(html, options);
|
|
30251
30263
|
}
|
|
30252
30264
|
async function blocksToPdf(blocks, options) {
|
|
30253
|
-
const markdown =
|
|
30265
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks);
|
|
30254
30266
|
return markdownToPdf(markdown, options);
|
|
30255
30267
|
}
|
|
30256
30268
|
|
|
@@ -30429,7 +30441,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
30429
30441
|
}
|
|
30430
30442
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
30431
30443
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
30432
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30444
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _557 => _557.getAttribute, 'call', _558 => _558("vertRelTo")]), () => ( "PARA"));
|
|
30433
30445
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
30434
30446
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
30435
30447
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -30490,7 +30502,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
30490
30502
|
if (ln(p) !== "p") continue;
|
|
30491
30503
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
30492
30504
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
30493
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
30505
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _559 => _559.spaceBefore]), () => ( 0)));
|
|
30494
30506
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
30495
30507
|
if (!res) {
|
|
30496
30508
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -30503,7 +30515,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
30503
30515
|
}
|
|
30504
30516
|
if (Number.isFinite(bottom)) {
|
|
30505
30517
|
cursorV = bottom;
|
|
30506
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
30518
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _560 => _560.spaceAfter]), () => ( 0));
|
|
30507
30519
|
}
|
|
30508
30520
|
}
|
|
30509
30521
|
continue;
|
|
@@ -30609,7 +30621,7 @@ function buildPara(p) {
|
|
|
30609
30621
|
const pos = findChildByLocalName(ch, "pos");
|
|
30610
30622
|
const w = num3(sz, "width") || num3(findChildByLocalName(ch, "curSz"), "width") || num3(findChildByLocalName(ch, "orgSz"), "width");
|
|
30611
30623
|
const h = num3(sz, "height") || num3(findChildByLocalName(ch, "curSz"), "height") || num3(findChildByLocalName(ch, "orgSz"), "height");
|
|
30612
|
-
const inline = _optionalChain([pos, 'optionalAccess',
|
|
30624
|
+
const inline = _optionalChain([pos, 'optionalAccess', _561 => _561.getAttribute, 'call', _562 => _562("treatAsChar")]) === "1";
|
|
30613
30625
|
const om = inline && cn === "tbl" ? findChildByLocalName(ch, "outMargin") : null;
|
|
30614
30626
|
objs.push({
|
|
30615
30627
|
el: ch,
|
|
@@ -30869,15 +30881,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30869
30881
|
const sx = ow > 0 ? w / ow : 1;
|
|
30870
30882
|
const sy = oh > 0 ? h / oh : 1;
|
|
30871
30883
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
30872
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
30873
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
30884
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _563 => _563.getAttribute, 'call', _564 => _564("style")]), () => ( "SOLID"));
|
|
30885
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _565 => _565.getAttribute, 'call', _566 => _566("color")]) || "#000000";
|
|
30874
30886
|
const hasStroke = lstyle !== "NONE";
|
|
30875
30887
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
30876
30888
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
30877
30889
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
30878
30890
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
30879
30891
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
30880
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
30892
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _567 => _567.getAttribute, 'call', _568 => _568("faceColor")]);
|
|
30881
30893
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
30882
30894
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
30883
30895
|
if (o.tag === "rect") {
|
|
@@ -30904,14 +30916,14 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30904
30916
|
}
|
|
30905
30917
|
function cellContentExtent(cell2, memo) {
|
|
30906
30918
|
if (!cell2.sub) return 0;
|
|
30907
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30919
|
+
const hit = _optionalChain([memo, 'optionalAccess', _569 => _569.cell, 'access', _570 => _570.get, 'call', _571 => _571(cell2.el)]);
|
|
30908
30920
|
if (hit !== void 0) return hit;
|
|
30909
30921
|
let ext = 0;
|
|
30910
30922
|
for (const p of elements2(cell2.sub)) {
|
|
30911
30923
|
if (ln2(p) !== "p") continue;
|
|
30912
30924
|
const m = buildPara(p);
|
|
30913
30925
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
30914
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
30926
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _572 => _572.segs, 'access', _573 => _573[0], 'optionalAccess', _574 => _574.vertpos]), () => ( 0));
|
|
30915
30927
|
for (const o of m.objs) {
|
|
30916
30928
|
if (o.inline) {
|
|
30917
30929
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
@@ -30919,14 +30931,14 @@ function cellContentExtent(cell2, memo) {
|
|
|
30919
30931
|
continue;
|
|
30920
30932
|
}
|
|
30921
30933
|
const pos = findChildByLocalName(o.el, "pos");
|
|
30922
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30934
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _575 => _575.getAttribute, 'call', _576 => _576("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
30923
30935
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
30924
30936
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
30925
30937
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
30926
30938
|
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
30927
30939
|
}
|
|
30928
30940
|
}
|
|
30929
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30941
|
+
_optionalChain([memo, 'optionalAccess', _577 => _577.cell, 'access', _578 => _578.set, 'call', _579 => _579(cell2.el, ext)]);
|
|
30930
30942
|
return ext;
|
|
30931
30943
|
}
|
|
30932
30944
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
@@ -30968,7 +30980,7 @@ function collectCells(tbl2) {
|
|
|
30968
30980
|
return cells;
|
|
30969
30981
|
}
|
|
30970
30982
|
function measureTableHeight(tbl2, memo) {
|
|
30971
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30983
|
+
const hit = _optionalChain([memo, 'optionalAccess', _580 => _580.table, 'access', _581 => _581.get, 'call', _582 => _582(tbl2)]);
|
|
30972
30984
|
if (hit !== void 0) return hit;
|
|
30973
30985
|
const cells = collectCells(tbl2);
|
|
30974
30986
|
if (cells.length === 0 || cells.length > 4096) return 0;
|
|
@@ -30979,7 +30991,7 @@ function measureTableHeight(tbl2, memo) {
|
|
|
30979
30991
|
);
|
|
30980
30992
|
let sum = 0;
|
|
30981
30993
|
for (const h of rowH) sum += h;
|
|
30982
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30994
|
+
_optionalChain([memo, 'optionalAccess', _583 => _583.table, 'access', _584 => _584.set, 'call', _585 => _585(tbl2, sum)]);
|
|
30983
30995
|
return sum;
|
|
30984
30996
|
}
|
|
30985
30997
|
function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
@@ -31010,7 +31022,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
31010
31022
|
}));
|
|
31011
31023
|
for (const g of geom) {
|
|
31012
31024
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
31013
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
31025
|
+
if (_optionalChain([bf, 'optionalAccess', _586 => _586.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
31014
31026
|
}
|
|
31015
31027
|
for (const g of geom) {
|
|
31016
31028
|
const { c } = g;
|
|
@@ -31048,7 +31060,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
31048
31060
|
const sz = findChildByLocalName(pic, "sz");
|
|
31049
31061
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
31050
31062
|
const img = findFirst(pic, "img");
|
|
31051
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
31063
|
+
const ref = _optionalChain([img, 'optionalAccess', _587 => _587.getAttribute, 'call', _588 => _588("binaryItemIDRef")]);
|
|
31052
31064
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
31053
31065
|
if (!loaded) {
|
|
31054
31066
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -31088,7 +31100,7 @@ function readSectionGeom(root) {
|
|
|
31088
31100
|
const pagePr = findFirst(root, "pagePr");
|
|
31089
31101
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
31090
31102
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
31091
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
31103
|
+
if (_optionalChain([pagePr, 'optionalAccess', _589 => _589.getAttribute, 'call', _590 => _590("landscape")]) === "NARROWLY" && PW < PH) {
|
|
31092
31104
|
const t = PW;
|
|
31093
31105
|
PW = PH;
|
|
31094
31106
|
PH = t;
|
|
@@ -31146,17 +31158,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
31146
31158
|
return { pages: ctx.pages, pageH };
|
|
31147
31159
|
}
|
|
31148
31160
|
async function renderHwpxToSvg(input, options) {
|
|
31149
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
31161
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _591 => _591.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
31150
31162
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
31151
|
-
|
|
31163
|
+
_chunkDJKLOLBTcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
31152
31164
|
let zip;
|
|
31153
31165
|
try {
|
|
31154
31166
|
zip = await _jszip2.default.loadAsync(input);
|
|
31155
31167
|
} catch (e38) {
|
|
31156
|
-
throw new (0,
|
|
31168
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
31157
31169
|
}
|
|
31158
31170
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
31159
|
-
if (secFiles.length === 0) throw new (0,
|
|
31171
|
+
if (secFiles.length === 0) throw new (0, _chunkDJKLOLBTcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
31160
31172
|
const warnings = [];
|
|
31161
31173
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
31162
31174
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -31164,7 +31176,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31164
31176
|
const secXmls = [];
|
|
31165
31177
|
for (const f of secFiles) {
|
|
31166
31178
|
const xml = await f.async("string");
|
|
31167
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
31179
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
31168
31180
|
secXmls.push(xml);
|
|
31169
31181
|
}
|
|
31170
31182
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -31188,7 +31200,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31188
31200
|
let href = binmap.get(ref);
|
|
31189
31201
|
if (!href) {
|
|
31190
31202
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
31191
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
31203
|
+
href = _optionalChain([cand, 'optionalAccess', _592 => _592.name]);
|
|
31192
31204
|
}
|
|
31193
31205
|
if (!href) continue;
|
|
31194
31206
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -31209,7 +31221,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31209
31221
|
styles,
|
|
31210
31222
|
images,
|
|
31211
31223
|
defs: [],
|
|
31212
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
31224
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _593 => _593.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
31213
31225
|
warnings,
|
|
31214
31226
|
warned: /* @__PURE__ */ new Set(),
|
|
31215
31227
|
stats: { texts: 0, images: 0, tables: 0 },
|
|
@@ -31220,7 +31232,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31220
31232
|
for (let si = 0; si < secXmls.length; si++) {
|
|
31221
31233
|
const secXml = secXmls[si];
|
|
31222
31234
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
31223
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
31235
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _594 => _594.reflow])) {
|
|
31224
31236
|
noCacheSkipped = true;
|
|
31225
31237
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
31226
31238
|
continue;
|
|
@@ -31232,14 +31244,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31232
31244
|
continue;
|
|
31233
31245
|
}
|
|
31234
31246
|
const geom = readSectionGeom(root);
|
|
31235
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess',
|
|
31247
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _595 => _595.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _596 => _596.reflowMode]), () => ( "keep")));
|
|
31236
31248
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
31237
31249
|
}
|
|
31238
31250
|
if (rendered.length === 0) {
|
|
31239
31251
|
if (noCacheSkipped) {
|
|
31240
|
-
throw new (0,
|
|
31252
|
+
throw new (0, _chunkDJKLOLBTcjs.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)");
|
|
31241
31253
|
}
|
|
31242
|
-
throw new (0,
|
|
31254
|
+
throw new (0, _chunkDJKLOLBTcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
31243
31255
|
}
|
|
31244
31256
|
const GAP = 2400;
|
|
31245
31257
|
const clipDefs = [];
|
|
@@ -31271,17 +31283,17 @@ ${groups.join("\n")}
|
|
|
31271
31283
|
// src/index.ts
|
|
31272
31284
|
async function parse(input, options) {
|
|
31273
31285
|
let buffer;
|
|
31274
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
31286
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _597 => _597.filePath]) ? { ...options, filePath: input } : options;
|
|
31275
31287
|
if (typeof input === "string") {
|
|
31276
31288
|
try {
|
|
31277
31289
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31278
|
-
buffer =
|
|
31290
|
+
buffer = _chunkDJKLOLBTcjs.toArrayBuffer.call(void 0, buf);
|
|
31279
31291
|
} catch (err) {
|
|
31280
31292
|
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}`;
|
|
31281
31293
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
31282
31294
|
}
|
|
31283
31295
|
} else if (Buffer.isBuffer(input)) {
|
|
31284
|
-
buffer =
|
|
31296
|
+
buffer = _chunkDJKLOLBTcjs.toArrayBuffer.call(void 0, input);
|
|
31285
31297
|
} else {
|
|
31286
31298
|
buffer = input;
|
|
31287
31299
|
}
|
|
@@ -31315,40 +31327,40 @@ async function parse(input, options) {
|
|
|
31315
31327
|
}
|
|
31316
31328
|
async function parseImage(buffer, options) {
|
|
31317
31329
|
try {
|
|
31318
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
31330
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-MKD6MKWO.cjs")));
|
|
31319
31331
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
31320
31332
|
return {
|
|
31321
31333
|
success: true,
|
|
31322
31334
|
fileType: "image",
|
|
31323
|
-
markdown:
|
|
31335
|
+
markdown: _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, blocks),
|
|
31324
31336
|
blocks,
|
|
31325
31337
|
warnings: warnings.length ? warnings : void 0,
|
|
31326
31338
|
pageCount: 1
|
|
31327
31339
|
};
|
|
31328
31340
|
} catch (err) {
|
|
31329
|
-
return { success: false, fileType: "image", error:
|
|
31341
|
+
return { success: false, fileType: "image", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31330
31342
|
}
|
|
31331
31343
|
}
|
|
31332
31344
|
async function parseHwp3(buffer, options) {
|
|
31333
31345
|
try {
|
|
31334
31346
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
31335
|
-
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31347
|
+
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _598 => _598.pageCount]) };
|
|
31336
31348
|
} catch (err) {
|
|
31337
|
-
return { success: false, fileType: "hwp3", error:
|
|
31349
|
+
return { success: false, fileType: "hwp3", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31338
31350
|
}
|
|
31339
31351
|
}
|
|
31340
31352
|
async function parseHwpx(buffer, options) {
|
|
31341
31353
|
try {
|
|
31342
31354
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
31343
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
31355
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _599 => _599.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _600 => _600.pageCount]) };
|
|
31344
31356
|
} catch (err) {
|
|
31345
|
-
return { success: false, fileType: "hwpx", error:
|
|
31357
|
+
return { success: false, fileType: "hwpx", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31346
31358
|
}
|
|
31347
31359
|
}
|
|
31348
31360
|
async function parseHwp(buffer, options) {
|
|
31349
31361
|
try {
|
|
31350
31362
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
31351
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
31363
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _601 => _601.filePath])) {
|
|
31352
31364
|
try {
|
|
31353
31365
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
31354
31366
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -31366,15 +31378,15 @@ async function parseHwp(buffer, options) {
|
|
|
31366
31378
|
} catch (e39) {
|
|
31367
31379
|
}
|
|
31368
31380
|
}
|
|
31369
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
31381
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _602 => _602.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _603 => _603.pageCount]) };
|
|
31370
31382
|
} catch (err) {
|
|
31371
|
-
return { success: false, fileType: "hwp", error:
|
|
31383
|
+
return { success: false, fileType: "hwp", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31372
31384
|
}
|
|
31373
31385
|
}
|
|
31374
31386
|
async function parsePdf(buffer, options) {
|
|
31375
31387
|
let parsePdfDocument;
|
|
31376
31388
|
try {
|
|
31377
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
31389
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-SWY4RKGD.cjs")));
|
|
31378
31390
|
parsePdfDocument = mod.parsePdfDocument;
|
|
31379
31391
|
} catch (e40) {
|
|
31380
31392
|
return {
|
|
@@ -31386,51 +31398,51 @@ async function parsePdf(buffer, options) {
|
|
|
31386
31398
|
}
|
|
31387
31399
|
try {
|
|
31388
31400
|
const { markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images } = await parsePdfDocument(buffer, options);
|
|
31389
|
-
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31401
|
+
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images, pageCount: _optionalChain([metadata, 'optionalAccess', _604 => _604.pageCount]) };
|
|
31390
31402
|
} catch (err) {
|
|
31391
31403
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
31392
|
-
return { success: false, fileType: "pdf", error:
|
|
31404
|
+
return { success: false, fileType: "pdf", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err), isImageBased };
|
|
31393
31405
|
}
|
|
31394
31406
|
}
|
|
31395
31407
|
async function parseXlsx(buffer, options) {
|
|
31396
31408
|
try {
|
|
31397
31409
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
31398
|
-
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31410
|
+
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _605 => _605.pageCount]) };
|
|
31399
31411
|
} catch (err) {
|
|
31400
|
-
return { success: false, fileType: "xlsx", error:
|
|
31412
|
+
return { success: false, fileType: "xlsx", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31401
31413
|
}
|
|
31402
31414
|
}
|
|
31403
31415
|
async function parseXls(buffer, options) {
|
|
31404
31416
|
try {
|
|
31405
31417
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
31406
|
-
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31418
|
+
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _606 => _606.pageCount]) };
|
|
31407
31419
|
} catch (err) {
|
|
31408
|
-
return { success: false, fileType: "xls", error:
|
|
31420
|
+
return { success: false, fileType: "xls", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31409
31421
|
}
|
|
31410
31422
|
}
|
|
31411
31423
|
async function parseDocx(buffer, options) {
|
|
31412
31424
|
try {
|
|
31413
31425
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
31414
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
31426
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _607 => _607.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _608 => _608.pageCount]) };
|
|
31415
31427
|
} catch (err) {
|
|
31416
|
-
return { success: false, fileType: "docx", error:
|
|
31428
|
+
return { success: false, fileType: "docx", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31417
31429
|
}
|
|
31418
31430
|
}
|
|
31419
31431
|
async function parseHwpml(buffer, options) {
|
|
31420
31432
|
try {
|
|
31421
31433
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
31422
|
-
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31434
|
+
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _609 => _609.pageCount]) };
|
|
31423
31435
|
} catch (err) {
|
|
31424
|
-
return { success: false, fileType: "hwpml", error:
|
|
31436
|
+
return { success: false, fileType: "hwpml", error: _chunkDJKLOLBTcjs.sanitizeError.call(void 0, err), code: _chunkDJKLOLBTcjs.classifyError.call(void 0, err) };
|
|
31425
31437
|
}
|
|
31426
31438
|
}
|
|
31427
31439
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
31428
31440
|
let buffer;
|
|
31429
31441
|
if (typeof input === "string") {
|
|
31430
31442
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31431
|
-
buffer =
|
|
31443
|
+
buffer = _chunkDJKLOLBTcjs.toArrayBuffer.call(void 0, buf);
|
|
31432
31444
|
} else if (Buffer.isBuffer(input)) {
|
|
31433
|
-
buffer =
|
|
31445
|
+
buffer = _chunkDJKLOLBTcjs.toArrayBuffer.call(void 0, input);
|
|
31434
31446
|
} else {
|
|
31435
31447
|
buffer = input;
|
|
31436
31448
|
}
|
|
@@ -31456,7 +31468,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
31456
31468
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
31457
31469
|
}
|
|
31458
31470
|
const fill = fillFormFields(parsed.blocks, values);
|
|
31459
|
-
const markdown =
|
|
31471
|
+
const markdown = _chunkUSGC3ZKUcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
31460
31472
|
if (outputFormat === "hwpx") {
|
|
31461
31473
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
31462
31474
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -31535,5 +31547,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
31535
31547
|
|
|
31536
31548
|
|
|
31537
31549
|
|
|
31538
|
-
exports.BUILTIN_TEMPLATES = BUILTIN_TEMPLATES; 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 =
|
|
31550
|
+
exports.BUILTIN_TEMPLATES = BUILTIN_TEMPLATES; 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 = _chunkDJKLOLBTcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkUSGC3ZKUcjs.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.extractClickHereFields = extractClickHereFields; 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.readBuiltinTemplate = readBuiltinTemplate; exports.readBuiltinTemplateSample = readBuiltinTemplateSample; exports.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.resolveBuiltinTemplate = resolveBuiltinTemplate; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
31539
31551
|
//# sourceMappingURL=index.cjs.map
|