kordoc 4.0.7 → 4.0.8
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/LICENSE +21 -21
- package/README.md +823 -806
- package/dist/{-6HWEFXVV.js → -LE4RLXVA.js} +9 -9
- package/dist/{chunk-BKWHX3RC.js → chunk-2DZQF6YJ.js} +3 -3
- package/dist/chunk-2DZQF6YJ.js.map +1 -0
- package/dist/{chunk-6GBLFQMA.js → chunk-5RPYBC2Q.js} +1 -1
- package/dist/chunk-5RPYBC2Q.js.map +1 -0
- package/dist/{chunk-U25XGCNH.cjs → chunk-6XAAYAWL.cjs} +142 -3
- package/dist/chunk-6XAAYAWL.cjs.map +1 -0
- package/dist/{chunk-TJJTLM76.js → chunk-7S3M4N4E.js} +666 -742
- package/dist/chunk-7S3M4N4E.js.map +1 -0
- package/dist/{chunk-Q7EN4EUJ.js → chunk-BNU5QGIZ.js} +2 -2
- package/dist/chunk-BNU5QGIZ.js.map +1 -0
- package/dist/{chunk-NGSHDBQR.js → chunk-D35VBACN.js} +3 -3
- package/dist/chunk-D35VBACN.js.map +1 -0
- package/dist/{chunk-X34YWRL5.cjs → chunk-DCZVOIEO.cjs} +1 -1
- package/dist/chunk-DCZVOIEO.cjs.map +1 -0
- package/dist/{chunk-AIQ3ISQU.js → chunk-GE43BE46.js} +1 -1
- package/dist/chunk-GE43BE46.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-CNM75ZSX.js → chunk-HMUEU7D7.js} +2 -2
- package/dist/chunk-HMUEU7D7.js.map +1 -0
- package/dist/{chunk-CFQLK3LM.js → chunk-MEPHGCPQ.js} +1 -1
- package/dist/chunk-MEPHGCPQ.js.map +1 -0
- package/dist/{chunk-3TBUDJDE.js → chunk-MOL7MDBG.js} +1 -1
- package/dist/chunk-MOL7MDBG.js.map +1 -0
- package/dist/{chunk-5OKHAJ62.js → chunk-OQPILS7B.js} +142 -3
- package/dist/chunk-OQPILS7B.js.map +1 -0
- package/dist/{chunk-ONXVBURQ.js → chunk-RROH5WHO.js} +2 -2
- package/dist/chunk-RROH5WHO.js.map +1 -0
- package/dist/{chunk-2SN3CKME.js → chunk-UEIYETCQ.js} +142 -3
- package/dist/chunk-UEIYETCQ.js.map +1 -0
- package/dist/cli.js +18 -18
- package/dist/cli.js.map +1 -1
- package/dist/{detect-NTR2FUEG.js → detect-RI2MQ33K.js} +2 -2
- package/dist/{formula-ZYUDQHD3.cjs → formula-5NKVS2LR.cjs} +1 -1
- package/dist/formula-5NKVS2LR.cjs.map +1 -0
- package/dist/{formula-KOQV353G.js → formula-JCNF43NE.js} +1 -1
- package/dist/formula-JCNF43NE.js.map +1 -0
- package/dist/{formula-MEDGYQXS.js → formula-RXVSQPXI.js} +1 -1
- package/dist/formula-RXVSQPXI.js.map +1 -0
- package/dist/index.cjs +1018 -1094
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +780 -856
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +14 -14
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +8 -0
- package/dist/page-range-LNMXJU6W.js +7 -0
- package/dist/page-range-P7SDW6LR.cjs +8 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -0
- package/dist/{parser-E6U5TNAU.cjs → parser-ITMU2WN5.cjs} +214 -38
- package/dist/parser-ITMU2WN5.cjs.map +1 -0
- package/dist/{parser-UGB3NIVH.js → parser-KMMUS73Q.js} +183 -7
- package/dist/parser-KMMUS73Q.js.map +1 -0
- package/dist/{parser-5EHWYJMC.js → parser-TCTCSBYZ.js} +185 -9
- package/dist/parser-TCTCSBYZ.js.map +1 -0
- package/dist/{profile-io-CAKRPQRD.js → profile-io-SLN4P76T.js} +3 -3
- package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/provider-4ZJKV3DC.js.map +1 -0
- package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
- package/dist/provider-AKROB7WQ.js.map +1 -0
- package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/render-25BT623I.js +10 -0
- package/dist/seal-R4TETA4C.js +10 -0
- package/dist/{setup-QSJ2INNS.js → setup-57FB3LSP.js} +1 -1
- package/dist/setup-57FB3LSP.js.map +1 -0
- package/dist/{watch-RMX427YR.js → watch-OHQWSVPE.js} +9 -9
- package/dist/watch-OHQWSVPE.js.map +1 -0
- package/package.json +97 -97
- package/dist/chunk-2SN3CKME.js.map +0 -1
- package/dist/chunk-3TBUDJDE.js.map +0 -1
- package/dist/chunk-5OKHAJ62.js.map +0 -1
- package/dist/chunk-6GBLFQMA.js.map +0 -1
- package/dist/chunk-AIQ3ISQU.js.map +0 -1
- package/dist/chunk-BKWHX3RC.js.map +0 -1
- package/dist/chunk-CFQLK3LM.js.map +0 -1
- package/dist/chunk-CNM75ZSX.js.map +0 -1
- package/dist/chunk-NGSHDBQR.js.map +0 -1
- package/dist/chunk-ONXVBURQ.js.map +0 -1
- package/dist/chunk-Q7EN4EUJ.js.map +0 -1
- package/dist/chunk-TJJTLM76.js.map +0 -1
- package/dist/chunk-U25XGCNH.cjs.map +0 -1
- package/dist/chunk-X34YWRL5.cjs.map +0 -1
- package/dist/formula-KOQV353G.js.map +0 -1
- package/dist/formula-MEDGYQXS.js.map +0 -1
- package/dist/formula-ZYUDQHD3.cjs.map +0 -1
- package/dist/page-range-CIRRJPXJ.js +0 -7
- package/dist/page-range-OF5I4PQY.js +0 -8
- package/dist/page-range-TPIRSA3J.cjs +0 -8
- package/dist/page-range-TPIRSA3J.cjs.map +0 -1
- package/dist/parser-5EHWYJMC.js.map +0 -1
- package/dist/parser-E6U5TNAU.cjs.map +0 -1
- package/dist/parser-UGB3NIVH.js.map +0 -1
- package/dist/provider-5K7O3Z2O.cjs.map +0 -1
- package/dist/provider-7H4CPZYS.js.map +0 -1
- package/dist/provider-H4WWSPOV.js.map +0 -1
- package/dist/render-P6663O4I.js +0 -10
- package/dist/seal-7PPTXKKV.js +0 -10
- package/dist/setup-QSJ2INNS.js.map +0 -1
- package/dist/watch-RMX427YR.js.map +0 -1
- /package/dist/{-6HWEFXVV.js.map → -LE4RLXVA.js.map} +0 -0
- /package/dist/{detect-NTR2FUEG.js.map → detect-RI2MQ33K.js.map} +0 -0
- /package/dist/{page-range-CIRRJPXJ.js.map → page-range-737B4EZW.js.map} +0 -0
- /package/dist/{page-range-OF5I4PQY.js.map → page-range-LNMXJU6W.js.map} +0 -0
- /package/dist/{profile-io-CAKRPQRD.js.map → profile-io-SLN4P76T.js.map} +0 -0
- /package/dist/{render-P6663O4I.js.map → render-25BT623I.js.map} +0 -0
- /package/dist/{seal-7PPTXKKV.js.map → seal-R4TETA4C.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var _chunkU25XGCNHcjs = require('./chunk-U25XGCNH.cjs');
|
|
24
23
|
|
|
24
|
+
var _chunk6XAAYAWLcjs = require('./chunk-6XAAYAWL.cjs');
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -406,7 +407,7 @@ function createSectionShared() {
|
|
|
406
407
|
function createXmlParser(warnings) {
|
|
407
408
|
return new (0, _xmldom.DOMParser)({
|
|
408
409
|
onError(level, msg2) {
|
|
409
|
-
if (level === "fatalError") throw new (0,
|
|
410
|
+
if (level === "fatalError") throw new (0, _chunk6XAAYAWLcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
410
411
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
411
412
|
}
|
|
412
413
|
});
|
|
@@ -462,10 +463,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
462
463
|
const xml = await file.async("text");
|
|
463
464
|
if (decompressed) {
|
|
464
465
|
decompressed.total += xml.length * 2;
|
|
465
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
466
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
466
467
|
}
|
|
467
468
|
const parser = createXmlParser();
|
|
468
|
-
const doc = parser.parseFromString(
|
|
469
|
+
const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
469
470
|
if (!doc.documentElement) continue;
|
|
470
471
|
const domDoc = doc;
|
|
471
472
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -648,9 +649,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
648
649
|
let level = 0;
|
|
649
650
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
650
651
|
const ratio = block.style.fontSize / baseFontSize;
|
|
651
|
-
if (ratio >=
|
|
652
|
-
else if (ratio >=
|
|
653
|
-
else if (ratio >=
|
|
652
|
+
if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H1) level = 1;
|
|
653
|
+
else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H2) level = 2;
|
|
654
|
+
else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H3) level = 3;
|
|
654
655
|
}
|
|
655
656
|
const compactText = text.replace(/\s+/g, "");
|
|
656
657
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1575,7 +1576,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1575
1576
|
}
|
|
1576
1577
|
function assertFiniteRange(name, value, min, max) {
|
|
1577
1578
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1578
|
-
throw new (0,
|
|
1579
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1579
1580
|
}
|
|
1580
1581
|
}
|
|
1581
1582
|
function validateGongmunOptions(opts) {
|
|
@@ -1590,10 +1591,10 @@ function validateGongmunOptions(opts) {
|
|
|
1590
1591
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1591
1592
|
}
|
|
1592
1593
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1593
|
-
throw new (0,
|
|
1594
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1594
1595
|
}
|
|
1595
1596
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1596
|
-
throw new (0,
|
|
1597
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1597
1598
|
}
|
|
1598
1599
|
}
|
|
1599
1600
|
if (opts.sizes) {
|
|
@@ -1602,7 +1603,7 @@ function validateGongmunOptions(opts) {
|
|
|
1602
1603
|
}
|
|
1603
1604
|
}
|
|
1604
1605
|
if (opts.approval && opts.approval.length > 6) {
|
|
1605
|
-
throw new (0,
|
|
1606
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("approval must contain at most 6 labels");
|
|
1606
1607
|
}
|
|
1607
1608
|
}
|
|
1608
1609
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1866,7 +1867,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1866
1867
|
|
|
1867
1868
|
// src/hwpx/table-build.ts
|
|
1868
1869
|
function buildTableWithCellMeta(state) {
|
|
1869
|
-
const table2 =
|
|
1870
|
+
const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, state.rows);
|
|
1870
1871
|
if (state.caption) table2.caption = state.caption;
|
|
1871
1872
|
const anchors = [];
|
|
1872
1873
|
{
|
|
@@ -1936,7 +1937,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1936
1937
|
const cell2 = parentTable.cell;
|
|
1937
1938
|
(cell2.blocks ??= []).push(block);
|
|
1938
1939
|
cell2.hasStructure = true;
|
|
1939
|
-
let flat =
|
|
1940
|
+
let flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1940
1941
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1941
1942
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1942
1943
|
} else {
|
|
@@ -1948,7 +1949,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1948
1949
|
// src/hwpx/section-walker.ts
|
|
1949
1950
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1950
1951
|
const parser = createXmlParser(warnings);
|
|
1951
|
-
const doc = parser.parseFromString(
|
|
1952
|
+
const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1952
1953
|
if (!doc.documentElement) return [];
|
|
1953
1954
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1954
1955
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2053,8 +2054,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2053
2054
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2054
2055
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2055
2056
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2056
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2057
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2057
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunk6XAAYAWLcjs.MAX_COLS);
|
|
2058
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunk6XAAYAWLcjs.MAX_ROWS);
|
|
2058
2059
|
}
|
|
2059
2060
|
break;
|
|
2060
2061
|
case "p": {
|
|
@@ -2252,7 +2253,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2252
2253
|
const sink = [];
|
|
2253
2254
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2254
2255
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2255
|
-
let flat =
|
|
2256
|
+
let flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, st.rows);
|
|
2256
2257
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2257
2258
|
return flat;
|
|
2258
2259
|
}
|
|
@@ -2385,7 +2386,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2385
2386
|
let url = (ch.textContent || "").trim();
|
|
2386
2387
|
if (!url) continue;
|
|
2387
2388
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2388
|
-
const safe =
|
|
2389
|
+
const safe = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, url);
|
|
2389
2390
|
if (safe) return safe;
|
|
2390
2391
|
}
|
|
2391
2392
|
return void 0;
|
|
@@ -2523,7 +2524,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2523
2524
|
case "hyperlink": {
|
|
2524
2525
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2525
2526
|
if (url) {
|
|
2526
|
-
const safe =
|
|
2527
|
+
const safe = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, url);
|
|
2527
2528
|
if (safe) href = safe;
|
|
2528
2529
|
}
|
|
2529
2530
|
walk(child);
|
|
@@ -2714,149 +2715,610 @@ function gongmunDepthFromIndent(para2, left, ctx) {
|
|
|
2714
2715
|
return depth >= 1 && depth < 8 ? depth : null;
|
|
2715
2716
|
}
|
|
2716
2717
|
|
|
2717
|
-
// src/
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2718
|
+
// src/hwp5/record.ts
|
|
2719
|
+
var _zlib = require('zlib');
|
|
2720
|
+
var TAG_PARA_HEADER = 66;
|
|
2721
|
+
var TAG_PARA_TEXT = 67;
|
|
2722
|
+
var TAG_CHAR_SHAPE = 68;
|
|
2723
|
+
var TAG_CTRL_HEADER = 71;
|
|
2724
|
+
var TAG_LIST_HEADER = 72;
|
|
2725
|
+
var TAG_TABLE = 77;
|
|
2726
|
+
var TAG_SHAPE_COMPONENT = 76;
|
|
2727
|
+
var TAG_SHAPE_COMPONENT_PICTURE = 85;
|
|
2728
|
+
var TAG_SHAPE_COMPONENT_CONTAINER = 86;
|
|
2729
|
+
var TAG_EQEDIT = 88;
|
|
2730
|
+
var TAG_BIN_DATA = 18;
|
|
2731
|
+
var TAG_DOC_CHAR_SHAPE = 21;
|
|
2732
|
+
var TAG_NUMBERING = 23;
|
|
2733
|
+
var TAG_BULLET = 24;
|
|
2734
|
+
var TAG_DOC_PARA_SHAPE = 25;
|
|
2735
|
+
var TAG_DOC_STYLE = 26;
|
|
2736
|
+
var CHAR_LINE = 0;
|
|
2737
|
+
var CHAR_SECTION_BREAK = 10;
|
|
2738
|
+
var CHAR_PARA = 13;
|
|
2739
|
+
var CHAR_TAB = 9;
|
|
2740
|
+
var CHAR_HYPHEN = 30;
|
|
2741
|
+
var CHAR_NBSP = 31;
|
|
2742
|
+
var CHAR_FIXED_NBSP = 24;
|
|
2743
|
+
var CHAR_FIXED_WIDTH = 25;
|
|
2744
|
+
var FLAG_COMPRESSED = 1 << 0;
|
|
2745
|
+
var FLAG_ENCRYPTED = 1 << 1;
|
|
2746
|
+
var FLAG_DISTRIBUTION = 1 << 2;
|
|
2747
|
+
var FLAG_DRM = 1 << 4;
|
|
2748
|
+
var MAX_RECORDS = 5e5;
|
|
2749
|
+
function readRecords(data) {
|
|
2750
|
+
const records = [];
|
|
2751
|
+
let offset = 0;
|
|
2752
|
+
while (offset + 4 <= data.length && records.length < MAX_RECORDS) {
|
|
2753
|
+
const header = data.readUInt32LE(offset);
|
|
2754
|
+
offset += 4;
|
|
2755
|
+
const tagId = header & 1023;
|
|
2756
|
+
const level = header >> 10 & 1023;
|
|
2757
|
+
let size = header >> 20 & 4095;
|
|
2758
|
+
if (size === 4095) {
|
|
2759
|
+
if (offset + 4 > data.length) break;
|
|
2760
|
+
size = data.readUInt32LE(offset);
|
|
2761
|
+
offset += 4;
|
|
2762
|
+
}
|
|
2763
|
+
if (offset + size > data.length) break;
|
|
2764
|
+
records.push({ tagId, level, size, data: data.subarray(offset, offset + size) });
|
|
2765
|
+
offset += size;
|
|
2740
2766
|
}
|
|
2767
|
+
return records;
|
|
2741
2768
|
}
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
if (
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
if (mime.includes("emf")) return "emf";
|
|
2750
|
-
if (mime.includes("svg")) return "svg";
|
|
2751
|
-
return "bin";
|
|
2752
|
-
}
|
|
2753
|
-
function collectImageBlocks(blocks, out, ownerCell, depth = 0) {
|
|
2754
|
-
if (depth > MAX_XML_DEPTH) return;
|
|
2755
|
-
for (const block of blocks) {
|
|
2756
|
-
if (block.type === "image") {
|
|
2757
|
-
out.push({ block, ownerCell });
|
|
2758
|
-
} else if (block.type === "table" && block.table) {
|
|
2759
|
-
for (const row of block.table.cells) {
|
|
2760
|
-
for (const cell2 of row) {
|
|
2761
|
-
if (_optionalChain([cell2, 'access', _65 => _65.blocks, 'optionalAccess', _66 => _66.length])) collectImageBlocks(cell2.blocks, out, cell2, depth + 1);
|
|
2762
|
-
}
|
|
2763
|
-
}
|
|
2769
|
+
var MAX_DECOMPRESS_SIZE2 = 100 * 1024 * 1024;
|
|
2770
|
+
function decompressStream(data) {
|
|
2771
|
+
const opts = { maxOutputLength: MAX_DECOMPRESS_SIZE2 };
|
|
2772
|
+
if (data.length >= 2 && data[0] === 120) {
|
|
2773
|
+
try {
|
|
2774
|
+
return _zlib.inflateSync.call(void 0, data, opts);
|
|
2775
|
+
} catch (e13) {
|
|
2764
2776
|
}
|
|
2765
2777
|
}
|
|
2778
|
+
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2766
2779
|
}
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2780
|
+
function parseFileHeader(data) {
|
|
2781
|
+
if (data.length < 40) throw new (0, _chunk6XAAYAWLcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2782
|
+
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2783
|
+
return {
|
|
2784
|
+
signature: sig,
|
|
2785
|
+
versionMajor: data[35],
|
|
2786
|
+
flags: data.readUInt32LE(36)
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
function readHwpString(data, offset) {
|
|
2790
|
+
if (offset + 2 > data.length) return { value: "", next: data.length };
|
|
2791
|
+
const len = data.readUInt16LE(offset);
|
|
2792
|
+
const start = offset + 2;
|
|
2793
|
+
const end = start + len * 2;
|
|
2794
|
+
if (len === 0 || end > data.length) return { value: "", next: start };
|
|
2795
|
+
return { value: data.subarray(start, end).toString("utf16le"), next: end };
|
|
2796
|
+
}
|
|
2797
|
+
function parseDocInfo(records) {
|
|
2798
|
+
const charShapes = [];
|
|
2799
|
+
const paraShapes = [];
|
|
2800
|
+
const styles = [];
|
|
2801
|
+
const binData = [];
|
|
2802
|
+
const numberings = [];
|
|
2803
|
+
const bullets = [];
|
|
2804
|
+
for (const rec of records) {
|
|
2805
|
+
if (rec.tagId === TAG_DOC_PARA_SHAPE && rec.data.length >= 4) {
|
|
2806
|
+
const attr1 = rec.data.readUInt32LE(0);
|
|
2807
|
+
const headType = attr1 >>> 23 & 3;
|
|
2808
|
+
const paraLevel = attr1 >>> 25 & 7;
|
|
2809
|
+
const numberingId = rec.data.length >= 32 ? rec.data.readUInt16LE(30) : 0;
|
|
2810
|
+
paraShapes.push({ headType, paraLevel, numberingId });
|
|
2811
|
+
}
|
|
2812
|
+
if (rec.tagId === TAG_BIN_DATA && rec.data.length >= 2) {
|
|
2813
|
+
const attr = rec.data.readUInt16LE(0);
|
|
2814
|
+
const typeBits = attr & 15;
|
|
2815
|
+
if (typeBits === 0) {
|
|
2816
|
+
binData.push({ kind: "link", storageId: 0, extension: "" });
|
|
2817
|
+
} else {
|
|
2818
|
+
const storageId = rec.data.length >= 4 ? rec.data.readUInt16LE(2) : 0;
|
|
2819
|
+
const { value: extension } = readHwpString(rec.data, 4);
|
|
2820
|
+
binData.push({ kind: typeBits === 2 ? "storage" : "embed", storageId, extension });
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
if (rec.tagId === TAG_NUMBERING && rec.data.length >= 14) {
|
|
2824
|
+
const levelFormats = [];
|
|
2825
|
+
const numberFormats = [];
|
|
2826
|
+
const startNumbers = [1, 1, 1, 1, 1, 1, 1];
|
|
2827
|
+
let offset = 0;
|
|
2828
|
+
for (let level = 0; level < 7; level++) {
|
|
2829
|
+
if (offset + 12 > rec.data.length) {
|
|
2830
|
+
levelFormats.push("");
|
|
2831
|
+
numberFormats.push(0);
|
|
2832
|
+
continue;
|
|
2794
2833
|
}
|
|
2834
|
+
const attr = rec.data.readUInt32LE(offset);
|
|
2835
|
+
numberFormats.push(attr >>> 5 & 15);
|
|
2836
|
+
offset += 12;
|
|
2837
|
+
const { value, next } = readHwpString(rec.data, offset);
|
|
2838
|
+
levelFormats.push(value);
|
|
2839
|
+
offset = next;
|
|
2795
2840
|
}
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
imageIndex++;
|
|
2808
|
-
const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
|
|
2809
|
-
img = { filename, data, mimeType };
|
|
2810
|
-
images.push(img);
|
|
2811
|
-
break;
|
|
2812
|
-
} catch (err) {
|
|
2813
|
-
if (err instanceof _chunkU25XGCNHcjs.KordocError) throw err;
|
|
2841
|
+
let baseStart = 1;
|
|
2842
|
+
if (offset + 2 <= rec.data.length) {
|
|
2843
|
+
baseStart = rec.data.readUInt16LE(offset) || 1;
|
|
2844
|
+
offset += 2;
|
|
2845
|
+
}
|
|
2846
|
+
for (let level = 0; level < 7; level++) {
|
|
2847
|
+
if (offset + 4 <= rec.data.length) {
|
|
2848
|
+
startNumbers[level] = rec.data.readUInt32LE(offset) || 1;
|
|
2849
|
+
offset += 4;
|
|
2850
|
+
} else {
|
|
2851
|
+
startNumbers[level] = baseStart;
|
|
2814
2852
|
}
|
|
2815
2853
|
}
|
|
2816
|
-
|
|
2817
|
-
resolved.set(ref, img);
|
|
2818
|
-
}
|
|
2819
|
-
if (!img) {
|
|
2820
|
-
block.type = "paragraph";
|
|
2821
|
-
block.text = `[\uC774\uBBF8\uC9C0: ${ref}]`;
|
|
2822
|
-
if (ownerCell) ownerCell.text = ownerCell.text.replace(``, `[\uC774\uBBF8\uC9C0: ${ref}]`);
|
|
2823
|
-
continue;
|
|
2854
|
+
numberings.push({ levelFormats, numberFormats, startNumbers });
|
|
2824
2855
|
}
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
}
|
|
2829
|
-
return images;
|
|
2830
|
-
}
|
|
2831
|
-
|
|
2832
|
-
// src/hwpx/metadata.ts
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
// src/hwpx/zip-sections.ts
|
|
2836
|
-
var _zlib = require('zlib');
|
|
2837
|
-
function extractFromBrokenZip(buffer) {
|
|
2838
|
-
const data = new Uint8Array(buffer);
|
|
2839
|
-
const view = new DataView(buffer);
|
|
2840
|
-
let pos = 0;
|
|
2841
|
-
const blocks = [];
|
|
2842
|
-
const warnings = [
|
|
2843
|
-
{ code: "BROKEN_ZIP_RECOVERY", message: "\uC190\uC0C1\uB41C ZIP \uAD6C\uC870 \u2014 Local File Header \uAE30\uBC18 \uBCF5\uAD6C \uBAA8\uB4DC" }
|
|
2844
|
-
];
|
|
2845
|
-
let totalDecompressed = 0;
|
|
2846
|
-
let entryCount = 0;
|
|
2847
|
-
let sectionNum = 0;
|
|
2848
|
-
const shared = createSectionShared();
|
|
2849
|
-
while (pos < data.length - 30) {
|
|
2850
|
-
if (data[pos] !== 80 || data[pos + 1] !== 75 || data[pos + 2] !== 3 || data[pos + 3] !== 4) {
|
|
2851
|
-
pos++;
|
|
2852
|
-
while (pos < data.length - 30) {
|
|
2853
|
-
if (data[pos] === 80 && data[pos + 1] === 75 && data[pos + 2] === 3 && data[pos + 3] === 4) break;
|
|
2854
|
-
pos++;
|
|
2855
|
-
}
|
|
2856
|
-
continue;
|
|
2856
|
+
if (rec.tagId === TAG_BULLET && rec.data.length >= 14) {
|
|
2857
|
+
const code = rec.data.readUInt16LE(12);
|
|
2858
|
+
bullets.push({ char: code > 0 ? String.fromCharCode(code) : "\u2022" });
|
|
2857
2859
|
}
|
|
2858
|
-
if (
|
|
2859
|
-
|
|
2860
|
+
if (rec.tagId === TAG_DOC_CHAR_SHAPE && rec.data.length >= 18) {
|
|
2861
|
+
if (rec.data.length >= 50) {
|
|
2862
|
+
const fontSize = rec.data.readUInt32LE(42);
|
|
2863
|
+
const attrFlags = rec.data.readUInt32LE(46);
|
|
2864
|
+
charShapes.push({ fontSize, attrFlags });
|
|
2865
|
+
} else {
|
|
2866
|
+
charShapes.push({ fontSize: 0, attrFlags: 0 });
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
if (rec.tagId === TAG_DOC_STYLE && rec.data.length >= 8) {
|
|
2870
|
+
try {
|
|
2871
|
+
let offset = 0;
|
|
2872
|
+
const nameLen = rec.data.readUInt16LE(offset);
|
|
2873
|
+
offset += 2;
|
|
2874
|
+
const nameBytes = nameLen * 2;
|
|
2875
|
+
const name = nameBytes > 0 && offset + nameBytes <= rec.data.length ? rec.data.subarray(offset, offset + nameBytes).toString("utf16le") : "";
|
|
2876
|
+
offset += nameBytes;
|
|
2877
|
+
let nameKo = "";
|
|
2878
|
+
if (offset + 2 <= rec.data.length) {
|
|
2879
|
+
const nameKoLen = rec.data.readUInt16LE(offset);
|
|
2880
|
+
offset += 2;
|
|
2881
|
+
const nameKoBytes = nameKoLen * 2;
|
|
2882
|
+
if (nameKoBytes > 0 && offset + nameKoBytes <= rec.data.length) {
|
|
2883
|
+
nameKo = rec.data.subarray(offset, offset + nameKoBytes).toString("utf16le");
|
|
2884
|
+
}
|
|
2885
|
+
offset += nameKoBytes;
|
|
2886
|
+
}
|
|
2887
|
+
const type = offset < rec.data.length ? rec.data.readUInt8(offset) : 0;
|
|
2888
|
+
offset += 1;
|
|
2889
|
+
offset += 1;
|
|
2890
|
+
offset += 2;
|
|
2891
|
+
const paraShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
|
|
2892
|
+
offset += 2;
|
|
2893
|
+
const charShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
|
|
2894
|
+
styles.push({ name, nameKo, charShapeId, paraShapeId, type });
|
|
2895
|
+
} catch (e14) {
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
return { charShapes, paraShapes, styles, binData, numberings, bullets };
|
|
2900
|
+
}
|
|
2901
|
+
function createParaTextState() {
|
|
2902
|
+
return { text: "", ctrlIdx: 0, fieldStack: [], fieldRanges: [] };
|
|
2903
|
+
}
|
|
2904
|
+
function isExtendedOnlyCtrlChar(ch) {
|
|
2905
|
+
return ch >= 1 && ch <= 3 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 18 || ch >= 21 && ch <= 23;
|
|
2906
|
+
}
|
|
2907
|
+
function appendParaText(state, data, resolveControl) {
|
|
2908
|
+
let result = "";
|
|
2909
|
+
let i = 0;
|
|
2910
|
+
const base = state.text.length;
|
|
2911
|
+
const resolveAt = (byteOffset, extended) => {
|
|
2912
|
+
const ctrlId = data.readUInt32LE(byteOffset);
|
|
2913
|
+
const idx = extended ? state.ctrlIdx : -1;
|
|
2914
|
+
const replacement = _optionalChain([resolveControl, 'optionalCall', _65 => _65(idx, ctrlId)]);
|
|
2915
|
+
if (replacement) result += replacement;
|
|
2916
|
+
if (extended) state.ctrlIdx++;
|
|
2917
|
+
};
|
|
2918
|
+
while (i + 1 < data.length) {
|
|
2919
|
+
const ch = data.readUInt16LE(i);
|
|
2920
|
+
i += 2;
|
|
2921
|
+
switch (ch) {
|
|
2922
|
+
// ── char 타입 (2바이트만, 확장 데이터 없음) ──
|
|
2923
|
+
case CHAR_LINE:
|
|
2924
|
+
result += "\n";
|
|
2925
|
+
break;
|
|
2926
|
+
case CHAR_SECTION_BREAK: {
|
|
2927
|
+
if (i + 16 <= data.length && data.readUInt16LE(i) === 11) {
|
|
2928
|
+
resolveAt(i + 2, true);
|
|
2929
|
+
i += 16;
|
|
2930
|
+
break;
|
|
2931
|
+
}
|
|
2932
|
+
result += "\n";
|
|
2933
|
+
break;
|
|
2934
|
+
}
|
|
2935
|
+
case CHAR_PARA:
|
|
2936
|
+
break;
|
|
2937
|
+
// 문단 끝
|
|
2938
|
+
case CHAR_HYPHEN:
|
|
2939
|
+
result += "-";
|
|
2940
|
+
break;
|
|
2941
|
+
case CHAR_NBSP:
|
|
2942
|
+
result += " ";
|
|
2943
|
+
break;
|
|
2944
|
+
case CHAR_FIXED_NBSP:
|
|
2945
|
+
result += "\xA0";
|
|
2946
|
+
break;
|
|
2947
|
+
// 진짜 NBSP
|
|
2948
|
+
case CHAR_FIXED_WIDTH:
|
|
2949
|
+
result += " ";
|
|
2950
|
+
break;
|
|
2951
|
+
// 고정폭 공백
|
|
2952
|
+
// ── inline 타입 (2바이트 + 14바이트 확장) ──
|
|
2953
|
+
case CHAR_TAB:
|
|
2954
|
+
result += " ";
|
|
2955
|
+
if (i + 14 <= data.length) i += 14;
|
|
2956
|
+
break;
|
|
2957
|
+
default:
|
|
2958
|
+
if (ch >= 1 && ch <= 31) {
|
|
2959
|
+
const isExtended = isExtendedOnlyCtrlChar(ch);
|
|
2960
|
+
const isInline = ch >= 4 && ch <= 9 || ch >= 19 && ch <= 20;
|
|
2961
|
+
if ((isExtended || isInline) && i + 14 <= data.length) {
|
|
2962
|
+
if (ch === 3) {
|
|
2963
|
+
state.fieldStack.push({ start: base + result.length, ctrlIdx: state.ctrlIdx });
|
|
2964
|
+
} else if (ch === 4) {
|
|
2965
|
+
const open = state.fieldStack.pop();
|
|
2966
|
+
if (open) {
|
|
2967
|
+
state.fieldRanges.push({ start: open.start, end: base + result.length, ctrlIdx: open.ctrlIdx });
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
resolveAt(i, isExtended);
|
|
2971
|
+
i += 14;
|
|
2972
|
+
}
|
|
2973
|
+
} else if (ch >= 32) {
|
|
2974
|
+
if (ch >= 55296 && ch <= 56319 && i + 1 < data.length) {
|
|
2975
|
+
const lo = data.readUInt16LE(i);
|
|
2976
|
+
if (lo >= 56320 && lo <= 57343) {
|
|
2977
|
+
i += 2;
|
|
2978
|
+
const codePoint = (ch - 55296 << 10) + (lo - 56320) + 65536;
|
|
2979
|
+
result += String.fromCodePoint(codePoint);
|
|
2980
|
+
break;
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
result += String.fromCharCode(ch);
|
|
2984
|
+
}
|
|
2985
|
+
break;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
state.text += result;
|
|
2989
|
+
}
|
|
2990
|
+
function extractEquationText(data) {
|
|
2991
|
+
if (data.length < 6) return null;
|
|
2992
|
+
const scriptLength = data.readUInt16LE(4);
|
|
2993
|
+
const scriptStart = 6;
|
|
2994
|
+
const scriptEnd = scriptStart + scriptLength * 2;
|
|
2995
|
+
if (scriptLength <= 0 || scriptEnd > data.length) return null;
|
|
2996
|
+
const equation = data.subarray(scriptStart, scriptEnd).toString("utf16le").replace(/\0+/g, "").trim();
|
|
2997
|
+
return equation || null;
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
// src/hwp5/images.ts
|
|
3001
|
+
function detectImageMime(data) {
|
|
3002
|
+
if (data.length < 4) return null;
|
|
3003
|
+
if (data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71) return "image/png";
|
|
3004
|
+
if (data[0] === 255 && data[1] === 216 && data[2] === 255) return "image/jpeg";
|
|
3005
|
+
if (data[0] === 71 && data[1] === 73 && data[2] === 70) return "image/gif";
|
|
3006
|
+
if (data[0] === 66 && data[1] === 77) return "image/bmp";
|
|
3007
|
+
if (data[0] === 215 && data[1] === 205 && data[2] === 198 && data[3] === 154) return "image/wmf";
|
|
3008
|
+
if (data[0] === 1 && data[1] === 0 && data[2] === 0 && data[3] === 0) return "image/emf";
|
|
3009
|
+
return null;
|
|
3010
|
+
}
|
|
3011
|
+
function normalizeBinPayload(data) {
|
|
3012
|
+
if (detectImageMime(data)) return data;
|
|
3013
|
+
try {
|
|
3014
|
+
const inflated = decompressStream(data);
|
|
3015
|
+
if (inflated.length > 0) return inflated;
|
|
3016
|
+
} catch (e15) {
|
|
3017
|
+
}
|
|
3018
|
+
return data;
|
|
3019
|
+
}
|
|
3020
|
+
var BIN_ENTRY_RE = /(?:^|\/)BIN([0-9A-Fa-f]{4,8})(?:\.[^./\\]*)?$/;
|
|
3021
|
+
function collectImageBlocks(blocks, out) {
|
|
3022
|
+
for (const b of blocks) {
|
|
3023
|
+
if (b.type === "image") out.push(b);
|
|
3024
|
+
if (b.table) {
|
|
3025
|
+
for (const row of b.table.cells) {
|
|
3026
|
+
for (const cell2 of row) {
|
|
3027
|
+
if (cell2.blocks) collectImageBlocks(cell2.blocks, out);
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
if (b.children) collectImageBlocks(b.children, out);
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
function forEachTableCell(blocks, fn) {
|
|
3035
|
+
for (const b of blocks) {
|
|
3036
|
+
if (b.table) {
|
|
3037
|
+
for (const row of b.table.cells) {
|
|
3038
|
+
for (const cell2 of row) {
|
|
3039
|
+
fn(cell2);
|
|
3040
|
+
if (cell2.blocks) forEachTableCell(cell2.blocks, fn);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
if (b.children) forEachTableCell(b.children, fn);
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
var CELL_IMAGE_SENTINEL_RE = /!\[image\]\(hwp5bin:(\d+)\)/g;
|
|
3048
|
+
function resolveCellImageSentinels(blocks, renamed) {
|
|
3049
|
+
forEachTableCell(blocks, (cell2) => {
|
|
3050
|
+
if (!cell2.text.includes("hwp5bin:")) return;
|
|
3051
|
+
cell2.text = cell2.text.replace(CELL_IMAGE_SENTINEL_RE, (_m, idStr) => {
|
|
3052
|
+
const filename = renamed.get(Number(idStr));
|
|
3053
|
+
return filename ? `` : "[\uC774\uBBF8\uC9C0]";
|
|
3054
|
+
});
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
function resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced) {
|
|
3058
|
+
const imageBlocks = [];
|
|
3059
|
+
collectImageBlocks(blocks, imageBlocks);
|
|
3060
|
+
const images = [];
|
|
3061
|
+
const renamed = /* @__PURE__ */ new Map();
|
|
3062
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
3063
|
+
let imageIndex = 0;
|
|
3064
|
+
for (const block of imageBlocks) {
|
|
3065
|
+
if (!block.text) continue;
|
|
3066
|
+
const storageId = parseInt(block.text, 10);
|
|
3067
|
+
if (isNaN(storageId)) continue;
|
|
3068
|
+
let img = resolved.get(storageId);
|
|
3069
|
+
if (img === void 0) {
|
|
3070
|
+
const bin = binDataMap.get(storageId);
|
|
3071
|
+
if (!bin) {
|
|
3072
|
+
warnings.push({ page: block.pageNumber, message: `BinData ${storageId} \uC5C6\uC74C`, code: "SKIPPED_IMAGE" });
|
|
3073
|
+
resolved.set(storageId, null);
|
|
3074
|
+
} else {
|
|
3075
|
+
const mime = detectImageMime(bin.data);
|
|
3076
|
+
if (!mime) {
|
|
3077
|
+
warnings.push({ page: block.pageNumber, message: `BinData ${storageId}: \uC54C \uC218 \uC5C6\uB294 \uC774\uBBF8\uC9C0 \uD615\uC2DD`, code: "SKIPPED_IMAGE" });
|
|
3078
|
+
resolved.set(storageId, null);
|
|
3079
|
+
} else {
|
|
3080
|
+
imageIndex++;
|
|
3081
|
+
const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
|
|
3082
|
+
img = { filename: `image_${String(imageIndex).padStart(3, "0")}.${ext}`, data: new Uint8Array(bin.data), mime };
|
|
3083
|
+
resolved.set(storageId, img);
|
|
3084
|
+
images.push({ filename: img.filename, data: img.data, mimeType: img.mime });
|
|
3085
|
+
renamed.set(storageId, img.filename);
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
img = resolved.get(storageId);
|
|
3089
|
+
}
|
|
3090
|
+
if (!img) {
|
|
3091
|
+
const bin = binDataMap.get(storageId);
|
|
3092
|
+
block.type = "paragraph";
|
|
3093
|
+
block.text = bin ? `[\uC774\uBBF8\uC9C0: ${bin.name}]` : `[\uC774\uBBF8\uC9C0: BinData ${storageId}]`;
|
|
3094
|
+
continue;
|
|
3095
|
+
}
|
|
3096
|
+
block.text = img.filename;
|
|
3097
|
+
block.imageData = { data: img.data, mimeType: img.mime, filename: binDataMap.get(storageId).name };
|
|
3098
|
+
}
|
|
3099
|
+
if (sweepUnreferenced) {
|
|
3100
|
+
for (const [storageId, bin] of [...binDataMap.entries()].sort((a, b) => a[0] - b[0])) {
|
|
3101
|
+
if (resolved.has(storageId)) continue;
|
|
3102
|
+
const mime = detectImageMime(bin.data);
|
|
3103
|
+
if (!mime) continue;
|
|
3104
|
+
imageIndex++;
|
|
3105
|
+
const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
|
|
3106
|
+
const filename = `image_${String(imageIndex).padStart(3, "0")}.${ext}`;
|
|
3107
|
+
const data = new Uint8Array(bin.data);
|
|
3108
|
+
images.push({ filename, data, mimeType: mime });
|
|
3109
|
+
blocks.push({ type: "image", text: filename, imageData: { data, mimeType: mime, filename: bin.name } });
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
resolveCellImageSentinels(blocks, renamed);
|
|
3113
|
+
return images;
|
|
3114
|
+
}
|
|
3115
|
+
function extractHwp5Images(fileIndex, blocks, warnings, sweepUnreferenced) {
|
|
3116
|
+
const binDataMap = /* @__PURE__ */ new Map();
|
|
3117
|
+
if (fileIndex) {
|
|
3118
|
+
for (const entry of fileIndex) {
|
|
3119
|
+
if (!_optionalChain([entry, 'optionalAccess', _66 => _66.name]) || !entry.content) continue;
|
|
3120
|
+
const match = entry.name.match(BIN_ENTRY_RE);
|
|
3121
|
+
if (!match) continue;
|
|
3122
|
+
const idx = parseInt(match[1], 16);
|
|
3123
|
+
const data = normalizeBinPayload(Buffer.from(entry.content));
|
|
3124
|
+
binDataMap.set(idx, { data, name: entry.name });
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
if (binDataMap.size === 0) {
|
|
3128
|
+
resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
|
|
3129
|
+
return [];
|
|
3130
|
+
}
|
|
3131
|
+
return resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced);
|
|
3132
|
+
}
|
|
3133
|
+
function extractHwp5ImagesLenient(lcfb, blocks, warnings, sweepUnreferenced) {
|
|
3134
|
+
const binDataMap = /* @__PURE__ */ new Map();
|
|
3135
|
+
const binRe = /^BIN([0-9A-Fa-f]{4,8})(?:\.|$)/;
|
|
3136
|
+
for (const e of lcfb.entries()) {
|
|
3137
|
+
const match = e.name.match(binRe);
|
|
3138
|
+
if (!match) continue;
|
|
3139
|
+
const idx = parseInt(match[1], 16);
|
|
3140
|
+
const raw = lcfb.findStream(e.name);
|
|
3141
|
+
if (!raw) continue;
|
|
3142
|
+
binDataMap.set(idx, { data: normalizeBinPayload(raw), name: e.name });
|
|
3143
|
+
}
|
|
3144
|
+
if (binDataMap.size === 0) {
|
|
3145
|
+
resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
|
|
3146
|
+
return [];
|
|
3147
|
+
}
|
|
3148
|
+
return resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced);
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
// src/hwpx/images.ts
|
|
3152
|
+
function imageExtToMime(ext) {
|
|
3153
|
+
switch (ext.toLowerCase()) {
|
|
3154
|
+
case "jpg":
|
|
3155
|
+
case "jpeg":
|
|
3156
|
+
return "image/jpeg";
|
|
3157
|
+
case "png":
|
|
3158
|
+
return "image/png";
|
|
3159
|
+
case "gif":
|
|
3160
|
+
return "image/gif";
|
|
3161
|
+
case "bmp":
|
|
3162
|
+
return "image/bmp";
|
|
3163
|
+
case "tif":
|
|
3164
|
+
case "tiff":
|
|
3165
|
+
return "image/tiff";
|
|
3166
|
+
case "wmf":
|
|
3167
|
+
return "image/wmf";
|
|
3168
|
+
case "emf":
|
|
3169
|
+
return "image/emf";
|
|
3170
|
+
case "svg":
|
|
3171
|
+
return "image/svg+xml";
|
|
3172
|
+
default:
|
|
3173
|
+
return "application/octet-stream";
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
function mimeToExt(mime) {
|
|
3177
|
+
if (mime.includes("jpeg")) return "jpg";
|
|
3178
|
+
if (mime.includes("png")) return "png";
|
|
3179
|
+
if (mime.includes("gif")) return "gif";
|
|
3180
|
+
if (mime.includes("bmp")) return "bmp";
|
|
3181
|
+
if (mime.includes("tiff")) return "tif";
|
|
3182
|
+
if (mime.includes("wmf")) return "wmf";
|
|
3183
|
+
if (mime.includes("emf")) return "emf";
|
|
3184
|
+
if (mime.includes("svg")) return "svg";
|
|
3185
|
+
return "bin";
|
|
3186
|
+
}
|
|
3187
|
+
function collectImageBlocks2(blocks, out, ownerCell, depth = 0) {
|
|
3188
|
+
if (depth > MAX_XML_DEPTH) return;
|
|
3189
|
+
for (const block of blocks) {
|
|
3190
|
+
if (block.type === "image") {
|
|
3191
|
+
out.push({ block, ownerCell });
|
|
3192
|
+
} else if (block.type === "table" && block.table) {
|
|
3193
|
+
for (const row of block.table.cells) {
|
|
3194
|
+
for (const cell2 of row) {
|
|
3195
|
+
if (_optionalChain([cell2, 'access', _67 => _67.blocks, 'optionalAccess', _68 => _68.length])) collectImageBlocks2(cell2.blocks, out, cell2, depth + 1);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUnreferenced) {
|
|
3202
|
+
const images = [];
|
|
3203
|
+
let imageIndex = 0;
|
|
3204
|
+
const usedPaths = /* @__PURE__ */ new Set();
|
|
3205
|
+
const imageBlocks = [];
|
|
3206
|
+
collectImageBlocks2(blocks, imageBlocks);
|
|
3207
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
3208
|
+
for (const { block, ownerCell } of imageBlocks) {
|
|
3209
|
+
if (block.type !== "image" || !block.text) continue;
|
|
3210
|
+
const ref = block.text;
|
|
3211
|
+
let img = resolved.get(ref);
|
|
3212
|
+
if (img === void 0) {
|
|
3213
|
+
img = null;
|
|
3214
|
+
const candidates = [
|
|
3215
|
+
`BinData/${ref}`,
|
|
3216
|
+
`Contents/BinData/${ref}`,
|
|
3217
|
+
ref
|
|
3218
|
+
// 절대 경로일 수도 있음
|
|
3219
|
+
];
|
|
3220
|
+
let resolvedPath = null;
|
|
3221
|
+
if (!ref.includes(".")) {
|
|
3222
|
+
const prefixes = [`BinData/${ref}`, `Contents/BinData/${ref}`];
|
|
3223
|
+
for (const prefix of prefixes) {
|
|
3224
|
+
const match = zip.file(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.[a-zA-Z0-9]+$`));
|
|
3225
|
+
if (match.length > 0) {
|
|
3226
|
+
resolvedPath = match[0].name;
|
|
3227
|
+
break;
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3232
|
+
for (const path of allCandidates) {
|
|
3233
|
+
if (_chunk6XAAYAWLcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3234
|
+
const file = zip.file(path);
|
|
3235
|
+
if (!file) continue;
|
|
3236
|
+
try {
|
|
3237
|
+
const data = await file.async("uint8array");
|
|
3238
|
+
decompressed.total += data.length;
|
|
3239
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3240
|
+
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3241
|
+
const mimeType = imageExtToMime(ext);
|
|
3242
|
+
imageIndex++;
|
|
3243
|
+
const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
|
|
3244
|
+
img = { filename, data, mimeType };
|
|
3245
|
+
images.push(img);
|
|
3246
|
+
usedPaths.add(path);
|
|
3247
|
+
break;
|
|
3248
|
+
} catch (err) {
|
|
3249
|
+
if (err instanceof _chunk6XAAYAWLcjs.KordocError) throw err;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
if (!img) _optionalChain([warnings, 'optionalAccess', _69 => _69.push, 'call', _70 => _70({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
3253
|
+
resolved.set(ref, img);
|
|
3254
|
+
}
|
|
3255
|
+
if (!img) {
|
|
3256
|
+
block.type = "paragraph";
|
|
3257
|
+
block.text = `[\uC774\uBBF8\uC9C0: ${ref}]`;
|
|
3258
|
+
if (ownerCell) ownerCell.text = ownerCell.text.replace(``, `[\uC774\uBBF8\uC9C0: ${ref}]`);
|
|
3259
|
+
continue;
|
|
3260
|
+
}
|
|
3261
|
+
block.text = img.filename;
|
|
3262
|
+
block.imageData = { data: img.data, mimeType: img.mimeType, filename: ref };
|
|
3263
|
+
if (ownerCell) ownerCell.text = ownerCell.text.replace(``, ``);
|
|
3264
|
+
}
|
|
3265
|
+
if (sweepUnreferenced) {
|
|
3266
|
+
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3267
|
+
for (const file of binEntries) {
|
|
3268
|
+
if (file.dir || usedPaths.has(file.name) || _chunk6XAAYAWLcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3269
|
+
try {
|
|
3270
|
+
const data = await file.async("uint8array");
|
|
3271
|
+
decompressed.total += data.length;
|
|
3272
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3273
|
+
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3274
|
+
let mimeType = imageExtToMime(ext);
|
|
3275
|
+
if (mimeType === "application/octet-stream") {
|
|
3276
|
+
const sniffed = detectImageMime(data);
|
|
3277
|
+
if (!sniffed) continue;
|
|
3278
|
+
mimeType = sniffed;
|
|
3279
|
+
}
|
|
3280
|
+
imageIndex++;
|
|
3281
|
+
const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
|
|
3282
|
+
const img = { filename, data, mimeType };
|
|
3283
|
+
images.push(img);
|
|
3284
|
+
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3285
|
+
} catch (err) {
|
|
3286
|
+
if (err instanceof _chunk6XAAYAWLcjs.KordocError) throw err;
|
|
3287
|
+
_optionalChain([warnings, 'optionalAccess', _71 => _71.push, 'call', _72 => _72({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
return images;
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
// src/hwpx/metadata.ts
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
// src/hwpx/zip-sections.ts
|
|
3298
|
+
|
|
3299
|
+
function extractFromBrokenZip(buffer) {
|
|
3300
|
+
const data = new Uint8Array(buffer);
|
|
3301
|
+
const view = new DataView(buffer);
|
|
3302
|
+
let pos = 0;
|
|
3303
|
+
const blocks = [];
|
|
3304
|
+
const warnings = [
|
|
3305
|
+
{ code: "BROKEN_ZIP_RECOVERY", message: "\uC190\uC0C1\uB41C ZIP \uAD6C\uC870 \u2014 Local File Header \uAE30\uBC18 \uBCF5\uAD6C \uBAA8\uB4DC" }
|
|
3306
|
+
];
|
|
3307
|
+
let totalDecompressed = 0;
|
|
3308
|
+
let entryCount = 0;
|
|
3309
|
+
let sectionNum = 0;
|
|
3310
|
+
const shared = createSectionShared();
|
|
3311
|
+
while (pos < data.length - 30) {
|
|
3312
|
+
if (data[pos] !== 80 || data[pos + 1] !== 75 || data[pos + 2] !== 3 || data[pos + 3] !== 4) {
|
|
3313
|
+
pos++;
|
|
3314
|
+
while (pos < data.length - 30) {
|
|
3315
|
+
if (data[pos] === 80 && data[pos + 1] === 75 && data[pos + 2] === 3 && data[pos + 3] === 4) break;
|
|
3316
|
+
pos++;
|
|
3317
|
+
}
|
|
3318
|
+
continue;
|
|
3319
|
+
}
|
|
3320
|
+
if (++entryCount > MAX_ZIP_ENTRIES) break;
|
|
3321
|
+
const method = view.getUint16(pos + 8, true);
|
|
2860
3322
|
const compSize = view.getUint32(pos + 18, true);
|
|
2861
3323
|
const nameLen = view.getUint16(pos + 26, true);
|
|
2862
3324
|
const extraLen = view.getUint16(pos + 28, true);
|
|
@@ -2872,7 +3334,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
2872
3334
|
}
|
|
2873
3335
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
2874
3336
|
const name = new TextDecoder().decode(nameBytes);
|
|
2875
|
-
if (
|
|
3337
|
+
if (_chunk6XAAYAWLcjs.isPathTraversal.call(void 0, name)) {
|
|
2876
3338
|
pos = fileStart + compSize;
|
|
2877
3339
|
continue;
|
|
2878
3340
|
}
|
|
@@ -2890,16 +3352,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2890
3352
|
continue;
|
|
2891
3353
|
}
|
|
2892
3354
|
totalDecompressed += content.length * 2;
|
|
2893
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3355
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2894
3356
|
sectionNum++;
|
|
2895
3357
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2896
|
-
} catch (
|
|
3358
|
+
} catch (e16) {
|
|
2897
3359
|
continue;
|
|
2898
3360
|
}
|
|
2899
3361
|
}
|
|
2900
|
-
if (blocks.length === 0) throw new (0,
|
|
3362
|
+
if (blocks.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2901
3363
|
applyPageText(blocks, shared);
|
|
2902
|
-
const markdown =
|
|
3364
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2903
3365
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2904
3366
|
}
|
|
2905
3367
|
async function readKordocLayout(zip) {
|
|
@@ -2908,8 +3370,8 @@ async function readKordocLayout(zip) {
|
|
|
2908
3370
|
try {
|
|
2909
3371
|
const xml = await file.async("text");
|
|
2910
3372
|
if (!/<opf:meta\b[^>]*name="generator"[^>]*content="kordoc"/.test(xml)) return null;
|
|
2911
|
-
return _nullishCoalesce(_optionalChain([xml, 'access',
|
|
2912
|
-
} catch (
|
|
3373
|
+
return _nullishCoalesce(_optionalChain([xml, 'access', _73 => _73.match, 'call', _74 => _74(/<opf:meta\b[^>]*name="kordoc-layout"[^>]*content="([^"]*)"/), 'optionalAccess', _75 => _75[1]]), () => ( null));
|
|
3374
|
+
} catch (e17) {
|
|
2913
3375
|
return null;
|
|
2914
3376
|
}
|
|
2915
3377
|
}
|
|
@@ -2924,18 +3386,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2924
3386
|
if (paths.length > 0) return paths;
|
|
2925
3387
|
}
|
|
2926
3388
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2927
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3389
|
+
return sectionFiles.map((f) => f.name).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
|
|
2928
3390
|
}
|
|
2929
3391
|
function parseSectionPathsFromManifest(xml) {
|
|
2930
3392
|
const parser = createXmlParser();
|
|
2931
|
-
const doc = parser.parseFromString(
|
|
3393
|
+
const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2932
3394
|
const items = doc.getElementsByTagName("opf:item");
|
|
2933
3395
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2934
3396
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2935
3397
|
for (let i = 0; i < items.length; i++) {
|
|
2936
3398
|
const item = items[i];
|
|
2937
3399
|
const id = item.getAttribute("id") || "";
|
|
2938
|
-
const href =
|
|
3400
|
+
const href = _chunk6XAAYAWLcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2939
3401
|
if (id && href) idToHref.set(id, href);
|
|
2940
3402
|
}
|
|
2941
3403
|
if (spine.length > 0) {
|
|
@@ -2946,7 +3408,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2946
3408
|
}
|
|
2947
3409
|
if (ordered.length > 0) return ordered;
|
|
2948
3410
|
}
|
|
2949
|
-
return Array.from(idToHref.values()).sort(
|
|
3411
|
+
return Array.from(idToHref.values()).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
|
|
2950
3412
|
}
|
|
2951
3413
|
|
|
2952
3414
|
// src/hwpx/metadata.ts
|
|
@@ -2959,23 +3421,23 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2959
3421
|
const xml = await file.async("text");
|
|
2960
3422
|
if (decompressed) {
|
|
2961
3423
|
decompressed.total += xml.length * 2;
|
|
2962
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3424
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2963
3425
|
}
|
|
2964
3426
|
parseDublinCoreMetadata(xml, metadata);
|
|
2965
3427
|
if (metadata.title || metadata.author) return;
|
|
2966
3428
|
}
|
|
2967
|
-
} catch (
|
|
3429
|
+
} catch (e18) {
|
|
2968
3430
|
}
|
|
2969
3431
|
}
|
|
2970
3432
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2971
3433
|
const parser = createXmlParser();
|
|
2972
|
-
const doc = parser.parseFromString(
|
|
3434
|
+
const doc = parser.parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2973
3435
|
if (!doc.documentElement) return;
|
|
2974
3436
|
const getText = (tagNames) => {
|
|
2975
3437
|
for (const tag of tagNames) {
|
|
2976
3438
|
const els = doc.getElementsByTagName(tag);
|
|
2977
3439
|
if (els.length > 0) {
|
|
2978
|
-
const text = _optionalChain([els, 'access',
|
|
3440
|
+
const text = _optionalChain([els, 'access', _76 => _76[0], 'access', _77 => _77.textContent, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]);
|
|
2979
3441
|
if (text) return text;
|
|
2980
3442
|
}
|
|
2981
3443
|
}
|
|
@@ -2994,348 +3456,66 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2994
3456
|
|
|
2995
3457
|
// src/hwpx/parser.ts
|
|
2996
3458
|
async function parseHwpxDocument(buffer, options) {
|
|
2997
|
-
|
|
3459
|
+
_chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2998
3460
|
let zip;
|
|
2999
3461
|
try {
|
|
3000
3462
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
3001
|
-
} catch (
|
|
3463
|
+
} catch (e19) {
|
|
3002
3464
|
return extractFromBrokenZip(buffer);
|
|
3003
3465
|
}
|
|
3004
3466
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3005
3467
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3006
|
-
throw new (0,
|
|
3468
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3007
3469
|
}
|
|
3008
3470
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3009
3471
|
if (manifestFile) {
|
|
3010
3472
|
const manifestXml = await manifestFile.async("text");
|
|
3011
|
-
if (isEncryptedHwpx(manifestXml)) {
|
|
3012
|
-
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
3013
|
-
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3014
|
-
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3015
|
-
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
throw new (0, _chunkU25XGCNHcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
const decompressed = { total: 0 };
|
|
3022
|
-
const metadata = {};
|
|
3023
|
-
await extractHwpxMetadata(zip, metadata, decompressed);
|
|
3024
|
-
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3025
|
-
const warnings = [];
|
|
3026
|
-
const sectionPaths = await resolveSectionPaths(zip);
|
|
3027
|
-
if (sectionPaths.length === 0) throw new (0, _chunkU25XGCNHcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3028
|
-
metadata.pageCount = sectionPaths.length;
|
|
3029
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _77 => _77.pages]) ? _chunkX34YWRL5cjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3030
|
-
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3031
|
-
const blocks = [];
|
|
3032
|
-
const shared = createSectionShared();
|
|
3033
|
-
shared.kordocLayout = await readKordocLayout(zip);
|
|
3034
|
-
let parsedSections = 0;
|
|
3035
|
-
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3036
|
-
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
3037
|
-
const file = zip.file(sectionPaths[si]);
|
|
3038
|
-
if (!file) continue;
|
|
3039
|
-
try {
|
|
3040
|
-
const xml = await file.async("text");
|
|
3041
|
-
decompressed.total += xml.length * 2;
|
|
3042
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkU25XGCNHcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3043
|
-
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3044
|
-
parsedSections++;
|
|
3045
|
-
_optionalChain([options, 'optionalAccess', _78 => _78.onProgress, 'optionalCall', _79 => _79(parsedSections, totalTarget)]);
|
|
3046
|
-
} catch (secErr) {
|
|
3047
|
-
if (secErr instanceof _chunkU25XGCNHcjs.KordocError) throw secErr;
|
|
3048
|
-
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" });
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
|
-
applyPageText(blocks, shared);
|
|
3052
|
-
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
3053
|
-
detectHwpxHeadings(blocks, styleMap);
|
|
3054
|
-
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3055
|
-
const markdown = _chunkU25XGCNHcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3056
|
-
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 };
|
|
3057
|
-
}
|
|
3058
|
-
|
|
3059
|
-
// src/hwp5/record.ts
|
|
3060
|
-
|
|
3061
|
-
var TAG_PARA_HEADER = 66;
|
|
3062
|
-
var TAG_PARA_TEXT = 67;
|
|
3063
|
-
var TAG_CHAR_SHAPE = 68;
|
|
3064
|
-
var TAG_CTRL_HEADER = 71;
|
|
3065
|
-
var TAG_LIST_HEADER = 72;
|
|
3066
|
-
var TAG_TABLE = 77;
|
|
3067
|
-
var TAG_SHAPE_COMPONENT = 76;
|
|
3068
|
-
var TAG_SHAPE_COMPONENT_PICTURE = 85;
|
|
3069
|
-
var TAG_SHAPE_COMPONENT_CONTAINER = 86;
|
|
3070
|
-
var TAG_EQEDIT = 88;
|
|
3071
|
-
var TAG_BIN_DATA = 18;
|
|
3072
|
-
var TAG_DOC_CHAR_SHAPE = 21;
|
|
3073
|
-
var TAG_NUMBERING = 23;
|
|
3074
|
-
var TAG_BULLET = 24;
|
|
3075
|
-
var TAG_DOC_PARA_SHAPE = 25;
|
|
3076
|
-
var TAG_DOC_STYLE = 26;
|
|
3077
|
-
var CHAR_LINE = 0;
|
|
3078
|
-
var CHAR_SECTION_BREAK = 10;
|
|
3079
|
-
var CHAR_PARA = 13;
|
|
3080
|
-
var CHAR_TAB = 9;
|
|
3081
|
-
var CHAR_HYPHEN = 30;
|
|
3082
|
-
var CHAR_NBSP = 31;
|
|
3083
|
-
var CHAR_FIXED_NBSP = 24;
|
|
3084
|
-
var CHAR_FIXED_WIDTH = 25;
|
|
3085
|
-
var FLAG_COMPRESSED = 1 << 0;
|
|
3086
|
-
var FLAG_ENCRYPTED = 1 << 1;
|
|
3087
|
-
var FLAG_DISTRIBUTION = 1 << 2;
|
|
3088
|
-
var FLAG_DRM = 1 << 4;
|
|
3089
|
-
var MAX_RECORDS = 5e5;
|
|
3090
|
-
function readRecords(data) {
|
|
3091
|
-
const records = [];
|
|
3092
|
-
let offset = 0;
|
|
3093
|
-
while (offset + 4 <= data.length && records.length < MAX_RECORDS) {
|
|
3094
|
-
const header = data.readUInt32LE(offset);
|
|
3095
|
-
offset += 4;
|
|
3096
|
-
const tagId = header & 1023;
|
|
3097
|
-
const level = header >> 10 & 1023;
|
|
3098
|
-
let size = header >> 20 & 4095;
|
|
3099
|
-
if (size === 4095) {
|
|
3100
|
-
if (offset + 4 > data.length) break;
|
|
3101
|
-
size = data.readUInt32LE(offset);
|
|
3102
|
-
offset += 4;
|
|
3103
|
-
}
|
|
3104
|
-
if (offset + size > data.length) break;
|
|
3105
|
-
records.push({ tagId, level, size, data: data.subarray(offset, offset + size) });
|
|
3106
|
-
offset += size;
|
|
3107
|
-
}
|
|
3108
|
-
return records;
|
|
3109
|
-
}
|
|
3110
|
-
var MAX_DECOMPRESS_SIZE2 = 100 * 1024 * 1024;
|
|
3111
|
-
function decompressStream(data) {
|
|
3112
|
-
const opts = { maxOutputLength: MAX_DECOMPRESS_SIZE2 };
|
|
3113
|
-
if (data.length >= 2 && data[0] === 120) {
|
|
3114
|
-
try {
|
|
3115
|
-
return _zlib.inflateSync.call(void 0, data, opts);
|
|
3116
|
-
} catch (e17) {
|
|
3117
|
-
}
|
|
3118
|
-
}
|
|
3119
|
-
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
3120
|
-
}
|
|
3121
|
-
function parseFileHeader(data) {
|
|
3122
|
-
if (data.length < 40) throw new (0, _chunkU25XGCNHcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
3123
|
-
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
3124
|
-
return {
|
|
3125
|
-
signature: sig,
|
|
3126
|
-
versionMajor: data[35],
|
|
3127
|
-
flags: data.readUInt32LE(36)
|
|
3128
|
-
};
|
|
3129
|
-
}
|
|
3130
|
-
function readHwpString(data, offset) {
|
|
3131
|
-
if (offset + 2 > data.length) return { value: "", next: data.length };
|
|
3132
|
-
const len = data.readUInt16LE(offset);
|
|
3133
|
-
const start = offset + 2;
|
|
3134
|
-
const end = start + len * 2;
|
|
3135
|
-
if (len === 0 || end > data.length) return { value: "", next: start };
|
|
3136
|
-
return { value: data.subarray(start, end).toString("utf16le"), next: end };
|
|
3137
|
-
}
|
|
3138
|
-
function parseDocInfo(records) {
|
|
3139
|
-
const charShapes = [];
|
|
3140
|
-
const paraShapes = [];
|
|
3141
|
-
const styles = [];
|
|
3142
|
-
const binData = [];
|
|
3143
|
-
const numberings = [];
|
|
3144
|
-
const bullets = [];
|
|
3145
|
-
for (const rec of records) {
|
|
3146
|
-
if (rec.tagId === TAG_DOC_PARA_SHAPE && rec.data.length >= 4) {
|
|
3147
|
-
const attr1 = rec.data.readUInt32LE(0);
|
|
3148
|
-
const headType = attr1 >>> 23 & 3;
|
|
3149
|
-
const paraLevel = attr1 >>> 25 & 7;
|
|
3150
|
-
const numberingId = rec.data.length >= 32 ? rec.data.readUInt16LE(30) : 0;
|
|
3151
|
-
paraShapes.push({ headType, paraLevel, numberingId });
|
|
3152
|
-
}
|
|
3153
|
-
if (rec.tagId === TAG_BIN_DATA && rec.data.length >= 2) {
|
|
3154
|
-
const attr = rec.data.readUInt16LE(0);
|
|
3155
|
-
const typeBits = attr & 15;
|
|
3156
|
-
if (typeBits === 0) {
|
|
3157
|
-
binData.push({ kind: "link", storageId: 0, extension: "" });
|
|
3158
|
-
} else {
|
|
3159
|
-
const storageId = rec.data.length >= 4 ? rec.data.readUInt16LE(2) : 0;
|
|
3160
|
-
const { value: extension } = readHwpString(rec.data, 4);
|
|
3161
|
-
binData.push({ kind: typeBits === 2 ? "storage" : "embed", storageId, extension });
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
if (rec.tagId === TAG_NUMBERING && rec.data.length >= 14) {
|
|
3165
|
-
const levelFormats = [];
|
|
3166
|
-
const numberFormats = [];
|
|
3167
|
-
const startNumbers = [1, 1, 1, 1, 1, 1, 1];
|
|
3168
|
-
let offset = 0;
|
|
3169
|
-
for (let level = 0; level < 7; level++) {
|
|
3170
|
-
if (offset + 12 > rec.data.length) {
|
|
3171
|
-
levelFormats.push("");
|
|
3172
|
-
numberFormats.push(0);
|
|
3173
|
-
continue;
|
|
3174
|
-
}
|
|
3175
|
-
const attr = rec.data.readUInt32LE(offset);
|
|
3176
|
-
numberFormats.push(attr >>> 5 & 15);
|
|
3177
|
-
offset += 12;
|
|
3178
|
-
const { value, next } = readHwpString(rec.data, offset);
|
|
3179
|
-
levelFormats.push(value);
|
|
3180
|
-
offset = next;
|
|
3181
|
-
}
|
|
3182
|
-
let baseStart = 1;
|
|
3183
|
-
if (offset + 2 <= rec.data.length) {
|
|
3184
|
-
baseStart = rec.data.readUInt16LE(offset) || 1;
|
|
3185
|
-
offset += 2;
|
|
3186
|
-
}
|
|
3187
|
-
for (let level = 0; level < 7; level++) {
|
|
3188
|
-
if (offset + 4 <= rec.data.length) {
|
|
3189
|
-
startNumbers[level] = rec.data.readUInt32LE(offset) || 1;
|
|
3190
|
-
offset += 4;
|
|
3191
|
-
} else {
|
|
3192
|
-
startNumbers[level] = baseStart;
|
|
3193
|
-
}
|
|
3194
|
-
}
|
|
3195
|
-
numberings.push({ levelFormats, numberFormats, startNumbers });
|
|
3196
|
-
}
|
|
3197
|
-
if (rec.tagId === TAG_BULLET && rec.data.length >= 14) {
|
|
3198
|
-
const code = rec.data.readUInt16LE(12);
|
|
3199
|
-
bullets.push({ char: code > 0 ? String.fromCharCode(code) : "\u2022" });
|
|
3200
|
-
}
|
|
3201
|
-
if (rec.tagId === TAG_DOC_CHAR_SHAPE && rec.data.length >= 18) {
|
|
3202
|
-
if (rec.data.length >= 50) {
|
|
3203
|
-
const fontSize = rec.data.readUInt32LE(42);
|
|
3204
|
-
const attrFlags = rec.data.readUInt32LE(46);
|
|
3205
|
-
charShapes.push({ fontSize, attrFlags });
|
|
3206
|
-
} else {
|
|
3207
|
-
charShapes.push({ fontSize: 0, attrFlags: 0 });
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
if (rec.tagId === TAG_DOC_STYLE && rec.data.length >= 8) {
|
|
3211
|
-
try {
|
|
3212
|
-
let offset = 0;
|
|
3213
|
-
const nameLen = rec.data.readUInt16LE(offset);
|
|
3214
|
-
offset += 2;
|
|
3215
|
-
const nameBytes = nameLen * 2;
|
|
3216
|
-
const name = nameBytes > 0 && offset + nameBytes <= rec.data.length ? rec.data.subarray(offset, offset + nameBytes).toString("utf16le") : "";
|
|
3217
|
-
offset += nameBytes;
|
|
3218
|
-
let nameKo = "";
|
|
3219
|
-
if (offset + 2 <= rec.data.length) {
|
|
3220
|
-
const nameKoLen = rec.data.readUInt16LE(offset);
|
|
3221
|
-
offset += 2;
|
|
3222
|
-
const nameKoBytes = nameKoLen * 2;
|
|
3223
|
-
if (nameKoBytes > 0 && offset + nameKoBytes <= rec.data.length) {
|
|
3224
|
-
nameKo = rec.data.subarray(offset, offset + nameKoBytes).toString("utf16le");
|
|
3225
|
-
}
|
|
3226
|
-
offset += nameKoBytes;
|
|
3227
|
-
}
|
|
3228
|
-
const type = offset < rec.data.length ? rec.data.readUInt8(offset) : 0;
|
|
3229
|
-
offset += 1;
|
|
3230
|
-
offset += 1;
|
|
3231
|
-
offset += 2;
|
|
3232
|
-
const paraShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
|
|
3233
|
-
offset += 2;
|
|
3234
|
-
const charShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
|
|
3235
|
-
styles.push({ name, nameKo, charShapeId, paraShapeId, type });
|
|
3236
|
-
} catch (e18) {
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
}
|
|
3240
|
-
return { charShapes, paraShapes, styles, binData, numberings, bullets };
|
|
3241
|
-
}
|
|
3242
|
-
function createParaTextState() {
|
|
3243
|
-
return { text: "", ctrlIdx: 0, fieldStack: [], fieldRanges: [] };
|
|
3244
|
-
}
|
|
3245
|
-
function isExtendedOnlyCtrlChar(ch) {
|
|
3246
|
-
return ch >= 1 && ch <= 3 || ch >= 11 && ch <= 12 || ch >= 14 && ch <= 18 || ch >= 21 && ch <= 23;
|
|
3247
|
-
}
|
|
3248
|
-
function appendParaText(state, data, resolveControl) {
|
|
3249
|
-
let result = "";
|
|
3250
|
-
let i = 0;
|
|
3251
|
-
const base = state.text.length;
|
|
3252
|
-
const resolveAt = (byteOffset, extended) => {
|
|
3253
|
-
const ctrlId = data.readUInt32LE(byteOffset);
|
|
3254
|
-
const idx = extended ? state.ctrlIdx : -1;
|
|
3255
|
-
const replacement = _optionalChain([resolveControl, 'optionalCall', _80 => _80(idx, ctrlId)]);
|
|
3256
|
-
if (replacement) result += replacement;
|
|
3257
|
-
if (extended) state.ctrlIdx++;
|
|
3258
|
-
};
|
|
3259
|
-
while (i + 1 < data.length) {
|
|
3260
|
-
const ch = data.readUInt16LE(i);
|
|
3261
|
-
i += 2;
|
|
3262
|
-
switch (ch) {
|
|
3263
|
-
// ── char 타입 (2바이트만, 확장 데이터 없음) ──
|
|
3264
|
-
case CHAR_LINE:
|
|
3265
|
-
result += "\n";
|
|
3266
|
-
break;
|
|
3267
|
-
case CHAR_SECTION_BREAK: {
|
|
3268
|
-
if (i + 16 <= data.length && data.readUInt16LE(i) === 11) {
|
|
3269
|
-
resolveAt(i + 2, true);
|
|
3270
|
-
i += 16;
|
|
3271
|
-
break;
|
|
3473
|
+
if (isEncryptedHwpx(manifestXml)) {
|
|
3474
|
+
if (isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _80 => _80.filePath])) {
|
|
3475
|
+
const { pages, pageCount, warnings: warnings2 } = extractTextViaCom(options.filePath);
|
|
3476
|
+
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
3477
|
+
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3272
3478
|
}
|
|
3273
|
-
result += "\n";
|
|
3274
|
-
break;
|
|
3275
3479
|
}
|
|
3276
|
-
|
|
3277
|
-
break;
|
|
3278
|
-
// 문단 끝
|
|
3279
|
-
case CHAR_HYPHEN:
|
|
3280
|
-
result += "-";
|
|
3281
|
-
break;
|
|
3282
|
-
case CHAR_NBSP:
|
|
3283
|
-
result += " ";
|
|
3284
|
-
break;
|
|
3285
|
-
case CHAR_FIXED_NBSP:
|
|
3286
|
-
result += "\xA0";
|
|
3287
|
-
break;
|
|
3288
|
-
// 진짜 NBSP
|
|
3289
|
-
case CHAR_FIXED_WIDTH:
|
|
3290
|
-
result += " ";
|
|
3291
|
-
break;
|
|
3292
|
-
// 고정폭 공백
|
|
3293
|
-
// ── inline 타입 (2바이트 + 14바이트 확장) ──
|
|
3294
|
-
case CHAR_TAB:
|
|
3295
|
-
result += " ";
|
|
3296
|
-
if (i + 14 <= data.length) i += 14;
|
|
3297
|
-
break;
|
|
3298
|
-
default:
|
|
3299
|
-
if (ch >= 1 && ch <= 31) {
|
|
3300
|
-
const isExtended = isExtendedOnlyCtrlChar(ch);
|
|
3301
|
-
const isInline = ch >= 4 && ch <= 9 || ch >= 19 && ch <= 20;
|
|
3302
|
-
if ((isExtended || isInline) && i + 14 <= data.length) {
|
|
3303
|
-
if (ch === 3) {
|
|
3304
|
-
state.fieldStack.push({ start: base + result.length, ctrlIdx: state.ctrlIdx });
|
|
3305
|
-
} else if (ch === 4) {
|
|
3306
|
-
const open = state.fieldStack.pop();
|
|
3307
|
-
if (open) {
|
|
3308
|
-
state.fieldRanges.push({ start: open.start, end: base + result.length, ctrlIdx: open.ctrlIdx });
|
|
3309
|
-
}
|
|
3310
|
-
}
|
|
3311
|
-
resolveAt(i, isExtended);
|
|
3312
|
-
i += 14;
|
|
3313
|
-
}
|
|
3314
|
-
} else if (ch >= 32) {
|
|
3315
|
-
if (ch >= 55296 && ch <= 56319 && i + 1 < data.length) {
|
|
3316
|
-
const lo = data.readUInt16LE(i);
|
|
3317
|
-
if (lo >= 56320 && lo <= 57343) {
|
|
3318
|
-
i += 2;
|
|
3319
|
-
const codePoint = (ch - 55296 << 10) + (lo - 56320) + 65536;
|
|
3320
|
-
result += String.fromCodePoint(codePoint);
|
|
3321
|
-
break;
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
result += String.fromCharCode(ch);
|
|
3325
|
-
}
|
|
3326
|
-
break;
|
|
3480
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
3327
3481
|
}
|
|
3328
3482
|
}
|
|
3329
|
-
|
|
3330
|
-
}
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
const
|
|
3334
|
-
const
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
const
|
|
3338
|
-
|
|
3483
|
+
const decompressed = { total: 0 };
|
|
3484
|
+
const metadata = {};
|
|
3485
|
+
await extractHwpxMetadata(zip, metadata, decompressed);
|
|
3486
|
+
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3487
|
+
const warnings = [];
|
|
3488
|
+
const sectionPaths = await resolveSectionPaths(zip);
|
|
3489
|
+
if (sectionPaths.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3490
|
+
metadata.pageCount = sectionPaths.length;
|
|
3491
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _81 => _81.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3492
|
+
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
3493
|
+
const blocks = [];
|
|
3494
|
+
const shared = createSectionShared();
|
|
3495
|
+
shared.kordocLayout = await readKordocLayout(zip);
|
|
3496
|
+
let parsedSections = 0;
|
|
3497
|
+
for (let si = 0; si < sectionPaths.length; si++) {
|
|
3498
|
+
if (pageFilter && !pageFilter.has(si + 1)) continue;
|
|
3499
|
+
const file = zip.file(sectionPaths[si]);
|
|
3500
|
+
if (!file) continue;
|
|
3501
|
+
try {
|
|
3502
|
+
const xml = await file.async("text");
|
|
3503
|
+
decompressed.total += xml.length * 2;
|
|
3504
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3505
|
+
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
3506
|
+
parsedSections++;
|
|
3507
|
+
_optionalChain([options, 'optionalAccess', _82 => _82.onProgress, 'optionalCall', _83 => _83(parsedSections, totalTarget)]);
|
|
3508
|
+
} catch (secErr) {
|
|
3509
|
+
if (secErr instanceof _chunk6XAAYAWLcjs.KordocError) throw secErr;
|
|
3510
|
+
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" });
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
applyPageText(blocks, shared);
|
|
3514
|
+
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3515
|
+
detectHwpxHeadings(blocks, styleMap);
|
|
3516
|
+
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3517
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3518
|
+
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 };
|
|
3339
3519
|
}
|
|
3340
3520
|
|
|
3341
3521
|
// src/hwp5/numbering.ts
|
|
@@ -3516,282 +3696,6 @@ function expandNumberingFormat(formatStr, counters, numbering) {
|
|
|
3516
3696
|
return result;
|
|
3517
3697
|
}
|
|
3518
3698
|
|
|
3519
|
-
// src/hwp5/images.ts
|
|
3520
|
-
function detectImageMime(data) {
|
|
3521
|
-
if (data.length < 4) return null;
|
|
3522
|
-
if (data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71) return "image/png";
|
|
3523
|
-
if (data[0] === 255 && data[1] === 216 && data[2] === 255) return "image/jpeg";
|
|
3524
|
-
if (data[0] === 71 && data[1] === 73 && data[2] === 70) return "image/gif";
|
|
3525
|
-
if (data[0] === 66 && data[1] === 77) return "image/bmp";
|
|
3526
|
-
if (data[0] === 215 && data[1] === 205 && data[2] === 198 && data[3] === 154) return "image/wmf";
|
|
3527
|
-
if (data[0] === 1 && data[1] === 0 && data[2] === 0 && data[3] === 0) return "image/emf";
|
|
3528
|
-
return null;
|
|
3529
|
-
}
|
|
3530
|
-
function normalizeBinPayload(data) {
|
|
3531
|
-
if (detectImageMime(data)) return data;
|
|
3532
|
-
try {
|
|
3533
|
-
const inflated = decompressStream(data);
|
|
3534
|
-
if (inflated.length > 0) return inflated;
|
|
3535
|
-
} catch (e19) {
|
|
3536
|
-
}
|
|
3537
|
-
return data;
|
|
3538
|
-
}
|
|
3539
|
-
var BIN_ENTRY_RE = /(?:^|\/)BIN([0-9A-Fa-f]{4,8})(?:\.[^./\\]*)?$/;
|
|
3540
|
-
function collectImageBlocks2(blocks, out) {
|
|
3541
|
-
for (const b of blocks) {
|
|
3542
|
-
if (b.type === "image") out.push(b);
|
|
3543
|
-
if (b.table) {
|
|
3544
|
-
for (const row of b.table.cells) {
|
|
3545
|
-
for (const cell2 of row) {
|
|
3546
|
-
if (cell2.blocks) collectImageBlocks2(cell2.blocks, out);
|
|
3547
|
-
}
|
|
3548
|
-
}
|
|
3549
|
-
}
|
|
3550
|
-
if (b.children) collectImageBlocks2(b.children, out);
|
|
3551
|
-
}
|
|
3552
|
-
}
|
|
3553
|
-
function forEachTableCell(blocks, fn) {
|
|
3554
|
-
for (const b of blocks) {
|
|
3555
|
-
if (b.table) {
|
|
3556
|
-
for (const row of b.table.cells) {
|
|
3557
|
-
for (const cell2 of row) {
|
|
3558
|
-
fn(cell2);
|
|
3559
|
-
if (cell2.blocks) forEachTableCell(cell2.blocks, fn);
|
|
3560
|
-
}
|
|
3561
|
-
}
|
|
3562
|
-
}
|
|
3563
|
-
if (b.children) forEachTableCell(b.children, fn);
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
var CELL_IMAGE_SENTINEL_RE = /!\[image\]\(hwp5bin:(\d+)\)/g;
|
|
3567
|
-
function resolveCellImageSentinels(blocks, renamed) {
|
|
3568
|
-
forEachTableCell(blocks, (cell2) => {
|
|
3569
|
-
if (!cell2.text.includes("hwp5bin:")) return;
|
|
3570
|
-
cell2.text = cell2.text.replace(CELL_IMAGE_SENTINEL_RE, (_m, idStr) => {
|
|
3571
|
-
const filename = renamed.get(Number(idStr));
|
|
3572
|
-
return filename ? `` : "[\uC774\uBBF8\uC9C0]";
|
|
3573
|
-
});
|
|
3574
|
-
});
|
|
3575
|
-
}
|
|
3576
|
-
function resolveImageBlocks(binDataMap, blocks, warnings) {
|
|
3577
|
-
const imageBlocks = [];
|
|
3578
|
-
collectImageBlocks2(blocks, imageBlocks);
|
|
3579
|
-
if (imageBlocks.length === 0) return [];
|
|
3580
|
-
const images = [];
|
|
3581
|
-
const renamed = /* @__PURE__ */ new Map();
|
|
3582
|
-
const resolved = /* @__PURE__ */ new Map();
|
|
3583
|
-
let imageIndex = 0;
|
|
3584
|
-
for (const block of imageBlocks) {
|
|
3585
|
-
if (!block.text) continue;
|
|
3586
|
-
const storageId = parseInt(block.text, 10);
|
|
3587
|
-
if (isNaN(storageId)) continue;
|
|
3588
|
-
let img = resolved.get(storageId);
|
|
3589
|
-
if (img === void 0) {
|
|
3590
|
-
const bin = binDataMap.get(storageId);
|
|
3591
|
-
if (!bin) {
|
|
3592
|
-
warnings.push({ page: block.pageNumber, message: `BinData ${storageId} \uC5C6\uC74C`, code: "SKIPPED_IMAGE" });
|
|
3593
|
-
resolved.set(storageId, null);
|
|
3594
|
-
} else {
|
|
3595
|
-
const mime = detectImageMime(bin.data);
|
|
3596
|
-
if (!mime) {
|
|
3597
|
-
warnings.push({ page: block.pageNumber, message: `BinData ${storageId}: \uC54C \uC218 \uC5C6\uB294 \uC774\uBBF8\uC9C0 \uD615\uC2DD`, code: "SKIPPED_IMAGE" });
|
|
3598
|
-
resolved.set(storageId, null);
|
|
3599
|
-
} else {
|
|
3600
|
-
imageIndex++;
|
|
3601
|
-
const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
|
|
3602
|
-
img = { filename: `image_${String(imageIndex).padStart(3, "0")}.${ext}`, data: new Uint8Array(bin.data), mime };
|
|
3603
|
-
resolved.set(storageId, img);
|
|
3604
|
-
images.push({ filename: img.filename, data: img.data, mimeType: img.mime });
|
|
3605
|
-
renamed.set(storageId, img.filename);
|
|
3606
|
-
}
|
|
3607
|
-
}
|
|
3608
|
-
img = resolved.get(storageId);
|
|
3609
|
-
}
|
|
3610
|
-
if (!img) {
|
|
3611
|
-
const bin = binDataMap.get(storageId);
|
|
3612
|
-
block.type = "paragraph";
|
|
3613
|
-
block.text = bin ? `[\uC774\uBBF8\uC9C0: ${bin.name}]` : `[\uC774\uBBF8\uC9C0: BinData ${storageId}]`;
|
|
3614
|
-
continue;
|
|
3615
|
-
}
|
|
3616
|
-
block.text = img.filename;
|
|
3617
|
-
block.imageData = { data: img.data, mimeType: img.mime, filename: binDataMap.get(storageId).name };
|
|
3618
|
-
}
|
|
3619
|
-
resolveCellImageSentinels(blocks, renamed);
|
|
3620
|
-
return images;
|
|
3621
|
-
}
|
|
3622
|
-
function extractHwp5Images(fileIndex, blocks, warnings) {
|
|
3623
|
-
const binDataMap = /* @__PURE__ */ new Map();
|
|
3624
|
-
if (fileIndex) {
|
|
3625
|
-
for (const entry of fileIndex) {
|
|
3626
|
-
if (!_optionalChain([entry, 'optionalAccess', _81 => _81.name]) || !entry.content) continue;
|
|
3627
|
-
const match = entry.name.match(BIN_ENTRY_RE);
|
|
3628
|
-
if (!match) continue;
|
|
3629
|
-
const idx = parseInt(match[1], 16);
|
|
3630
|
-
const data = normalizeBinPayload(Buffer.from(entry.content));
|
|
3631
|
-
binDataMap.set(idx, { data, name: entry.name });
|
|
3632
|
-
}
|
|
3633
|
-
}
|
|
3634
|
-
if (binDataMap.size === 0) {
|
|
3635
|
-
resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
|
|
3636
|
-
return [];
|
|
3637
|
-
}
|
|
3638
|
-
return resolveImageBlocks(binDataMap, blocks, warnings);
|
|
3639
|
-
}
|
|
3640
|
-
function extractHwp5ImagesLenient(lcfb, blocks, warnings) {
|
|
3641
|
-
const binDataMap = /* @__PURE__ */ new Map();
|
|
3642
|
-
const binRe = /^BIN([0-9A-Fa-f]{4,8})(?:\.|$)/;
|
|
3643
|
-
for (const e of lcfb.entries()) {
|
|
3644
|
-
const match = e.name.match(binRe);
|
|
3645
|
-
if (!match) continue;
|
|
3646
|
-
const idx = parseInt(match[1], 16);
|
|
3647
|
-
const raw = lcfb.findStream(e.name);
|
|
3648
|
-
if (!raw) continue;
|
|
3649
|
-
binDataMap.set(idx, { data: normalizeBinPayload(raw), name: e.name });
|
|
3650
|
-
}
|
|
3651
|
-
if (binDataMap.size === 0) {
|
|
3652
|
-
resolveCellImageSentinels(blocks, /* @__PURE__ */ new Map());
|
|
3653
|
-
return [];
|
|
3654
|
-
}
|
|
3655
|
-
return resolveImageBlocks(binDataMap, blocks, warnings);
|
|
3656
|
-
}
|
|
3657
|
-
|
|
3658
|
-
// src/image/transcode.ts
|
|
3659
|
-
|
|
3660
|
-
var CRC_TABLE = (() => {
|
|
3661
|
-
const table2 = new Uint32Array(256);
|
|
3662
|
-
for (let n = 0; n < 256; n++) {
|
|
3663
|
-
let c = n;
|
|
3664
|
-
for (let k = 0; k < 8; k++) {
|
|
3665
|
-
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
3666
|
-
}
|
|
3667
|
-
table2[n] = c >>> 0;
|
|
3668
|
-
}
|
|
3669
|
-
return table2;
|
|
3670
|
-
})();
|
|
3671
|
-
function crc32(bytes) {
|
|
3672
|
-
let c = 4294967295;
|
|
3673
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
3674
|
-
c = CRC_TABLE[(c ^ bytes[i]) & 255] ^ c >>> 8;
|
|
3675
|
-
}
|
|
3676
|
-
return (c ^ 4294967295) >>> 0;
|
|
3677
|
-
}
|
|
3678
|
-
var BI_RGB = 0;
|
|
3679
|
-
var MAX_DIM = 32767;
|
|
3680
|
-
var MAX_PIXELS = 36e6;
|
|
3681
|
-
function bmpToPng(bmp) {
|
|
3682
|
-
if (bmp.length < 54) return null;
|
|
3683
|
-
if (bmp[0] !== 66 || bmp[1] !== 77) return null;
|
|
3684
|
-
const dv = new DataView(bmp.buffer, bmp.byteOffset, bmp.byteLength);
|
|
3685
|
-
const dataOffset = dv.getUint32(10, true);
|
|
3686
|
-
const headerSize = dv.getUint32(14, true);
|
|
3687
|
-
if (headerSize < 40) return null;
|
|
3688
|
-
const width = dv.getInt32(18, true);
|
|
3689
|
-
const rawHeight = dv.getInt32(22, true);
|
|
3690
|
-
const bitCount = dv.getUint16(28, true);
|
|
3691
|
-
const compression = dv.getUint32(30, true);
|
|
3692
|
-
if (compression !== BI_RGB) return null;
|
|
3693
|
-
if (bitCount !== 24 && bitCount !== 32) return null;
|
|
3694
|
-
if (width <= 0 || rawHeight === 0) return null;
|
|
3695
|
-
if (width > MAX_DIM || Math.abs(rawHeight) > MAX_DIM) return null;
|
|
3696
|
-
const topDown = rawHeight < 0;
|
|
3697
|
-
const height = Math.abs(rawHeight);
|
|
3698
|
-
if (width * height > MAX_PIXELS) return null;
|
|
3699
|
-
const bytesPerPixel = bitCount >> 3;
|
|
3700
|
-
const rowStride = width * bytesPerPixel + 3 & ~3;
|
|
3701
|
-
if (dataOffset + rowStride * height > bmp.length) return null;
|
|
3702
|
-
const rgba = new Uint8Array(width * height * 4);
|
|
3703
|
-
let anyAlpha = 0;
|
|
3704
|
-
for (let y = 0; y < height; y++) {
|
|
3705
|
-
const srcRow = topDown ? y : height - 1 - y;
|
|
3706
|
-
let src = dataOffset + srcRow * rowStride;
|
|
3707
|
-
let dst = y * width * 4;
|
|
3708
|
-
for (let x = 0; x < width; x++) {
|
|
3709
|
-
rgba[dst] = bmp[src + 2];
|
|
3710
|
-
rgba[dst + 1] = bmp[src + 1];
|
|
3711
|
-
rgba[dst + 2] = bmp[src];
|
|
3712
|
-
const a = bitCount === 32 ? bmp[src + 3] : 255;
|
|
3713
|
-
rgba[dst + 3] = a;
|
|
3714
|
-
anyAlpha |= a;
|
|
3715
|
-
src += bytesPerPixel;
|
|
3716
|
-
dst += 4;
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
if (bitCount === 32 && anyAlpha === 0) {
|
|
3720
|
-
for (let i = 3; i < rgba.length; i += 4) rgba[i] = 255;
|
|
3721
|
-
}
|
|
3722
|
-
return encodePng(width, height, rgba);
|
|
3723
|
-
}
|
|
3724
|
-
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
3725
|
-
function chunk(type, data) {
|
|
3726
|
-
const body = new Uint8Array(4 + data.length);
|
|
3727
|
-
body[0] = type.charCodeAt(0);
|
|
3728
|
-
body[1] = type.charCodeAt(1);
|
|
3729
|
-
body[2] = type.charCodeAt(2);
|
|
3730
|
-
body[3] = type.charCodeAt(3);
|
|
3731
|
-
body.set(data, 4);
|
|
3732
|
-
const out = new Uint8Array(8 + data.length + 4);
|
|
3733
|
-
const dv = new DataView(out.buffer);
|
|
3734
|
-
dv.setUint32(0, data.length, false);
|
|
3735
|
-
out.set(body, 4);
|
|
3736
|
-
dv.setUint32(8 + data.length, crc32(body), false);
|
|
3737
|
-
return out;
|
|
3738
|
-
}
|
|
3739
|
-
function encodePng(width, height, rgba) {
|
|
3740
|
-
const ihdr = new Uint8Array(13);
|
|
3741
|
-
const iv = new DataView(ihdr.buffer);
|
|
3742
|
-
iv.setUint32(0, width, false);
|
|
3743
|
-
iv.setUint32(4, height, false);
|
|
3744
|
-
ihdr[8] = 8;
|
|
3745
|
-
ihdr[9] = 6;
|
|
3746
|
-
const stride = width * 4;
|
|
3747
|
-
const raw = new Uint8Array((stride + 1) * height);
|
|
3748
|
-
for (let y = 0; y < height; y++) {
|
|
3749
|
-
const rowStart = y * (stride + 1);
|
|
3750
|
-
raw[rowStart] = 0;
|
|
3751
|
-
raw.set(rgba.subarray(y * stride, y * stride + stride), rowStart + 1);
|
|
3752
|
-
}
|
|
3753
|
-
const idat = _zlib.deflateSync.call(void 0, raw);
|
|
3754
|
-
const ihdrChunk = chunk("IHDR", ihdr);
|
|
3755
|
-
const idatChunk = chunk("IDAT", idat);
|
|
3756
|
-
const iendChunk = chunk("IEND", new Uint8Array(0));
|
|
3757
|
-
const out = new Uint8Array(PNG_SIGNATURE.length + ihdrChunk.length + idatChunk.length + iendChunk.length);
|
|
3758
|
-
let o = 0;
|
|
3759
|
-
out.set(PNG_SIGNATURE, o);
|
|
3760
|
-
o += PNG_SIGNATURE.length;
|
|
3761
|
-
out.set(ihdrChunk, o);
|
|
3762
|
-
o += ihdrChunk.length;
|
|
3763
|
-
out.set(idatChunk, o);
|
|
3764
|
-
o += idatChunk.length;
|
|
3765
|
-
out.set(iendChunk, o);
|
|
3766
|
-
return out;
|
|
3767
|
-
}
|
|
3768
|
-
function escapeRegExp(s) {
|
|
3769
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3770
|
-
}
|
|
3771
|
-
function inlineImagesIntoMarkdown(markdown, images, opts) {
|
|
3772
|
-
const compress = _optionalChain([opts, 'optionalAccess', _82 => _82.compress]) !== false;
|
|
3773
|
-
let out = markdown;
|
|
3774
|
-
for (const img of images) {
|
|
3775
|
-
let bytes = img.data;
|
|
3776
|
-
let mime = img.mimeType;
|
|
3777
|
-
if (compress && mime === "image/bmp") {
|
|
3778
|
-
const png = bmpToPng(img.data);
|
|
3779
|
-
if (png) {
|
|
3780
|
-
bytes = png;
|
|
3781
|
-
mime = "image/png";
|
|
3782
|
-
}
|
|
3783
|
-
}
|
|
3784
|
-
const base64 = Buffer.from(bytes).toString("base64");
|
|
3785
|
-
const dataUri = `data:${mime};base64,${base64}`;
|
|
3786
|
-
const name = escapeRegExp(img.filename);
|
|
3787
|
-
const mdRe = new RegExp(`!\\[image\\]\\((?:images/)?${name}\\)`, "g");
|
|
3788
|
-
out = out.replace(mdRe, () => ``);
|
|
3789
|
-
const imgTagRe = new RegExp(`(<img\\b[^>]*\\bsrc=")(?:images/)?${name}(")`, "g");
|
|
3790
|
-
out = out.replace(imgTagRe, (_m, pre, post) => `${pre}${dataUri}${post}`);
|
|
3791
|
-
}
|
|
3792
|
-
return out;
|
|
3793
|
-
}
|
|
3794
|
-
|
|
3795
3699
|
// src/hwp5/aes.ts
|
|
3796
3700
|
var S_BOX = new Uint8Array([
|
|
3797
3701
|
99,
|
|
@@ -4789,22 +4693,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4789
4693
|
lenientCfb = parseLenientCfb(buffer);
|
|
4790
4694
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4791
4695
|
} catch (e22) {
|
|
4792
|
-
throw new (0,
|
|
4696
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4793
4697
|
}
|
|
4794
4698
|
}
|
|
4795
4699
|
const findStream = (path) => {
|
|
4796
4700
|
if (cfb) {
|
|
4797
4701
|
const entry = CFB.find(cfb, path);
|
|
4798
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
4702
|
+
return _optionalChain([entry, 'optionalAccess', _84 => _84.content]) ? Buffer.from(entry.content) : null;
|
|
4799
4703
|
}
|
|
4800
4704
|
return lenientCfb.findStream(path);
|
|
4801
4705
|
};
|
|
4802
4706
|
const headerData = findStream("/FileHeader");
|
|
4803
|
-
if (!headerData) throw new (0,
|
|
4707
|
+
if (!headerData) throw new (0, _chunk6XAAYAWLcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4804
4708
|
const header = parseFileHeader(headerData);
|
|
4805
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4806
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4807
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4709
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4710
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4711
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunk6XAAYAWLcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4808
4712
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4809
4713
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4810
4714
|
const metadata = {
|
|
@@ -4813,9 +4717,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
4813
4717
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4814
4718
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4815
4719
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4816
|
-
if (sections.length === 0) throw new (0,
|
|
4720
|
+
if (sections.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4817
4721
|
metadata.pageCount = sections.length;
|
|
4818
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
4722
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _85 => _85.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4819
4723
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
4820
4724
|
const bodyBlocks = [];
|
|
4821
4725
|
const doc = createHwp5DocState();
|
|
@@ -4827,22 +4731,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4827
4731
|
const sectionData = sections[si];
|
|
4828
4732
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4829
4733
|
totalDecompressed += data.length;
|
|
4830
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4734
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4831
4735
|
const records = readRecords(data);
|
|
4832
4736
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4833
4737
|
bodyBlocks.push(...sectionBlocks);
|
|
4834
4738
|
parsedSections++;
|
|
4835
|
-
_optionalChain([options, 'optionalAccess',
|
|
4739
|
+
_optionalChain([options, 'optionalAccess', _86 => _86.onProgress, 'optionalCall', _87 => _87(parsedSections, totalTarget)]);
|
|
4836
4740
|
} catch (secErr) {
|
|
4837
|
-
if (secErr instanceof
|
|
4741
|
+
if (secErr instanceof _chunk6XAAYAWLcjs.KordocError) throw secErr;
|
|
4838
4742
|
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" });
|
|
4839
4743
|
}
|
|
4840
4744
|
}
|
|
4841
4745
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4842
|
-
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
4843
|
-
let flatBlocks =
|
|
4844
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4845
|
-
const deduped =
|
|
4746
|
+
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4747
|
+
let flatBlocks = _chunk6XAAYAWLcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4748
|
+
if (_optionalChain([options, 'optionalAccess', _88 => _88.dedupeRunningHeaders])) {
|
|
4749
|
+
const deduped = _chunk6XAAYAWLcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4846
4750
|
const removed = flatBlocks.length - deduped.length;
|
|
4847
4751
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4848
4752
|
flatBlocks = deduped;
|
|
@@ -4851,10 +4755,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4851
4755
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4852
4756
|
}
|
|
4853
4757
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4854
|
-
let markdown =
|
|
4855
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4758
|
+
let markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4759
|
+
if (_optionalChain([options, 'optionalAccess', _89 => _89.inlineImages]) && images.length > 0) {
|
|
4856
4760
|
try {
|
|
4857
|
-
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
4761
|
+
markdown = _chunk6XAAYAWLcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4858
4762
|
} catch (inlineErr) {
|
|
4859
4763
|
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" });
|
|
4860
4764
|
}
|
|
@@ -4864,7 +4768,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4864
4768
|
function parseDocInfoStream(cfb, compressed) {
|
|
4865
4769
|
try {
|
|
4866
4770
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
4867
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4771
|
+
if (!_optionalChain([entry, 'optionalAccess', _90 => _90.content])) return null;
|
|
4868
4772
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
4869
4773
|
const records = readRecords(data);
|
|
4870
4774
|
return parseDocInfo(records);
|
|
@@ -4885,7 +4789,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4885
4789
|
let baseFontSize = 0;
|
|
4886
4790
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
4887
4791
|
for (const b of blocks) {
|
|
4888
|
-
if (_optionalChain([b, 'access',
|
|
4792
|
+
if (_optionalChain([b, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]) && b.text) {
|
|
4889
4793
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
4890
4794
|
}
|
|
4891
4795
|
}
|
|
@@ -4901,7 +4805,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4901
4805
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
4902
4806
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
4903
4807
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
4904
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4808
|
+
if (_optionalChain([cs, 'optionalAccess', _93 => _93.fontSize]) > 0) {
|
|
4905
4809
|
baseFontSize = cs.fontSize / 10;
|
|
4906
4810
|
break;
|
|
4907
4811
|
}
|
|
@@ -4916,11 +4820,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4916
4820
|
if (text.length === 0 || text.length > 200) continue;
|
|
4917
4821
|
if (/^\d+$/.test(text)) continue;
|
|
4918
4822
|
let level = 0;
|
|
4919
|
-
if (_optionalChain([block, 'access',
|
|
4823
|
+
if (_optionalChain([block, 'access', _94 => _94.style, 'optionalAccess', _95 => _95.fontSize]) && baseFontSize > 0) {
|
|
4920
4824
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4921
|
-
if (ratio >=
|
|
4922
|
-
else if (ratio >=
|
|
4923
|
-
else if (ratio >=
|
|
4825
|
+
if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H1) level = 1;
|
|
4826
|
+
else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H2) level = 2;
|
|
4827
|
+
else if (ratio >= _chunk6XAAYAWLcjs.HEADING_RATIO_H3) level = 3;
|
|
4924
4828
|
}
|
|
4925
4829
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4926
4830
|
if (level === 0) level = 2;
|
|
@@ -4936,7 +4840,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4936
4840
|
function extractHwp5Metadata(cfb, metadata) {
|
|
4937
4841
|
try {
|
|
4938
4842
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
4939
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4843
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _96 => _96.content])) return;
|
|
4940
4844
|
const data = Buffer.from(summaryEntry.content);
|
|
4941
4845
|
if (data.length < 48) return;
|
|
4942
4846
|
const numSets = data.readUInt32LE(24);
|
|
@@ -4969,7 +4873,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
4969
4873
|
const sections = [];
|
|
4970
4874
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4971
4875
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
4972
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4876
|
+
if (!_optionalChain([entry, 'optionalAccess', _97 => _97.content])) break;
|
|
4973
4877
|
try {
|
|
4974
4878
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
4975
4879
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -4983,13 +4887,13 @@ function findSections(cfb) {
|
|
|
4983
4887
|
const sections = [];
|
|
4984
4888
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
4985
4889
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
4986
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4890
|
+
if (!_optionalChain([entry, 'optionalAccess', _98 => _98.content])) break;
|
|
4987
4891
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
4988
4892
|
}
|
|
4989
4893
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
4990
4894
|
for (const entry of cfb.FileIndex) {
|
|
4991
4895
|
if (sections.length >= MAX_SECTIONS) break;
|
|
4992
|
-
if (_optionalChain([entry, 'access',
|
|
4896
|
+
if (_optionalChain([entry, 'access', _99 => _99.name, 'optionalAccess', _100 => _100.startsWith, 'call', _101 => _101("Section")]) && entry.content) {
|
|
4993
4897
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
4994
4898
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
4995
4899
|
}
|
|
@@ -5005,7 +4909,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5005
4909
|
if (!raw) break;
|
|
5006
4910
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5007
4911
|
totalDecompressed += content.length;
|
|
5008
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4912
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5009
4913
|
sections.push({ idx: i, content });
|
|
5010
4914
|
}
|
|
5011
4915
|
if (sections.length === 0) {
|
|
@@ -5017,7 +4921,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5017
4921
|
if (raw) {
|
|
5018
4922
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5019
4923
|
totalDecompressed += content.length;
|
|
5020
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4924
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5021
4925
|
sections.push({ idx, content });
|
|
5022
4926
|
}
|
|
5023
4927
|
}
|
|
@@ -5034,7 +4938,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5034
4938
|
try {
|
|
5035
4939
|
const content = decryptViewText(raw, compressed);
|
|
5036
4940
|
totalDecompressed += content.length;
|
|
5037
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4941
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5038
4942
|
sections.push({ idx: i, content });
|
|
5039
4943
|
} catch (e27) {
|
|
5040
4944
|
break;
|
|
@@ -5135,9 +5039,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5135
5039
|
const applied = [];
|
|
5136
5040
|
for (const r of ranges) {
|
|
5137
5041
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5138
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
5042
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _102 => _102.href]) || r.end <= r.start) continue;
|
|
5139
5043
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5140
|
-
const href =
|
|
5044
|
+
const href = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5141
5045
|
if (!href) continue;
|
|
5142
5046
|
const anchor = text.slice(r.start, r.end);
|
|
5143
5047
|
if (!anchor.trim()) continue;
|
|
@@ -5155,7 +5059,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5155
5059
|
}
|
|
5156
5060
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
5157
5061
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
5158
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
5062
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _103 => _103.docInfo, 'optionalAccess', _104 => _104.numberings, 'access', _105 => _105[nid - 1]]) : void 0;
|
|
5159
5063
|
if (numbering) {
|
|
5160
5064
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
5161
5065
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -5165,7 +5069,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5165
5069
|
}
|
|
5166
5070
|
}
|
|
5167
5071
|
} else if (ps.headType === 3) {
|
|
5168
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
5072
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _106 => _106.docInfo, 'optionalAccess', _107 => _107.bullets, 'access', _108 => _108[ps.numberingId - 1]]) : void 0;
|
|
5169
5073
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
5170
5074
|
}
|
|
5171
5075
|
}
|
|
@@ -5370,8 +5274,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5370
5274
|
let tableIdx = -1;
|
|
5371
5275
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5372
5276
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5373
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5374
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5277
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunk6XAAYAWLcjs.MAX_ROWS);
|
|
5278
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunk6XAAYAWLcjs.MAX_COLS);
|
|
5375
5279
|
tableIdx = i2;
|
|
5376
5280
|
break;
|
|
5377
5281
|
}
|
|
@@ -5411,7 +5315,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5411
5315
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
5412
5316
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
5413
5317
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
5414
|
-
if (_optionalChain([c, 'access',
|
|
5318
|
+
if (_optionalChain([c, 'access', _109 => _109.blocks, 'optionalAccess', _110 => _110.length])) ir.blocks = c.blocks;
|
|
5415
5319
|
if (c.isHeader) ir.isHeader = true;
|
|
5416
5320
|
return ir;
|
|
5417
5321
|
}));
|
|
@@ -5420,7 +5324,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5420
5324
|
return table3;
|
|
5421
5325
|
}
|
|
5422
5326
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5423
|
-
const table2 =
|
|
5327
|
+
const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
|
|
5424
5328
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5425
5329
|
return table2.rows > 0 ? table2 : null;
|
|
5426
5330
|
}
|
|
@@ -5437,8 +5341,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5437
5341
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5438
5342
|
const cs = rec.data.readUInt16LE(12);
|
|
5439
5343
|
const rs = rec.data.readUInt16LE(14);
|
|
5440
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5441
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5344
|
+
if (cs > 0) colSpan = Math.min(cs, _chunk6XAAYAWLcjs.MAX_COLS);
|
|
5345
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunk6XAAYAWLcjs.MAX_ROWS);
|
|
5442
5346
|
}
|
|
5443
5347
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5444
5348
|
const parts = [];
|
|
@@ -5448,7 +5352,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5448
5352
|
parts.push(``);
|
|
5449
5353
|
hasStructure = true;
|
|
5450
5354
|
} else if (b.type === "table" && b.table) {
|
|
5451
|
-
const flat =
|
|
5355
|
+
const flat = _chunk6XAAYAWLcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5452
5356
|
if (flat) parts.push(flat);
|
|
5453
5357
|
hasStructure = true;
|
|
5454
5358
|
} else if (b.text) {
|
|
@@ -5545,8 +5449,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
5545
5449
|
if (data.length < 73) return null;
|
|
5546
5450
|
const binDataId = data.readUInt16LE(71);
|
|
5547
5451
|
if (binDataId === 0) return null;
|
|
5548
|
-
const item = _optionalChain([ctx, 'access',
|
|
5549
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
5452
|
+
const item = _optionalChain([ctx, 'access', _111 => _111.docInfo, 'optionalAccess', _112 => _112.binData, 'access', _113 => _113[binDataId - 1]]);
|
|
5453
|
+
if (_optionalChain([item, 'optionalAccess', _114 => _114.kind]) === "link") {
|
|
5550
5454
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
5551
5455
|
return null;
|
|
5552
5456
|
}
|
|
@@ -17877,15 +17781,15 @@ function getElements(parent, tagName) {
|
|
|
17877
17781
|
const result = [];
|
|
17878
17782
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
17879
17783
|
if (result.length > 0) return result;
|
|
17880
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
17784
|
+
const nsNodes = _optionalChain([parent, 'access', _115 => _115.getElementsByTagNameNS, 'optionalCall', _116 => _116("*", tagName)]);
|
|
17881
17785
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
17882
17786
|
return result;
|
|
17883
17787
|
}
|
|
17884
17788
|
function getTextContent(el) {
|
|
17885
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
17789
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _117 => _117.textContent, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]), () => ( ""));
|
|
17886
17790
|
}
|
|
17887
17791
|
function parseXml(text) {
|
|
17888
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17792
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17889
17793
|
}
|
|
17890
17794
|
function parseSharedStrings(xml) {
|
|
17891
17795
|
const doc = parseXml(xml);
|
|
@@ -18022,14 +17926,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
18022
17926
|
const merge = mergeMap.get(key);
|
|
18023
17927
|
row.push({
|
|
18024
17928
|
text,
|
|
18025
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18026
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17929
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _120 => _120.colSpan]), () => ( 1)),
|
|
17930
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _121 => _121.rowSpan]), () => ( 1))
|
|
18027
17931
|
});
|
|
18028
17932
|
}
|
|
18029
17933
|
cellRows.push(row);
|
|
18030
17934
|
}
|
|
18031
17935
|
if (cellRows.length > 0) {
|
|
18032
|
-
const table2 =
|
|
17936
|
+
const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
|
|
18033
17937
|
if (table2.rows > 0) {
|
|
18034
17938
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18035
17939
|
}
|
|
@@ -18037,12 +17941,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
18037
17941
|
return blocks;
|
|
18038
17942
|
}
|
|
18039
17943
|
async function parseXlsxDocument(buffer, options) {
|
|
18040
|
-
|
|
17944
|
+
_chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
18041
17945
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18042
17946
|
const warnings = [];
|
|
18043
17947
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18044
17948
|
if (!workbookFile) {
|
|
18045
|
-
throw new (0,
|
|
17949
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18046
17950
|
}
|
|
18047
17951
|
let sharedStrings = [];
|
|
18048
17952
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18051,7 +17955,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18051
17955
|
}
|
|
18052
17956
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
18053
17957
|
if (sheets.length === 0) {
|
|
18054
|
-
throw new (0,
|
|
17958
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18055
17959
|
}
|
|
18056
17960
|
let relsMap = /* @__PURE__ */ new Map();
|
|
18057
17961
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -18059,8 +17963,8 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18059
17963
|
relsMap = parseRels(await relsFile.async("text"));
|
|
18060
17964
|
}
|
|
18061
17965
|
let pageFilter = null;
|
|
18062
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18063
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
17966
|
+
if (_optionalChain([options, 'optionalAccess', _122 => _122.pages])) {
|
|
17967
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18064
17968
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
18065
17969
|
}
|
|
18066
17970
|
const blocks = [];
|
|
@@ -18068,7 +17972,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18068
17972
|
for (let i = 0; i < processedSheets; i++) {
|
|
18069
17973
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18070
17974
|
const sheet = sheets[i];
|
|
18071
|
-
_optionalChain([options, 'optionalAccess',
|
|
17975
|
+
_optionalChain([options, 'optionalAccess', _123 => _123.onProgress, 'optionalCall', _124 => _124(i + 1, processedSheets)]);
|
|
18072
17976
|
let sheetPath = relsMap.get(sheet.rId);
|
|
18073
17977
|
if (sheetPath) {
|
|
18074
17978
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -18123,7 +18027,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18123
18027
|
} catch (e28) {
|
|
18124
18028
|
}
|
|
18125
18029
|
}
|
|
18126
|
-
const markdown =
|
|
18030
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18127
18031
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18128
18032
|
}
|
|
18129
18033
|
|
|
@@ -18530,11 +18434,11 @@ function processGlobals(records) {
|
|
|
18530
18434
|
let encrypted = false;
|
|
18531
18435
|
const firstBof = records[0];
|
|
18532
18436
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18533
|
-
throw new (0,
|
|
18437
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18534
18438
|
}
|
|
18535
18439
|
const bof = decodeBof(firstBof.data);
|
|
18536
18440
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18537
|
-
throw new (0,
|
|
18441
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18538
18442
|
}
|
|
18539
18443
|
let i = 1;
|
|
18540
18444
|
while (i < records.length) {
|
|
@@ -18642,14 +18546,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
18642
18546
|
const merge = mergeMap.get(key);
|
|
18643
18547
|
row.push({
|
|
18644
18548
|
text: grid[r][c],
|
|
18645
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18646
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
18549
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _125 => _125.colSpan]), () => ( 1)),
|
|
18550
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _126 => _126.rowSpan]), () => ( 1))
|
|
18647
18551
|
});
|
|
18648
18552
|
}
|
|
18649
18553
|
cellRows.push(row);
|
|
18650
18554
|
}
|
|
18651
18555
|
if (cellRows.length > 0) {
|
|
18652
|
-
const table2 =
|
|
18556
|
+
const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
|
|
18653
18557
|
if (table2.rows > 0) {
|
|
18654
18558
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18655
18559
|
}
|
|
@@ -18662,21 +18566,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18662
18566
|
try {
|
|
18663
18567
|
cfb = parseLenientCfb(buf);
|
|
18664
18568
|
} catch (e) {
|
|
18665
|
-
throw new (0,
|
|
18569
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
18666
18570
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18667
18571
|
);
|
|
18668
18572
|
}
|
|
18669
18573
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18670
18574
|
if (!wb) {
|
|
18671
|
-
throw new (0,
|
|
18575
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18672
18576
|
}
|
|
18673
18577
|
const records = readRecords2(wb);
|
|
18674
18578
|
if (records.length === 0) {
|
|
18675
|
-
throw new (0,
|
|
18579
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18676
18580
|
}
|
|
18677
18581
|
const firstBof = decodeBof(records[0].data);
|
|
18678
18582
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18679
|
-
throw new (0,
|
|
18583
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
18680
18584
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18681
18585
|
);
|
|
18682
18586
|
}
|
|
@@ -18697,8 +18601,8 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18697
18601
|
}
|
|
18698
18602
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18699
18603
|
let pageFilter = null;
|
|
18700
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
18701
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
18604
|
+
if (_optionalChain([options, 'optionalAccess', _127 => _127.pages])) {
|
|
18605
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
18702
18606
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18703
18607
|
}
|
|
18704
18608
|
const allBlocks = [];
|
|
@@ -18706,7 +18610,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18706
18610
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
18707
18611
|
const meta = globals.sheets[i];
|
|
18708
18612
|
if (meta.dt !== 0) continue;
|
|
18709
|
-
_optionalChain([options, 'optionalAccess',
|
|
18613
|
+
_optionalChain([options, 'optionalAccess', _128 => _128.onProgress, 'optionalCall', _129 => _129(i + 1, totalSheets)]);
|
|
18710
18614
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
18711
18615
|
if (bofIdx < 0) {
|
|
18712
18616
|
warnings.push({
|
|
@@ -18736,7 +18640,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18736
18640
|
pageCount: totalSheets
|
|
18737
18641
|
};
|
|
18738
18642
|
return {
|
|
18739
|
-
markdown:
|
|
18643
|
+
markdown: _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18740
18644
|
blocks: allBlocks,
|
|
18741
18645
|
metadata,
|
|
18742
18646
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18749,7 +18653,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18749
18653
|
|
|
18750
18654
|
// src/docx/equation.ts
|
|
18751
18655
|
function lname(el) {
|
|
18752
|
-
return el.localName || _optionalChain([el, 'access',
|
|
18656
|
+
return el.localName || _optionalChain([el, 'access', _130 => _130.tagName, 'optionalAccess', _131 => _131.replace, 'call', _132 => _132(/^[^:]+:/, "")]) || "";
|
|
18753
18657
|
}
|
|
18754
18658
|
function kids(parent, name) {
|
|
18755
18659
|
const out = [];
|
|
@@ -19122,7 +19026,7 @@ function isDisplayMath(el) {
|
|
|
19122
19026
|
// src/docx/parser.ts
|
|
19123
19027
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
19124
19028
|
function matchesLocal(el, localName2) {
|
|
19125
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
19029
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _133 => _133.tagName, 'optionalAccess', _134 => _134.endsWith, 'call', _135 => _135(`:${localName2}`)]), () => ( false)));
|
|
19126
19030
|
}
|
|
19127
19031
|
function effectiveChildElements(parent) {
|
|
19128
19032
|
const result = [];
|
|
@@ -19155,7 +19059,7 @@ function findElements(parent, localName2) {
|
|
|
19155
19059
|
const child = children[i];
|
|
19156
19060
|
if (child.nodeType === 1) {
|
|
19157
19061
|
const el = child;
|
|
19158
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
19062
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _136 => _136.tagName, 'optionalAccess', _137 => _137.endsWith, 'call', _138 => _138(`:${localName2}`)])) {
|
|
19159
19063
|
result.push(el);
|
|
19160
19064
|
}
|
|
19161
19065
|
walk(el);
|
|
@@ -19174,7 +19078,7 @@ function getAttr(el, localName2) {
|
|
|
19174
19078
|
return null;
|
|
19175
19079
|
}
|
|
19176
19080
|
function parseXml2(text) {
|
|
19177
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19081
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk6XAAYAWLcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19178
19082
|
}
|
|
19179
19083
|
function parseStyles(xml) {
|
|
19180
19084
|
const doc = parseXml2(xml);
|
|
@@ -19276,7 +19180,7 @@ function collectOmmlRoots(p) {
|
|
|
19276
19180
|
const child = children[i];
|
|
19277
19181
|
if (child.nodeType !== 1) continue;
|
|
19278
19182
|
const el = child;
|
|
19279
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
19183
|
+
const tag = el.localName || _optionalChain([el, 'access', _139 => _139.tagName, 'optionalAccess', _140 => _140.replace, 'call', _141 => _141(/^[^:]+:/, "")]) || "";
|
|
19280
19184
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
19281
19185
|
out.push(el);
|
|
19282
19186
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -19313,7 +19217,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19313
19217
|
function makeLink(text, rawHref) {
|
|
19314
19218
|
if (!text) return "";
|
|
19315
19219
|
if (!rawHref) return text;
|
|
19316
|
-
const href =
|
|
19220
|
+
const href = _chunk6XAAYAWLcjs.sanitizeHref.call(void 0, rawHref);
|
|
19317
19221
|
return href ? `[${text}](${href})` : text;
|
|
19318
19222
|
}
|
|
19319
19223
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19415,7 +19319,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19415
19319
|
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
19416
19320
|
if (!text) return null;
|
|
19417
19321
|
const style = styles.get(styleId);
|
|
19418
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
19322
|
+
if (_optionalChain([style, 'optionalAccess', _142 => _142.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
19419
19323
|
return {
|
|
19420
19324
|
type: "heading",
|
|
19421
19325
|
text,
|
|
@@ -19424,8 +19328,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
19424
19328
|
}
|
|
19425
19329
|
if (numId && numId !== "0") {
|
|
19426
19330
|
const numDef = numbering.get(numId);
|
|
19427
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
19428
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
19331
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _143 => _143.get, 'call', _144 => _144(ilvl)]);
|
|
19332
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _145 => _145.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
19429
19333
|
return { type: "list", text, listType };
|
|
19430
19334
|
}
|
|
19431
19335
|
const block = { type: "paragraph", text };
|
|
@@ -19507,7 +19411,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19507
19411
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19508
19412
|
})
|
|
19509
19413
|
);
|
|
19510
|
-
const table2 =
|
|
19414
|
+
const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
|
|
19511
19415
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19512
19416
|
return { type: "table", table: table2 };
|
|
19513
19417
|
}
|
|
@@ -19517,10 +19421,10 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
19517
19421
|
for (const el of effectiveChildElements(tc2)) {
|
|
19518
19422
|
if (matchesLocal(el, "p")) {
|
|
19519
19423
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19520
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
19424
|
+
if (_optionalChain([block, 'optionalAccess', _146 => _146.text])) parts.push(block.text);
|
|
19521
19425
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19522
19426
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19523
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
19427
|
+
if (_optionalChain([tb, 'optionalAccess', _147 => _147.text])) parts.push(tb.text);
|
|
19524
19428
|
}
|
|
19525
19429
|
} else if (matchesLocal(el, "tbl")) {
|
|
19526
19430
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -19536,9 +19440,17 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19536
19440
|
const imageMap = /* @__PURE__ */ new Map();
|
|
19537
19441
|
const images = [];
|
|
19538
19442
|
let imgIdx = 0;
|
|
19443
|
+
const imageRefs = [];
|
|
19539
19444
|
for (const blip of findElements(doc.documentElement, "blip")) {
|
|
19540
19445
|
const embedId = getAttr(blip, "embed");
|
|
19541
|
-
if (
|
|
19446
|
+
if (embedId) imageRefs.push(embedId);
|
|
19447
|
+
}
|
|
19448
|
+
for (const imagedata of collectNonFallbackImagedata(doc.documentElement)) {
|
|
19449
|
+
const embedId = getAttr(imagedata, "id");
|
|
19450
|
+
if (embedId) imageRefs.push(embedId);
|
|
19451
|
+
}
|
|
19452
|
+
for (const embedId of imageRefs) {
|
|
19453
|
+
if (imageMap.has(embedId)) continue;
|
|
19542
19454
|
const target = rels.get(embedId);
|
|
19543
19455
|
if (!target) continue;
|
|
19544
19456
|
const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
|
|
@@ -19547,7 +19459,7 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19547
19459
|
try {
|
|
19548
19460
|
const data = await imgFile.async("uint8array");
|
|
19549
19461
|
imgIdx++;
|
|
19550
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
19462
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _148 => _148.split, 'call', _149 => _149("."), 'access', _150 => _150.pop, 'call', _151 => _151(), 'optionalAccess', _152 => _152.toLowerCase, 'call', _153 => _153()]), () => ( "png"));
|
|
19551
19463
|
const mimeMap = {
|
|
19552
19464
|
png: "image/png",
|
|
19553
19465
|
jpg: "image/jpeg",
|
|
@@ -19573,14 +19485,26 @@ function collectParagraphBlips(node, out = [], depth = 0) {
|
|
|
19573
19485
|
if (depth > 40) return out;
|
|
19574
19486
|
for (const el of effectiveChildElements(node)) {
|
|
19575
19487
|
if (matchesLocal(el, "txbxContent") || matchesLocal(el, "Fallback")) continue;
|
|
19576
|
-
if (matchesLocal(el, "blip")) out.push(el);
|
|
19488
|
+
if (matchesLocal(el, "blip") || matchesLocal(el, "imagedata")) out.push(el);
|
|
19577
19489
|
else collectParagraphBlips(el, out, depth + 1);
|
|
19578
19490
|
}
|
|
19579
19491
|
return out;
|
|
19580
19492
|
}
|
|
19493
|
+
function collectNonFallbackImagedata(node, out = [], depth = 0) {
|
|
19494
|
+
if (depth > 60) return out;
|
|
19495
|
+
const children = node.childNodes;
|
|
19496
|
+
for (let i = 0; i < children.length; i++) {
|
|
19497
|
+
if (children[i].nodeType !== 1) continue;
|
|
19498
|
+
const el = children[i];
|
|
19499
|
+
if (matchesLocal(el, "Fallback")) continue;
|
|
19500
|
+
if (matchesLocal(el, "imagedata")) out.push(el);
|
|
19501
|
+
else collectNonFallbackImagedata(el, out, depth + 1);
|
|
19502
|
+
}
|
|
19503
|
+
return out;
|
|
19504
|
+
}
|
|
19581
19505
|
function emitParagraphImages(p, imageMap, linked, out) {
|
|
19582
19506
|
for (const blip of collectParagraphBlips(p)) {
|
|
19583
|
-
const embedId = getAttr(blip, "embed");
|
|
19507
|
+
const embedId = _nullishCoalesce(getAttr(blip, "embed"), () => ( getAttr(blip, "id")));
|
|
19584
19508
|
if (!embedId) continue;
|
|
19585
19509
|
const filename = imageMap.get(embedId);
|
|
19586
19510
|
if (!filename) continue;
|
|
@@ -19589,12 +19513,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19589
19513
|
}
|
|
19590
19514
|
}
|
|
19591
19515
|
async function parseDocxDocument(buffer, options) {
|
|
19592
|
-
|
|
19516
|
+
_chunk6XAAYAWLcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
19593
19517
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19594
19518
|
const warnings = [];
|
|
19595
19519
|
const docFile = zip.file("word/document.xml");
|
|
19596
19520
|
if (!docFile) {
|
|
19597
|
-
throw new (0,
|
|
19521
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19598
19522
|
}
|
|
19599
19523
|
let rels = /* @__PURE__ */ new Map();
|
|
19600
19524
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19641,7 +19565,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19641
19565
|
const doc = parseXml2(docXml);
|
|
19642
19566
|
const body = findElements(doc, "body");
|
|
19643
19567
|
if (body.length === 0) {
|
|
19644
|
-
throw new (0,
|
|
19568
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19645
19569
|
}
|
|
19646
19570
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19647
19571
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19649,7 +19573,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19649
19573
|
const bodyEl = body[0];
|
|
19650
19574
|
const topLevel = effectiveChildElements(bodyEl);
|
|
19651
19575
|
for (const el of topLevel) {
|
|
19652
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
19576
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _154 => _154.tagName, 'optionalAccess', _155 => _155.split, 'call', _156 => _156(":"), 'access', _157 => _157.pop, 'call', _158 => _158()])));
|
|
19653
19577
|
if (localName2 === "p") {
|
|
19654
19578
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19655
19579
|
if (block) blocks.push(block);
|
|
@@ -19692,7 +19616,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19692
19616
|
}
|
|
19693
19617
|
}
|
|
19694
19618
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19695
|
-
const markdown =
|
|
19619
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19696
19620
|
return {
|
|
19697
19621
|
markdown,
|
|
19698
19622
|
blocks,
|
|
@@ -19715,7 +19639,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19715
19639
|
}
|
|
19716
19640
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19717
19641
|
const normalized = text.replace(/ /g, " ");
|
|
19718
|
-
const xml =
|
|
19642
|
+
const xml = _chunk6XAAYAWLcjs.stripDtd.call(void 0, normalized);
|
|
19719
19643
|
const warnings = [];
|
|
19720
19644
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19721
19645
|
onError: (_level, msg2) => {
|
|
@@ -19743,7 +19667,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19743
19667
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
19744
19668
|
}
|
|
19745
19669
|
const blocks = [];
|
|
19746
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
19670
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _159 => _159.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
19747
19671
|
let sectionIdx = 0;
|
|
19748
19672
|
const children = body.childNodes;
|
|
19749
19673
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -19755,7 +19679,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19755
19679
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
19756
19680
|
}
|
|
19757
19681
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
19758
|
-
const markdown =
|
|
19682
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19759
19683
|
return {
|
|
19760
19684
|
markdown,
|
|
19761
19685
|
blocks,
|
|
@@ -19841,7 +19765,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
19841
19765
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
19842
19766
|
const text = extractParagraphText(el);
|
|
19843
19767
|
if (!text) return;
|
|
19844
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
19768
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _160 => _160.headingLevel]) != null) {
|
|
19845
19769
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
19846
19770
|
} else {
|
|
19847
19771
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -19913,7 +19837,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
19913
19837
|
const cellRows = grid.map(
|
|
19914
19838
|
(row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
19915
19839
|
);
|
|
19916
|
-
const table2 =
|
|
19840
|
+
const table2 = _chunk6XAAYAWLcjs.buildTable.call(void 0, cellRows);
|
|
19917
19841
|
const caption = extractShapeCaption(el);
|
|
19918
19842
|
if (caption.text && caption.before) {
|
|
19919
19843
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20173,7 +20097,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
20173
20097
|
(match, prefix, suffix) => {
|
|
20174
20098
|
const label = prefix + suffix;
|
|
20175
20099
|
const normalizedLabel = normalizeLabel(label);
|
|
20176
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20100
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _161 => _161.has, 'call', _162 => _162(normalizedLabel)])) return match;
|
|
20177
20101
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
20178
20102
|
if (matchKey === void 0) return match;
|
|
20179
20103
|
const newValue = values.consume(matchKey);
|
|
@@ -20423,8 +20347,8 @@ function extractFromTable(table2) {
|
|
|
20423
20347
|
if (table2.cols >= 2) {
|
|
20424
20348
|
for (let r = 0; r < table2.rows; r++) {
|
|
20425
20349
|
for (let c = 0; c < table2.cols - 1; c++) {
|
|
20426
|
-
const labelCell = _optionalChain([table2, 'access',
|
|
20427
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20350
|
+
const labelCell = _optionalChain([table2, 'access', _163 => _163.cells, 'access', _164 => _164[r], 'optionalAccess', _165 => _165[c]]);
|
|
20351
|
+
const valueCell = _optionalChain([table2, 'access', _166 => _166.cells, 'access', _167 => _167[r], 'optionalAccess', _168 => _168[c + 1]]);
|
|
20428
20352
|
if (!labelCell || !valueCell) continue;
|
|
20429
20353
|
if (isLabelCell(labelCell.text)) {
|
|
20430
20354
|
fields.push({
|
|
@@ -20446,8 +20370,8 @@ function extractFromTable(table2) {
|
|
|
20446
20370
|
if (allLabels) {
|
|
20447
20371
|
for (let r = 1; r < table2.rows; r++) {
|
|
20448
20372
|
for (let c = 0; c < table2.cols; c++) {
|
|
20449
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
20450
|
-
const value = _nullishCoalesce(_optionalChain([table2, 'access',
|
|
20373
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _169 => _169[c], 'optionalAccess', _170 => _170.text, 'access', _171 => _171.trim, 'call', _172 => _172()]), () => ( ""));
|
|
20374
|
+
const value = _nullishCoalesce(_optionalChain([table2, 'access', _173 => _173.cells, 'access', _174 => _174[r], 'optionalAccess', _175 => _175[c], 'optionalAccess', _176 => _176.text, 'access', _177 => _177.trim, 'call', _178 => _178()]), () => ( ""));
|
|
20451
20375
|
if (label && value) {
|
|
20452
20376
|
fields.push({ label, value, row: r, col: c });
|
|
20453
20377
|
}
|
|
@@ -20540,7 +20464,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
20540
20464
|
for (const table2 of allTables) {
|
|
20541
20465
|
for (let r = 0; r < table2.rows; r++) {
|
|
20542
20466
|
for (let c = 0; c < table2.cols; c++) {
|
|
20543
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20467
|
+
const cell2 = _optionalChain([table2, 'access', _179 => _179.cells, 'access', _180 => _180[r], 'optionalAccess', _181 => _181[c]]);
|
|
20544
20468
|
if (!cell2) continue;
|
|
20545
20469
|
const result = fillInCellPatterns(cell2.text, cursor, matchedLabels, blockedLabels);
|
|
20546
20470
|
if (result) {
|
|
@@ -20572,7 +20496,7 @@ function collectIRTables(blocks, depth) {
|
|
|
20572
20496
|
out.push(block.table);
|
|
20573
20497
|
for (const row of block.table.cells) {
|
|
20574
20498
|
for (const cell2 of row) {
|
|
20575
|
-
if (_optionalChain([cell2, 'optionalAccess',
|
|
20499
|
+
if (_optionalChain([cell2, 'optionalAccess', _182 => _182.blocks, 'optionalAccess', _183 => _183.length])) out.push(...collectIRTables(cell2.blocks, depth + 1));
|
|
20576
20500
|
}
|
|
20577
20501
|
}
|
|
20578
20502
|
}
|
|
@@ -20583,7 +20507,7 @@ function coveredPositions(table2) {
|
|
|
20583
20507
|
for (let r = 0; r < table2.rows; r++) {
|
|
20584
20508
|
for (let c = 0; c < table2.cols; c++) {
|
|
20585
20509
|
if (covered.has(`${r},${c}`)) continue;
|
|
20586
|
-
const cell2 = _optionalChain([table2, 'access',
|
|
20510
|
+
const cell2 = _optionalChain([table2, 'access', _184 => _184.cells, 'access', _185 => _185[r], 'optionalAccess', _186 => _186[c]]);
|
|
20587
20511
|
if (!cell2) continue;
|
|
20588
20512
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
20589
20513
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -20613,12 +20537,12 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20613
20537
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
20614
20538
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
20615
20539
|
if (!normalizedCellLabel) continue;
|
|
20616
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20540
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _187 => _187.has, 'call', _188 => _188(normalizedCellLabel)])) continue;
|
|
20617
20541
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
20618
20542
|
if (matchKey === void 0) continue;
|
|
20619
20543
|
const newValue = values.consume(matchKey);
|
|
20620
20544
|
if (newValue === void 0) continue;
|
|
20621
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
20545
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _189 => _189.has, 'call', _190 => _190(valueCell)])) {
|
|
20622
20546
|
valueCell.text = newValue + " " + valueCell.text;
|
|
20623
20547
|
} else {
|
|
20624
20548
|
valueCell.text = newValue;
|
|
@@ -20644,10 +20568,10 @@ function fillTable(table2, values, filled, matchedLabels, patternFilledCells, bl
|
|
|
20644
20568
|
for (let c = 0; c < table2.cols; c++) {
|
|
20645
20569
|
if (covered.has(`${r},${c}`)) continue;
|
|
20646
20570
|
const headerCell = headerRow[c];
|
|
20647
|
-
const valueCell = _optionalChain([table2, 'access',
|
|
20571
|
+
const valueCell = _optionalChain([table2, 'access', _191 => _191.cells, 'access', _192 => _192[r], 'optionalAccess', _193 => _193[c]]);
|
|
20648
20572
|
if (!headerCell || !valueCell) continue;
|
|
20649
20573
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
20650
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20574
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _194 => _194.has, 'call', _195 => _195(headerLabel)])) continue;
|
|
20651
20575
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
20652
20576
|
if (matchKey === void 0) continue;
|
|
20653
20577
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -20673,7 +20597,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
20673
20597
|
let pos = 0;
|
|
20674
20598
|
for (const seg of segments) {
|
|
20675
20599
|
const nlabel = normalizeLabel(seg.label);
|
|
20676
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20600
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _196 => _196.has, 'call', _197 => _197(nlabel)])) continue;
|
|
20677
20601
|
const matchKey = findMatchingKey(nlabel, values);
|
|
20678
20602
|
if (matchKey === void 0) continue;
|
|
20679
20603
|
const newValue = values.consume(matchKey);
|
|
@@ -21241,19 +21165,19 @@ function parseCentralDirectory(buf) {
|
|
|
21241
21165
|
}
|
|
21242
21166
|
}
|
|
21243
21167
|
}
|
|
21244
|
-
if (eocdOffset < 0) throw new (0,
|
|
21168
|
+
if (eocdOffset < 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21245
21169
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21246
21170
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21247
21171
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21248
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21172
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21249
21173
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21250
|
-
throw new (0,
|
|
21174
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21251
21175
|
}
|
|
21252
21176
|
const decoder = new TextDecoder("utf-8");
|
|
21253
21177
|
const entries = [];
|
|
21254
21178
|
let pos = cdOffset;
|
|
21255
21179
|
for (let i = 0; i < totalEntries; i++) {
|
|
21256
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21180
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21257
21181
|
const flags = view.getUint16(pos + 8, true);
|
|
21258
21182
|
const method = view.getUint16(pos + 10, true);
|
|
21259
21183
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21264,7 +21188,7 @@ function parseCentralDirectory(buf) {
|
|
|
21264
21188
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21265
21189
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21266
21190
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21267
|
-
throw new (0,
|
|
21191
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21268
21192
|
}
|
|
21269
21193
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21270
21194
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21273,7 +21197,7 @@ function parseCentralDirectory(buf) {
|
|
|
21273
21197
|
}
|
|
21274
21198
|
return { entries, cdOffset, cdSize, eocdOffset };
|
|
21275
21199
|
}
|
|
21276
|
-
var
|
|
21200
|
+
var CRC_TABLE = (() => {
|
|
21277
21201
|
const table2 = new Uint32Array(256);
|
|
21278
21202
|
for (let n = 0; n < 256; n++) {
|
|
21279
21203
|
let c = n;
|
|
@@ -21282,10 +21206,10 @@ var CRC_TABLE2 = (() => {
|
|
|
21282
21206
|
}
|
|
21283
21207
|
return table2;
|
|
21284
21208
|
})();
|
|
21285
|
-
function
|
|
21209
|
+
function crc32(data) {
|
|
21286
21210
|
let crc = 4294967295;
|
|
21287
21211
|
for (let i = 0; i < data.length; i++) {
|
|
21288
|
-
crc =
|
|
21212
|
+
crc = CRC_TABLE[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
21289
21213
|
}
|
|
21290
21214
|
return (crc ^ 4294967295) >>> 0;
|
|
21291
21215
|
}
|
|
@@ -21293,11 +21217,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21293
21217
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21294
21218
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21295
21219
|
for (const name of replacements.keys()) {
|
|
21296
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21220
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21297
21221
|
}
|
|
21298
21222
|
if (additions) {
|
|
21299
21223
|
for (const name of additions.keys()) {
|
|
21300
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21224
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21301
21225
|
}
|
|
21302
21226
|
}
|
|
21303
21227
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21316,7 +21240,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21316
21240
|
offset += seg.length;
|
|
21317
21241
|
continue;
|
|
21318
21242
|
}
|
|
21319
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21243
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunk6XAAYAWLcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21320
21244
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21321
21245
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21322
21246
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21324,7 +21248,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21324
21248
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21325
21249
|
const method = e.method;
|
|
21326
21250
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21327
|
-
const crc =
|
|
21251
|
+
const crc = crc32(newData);
|
|
21328
21252
|
const flags = e.flags & ~8;
|
|
21329
21253
|
hview.setUint16(6, flags, true);
|
|
21330
21254
|
hview.setUint32(14, crc, true);
|
|
@@ -21342,7 +21266,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21342
21266
|
const deflated = new Uint8Array(_zlib.deflateRawSync.call(void 0, data));
|
|
21343
21267
|
const method = deflated.length < data.length ? 8 : 0;
|
|
21344
21268
|
const compData = method === 8 ? deflated : data;
|
|
21345
|
-
const crc =
|
|
21269
|
+
const crc = crc32(data);
|
|
21346
21270
|
const header = new Uint8Array(30 + nameBytes.length);
|
|
21347
21271
|
const hv = new DataView(header.buffer);
|
|
21348
21272
|
hv.setUint32(0, LOCAL_SIG, true);
|
|
@@ -21422,7 +21346,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21422
21346
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21423
21347
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21424
21348
|
if (sectionPaths.length === 0) {
|
|
21425
|
-
throw new (0,
|
|
21349
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21426
21350
|
}
|
|
21427
21351
|
const normalizedValues = normalizeValues(values);
|
|
21428
21352
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -21495,7 +21419,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21495
21419
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
21496
21420
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
21497
21421
|
if (!normalizedCellLabel) continue;
|
|
21498
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21422
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _198 => _198.has, 'call', _199 => _199(normalizedCellLabel)])) continue;
|
|
21499
21423
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
21500
21424
|
if (matchKey === void 0) continue;
|
|
21501
21425
|
if (patternApplied.has(valueCell)) {
|
|
@@ -21553,7 +21477,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21553
21477
|
const dataCells = table2.rows[rowIdx];
|
|
21554
21478
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
21555
21479
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
21556
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21480
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _200 => _200.has, 'call', _201 => _201(headerLabel)])) continue;
|
|
21557
21481
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
21558
21482
|
if (matchKey === void 0) continue;
|
|
21559
21483
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -21586,11 +21510,11 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21586
21510
|
}
|
|
21587
21511
|
for (const para2 of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
21588
21512
|
const existing = ledger.get(para2);
|
|
21589
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
21513
|
+
if (_optionalChain([existing, 'optionalAccess', _202 => _202.fullText]) !== void 0) continue;
|
|
21590
21514
|
const text = matchText(para2);
|
|
21591
21515
|
for (const seg of scanInlineSegments(text)) {
|
|
21592
21516
|
const nlabel = normalizeLabel(seg.label);
|
|
21593
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
21517
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _203 => _203.has, 'call', _204 => _204(nlabel)])) continue;
|
|
21594
21518
|
const matchKey = findMatchingKey(nlabel, cursor);
|
|
21595
21519
|
if (matchKey === void 0) continue;
|
|
21596
21520
|
const newValue = cursor.consume(matchKey);
|
|
@@ -21699,16 +21623,16 @@ var PARA_LIST = 7;
|
|
|
21699
21623
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
21700
21624
|
function resolveTheme(theme) {
|
|
21701
21625
|
return {
|
|
21702
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21703
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21704
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21705
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21706
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21707
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21626
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _205 => _205.headingColors, 'optionalAccess', _206 => _206[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21627
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _207 => _207.headingColors, 'optionalAccess', _208 => _208[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21628
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _209 => _209.headingColors, 'optionalAccess', _210 => _210[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21629
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _211 => _211.headingColors, 'optionalAccess', _212 => _212[4]]), () => ( _optionalChain([theme, 'optionalAccess', _213 => _213.headingColors, 'optionalAccess', _214 => _214[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21630
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _215 => _215.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21631
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _216 => _216.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21708
21632
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
21709
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
21710
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21711
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
21633
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _217 => _217.quoteColor]) !== void 0,
|
|
21634
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _218 => _218.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _219 => _219.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21635
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _220 => _220.tableHeaderBold])
|
|
21712
21636
|
};
|
|
21713
21637
|
}
|
|
21714
21638
|
function escapeXml(text) {
|
|
@@ -22111,7 +22035,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22111
22035
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22112
22036
|
const got = m ? Number(m[1]) : NaN;
|
|
22113
22037
|
if (got !== startId + i) {
|
|
22114
|
-
throw new (0,
|
|
22038
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
22115
22039
|
`\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)`
|
|
22116
22040
|
);
|
|
22117
22041
|
}
|
|
@@ -22195,7 +22119,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22195
22119
|
}
|
|
22196
22120
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22197
22121
|
if (rows.length !== expectedBase) {
|
|
22198
|
-
throw new (0,
|
|
22122
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
22199
22123
|
`\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`
|
|
22200
22124
|
);
|
|
22201
22125
|
}
|
|
@@ -22422,7 +22346,7 @@ function buildStyles(gongmun) {
|
|
|
22422
22346
|
</hh:styles>`;
|
|
22423
22347
|
}
|
|
22424
22348
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = [], listIndentVariants = [], extraFonts = []) {
|
|
22425
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
22349
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _221 => _221.fonts, 'access', _222 => _222.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _223 => _223.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
22426
22350
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
22427
22351
|
const paraPropsXml = buildParaProperties(gongmun, gongmun ? listIndentVariants : []);
|
|
22428
22352
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22551,8 +22475,8 @@ function parseChartFence(text) {
|
|
|
22551
22475
|
const spec = chartSpec(type);
|
|
22552
22476
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22553
22477
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22554
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22555
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22478
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _224 => _224.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
22479
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _225 => _225[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22556
22480
|
if (!spec.scatter) {
|
|
22557
22481
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22558
22482
|
}
|
|
@@ -22594,7 +22518,7 @@ function serSpPr(color, stroke) {
|
|
|
22594
22518
|
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>`;
|
|
22595
22519
|
}
|
|
22596
22520
|
function dPtXml(pointColors, pie) {
|
|
22597
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
22521
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _226 => _226.length])) return "";
|
|
22598
22522
|
return pointColors.map((col, i) => {
|
|
22599
22523
|
const f = chartColorFill(col);
|
|
22600
22524
|
if (!f) return "";
|
|
@@ -22833,8 +22757,8 @@ function buildGaejosikCover(title, gongmun, bodyWidth = GAEJOSIK_BASE_WIDTH) {
|
|
|
22833
22757
|
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 });
|
|
22834
22758
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3, 1, bodyWidth);
|
|
22835
22759
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
22836
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22837
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22760
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _227 => _227.cover, 'optionalAccess', _228 => _228.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
22761
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _229 => _229.cover, 'optionalAccess', _230 => _230.org]), () => ( ""));
|
|
22838
22762
|
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>`;
|
|
22839
22763
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
22840
22764
|
return [
|
|
@@ -23070,7 +22994,7 @@ function escapeGfm(text) {
|
|
|
23070
22994
|
}
|
|
23071
22995
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
23072
22996
|
function sanitizeText(text) {
|
|
23073
|
-
let result =
|
|
22997
|
+
let result = _chunk6XAAYAWLcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23074
22998
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23075
22999
|
const tokens = result.split(" ");
|
|
23076
23000
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23100,7 +23024,7 @@ function replicateGfmTable(table2) {
|
|
|
23100
23024
|
for (let r = 0; r < numRows; r++) {
|
|
23101
23025
|
for (let c = 0; c < numCols; c++) {
|
|
23102
23026
|
if (skip.has(`${r},${c}`)) continue;
|
|
23103
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23027
|
+
const cell2 = _optionalChain([cells, 'access', _231 => _231[r], 'optionalAccess', _232 => _232[c]]);
|
|
23104
23028
|
if (!cell2) continue;
|
|
23105
23029
|
display[r][c] = {
|
|
23106
23030
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -23154,7 +23078,7 @@ function unescapeGfmCell(text) {
|
|
|
23154
23078
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
23155
23079
|
}
|
|
23156
23080
|
function replicateCellInnerHtml(cell2) {
|
|
23157
|
-
if (_optionalChain([cell2, 'access',
|
|
23081
|
+
if (_optionalChain([cell2, 'access', _233 => _233.blocks, 'optionalAccess', _234 => _234.length])) {
|
|
23158
23082
|
return cell2.blocks.map((b) => {
|
|
23159
23083
|
if (b.type === "table" && b.table) {
|
|
23160
23084
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -23193,7 +23117,7 @@ function replicateHtmlTable(table2) {
|
|
|
23193
23117
|
const rowCells = [];
|
|
23194
23118
|
for (let c = 0; c < numCols; c++) {
|
|
23195
23119
|
if (skip.has(`${r},${c}`)) continue;
|
|
23196
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
23120
|
+
const cell2 = _optionalChain([cells, 'access', _235 => _235[r], 'optionalAccess', _236 => _236[c]]);
|
|
23197
23121
|
if (!cell2) continue;
|
|
23198
23122
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
23199
23123
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -23239,8 +23163,8 @@ function parseHtmlTable(raw) {
|
|
|
23239
23163
|
}
|
|
23240
23164
|
} else {
|
|
23241
23165
|
if (!isClose) {
|
|
23242
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
23243
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
23166
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _237 => _237.match, 'call', _238 => _238(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _239 => _239[1]]) || "1", 10);
|
|
23167
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _240 => _240.match, 'call', _241 => _241(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _242 => _242[1]]) || "1", 10);
|
|
23244
23168
|
cellStart = m.index + m[0].length;
|
|
23245
23169
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
23246
23170
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -23266,7 +23190,7 @@ function htmlCellInnerToLines(inner) {
|
|
|
23266
23190
|
hadNonText = true;
|
|
23267
23191
|
work = work.replace(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi, (tag) => {
|
|
23268
23192
|
const m = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(tag);
|
|
23269
|
-
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess',
|
|
23193
|
+
const src = _nullishCoalesce(_optionalChain([m, 'optionalAccess', _243 => _243[1]]), () => ( _optionalChain([m, 'optionalAccess', _244 => _244[2]])));
|
|
23270
23194
|
if (src) imgSrcs.push(src);
|
|
23271
23195
|
return "";
|
|
23272
23196
|
});
|
|
@@ -23397,7 +23321,7 @@ function edgeXml(tag, d) {
|
|
|
23397
23321
|
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"/>`;
|
|
23398
23322
|
}
|
|
23399
23323
|
function borderFillDefToXml(id, def) {
|
|
23400
|
-
const fill = _optionalChain([def, 'access',
|
|
23324
|
+
const fill = _optionalChain([def, 'access', _245 => _245.fill, 'optionalAccess', _246 => _246.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${escapeXml(def.fill.faceColor)}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
23401
23325
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
23402
23326
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
23403
23327
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -23802,11 +23726,11 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
23802
23726
|
function generateTable(rows, theme, style = null, remap = null, seq = 0, images = null) {
|
|
23803
23727
|
const rowCnt = rows.length;
|
|
23804
23728
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
23805
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23729
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _247 => _247.bfRegistry]), () => ( null));
|
|
23806
23730
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
23807
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23731
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _248 => _248.charHeight]), () => ( 1e3));
|
|
23808
23732
|
const rowAnchor = normalizeRowAnchor((_nullishCoalesce(rows[0], () => ( []))).map((c) => c.replace(/!\[[^\]]*\]\([^)]*\)/g, "")));
|
|
23809
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
23733
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _249 => _249[0], 'optionalAccess', _250 => _250[0]]), () => ( ""))), seq, rowAnchor);
|
|
23810
23734
|
const colMax = Array(colCnt).fill(0);
|
|
23811
23735
|
const colMaxBody = Array(colCnt).fill(0);
|
|
23812
23736
|
const colMinWord = Array(colCnt).fill(0);
|
|
@@ -23834,7 +23758,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
23834
23758
|
const k = `${rowIdx},${colIdx}`;
|
|
23835
23759
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
23836
23760
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
23837
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23761
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _251 => _251.cellChar, 'access', _252 => _252.get, 'call', _253 => _253(k)]), () => ( defaultCharPr));
|
|
23838
23762
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
23839
23763
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
23840
23764
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
@@ -23852,11 +23776,11 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
23852
23776
|
}
|
|
23853
23777
|
}
|
|
23854
23778
|
}
|
|
23855
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
23779
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _254 => _254.cellChar, 'access', _255 => _255.has, 'call', _256 => _256(k)]) ? void 0 : mapId);
|
|
23856
23780
|
const body = (runs || (picRuns ? "" : `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`)) + picRuns;
|
|
23857
23781
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${body}</hp:p>`;
|
|
23858
23782
|
}).join("");
|
|
23859
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23783
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _257 => _257.cellBf, 'access', _258 => _258.get, 'call', _259 => _259(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
23860
23784
|
row: rowIdx,
|
|
23861
23785
|
rowEnd: rowIdx,
|
|
23862
23786
|
col: colIdx,
|
|
@@ -23866,7 +23790,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
23866
23790
|
headerRows: 1,
|
|
23867
23791
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
23868
23792
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
23869
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23793
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _260 => _260.cellH, 'access', _261 => _261.get, 'call', _262 => _262(k)]), () => ( cellH));
|
|
23870
23794
|
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>`;
|
|
23871
23795
|
}).join("");
|
|
23872
23796
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -23875,7 +23799,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0, images
|
|
|
23875
23799
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
23876
23800
|
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;
|
|
23877
23801
|
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>`;
|
|
23878
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
23802
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _263 => _263.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
23879
23803
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
23880
23804
|
}
|
|
23881
23805
|
function layoutHtmlRows(rows) {
|
|
@@ -23915,7 +23839,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23915
23839
|
if (!rows || rows.length === 0) return null;
|
|
23916
23840
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
23917
23841
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
23918
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23842
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _264 => _264.charHeight]), () => ( 1e3));
|
|
23919
23843
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
23920
23844
|
const row0 = Array.from({ length: colCnt }, () => "");
|
|
23921
23845
|
for (const cell2 of placed) {
|
|
@@ -23944,7 +23868,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23944
23868
|
const tblId = nextTableId();
|
|
23945
23869
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
23946
23870
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
23947
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23871
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _265 => _265.bfRegistry]), () => ( null));
|
|
23948
23872
|
let htmlHeaderRows = 0;
|
|
23949
23873
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
23950
23874
|
const tableRowHeights = Array(rowCnt).fill(cellH);
|
|
@@ -23959,7 +23883,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23959
23883
|
const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
|
|
23960
23884
|
if (nestedXml) {
|
|
23961
23885
|
nestedXmls.push(nestedXml);
|
|
23962
|
-
const szH = _optionalChain([nestedXml, 'access',
|
|
23886
|
+
const szH = _optionalChain([nestedXml, 'access', _266 => _266.match, 'call', _267 => _267(/<hp:sz [^>]*height="(\d+)"/), 'optionalAccess', _268 => _268[1]]);
|
|
23963
23887
|
nestedH += (szH ? Number(szH) : (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH) + 300;
|
|
23964
23888
|
}
|
|
23965
23889
|
}
|
|
@@ -23968,7 +23892,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23968
23892
|
for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
|
|
23969
23893
|
const lineH = style ? Math.round(measureH * 1.6) : 800;
|
|
23970
23894
|
const contentH = Math.max(cellH * rowSpan, Math.max(wrapLines, 1) * lineH + nestedH);
|
|
23971
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23895
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _269 => _269.cellH, 'access', _270 => _270.get, 'call', _271 => _271(`${cell2.r},${cell2.c}`)]), () => ( 0)), contentH);
|
|
23972
23896
|
const perRow = Math.ceil(cellHeight / rowSpan);
|
|
23973
23897
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
|
|
23974
23898
|
return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
|
|
@@ -23979,7 +23903,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23979
23903
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
23980
23904
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
23981
23905
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
23982
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23906
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _272 => _272.cellChar, 'access', _273 => _273.get, 'call', _274 => _274(k)]), () => ( defaultCharPr));
|
|
23983
23907
|
const centered = isHeader || colCentered[cell2.c];
|
|
23984
23908
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
23985
23909
|
const picUrls = images ? [...imgSrcs] : [];
|
|
@@ -24015,7 +23939,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
24015
23939
|
let cellHeight = 0;
|
|
24016
23940
|
for (let r = cell2.r; r < cell2.r + rowSpan; r++) cellHeight += tableRowHeights[r];
|
|
24017
23941
|
const rowEnd = cell2.r + rowSpan - 1;
|
|
24018
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23942
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _275 => _275.cellBf, 'access', _276 => _276.get, 'call', _277 => _277(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
24019
23943
|
row: cell2.r,
|
|
24020
23944
|
rowEnd,
|
|
24021
23945
|
col: cell2.c,
|
|
@@ -24185,7 +24109,7 @@ function buildPressHead(g, ids, bodyWidth, reg) {
|
|
|
24185
24109
|
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
24186
24110
|
}
|
|
24187
24111
|
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
24188
|
-
const c = _optionalChain([g, 'access',
|
|
24112
|
+
const c = _optionalChain([g, 'access', _278 => _278.press, 'optionalAccess', _279 => _279.contact]);
|
|
24189
24113
|
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
24190
24114
|
const w = bodyWidth - 280;
|
|
24191
24115
|
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
@@ -24566,7 +24490,7 @@ function generateSecPr(gongmun) {
|
|
|
24566
24490
|
}
|
|
24567
24491
|
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>`;
|
|
24568
24492
|
const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
|
|
24569
|
-
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess',
|
|
24493
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _280 => _280.pageNumbers]) ? pageNumCtrl() : "");
|
|
24570
24494
|
}
|
|
24571
24495
|
var SectionOpener = (_class6 = class {
|
|
24572
24496
|
constructor(gongmun) {;_class6.prototype.__init12.call(this);
|
|
@@ -24605,19 +24529,19 @@ function buildPreamble(blocks, ctx) {
|
|
|
24605
24529
|
const { gongmun, dfIds, bfReg, tableStyle, richAssets, gjBodyW } = ctx;
|
|
24606
24530
|
const preamble = [];
|
|
24607
24531
|
let hasFrontPages = false;
|
|
24608
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24532
|
+
if (_optionalChain([gongmun, 'optionalAccess', _281 => _281.reportInfo]) && dfIds) {
|
|
24609
24533
|
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
24610
24534
|
}
|
|
24611
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24535
|
+
if (_optionalChain([gongmun, 'optionalAccess', _282 => _282.approval]) && bfReg) {
|
|
24612
24536
|
preamble.push(buildApprovalTable(gongmun.approval, bfReg, richAssets ? GJ_CHAR_APPROVAL : GONGMUN_APPROVAL_CHAR));
|
|
24613
24537
|
}
|
|
24614
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24538
|
+
if (_optionalChain([gongmun, 'optionalAccess', _283 => _283.docHead]) && dfIds) {
|
|
24615
24539
|
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
24616
24540
|
}
|
|
24617
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24541
|
+
if (_optionalChain([gongmun, 'optionalAccess', _284 => _284.noticeHead]) && dfIds) {
|
|
24618
24542
|
preamble.push(...buildNoticeHead(gongmun));
|
|
24619
24543
|
}
|
|
24620
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24544
|
+
if (_optionalChain([gongmun, 'optionalAccess', _285 => _285.press]) && dfIds && bfReg && tableStyle) {
|
|
24621
24545
|
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
24622
24546
|
}
|
|
24623
24547
|
if (gongmun && (gongmun.cover || gongmun.toc)) {
|
|
@@ -24646,7 +24570,7 @@ function buildPreamble(blocks, ctx) {
|
|
|
24646
24570
|
}
|
|
24647
24571
|
if (gongmun && !ctx.gaejosik && ctx.coverH1Idx < 0 && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
24648
24572
|
ctx.titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
24649
|
-
} else if (_optionalChain([gongmun, 'optionalAccess',
|
|
24573
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _286 => _286.press]) && ctx.coverH1Idx < 0 && dfIds) {
|
|
24650
24574
|
ctx.pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
24651
24575
|
}
|
|
24652
24576
|
if (preamble.length > 0) {
|
|
@@ -24661,7 +24585,7 @@ function renderHeading(block, blockIdx, ctx) {
|
|
|
24661
24585
|
if (gongmun && blockIdx === ctx.coverH1Idx) return "";
|
|
24662
24586
|
if (gongmun && blockIdx === ctx.pressH1Idx && dfIds) {
|
|
24663
24587
|
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
24664
|
-
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
24588
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _287 => _287.press, 'optionalAccess', _288 => _288.sub]), () => ( []))) {
|
|
24665
24589
|
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
24666
24590
|
}
|
|
24667
24591
|
return parts.join("\n ");
|
|
@@ -24755,8 +24679,8 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
24755
24679
|
const { gongmun, gongmunList, measured, fit, vBase, dfIds } = ctx;
|
|
24756
24680
|
if (gongmun && gongmunList) {
|
|
24757
24681
|
const info = gongmunList.items.get(blockIdx);
|
|
24758
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
24759
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
24682
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _289 => _289.depth]), () => ( 0));
|
|
24683
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _290 => _290.marker]), () => ( ""));
|
|
24760
24684
|
const content = block.text || "";
|
|
24761
24685
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
24762
24686
|
return generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
@@ -24765,7 +24689,7 @@ function renderListItem(block, blockIdx, ctx) {
|
|
|
24765
24689
|
return generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, ctx.chamMap);
|
|
24766
24690
|
}
|
|
24767
24691
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
24768
|
-
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess',
|
|
24692
|
+
const listParaPr = marker2 ? _optionalChain([info, 'optionalAccess', _291 => _291.indentVariant]) !== void 0 ? GONGMUN_LIST_VARIANT_BASE + info.indentVariant : GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
24769
24693
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
24770
24694
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
24771
24695
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
@@ -24824,18 +24748,18 @@ function renderHtmlTable(block, ctx) {
|
|
|
24824
24748
|
}
|
|
24825
24749
|
function appendPostamble(blocks, ctx) {
|
|
24826
24750
|
const { gongmun, dfIds, bfReg, tableStyle, paraXmls } = ctx;
|
|
24827
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24751
|
+
if (_optionalChain([gongmun, 'optionalAccess', _292 => _292.noticeHead]) && dfIds) {
|
|
24828
24752
|
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
24829
24753
|
}
|
|
24830
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24831
|
-
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access',
|
|
24754
|
+
if (_optionalChain([gongmun, 'optionalAccess', _293 => _293.endMark]) && paraXmls.length > 0) {
|
|
24755
|
+
const lastBlock = [...blocks].reverse().find((b) => (b.text || "").trim() || b.type === "table" && _optionalChain([b, 'access', _294 => _294.rows, 'optionalAccess', _295 => _295.length]));
|
|
24832
24756
|
const lastText = lastBlock && (lastBlock.type === "paragraph" || lastBlock.type === "list_item") ? lastBlock.text || "" : "";
|
|
24833
24757
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
24834
24758
|
}
|
|
24835
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24759
|
+
if (_optionalChain([gongmun, 'optionalAccess', _296 => _296.docFoot]) && dfIds) {
|
|
24836
24760
|
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
24837
24761
|
}
|
|
24838
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
24762
|
+
if (_optionalChain([gongmun, 'optionalAccess', _297 => _297.press]) && dfIds && bfReg && tableStyle) {
|
|
24839
24763
|
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
24840
24764
|
}
|
|
24841
24765
|
}
|
|
@@ -24855,7 +24779,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
24855
24779
|
remap,
|
|
24856
24780
|
dfIds,
|
|
24857
24781
|
images,
|
|
24858
|
-
gaejosik: _optionalChain([gongmun, 'optionalAccess',
|
|
24782
|
+
gaejosik: _optionalChain([gongmun, 'optionalAccess', _298 => _298.preset]) === "gaejosik",
|
|
24859
24783
|
measured,
|
|
24860
24784
|
richAssets,
|
|
24861
24785
|
vBase: charVariantBase(richAssets, !!gongmun),
|
|
@@ -24961,18 +24885,18 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
24961
24885
|
|
|
24962
24886
|
// src/hwpx/generator.ts
|
|
24963
24887
|
async function markdownToHwpx(markdown, options) {
|
|
24964
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
24965
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
24888
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _299 => _299.theme]));
|
|
24889
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _300 => _300.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
24966
24890
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
24967
24891
|
const richAssets = !!gongmun && needsGaejosikAssets(gongmun);
|
|
24968
24892
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
24969
24893
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
24970
24894
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
24971
24895
|
const staticBfEnd = staticBorderFillNext(gongmun);
|
|
24972
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
24973
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
24896
|
+
const remap = _optionalChain([options, 'optionalAccess', _301 => _301.profile]) ? buildProfileRemap(options.profile, charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _302 => _302.variants, 'optionalAccess', _303 => _303.length]), () => ( 0))) * 4, staticBfEnd, staticFontNext(gongmun)) : null;
|
|
24897
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _304 => _304.borderFillXmls, 'access', _305 => _305.length]), () => ( 0)))) : null;
|
|
24974
24898
|
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
24975
|
-
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
24899
|
+
const dfBase = charVariantBase(richAssets, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _306 => _306.variants, 'optionalAccess', _307 => _307.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _308 => _308.charPrXmls, 'access', _309 => _309.length]), () => ( 0)));
|
|
24976
24900
|
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
24977
24901
|
const chartParts = [];
|
|
24978
24902
|
const images = new ImageRegistry();
|
|
@@ -24983,7 +24907,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
24983
24907
|
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)`);
|
|
24984
24908
|
}
|
|
24985
24909
|
}
|
|
24986
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
24910
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _310 => _310.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _311 => _311.emit, 'call', _312 => _312()]), () => ( []))];
|
|
24987
24911
|
const zip = new (0, _jszip2.default)();
|
|
24988
24912
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
24989
24913
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
@@ -24992,11 +24916,11 @@ async function markdownToHwpx(markdown, options) {
|
|
|
24992
24916
|
zip.file("Contents/header.xml", generateHeaderXml(
|
|
24993
24917
|
theme,
|
|
24994
24918
|
gongmun,
|
|
24995
|
-
_nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
24919
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _313 => _313.variants]), () => ( [])),
|
|
24996
24920
|
extraBorderFills,
|
|
24997
|
-
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
24998
|
-
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess',
|
|
24999
|
-
_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
24921
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _314 => _314.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, richAssets) : []],
|
|
24922
|
+
_nullishCoalesce(_optionalChain([gongmunList, 'optionalAccess', _315 => _315.indentVariants]), () => ( [])),
|
|
24923
|
+
_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _316 => _316.fontFaces]), () => ( []))
|
|
25000
24924
|
));
|
|
25001
24925
|
zip.file("Contents/section0.xml", sectionXml);
|
|
25002
24926
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
@@ -25291,7 +25215,7 @@ function parseRenderStyles(headXml) {
|
|
|
25291
25215
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
25292
25216
|
const textColor = el.getAttribute("textColor");
|
|
25293
25217
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
25294
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
25218
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _317 => _317.getAttribute, 'call', _318 => _318("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _319 => _319.getAttribute, 'call', _320 => _320("latin")])));
|
|
25295
25219
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
25296
25220
|
styles.charPr.set(id, {
|
|
25297
25221
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -25299,8 +25223,8 @@ function parseRenderStyles(headXml) {
|
|
|
25299
25223
|
italic: findChildByLocalName(el, "italic") != null,
|
|
25300
25224
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
25301
25225
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
25302
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
25303
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
25226
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _321 => _321.getAttribute, 'call', _322 => _322("hangul")])) || 100,
|
|
25227
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _323 => _323.getAttribute, 'call', _324 => _324("hangul")])) || 0,
|
|
25304
25228
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0,
|
|
25305
25229
|
face
|
|
25306
25230
|
});
|
|
@@ -25309,7 +25233,7 @@ function parseRenderStyles(headXml) {
|
|
|
25309
25233
|
const id = el.getAttribute("id");
|
|
25310
25234
|
if (id != null) {
|
|
25311
25235
|
const align = findChildByLocalName(el, "align");
|
|
25312
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
25236
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _325 => _325.getAttribute, 'call', _326 => _326("horizontal")]) || "JUSTIFY");
|
|
25313
25237
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
25314
25238
|
}
|
|
25315
25239
|
} else if (tag === "borderFill") {
|
|
@@ -25323,7 +25247,7 @@ function parseRenderStyles(headXml) {
|
|
|
25323
25247
|
};
|
|
25324
25248
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
25325
25249
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
25326
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
25250
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _327 => _327.getAttribute, 'call', _328 => _328("faceColor")]);
|
|
25327
25251
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
25328
25252
|
styles.borderFill.set(id, bf);
|
|
25329
25253
|
}
|
|
@@ -25395,7 +25319,7 @@ function collectSites(scan) {
|
|
|
25395
25319
|
}
|
|
25396
25320
|
function attrOf(openTag, name) {
|
|
25397
25321
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
25398
|
-
return _optionalChain([m, 'optionalAccess',
|
|
25322
|
+
return _optionalChain([m, 'optionalAccess', _329 => _329[1]]);
|
|
25399
25323
|
}
|
|
25400
25324
|
function paraOpenTag(xml, para2) {
|
|
25401
25325
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -25410,7 +25334,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
25410
25334
|
if (!tr) return null;
|
|
25411
25335
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
25412
25336
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
25413
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
25337
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _330 => _330[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
25414
25338
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
25415
25339
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
25416
25340
|
if (close === -1) return null;
|
|
@@ -25437,7 +25361,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
25437
25361
|
if (width === null) return null;
|
|
25438
25362
|
let content = width;
|
|
25439
25363
|
const win = cellAddrWindow(xml, cell2);
|
|
25440
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
25364
|
+
const mg = _optionalChain([win, 'optionalAccess', _331 => _331.match, 'call', _332 => _332(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
25441
25365
|
if (mg) {
|
|
25442
25366
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
25443
25367
|
}
|
|
@@ -25471,11 +25395,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25471
25395
|
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>`;
|
|
25472
25396
|
}
|
|
25473
25397
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25474
|
-
if (ops.length === 0) throw new (0,
|
|
25398
|
+
if (ops.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25475
25399
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25476
25400
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25477
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
25478
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25401
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _333 => _333.match, 'call', _334 => _334(/(\d+)\.xml$/i), 'optionalAccess', _335 => _335[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _336 => _336.match, 'call', _337 => _337(/(\d+)\.xml$/i), 'optionalAccess', _338 => _338[1]]), () => ( 0))));
|
|
25402
|
+
if (sectionPaths.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25479
25403
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25480
25404
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25481
25405
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25516,11 +25440,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25516
25440
|
const manifestItems = [];
|
|
25517
25441
|
const placed = [];
|
|
25518
25442
|
for (const op of ops) {
|
|
25519
|
-
if (!op.anchor) throw new (0,
|
|
25520
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25443
|
+
if (!op.anchor) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25444
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25521
25445
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25522
|
-
if (!MIME[ext]) throw new (0,
|
|
25523
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25446
|
+
if (!MIME[ext]) throw new (0, _chunk6XAAYAWLcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25447
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunk6XAAYAWLcjs.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)`);
|
|
25524
25448
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25525
25449
|
let found = null;
|
|
25526
25450
|
let total = 0;
|
|
@@ -25553,7 +25477,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25553
25477
|
}
|
|
25554
25478
|
}
|
|
25555
25479
|
}
|
|
25556
|
-
throw new (0,
|
|
25480
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
25557
25481
|
`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)})`
|
|
25558
25482
|
);
|
|
25559
25483
|
}
|
|
@@ -25561,9 +25485,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25561
25485
|
const xml = sectionXmls[si];
|
|
25562
25486
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25563
25487
|
if (!run) {
|
|
25564
|
-
throw new (0,
|
|
25488
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
25565
25489
|
}
|
|
25566
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
25490
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _339 => _339.charPr, 'access', _340 => _340.get, 'call', _341 => _341(run.charPr), 'optionalAccess', _342 => _342.height]), () => ( 1e3));
|
|
25567
25491
|
const fontPt = charPrHeight / 100;
|
|
25568
25492
|
const emMm = fontPt * 25.4 / 72;
|
|
25569
25493
|
const lineHMm = emMm;
|
|
@@ -25572,7 +25496,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25572
25496
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
25573
25497
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
25574
25498
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
25575
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
25499
|
+
const align = _optionalChain([styles, 'optionalAccess', _343 => _343.paraAlign, 'access', _344 => _344.get, 'call', _345 => _345(paraPrId)]);
|
|
25576
25500
|
let alignShiftMm = 0;
|
|
25577
25501
|
if (align === "CENTER" || align === "RIGHT") {
|
|
25578
25502
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -25668,7 +25592,7 @@ function parseBorderFills(headerDoc) {
|
|
|
25668
25592
|
};
|
|
25669
25593
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
25670
25594
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
25671
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
25595
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _346 => _346.getAttribute, 'call', _347 => _347("faceColor")]);
|
|
25672
25596
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
25673
25597
|
map.set(id, def);
|
|
25674
25598
|
}
|
|
@@ -25700,7 +25624,7 @@ function parseCharPrs(headerDoc, hangulFonts) {
|
|
|
25700
25624
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
25701
25625
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
25702
25626
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
25703
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
25627
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _348 => _348.getAttribute, 'call', _349 => _349("hangul")]);
|
|
25704
25628
|
if (hangul) {
|
|
25705
25629
|
def.fontRef_hangul = hangul;
|
|
25706
25630
|
const face = hangulFonts.get(hangul);
|
|
@@ -25728,7 +25652,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
25728
25652
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
25729
25653
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
25730
25654
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
25731
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
25655
|
+
const width = _optionalChain([sz, 'optionalAccess', _350 => _350.getAttribute, 'call', _351 => _351("width")]) || void 0;
|
|
25732
25656
|
const cells = [];
|
|
25733
25657
|
const usedBf = /* @__PURE__ */ new Set();
|
|
25734
25658
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -25741,17 +25665,17 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
25741
25665
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
25742
25666
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
25743
25667
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
25744
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
25745
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
25668
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _352 => _352.getAttribute, 'call', _353 => _353("rowAddr")])), () => ( 0));
|
|
25669
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _354 => _354.getAttribute, 'call', _355 => _355("colAddr")])), () => ( 0));
|
|
25746
25670
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
25747
25671
|
if (row === 0) row0Texts.set(col, directCellText(tc2));
|
|
25748
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
25749
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
25672
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _356 => _356.getAttribute, 'call', _357 => _357("colSpan")])), () => ( 1));
|
|
25673
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _358 => _358.getAttribute, 'call', _359 => _359("rowSpan")])), () => ( 1));
|
|
25750
25674
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
25751
25675
|
const cpId = firstRunCharPr(tc2);
|
|
25752
25676
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
25753
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
25754
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
25677
|
+
const w = _optionalChain([csz, 'optionalAccess', _360 => _360.getAttribute, 'call', _361 => _361("width")]);
|
|
25678
|
+
const hh = _optionalChain([csz, 'optionalAccess', _362 => _362.getAttribute, 'call', _363 => _363("height")]);
|
|
25755
25679
|
if (w) cell2.width_hwpunit = w;
|
|
25756
25680
|
if (hh) cell2.height_hwpunit = hh;
|
|
25757
25681
|
if (bfId) {
|
|
@@ -25839,16 +25763,16 @@ function pick(map, keys) {
|
|
|
25839
25763
|
return out;
|
|
25840
25764
|
}
|
|
25841
25765
|
async function hwpxToProfile(input) {
|
|
25842
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
25766
|
+
const buf = input instanceof ArrayBuffer ? input : _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
|
|
25843
25767
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
25844
25768
|
const parser = createXmlParser();
|
|
25845
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
25769
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _364 => _364.file, 'call', _365 => _365(/[Hh]eader\.xml$/), 'optionalAccess', _366 => _366[0]])));
|
|
25846
25770
|
let headerXml = "<root/>";
|
|
25847
25771
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
25848
25772
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
25849
25773
|
const borderFills = parseBorderFills(headerDoc);
|
|
25850
25774
|
const charPrs = parseCharPrs(headerDoc, parseHangulFonts(headerDoc));
|
|
25851
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
25775
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _367 => _367.name, 'access', _368 => _368.match, 'call', _369 => _369(/(\d+)\.xml$/), 'optionalAccess', _370 => _370[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _371 => _371.name, 'access', _372 => _372.match, 'call', _373 => _373(/(\d+)\.xml$/), 'optionalAccess', _374 => _374[1]]), () => ( null))), () => ( 0))));
|
|
25852
25776
|
const tables = [];
|
|
25853
25777
|
let tableIndex = 0;
|
|
25854
25778
|
for (const f of sectionFiles) {
|
|
@@ -26162,7 +26086,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
26162
26086
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
26163
26087
|
function patchTableRows(input) {
|
|
26164
26088
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
26165
|
-
const xml = _optionalChain([ctx, 'access',
|
|
26089
|
+
const xml = _optionalChain([ctx, 'access', _375 => _375.scans, 'access', _376 => _376[scanTable.sectionIndex], 'optionalAccess', _377 => _377.xml]);
|
|
26166
26090
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
26167
26091
|
const numRows = table2.rows;
|
|
26168
26092
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -26329,7 +26253,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
26329
26253
|
const rr = scanTable.rowRanges[template];
|
|
26330
26254
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
26331
26255
|
const scan = scanSectionXml(wrapped, 0);
|
|
26332
|
-
const row = _optionalChain([scan, 'access',
|
|
26256
|
+
const row = _optionalChain([scan, 'access', _378 => _378.tables, 'access', _379 => _379[0], 'optionalAccess', _380 => _380.rows, 'access', _381 => _381[0]]);
|
|
26333
26257
|
if (!row || row.length !== cells.length) return null;
|
|
26334
26258
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
26335
26259
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -26372,7 +26296,7 @@ function rowHeightOf(fragment) {
|
|
|
26372
26296
|
}
|
|
26373
26297
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
26374
26298
|
const from = scanTable.start + tblOpenLen;
|
|
26375
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
26299
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _382 => _382.rowRanges, 'access', _383 => _383[0], 'optionalAccess', _384 => _384.start]), () => ( from));
|
|
26376
26300
|
const slice = xml.slice(from, to);
|
|
26377
26301
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
26378
26302
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -26561,9 +26485,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
26561
26485
|
});
|
|
26562
26486
|
}
|
|
26563
26487
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
26564
|
-
const irCell = _optionalChain([table2, 'access',
|
|
26488
|
+
const irCell = _optionalChain([table2, 'access', _385 => _385.cells, 'access', _386 => _386[oc.gridR], 'optionalAccess', _387 => _387[oc.gridC]]);
|
|
26565
26489
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
26566
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
26490
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _388 => _388.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
26567
26491
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
26568
26492
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
26569
26493
|
}
|
|
@@ -26631,7 +26555,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
26631
26555
|
};
|
|
26632
26556
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
26633
26557
|
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)");
|
|
26634
|
-
const irCell = _optionalChain([table2, 'access',
|
|
26558
|
+
const irCell = _optionalChain([table2, 'access', _389 => _389.cells, 'access', _390 => _390[gridR], 'optionalAccess', _391 => _391[gridC]]);
|
|
26635
26559
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
26636
26560
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
26637
26561
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -26654,7 +26578,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
26654
26578
|
if (newLines.length === 0) return 0;
|
|
26655
26579
|
const target = cell2.paragraphs[0];
|
|
26656
26580
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
26657
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
26581
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _392 => _392.scans, 'access', _393 => _393[target.sectionIndex], 'optionalAccess', _394 => _394.xml]));
|
|
26658
26582
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
26659
26583
|
splices.push(...sp);
|
|
26660
26584
|
sectionIndex = target.sectionIndex;
|
|
@@ -26677,7 +26601,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
26677
26601
|
}
|
|
26678
26602
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
26679
26603
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
26680
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
26604
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _395 => _395.scans, 'access', _396 => _396[nonEmpty[i].sectionIndex], 'optionalAccess', _397 => _397.xml]));
|
|
26681
26605
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
26682
26606
|
splices.push(...sp);
|
|
26683
26607
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -26758,7 +26682,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
26758
26682
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
26759
26683
|
if (paths.length > 0) return paths;
|
|
26760
26684
|
}
|
|
26761
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
26685
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
|
|
26762
26686
|
}
|
|
26763
26687
|
function sectionPathsFromManifest(xml) {
|
|
26764
26688
|
const attr = (tag, name) => {
|
|
@@ -26768,7 +26692,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26768
26692
|
const idToHref = /* @__PURE__ */ new Map();
|
|
26769
26693
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
26770
26694
|
const id = attr(m[1], "id");
|
|
26771
|
-
const href =
|
|
26695
|
+
const href = _chunk6XAAYAWLcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
26772
26696
|
if (id && href) idToHref.set(id, href);
|
|
26773
26697
|
}
|
|
26774
26698
|
const ordered = [];
|
|
@@ -26777,7 +26701,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
26777
26701
|
if (href) ordered.push(href);
|
|
26778
26702
|
}
|
|
26779
26703
|
if (ordered.length > 0) return ordered;
|
|
26780
|
-
return Array.from(idToHref.values()).sort(
|
|
26704
|
+
return Array.from(idToHref.values()).sort(_chunk6XAAYAWLcjs.compareSectionPaths);
|
|
26781
26705
|
}
|
|
26782
26706
|
|
|
26783
26707
|
// src/roundtrip/patcher.ts
|
|
@@ -26869,7 +26793,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
26869
26793
|
}
|
|
26870
26794
|
}
|
|
26871
26795
|
let verification;
|
|
26872
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26796
|
+
if (_optionalChain([options, 'optionalAccess', _398 => _398.verify]) !== false) {
|
|
26873
26797
|
try {
|
|
26874
26798
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
26875
26799
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -26884,20 +26808,20 @@ function buildOrigUnits(blocks) {
|
|
|
26884
26808
|
for (let i = 0; i < blocks.length; i++) {
|
|
26885
26809
|
const block = blocks[i];
|
|
26886
26810
|
let consume = 1;
|
|
26887
|
-
let
|
|
26811
|
+
let chunk;
|
|
26888
26812
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
26889
26813
|
const next = blocks[i + 1];
|
|
26890
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
26891
|
-
|
|
26814
|
+
if (_optionalChain([next, 'optionalAccess', _399 => _399.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
26815
|
+
chunk = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
26892
26816
|
} else {
|
|
26893
|
-
|
|
26817
|
+
chunk = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, [block]);
|
|
26894
26818
|
}
|
|
26895
|
-
if (
|
|
26896
|
-
const subUnits = splitMarkdownUnits(
|
|
26819
|
+
if (chunk) {
|
|
26820
|
+
const subUnits = splitMarkdownUnits(chunk);
|
|
26897
26821
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
26898
26822
|
for (let s = 0; s < subUnits.length; s++) {
|
|
26899
26823
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
26900
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
26824
|
+
if (block.type === "table" && _optionalChain([block, 'access', _400 => _400.table, 'optionalAccess', _401 => _401.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
26901
26825
|
u.role = "caption";
|
|
26902
26826
|
}
|
|
26903
26827
|
units.push(u);
|
|
@@ -27008,7 +26932,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27008
26932
|
const ti = ctx.tableInsert;
|
|
27009
26933
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
27010
26934
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27011
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26935
|
+
if (!_optionalChain([mapping, 'optionalAccess', _402 => _402.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");
|
|
27012
26936
|
const para2 = mapping.para;
|
|
27013
26937
|
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");
|
|
27014
26938
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -27036,7 +26960,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
27036
26960
|
}
|
|
27037
26961
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
27038
26962
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27039
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26963
|
+
if (!_optionalChain([mapping, 'optionalAccess', _403 => _403.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)");
|
|
27040
26964
|
if (block.text && block.text.includes("\n")) {
|
|
27041
26965
|
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)");
|
|
27042
26966
|
}
|
|
@@ -27067,7 +26991,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
27067
26991
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27068
26992
|
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");
|
|
27069
26993
|
}
|
|
27070
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
26994
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _404 => _404.scans, 'access', _405 => _405[mapping.para.sectionIndex], 'optionalAccess', _406 => _406.xml]));
|
|
27071
26995
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27072
26996
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27073
26997
|
return 1;
|
|
@@ -27253,7 +27177,7 @@ var Surgeon = (_class7 = class {
|
|
|
27253
27177
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
27254
27178
|
findEntry(path) {
|
|
27255
27179
|
const parts = path.replace(/^\//, "").split("/");
|
|
27256
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
27180
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _407 => _407.entries, 'access', _408 => _408[0], 'optionalAccess', _409 => _409.child]), () => ( -1));
|
|
27257
27181
|
let current;
|
|
27258
27182
|
for (const part of parts) {
|
|
27259
27183
|
const search = (idx) => {
|
|
@@ -27466,8 +27390,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
27466
27390
|
parts.push(header, data);
|
|
27467
27391
|
};
|
|
27468
27392
|
for (let i = 0; i < recs.length; i++) {
|
|
27469
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
27470
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
27393
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _410 => _410.get, 'call', _411 => _411(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
27394
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _412 => _412.get, 'call', _413 => _413(i)]), () => ( recs[i].data)));
|
|
27471
27395
|
}
|
|
27472
27396
|
return Buffer.concat(parts);
|
|
27473
27397
|
}
|
|
@@ -27585,7 +27509,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27585
27509
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
27586
27510
|
}
|
|
27587
27511
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
27588
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
27512
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _414 => _414.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
27589
27513
|
let flags;
|
|
27590
27514
|
try {
|
|
27591
27515
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -27607,7 +27531,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27607
27531
|
const scans = [];
|
|
27608
27532
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
27609
27533
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
27610
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
27534
|
+
if (!_optionalChain([entry, 'optionalAccess', _415 => _415.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
27611
27535
|
let stream;
|
|
27612
27536
|
try {
|
|
27613
27537
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -27658,7 +27582,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
27658
27582
|
}
|
|
27659
27583
|
}
|
|
27660
27584
|
let verification;
|
|
27661
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27585
|
+
if (_optionalChain([options, 'optionalAccess', _416 => _416.verify]) !== false) {
|
|
27662
27586
|
try {
|
|
27663
27587
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
27664
27588
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -27748,7 +27672,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
27748
27672
|
for (const [key, scanCell] of scanTable.cells) {
|
|
27749
27673
|
const comma = key.indexOf(",");
|
|
27750
27674
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
27751
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
27675
|
+
const irCell = _optionalChain([irTable, 'access', _417 => _417.cells, 'access', _418 => _418[r], 'optionalAccess', _419 => _419[c]]);
|
|
27752
27676
|
if (!irCell) continue;
|
|
27753
27677
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
27754
27678
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -27784,7 +27708,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
27784
27708
|
}
|
|
27785
27709
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
27786
27710
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
27787
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27711
|
+
if (!_optionalChain([mapping, 'optionalAccess', _420 => _420.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)");
|
|
27788
27712
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
27789
27713
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
27790
27714
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -27983,7 +27907,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
27983
27907
|
};
|
|
27984
27908
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
27985
27909
|
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)");
|
|
27986
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27910
|
+
const irCell = _optionalChain([table2, 'access', _421 => _421.cells, 'access', _422 => _422[gridR], 'optionalAccess', _423 => _423[gridC]]);
|
|
27987
27911
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
27988
27912
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
27989
27913
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -28375,7 +28299,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28375
28299
|
const block = st.blocks[blockIndex];
|
|
28376
28300
|
if (!block) return void 0;
|
|
28377
28301
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
28378
|
-
const para2 = _optionalChain([st, 'access',
|
|
28302
|
+
const para2 = _optionalChain([st, 'access', _424 => _424.paraMap, 'access', _425 => _425.get, 'call', _426 => _426(blockIndex), 'optionalAccess', _427 => _427.para]);
|
|
28379
28303
|
if (!para2) return void 0;
|
|
28380
28304
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
28381
28305
|
}
|
|
@@ -28400,7 +28324,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28400
28324
|
if (block.text && block.text.includes("\n")) {
|
|
28401
28325
|
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)" };
|
|
28402
28326
|
}
|
|
28403
|
-
if (!_optionalChain([st, 'access',
|
|
28327
|
+
if (!_optionalChain([st, 'access', _428 => _428.paraMap, 'access', _429 => _429.get, 'call', _430 => _430(blockIndex), 'optionalAccess', _431 => _431.para])) {
|
|
28404
28328
|
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)" };
|
|
28405
28329
|
}
|
|
28406
28330
|
return { capability: "text" };
|
|
@@ -28466,7 +28390,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28466
28390
|
continue;
|
|
28467
28391
|
}
|
|
28468
28392
|
if (block.type === "table" && block.table) {
|
|
28469
|
-
if (!_optionalChain([edit, 'access',
|
|
28393
|
+
if (!_optionalChain([edit, 'access', _432 => _432.cells, 'optionalAccess', _433 => _433.length])) {
|
|
28470
28394
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
28471
28395
|
continue;
|
|
28472
28396
|
}
|
|
@@ -28486,7 +28410,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28486
28410
|
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) });
|
|
28487
28411
|
continue;
|
|
28488
28412
|
}
|
|
28489
|
-
const irCell = _optionalChain([block, 'access',
|
|
28413
|
+
const irCell = _optionalChain([block, 'access', _434 => _434.table, 'access', _435 => _435.cells, 'access', _436 => _436[cellEdit.row], 'optionalAccess', _437 => _437[cellEdit.col]]);
|
|
28490
28414
|
if (!irCell) {
|
|
28491
28415
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
28492
28416
|
continue;
|
|
@@ -28542,7 +28466,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28542
28466
|
}
|
|
28543
28467
|
if (replacements.size === 0) {
|
|
28544
28468
|
let changes2;
|
|
28545
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28469
|
+
if (_optionalChain([options, 'optionalAccess', _438 => _438.verify]) !== false) {
|
|
28546
28470
|
const units = splitMarkdownUnits(st.markdown);
|
|
28547
28471
|
changes2 = diffUnitLists(units, units);
|
|
28548
28472
|
}
|
|
@@ -28563,7 +28487,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28563
28487
|
}
|
|
28564
28488
|
this.state = newState;
|
|
28565
28489
|
let changes;
|
|
28566
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
28490
|
+
if (_optionalChain([options, 'optionalAccess', _439 => _439.verify]) !== false) {
|
|
28567
28491
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
28568
28492
|
}
|
|
28569
28493
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -28583,7 +28507,7 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28583
28507
|
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)");
|
|
28584
28508
|
}
|
|
28585
28509
|
const mapping = st.paraMap.get(blockIndex);
|
|
28586
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
28510
|
+
if (!_optionalChain([mapping, 'optionalAccess', _440 => _440.para])) {
|
|
28587
28511
|
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)");
|
|
28588
28512
|
}
|
|
28589
28513
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -28603,14 +28527,14 @@ var HwpxSession = (_class8 = class _HwpxSession {
|
|
|
28603
28527
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
28604
28528
|
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");
|
|
28605
28529
|
}
|
|
28606
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
28530
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _441 => _441.scans, 'access', _442 => _442[mapping.para.sectionIndex], 'optionalAccess', _443 => _443.xml]));
|
|
28607
28531
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
28608
28532
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
28609
28533
|
return 1;
|
|
28610
28534
|
}
|
|
28611
28535
|
}, _class8);
|
|
28612
28536
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
28613
|
-
const irCell = _optionalChain([table2, 'access',
|
|
28537
|
+
const irCell = _optionalChain([table2, 'access', _444 => _444.cells, 'access', _445 => _445[r], 'optionalAccess', _446 => _446[c]]);
|
|
28614
28538
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
28615
28539
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
28616
28540
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -28694,11 +28618,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
28694
28618
|
breaks: false
|
|
28695
28619
|
});
|
|
28696
28620
|
function renderHtml(markdown, options) {
|
|
28697
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28698
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28621
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _447 => _447.preset]), () => ( "default"));
|
|
28622
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _448 => _448.extraCss]), () => ( "")));
|
|
28699
28623
|
const body = md.render(markdown);
|
|
28700
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
28701
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
28624
|
+
const watermark = _optionalChain([options, 'optionalAccess', _449 => _449.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
28625
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _450 => _450.watermark]) ? `
|
|
28702
28626
|
.watermark {
|
|
28703
28627
|
position: fixed;
|
|
28704
28628
|
top: 50%; left: 50%;
|
|
@@ -28729,13 +28653,13 @@ async function htmlToPdf(html, options) {
|
|
|
28729
28653
|
try {
|
|
28730
28654
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
28731
28655
|
} catch (e31) {
|
|
28732
|
-
throw new (0,
|
|
28656
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
28733
28657
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
28734
28658
|
);
|
|
28735
28659
|
}
|
|
28736
28660
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
28737
28661
|
if (!executablePath) {
|
|
28738
|
-
throw new (0,
|
|
28662
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)(
|
|
28739
28663
|
"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."
|
|
28740
28664
|
);
|
|
28741
28665
|
}
|
|
@@ -28747,10 +28671,10 @@ async function htmlToPdf(html, options) {
|
|
|
28747
28671
|
try {
|
|
28748
28672
|
const page = await browser.newPage();
|
|
28749
28673
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
28750
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
28674
|
+
const margin = _optionalChain([options, 'optionalAccess', _451 => _451.margin]);
|
|
28751
28675
|
const pdf = await page.pdf({
|
|
28752
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28753
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
28676
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _452 => _452.pageSize]), () => ( "A4")),
|
|
28677
|
+
landscape: _optionalChain([options, 'optionalAccess', _453 => _453.orientation]) === "landscape",
|
|
28754
28678
|
printBackground: true,
|
|
28755
28679
|
margin: margin ? {
|
|
28756
28680
|
top: toCss(margin.top),
|
|
@@ -28758,9 +28682,9 @@ async function htmlToPdf(html, options) {
|
|
|
28758
28682
|
bottom: toCss(margin.bottom),
|
|
28759
28683
|
left: toCss(margin.left)
|
|
28760
28684
|
} : void 0,
|
|
28761
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
28762
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28763
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28685
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _454 => _454.header]) || _optionalChain([options, 'optionalAccess', _455 => _455.footer])),
|
|
28686
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _456 => _456.header]), () => ( "<div></div>")),
|
|
28687
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _457 => _457.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
28764
28688
|
});
|
|
28765
28689
|
return Buffer.from(pdf);
|
|
28766
28690
|
} finally {
|
|
@@ -28794,7 +28718,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
28794
28718
|
return htmlToPdf(html, options);
|
|
28795
28719
|
}
|
|
28796
28720
|
async function blocksToPdf(blocks, options) {
|
|
28797
|
-
const markdown =
|
|
28721
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, blocks);
|
|
28798
28722
|
return markdownToPdf(markdown, options);
|
|
28799
28723
|
}
|
|
28800
28724
|
|
|
@@ -28973,7 +28897,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
28973
28897
|
}
|
|
28974
28898
|
const wrapAttr = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( ""));
|
|
28975
28899
|
if (wrapAttr === "BEHIND_TEXT" || wrapAttr === "IN_FRONT_OF_TEXT") continue;
|
|
28976
|
-
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
28900
|
+
const vertRel = _nullishCoalesce(_optionalChain([pos, 'optionalAccess', _458 => _458.getAttribute, 'call', _459 => _459("vertRelTo")]), () => ( "PARA"));
|
|
28977
28901
|
if (vertRel === "PAGE" || vertRel === "PAPER") continue;
|
|
28978
28902
|
const vo = Math.max(0, num2(pos, "vertOffset"));
|
|
28979
28903
|
if (wrapAttr === "TOP_AND_BOTTOM") {
|
|
@@ -29034,7 +28958,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29034
28958
|
if (ln(p) !== "p") continue;
|
|
29035
28959
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
29036
28960
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
29037
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
28961
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _460 => _460.spaceBefore]), () => ( 0)));
|
|
29038
28962
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
29039
28963
|
if (!res) {
|
|
29040
28964
|
const lsa = findChildByLocalName(p, "linesegarray");
|
|
@@ -29047,7 +28971,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
29047
28971
|
}
|
|
29048
28972
|
if (Number.isFinite(bottom)) {
|
|
29049
28973
|
cursorV = bottom;
|
|
29050
|
-
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
28974
|
+
prevSpaceAfter = _nullishCoalesce(_optionalChain([g, 'optionalAccess', _461 => _461.spaceAfter]), () => ( 0));
|
|
29051
28975
|
}
|
|
29052
28976
|
}
|
|
29053
28977
|
continue;
|
|
@@ -29157,7 +29081,7 @@ function buildPara(p) {
|
|
|
29157
29081
|
el: ch,
|
|
29158
29082
|
tag: cn,
|
|
29159
29083
|
index: chars.length,
|
|
29160
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
29084
|
+
inline: _optionalChain([pos, 'optionalAccess', _462 => _462.getAttribute, 'call', _463 => _463("treatAsChar")]) === "1",
|
|
29161
29085
|
width: w,
|
|
29162
29086
|
height: h
|
|
29163
29087
|
});
|
|
@@ -29409,15 +29333,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
29409
29333
|
const sx = ow > 0 ? w / ow : 1;
|
|
29410
29334
|
const sy = oh > 0 ? h / oh : 1;
|
|
29411
29335
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
29412
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
29413
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
29336
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _464 => _464.getAttribute, 'call', _465 => _465("style")]), () => ( "SOLID"));
|
|
29337
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _466 => _466.getAttribute, 'call', _467 => _467("color")]) || "#000000";
|
|
29414
29338
|
const hasStroke = lstyle !== "NONE";
|
|
29415
29339
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
29416
29340
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
29417
29341
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
29418
29342
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
29419
29343
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
29420
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
29344
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _468 => _468.getAttribute, 'call', _469 => _469("faceColor")]);
|
|
29421
29345
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
29422
29346
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
29423
29347
|
if (o.tag === "rect") {
|
|
@@ -29449,7 +29373,7 @@ function cellContentExtent(cell2) {
|
|
|
29449
29373
|
if (ln2(p) !== "p") continue;
|
|
29450
29374
|
const m = buildPara(p);
|
|
29451
29375
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
29452
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
29376
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _470 => _470.segs, 'access', _471 => _471[0], 'optionalAccess', _472 => _472.vertpos]), () => ( 0));
|
|
29453
29377
|
for (const o of m.objs) {
|
|
29454
29378
|
if (o.inline) {
|
|
29455
29379
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -29457,7 +29381,7 @@ function cellContentExtent(cell2) {
|
|
|
29457
29381
|
continue;
|
|
29458
29382
|
}
|
|
29459
29383
|
const pos = findChildByLocalName(o.el, "pos");
|
|
29460
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
29384
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _473 => _473.getAttribute, 'call', _474 => _474("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
29461
29385
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
29462
29386
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
29463
29387
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
@@ -29543,7 +29467,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
29543
29467
|
}));
|
|
29544
29468
|
for (const g of geom) {
|
|
29545
29469
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
29546
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
29470
|
+
if (_optionalChain([bf, 'optionalAccess', _475 => _475.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
29547
29471
|
}
|
|
29548
29472
|
for (const g of geom) {
|
|
29549
29473
|
const { c } = g;
|
|
@@ -29581,7 +29505,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
29581
29505
|
const sz = findChildByLocalName(pic, "sz");
|
|
29582
29506
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
29583
29507
|
const img = findFirst(pic, "img");
|
|
29584
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
29508
|
+
const ref = _optionalChain([img, 'optionalAccess', _476 => _476.getAttribute, 'call', _477 => _477("binaryItemIDRef")]);
|
|
29585
29509
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
29586
29510
|
if (!loaded) {
|
|
29587
29511
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -29620,7 +29544,7 @@ function readSectionGeom(root) {
|
|
|
29620
29544
|
const pagePr = findFirst(root, "pagePr");
|
|
29621
29545
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
29622
29546
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
29623
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
29547
|
+
if (_optionalChain([pagePr, 'optionalAccess', _478 => _478.getAttribute, 'call', _479 => _479("landscape")]) === "NARROWLY" && PW < PH) {
|
|
29624
29548
|
const t = PW;
|
|
29625
29549
|
PW = PH;
|
|
29626
29550
|
PH = t;
|
|
@@ -29678,17 +29602,17 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
29678
29602
|
return { pages: ctx.pages, pageH };
|
|
29679
29603
|
}
|
|
29680
29604
|
async function renderHwpxToSvg(input, options) {
|
|
29681
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29605
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _480 => _480.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
29682
29606
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
29683
|
-
|
|
29607
|
+
_chunk6XAAYAWLcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
29684
29608
|
let zip;
|
|
29685
29609
|
try {
|
|
29686
29610
|
zip = await _jszip2.default.loadAsync(input);
|
|
29687
29611
|
} catch (e32) {
|
|
29688
|
-
throw new (0,
|
|
29612
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
29689
29613
|
}
|
|
29690
29614
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
29691
|
-
if (secFiles.length === 0) throw new (0,
|
|
29615
|
+
if (secFiles.length === 0) throw new (0, _chunk6XAAYAWLcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
29692
29616
|
const warnings = [];
|
|
29693
29617
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
29694
29618
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -29696,7 +29620,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29696
29620
|
const secXmls = [];
|
|
29697
29621
|
for (const f of secFiles) {
|
|
29698
29622
|
const xml = await f.async("string");
|
|
29699
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
29623
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
29700
29624
|
secXmls.push(xml);
|
|
29701
29625
|
}
|
|
29702
29626
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -29720,7 +29644,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29720
29644
|
let href = binmap.get(ref);
|
|
29721
29645
|
if (!href) {
|
|
29722
29646
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
29723
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
29647
|
+
href = _optionalChain([cand, 'optionalAccess', _481 => _481.name]);
|
|
29724
29648
|
}
|
|
29725
29649
|
if (!href) continue;
|
|
29726
29650
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -29741,7 +29665,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29741
29665
|
styles,
|
|
29742
29666
|
images,
|
|
29743
29667
|
defs: [],
|
|
29744
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
29668
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _482 => _482.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
29745
29669
|
warnings,
|
|
29746
29670
|
warned: /* @__PURE__ */ new Set(),
|
|
29747
29671
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -29751,7 +29675,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29751
29675
|
for (let si = 0; si < secXmls.length; si++) {
|
|
29752
29676
|
const secXml = secXmls[si];
|
|
29753
29677
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
29754
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
29678
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _483 => _483.reflow])) {
|
|
29755
29679
|
noCacheSkipped = true;
|
|
29756
29680
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
29757
29681
|
continue;
|
|
@@ -29763,14 +29687,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
29763
29687
|
continue;
|
|
29764
29688
|
}
|
|
29765
29689
|
const geom = readSectionGeom(root);
|
|
29766
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess',
|
|
29690
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, !!_optionalChain([options, 'optionalAccess', _484 => _484.reflow]), _nullishCoalesce(_optionalChain([options, 'optionalAccess', _485 => _485.reflowMode]), () => ( "keep")));
|
|
29767
29691
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
29768
29692
|
}
|
|
29769
29693
|
if (rendered.length === 0) {
|
|
29770
29694
|
if (noCacheSkipped) {
|
|
29771
|
-
throw new (0,
|
|
29695
|
+
throw new (0, _chunk6XAAYAWLcjs.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)");
|
|
29772
29696
|
}
|
|
29773
|
-
throw new (0,
|
|
29697
|
+
throw new (0, _chunk6XAAYAWLcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
29774
29698
|
}
|
|
29775
29699
|
const GAP = 2400;
|
|
29776
29700
|
const clipDefs = [];
|
|
@@ -29802,17 +29726,17 @@ ${groups.join("\n")}
|
|
|
29802
29726
|
// src/index.ts
|
|
29803
29727
|
async function parse(input, options) {
|
|
29804
29728
|
let buffer;
|
|
29805
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
29729
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _486 => _486.filePath]) ? { ...options, filePath: input } : options;
|
|
29806
29730
|
if (typeof input === "string") {
|
|
29807
29731
|
try {
|
|
29808
29732
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29809
|
-
buffer =
|
|
29733
|
+
buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, buf);
|
|
29810
29734
|
} catch (err) {
|
|
29811
29735
|
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}`;
|
|
29812
29736
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
29813
29737
|
}
|
|
29814
29738
|
} else if (Buffer.isBuffer(input)) {
|
|
29815
|
-
buffer =
|
|
29739
|
+
buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
|
|
29816
29740
|
} else {
|
|
29817
29741
|
buffer = input;
|
|
29818
29742
|
}
|
|
@@ -29847,21 +29771,21 @@ async function parseHwp3(buffer, options) {
|
|
|
29847
29771
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
29848
29772
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
29849
29773
|
} catch (err) {
|
|
29850
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29774
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29851
29775
|
}
|
|
29852
29776
|
}
|
|
29853
29777
|
async function parseHwpx(buffer, options) {
|
|
29854
29778
|
try {
|
|
29855
29779
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
29856
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
29780
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _487 => _487.length]) ? images : void 0 };
|
|
29857
29781
|
} catch (err) {
|
|
29858
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29782
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29859
29783
|
}
|
|
29860
29784
|
}
|
|
29861
29785
|
async function parseHwp(buffer, options) {
|
|
29862
29786
|
try {
|
|
29863
29787
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
29864
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
29788
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _488 => _488.filePath])) {
|
|
29865
29789
|
try {
|
|
29866
29790
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
29867
29791
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -29878,15 +29802,15 @@ async function parseHwp(buffer, options) {
|
|
|
29878
29802
|
} catch (e33) {
|
|
29879
29803
|
}
|
|
29880
29804
|
}
|
|
29881
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
29805
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _489 => _489.length]) ? images : void 0 };
|
|
29882
29806
|
} catch (err) {
|
|
29883
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29807
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29884
29808
|
}
|
|
29885
29809
|
}
|
|
29886
29810
|
async function parsePdf(buffer, options) {
|
|
29887
29811
|
let parsePdfDocument;
|
|
29888
29812
|
try {
|
|
29889
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
29813
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ITMU2WN5.cjs")));
|
|
29890
29814
|
parsePdfDocument = mod.parsePdfDocument;
|
|
29891
29815
|
} catch (e34) {
|
|
29892
29816
|
return {
|
|
@@ -29897,11 +29821,11 @@ async function parsePdf(buffer, options) {
|
|
|
29897
29821
|
};
|
|
29898
29822
|
}
|
|
29899
29823
|
try {
|
|
29900
|
-
const { markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary } = await parsePdfDocument(buffer, options);
|
|
29901
|
-
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
29824
|
+
const { markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images } = await parsePdfDocument(buffer, options);
|
|
29825
|
+
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
29902
29826
|
} catch (err) {
|
|
29903
29827
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
29904
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29828
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err), isImageBased };
|
|
29905
29829
|
}
|
|
29906
29830
|
}
|
|
29907
29831
|
async function parseXlsx(buffer, options) {
|
|
@@ -29909,7 +29833,7 @@ async function parseXlsx(buffer, options) {
|
|
|
29909
29833
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
29910
29834
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
29911
29835
|
} catch (err) {
|
|
29912
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29836
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29913
29837
|
}
|
|
29914
29838
|
}
|
|
29915
29839
|
async function parseXls(buffer, options) {
|
|
@@ -29917,15 +29841,15 @@ async function parseXls(buffer, options) {
|
|
|
29917
29841
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
29918
29842
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
29919
29843
|
} catch (err) {
|
|
29920
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29844
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29921
29845
|
}
|
|
29922
29846
|
}
|
|
29923
29847
|
async function parseDocx(buffer, options) {
|
|
29924
29848
|
try {
|
|
29925
29849
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
29926
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
29850
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _490 => _490.length]) ? images : void 0 };
|
|
29927
29851
|
} catch (err) {
|
|
29928
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29852
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29929
29853
|
}
|
|
29930
29854
|
}
|
|
29931
29855
|
async function parseHwpml(buffer, options) {
|
|
@@ -29933,16 +29857,16 @@ async function parseHwpml(buffer, options) {
|
|
|
29933
29857
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
29934
29858
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
29935
29859
|
} catch (err) {
|
|
29936
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
29860
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk6XAAYAWLcjs.classifyError.call(void 0, err) };
|
|
29937
29861
|
}
|
|
29938
29862
|
}
|
|
29939
29863
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
29940
29864
|
let buffer;
|
|
29941
29865
|
if (typeof input === "string") {
|
|
29942
29866
|
const buf = await _promises.readFile.call(void 0, input);
|
|
29943
|
-
buffer =
|
|
29867
|
+
buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, buf);
|
|
29944
29868
|
} else if (Buffer.isBuffer(input)) {
|
|
29945
|
-
buffer =
|
|
29869
|
+
buffer = _chunk6XAAYAWLcjs.toArrayBuffer.call(void 0, input);
|
|
29946
29870
|
} else {
|
|
29947
29871
|
buffer = input;
|
|
29948
29872
|
}
|
|
@@ -29968,7 +29892,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
29968
29892
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
29969
29893
|
}
|
|
29970
29894
|
const fill = fillFormFields(parsed.blocks, values);
|
|
29971
|
-
const markdown =
|
|
29895
|
+
const markdown = _chunk6XAAYAWLcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
29972
29896
|
if (outputFormat === "hwpx") {
|
|
29973
29897
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
29974
29898
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30037,5 +29961,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30037
29961
|
|
|
30038
29962
|
|
|
30039
29963
|
|
|
30040
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
29964
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunk6XAAYAWLcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk6XAAYAWLcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
30041
29965
|
//# sourceMappingURL=index.cjs.map
|