kordoc 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/{-R6NUMPRV.js → -CWYIC4ES.js} +9 -9
- package/dist/{chunk-W6CUD7V3.js → chunk-2CF2WXBG.js} +3 -3
- package/dist/{chunk-YOZ7ZRCD.js → chunk-45EUJ2P6.js} +310 -76
- package/dist/chunk-45EUJ2P6.js.map +1 -0
- package/dist/{chunk-HNRULYUH.js → chunk-7ZQKECQT.js} +2 -2
- package/dist/{chunk-RZURSA4N.js → chunk-CBUC73JM.js} +3 -3
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-ONS7JKVA.js → chunk-EYLOFSA5.js} +2 -2
- package/dist/{chunk-ONS7JKVA.js.map → chunk-EYLOFSA5.js.map} +1 -1
- package/dist/{chunk-YVYU267E.js → chunk-FT2EXMMP.js} +16 -5
- package/dist/chunk-FT2EXMMP.js.map +1 -0
- package/dist/{chunk-V35DRUJC.js → chunk-GCHH4WHT.js} +2 -2
- package/dist/{chunk-UDGPM5R5.cjs → chunk-GLPLLT4Q.cjs} +4 -4
- package/dist/chunk-GLPLLT4Q.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-HFJF477F.js → chunk-M4I5F6GK.js} +16 -5
- package/dist/chunk-M4I5F6GK.js.map +1 -0
- package/dist/{chunk-GHGZU2LQ.js → chunk-NBOVSNSR.js} +2 -2
- package/dist/{chunk-AB322K3O.cjs → chunk-TCPO6XAY.cjs} +17 -6
- package/dist/chunk-TCPO6XAY.cjs.map +1 -0
- package/dist/{chunk-5KLE3U23.js → chunk-TP4P7M4I.js} +2 -2
- package/dist/{chunk-P7YPCK7C.js → chunk-TTEHX4FN.js} +2 -2
- package/dist/{chunk-SKM6KZUH.cjs → chunk-U3ZNF4SO.cjs} +9 -9
- package/dist/chunk-U3ZNF4SO.cjs.map +1 -0
- package/dist/{chunk-A73RMJ6B.js → chunk-UEWW3DH2.js} +1 -1
- package/dist/{chunk-A73RMJ6B.js.map → chunk-UEWW3DH2.js.map} +1 -1
- package/dist/{chunk-H2KMJOB6.cjs → chunk-UQ6KDJWE.cjs} +2 -2
- package/dist/chunk-UQ6KDJWE.cjs.map +1 -0
- package/dist/{chunk-65DYCXGC.js → chunk-WDIPTY3Q.js} +3 -3
- package/dist/{chunk-XCIC7U6Y.js → chunk-XYSTZIIL.js} +2 -2
- package/dist/{chunk-QXYB74QF.js → chunk-ZHNUH2IW.js} +2 -2
- package/dist/chunk-ZV5OKQ3Z.cjs.map +1 -1
- package/dist/chunks-EYDY4Y6O.js +10 -0
- package/dist/cli.js +54 -19
- package/dist/cli.js.map +1 -1
- package/dist/formula-CG4S7TWO.cjs.map +1 -1
- package/dist/{image-ocr-U2DRRFL3.js → image-ocr-BWQIUUVC.js} +13 -5
- package/dist/image-ocr-BWQIUUVC.js.map +1 -0
- package/dist/{image-ocr-XC52AQDV.js → image-ocr-EDZOUU6Q.js} +14 -6
- package/dist/image-ocr-EDZOUU6Q.js.map +1 -0
- package/dist/{image-ocr-F2BQA26V.cjs → image-ocr-KZ4MGVJ3.cjs} +19 -11
- package/dist/image-ocr-KZ4MGVJ3.cjs.map +1 -0
- package/dist/index.cjs +647 -413
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +305 -71
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +63 -30
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-TFPGQWCC.js → parser-6OJOFJ64.js} +5 -5
- package/dist/{parser-FFQN67O6.cjs → parser-7G2QFIYZ.cjs} +24 -24
- package/dist/parser-7G2QFIYZ.cjs.map +1 -0
- package/dist/{parser-ESGFWWCT.js → parser-JLEKXA2Z.js} +6 -6
- package/dist/pdf-ocr-364VNE6N.cjs +13 -0
- package/dist/pdf-ocr-364VNE6N.cjs.map +1 -0
- package/dist/{pdf-ocr-WE5TMRFU.js → pdf-ocr-OWUZLWQ3.js} +5 -5
- package/dist/pdf-ocr-YQGMCT53.js +12 -0
- package/dist/{profile-io-O6BDCUJN.js → profile-io-FMPT6VEZ.js} +3 -3
- package/dist/{rasterize-V22VCCE7.js → rasterize-LARCX6CS.js} +2 -2
- package/dist/render-4WHQ7JCX.js +10 -0
- package/dist/seal-BX6YA6PI.js +10 -0
- package/dist/{watch-HGKBICED.js → watch-Y2VKD2MN.js} +9 -9
- package/package.json +1 -1
- package/dist/chunk-AB322K3O.cjs.map +0 -1
- package/dist/chunk-H2KMJOB6.cjs.map +0 -1
- package/dist/chunk-HFJF477F.js.map +0 -1
- package/dist/chunk-SKM6KZUH.cjs.map +0 -1
- package/dist/chunk-UDGPM5R5.cjs.map +0 -1
- package/dist/chunk-YOZ7ZRCD.js.map +0 -1
- package/dist/chunk-YVYU267E.js.map +0 -1
- package/dist/chunks-QMGCI5DG.js +0 -10
- package/dist/image-ocr-F2BQA26V.cjs.map +0 -1
- package/dist/image-ocr-U2DRRFL3.js.map +0 -1
- package/dist/image-ocr-XC52AQDV.js.map +0 -1
- package/dist/parser-FFQN67O6.cjs.map +0 -1
- package/dist/pdf-ocr-4R646OO6.js +0 -12
- package/dist/pdf-ocr-UQBZH3HE.cjs +0 -13
- package/dist/pdf-ocr-UQBZH3HE.cjs.map +0 -1
- package/dist/render-3BSVTTZE.js +0 -10
- package/dist/seal-6ZSEJVOD.js +0 -10
- /package/dist/{-R6NUMPRV.js.map → -CWYIC4ES.js.map} +0 -0
- /package/dist/{chunk-W6CUD7V3.js.map → chunk-2CF2WXBG.js.map} +0 -0
- /package/dist/{chunk-HNRULYUH.js.map → chunk-7ZQKECQT.js.map} +0 -0
- /package/dist/{chunk-RZURSA4N.js.map → chunk-CBUC73JM.js.map} +0 -0
- /package/dist/{chunk-V35DRUJC.js.map → chunk-GCHH4WHT.js.map} +0 -0
- /package/dist/{chunk-GHGZU2LQ.js.map → chunk-NBOVSNSR.js.map} +0 -0
- /package/dist/{chunk-5KLE3U23.js.map → chunk-TP4P7M4I.js.map} +0 -0
- /package/dist/{chunk-P7YPCK7C.js.map → chunk-TTEHX4FN.js.map} +0 -0
- /package/dist/{chunk-65DYCXGC.js.map → chunk-WDIPTY3Q.js.map} +0 -0
- /package/dist/{chunk-XCIC7U6Y.js.map → chunk-XYSTZIIL.js.map} +0 -0
- /package/dist/{chunk-QXYB74QF.js.map → chunk-ZHNUH2IW.js.map} +0 -0
- /package/dist/{chunks-QMGCI5DG.js.map → chunks-EYDY4Y6O.js.map} +0 -0
- /package/dist/{parser-TFPGQWCC.js.map → parser-6OJOFJ64.js.map} +0 -0
- /package/dist/{parser-ESGFWWCT.js.map → parser-JLEKXA2Z.js.map} +0 -0
- /package/dist/{pdf-ocr-4R646OO6.js.map → pdf-ocr-OWUZLWQ3.js.map} +0 -0
- /package/dist/{pdf-ocr-WE5TMRFU.js.map → pdf-ocr-YQGMCT53.js.map} +0 -0
- /package/dist/{profile-io-O6BDCUJN.js.map → profile-io-FMPT6VEZ.js.map} +0 -0
- /package/dist/{rasterize-V22VCCE7.js.map → rasterize-LARCX6CS.js.map} +0 -0
- /package/dist/{render-3BSVTTZE.js.map → render-4WHQ7JCX.js.map} +0 -0
- /package/dist/{seal-6ZSEJVOD.js.map → seal-BX6YA6PI.js.map} +0 -0
- /package/dist/{watch-HGKBICED.js.map → watch-Y2VKD2MN.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkGLPLLT4Qcjs = require('./chunk-GLPLLT4Q.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 _chunkUQ6KDJWEcjs = require('./chunk-UQ6KDJWE.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 _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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, _chunkUQ6KDJWEcjs.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(_chunkUQ6KDJWEcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
641
641
|
if (!doc.documentElement) continue;
|
|
642
642
|
const domDoc = doc;
|
|
643
643
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -824,9 +824,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
824
824
|
let level = 0;
|
|
825
825
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _16 => _16.style, 'optionalAccess', _17 => _17.fontSize])) {
|
|
826
826
|
const ratio = block.style.fontSize / baseFontSize;
|
|
827
|
-
if (ratio >=
|
|
828
|
-
else if (ratio >=
|
|
829
|
-
else if (ratio >=
|
|
827
|
+
if (ratio >= _chunkUQ6KDJWEcjs.HEADING_RATIO_H1) level = 1;
|
|
828
|
+
else if (ratio >= _chunkUQ6KDJWEcjs.HEADING_RATIO_H2) level = 2;
|
|
829
|
+
else if (ratio >= _chunkUQ6KDJWEcjs.HEADING_RATIO_H3) level = 3;
|
|
830
830
|
}
|
|
831
831
|
const compactText = text.replace(/\s+/g, "");
|
|
832
832
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1419,7 +1419,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1419
1419
|
|
|
1420
1420
|
// src/hwpx/table-build.ts
|
|
1421
1421
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols, keepEmptyParagraphs) {
|
|
1422
|
-
const table2 =
|
|
1422
|
+
const table2 = _chunkGLPLLT4Qcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols, keepEmptyParagraphs });
|
|
1423
1423
|
if (state.caption) table2.caption = state.caption;
|
|
1424
1424
|
if (_optionalChain([state, 'access', _21 => _21.captionBlocks, 'optionalAccess', _22 => _22.length])) table2.captionBlocks = state.captionBlocks;
|
|
1425
1425
|
const anchors = [];
|
|
@@ -1490,7 +1490,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1490
1490
|
const cell2 = parentTable.cell;
|
|
1491
1491
|
(cell2.blocks ??= []).push(block);
|
|
1492
1492
|
cell2.hasStructure = true;
|
|
1493
|
-
let flat =
|
|
1493
|
+
let flat = _chunkGLPLLT4Qcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1494
1494
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1495
1495
|
if (flat) {
|
|
1496
1496
|
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
@@ -1506,7 +1506,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1506
1506
|
// src/hwpx/section-walker.ts
|
|
1507
1507
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1508
1508
|
const parser = createXmlParser(warnings);
|
|
1509
|
-
const doc = parser.parseFromString(
|
|
1509
|
+
const doc = parser.parseFromString(_chunkUQ6KDJWEcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1510
1510
|
if (!doc.documentElement) return [];
|
|
1511
1511
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1512
1512
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1613,8 +1613,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1613
1613
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1614
1614
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1615
1615
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1616
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1617
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1616
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkGLPLLT4Qcjs.MAX_COLS);
|
|
1617
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkGLPLLT4Qcjs.MAX_ROWS);
|
|
1618
1618
|
}
|
|
1619
1619
|
break;
|
|
1620
1620
|
case "p": {
|
|
@@ -1885,7 +1885,7 @@ function buildSubListTable(el, ctx, depth) {
|
|
|
1885
1885
|
const sink = [];
|
|
1886
1886
|
const st = { rows: [], currentRow: [], cell: null };
|
|
1887
1887
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
1888
|
-
let flat =
|
|
1888
|
+
let flat = _chunkGLPLLT4Qcjs.convertTableToText.call(void 0, st.rows);
|
|
1889
1889
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
1890
1890
|
const built = [];
|
|
1891
1891
|
completeTable(st, [], built, ctx);
|
|
@@ -2040,7 +2040,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2040
2040
|
let url = (ch.textContent || "").trim();
|
|
2041
2041
|
if (!url) continue;
|
|
2042
2042
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2043
|
-
const safe =
|
|
2043
|
+
const safe = _chunkUQ6KDJWEcjs.sanitizeHref.call(void 0, url);
|
|
2044
2044
|
if (safe) return safe;
|
|
2045
2045
|
}
|
|
2046
2046
|
return void 0;
|
|
@@ -2200,7 +2200,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2200
2200
|
case "hyperlink": {
|
|
2201
2201
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2202
2202
|
if (url) {
|
|
2203
|
-
const safe =
|
|
2203
|
+
const safe = _chunkUQ6KDJWEcjs.sanitizeHref.call(void 0, url);
|
|
2204
2204
|
if (safe) href = safe;
|
|
2205
2205
|
}
|
|
2206
2206
|
walk(child, depth + 1);
|
|
@@ -2481,7 +2481,7 @@ function decompressStream(data) {
|
|
|
2481
2481
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2482
2482
|
}
|
|
2483
2483
|
function parseFileHeader(data) {
|
|
2484
|
-
if (data.length < 40) throw new (0,
|
|
2484
|
+
if (data.length < 40) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2485
2485
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2486
2486
|
return {
|
|
2487
2487
|
signature: sig,
|
|
@@ -2933,13 +2933,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2933
2933
|
}
|
|
2934
2934
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
2935
2935
|
for (const path of allCandidates) {
|
|
2936
|
-
if (
|
|
2936
|
+
if (_chunkUQ6KDJWEcjs.isPathTraversal.call(void 0, path)) continue;
|
|
2937
2937
|
const file = zip.file(path);
|
|
2938
2938
|
if (!file) continue;
|
|
2939
2939
|
try {
|
|
2940
2940
|
const data = await file.async("uint8array");
|
|
2941
2941
|
decompressed.total += data.length;
|
|
2942
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2942
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2943
2943
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
2944
2944
|
const mimeType = imageExtToMime(ext);
|
|
2945
2945
|
imageIndex++;
|
|
@@ -2949,7 +2949,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2949
2949
|
usedPaths.add(path);
|
|
2950
2950
|
break;
|
|
2951
2951
|
} catch (err) {
|
|
2952
|
-
if (err instanceof
|
|
2952
|
+
if (err instanceof _chunkUQ6KDJWEcjs.KordocError) throw err;
|
|
2953
2953
|
}
|
|
2954
2954
|
}
|
|
2955
2955
|
if (!img) _optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -2969,11 +2969,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2969
2969
|
if (sweepUnreferenced) {
|
|
2970
2970
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
2971
2971
|
for (const file of binEntries) {
|
|
2972
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
2972
|
+
if (file.dir || usedPaths.has(file.name) || _chunkUQ6KDJWEcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
2973
2973
|
try {
|
|
2974
2974
|
const data = await file.async("uint8array");
|
|
2975
2975
|
decompressed.total += data.length;
|
|
2976
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2976
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2977
2977
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
2978
2978
|
let mimeType = imageExtToMime(ext);
|
|
2979
2979
|
if (mimeType === "application/octet-stream") {
|
|
@@ -2987,7 +2987,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2987
2987
|
images.push(img);
|
|
2988
2988
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
2989
2989
|
} catch (err) {
|
|
2990
|
-
if (err instanceof
|
|
2990
|
+
if (err instanceof _chunkUQ6KDJWEcjs.KordocError) throw err;
|
|
2991
2991
|
_optionalChain([warnings, 'optionalAccess', _82 => _82.push, 'call', _83 => _83({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
2992
2992
|
}
|
|
2993
2993
|
}
|
|
@@ -3038,7 +3038,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3038
3038
|
}
|
|
3039
3039
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3040
3040
|
const name = new TextDecoder().decode(nameBytes);
|
|
3041
|
-
if (
|
|
3041
|
+
if (_chunkUQ6KDJWEcjs.isPathTraversal.call(void 0, name)) {
|
|
3042
3042
|
pos = fileStart + compSize;
|
|
3043
3043
|
continue;
|
|
3044
3044
|
}
|
|
@@ -3056,16 +3056,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3056
3056
|
continue;
|
|
3057
3057
|
}
|
|
3058
3058
|
totalDecompressed += content.length * 2;
|
|
3059
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3059
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3060
3060
|
sectionNum++;
|
|
3061
3061
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3062
3062
|
} catch (e17) {
|
|
3063
3063
|
continue;
|
|
3064
3064
|
}
|
|
3065
3065
|
}
|
|
3066
|
-
if (blocks.length === 0) throw new (0,
|
|
3066
|
+
if (blocks.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3067
3067
|
applyPageText(blocks, shared);
|
|
3068
|
-
const markdown =
|
|
3068
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3069
3069
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3070
3070
|
}
|
|
3071
3071
|
async function readKordocLayout(zip) {
|
|
@@ -3090,18 +3090,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3090
3090
|
if (paths.length > 0) return paths;
|
|
3091
3091
|
}
|
|
3092
3092
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3093
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3093
|
+
return sectionFiles.map((f) => f.name).sort(_chunkUQ6KDJWEcjs.compareSectionPaths);
|
|
3094
3094
|
}
|
|
3095
3095
|
function parseSectionPathsFromManifest(xml) {
|
|
3096
3096
|
const parser = createXmlParser();
|
|
3097
|
-
const doc = parser.parseFromString(
|
|
3097
|
+
const doc = parser.parseFromString(_chunkUQ6KDJWEcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3098
3098
|
const items = doc.getElementsByTagName("opf:item");
|
|
3099
3099
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3100
3100
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3101
3101
|
for (let i = 0; i < items.length; i++) {
|
|
3102
3102
|
const item = items[i];
|
|
3103
3103
|
const id = item.getAttribute("id") || "";
|
|
3104
|
-
const href =
|
|
3104
|
+
const href = _chunkUQ6KDJWEcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3105
3105
|
if (id && href) idToHref.set(id, href);
|
|
3106
3106
|
}
|
|
3107
3107
|
if (spine.length > 0) {
|
|
@@ -3112,7 +3112,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3112
3112
|
}
|
|
3113
3113
|
if (ordered.length > 0) return ordered;
|
|
3114
3114
|
}
|
|
3115
|
-
return Array.from(idToHref.values()).sort(
|
|
3115
|
+
return Array.from(idToHref.values()).sort(_chunkUQ6KDJWEcjs.compareSectionPaths);
|
|
3116
3116
|
}
|
|
3117
3117
|
|
|
3118
3118
|
// src/hwpx/metadata.ts
|
|
@@ -3125,7 +3125,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3125
3125
|
const xml = await file.async("text");
|
|
3126
3126
|
if (decompressed) {
|
|
3127
3127
|
decompressed.total += xml.length * 2;
|
|
3128
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3128
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3129
3129
|
}
|
|
3130
3130
|
parseDublinCoreMetadata(xml, metadata);
|
|
3131
3131
|
if (metadata.title || metadata.author) return;
|
|
@@ -3135,7 +3135,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3135
3135
|
}
|
|
3136
3136
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3137
3137
|
const parser = createXmlParser();
|
|
3138
|
-
const doc = parser.parseFromString(
|
|
3138
|
+
const doc = parser.parseFromString(_chunkUQ6KDJWEcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3139
3139
|
if (!doc.documentElement) return;
|
|
3140
3140
|
const getText = (tagNames) => {
|
|
3141
3141
|
for (const tag of tagNames) {
|
|
@@ -3160,7 +3160,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3160
3160
|
|
|
3161
3161
|
// src/hwpx/parser.ts
|
|
3162
3162
|
async function parseHwpxDocument(buffer, options) {
|
|
3163
|
-
|
|
3163
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3164
3164
|
let zip;
|
|
3165
3165
|
try {
|
|
3166
3166
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3169,7 +3169,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3169
3169
|
}
|
|
3170
3170
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3171
3171
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3172
|
-
throw new (0,
|
|
3172
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3173
3173
|
}
|
|
3174
3174
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3175
3175
|
if (manifestFile) {
|
|
@@ -3184,7 +3184,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3184
3184
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3185
3185
|
}
|
|
3186
3186
|
}
|
|
3187
|
-
throw new (0,
|
|
3187
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
3188
3188
|
"\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
3189
|
);
|
|
3190
3190
|
}
|
|
@@ -3196,7 +3196,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3196
3196
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3197
3197
|
const warnings = [];
|
|
3198
3198
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3199
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3199
|
+
if (sectionPaths.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3200
3200
|
metadata.pageCount = sectionPaths.length;
|
|
3201
3201
|
const pageFilter = _optionalChain([options, 'optionalAccess', _93 => _93.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3202
3202
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3226,7 +3226,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3226
3226
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3227
3227
|
detectHwpxHeadings(blocks, styleMap);
|
|
3228
3228
|
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 =
|
|
3229
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3230
3230
|
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
3231
|
}
|
|
3232
3232
|
|
|
@@ -4226,7 +4226,7 @@ function decryptPasswordStream(raw, password) {
|
|
|
4226
4226
|
var TAG_DOCUMENT_PROPERTIES = 16;
|
|
4227
4227
|
var TAG_ID_MAPPINGS = 17;
|
|
4228
4228
|
function assertDecryptedDocInfo(data, readRecords3) {
|
|
4229
|
-
const wrong = () => new (0,
|
|
4229
|
+
const wrong = () => new (0, _chunkUQ6KDJWEcjs.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
4230
|
let records;
|
|
4231
4231
|
try {
|
|
4232
4232
|
records = readRecords3(data);
|
|
@@ -4238,7 +4238,7 @@ function assertDecryptedDocInfo(data, readRecords3) {
|
|
|
4238
4238
|
}
|
|
4239
4239
|
function assertSupportedEncryptVersion(version) {
|
|
4240
4240
|
if (version !== SUPPORTED_ENCRYPT_VERSION) {
|
|
4241
|
-
throw new (0,
|
|
4241
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
4242
4242
|
`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP \uC554\uD638\uD654 \uBC84\uC804\uC785\uB2C8\uB2E4 (EncryptVersion=${version}, \uC9C0\uC6D0: ${SUPPORTED_ENCRYPT_VERSION})`
|
|
4243
4243
|
);
|
|
4244
4244
|
}
|
|
@@ -4321,7 +4321,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4321
4321
|
lenientCfb = parseLenientCfb(buffer);
|
|
4322
4322
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4323
4323
|
} catch (e24) {
|
|
4324
|
-
throw new (0,
|
|
4324
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4325
4325
|
}
|
|
4326
4326
|
}
|
|
4327
4327
|
const readRawStream = (path) => {
|
|
@@ -4332,14 +4332,14 @@ function parseHwp5Document(buffer, options) {
|
|
|
4332
4332
|
return lenientCfb.findStream(path);
|
|
4333
4333
|
};
|
|
4334
4334
|
const headerData = readRawStream("/FileHeader");
|
|
4335
|
-
if (!headerData) throw new (0,
|
|
4335
|
+
if (!headerData) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4336
4336
|
const header = parseFileHeader(headerData);
|
|
4337
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4338
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4337
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4338
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4339
4339
|
const encrypted = (header.flags & FLAG_ENCRYPTED) !== 0;
|
|
4340
4340
|
if (encrypted) {
|
|
4341
4341
|
if (!_optionalChain([options, 'optionalAccess', _101 => _101.password])) {
|
|
4342
|
-
throw new (0,
|
|
4342
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
4343
|
}
|
|
4344
4344
|
assertSupportedEncryptVersion(readEncryptVersion(headerData));
|
|
4345
4345
|
}
|
|
@@ -4357,18 +4357,18 @@ function parseHwp5Document(buffer, options) {
|
|
|
4357
4357
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4358
4358
|
if (encrypted) {
|
|
4359
4359
|
const rawDocInfo = findStream("/DocInfo");
|
|
4360
|
-
if (!rawDocInfo) throw new (0,
|
|
4360
|
+
if (!rawDocInfo) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("DocInfo \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4361
4361
|
let docInfoData;
|
|
4362
4362
|
try {
|
|
4363
4363
|
docInfoData = compressed ? decompressStream(rawDocInfo) : rawDocInfo;
|
|
4364
4364
|
} catch (e25) {
|
|
4365
|
-
throw new (0,
|
|
4365
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
4366
|
}
|
|
4367
4367
|
assertDecryptedDocInfo(docInfoData, readRecords);
|
|
4368
4368
|
}
|
|
4369
4369
|
const docInfo = cfb && !encrypted ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4370
4370
|
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,
|
|
4371
|
+
if (sections.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4372
4372
|
metadata.pageCount = sections.length;
|
|
4373
4373
|
const pageFilter = _optionalChain([options, 'optionalAccess', _102 => _102.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4374
4374
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4383,22 +4383,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4383
4383
|
const sectionData = sections[si];
|
|
4384
4384
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4385
4385
|
totalDecompressed += data.length;
|
|
4386
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4386
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4387
4387
|
const records = readRecords(data);
|
|
4388
4388
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4389
4389
|
bodyBlocks.push(...sectionBlocks);
|
|
4390
4390
|
parsedSections++;
|
|
4391
4391
|
_optionalChain([options, 'optionalAccess', _104 => _104.onProgress, 'optionalCall', _105 => _105(parsedSections, totalTarget)]);
|
|
4392
4392
|
} catch (secErr) {
|
|
4393
|
-
if (secErr instanceof
|
|
4393
|
+
if (secErr instanceof _chunkUQ6KDJWEcjs.KordocError) throw secErr;
|
|
4394
4394
|
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
4395
|
}
|
|
4396
4396
|
}
|
|
4397
4397
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4398
4398
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4399
|
-
let flatBlocks =
|
|
4399
|
+
let flatBlocks = _chunkGLPLLT4Qcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4400
4400
|
if (_optionalChain([options, 'optionalAccess', _106 => _106.dedupeRunningHeaders])) {
|
|
4401
|
-
const deduped =
|
|
4401
|
+
const deduped = _chunkGLPLLT4Qcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4402
4402
|
const removed = flatBlocks.length - deduped.length;
|
|
4403
4403
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4404
4404
|
flatBlocks = deduped;
|
|
@@ -4407,10 +4407,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4407
4407
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4408
4408
|
}
|
|
4409
4409
|
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 =
|
|
4410
|
+
let markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4411
4411
|
if (_optionalChain([options, 'optionalAccess', _107 => _107.inlineImages]) && images.length > 0) {
|
|
4412
4412
|
try {
|
|
4413
|
-
markdown =
|
|
4413
|
+
markdown = _chunkGLPLLT4Qcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4414
4414
|
} catch (inlineErr) {
|
|
4415
4415
|
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
4416
|
}
|
|
@@ -4474,9 +4474,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4474
4474
|
let level = 0;
|
|
4475
4475
|
if (_optionalChain([block, 'access', _112 => _112.style, 'optionalAccess', _113 => _113.fontSize]) && baseFontSize > 0) {
|
|
4476
4476
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4477
|
-
if (ratio >=
|
|
4478
|
-
else if (ratio >=
|
|
4479
|
-
else if (ratio >=
|
|
4477
|
+
if (ratio >= _chunkUQ6KDJWEcjs.HEADING_RATIO_H1) level = 1;
|
|
4478
|
+
else if (ratio >= _chunkUQ6KDJWEcjs.HEADING_RATIO_H2) level = 2;
|
|
4479
|
+
else if (ratio >= _chunkUQ6KDJWEcjs.HEADING_RATIO_H3) level = 3;
|
|
4480
4480
|
}
|
|
4481
4481
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4482
4482
|
if (level === 0) level = 2;
|
|
@@ -4570,7 +4570,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4570
4570
|
if (!raw) break;
|
|
4571
4571
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4572
4572
|
totalDecompressed += content.length;
|
|
4573
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4573
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4574
4574
|
sections.push({ idx: i, content });
|
|
4575
4575
|
}
|
|
4576
4576
|
if (sections.length === 0) {
|
|
@@ -4582,7 +4582,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4582
4582
|
if (raw) {
|
|
4583
4583
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4584
4584
|
totalDecompressed += content.length;
|
|
4585
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4585
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4586
4586
|
sections.push({ idx, content });
|
|
4587
4587
|
}
|
|
4588
4588
|
}
|
|
@@ -4599,7 +4599,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4599
4599
|
try {
|
|
4600
4600
|
const content = decryptViewText(raw, compressed);
|
|
4601
4601
|
totalDecompressed += content.length;
|
|
4602
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4602
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4603
4603
|
sections.push({ idx: i, content });
|
|
4604
4604
|
} catch (e30) {
|
|
4605
4605
|
break;
|
|
@@ -4702,7 +4702,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4702
4702
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4703
4703
|
if (!_optionalChain([ctrl, 'optionalAccess', _120 => _120.href]) || r.end <= r.start) continue;
|
|
4704
4704
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4705
|
-
const href =
|
|
4705
|
+
const href = _chunkUQ6KDJWEcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4706
4706
|
if (!href) continue;
|
|
4707
4707
|
const anchor = text.slice(r.start, r.end);
|
|
4708
4708
|
if (!anchor.trim()) continue;
|
|
@@ -4938,8 +4938,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4938
4938
|
let tableIdx = -1;
|
|
4939
4939
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4940
4940
|
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),
|
|
4941
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkGLPLLT4Qcjs.MAX_ROWS);
|
|
4942
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkGLPLLT4Qcjs.MAX_COLS);
|
|
4943
4943
|
tableIdx = i2;
|
|
4944
4944
|
break;
|
|
4945
4945
|
}
|
|
@@ -4988,7 +4988,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4988
4988
|
return table3;
|
|
4989
4989
|
}
|
|
4990
4990
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4991
|
-
const table2 =
|
|
4991
|
+
const table2 = _chunkGLPLLT4Qcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
4992
4992
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
4993
4993
|
return table2.rows > 0 ? table2 : null;
|
|
4994
4994
|
}
|
|
@@ -5005,8 +5005,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5005
5005
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5006
5006
|
const cs = rec.data.readUInt16LE(12);
|
|
5007
5007
|
const rs = rec.data.readUInt16LE(14);
|
|
5008
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5009
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5008
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkGLPLLT4Qcjs.MAX_COLS);
|
|
5009
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkGLPLLT4Qcjs.MAX_ROWS);
|
|
5010
5010
|
}
|
|
5011
5011
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5012
5012
|
const parts = [];
|
|
@@ -5016,7 +5016,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5016
5016
|
parts.push(``);
|
|
5017
5017
|
hasStructure = true;
|
|
5018
5018
|
} else if (b.type === "table" && b.table) {
|
|
5019
|
-
const flat =
|
|
5019
|
+
const flat = _chunkGLPLLT4Qcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5020
5020
|
if (flat) parts.push(flat);
|
|
5021
5021
|
hasStructure = true;
|
|
5022
5022
|
} else if (b.text) {
|
|
@@ -17287,25 +17287,25 @@ function desEcbDecrypt(data, key) {
|
|
|
17287
17287
|
}
|
|
17288
17288
|
function readLayout(data) {
|
|
17289
17289
|
if (data.length < FIXED_HEADER_BYTES) {
|
|
17290
|
-
throw new (0,
|
|
17290
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uD5E4\uB354\uAC00 \uC798\uB838\uC2B5\uB2C8\uB2E4");
|
|
17291
17291
|
}
|
|
17292
17292
|
const infoBlockLength = data[INFO_BLOCK_LENGTH_OFFSET] | data[INFO_BLOCK_LENGTH_OFFSET + 1] << 8;
|
|
17293
17293
|
const payloadOffset = FIXED_HEADER_BYTES + infoBlockLength;
|
|
17294
17294
|
if (payloadOffset >= data.length) {
|
|
17295
|
-
throw new (0,
|
|
17295
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17296
17296
|
}
|
|
17297
17297
|
return { payloadOffset, compressed: data[COMPRESSION_FLAG_OFFSET] !== 0 };
|
|
17298
17298
|
}
|
|
17299
17299
|
function decryptHwp3Document(input, password) {
|
|
17300
17300
|
const { payloadOffset, compressed } = readLayout(input);
|
|
17301
17301
|
if (!compressed) {
|
|
17302
|
-
throw new (0,
|
|
17302
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
17303
|
}
|
|
17304
17304
|
const source = Buffer.from(input);
|
|
17305
17305
|
const payload = source.subarray(payloadOffset);
|
|
17306
17306
|
const aligned = payload.subarray(0, payload.length - payload.length % 8);
|
|
17307
17307
|
if (aligned.length === 0) {
|
|
17308
|
-
throw new (0,
|
|
17308
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4");
|
|
17309
17309
|
}
|
|
17310
17310
|
const decrypted = desEcbDecrypt(aligned, deriveDesKey(password));
|
|
17311
17311
|
let inflated;
|
|
@@ -17313,14 +17313,14 @@ function decryptHwp3Document(input, password) {
|
|
|
17313
17313
|
inflated = _zlib.inflateRawSync.call(void 0, decrypted, { maxOutputLength: MAX_DECOMPRESSED_BYTES });
|
|
17314
17314
|
} catch (err) {
|
|
17315
17315
|
if (_optionalChain([err, 'optionalAccess', _133 => _133.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17316
|
-
throw new (0,
|
|
17316
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
17317
17317
|
`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
17318
|
);
|
|
17319
17319
|
}
|
|
17320
|
-
throw new (0,
|
|
17320
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
17321
|
}
|
|
17322
17322
|
if (inflated.length <= PASSWORD_PREFIX_BYTES) {
|
|
17323
|
-
throw new (0,
|
|
17323
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
17324
|
}
|
|
17325
17325
|
const body = inflated.subarray(PASSWORD_PREFIX_BYTES);
|
|
17326
17326
|
const out = Buffer.concat([source.subarray(0, payloadOffset), body]);
|
|
@@ -17355,7 +17355,7 @@ function parseHwp3Document(buffer, options) {
|
|
|
17355
17355
|
let source = Buffer.from(buffer);
|
|
17356
17356
|
if (isEncryptedHwp3(source)) {
|
|
17357
17357
|
if (!_optionalChain([options, 'optionalAccess', _134 => _134.password])) {
|
|
17358
|
-
throw new (0,
|
|
17358
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
17359
17359
|
"\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
17360
|
);
|
|
17361
17361
|
}
|
|
@@ -17372,10 +17372,10 @@ function parseHwp3Document(buffer, options) {
|
|
|
17372
17372
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17373
17373
|
} catch (err) {
|
|
17374
17374
|
if (_optionalChain([err, 'optionalAccess', _135 => _135.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17375
|
-
throw new (0,
|
|
17375
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
17376
|
}
|
|
17377
17377
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
17378
|
-
throw new (0,
|
|
17378
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`HWP3 \uC555\uCD95 \uD574\uC81C \uC2E4\uD328: ${msg2}`);
|
|
17379
17379
|
}
|
|
17380
17380
|
} else {
|
|
17381
17381
|
body = tail;
|
|
@@ -17617,7 +17617,7 @@ function getTextContent(el) {
|
|
|
17617
17617
|
return _nullishCoalesce(_optionalChain([el, 'access', _138 => _138.textContent, 'optionalAccess', _139 => _139.trim, 'call', _140 => _140()]), () => ( ""));
|
|
17618
17618
|
}
|
|
17619
17619
|
function parseXml(text) {
|
|
17620
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17620
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkUQ6KDJWEcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17621
17621
|
}
|
|
17622
17622
|
function collectRichText(root) {
|
|
17623
17623
|
let out = "";
|
|
@@ -17852,7 +17852,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
17852
17852
|
cellRows.push(row);
|
|
17853
17853
|
}
|
|
17854
17854
|
if (cellRows.length > 0) {
|
|
17855
|
-
const table2 =
|
|
17855
|
+
const table2 = _chunkGLPLLT4Qcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
17856
17856
|
if (table2.rows > 0) {
|
|
17857
17857
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17858
17858
|
}
|
|
@@ -17860,12 +17860,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
17860
17860
|
return blocks;
|
|
17861
17861
|
}
|
|
17862
17862
|
async function parseXlsxDocument(buffer, options) {
|
|
17863
|
-
|
|
17863
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
17864
17864
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
17865
17865
|
const warnings = [];
|
|
17866
17866
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
17867
17867
|
if (!workbookFile) {
|
|
17868
|
-
throw new (0,
|
|
17868
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17869
17869
|
}
|
|
17870
17870
|
let sharedStrings = [];
|
|
17871
17871
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17874,7 +17874,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17874
17874
|
}
|
|
17875
17875
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
17876
17876
|
if (sheets.length === 0) {
|
|
17877
|
-
throw new (0,
|
|
17877
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17878
17878
|
}
|
|
17879
17879
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
17880
17880
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -17958,7 +17958,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17958
17958
|
} catch (e32) {
|
|
17959
17959
|
}
|
|
17960
17960
|
}
|
|
17961
|
-
const markdown =
|
|
17961
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17962
17962
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17963
17963
|
}
|
|
17964
17964
|
|
|
@@ -18409,11 +18409,11 @@ function processGlobals(records) {
|
|
|
18409
18409
|
const xfFmtIds = [];
|
|
18410
18410
|
const firstBof = records[0];
|
|
18411
18411
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18412
|
-
throw new (0,
|
|
18412
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18413
18413
|
}
|
|
18414
18414
|
const bof = decodeBof(firstBof.data);
|
|
18415
18415
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18416
|
-
throw new (0,
|
|
18416
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18417
18417
|
}
|
|
18418
18418
|
let i = 1;
|
|
18419
18419
|
while (i < records.length) {
|
|
@@ -18548,7 +18548,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18548
18548
|
cellRows.push(row);
|
|
18549
18549
|
}
|
|
18550
18550
|
if (cellRows.length > 0) {
|
|
18551
|
-
const table2 =
|
|
18551
|
+
const table2 = _chunkGLPLLT4Qcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18552
18552
|
if (table2.rows > 0) {
|
|
18553
18553
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18554
18554
|
}
|
|
@@ -18561,28 +18561,28 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18561
18561
|
try {
|
|
18562
18562
|
cfb = parseLenientCfb(buf);
|
|
18563
18563
|
} catch (e) {
|
|
18564
|
-
throw new (0,
|
|
18564
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
18565
18565
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18566
18566
|
);
|
|
18567
18567
|
}
|
|
18568
18568
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18569
18569
|
if (!wb) {
|
|
18570
|
-
throw new (0,
|
|
18570
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18571
18571
|
}
|
|
18572
18572
|
const records = readRecords2(wb);
|
|
18573
18573
|
if (records.length === 0) {
|
|
18574
|
-
throw new (0,
|
|
18574
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18575
18575
|
}
|
|
18576
18576
|
const firstBof = decodeBof(records[0].data);
|
|
18577
18577
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18578
|
-
throw new (0,
|
|
18578
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
18579
18579
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18580
18580
|
);
|
|
18581
18581
|
}
|
|
18582
18582
|
const globals = processGlobals(records);
|
|
18583
18583
|
const warnings = [];
|
|
18584
18584
|
if (globals.encrypted) {
|
|
18585
|
-
throw new (0,
|
|
18585
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("XLS \uD30C\uC77C\uC774 \uC554\uD638\uD654\uB418\uC5B4 \uC788\uC5B4 \uD30C\uC2F1\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18586
18586
|
}
|
|
18587
18587
|
const convertNum = globals.dateXfs.size > 0 ? (n, ixfe) => {
|
|
18588
18588
|
const kind = globals.dateXfs.get(ixfe);
|
|
@@ -18633,7 +18633,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18633
18633
|
pageCount: totalSheets
|
|
18634
18634
|
};
|
|
18635
18635
|
return {
|
|
18636
|
-
markdown:
|
|
18636
|
+
markdown: _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18637
18637
|
blocks: allBlocks,
|
|
18638
18638
|
metadata,
|
|
18639
18639
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19061,7 +19061,7 @@ function getAttr(el, localName2) {
|
|
|
19061
19061
|
return null;
|
|
19062
19062
|
}
|
|
19063
19063
|
function parseXml2(text) {
|
|
19064
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19064
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkUQ6KDJWEcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19065
19065
|
}
|
|
19066
19066
|
function parseStyles(xml) {
|
|
19067
19067
|
const doc = parseXml2(xml);
|
|
@@ -19219,7 +19219,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19219
19219
|
function makeLink(text, rawHref) {
|
|
19220
19220
|
if (!text) return "";
|
|
19221
19221
|
if (!rawHref) return text;
|
|
19222
|
-
const href =
|
|
19222
|
+
const href = _chunkUQ6KDJWEcjs.sanitizeHref.call(void 0, rawHref);
|
|
19223
19223
|
return href ? `[${text}](${href})` : text;
|
|
19224
19224
|
}
|
|
19225
19225
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19413,7 +19413,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19413
19413
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19414
19414
|
})
|
|
19415
19415
|
);
|
|
19416
|
-
const table2 =
|
|
19416
|
+
const table2 = _chunkGLPLLT4Qcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19417
19417
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19418
19418
|
return { type: "table", table: table2 };
|
|
19419
19419
|
}
|
|
@@ -19515,12 +19515,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19515
19515
|
}
|
|
19516
19516
|
}
|
|
19517
19517
|
async function parseDocxDocument(buffer, options) {
|
|
19518
|
-
|
|
19518
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19519
19519
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19520
19520
|
const warnings = [];
|
|
19521
19521
|
const docFile = zip.file("word/document.xml");
|
|
19522
19522
|
if (!docFile) {
|
|
19523
|
-
throw new (0,
|
|
19523
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19524
19524
|
}
|
|
19525
19525
|
let rels = /* @__PURE__ */ new Map();
|
|
19526
19526
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19567,7 +19567,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19567
19567
|
const doc = parseXml2(docXml);
|
|
19568
19568
|
const body = findElements(doc, "body");
|
|
19569
19569
|
if (body.length === 0) {
|
|
19570
|
-
throw new (0,
|
|
19570
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19571
19571
|
}
|
|
19572
19572
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19573
19573
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19618,7 +19618,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19618
19618
|
}
|
|
19619
19619
|
}
|
|
19620
19620
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19621
|
-
const markdown =
|
|
19621
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19622
19622
|
return {
|
|
19623
19623
|
markdown,
|
|
19624
19624
|
blocks,
|
|
@@ -19636,11 +19636,11 @@ var MAX_TABLE_COLS = 500;
|
|
|
19636
19636
|
var MAX_HWPML_BYTES = 50 * 1024 * 1024;
|
|
19637
19637
|
function parseHwpmlDocument(buffer, options) {
|
|
19638
19638
|
if (buffer.byteLength > MAX_HWPML_BYTES) {
|
|
19639
|
-
throw new (0,
|
|
19639
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`HWPML \uD30C\uC77C \uD06C\uAE30 \uCD08\uACFC (${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB > 50MB)`);
|
|
19640
19640
|
}
|
|
19641
19641
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19642
19642
|
const normalized = text.replace(/ /g, " ");
|
|
19643
|
-
const xml =
|
|
19643
|
+
const xml = _chunkUQ6KDJWEcjs.stripDtd.call(void 0, normalized);
|
|
19644
19644
|
const warnings = [];
|
|
19645
19645
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19646
19646
|
onError: (_level, msg2) => {
|
|
@@ -19680,7 +19680,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19680
19680
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _184 => _184.keepTrailingEmptyCols]), () => ( false)));
|
|
19681
19681
|
}
|
|
19682
19682
|
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 =
|
|
19683
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19684
19684
|
return {
|
|
19685
19685
|
markdown,
|
|
19686
19686
|
blocks,
|
|
@@ -19845,7 +19845,7 @@ function buildHmlTable(el, warnings, keep, tableDepth) {
|
|
|
19845
19845
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
19846
19846
|
cellRows[r].push(cell2);
|
|
19847
19847
|
}
|
|
19848
|
-
const table2 =
|
|
19848
|
+
const table2 = _chunkGLPLLT4Qcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
19849
19849
|
if (structured.length > 0) {
|
|
19850
19850
|
const claimed = /* @__PURE__ */ new Set();
|
|
19851
19851
|
for (const { ctx, cellBlocks } of structured) {
|
|
@@ -21356,7 +21356,7 @@ function fillClickHereInXml(xml, cursor, blockedLabels) {
|
|
|
21356
21356
|
};
|
|
21357
21357
|
}
|
|
21358
21358
|
async function extractClickHereFields(hwpxBuffer) {
|
|
21359
|
-
|
|
21359
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21360
21360
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21361
21361
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21362
21362
|
const fields = [];
|
|
@@ -21404,19 +21404,19 @@ function parseCentralDirectory(buf) {
|
|
|
21404
21404
|
}
|
|
21405
21405
|
}
|
|
21406
21406
|
}
|
|
21407
|
-
if (eocdOffset < 0) throw new (0,
|
|
21407
|
+
if (eocdOffset < 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21408
21408
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21409
21409
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21410
21410
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21411
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21411
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21412
21412
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21413
|
-
throw new (0,
|
|
21413
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21414
21414
|
}
|
|
21415
21415
|
const decoder = new TextDecoder("utf-8");
|
|
21416
21416
|
const entries = [];
|
|
21417
21417
|
let pos = cdOffset;
|
|
21418
21418
|
for (let i = 0; i < totalEntries; i++) {
|
|
21419
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21419
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21420
21420
|
const flags = view.getUint16(pos + 8, true);
|
|
21421
21421
|
const method = view.getUint16(pos + 10, true);
|
|
21422
21422
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21427,7 +21427,7 @@ function parseCentralDirectory(buf) {
|
|
|
21427
21427
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21428
21428
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21429
21429
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21430
|
-
throw new (0,
|
|
21430
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21431
21431
|
}
|
|
21432
21432
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21433
21433
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21456,11 +21456,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21456
21456
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21457
21457
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21458
21458
|
for (const name of replacements.keys()) {
|
|
21459
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21459
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21460
21460
|
}
|
|
21461
21461
|
if (additions) {
|
|
21462
21462
|
for (const name of additions.keys()) {
|
|
21463
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21463
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21464
21464
|
}
|
|
21465
21465
|
}
|
|
21466
21466
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21479,7 +21479,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21479
21479
|
offset += seg.length;
|
|
21480
21480
|
continue;
|
|
21481
21481
|
}
|
|
21482
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21482
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21483
21483
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21484
21484
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21485
21485
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21487,7 +21487,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21487
21487
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21488
21488
|
const method = e.method;
|
|
21489
21489
|
if (method !== 0 && method !== 8) {
|
|
21490
|
-
throw new (0,
|
|
21490
|
+
throw new (0, _chunkUQ6KDJWEcjs.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
21491
|
}
|
|
21492
21492
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21493
21493
|
const crc = crc32(newData);
|
|
@@ -21585,11 +21585,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21585
21585
|
// src/form/filler-hwpx.ts
|
|
21586
21586
|
async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
21587
21587
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
21588
|
-
|
|
21588
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21589
21589
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21590
21590
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21591
21591
|
if (sectionPaths.length === 0) {
|
|
21592
|
-
throw new (0,
|
|
21592
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21593
21593
|
}
|
|
21594
21594
|
const warnings = [];
|
|
21595
21595
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22331,7 +22331,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
22331
22331
|
}
|
|
22332
22332
|
function assertFiniteRange(name, value, min, max) {
|
|
22333
22333
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
22334
|
-
throw new (0,
|
|
22334
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
22335
22335
|
}
|
|
22336
22336
|
}
|
|
22337
22337
|
function validateGongmunOptions(opts) {
|
|
@@ -22346,10 +22346,10 @@ function validateGongmunOptions(opts) {
|
|
|
22346
22346
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
22347
22347
|
}
|
|
22348
22348
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
22349
|
-
throw new (0,
|
|
22349
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
22350
22350
|
}
|
|
22351
22351
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
22352
|
-
throw new (0,
|
|
22352
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
22353
22353
|
}
|
|
22354
22354
|
}
|
|
22355
22355
|
if (opts.sizes) {
|
|
@@ -22358,7 +22358,7 @@ function validateGongmunOptions(opts) {
|
|
|
22358
22358
|
}
|
|
22359
22359
|
}
|
|
22360
22360
|
if (opts.approval && opts.approval.length > 6) {
|
|
22361
|
-
throw new (0,
|
|
22361
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("approval must contain at most 6 labels");
|
|
22362
22362
|
}
|
|
22363
22363
|
}
|
|
22364
22364
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -22669,6 +22669,26 @@ function charVariantBase(richAssets, isGongmun = true) {
|
|
|
22669
22669
|
var GONGMUN_BODY_RATIO = 95;
|
|
22670
22670
|
|
|
22671
22671
|
// src/hwpx/md-runs.ts
|
|
22672
|
+
var HYPERLINK_FIELDID = 627600491;
|
|
22673
|
+
var FIELD_ID_BASE = 18e8;
|
|
22674
|
+
var FOOTNOTE_INST_BASE = 185e7;
|
|
22675
|
+
var inlineDoc = null;
|
|
22676
|
+
function beginInlineDoc(footnotes) {
|
|
22677
|
+
inlineDoc = { footnotes, fieldSeq: 0, noteSeq: 0, inNote: false };
|
|
22678
|
+
}
|
|
22679
|
+
function endInlineDoc() {
|
|
22680
|
+
inlineDoc = null;
|
|
22681
|
+
}
|
|
22682
|
+
function extractFootnoteDefs(md2) {
|
|
22683
|
+
const defs = /* @__PURE__ */ new Map();
|
|
22684
|
+
const out = md2.replace(/\r\n?/g, "\n").split("\n").filter((line) => {
|
|
22685
|
+
const m = /^\[\^([^\]\s]+)\]:\s?(.*)$/.exec(line);
|
|
22686
|
+
if (!m) return true;
|
|
22687
|
+
defs.set(m[1], m[2].trim());
|
|
22688
|
+
return false;
|
|
22689
|
+
}).join("\n");
|
|
22690
|
+
return { md: defs.size > 0 ? out : md2, defs };
|
|
22691
|
+
}
|
|
22672
22692
|
function buildPrvText(blocks) {
|
|
22673
22693
|
const lines = [];
|
|
22674
22694
|
let bytes = 0;
|
|
@@ -22860,8 +22880,45 @@ function parseInlineMarkdown(text) {
|
|
|
22860
22880
|
return `\0${literals.length - 1}\0`;
|
|
22861
22881
|
});
|
|
22862
22882
|
text = text.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
|
|
22863
|
-
text = text.replace(/\[([^\]]*)\]\(([^)]*)\)/g, (_, t, u) => t || u);
|
|
22864
22883
|
text = text.replace(/~~([^~]+)~~/g, "$1");
|
|
22884
|
+
let spans;
|
|
22885
|
+
if (inlineDoc) {
|
|
22886
|
+
spans = [];
|
|
22887
|
+
const re = /\[\^([^\]\s]+)\]|\[([^\]]*)\]\(([^)]*)\)/g;
|
|
22888
|
+
let last = 0;
|
|
22889
|
+
for (const m of text.matchAll(re)) {
|
|
22890
|
+
const idx = m.index;
|
|
22891
|
+
if (idx > last) spans.push(...emphasisSpans(text.slice(last, idx)));
|
|
22892
|
+
if (m[1] !== void 0) {
|
|
22893
|
+
const def = inlineDoc.inNote ? void 0 : inlineDoc.footnotes.get(m[1]);
|
|
22894
|
+
if (def !== void 0) spans.push({ text: "", bold: false, italic: false, code: false, note: def });
|
|
22895
|
+
else spans.push(...emphasisSpans(m[0]));
|
|
22896
|
+
} else {
|
|
22897
|
+
const anchor = m[2] || m[3];
|
|
22898
|
+
const href = _nullishCoalesce(_chunkUQ6KDJWEcjs.sanitizeHref.call(void 0, m[3].trim()), () => ( void 0));
|
|
22899
|
+
const sub = emphasisSpans(anchor);
|
|
22900
|
+
if (href) for (const s of sub) s.href = href;
|
|
22901
|
+
spans.push(...sub);
|
|
22902
|
+
}
|
|
22903
|
+
last = idx + m[0].length;
|
|
22904
|
+
}
|
|
22905
|
+
if (last < text.length) spans.push(...emphasisSpans(text.slice(last)));
|
|
22906
|
+
if (spans.length === 0) spans.push({ text, bold: false, italic: false, code: false });
|
|
22907
|
+
} else {
|
|
22908
|
+
text = text.replace(/\[([^\]]*)\]\(([^)]*)\)/g, (_, t, u) => t || u);
|
|
22909
|
+
spans = emphasisSpans(text);
|
|
22910
|
+
if (spans.length === 0) spans.push({ text, bold: false, italic: false, code: false });
|
|
22911
|
+
}
|
|
22912
|
+
for (const span of spans) {
|
|
22913
|
+
if (!span.text.includes("\0")) continue;
|
|
22914
|
+
span.text = span.text.replace(/\x00(\d+)\x00/g, (_, i) => {
|
|
22915
|
+
const c = _nullishCoalesce(literals[+i], () => ( ""));
|
|
22916
|
+
return span.code ? "\\" + c : c;
|
|
22917
|
+
});
|
|
22918
|
+
}
|
|
22919
|
+
return spans;
|
|
22920
|
+
}
|
|
22921
|
+
function emphasisSpans(text) {
|
|
22865
22922
|
const spans = [];
|
|
22866
22923
|
const regex = /(`[^`]+`|\*{3}[^*]+\*{3}|\*{2}[^*]+\*{2}|\*[^*]+\*|(?<![^\s\p{P}\p{S}\x00])(?<!_)_{2}(?=\S)[^_]+(?<=\S)_{2}(?!_)(?![^\s\p{P}\p{S}\x00])|(?<![^\s\p{P}\p{S}\x00])(?<!_)_(?=\S)[^_]+(?<=\S)_(?!_)(?![^\s\p{P}\p{S}\x00]))/gu;
|
|
22867
22924
|
let lastIdx = 0;
|
|
@@ -22885,16 +22942,6 @@ function parseInlineMarkdown(text) {
|
|
|
22885
22942
|
if (lastIdx < text.length) {
|
|
22886
22943
|
spans.push({ text: text.slice(lastIdx), bold: false, italic: false, code: false });
|
|
22887
22944
|
}
|
|
22888
|
-
if (spans.length === 0) {
|
|
22889
|
-
spans.push({ text, bold: false, italic: false, code: false });
|
|
22890
|
-
}
|
|
22891
|
-
for (const span of spans) {
|
|
22892
|
-
if (!span.text.includes("\0")) continue;
|
|
22893
|
-
span.text = span.text.replace(/\x00(\d+)\x00/g, (_, i) => {
|
|
22894
|
-
const c = _nullishCoalesce(literals[+i], () => ( ""));
|
|
22895
|
-
return span.code ? "\\" + c : c;
|
|
22896
|
-
});
|
|
22897
|
-
}
|
|
22898
22945
|
return spans;
|
|
22899
22946
|
}
|
|
22900
22947
|
function spanToCharPrId(span) {
|
|
@@ -22904,13 +22951,54 @@ function spanToCharPrId(span) {
|
|
|
22904
22951
|
if (span.italic) return CHAR_ITALIC;
|
|
22905
22952
|
return CHAR_NORMAL;
|
|
22906
22953
|
}
|
|
22954
|
+
function hyperlinkBeginXml(fid, href) {
|
|
22955
|
+
const cmd = escapeXml(href.replace(/:/g, "\\:"));
|
|
22956
|
+
const path = escapeXml(href);
|
|
22957
|
+
return `<hp:ctrl><hp:fieldBegin id="${fid}" type="HYPERLINK" name="" editable="0" dirty="0" zorder="-1" fieldid="${HYPERLINK_FIELDID}"><hp:parameters cnt="6" name=""><hp:integerParam name="Prop">0</hp:integerParam><hp:stringParam name="Command">${cmd};1;0;0</hp:stringParam><hp:stringParam name="Path">${path}</hp:stringParam><hp:stringParam name="Category">HWPHYPERLINK_TYPE_URL</hp:stringParam><hp:stringParam name="TargetType">HWPHYPERLINK_TARGET_BOOKMARK</hp:stringParam><hp:stringParam name="DocOpenType">HWPHYPERLINK_JUMP_CURRENTTAB</hp:stringParam></hp:parameters></hp:fieldBegin></hp:ctrl>`;
|
|
22958
|
+
}
|
|
22959
|
+
function footnoteXml(note, mapCharId) {
|
|
22960
|
+
const d = inlineDoc;
|
|
22961
|
+
const n = ++d.noteSeq;
|
|
22962
|
+
d.inNote = true;
|
|
22963
|
+
let body;
|
|
22964
|
+
try {
|
|
22965
|
+
body = generateRuns(note, CHAR_NORMAL, mapCharId);
|
|
22966
|
+
} finally {
|
|
22967
|
+
d.inNote = false;
|
|
22968
|
+
}
|
|
22969
|
+
return `<hp:ctrl><hp:footNote number="${n}" suffixChar="41" instId="${FOOTNOTE_INST_BASE + n}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0"><hp:p paraPrIDRef="0" styleIDRef="0">${body}</hp:p></hp:subList></hp:footNote></hp:ctrl>`;
|
|
22970
|
+
}
|
|
22907
22971
|
function generateRuns(text, defaultCharPr = CHAR_NORMAL, mapCharId) {
|
|
22908
22972
|
const spans = parseInlineMarkdown(text);
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22973
|
+
const mapped = (id) => mapCharId ? mapCharId(id) : id;
|
|
22974
|
+
const out = [];
|
|
22975
|
+
let openHref = null;
|
|
22976
|
+
let openFid = 0;
|
|
22977
|
+
const closeField = () => {
|
|
22978
|
+
if (openHref === null) return;
|
|
22979
|
+
out.push(`<hp:run charPrIDRef="${mapped(defaultCharPr)}"><hp:ctrl><hp:fieldEnd beginIDRef="${openFid}" fieldid="${HYPERLINK_FIELDID}"/></hp:ctrl></hp:run>`);
|
|
22980
|
+
openHref = null;
|
|
22981
|
+
};
|
|
22982
|
+
for (const span of spans) {
|
|
22983
|
+
if (span.note !== void 0 && inlineDoc) {
|
|
22984
|
+
closeField();
|
|
22985
|
+
out.push(`<hp:run charPrIDRef="${mapped(defaultCharPr)}">${footnoteXml(span.note, mapCharId)}</hp:run>`);
|
|
22986
|
+
continue;
|
|
22987
|
+
}
|
|
22988
|
+
const href = inlineDoc ? _nullishCoalesce(span.href, () => ( null)) : null;
|
|
22989
|
+
if (href !== openHref) {
|
|
22990
|
+
closeField();
|
|
22991
|
+
if (href !== null) {
|
|
22992
|
+
openFid = FIELD_ID_BASE + ++inlineDoc.fieldSeq;
|
|
22993
|
+
openHref = href;
|
|
22994
|
+
out.push(`<hp:run charPrIDRef="${mapped(defaultCharPr)}">${hyperlinkBeginXml(openFid, href)}</hp:run>`);
|
|
22995
|
+
}
|
|
22996
|
+
}
|
|
22997
|
+
const charId = span.code || span.bold || span.italic ? spanToCharPrId(span) : defaultCharPr;
|
|
22998
|
+
out.push(`<hp:run charPrIDRef="${mapped(charId)}"><hp:t>${escapeXml(span.text)}</hp:t></hp:run>`);
|
|
22999
|
+
}
|
|
23000
|
+
closeField();
|
|
23001
|
+
return out.join("");
|
|
22914
23002
|
}
|
|
22915
23003
|
function generateParagraph(text, paraPrId = PARA_NORMAL, charPrId = CHAR_NORMAL, mapCharId, styleId = 0) {
|
|
22916
23004
|
if (paraPrId === PARA_CODE) {
|
|
@@ -22920,6 +23008,56 @@ function generateParagraph(text, paraPrId = PARA_NORMAL, charPrId = CHAR_NORMAL,
|
|
|
22920
23008
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="${styleId}">${runs}</hp:p>`;
|
|
22921
23009
|
}
|
|
22922
23010
|
|
|
23011
|
+
// src/hwpx/gen-page.ts
|
|
23012
|
+
var PAPER_MM = {
|
|
23013
|
+
A4: [210, 297],
|
|
23014
|
+
A3: [297, 420],
|
|
23015
|
+
B4: [257, 364],
|
|
23016
|
+
B5: [182, 257],
|
|
23017
|
+
Letter: [215.9, 279.4]
|
|
23018
|
+
};
|
|
23019
|
+
function resolvePage(opts) {
|
|
23020
|
+
if (!opts) return null;
|
|
23021
|
+
const { size, orientation, columns, header, footer } = opts;
|
|
23022
|
+
if (size === void 0 && orientation === void 0 && columns === void 0 && header === void 0 && footer === void 0) return null;
|
|
23023
|
+
let wMm = 210, hMm = 297;
|
|
23024
|
+
if (size !== void 0) {
|
|
23025
|
+
if (typeof size === "string") {
|
|
23026
|
+
const preset = PAPER_MM[size];
|
|
23027
|
+
if (!preset) throw new Error(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC6A9\uC9C0 \uD504\uB9AC\uC14B: ${size} (A4\xB7A3\xB7B4\xB7B5\xB7Letter)`);
|
|
23028
|
+
[wMm, hMm] = preset;
|
|
23029
|
+
} else {
|
|
23030
|
+
if (!(size.widthMm > 0) || !(size.heightMm > 0) || size.widthMm > 1e3 || size.heightMm > 1e3) {
|
|
23031
|
+
throw new Error(`\uC6A9\uC9C0 \uCE58\uC218\uB294 0~1000mm \uBC94\uC704\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${size.widthMm}\xD7${size.heightMm}`);
|
|
23032
|
+
}
|
|
23033
|
+
wMm = size.widthMm;
|
|
23034
|
+
hMm = size.heightMm;
|
|
23035
|
+
}
|
|
23036
|
+
}
|
|
23037
|
+
const cols = _nullishCoalesce(columns, () => ( 1));
|
|
23038
|
+
if (!Number.isInteger(cols) || cols < 1 || cols > 8) {
|
|
23039
|
+
throw new Error(`\uB2E4\uB2E8 \uAC1C\uC218\uB294 1~8 \uC815\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${columns}`);
|
|
23040
|
+
}
|
|
23041
|
+
const paperHU = (mm) => Math.floor(mm * 7200 / 25.4);
|
|
23042
|
+
return {
|
|
23043
|
+
widthHU: size === void 0 ? A4_W_HU : paperHU(wMm),
|
|
23044
|
+
heightHU: size === void 0 ? A4_H_HU : paperHU(hMm),
|
|
23045
|
+
// 실측: 용지 치수는 방향과 무관하게 유지, 방향은 landscape 속성만 바뀐다
|
|
23046
|
+
landscape: orientation === "landscape" ? "NARROWLY" : "WIDELY",
|
|
23047
|
+
columns: cols,
|
|
23048
|
+
header: _optionalChain([header, 'optionalAccess', _289 => _289.trim, 'call', _290 => _290()]) ? header.trim() : null,
|
|
23049
|
+
footer: _optionalChain([footer, 'optionalAccess', _291 => _291.trim, 'call', _292 => _292()]) ? footer.trim() : null
|
|
23050
|
+
};
|
|
23051
|
+
}
|
|
23052
|
+
function columnColPrXml(columns) {
|
|
23053
|
+
const gap = columns > 1 ? 2268 : 0;
|
|
23054
|
+
return `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="${columns}" sameSz="1" sameGap="${gap}"/></hp:ctrl>`;
|
|
23055
|
+
}
|
|
23056
|
+
function headerFooterCtrl(tag, text, id, mapCharId) {
|
|
23057
|
+
const runs = generateRuns(text, void 0, mapCharId);
|
|
23058
|
+
return `<hp:ctrl><hp:${tag} id="${id}" applyPageType="BOTH"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0"><hp:p paraPrIDRef="0" styleIDRef="0">${runs}</hp:p></hp:subList></hp:${tag}></hp:ctrl>`;
|
|
23059
|
+
}
|
|
23060
|
+
|
|
22923
23061
|
// src/hwpx/gen-header.ts
|
|
22924
23062
|
function generateContainerXml() {
|
|
22925
23063
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22955,7 +23093,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22955
23093
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22956
23094
|
const got = m ? Number(m[1]) : NaN;
|
|
22957
23095
|
if (got !== startId + i) {
|
|
22958
|
-
throw new (0,
|
|
23096
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
22959
23097
|
`\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)`
|
|
22960
23098
|
);
|
|
22961
23099
|
}
|
|
@@ -23039,7 +23177,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
23039
23177
|
}
|
|
23040
23178
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
23041
23179
|
if (rows.length !== expectedBase) {
|
|
23042
|
-
throw new (0,
|
|
23180
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
23043
23181
|
`\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`
|
|
23044
23182
|
);
|
|
23045
23183
|
}
|
|
@@ -23267,7 +23405,7 @@ function buildStyles(gongmun) {
|
|
|
23267
23405
|
</hh:styles>`;
|
|
23268
23406
|
}
|
|
23269
23407
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
23270
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
23408
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _293 => _293.fonts, 'access', _294 => _294.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _295 => _295.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
23271
23409
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
23272
23410
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
23273
23411
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -23396,8 +23534,8 @@ function parseChartFence(text) {
|
|
|
23396
23534
|
const spec = chartSpec(type);
|
|
23397
23535
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
23398
23536
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
23399
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
23400
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
23537
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _296 => _296.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
23538
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _297 => _297[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
23401
23539
|
if (!spec.scatter) {
|
|
23402
23540
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
23403
23541
|
}
|
|
@@ -23439,7 +23577,7 @@ function serSpPr(color, stroke) {
|
|
|
23439
23577
|
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>`;
|
|
23440
23578
|
}
|
|
23441
23579
|
function dPtXml(pointColors, pie) {
|
|
23442
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
23580
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _298 => _298.length])) return "";
|
|
23443
23581
|
return pointColors.map((col, i) => {
|
|
23444
23582
|
const f = chartColorFill(col);
|
|
23445
23583
|
if (!f) return "";
|
|
@@ -23678,8 +23816,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
23678
23816
|
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 });
|
|
23679
23817
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
23680
23818
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
23681
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23682
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
23819
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _299 => _299.cover, 'optionalAccess', _300 => _300.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
23820
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _301 => _301.cover, 'optionalAccess', _302 => _302.org]), () => ( ""));
|
|
23683
23821
|
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>`;
|
|
23684
23822
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
23685
23823
|
return [
|
|
@@ -23935,7 +24073,7 @@ function escapeGfm(text) {
|
|
|
23935
24073
|
}
|
|
23936
24074
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23937
24075
|
function sanitizeText(text) {
|
|
23938
|
-
let result =
|
|
24076
|
+
let result = _chunkGLPLLT4Qcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23939
24077
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23940
24078
|
const tokens = result.split(" ");
|
|
23941
24079
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23965,7 +24103,7 @@ function replicateGfmTable(table2) {
|
|
|
23965
24103
|
for (let r = 0; r < numRows; r++) {
|
|
23966
24104
|
for (let c = 0; c < numCols; c++) {
|
|
23967
24105
|
if (skip.has(`${r},${c}`)) continue;
|
|
23968
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
24106
|
+
const cell2 = _optionalChain([cells, 'access', _303 => _303[r], 'optionalAccess', _304 => _304[c]]);
|
|
23969
24107
|
if (!cell2) continue;
|
|
23970
24108
|
display[r][c] = {
|
|
23971
24109
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -24019,7 +24157,7 @@ function unescapeGfmCell(text) {
|
|
|
24019
24157
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*_`])/g, "$1");
|
|
24020
24158
|
}
|
|
24021
24159
|
function replicateCellInnerHtml(cell2) {
|
|
24022
|
-
if (_optionalChain([cell2, 'access',
|
|
24160
|
+
if (_optionalChain([cell2, 'access', _305 => _305.blocks, 'optionalAccess', _306 => _306.length])) {
|
|
24023
24161
|
return cell2.blocks.map((b) => {
|
|
24024
24162
|
if (b.type === "table" && b.table) {
|
|
24025
24163
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -24058,7 +24196,7 @@ function replicateHtmlTable(table2) {
|
|
|
24058
24196
|
const rowCells = [];
|
|
24059
24197
|
for (let c = 0; c < numCols; c++) {
|
|
24060
24198
|
if (skip.has(`${r},${c}`)) continue;
|
|
24061
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
24199
|
+
const cell2 = _optionalChain([cells, 'access', _307 => _307[r], 'optionalAccess', _308 => _308[c]]);
|
|
24062
24200
|
if (!cell2) continue;
|
|
24063
24201
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
24064
24202
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -24104,10 +24242,10 @@ function parseHtmlTable(raw) {
|
|
|
24104
24242
|
}
|
|
24105
24243
|
} else {
|
|
24106
24244
|
if (!isClose) {
|
|
24107
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
24108
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
24245
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _309 => _309.match, 'call', _310 => _310(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _311 => _311[1]]) || "1", 10);
|
|
24246
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _312 => _312.match, 'call', _313 => _313(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _314 => _314[1]]) || "1", 10);
|
|
24109
24247
|
cellStart = m.index + m[0].length;
|
|
24110
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
24248
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkGLPLLT4Qcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkGLPLLT4Qcjs.MAX_ROWS) };
|
|
24111
24249
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
24112
24250
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
24113
24251
|
cellStart = -1;
|
|
@@ -24131,7 +24269,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
24131
24269
|
hadNonText = true;
|
|
24132
24270
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
24133
24271
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
24134
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
24272
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _315 => _315[1]]), () => ( _optionalChain([m, 'optionalAccess', _316 => _316[2]])));
|
|
24135
24273
|
if (src) imgSrcs.push(src);
|
|
24136
24274
|
return "";
|
|
24137
24275
|
});
|
|
@@ -24274,7 +24412,7 @@ function edgeXml(tag, d) {
|
|
|
24274
24412
|
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"/>`;
|
|
24275
24413
|
}
|
|
24276
24414
|
function borderFillDefToXml(id, def) {
|
|
24277
|
-
const fill = _optionalChain([def, 'access',
|
|
24415
|
+
const fill = _optionalChain([def, 'access', _317 => _317.fill, 'optionalAccess', _318 => _318.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
24278
24416
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
24279
24417
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
24280
24418
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -24510,15 +24648,65 @@ var IMAGE_EXT_MIME = {
|
|
|
24510
24648
|
tif: "image/tiff",
|
|
24511
24649
|
tiff: "image/tiff"
|
|
24512
24650
|
};
|
|
24513
|
-
|
|
24651
|
+
function sniffImage(b) {
|
|
24652
|
+
if (b.length >= 8 && b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) return { mime: "image/png", ext: "png" };
|
|
24653
|
+
if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255) return { mime: "image/jpeg", ext: "jpg" };
|
|
24654
|
+
if (b.length >= 6 && b[0] === 71 && b[1] === 73 && b[2] === 70) return { mime: "image/gif", ext: "gif" };
|
|
24655
|
+
if (b.length >= 2 && b[0] === 66 && b[1] === 77) return { mime: "image/bmp", ext: "bmp" };
|
|
24656
|
+
return null;
|
|
24657
|
+
}
|
|
24658
|
+
function probeImageSize(b) {
|
|
24659
|
+
const dv = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
24660
|
+
try {
|
|
24661
|
+
if (b[0] === 137 && b[1] === 80) {
|
|
24662
|
+
return { w: dv.getUint32(16), h: dv.getUint32(20) };
|
|
24663
|
+
}
|
|
24664
|
+
if (b[0] === 255 && b[1] === 216) {
|
|
24665
|
+
let i = 2;
|
|
24666
|
+
while (i + 9 < b.length) {
|
|
24667
|
+
if (b[i] !== 255) {
|
|
24668
|
+
i++;
|
|
24669
|
+
continue;
|
|
24670
|
+
}
|
|
24671
|
+
const marker = b[i + 1];
|
|
24672
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
24673
|
+
return { w: dv.getUint16(i + 7), h: dv.getUint16(i + 5) };
|
|
24674
|
+
}
|
|
24675
|
+
i += 2 + dv.getUint16(i + 2);
|
|
24676
|
+
}
|
|
24677
|
+
return null;
|
|
24678
|
+
}
|
|
24679
|
+
if (b[0] === 71 && b[1] === 73) {
|
|
24680
|
+
return { w: dv.getUint16(6, true), h: dv.getUint16(8, true) };
|
|
24681
|
+
}
|
|
24682
|
+
if (b[0] === 66 && b[1] === 77) {
|
|
24683
|
+
return { w: dv.getUint32(18, true), h: Math.abs(dv.getInt32(22, true)) };
|
|
24684
|
+
}
|
|
24685
|
+
} catch (e34) {
|
|
24686
|
+
}
|
|
24687
|
+
return null;
|
|
24688
|
+
}
|
|
24689
|
+
var PX_TO_HU = 75;
|
|
24690
|
+
var MAX_IMG_W_HU = 48189;
|
|
24691
|
+
var ImageRegistry = (_class5 = class {
|
|
24692
|
+
/** @param supplied url → 실데이터 바이트 (markdownToHwpx images 옵션) */
|
|
24693
|
+
constructor(supplied) {;_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);
|
|
24694
|
+
this.supplied = supplied;
|
|
24695
|
+
}
|
|
24514
24696
|
__init8() {this.byUrl = /* @__PURE__ */ new Map()}
|
|
24515
24697
|
__init9() {this.ids = /* @__PURE__ */ new Set()}
|
|
24516
24698
|
__init10() {this.parts = []}
|
|
24517
24699
|
__init11() {this.picSeq = 0}
|
|
24700
|
+
__init12() {this.binSeq = 0}
|
|
24518
24701
|
/** url 등록(중복 시 기존 파트) — 수용 불가면 null */
|
|
24519
24702
|
take(url) {
|
|
24520
24703
|
const cached = this.byUrl.get(url);
|
|
24521
24704
|
if (cached !== void 0) return cached;
|
|
24705
|
+
const real = this.takeReal(url);
|
|
24706
|
+
if (real) {
|
|
24707
|
+
this.byUrl.set(url, real);
|
|
24708
|
+
return real;
|
|
24709
|
+
}
|
|
24522
24710
|
let part = null;
|
|
24523
24711
|
const m = /^([A-Za-z0-9._-]+)\.([A-Za-z0-9]+)$/.exec(url);
|
|
24524
24712
|
const mime = m ? IMAGE_EXT_MIME[m[2].toLowerCase()] : void 0;
|
|
@@ -24538,6 +24726,41 @@ var ImageRegistry = (_class5 = class {constructor() { _class5.prototype.__init8.
|
|
|
24538
24726
|
this.byUrl.set(url, part);
|
|
24539
24727
|
return part;
|
|
24540
24728
|
}
|
|
24729
|
+
/** 실데이터 등록 — images 맵 바이트·data: URI. 포맷 미상(webp 등)은 null → placeholder 폴백 */
|
|
24730
|
+
takeReal(url) {
|
|
24731
|
+
let bytes = _optionalChain([this, 'access', _319 => _319.supplied, 'optionalAccess', _320 => _320.get, 'call', _321 => _321(url)]);
|
|
24732
|
+
if (!bytes && url.startsWith("data:")) {
|
|
24733
|
+
const m = /^data:image\/[a-z+]+;base64,([A-Za-z0-9+/=\s]+)$/i.exec(url);
|
|
24734
|
+
if (m) {
|
|
24735
|
+
try {
|
|
24736
|
+
bytes = new Uint8Array(Buffer.from(m[1].replace(/\s+/g, ""), "base64"));
|
|
24737
|
+
} catch (e35) {
|
|
24738
|
+
}
|
|
24739
|
+
}
|
|
24740
|
+
}
|
|
24741
|
+
if (!bytes || bytes.length === 0) return null;
|
|
24742
|
+
const sniffed = sniffImage(bytes);
|
|
24743
|
+
if (!sniffed) return null;
|
|
24744
|
+
const safe = /^([A-Za-z0-9._-]+)\.([A-Za-z0-9]+)$/.exec(url);
|
|
24745
|
+
const base = safe && !url.includes("..") ? safe[1] : `image${++this.binSeq}`;
|
|
24746
|
+
let itemId = base.replace(/[^A-Za-z0-9_]/g, "_");
|
|
24747
|
+
let n = 1;
|
|
24748
|
+
while (this.ids.has(itemId)) itemId = `${base.replace(/[^A-Za-z0-9_]/g, "_")}_${n++}`;
|
|
24749
|
+
this.ids.add(itemId);
|
|
24750
|
+
const dim = probeImageSize(bytes);
|
|
24751
|
+
let wHU, hHU;
|
|
24752
|
+
if (dim && dim.w > 0 && dim.h > 0) {
|
|
24753
|
+
wHU = dim.w * PX_TO_HU;
|
|
24754
|
+
hHU = dim.h * PX_TO_HU;
|
|
24755
|
+
if (wHU > MAX_IMG_W_HU) {
|
|
24756
|
+
hHU = Math.round(hHU * (MAX_IMG_W_HU / wHU));
|
|
24757
|
+
wHU = MAX_IMG_W_HU;
|
|
24758
|
+
}
|
|
24759
|
+
}
|
|
24760
|
+
const part = { name: `BinData/${itemId}.${sniffed.ext}`, itemId, mime: sniffed.mime, data: bytes, wHU, hHU };
|
|
24761
|
+
this.parts.push(part);
|
|
24762
|
+
return part;
|
|
24763
|
+
}
|
|
24541
24764
|
/** manifest <opf:item> 조각들 (실측: isEmbeded="1") */
|
|
24542
24765
|
manifestItems() {
|
|
24543
24766
|
return this.parts.map((p) => `<opf:item id="${p.itemId}" href="${p.name}" media-type="${p.mime}" isEmbeded="1"/>`);
|
|
@@ -24545,8 +24768,9 @@ var ImageRegistry = (_class5 = class {constructor() { _class5.prototype.__init8.
|
|
|
24545
24768
|
/** 인라인 <hp:pic> XML — 실측 저장본 미러, treatAsChar=1 (셀·문단 안 배치) */
|
|
24546
24769
|
inlinePicXml(part) {
|
|
24547
24770
|
const id = PIC_ID_BASE + ++this.picSeq;
|
|
24548
|
-
const
|
|
24549
|
-
|
|
24771
|
+
const w = _nullishCoalesce(part.wHU, () => ( 1130));
|
|
24772
|
+
const h = _nullishCoalesce(part.hHU, () => ( 1130));
|
|
24773
|
+
return `<hp:pic id="${id}" zOrder="0" numberingType="PICTURE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${id}" reverse="0" xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core"><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.floor(w / 2)}" centerY="${Math.floor(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="${part.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="1" affectLSpacing="0" flowWithText="1" 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:pic>`;
|
|
24550
24774
|
}
|
|
24551
24775
|
}, _class5);
|
|
24552
24776
|
var MD_IMAGE_RE = /!\[[^\]]*\]\(([^)\s]+)\)/g;
|
|
@@ -24679,11 +24903,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
24679
24903
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
24680
24904
|
const rowCnt = rows.length;
|
|
24681
24905
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
24682
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24906
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _322 => _322.bfRegistry]), () => ( null));
|
|
24683
24907
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
24684
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
24908
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _323 => _323.charHeight]), () => ( 1e3));
|
|
24685
24909
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
24686
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
24910
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _324 => _324[0], 'optionalAccess', _325 => _325[0]]), () => ( ""))), seq, rowAnchor);
|
|
24687
24911
|
const colMax = Array(colCnt).fill(0);
|
|
24688
24912
|
const colMaxBody = Array(colCnt).fill(0);
|
|
24689
24913
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -24711,7 +24935,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24711
24935
|
const k = `${rowIdx},${colIdx}`;
|
|
24712
24936
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
24713
24937
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
24714
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24938
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _326 => _326.cellChar, 'access', _327 => _327.get, 'call', _328 => _328(k)]), () => ( defaultCharPr));
|
|
24715
24939
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
24716
24940
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24717
24941
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -24729,11 +24953,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24729
24953
|
}
|
|
24730
24954
|
}
|
|
24731
24955
|
}
|
|
24732
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
24956
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _329 => _329.cellChar, 'access', _330 => _330.has, 'call', _331 => _331(k)]) ? void 0 : mapId);
|
|
24733
24957
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
24734
24958
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
24735
24959
|
}).join("");
|
|
24736
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24960
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _332 => _332.cellBf, 'access', _333 => _333.get, 'call', _334 => _334(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24737
24961
|
row: rowIdx,
|
|
24738
24962
|
rowEnd: rowIdx,
|
|
24739
24963
|
col: colIdx,
|
|
@@ -24743,7 +24967,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24743
24967
|
headerRows: 1,
|
|
24744
24968
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
24745
24969
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
24746
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
24970
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _335 => _335.cellH, 'access', _336 => _336.get, 'call', _337 => _337(k)]), () => ( cellH));
|
|
24747
24971
|
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>`;
|
|
24748
24972
|
}).join("");
|
|
24749
24973
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -24752,7 +24976,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
24752
24976
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
24753
24977
|
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;
|
|
24754
24978
|
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>`;
|
|
24755
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
24979
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _338 => _338.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
24756
24980
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
24757
24981
|
}
|
|
24758
24982
|
function layoutHtmlRows(rows) {
|
|
@@ -24763,8 +24987,8 @@ function layoutHtmlRows(rows) {
|
|
|
24763
24987
|
let c = 0;
|
|
24764
24988
|
for (const cell2 of rows[r].cells) {
|
|
24765
24989
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24766
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24767
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24990
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkGLPLLT4Qcjs.MAX_COLS);
|
|
24991
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkGLPLLT4Qcjs.MAX_ROWS);
|
|
24768
24992
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24769
24993
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24770
24994
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -24792,7 +25016,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24792
25016
|
if (!rows || rows.length === 0) return null;
|
|
24793
25017
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
24794
25018
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
24795
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
25019
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _339 => _339.charHeight]), () => ( 1e3));
|
|
24796
25020
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
24797
25021
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
24798
25022
|
for (const cell2 of placed) {
|
|
@@ -24821,7 +25045,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24821
25045
|
const tblId = nextTableId();
|
|
24822
25046
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
24823
25047
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
24824
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
25048
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _340 => _340.bfRegistry]), () => ( null));
|
|
24825
25049
|
let htmlHeaderRows = 0;
|
|
24826
25050
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
24827
25051
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -24835,7 +25059,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24835
25059
|
const nestedW = Math.max(Math.min(Math.max(sw - 1020, 4e3), sw - 282), 500);
|
|
24836
25060
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
24837
25061
|
if (nestedXml) {
|
|
24838
|
-
const szH = _optionalChain([nestedXml, 'access',
|
|
25062
|
+
const szH = _optionalChain([nestedXml, 'access', _341 => _341.match, 'call', _342 => _342(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _343 => _343[1]]);
|
|
24839
25063
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
24840
25064
|
}
|
|
24841
25065
|
return nestedXml;
|
|
@@ -24846,7 +25070,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24846
25070
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
24847
25071
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
24848
25072
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
24849
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
25073
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _344 => _344.cellH, 'access', _345 => _345.get, 'call', _346 => _346(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
|
|
24850
25074
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
24851
25075
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
24852
25076
|
return { cell: cell2, rowSpan, lines, nestedXmls, segLines, imgSrcs: cellParsed[i].imgSrcs };
|
|
@@ -24857,7 +25081,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24857
25081
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
24858
25082
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
24859
25083
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
24860
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
25084
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _347 => _347.cellChar, 'access', _348 => _348.get, 'call', _349 => _349(k)]), () => ( defaultCharPr));
|
|
24861
25085
|
const centered = isHeader || colCentered[cell2.c];
|
|
24862
25086
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
24863
25087
|
const picUrls = images ? [...imgSrcs] : [];
|
|
@@ -24897,7 +25121,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24897
25121
|
let cellHeight = 0;
|
|
24898
25122
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
24899
25123
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
24900
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
25124
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _350 => _350.cellBf, 'access', _351 => _351.get, 'call', _352 => _352(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24901
25125
|
row: cell2.r,
|
|
24902
25126
|
rowEnd,
|
|
24903
25127
|
col: cell2.c,
|
|
@@ -25067,7 +25291,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
25067
25291
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
25068
25292
|
}
|
|
25069
25293
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
25070
|
-
const c = _optionalChain([g, 'access',
|
|
25294
|
+
const c = _optionalChain([g, 'access', _353 => _353.press, 'optionalAccess', _354 => _354.contact]);
|
|
25071
25295
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
25072
25296
|
const w = bodyWidth - 280;
|
|
25073
25297
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -25433,7 +25657,7 @@ function generateEquationParagraph(input, zOrder = 0) {
|
|
|
25433
25657
|
}
|
|
25434
25658
|
|
|
25435
25659
|
// src/hwpx/gen-section.ts
|
|
25436
|
-
function generateSecPr(gongmun) {
|
|
25660
|
+
function generateSecPr(gongmun, page = null) {
|
|
25437
25661
|
const m = gongmun ? {
|
|
25438
25662
|
top: mmToHwpunit(gongmun.margins.top),
|
|
25439
25663
|
bottom: mmToHwpunit(gongmun.margins.bottom),
|
|
@@ -25446,15 +25670,17 @@ function generateSecPr(gongmun) {
|
|
|
25446
25670
|
m.header = gongmun.headerFooter;
|
|
25447
25671
|
m.footer = gongmun.headerFooter;
|
|
25448
25672
|
}
|
|
25449
|
-
const secPr = `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="${A4_W_HU}" height="${A4_H_HU}" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
|
|
25450
|
-
const colPr =
|
|
25451
|
-
|
|
25673
|
+
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', _355 => _355.landscape]), () => ( "WIDELY"))}" width="${_nullishCoalesce(_optionalChain([page, 'optionalAccess', _356 => _356.widthHU]), () => ( A4_W_HU))}" height="${_nullishCoalesce(_optionalChain([page, 'optionalAccess', _357 => _357.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>`;
|
|
25674
|
+
const colPr = columnColPrXml(_nullishCoalesce(_optionalChain([page, 'optionalAccess', _358 => _358.columns]), () => ( 1)));
|
|
25675
|
+
const hf = (_optionalChain([page, 'optionalAccess', _359 => _359.header]) ? headerFooterCtrl("header", page.header, 1) : "") + (_optionalChain([page, 'optionalAccess', _360 => _360.footer]) ? headerFooterCtrl("footer", page.footer, 2) : "");
|
|
25676
|
+
return secPr + colPr + hf + (_optionalChain([gongmun, 'optionalAccess', _361 => _361.pageNumbers]) ? pageNumCtrl() : "");
|
|
25452
25677
|
}
|
|
25453
25678
|
var SectionOpener = (_class6 = class {
|
|
25454
|
-
constructor(gongmun) {;_class6.prototype.
|
|
25679
|
+
constructor(gongmun, page = null) {;_class6.prototype.__init13.call(this);
|
|
25455
25680
|
this.gongmun = gongmun;
|
|
25681
|
+
this.page = page;
|
|
25456
25682
|
}
|
|
25457
|
-
|
|
25683
|
+
__init13() {this.pending = true}
|
|
25458
25684
|
/** 아직 secPr를 나를 첫 문단이 안 나왔는가 */
|
|
25459
25685
|
get isFirst() {
|
|
25460
25686
|
return this.pending;
|
|
@@ -25464,7 +25690,7 @@ var SectionOpener = (_class6 = class {
|
|
|
25464
25690
|
this.pending = false;
|
|
25465
25691
|
return xml.replace(
|
|
25466
25692
|
/<hp:run charPrIDRef="(\d+)">/,
|
|
25467
|
-
`<hp:run charPrIDRef="$1">${generateSecPr(this.gongmun)}`
|
|
25693
|
+
`<hp:run charPrIDRef="$1">${generateSecPr(this.gongmun, this.page)}`
|
|
25468
25694
|
);
|
|
25469
25695
|
}
|
|
25470
25696
|
/**
|
|
@@ -25474,32 +25700,32 @@ var SectionOpener = (_class6 = class {
|
|
|
25474
25700
|
emitCarrier(paraXmls) {
|
|
25475
25701
|
if (!this.pending) return;
|
|
25476
25702
|
this.pending = false;
|
|
25477
|
-
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(this.gongmun)}<hp:t></hp:t></hp:run>`;
|
|
25703
|
+
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(this.gongmun, this.page)}<hp:t></hp:t></hp:run>`;
|
|
25478
25704
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
25479
25705
|
}
|
|
25480
25706
|
/** 빈 문서 폴백 — secPr를 실은 빈 단락 XML */
|
|
25481
25707
|
emptyDoc() {
|
|
25482
25708
|
this.pending = false;
|
|
25483
|
-
return `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(this.gongmun)}<hp:t></hp:t></hp:run></hp:p>`;
|
|
25709
|
+
return `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(this.gongmun, this.page)}<hp:t></hp:t></hp:run></hp:p>`;
|
|
25484
25710
|
}
|
|
25485
25711
|
}, _class6);
|
|
25486
25712
|
function buildPreamble(blocks, ctx) {
|
|
25487
25713
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
25488
25714
|
const preamble = [];
|
|
25489
25715
|
let hasFrontPages = false;
|
|
25490
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25716
|
+
if (_optionalChain([gongmun, 'optionalAccess', _362 => _362.reportInfo]) && dfIds) {
|
|
25491
25717
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
25492
25718
|
}
|
|
25493
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25719
|
+
if (_optionalChain([gongmun, 'optionalAccess', _363 => _363.approval]) && bfReg) {
|
|
25494
25720
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
25495
25721
|
}
|
|
25496
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25722
|
+
if (_optionalChain([gongmun, 'optionalAccess', _364 => _364.docHead]) && dfIds) {
|
|
25497
25723
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
25498
25724
|
}
|
|
25499
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25725
|
+
if (_optionalChain([gongmun, 'optionalAccess', _365 => _365.noticeHead]) && dfIds) {
|
|
25500
25726
|
preamble.push(...buildNoticeHead(gongmun));
|
|
25501
25727
|
}
|
|
25502
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25728
|
+
if (_optionalChain([gongmun, 'optionalAccess', _366 => _366.press]) && dfIds && bfReg && tableStyle) {
|
|
25503
25729
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25504
25730
|
}
|
|
25505
25731
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -25528,7 +25754,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
25528
25754
|
}
|
|
25529
25755
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
25530
25756
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25531
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
25757
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _367 => _367.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
25532
25758
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
25533
25759
|
}
|
|
25534
25760
|
if (preamble.length > 0) {
|
|
@@ -25543,7 +25769,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
25543
25769
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
25544
25770
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
25545
25771
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
25546
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
25772
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _368 => _368.press, 'optionalAccess', _369 => _369.sub]), () => ( []))) {
|
|
25547
25773
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
25548
25774
|
}
|
|
25549
25775
|
return parts.join("\n ");
|
|
@@ -25637,8 +25863,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25637
25863
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
25638
25864
|
if (gongmun && gongmunList) {
|
|
25639
25865
|
const info = gongmunList.items.get(blockIdx);
|
|
25640
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25641
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
25866
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _370 => _370.depth]), () => ( 0));
|
|
25867
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _371 => _371.marker]), () => ( ""));
|
|
25642
25868
|
const content = block.text || "";
|
|
25643
25869
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
25644
25870
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -25647,7 +25873,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
25647
25873
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
25648
25874
|
}
|
|
25649
25875
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
25650
|
-
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess',
|
|
25876
|
+
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _372 => _372.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
25651
25877
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
25652
25878
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
25653
25879
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -25706,22 +25932,22 @@ function renderHtmlTable(block, ctx) {
|
|
|
25706
25932
|
}
|
|
25707
25933
|
function appendPostamble(blocks, ctx) {
|
|
25708
25934
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
25709
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25935
|
+
if (_optionalChain([gongmun, 'optionalAccess', _373 => _373.noticeHead]) && dfIds) {
|
|
25710
25936
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
25711
25937
|
}
|
|
25712
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25713
|
-
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access',
|
|
25938
|
+
if (_optionalChain([gongmun, 'optionalAccess', _374 => _374.endMark]) && paraXmls.length > 0) {
|
|
25939
|
+
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _375 => _375.rows, 'optionalAccess', _376 => _376.length]));
|
|
25714
25940
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
25715
25941
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
25716
25942
|
}
|
|
25717
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25943
|
+
if (_optionalChain([gongmun, 'optionalAccess', _377 => _377.docFoot]) && dfIds) {
|
|
25718
25944
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
25719
25945
|
}
|
|
25720
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
25946
|
+
if (_optionalChain([gongmun, 'optionalAccess', _378 => _378.press]) && dfIds && bfReg && tableStyle) {
|
|
25721
25947
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
25722
25948
|
}
|
|
25723
25949
|
}
|
|
25724
|
-
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null, dfIds = null, images = null) {
|
|
25950
|
+
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null, dfIds = null, images = null, page = null) {
|
|
25725
25951
|
resetTableIds();
|
|
25726
25952
|
resetGjTableIds();
|
|
25727
25953
|
resetExtraTableIds();
|
|
@@ -25737,7 +25963,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25737
25963
|
remap,
|
|
25738
25964
|
dfIds,
|
|
25739
25965
|
images,
|
|
25740
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
25966
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _379 => _379.preset]) === "gaejosik",
|
|
25741
25967
|
measured,
|
|
25742
25968
|
richAssets,
|
|
25743
25969
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -25760,7 +25986,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25760
25986
|
// 개조식 장식표(표지·목차·장헤더·제목박스) 폭 스케일용 본문폭 — margins 오버라이드 대응
|
|
25761
25987
|
gjBodyW: gongmun ? mmToHwpunit(210 - gongmun.margins.left - gongmun.margins.right) : GAEJOSIK_BASE_WIDTH,
|
|
25762
25988
|
chamMap: (id) => id === CHAR_BOLD ? GJ_CHAR_CHAM_BOLD : id,
|
|
25763
|
-
opener: new SectionOpener(gongmun),
|
|
25989
|
+
opener: new SectionOpener(gongmun, page),
|
|
25764
25990
|
paraXmls: [],
|
|
25765
25991
|
// 표 방출 순번 — 생성 성공 여부와 무관하게 '시도' 기준으로 센다. 실패한 표가 이후
|
|
25766
25992
|
// 표들의 순번을 밀면 앵커 없는 프로필(손편집·구버전)의 table_index 매칭이 어긋난다.
|
|
@@ -25843,47 +26069,55 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
25843
26069
|
|
|
25844
26070
|
// src/hwpx/generator.ts
|
|
25845
26071
|
async function markdownToHwpx(markdown, options) {
|
|
25846
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
25847
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
25848
|
-
const
|
|
25849
|
-
const
|
|
25850
|
-
|
|
25851
|
-
|
|
25852
|
-
|
|
25853
|
-
|
|
25854
|
-
|
|
25855
|
-
|
|
25856
|
-
|
|
25857
|
-
|
|
25858
|
-
|
|
25859
|
-
|
|
25860
|
-
|
|
25861
|
-
|
|
25862
|
-
|
|
25863
|
-
const
|
|
25864
|
-
|
|
25865
|
-
|
|
25866
|
-
|
|
25867
|
-
|
|
25868
|
-
|
|
25869
|
-
|
|
25870
|
-
|
|
25871
|
-
|
|
25872
|
-
|
|
25873
|
-
|
|
25874
|
-
|
|
25875
|
-
|
|
25876
|
-
|
|
25877
|
-
|
|
25878
|
-
|
|
25879
|
-
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
|
|
25886
|
-
|
|
26072
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _380 => _380.theme]));
|
|
26073
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _381 => _381.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
26074
|
+
const page = resolvePage(_optionalChain([options, 'optionalAccess', _382 => _382.page]));
|
|
26075
|
+
const { md: md2, defs } = extractFootnoteDefs(markdown);
|
|
26076
|
+
beginInlineDoc(defs);
|
|
26077
|
+
try {
|
|
26078
|
+
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
26079
|
+
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
26080
|
+
const blocks = parseMarkdownToBlocks(md2);
|
|
26081
|
+
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
26082
|
+
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
26083
|
+
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
26084
|
+
const remap = _optionalChain([options, 'optionalAccess', _383 => _383.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _384 => _384.variants, 'optionalAccess', _385 => _385.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
|
|
26085
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _386 => _386.borderFillXmls, 'access', _387 => _387.length]), () => ( 0)))) : null;
|
|
26086
|
+
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
26087
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _388 => _388.variants, 'optionalAccess', _389 => _389.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _390 => _390.charPrXmls, 'access', _391 => _391.length]), () => ( 0)));
|
|
26088
|
+
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
26089
|
+
const chartParts = [];
|
|
26090
|
+
const supplied = _optionalChain([options, 'optionalAccess', _392 => _392.images]) ? new Map(Object.entries(options.images).map(([k, v]) => [k, v instanceof Uint8Array ? v : new Uint8Array(v)])) : void 0;
|
|
26091
|
+
const images = new ImageRegistry(supplied);
|
|
26092
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap, dfIds, images, page);
|
|
26093
|
+
if (remap && remap.tables.length > 0) {
|
|
26094
|
+
const unused = remap.tables.filter((t) => !t.used).length;
|
|
26095
|
+
if (unused === remap.tables.length) {
|
|
26096
|
+
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)`);
|
|
26097
|
+
}
|
|
26098
|
+
}
|
|
26099
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _393 => _393.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _394 => _394.emit, 'call', _395 => _395()]), () => ( []))];
|
|
26100
|
+
const zip = new (0, _jszip2.default)();
|
|
26101
|
+
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
26102
|
+
zip.file("META-INF/container.xml", generateContainerXml());
|
|
26103
|
+
zip.file("Contents/content.hpf", generateManifest(chartParts, images.manifestItems(), gongmun ? "gongmun" : "default"));
|
|
26104
|
+
for (const part of images.parts) zip.file(part.name, part.data);
|
|
26105
|
+
zip.file("Contents/header.xml", generateHeaderXml(
|
|
26106
|
+
theme,
|
|
26107
|
+
gongmun,
|
|
26108
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _396 => _396.variants]), () => ( [])),
|
|
26109
|
+
extraBorderFills,
|
|
26110
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _397 => _397.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
|
|
26111
|
+
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _398 => _398.indentVariants]), () => ( [])),
|
|
26112
|
+
_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _399 => _399.fontFaces]), () => ( []))
|
|
26113
|
+
));
|
|
26114
|
+
zip.file("Contents/section0.xml", sectionXml);
|
|
26115
|
+
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
26116
|
+
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
26117
|
+
return await zip.generateAsync({ type: "arraybuffer" });
|
|
26118
|
+
} finally {
|
|
26119
|
+
endInlineDoc();
|
|
26120
|
+
}
|
|
25887
26121
|
}
|
|
25888
26122
|
|
|
25889
26123
|
// src/diff/compare.ts
|
|
@@ -25929,7 +26163,7 @@ function alignBlocks(a, b) {
|
|
|
25929
26163
|
const m = a.length, n = b.length;
|
|
25930
26164
|
if (m * n > 1e7) return fallbackAlign(a, b);
|
|
25931
26165
|
const lenOf = (blk) => {
|
|
25932
|
-
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
26166
|
+
const t = blk.text !== void 0 ? blk.text : blk.type === "table" && blk.table ? blk.table.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _400 => _400.text]), () => ( ""))).join(" ") : "";
|
|
25933
26167
|
return t.replace(/\s+/g, " ").trim().length;
|
|
25934
26168
|
};
|
|
25935
26169
|
const aLen = a.map(lenOf);
|
|
@@ -26002,8 +26236,8 @@ function blockSimilarity(a, b) {
|
|
|
26002
26236
|
}
|
|
26003
26237
|
function tableSimilarity(a, b) {
|
|
26004
26238
|
const dimSim = 1 - Math.abs(a.rows * a.cols - b.rows * b.cols) / Math.max(a.rows * a.cols, b.rows * b.cols, 1);
|
|
26005
|
-
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
26006
|
-
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
26239
|
+
const textsA = a.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _401 => _401.text]), () => ( ""))).join(" ");
|
|
26240
|
+
const textsB = b.cells.flat().map((c) => _nullishCoalesce(_optionalChain([c, 'optionalAccess', _402 => _402.text]), () => ( ""))).join(" ");
|
|
26007
26241
|
const contentSim = normalizedSimilarity(textsA, textsB);
|
|
26008
26242
|
return dimSim * 0.3 + contentSim * 0.7;
|
|
26009
26243
|
}
|
|
@@ -26014,8 +26248,8 @@ function diffTableCells(a, b) {
|
|
|
26014
26248
|
for (let r = 0; r < maxRows; r++) {
|
|
26015
26249
|
const row = [];
|
|
26016
26250
|
for (let c = 0; c < maxCols; c++) {
|
|
26017
|
-
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access',
|
|
26018
|
-
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access',
|
|
26251
|
+
const cellA = r < a.rows && c < a.cols ? _optionalChain([a, 'access', _403 => _403.cells, 'access', _404 => _404[r], 'optionalAccess', _405 => _405[c], 'optionalAccess', _406 => _406.text]) : void 0;
|
|
26252
|
+
const cellB = r < b.rows && c < b.cols ? _optionalChain([b, 'access', _407 => _407.cells, 'access', _408 => _408[r], 'optionalAccess', _409 => _409[c], 'optionalAccess', _410 => _410.text]) : void 0;
|
|
26019
26253
|
let type;
|
|
26020
26254
|
if (cellA === void 0) type = "added";
|
|
26021
26255
|
else if (cellB === void 0) type = "removed";
|
|
@@ -26065,7 +26299,7 @@ function builtinTemplateDir() {
|
|
|
26065
26299
|
for (const c of candidates) {
|
|
26066
26300
|
if (_fs.existsSync.call(void 0, _path.join.call(void 0, c, BUILTIN_TEMPLATES[0].file))) return c;
|
|
26067
26301
|
}
|
|
26068
|
-
throw new (0,
|
|
26302
|
+
throw new (0, _chunkUQ6KDJWEcjs.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)");
|
|
26069
26303
|
}
|
|
26070
26304
|
function readBuiltinTemplate(t) {
|
|
26071
26305
|
const buf = _fs.readFileSync.call(void 0, _path.join.call(void 0, builtinTemplateDir(), t.file));
|
|
@@ -26228,7 +26462,7 @@ function parseRenderStyles(headXml) {
|
|
|
26228
26462
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
26229
26463
|
const textColor = el.getAttribute("textColor");
|
|
26230
26464
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
26231
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
26465
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _411 => _411.getAttribute, 'call', _412 => _412("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _413 => _413.getAttribute, 'call', _414 => _414("latin")])));
|
|
26232
26466
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
26233
26467
|
styles.charPr.set(id, {
|
|
26234
26468
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -26236,8 +26470,8 @@ function parseRenderStyles(headXml) {
|
|
|
26236
26470
|
italic: findChildByLocalName(el, "italic") != null,
|
|
26237
26471
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
26238
26472
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
26239
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
26240
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
26473
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _415 => _415.getAttribute, 'call', _416 => _416("hangul")])) || 100,
|
|
26474
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _417 => _417.getAttribute, 'call', _418 => _418("hangul")])) || 0,
|
|
26241
26475
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
26242
26476
|
face
|
|
26243
26477
|
});
|
|
@@ -26246,7 +26480,7 @@ function parseRenderStyles(headXml) {
|
|
|
26246
26480
|
const id = el.getAttribute("id");
|
|
26247
26481
|
if (id != null) {
|
|
26248
26482
|
const align = findChildByLocalName(el, "align");
|
|
26249
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
26483
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _419 => _419.getAttribute, 'call', _420 => _420("horizontal")]) || "JUSTIFY");
|
|
26250
26484
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
26251
26485
|
}
|
|
26252
26486
|
} else if (tag === "borderFill") {
|
|
@@ -26260,7 +26494,7 @@ function parseRenderStyles(headXml) {
|
|
|
26260
26494
|
};
|
|
26261
26495
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26262
26496
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26263
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26497
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _421 => _421.getAttribute, 'call', _422 => _422("faceColor")]);
|
|
26264
26498
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
26265
26499
|
styles.borderFill.set(id, bf);
|
|
26266
26500
|
}
|
|
@@ -26332,7 +26566,7 @@ function collectSites(scan) {
|
|
|
26332
26566
|
}
|
|
26333
26567
|
function attrOf3(openTag, name) {
|
|
26334
26568
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
26335
|
-
return _optionalChain([m, 'optionalAccess',
|
|
26569
|
+
return _optionalChain([m, 'optionalAccess', _423 => _423[1]]);
|
|
26336
26570
|
}
|
|
26337
26571
|
function paraOpenTag(xml, para2) {
|
|
26338
26572
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -26347,7 +26581,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
26347
26581
|
if (!tr) return null;
|
|
26348
26582
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
26349
26583
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
26350
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
26584
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _424 => _424[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
26351
26585
|
const charPr2 = runOpen && attrOf3(runOpen[0], "charPrIDRef") || "0";
|
|
26352
26586
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
26353
26587
|
if (close === -1) return null;
|
|
@@ -26374,7 +26608,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
26374
26608
|
if (width === null) return null;
|
|
26375
26609
|
let content = width;
|
|
26376
26610
|
const win = cellAddrWindow(xml, cell2);
|
|
26377
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
26611
|
+
const mg = _optionalChain([win, 'optionalAccess', _425 => _425.match, 'call', _426 => _426(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
26378
26612
|
if (mg) {
|
|
26379
26613
|
content -= Number(_nullishCoalesce(attrOf3(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf3(mg[0], "right"), () => ( 0)));
|
|
26380
26614
|
}
|
|
@@ -26408,12 +26642,12 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
26408
26642
|
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>`;
|
|
26409
26643
|
}
|
|
26410
26644
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
26411
|
-
if (ops.length === 0) throw new (0,
|
|
26645
|
+
if (ops.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
26412
26646
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
26413
|
-
|
|
26647
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
26414
26648
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
26415
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
26416
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
26649
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _427 => _427.match, 'call', _428 => _428(/(\d+)\.xml$/i), 'optionalAccess', _429 => _429[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _430 => _430.match, 'call', _431 => _431(/(\d+)\.xml$/i), 'optionalAccess', _432 => _432[1]]), () => ( 0))));
|
|
26650
|
+
if (sectionPaths.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
26417
26651
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
26418
26652
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
26419
26653
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -26454,11 +26688,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26454
26688
|
const manifestItems = [];
|
|
26455
26689
|
const placed = [];
|
|
26456
26690
|
for (const op of ops) {
|
|
26457
|
-
if (!op.anchor) throw new (0,
|
|
26458
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
26691
|
+
if (!op.anchor) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26692
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26459
26693
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
26460
|
-
if (!MIME[ext]) throw new (0,
|
|
26461
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
26694
|
+
if (!MIME[ext]) throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
26695
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkUQ6KDJWEcjs.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)`);
|
|
26462
26696
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
26463
26697
|
let found = null;
|
|
26464
26698
|
let total = 0;
|
|
@@ -26491,7 +26725,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26491
26725
|
}
|
|
26492
26726
|
}
|
|
26493
26727
|
}
|
|
26494
|
-
throw new (0,
|
|
26728
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
26495
26729
|
`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)})`
|
|
26496
26730
|
);
|
|
26497
26731
|
}
|
|
@@ -26499,9 +26733,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26499
26733
|
const xml = sectionXmls[si];
|
|
26500
26734
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26501
26735
|
if (!run) {
|
|
26502
|
-
throw new (0,
|
|
26736
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26503
26737
|
}
|
|
26504
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
26738
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _433 => _433.charPr, 'access', _434 => _434.get, 'call', _435 => _435(run.charPr), 'optionalAccess', _436 => _436.height]), () => ( 1e3));
|
|
26505
26739
|
const fontPt = charPrHeight / 100;
|
|
26506
26740
|
const emMm = fontPt * 25.4 / 72;
|
|
26507
26741
|
const lineHMm = emMm;
|
|
@@ -26510,7 +26744,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26510
26744
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
26511
26745
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
26512
26746
|
const paraPrId = _nullishCoalesce(attrOf3(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
26513
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
26747
|
+
const align = _optionalChain([styles, 'optionalAccess', _437 => _437.paraAlign, 'access', _438 => _438.get, 'call', _439 => _439(paraPrId)]);
|
|
26514
26748
|
let alignShiftMm = 0;
|
|
26515
26749
|
if (align === "CENTER" || align === "RIGHT") {
|
|
26516
26750
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -26606,7 +26840,7 @@ function parseBorderFills(headerDoc) {
|
|
|
26606
26840
|
};
|
|
26607
26841
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
26608
26842
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26609
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26843
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _440 => _440.getAttribute, 'call', _441 => _441("faceColor")]);
|
|
26610
26844
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
26611
26845
|
map.set(id, def);
|
|
26612
26846
|
}
|
|
@@ -26638,7 +26872,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
26638
26872
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
26639
26873
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
26640
26874
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
26641
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
26875
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _442 => _442.getAttribute, 'call', _443 => _443("hangul")]);
|
|
26642
26876
|
if (hangul) {
|
|
26643
26877
|
def.fontRef_hangul = hangul;
|
|
26644
26878
|
const face = hangulFonts.get(hangul);
|
|
@@ -26666,7 +26900,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26666
26900
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
26667
26901
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
26668
26902
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
26669
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
26903
|
+
const width = _optionalChain([sz, 'optionalAccess', _444 => _444.getAttribute, 'call', _445 => _445("width")]) || void 0;
|
|
26670
26904
|
const cells = [];
|
|
26671
26905
|
const usedBf = /* @__PURE__ */ new Set();
|
|
26672
26906
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -26679,17 +26913,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
26679
26913
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
26680
26914
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
26681
26915
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
26682
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26683
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
26916
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _446 => _446.getAttribute, 'call', _447 => _447("rowAddr")])), () => ( 0));
|
|
26917
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _448 => _448.getAttribute, 'call', _449 => _449("colAddr")])), () => ( 0));
|
|
26684
26918
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
26685
26919
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
26686
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26687
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
26920
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _450 => _450.getAttribute, 'call', _451 => _451("colSpan")])), () => ( 1));
|
|
26921
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _452 => _452.getAttribute, 'call', _453 => _453("rowSpan")])), () => ( 1));
|
|
26688
26922
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
26689
26923
|
const cpId = firstRunCharPr(tc2);
|
|
26690
26924
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
26691
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
26692
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
26925
|
+
const w = _optionalChain([csz, 'optionalAccess', _454 => _454.getAttribute, 'call', _455 => _455("width")]);
|
|
26926
|
+
const hh = _optionalChain([csz, 'optionalAccess', _456 => _456.getAttribute, 'call', _457 => _457("height")]);
|
|
26693
26927
|
if (w) cell2.width_hwpunit = w;
|
|
26694
26928
|
if (hh) cell2.height_hwpunit = hh;
|
|
26695
26929
|
if (bfId) {
|
|
@@ -26777,16 +27011,16 @@ function pick(map, keys) {
|
|
|
26777
27011
|
return out;
|
|
26778
27012
|
}
|
|
26779
27013
|
async function hwpxToProfile(input) {
|
|
26780
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
27014
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkUQ6KDJWEcjs.toArrayBuffer.call(void 0, input);
|
|
26781
27015
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26782
27016
|
const parser = createXmlParser();
|
|
26783
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
27017
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _458 => _458.file, 'call', _459 => _459(/[Hh]eader\.xml$/), 'optionalAccess', _460 => _460[0]])));
|
|
26784
27018
|
let headerXml = "<root/>";
|
|
26785
27019
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
26786
27020
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
26787
27021
|
const borderFills = parseBorderFills(headerDoc);
|
|
26788
27022
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
26789
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
27023
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _461 => _461.name, 'access', _462 => _462.match, 'call', _463 => _463(/(\d+)\.xml$/), 'optionalAccess', _464 => _464[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _465 => _465.name, 'access', _466 => _466.match, 'call', _467 => _467(/(\d+)\.xml$/), 'optionalAccess', _468 => _468[1]]), () => ( null))), () => ( 0))));
|
|
26790
27024
|
const tables = [];
|
|
26791
27025
|
let tableIndex = 0;
|
|
26792
27026
|
for (const f of sectionFiles) {
|
|
@@ -27100,7 +27334,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
27100
27334
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
27101
27335
|
function patchTableRows(input) {
|
|
27102
27336
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
27103
|
-
const xml = _optionalChain([ctx, 'access',
|
|
27337
|
+
const xml = _optionalChain([ctx, 'access', _469 => _469.scans, 'access', _470 => _470[scanTable.sectionIndex], 'optionalAccess', _471 => _471.xml]);
|
|
27104
27338
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
27105
27339
|
const numRows = table2.rows;
|
|
27106
27340
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -27267,7 +27501,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
27267
27501
|
const rr = scanTable.rowRanges[template];
|
|
27268
27502
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
27269
27503
|
const scan = scanSectionXml(wrapped, 0);
|
|
27270
|
-
const row = _optionalChain([scan, 'access',
|
|
27504
|
+
const row = _optionalChain([scan, 'access', _472 => _472.tables, 'access', _473 => _473[0], 'optionalAccess', _474 => _474.rows, 'access', _475 => _475[0]]);
|
|
27271
27505
|
if (!row || row.length !== cells.length) return null;
|
|
27272
27506
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
27273
27507
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -27310,7 +27544,7 @@ function rowHeightOf(fragment) {
|
|
|
27310
27544
|
}
|
|
27311
27545
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
27312
27546
|
const from = scanTable.start + tblOpenLen;
|
|
27313
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
27547
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _476 => _476.rowRanges, 'access', _477 => _477[0], 'optionalAccess', _478 => _478.start]), () => ( from));
|
|
27314
27548
|
const slice = xml.slice(from, to);
|
|
27315
27549
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
27316
27550
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -27499,9 +27733,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
27499
27733
|
});
|
|
27500
27734
|
}
|
|
27501
27735
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
27502
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27736
|
+
const irCell = _optionalChain([table2, 'access', _479 => _479.cells, 'access', _480 => _480[oc.gridR], 'optionalAccess', _481 => _481[oc.gridC]]);
|
|
27503
27737
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
27504
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
27738
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _482 => _482.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
27505
27739
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
27506
27740
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
27507
27741
|
}
|
|
@@ -27569,7 +27803,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27569
27803
|
};
|
|
27570
27804
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
27571
27805
|
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)");
|
|
27572
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27806
|
+
const irCell = _optionalChain([table2, 'access', _483 => _483.cells, 'access', _484 => _484[gridR], 'optionalAccess', _485 => _485[gridC]]);
|
|
27573
27807
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
27574
27808
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27575
27809
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27593,7 +27827,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27593
27827
|
const target = cell2.paragraphs[0];
|
|
27594
27828
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
27595
27829
|
const value = newLines.join(" ");
|
|
27596
|
-
const xml = _optionalChain([ctx, 'access',
|
|
27830
|
+
const xml = _optionalChain([ctx, 'access', _486 => _486.scans, 'access', _487 => _487[target.sectionIndex], 'optionalAccess', _488 => _488.xml]);
|
|
27597
27831
|
const rawT = xml ? paraTText(target, xml) : null;
|
|
27598
27832
|
let sp;
|
|
27599
27833
|
if (xml && rawT === null) {
|
|
@@ -27627,7 +27861,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
27627
27861
|
}
|
|
27628
27862
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
27629
27863
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
27630
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
27864
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _489 => _489.scans, 'access', _490 => _490[nonEmpty[i].sectionIndex], 'optionalAccess', _491 => _491.xml]));
|
|
27631
27865
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27632
27866
|
splices.push(...sp);
|
|
27633
27867
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -27708,7 +27942,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27708
27942
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27709
27943
|
if (paths.length > 0) return paths;
|
|
27710
27944
|
}
|
|
27711
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27945
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkUQ6KDJWEcjs.compareSectionPaths);
|
|
27712
27946
|
}
|
|
27713
27947
|
function sectionPathsFromManifest(xml) {
|
|
27714
27948
|
const attr = (tag, name) => {
|
|
@@ -27718,7 +27952,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27718
27952
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27719
27953
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27720
27954
|
const id = attr(m[1], "id");
|
|
27721
|
-
const href =
|
|
27955
|
+
const href = _chunkUQ6KDJWEcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27722
27956
|
if (id && href) idToHref.set(id, href);
|
|
27723
27957
|
}
|
|
27724
27958
|
const ordered = [];
|
|
@@ -27727,7 +27961,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27727
27961
|
if (href) ordered.push(href);
|
|
27728
27962
|
}
|
|
27729
27963
|
if (ordered.length > 0) return ordered;
|
|
27730
|
-
return Array.from(idToHref.values()).sort(
|
|
27964
|
+
return Array.from(idToHref.values()).sort(_chunkUQ6KDJWEcjs.compareSectionPaths);
|
|
27731
27965
|
}
|
|
27732
27966
|
|
|
27733
27967
|
// src/roundtrip/patcher.ts
|
|
@@ -27744,7 +27978,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
27744
27978
|
let zip;
|
|
27745
27979
|
try {
|
|
27746
27980
|
zip = await _jszip2.default.loadAsync(original);
|
|
27747
|
-
} catch (
|
|
27981
|
+
} catch (e36) {
|
|
27748
27982
|
return { success: false, applied: 0, skipped, error: "ZIP \uB85C\uB4DC \uC2E4\uD328" };
|
|
27749
27983
|
}
|
|
27750
27984
|
const sectionPaths = await resolveSectionEntryNames(zip);
|
|
@@ -27819,7 +28053,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
27819
28053
|
}
|
|
27820
28054
|
}
|
|
27821
28055
|
let verification;
|
|
27822
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28056
|
+
if (_optionalChain([options, 'optionalAccess', _492 => _492.verify]) !== false) {
|
|
27823
28057
|
try {
|
|
27824
28058
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
27825
28059
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -27837,17 +28071,17 @@ function buildOrigUnits(blocks) {
|
|
|
27837
28071
|
let chunk;
|
|
27838
28072
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27839
28073
|
const next = blocks[i + 1];
|
|
27840
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
27841
|
-
chunk =
|
|
28074
|
+
if (_optionalChain([next, 'optionalAccess', _493 => _493.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
28075
|
+
chunk = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27842
28076
|
} else {
|
|
27843
|
-
chunk =
|
|
28077
|
+
chunk = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27844
28078
|
}
|
|
27845
28079
|
if (chunk) {
|
|
27846
28080
|
const subUnits = splitMarkdownUnits(chunk);
|
|
27847
28081
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
27848
28082
|
for (let s = 0; s < subUnits.length; s++) {
|
|
27849
28083
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
27850
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
28084
|
+
if (block.type === "table" && _optionalChain([block, 'access', _494 => _494.table, 'optionalAccess', _495 => _495.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
27851
28085
|
u.role = "caption";
|
|
27852
28086
|
}
|
|
27853
28087
|
units.push(u);
|
|
@@ -27958,7 +28192,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27958
28192
|
const ti = ctx.tableInsert;
|
|
27959
28193
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
27960
28194
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27961
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28195
|
+
if (!_optionalChain([mapping, 'optionalAccess', _496 => _496.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");
|
|
27962
28196
|
const para2 = mapping.para;
|
|
27963
28197
|
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");
|
|
27964
28198
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -27986,7 +28220,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27986
28220
|
}
|
|
27987
28221
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
27988
28222
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27989
|
-
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\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
27990
28224
|
if (block.text && block.text.includes("\n")) {
|
|
27991
28225
|
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)");
|
|
27992
28226
|
}
|
|
@@ -28017,7 +28251,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
28017
28251
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
28018
28252
|
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");
|
|
28019
28253
|
}
|
|
28020
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
28254
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _498 => _498.scans, 'access', _499 => _499[mapping.para.sectionIndex], 'optionalAccess', _500 => _500.xml]));
|
|
28021
28255
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
28022
28256
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
28023
28257
|
return 1;
|
|
@@ -28105,17 +28339,17 @@ var Surgeon = (_class7 = class {
|
|
|
28105
28339
|
|
|
28106
28340
|
/** 논리 파일 길이 — buf는 성장 시 기하급수 capacity로 재할당되므로 buf.length와 다를 수 있음 */
|
|
28107
28341
|
|
|
28108
|
-
|
|
28342
|
+
__init14() {this.fat = []}
|
|
28109
28343
|
/** FAT 배열을 구성하는 섹터 번호들 (DIFAT 순서) */
|
|
28110
|
-
|
|
28111
|
-
|
|
28112
|
-
|
|
28113
|
-
|
|
28114
|
-
|
|
28344
|
+
__init15() {this.fatSectors = []}
|
|
28345
|
+
__init16() {this.miniFat = []}
|
|
28346
|
+
__init17() {this.miniFatSectors = []}
|
|
28347
|
+
__init18() {this.dirSectors = []}
|
|
28348
|
+
__init19() {this.entries = []}
|
|
28115
28349
|
/** replace()가 FREESECT로 해제한 섹터 — finish()에서 재할당 안 된 것만 0으로 지움 (데이터 잔존 방지) */
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
constructor(file) {;_class7.prototype.
|
|
28350
|
+
__init20() {this.freedSectors = []}
|
|
28351
|
+
__init21() {this.freedMiniSectors = []}
|
|
28352
|
+
constructor(file) {;_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this);_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);
|
|
28119
28353
|
if (file.length < SECTOR || file.readUInt32LE(0) !== 3759263696) {
|
|
28120
28354
|
throw new OleSurgeonError("OLE \uC2DC\uADF8\uB2C8\uCC98\uAC00 \uC544\uB2D9\uB2C8\uB2E4");
|
|
28121
28355
|
}
|
|
@@ -28209,7 +28443,7 @@ var Surgeon = (_class7 = class {
|
|
|
28209
28443
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
28210
28444
|
findEntry(path) {
|
|
28211
28445
|
const parts = path.replace(/^\//, "").split("/");
|
|
28212
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
28446
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _501 => _501.entries, 'access', _502 => _502[0], 'optionalAccess', _503 => _503.child]), () => ( -1));
|
|
28213
28447
|
let current;
|
|
28214
28448
|
for (const part of parts) {
|
|
28215
28449
|
const search = (idx) => {
|
|
@@ -28462,8 +28696,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
28462
28696
|
parts.push(header, data);
|
|
28463
28697
|
};
|
|
28464
28698
|
for (let i = 0; i < recs.length; i++) {
|
|
28465
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
28466
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
28699
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _504 => _504.get, 'call', _505 => _505(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
28700
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _506 => _506.get, 'call', _507 => _507(i)]), () => ( recs[i].data)));
|
|
28467
28701
|
}
|
|
28468
28702
|
return Buffer.concat(parts);
|
|
28469
28703
|
}
|
|
@@ -28581,7 +28815,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28581
28815
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
28582
28816
|
}
|
|
28583
28817
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
28584
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
28818
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _508 => _508.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
28585
28819
|
let flags;
|
|
28586
28820
|
try {
|
|
28587
28821
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -28603,7 +28837,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28603
28837
|
const scans = [];
|
|
28604
28838
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
28605
28839
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
28606
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
28840
|
+
if (!_optionalChain([entry, 'optionalAccess', _509 => _509.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
28607
28841
|
let stream;
|
|
28608
28842
|
try {
|
|
28609
28843
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -28654,7 +28888,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
28654
28888
|
}
|
|
28655
28889
|
}
|
|
28656
28890
|
let verification;
|
|
28657
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28891
|
+
if (_optionalChain([options, 'optionalAccess', _510 => _510.verify]) !== false) {
|
|
28658
28892
|
try {
|
|
28659
28893
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
28660
28894
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -28744,7 +28978,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
28744
28978
|
for (const [key, scanCell] of scanTable.cells) {
|
|
28745
28979
|
const comma = key.indexOf(",");
|
|
28746
28980
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
28747
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
28981
|
+
const irCell = _optionalChain([irTable, 'access', _511 => _511.cells, 'access', _512 => _512[r], 'optionalAccess', _513 => _513[c]]);
|
|
28748
28982
|
if (!irCell) continue;
|
|
28749
28983
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
28750
28984
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -28780,7 +29014,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
28780
29014
|
}
|
|
28781
29015
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
28782
29016
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
28783
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
29017
|
+
if (!_optionalChain([mapping, 'optionalAccess', _514 => _514.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)");
|
|
28784
29018
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
28785
29019
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
28786
29020
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -28979,7 +29213,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
28979
29213
|
};
|
|
28980
29214
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
28981
29215
|
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)");
|
|
28982
|
-
const irCell = _optionalChain([table2, 'access',
|
|
29216
|
+
const irCell = _optionalChain([table2, 'access', _515 => _515.cells, 'access', _516 => _516[gridR], 'optionalAccess', _517 => _517[gridC]]);
|
|
28983
29217
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
28984
29218
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
28985
29219
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -29386,11 +29620,11 @@ var RULES2 = {
|
|
|
29386
29620
|
}
|
|
29387
29621
|
};
|
|
29388
29622
|
function redactText(text, options) {
|
|
29389
|
-
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29623
|
+
const maskChar = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _518 => _518.maskChar]), () => ( "\u25CF"));
|
|
29390
29624
|
if (maskChar.length !== 1 || /[0-9A-Za-z]/.test(maskChar)) {
|
|
29391
29625
|
throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\uAC00 \uC544\uB2CC 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
|
|
29392
29626
|
}
|
|
29393
|
-
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29627
|
+
const enabled = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _519 => _519.rules]), () => ( DEFAULT_REDACT_RULES));
|
|
29394
29628
|
const hits = [];
|
|
29395
29629
|
if (text === "" || enabled.length === 0) return { text, hits };
|
|
29396
29630
|
const occupied = [];
|
|
@@ -29445,8 +29679,8 @@ function sameBreadcrumb(a, b) {
|
|
|
29445
29679
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
29446
29680
|
}
|
|
29447
29681
|
function blocksToChunks(blocks, options) {
|
|
29448
|
-
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29449
|
-
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29682
|
+
const granularity = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _520 => _520.granularity]), () => ( "section"));
|
|
29683
|
+
const includeCells = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _521 => _521.includeTableCells]), () => ( false));
|
|
29450
29684
|
const chunks = [];
|
|
29451
29685
|
const headingStack = [];
|
|
29452
29686
|
const listStack = [];
|
|
@@ -29460,12 +29694,12 @@ function blocksToChunks(blocks, options) {
|
|
|
29460
29694
|
let run = null;
|
|
29461
29695
|
const flushRun = () => {
|
|
29462
29696
|
if (!run) return;
|
|
29463
|
-
push("text", run.breadcrumb,
|
|
29697
|
+
push("text", run.breadcrumb, _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
29464
29698
|
run = null;
|
|
29465
29699
|
};
|
|
29466
29700
|
for (let i = 0; i < blocks.length; i++) {
|
|
29467
29701
|
const block = blocks[i];
|
|
29468
|
-
const md2 =
|
|
29702
|
+
const md2 = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, [block]);
|
|
29469
29703
|
if (!md2) continue;
|
|
29470
29704
|
if (block.type === "heading") {
|
|
29471
29705
|
flushRun();
|
|
@@ -29555,7 +29789,7 @@ function irCellLines(text) {
|
|
|
29555
29789
|
}
|
|
29556
29790
|
var HwpxSession = (_class8 = class _HwpxSession {
|
|
29557
29791
|
|
|
29558
|
-
constructor(state) {;_class8.prototype.
|
|
29792
|
+
constructor(state) {;_class8.prototype.__init22.call(this);
|
|
29559
29793
|
this.state = state;
|
|
29560
29794
|
}
|
|
29561
29795
|
/** HWPX 바이트로 세션을 연다 (입력은 복사되어 외부 변이와 격리) */
|
|
@@ -29581,7 +29815,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29581
29815
|
const block = st.blocks[blockIndex];
|
|
29582
29816
|
if (!block) return void 0;
|
|
29583
29817
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
29584
|
-
const para2 = _optionalChain([st, 'access',
|
|
29818
|
+
const para2 = _optionalChain([st, 'access', _522 => _522.paraMap, 'access', _523 => _523.get, 'call', _524 => _524(blockIndex), 'optionalAccess', _525 => _525.para]);
|
|
29585
29819
|
if (!para2) return void 0;
|
|
29586
29820
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
29587
29821
|
}
|
|
@@ -29606,7 +29840,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29606
29840
|
if (block.text && block.text.includes("\n")) {
|
|
29607
29841
|
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)" };
|
|
29608
29842
|
}
|
|
29609
|
-
if (!_optionalChain([st, 'access',
|
|
29843
|
+
if (!_optionalChain([st, 'access', _526 => _526.paraMap, 'access', _527 => _527.get, 'call', _528 => _528(blockIndex), 'optionalAccess', _529 => _529.para])) {
|
|
29610
29844
|
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)" };
|
|
29611
29845
|
}
|
|
29612
29846
|
return { capability: "text" };
|
|
@@ -29655,7 +29889,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29655
29889
|
this.opQueue = run.then(() => void 0, () => void 0);
|
|
29656
29890
|
return run;
|
|
29657
29891
|
}
|
|
29658
|
-
|
|
29892
|
+
__init22() {this.opQueue = Promise.resolve()}
|
|
29659
29893
|
async patchBlocksInner(edits, options) {
|
|
29660
29894
|
const st = this.state;
|
|
29661
29895
|
const skipped = [];
|
|
@@ -29672,7 +29906,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29672
29906
|
continue;
|
|
29673
29907
|
}
|
|
29674
29908
|
if (block.type === "table" && block.table) {
|
|
29675
|
-
if (!_optionalChain([edit, 'access',
|
|
29909
|
+
if (!_optionalChain([edit, 'access', _530 => _530.cells, 'optionalAccess', _531 => _531.length])) {
|
|
29676
29910
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
29677
29911
|
continue;
|
|
29678
29912
|
}
|
|
@@ -29692,7 +29926,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29692
29926
|
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) });
|
|
29693
29927
|
continue;
|
|
29694
29928
|
}
|
|
29695
|
-
const irCell = _optionalChain([block, 'access',
|
|
29929
|
+
const irCell = _optionalChain([block, 'access', _532 => _532.table, 'access', _533 => _533.cells, 'access', _534 => _534[cellEdit.row], 'optionalAccess', _535 => _535[cellEdit.col]]);
|
|
29696
29930
|
if (!irCell) {
|
|
29697
29931
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
29698
29932
|
continue;
|
|
@@ -29748,7 +29982,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29748
29982
|
}
|
|
29749
29983
|
if (replacements.size === 0) {
|
|
29750
29984
|
let changes2;
|
|
29751
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
29985
|
+
if (_optionalChain([options, 'optionalAccess', _536 => _536.verify]) !== false) {
|
|
29752
29986
|
const units = splitMarkdownUnits(st.markdown);
|
|
29753
29987
|
changes2 = diffUnitLists(units, units);
|
|
29754
29988
|
}
|
|
@@ -29769,7 +30003,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29769
30003
|
}
|
|
29770
30004
|
this.state = newState;
|
|
29771
30005
|
let changes;
|
|
29772
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
30006
|
+
if (_optionalChain([options, 'optionalAccess', _537 => _537.verify]) !== false) {
|
|
29773
30007
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
29774
30008
|
}
|
|
29775
30009
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -29789,7 +30023,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29789
30023
|
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)");
|
|
29790
30024
|
}
|
|
29791
30025
|
const mapping = st.paraMap.get(blockIndex);
|
|
29792
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
30026
|
+
if (!_optionalChain([mapping, 'optionalAccess', _538 => _538.para])) {
|
|
29793
30027
|
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)");
|
|
29794
30028
|
}
|
|
29795
30029
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -29809,14 +30043,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
29809
30043
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
29810
30044
|
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");
|
|
29811
30045
|
}
|
|
29812
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
30046
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _539 => _539.scans, 'access', _540 => _540[mapping.para.sectionIndex], 'optionalAccess', _541 => _541.xml]));
|
|
29813
30047
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
29814
30048
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
29815
30049
|
return 1;
|
|
29816
30050
|
}
|
|
29817
30051
|
}, _class8);
|
|
29818
30052
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
29819
|
-
const irCell = _optionalChain([table2, 'access',
|
|
30053
|
+
const irCell = _optionalChain([table2, 'access', _542 => _542.cells, 'access', _543 => _543[r], 'optionalAccess', _544 => _544[c]]);
|
|
29820
30054
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
29821
30055
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
29822
30056
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -29900,11 +30134,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
29900
30134
|
breaks: false
|
|
29901
30135
|
});
|
|
29902
30136
|
function renderHtml(markdown, options) {
|
|
29903
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29904
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30137
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _545 => _545.preset]), () => ( "default"));
|
|
30138
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _546 => _546.extraCss]), () => ( "")));
|
|
29905
30139
|
const body = md.render(markdown);
|
|
29906
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
29907
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
30140
|
+
const watermark = _optionalChain([options, 'optionalAccess', _547 => _547.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
30141
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _548 => _548.watermark]) ? `
|
|
29908
30142
|
.watermark {
|
|
29909
30143
|
position: fixed;
|
|
29910
30144
|
top: 50%; left: 50%;
|
|
@@ -29934,14 +30168,14 @@ async function htmlToPdf(html, options) {
|
|
|
29934
30168
|
let puppeteer;
|
|
29935
30169
|
try {
|
|
29936
30170
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29937
|
-
} catch (
|
|
29938
|
-
throw new (0,
|
|
30171
|
+
} catch (e37) {
|
|
30172
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
29939
30173
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29940
30174
|
);
|
|
29941
30175
|
}
|
|
29942
30176
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29943
30177
|
if (!executablePath) {
|
|
29944
|
-
throw new (0,
|
|
30178
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)(
|
|
29945
30179
|
"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."
|
|
29946
30180
|
);
|
|
29947
30181
|
}
|
|
@@ -29953,10 +30187,10 @@ async function htmlToPdf(html, options) {
|
|
|
29953
30187
|
try {
|
|
29954
30188
|
const page = await browser.newPage();
|
|
29955
30189
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
29956
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
30190
|
+
const margin = _optionalChain([options, 'optionalAccess', _549 => _549.margin]);
|
|
29957
30191
|
const pdf = await page.pdf({
|
|
29958
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29959
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
30192
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _550 => _550.pageSize]), () => ( "A4")),
|
|
30193
|
+
landscape: _optionalChain([options, 'optionalAccess', _551 => _551.orientation]) === "landscape",
|
|
29960
30194
|
printBackground: true,
|
|
29961
30195
|
margin: margin ? {
|
|
29962
30196
|
top: toCss(margin.top),
|
|
@@ -29964,9 +30198,9 @@ async function htmlToPdf(html, options) {
|
|
|
29964
30198
|
bottom: toCss(margin.bottom),
|
|
29965
30199
|
left: toCss(margin.left)
|
|
29966
30200
|
} : void 0,
|
|
29967
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
29968
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29969
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
30201
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _552 => _552.header]) || _optionalChain([options, 'optionalAccess', _553 => _553.footer])),
|
|
30202
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _554 => _554.header]), () => ( "<div></div>")),
|
|
30203
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
29970
30204
|
});
|
|
29971
30205
|
return Buffer.from(pdf);
|
|
29972
30206
|
} finally {
|
|
@@ -30000,7 +30234,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
30000
30234
|
return htmlToPdf(html, options);
|
|
30001
30235
|
}
|
|
30002
30236
|
async function blocksToPdf(blocks, options) {
|
|
30003
|
-
const markdown =
|
|
30237
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks);
|
|
30004
30238
|
return markdownToPdf(markdown, options);
|
|
30005
30239
|
}
|
|
30006
30240
|
|
|
@@ -30179,7 +30413,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
30179
30413
|
}
|
|
30180
30414
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
30181
30415
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
30182
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30416
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _556 => _556.getAttribute, 'call', _557 => _557("vertRelTo")]), () => ( "PARA"));
|
|
30183
30417
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
30184
30418
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
30185
30419
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -30240,7 +30474,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
30240
30474
|
if (ln(p) !== "p") continue;
|
|
30241
30475
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
30242
30476
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
30243
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
30477
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _558 => _558.spaceBefore]), () => ( 0)));
|
|
30244
30478
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
30245
30479
|
if (!res) {
|
|
30246
30480
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -30253,7 +30487,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
30253
30487
|
}
|
|
30254
30488
|
if (Number.isFinite(bottom)) {
|
|
30255
30489
|
cursorV = bottom;
|
|
30256
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
30490
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _559 => _559.spaceAfter]), () => ( 0));
|
|
30257
30491
|
}
|
|
30258
30492
|
}
|
|
30259
30493
|
continue;
|
|
@@ -30359,7 +30593,7 @@ function buildPara(p) {
|
|
|
30359
30593
|
const pos = findChildByLocalName(ch, "pos");
|
|
30360
30594
|
const w = num3(sz, "width") || num3(findChildByLocalName(ch, "curSz"), "width") || num3(findChildByLocalName(ch, "orgSz"), "width");
|
|
30361
30595
|
const h = num3(sz, "height") || num3(findChildByLocalName(ch, "curSz"), "height") || num3(findChildByLocalName(ch, "orgSz"), "height");
|
|
30362
|
-
const inline = _optionalChain([pos, 'optionalAccess',
|
|
30596
|
+
const inline = _optionalChain([pos, 'optionalAccess', _560 => _560.getAttribute, 'call', _561 => _561("treatAsChar")]) === "1";
|
|
30363
30597
|
const om = inline && cn === "tbl" ? findChildByLocalName(ch, "outMargin") : null;
|
|
30364
30598
|
objs.push({
|
|
30365
30599
|
el: ch,
|
|
@@ -30619,15 +30853,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30619
30853
|
const sx = ow > 0 ? w / ow : 1;
|
|
30620
30854
|
const sy = oh > 0 ? h / oh : 1;
|
|
30621
30855
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
30622
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
30623
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
30856
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _562 => _562.getAttribute, 'call', _563 => _563("style")]), () => ( "SOLID"));
|
|
30857
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _564 => _564.getAttribute, 'call', _565 => _565("color")]) || "#000000";
|
|
30624
30858
|
const hasStroke = lstyle !== "NONE";
|
|
30625
30859
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
30626
30860
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
30627
30861
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
30628
30862
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
30629
30863
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
30630
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
30864
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _566 => _566.getAttribute, 'call', _567 => _567("faceColor")]);
|
|
30631
30865
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
30632
30866
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
30633
30867
|
if (o.tag === "rect") {
|
|
@@ -30654,14 +30888,14 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
30654
30888
|
}
|
|
30655
30889
|
function cellContentExtent(cell2, memo) {
|
|
30656
30890
|
if (!cell2.sub) return 0;
|
|
30657
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30891
|
+
const hit = _optionalChain([memo, 'optionalAccess', _568 => _568.cell, 'access', _569 => _569.get, 'call', _570 => _570(cell2.el)]);
|
|
30658
30892
|
if (hit !== void 0) return hit;
|
|
30659
30893
|
let ext = 0;
|
|
30660
30894
|
for (const p of elements2(cell2.sub)) {
|
|
30661
30895
|
if (ln2(p) !== "p") continue;
|
|
30662
30896
|
const m = buildPara(p);
|
|
30663
30897
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
30664
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
30898
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _571 => _571.segs, 'access', _572 => _572[0], 'optionalAccess', _573 => _573.vertpos]), () => ( 0));
|
|
30665
30899
|
for (const o of m.objs) {
|
|
30666
30900
|
if (o.inline) {
|
|
30667
30901
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
@@ -30669,14 +30903,14 @@ function cellContentExtent(cell2, memo) {
|
|
|
30669
30903
|
continue;
|
|
30670
30904
|
}
|
|
30671
30905
|
const pos = findChildByLocalName(o.el, "pos");
|
|
30672
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
30906
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _574 => _574.getAttribute, 'call', _575 => _575("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
30673
30907
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
30674
30908
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
30675
30909
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
30676
30910
|
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
30677
30911
|
}
|
|
30678
30912
|
}
|
|
30679
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30913
|
+
_optionalChain([memo, 'optionalAccess', _576 => _576.cell, 'access', _577 => _577.set, 'call', _578 => _578(cell2.el, ext)]);
|
|
30680
30914
|
return ext;
|
|
30681
30915
|
}
|
|
30682
30916
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
@@ -30718,7 +30952,7 @@ function collectCells(tbl2) {
|
|
|
30718
30952
|
return cells;
|
|
30719
30953
|
}
|
|
30720
30954
|
function measureTableHeight(tbl2, memo) {
|
|
30721
|
-
const hit = _optionalChain([memo, 'optionalAccess',
|
|
30955
|
+
const hit = _optionalChain([memo, 'optionalAccess', _579 => _579.table, 'access', _580 => _580.get, 'call', _581 => _581(tbl2)]);
|
|
30722
30956
|
if (hit !== void 0) return hit;
|
|
30723
30957
|
const cells = collectCells(tbl2);
|
|
30724
30958
|
if (cells.length === 0 || cells.length > 4096) return 0;
|
|
@@ -30729,7 +30963,7 @@ function measureTableHeight(tbl2, memo) {
|
|
|
30729
30963
|
);
|
|
30730
30964
|
let sum = 0;
|
|
30731
30965
|
for (const h of rowH) sum += h;
|
|
30732
|
-
_optionalChain([memo, 'optionalAccess',
|
|
30966
|
+
_optionalChain([memo, 'optionalAccess', _582 => _582.table, 'access', _583 => _583.set, 'call', _584 => _584(tbl2, sum)]);
|
|
30733
30967
|
return sum;
|
|
30734
30968
|
}
|
|
30735
30969
|
function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
@@ -30760,7 +30994,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
30760
30994
|
}));
|
|
30761
30995
|
for (const g of geom) {
|
|
30762
30996
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
30763
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
30997
|
+
if (_optionalChain([bf, 'optionalAccess', _585 => _585.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
30764
30998
|
}
|
|
30765
30999
|
for (const g of geom) {
|
|
30766
31000
|
const { c } = g;
|
|
@@ -30798,7 +31032,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
30798
31032
|
const sz = findChildByLocalName(pic, "sz");
|
|
30799
31033
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
30800
31034
|
const img = findFirst(pic, "img");
|
|
30801
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
31035
|
+
const ref = _optionalChain([img, 'optionalAccess', _586 => _586.getAttribute, 'call', _587 => _587("binaryItemIDRef")]);
|
|
30802
31036
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
30803
31037
|
if (!loaded) {
|
|
30804
31038
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -30838,7 +31072,7 @@ function readSectionGeom(root) {
|
|
|
30838
31072
|
const pagePr = findFirst(root, "pagePr");
|
|
30839
31073
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
30840
31074
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
30841
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
31075
|
+
if (_optionalChain([pagePr, 'optionalAccess', _588 => _588.getAttribute, 'call', _589 => _589("landscape")]) === "NARROWLY" && PW < PH) {
|
|
30842
31076
|
const t = PW;
|
|
30843
31077
|
PW = PH;
|
|
30844
31078
|
PH = t;
|
|
@@ -30896,17 +31130,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30896
31130
|
return { pages: ctx.pages, pageH };
|
|
30897
31131
|
}
|
|
30898
31132
|
async function renderHwpxToSvg(input, options) {
|
|
30899
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
31133
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _590 => _590.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30900
31134
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30901
|
-
|
|
31135
|
+
_chunkUQ6KDJWEcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30902
31136
|
let zip;
|
|
30903
31137
|
try {
|
|
30904
31138
|
zip = await _jszip2.default.loadAsync(input);
|
|
30905
|
-
} catch (
|
|
30906
|
-
throw new (0,
|
|
31139
|
+
} catch (e38) {
|
|
31140
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30907
31141
|
}
|
|
30908
31142
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30909
|
-
if (secFiles.length === 0) throw new (0,
|
|
31143
|
+
if (secFiles.length === 0) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30910
31144
|
const warnings = [];
|
|
30911
31145
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30912
31146
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30914,7 +31148,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30914
31148
|
const secXmls = [];
|
|
30915
31149
|
for (const f of secFiles) {
|
|
30916
31150
|
const xml = await f.async("string");
|
|
30917
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
31151
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30918
31152
|
secXmls.push(xml);
|
|
30919
31153
|
}
|
|
30920
31154
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30938,7 +31172,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30938
31172
|
let href = binmap.get(ref);
|
|
30939
31173
|
if (!href) {
|
|
30940
31174
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
30941
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
31175
|
+
href = _optionalChain([cand, 'optionalAccess', _591 => _591.name]);
|
|
30942
31176
|
}
|
|
30943
31177
|
if (!href) continue;
|
|
30944
31178
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -30959,7 +31193,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30959
31193
|
styles,
|
|
30960
31194
|
images,
|
|
30961
31195
|
defs: [],
|
|
30962
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
31196
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _592 => _592.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
30963
31197
|
warnings,
|
|
30964
31198
|
warned: /* @__PURE__ */ new Set(),
|
|
30965
31199
|
stats: { texts: 0, images: 0, tables: 0 },
|
|
@@ -30970,7 +31204,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30970
31204
|
for (let si = 0; si < secXmls.length; si++) {
|
|
30971
31205
|
const secXml = secXmls[si];
|
|
30972
31206
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
30973
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
31207
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _593 => _593.reflow])) {
|
|
30974
31208
|
noCacheSkipped = true;
|
|
30975
31209
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
30976
31210
|
continue;
|
|
@@ -30982,14 +31216,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30982
31216
|
continue;
|
|
30983
31217
|
}
|
|
30984
31218
|
const geom = readSectionGeom(root);
|
|
30985
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess',
|
|
31219
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _594 => _594.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _595 => _595.reflowMode]), () => ( "keep")));
|
|
30986
31220
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
30987
31221
|
}
|
|
30988
31222
|
if (rendered.length === 0) {
|
|
30989
31223
|
if (noCacheSkipped) {
|
|
30990
|
-
throw new (0,
|
|
31224
|
+
throw new (0, _chunkUQ6KDJWEcjs.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)");
|
|
30991
31225
|
}
|
|
30992
|
-
throw new (0,
|
|
31226
|
+
throw new (0, _chunkUQ6KDJWEcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30993
31227
|
}
|
|
30994
31228
|
const GAP = 2400;
|
|
30995
31229
|
const clipDefs = [];
|
|
@@ -31021,17 +31255,17 @@ ${groups.join("\n")}
|
|
|
31021
31255
|
// src/index.ts
|
|
31022
31256
|
async function parse(input, options) {
|
|
31023
31257
|
let buffer;
|
|
31024
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
31258
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _596 => _596.filePath]) ? { ...options, filePath: input } : options;
|
|
31025
31259
|
if (typeof input === "string") {
|
|
31026
31260
|
try {
|
|
31027
31261
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31028
|
-
buffer =
|
|
31262
|
+
buffer = _chunkUQ6KDJWEcjs.toArrayBuffer.call(void 0, buf);
|
|
31029
31263
|
} catch (err) {
|
|
31030
31264
|
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}`;
|
|
31031
31265
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
31032
31266
|
}
|
|
31033
31267
|
} else if (Buffer.isBuffer(input)) {
|
|
31034
|
-
buffer =
|
|
31268
|
+
buffer = _chunkUQ6KDJWEcjs.toArrayBuffer.call(void 0, input);
|
|
31035
31269
|
} else {
|
|
31036
31270
|
buffer = input;
|
|
31037
31271
|
}
|
|
@@ -31065,40 +31299,40 @@ async function parse(input, options) {
|
|
|
31065
31299
|
}
|
|
31066
31300
|
async function parseImage(buffer, options) {
|
|
31067
31301
|
try {
|
|
31068
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
31302
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-KZ4MGVJ3.cjs")));
|
|
31069
31303
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
31070
31304
|
return {
|
|
31071
31305
|
success: true,
|
|
31072
31306
|
fileType: "image",
|
|
31073
|
-
markdown:
|
|
31307
|
+
markdown: _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, blocks),
|
|
31074
31308
|
blocks,
|
|
31075
31309
|
warnings: warnings.length ? warnings : void 0,
|
|
31076
31310
|
pageCount: 1
|
|
31077
31311
|
};
|
|
31078
31312
|
} catch (err) {
|
|
31079
|
-
return { success: false, fileType: "image", error:
|
|
31313
|
+
return { success: false, fileType: "image", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31080
31314
|
}
|
|
31081
31315
|
}
|
|
31082
31316
|
async function parseHwp3(buffer, options) {
|
|
31083
31317
|
try {
|
|
31084
31318
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
31085
|
-
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31319
|
+
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _597 => _597.pageCount]) };
|
|
31086
31320
|
} catch (err) {
|
|
31087
|
-
return { success: false, fileType: "hwp3", error:
|
|
31321
|
+
return { success: false, fileType: "hwp3", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31088
31322
|
}
|
|
31089
31323
|
}
|
|
31090
31324
|
async function parseHwpx(buffer, options) {
|
|
31091
31325
|
try {
|
|
31092
31326
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
31093
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
31327
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _598 => _598.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _599 => _599.pageCount]) };
|
|
31094
31328
|
} catch (err) {
|
|
31095
|
-
return { success: false, fileType: "hwpx", error:
|
|
31329
|
+
return { success: false, fileType: "hwpx", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31096
31330
|
}
|
|
31097
31331
|
}
|
|
31098
31332
|
async function parseHwp(buffer, options) {
|
|
31099
31333
|
try {
|
|
31100
31334
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
31101
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
31335
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _600 => _600.filePath])) {
|
|
31102
31336
|
try {
|
|
31103
31337
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
31104
31338
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -31113,20 +31347,20 @@ async function parseHwp(buffer, options) {
|
|
|
31113
31347
|
pageCount
|
|
31114
31348
|
};
|
|
31115
31349
|
}
|
|
31116
|
-
} catch (
|
|
31350
|
+
} catch (e39) {
|
|
31117
31351
|
}
|
|
31118
31352
|
}
|
|
31119
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
31353
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _601 => _601.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _602 => _602.pageCount]) };
|
|
31120
31354
|
} catch (err) {
|
|
31121
|
-
return { success: false, fileType: "hwp", error:
|
|
31355
|
+
return { success: false, fileType: "hwp", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31122
31356
|
}
|
|
31123
31357
|
}
|
|
31124
31358
|
async function parsePdf(buffer, options) {
|
|
31125
31359
|
let parsePdfDocument;
|
|
31126
31360
|
try {
|
|
31127
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
31361
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-7G2QFIYZ.cjs")));
|
|
31128
31362
|
parsePdfDocument = mod.parsePdfDocument;
|
|
31129
|
-
} catch (
|
|
31363
|
+
} catch (e40) {
|
|
31130
31364
|
return {
|
|
31131
31365
|
success: false,
|
|
31132
31366
|
fileType: "pdf",
|
|
@@ -31136,51 +31370,51 @@ async function parsePdf(buffer, options) {
|
|
|
31136
31370
|
}
|
|
31137
31371
|
try {
|
|
31138
31372
|
const { markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images } = await parsePdfDocument(buffer, options);
|
|
31139
|
-
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31373
|
+
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images, pageCount: _optionalChain([metadata, 'optionalAccess', _603 => _603.pageCount]) };
|
|
31140
31374
|
} catch (err) {
|
|
31141
31375
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
31142
|
-
return { success: false, fileType: "pdf", error:
|
|
31376
|
+
return { success: false, fileType: "pdf", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err), isImageBased };
|
|
31143
31377
|
}
|
|
31144
31378
|
}
|
|
31145
31379
|
async function parseXlsx(buffer, options) {
|
|
31146
31380
|
try {
|
|
31147
31381
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
31148
|
-
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31382
|
+
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _604 => _604.pageCount]) };
|
|
31149
31383
|
} catch (err) {
|
|
31150
|
-
return { success: false, fileType: "xlsx", error:
|
|
31384
|
+
return { success: false, fileType: "xlsx", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31151
31385
|
}
|
|
31152
31386
|
}
|
|
31153
31387
|
async function parseXls(buffer, options) {
|
|
31154
31388
|
try {
|
|
31155
31389
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
31156
|
-
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31390
|
+
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _605 => _605.pageCount]) };
|
|
31157
31391
|
} catch (err) {
|
|
31158
|
-
return { success: false, fileType: "xls", error:
|
|
31392
|
+
return { success: false, fileType: "xls", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31159
31393
|
}
|
|
31160
31394
|
}
|
|
31161
31395
|
async function parseDocx(buffer, options) {
|
|
31162
31396
|
try {
|
|
31163
31397
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
31164
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
31398
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _606 => _606.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _607 => _607.pageCount]) };
|
|
31165
31399
|
} catch (err) {
|
|
31166
|
-
return { success: false, fileType: "docx", error:
|
|
31400
|
+
return { success: false, fileType: "docx", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31167
31401
|
}
|
|
31168
31402
|
}
|
|
31169
31403
|
async function parseHwpml(buffer, options) {
|
|
31170
31404
|
try {
|
|
31171
31405
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
31172
|
-
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess',
|
|
31406
|
+
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _608 => _608.pageCount]) };
|
|
31173
31407
|
} catch (err) {
|
|
31174
|
-
return { success: false, fileType: "hwpml", error:
|
|
31408
|
+
return { success: false, fileType: "hwpml", error: _chunkUQ6KDJWEcjs.sanitizeError.call(void 0, err), code: _chunkUQ6KDJWEcjs.classifyError.call(void 0, err) };
|
|
31175
31409
|
}
|
|
31176
31410
|
}
|
|
31177
31411
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
31178
31412
|
let buffer;
|
|
31179
31413
|
if (typeof input === "string") {
|
|
31180
31414
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31181
|
-
buffer =
|
|
31415
|
+
buffer = _chunkUQ6KDJWEcjs.toArrayBuffer.call(void 0, buf);
|
|
31182
31416
|
} else if (Buffer.isBuffer(input)) {
|
|
31183
|
-
buffer =
|
|
31417
|
+
buffer = _chunkUQ6KDJWEcjs.toArrayBuffer.call(void 0, input);
|
|
31184
31418
|
} else {
|
|
31185
31419
|
buffer = input;
|
|
31186
31420
|
}
|
|
@@ -31206,7 +31440,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
31206
31440
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
31207
31441
|
}
|
|
31208
31442
|
const fill = fillFormFields(parsed.blocks, values);
|
|
31209
|
-
const markdown =
|
|
31443
|
+
const markdown = _chunkGLPLLT4Qcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
31210
31444
|
if (outputFormat === "hwpx") {
|
|
31211
31445
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
31212
31446
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -31285,5 +31519,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
31285
31519
|
|
|
31286
31520
|
|
|
31287
31521
|
|
|
31288
|
-
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 =
|
|
31522
|
+
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 = _chunkUQ6KDJWEcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkGLPLLT4Qcjs.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;
|
|
31289
31523
|
//# sourceMappingURL=index.cjs.map
|