kordoc 4.2.3 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{-GJYDKVQD.js → -2M56QRNH.js} +8 -8
- package/dist/{chunk-LMNSIPWZ.js → chunk-7KRCQE3P.js} +2 -2
- package/dist/{chunk-U6XYOV32.js → chunk-7Z3NHIRR.js} +2 -2
- package/dist/{chunk-CWP56BRC.cjs → chunk-BLNOGMIM.cjs} +2 -2
- package/dist/chunk-BLNOGMIM.cjs.map +1 -0
- package/dist/{chunk-WX75LYAS.js → chunk-CAA6DVEE.js} +14 -12
- package/dist/chunk-CAA6DVEE.js.map +1 -0
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-NOMNOG74.js → chunk-DOLK5KIS.js} +2 -2
- package/dist/{chunk-RAS3HM4X.js → chunk-E2K4SNMD.js} +2 -2
- package/dist/{chunk-LPWP4FWU.js → chunk-GFTAPAJS.js} +2 -2
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-X634MXVJ.js → chunk-H6O65EPK.js} +2 -2
- package/dist/chunk-H7OWEYH2.cjs.map +1 -1
- package/dist/{chunk-DE6FORIP.js → chunk-I53FOXZR.js} +2 -2
- package/dist/{chunk-WTJIRGPN.js → chunk-LWNFAIYG.js} +3 -3
- package/dist/{chunk-AA6UPPZF.cjs → chunk-LXUZUUUG.cjs} +9 -9
- package/dist/chunk-LXUZUUUG.cjs.map +1 -0
- package/dist/{chunk-QNVZAKUQ.js → chunk-OBX3VSIZ.js} +2 -2
- package/dist/{chunk-ELRVXOMP.js → chunk-PMBWFYZQ.js} +2 -2
- package/dist/{chunk-K5LGSH5T.js → chunk-PQ46DC6Y.js} +2 -2
- package/dist/{chunk-5AXGFJQO.cjs → chunk-SCJLAOY3.cjs} +4 -4
- package/dist/chunk-SCJLAOY3.cjs.map +1 -0
- package/dist/{chunk-NIPPOAT6.js → chunk-WMM6XVQX.js} +2 -2
- package/dist/{chunk-FF5QNEKZ.cjs → chunk-YFSYLEXO.cjs} +3 -3
- package/dist/chunk-YFSYLEXO.cjs.map +1 -0
- package/dist/{chunk-CGFWS3BQ.js → chunk-ZHRYLT3N.js} +3 -3
- package/dist/chunks-GT45ALC5.js +10 -0
- package/dist/cli.js +16 -16
- package/dist/formula-SB3NHDUM.cjs.map +1 -1
- package/dist/{image-ocr-O3YQ3KEN.js → image-ocr-HY42AVXC.js} +4 -4
- package/dist/{image-ocr-TCJLNMTG.cjs → image-ocr-JWAX5EOB.cjs} +9 -9
- package/dist/image-ocr-JWAX5EOB.cjs.map +1 -0
- package/dist/{image-ocr-PLTV4NOK.js → image-ocr-WCIDB6RY.js} +4 -4
- package/dist/index.cjs +157 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +14 -14
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-VQIJPCI5.cjs → parser-6RDEBLSB.cjs} +24 -24
- package/dist/parser-6RDEBLSB.cjs.map +1 -0
- package/dist/{parser-UX5T6KTZ.js → parser-SVZPCCRG.js} +5 -5
- package/dist/{parser-Y2X4JMAK.js → parser-WRNS6MX2.js} +5 -5
- package/dist/pdf-ocr-4SGVLUNL.cjs +13 -0
- package/dist/pdf-ocr-4SGVLUNL.cjs.map +1 -0
- package/dist/pdf-ocr-7AAHJOXQ.js +12 -0
- package/dist/{pdf-ocr-DOPZP6QS.js → pdf-ocr-WM3RZMZY.js} +4 -4
- package/dist/{profile-io-EGVJAZDG.js → profile-io-SWGUQSCL.js} +3 -3
- package/dist/{rasterize-TH26U5E2.js → rasterize-QA7W6QUF.js} +2 -2
- package/dist/render-DRUIPV77.js +10 -0
- package/dist/seal-3M4ZSW66.js +10 -0
- package/dist/{watch-4SP7V6SV.js → watch-SFQNFU7Q.js} +8 -8
- package/package.json +1 -1
- package/dist/chunk-5AXGFJQO.cjs.map +0 -1
- package/dist/chunk-AA6UPPZF.cjs.map +0 -1
- package/dist/chunk-CWP56BRC.cjs.map +0 -1
- package/dist/chunk-FF5QNEKZ.cjs.map +0 -1
- package/dist/chunk-WX75LYAS.js.map +0 -1
- package/dist/chunks-JOGD2KUK.js +0 -10
- package/dist/image-ocr-TCJLNMTG.cjs.map +0 -1
- package/dist/parser-VQIJPCI5.cjs.map +0 -1
- package/dist/pdf-ocr-I3Y6YF5K.js +0 -12
- package/dist/pdf-ocr-XMDJ2IF5.cjs +0 -13
- package/dist/pdf-ocr-XMDJ2IF5.cjs.map +0 -1
- package/dist/render-C4R3OJ45.js +0 -10
- package/dist/seal-JF2J4S52.js +0 -10
- /package/dist/{-GJYDKVQD.js.map → -2M56QRNH.js.map} +0 -0
- /package/dist/{chunk-LMNSIPWZ.js.map → chunk-7KRCQE3P.js.map} +0 -0
- /package/dist/{chunk-U6XYOV32.js.map → chunk-7Z3NHIRR.js.map} +0 -0
- /package/dist/{chunk-NOMNOG74.js.map → chunk-DOLK5KIS.js.map} +0 -0
- /package/dist/{chunk-RAS3HM4X.js.map → chunk-E2K4SNMD.js.map} +0 -0
- /package/dist/{chunk-LPWP4FWU.js.map → chunk-GFTAPAJS.js.map} +0 -0
- /package/dist/{chunk-X634MXVJ.js.map → chunk-H6O65EPK.js.map} +0 -0
- /package/dist/{chunk-DE6FORIP.js.map → chunk-I53FOXZR.js.map} +0 -0
- /package/dist/{chunk-WTJIRGPN.js.map → chunk-LWNFAIYG.js.map} +0 -0
- /package/dist/{chunk-QNVZAKUQ.js.map → chunk-OBX3VSIZ.js.map} +0 -0
- /package/dist/{chunk-ELRVXOMP.js.map → chunk-PMBWFYZQ.js.map} +0 -0
- /package/dist/{chunk-K5LGSH5T.js.map → chunk-PQ46DC6Y.js.map} +0 -0
- /package/dist/{chunk-NIPPOAT6.js.map → chunk-WMM6XVQX.js.map} +0 -0
- /package/dist/{chunk-CGFWS3BQ.js.map → chunk-ZHRYLT3N.js.map} +0 -0
- /package/dist/{chunks-JOGD2KUK.js.map → chunks-GT45ALC5.js.map} +0 -0
- /package/dist/{image-ocr-O3YQ3KEN.js.map → image-ocr-HY42AVXC.js.map} +0 -0
- /package/dist/{image-ocr-PLTV4NOK.js.map → image-ocr-WCIDB6RY.js.map} +0 -0
- /package/dist/{parser-UX5T6KTZ.js.map → parser-SVZPCCRG.js.map} +0 -0
- /package/dist/{parser-Y2X4JMAK.js.map → parser-WRNS6MX2.js.map} +0 -0
- /package/dist/{pdf-ocr-DOPZP6QS.js.map → pdf-ocr-7AAHJOXQ.js.map} +0 -0
- /package/dist/{pdf-ocr-I3Y6YF5K.js.map → pdf-ocr-WM3RZMZY.js.map} +0 -0
- /package/dist/{profile-io-EGVJAZDG.js.map → profile-io-SWGUQSCL.js.map} +0 -0
- /package/dist/{rasterize-TH26U5E2.js.map → rasterize-QA7W6QUF.js.map} +0 -0
- /package/dist/{render-C4R3OJ45.js.map → render-DRUIPV77.js.map} +0 -0
- /package/dist/{seal-JF2J4S52.js.map → seal-3M4ZSW66.js.map} +0 -0
- /package/dist/{watch-4SP7V6SV.js.map → watch-SFQNFU7Q.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkSCJLAOY3cjs = require('./chunk-SCJLAOY3.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -27,7 +27,7 @@ var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkBLNOGMIMcjs = require('./chunk-BLNOGMIM.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -413,7 +413,7 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
413
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
414
414
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
415
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
416
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkBLNOGMIMcjs.KordocError {
|
|
417
417
|
constructor(message) {
|
|
418
418
|
super(message);
|
|
419
419
|
this.name = "ZipBombError";
|
|
@@ -429,7 +429,7 @@ function createSectionShared() {
|
|
|
429
429
|
function createXmlParser(warnings) {
|
|
430
430
|
return new (0, _xmldom.DOMParser)({
|
|
431
431
|
onError(level, msg2) {
|
|
432
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkBLNOGMIMcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
433
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -506,10 +506,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
506
506
|
const xml = await file.async("text");
|
|
507
507
|
if (decompressed) {
|
|
508
508
|
decompressed.total += xml.length * 2;
|
|
509
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
509
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
510
510
|
}
|
|
511
511
|
const parser = createXmlParser();
|
|
512
|
-
const doc = parser.parseFromString(
|
|
512
|
+
const doc = parser.parseFromString(_chunkBLNOGMIMcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
513
513
|
if (!doc.documentElement) continue;
|
|
514
514
|
const domDoc = doc;
|
|
515
515
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -696,9 +696,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
696
696
|
let level = 0;
|
|
697
697
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
698
698
|
const ratio = block.style.fontSize / baseFontSize;
|
|
699
|
-
if (ratio >=
|
|
700
|
-
else if (ratio >=
|
|
701
|
-
else if (ratio >=
|
|
699
|
+
if (ratio >= _chunkBLNOGMIMcjs.HEADING_RATIO_H1) level = 1;
|
|
700
|
+
else if (ratio >= _chunkBLNOGMIMcjs.HEADING_RATIO_H2) level = 2;
|
|
701
|
+
else if (ratio >= _chunkBLNOGMIMcjs.HEADING_RATIO_H3) level = 3;
|
|
702
702
|
}
|
|
703
703
|
const compactText = text.replace(/\s+/g, "");
|
|
704
704
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1623,7 +1623,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
function assertFiniteRange(name, value, min, max) {
|
|
1625
1625
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1626
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1627
1627
|
}
|
|
1628
1628
|
}
|
|
1629
1629
|
function validateGongmunOptions(opts) {
|
|
@@ -1638,10 +1638,10 @@ function validateGongmunOptions(opts) {
|
|
|
1638
1638
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1639
1639
|
}
|
|
1640
1640
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1641
|
-
throw new (0,
|
|
1641
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1642
1642
|
}
|
|
1643
1643
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1644
|
-
throw new (0,
|
|
1644
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1645
1645
|
}
|
|
1646
1646
|
}
|
|
1647
1647
|
if (opts.sizes) {
|
|
@@ -1650,7 +1650,7 @@ function validateGongmunOptions(opts) {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
if (opts.approval && opts.approval.length > 6) {
|
|
1653
|
-
throw new (0,
|
|
1653
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("approval must contain at most 6 labels");
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1915,7 +1915,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1915
1915
|
|
|
1916
1916
|
// src/hwpx/table-build.ts
|
|
1917
1917
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1918
|
-
const table2 =
|
|
1918
|
+
const table2 = _chunkSCJLAOY3cjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1919
1919
|
if (state.caption) table2.caption = state.caption;
|
|
1920
1920
|
const anchors = [];
|
|
1921
1921
|
{
|
|
@@ -1985,7 +1985,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1985
1985
|
const cell2 = parentTable.cell;
|
|
1986
1986
|
(cell2.blocks ??= []).push(block);
|
|
1987
1987
|
cell2.hasStructure = true;
|
|
1988
|
-
let flat =
|
|
1988
|
+
let flat = _chunkSCJLAOY3cjs.convertTableToText.call(void 0, newTable.rows);
|
|
1989
1989
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1990
1990
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1991
1991
|
} else {
|
|
@@ -1997,7 +1997,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1997
1997
|
// src/hwpx/section-walker.ts
|
|
1998
1998
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1999
1999
|
const parser = createXmlParser(warnings);
|
|
2000
|
-
const doc = parser.parseFromString(
|
|
2000
|
+
const doc = parser.parseFromString(_chunkBLNOGMIMcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2001
2001
|
if (!doc.documentElement) return [];
|
|
2002
2002
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
2003
2003
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2103,8 +2103,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2103
2103
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2104
2104
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2105
2105
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2106
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2107
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2106
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkSCJLAOY3cjs.MAX_COLS);
|
|
2107
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkSCJLAOY3cjs.MAX_ROWS);
|
|
2108
2108
|
}
|
|
2109
2109
|
break;
|
|
2110
2110
|
case "p": {
|
|
@@ -2118,7 +2118,6 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2118
2118
|
}
|
|
2119
2119
|
if (segments) {
|
|
2120
2120
|
const cell2 = _nullishCoalesce(_optionalChain([tableCtx, 'optionalAccess', _36 => _36.cell]), () => ( null));
|
|
2121
|
-
if (text && cell2) cell2.text += (cell2.text ? "\n" : "") + (footnote ? `${text} (\uC8FC: ${footnote})` : text);
|
|
2122
2121
|
const segs = [...segments];
|
|
2123
2122
|
if (_optionalChain([ph, 'optionalAccess', _37 => _37.prefix])) {
|
|
2124
2123
|
const fi = segs.findIndex((s) => s);
|
|
@@ -2136,11 +2135,14 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2136
2135
|
if (href) block.href = href;
|
|
2137
2136
|
if (footnote) block.footnoteText = footnote;
|
|
2138
2137
|
}
|
|
2139
|
-
if (cell2)
|
|
2140
|
-
|
|
2138
|
+
if (cell2) {
|
|
2139
|
+
cell2.text += (cell2.text ? "\n" : "") + s;
|
|
2140
|
+
(cell2.blocks ??= []).push(block);
|
|
2141
|
+
} else blocks.push(block);
|
|
2141
2142
|
};
|
|
2142
2143
|
tableCtx = walkParagraphChildren(el, blocks, tableCtx, tableStack, ctx, depth + 1, flush);
|
|
2143
2144
|
while (segIdx < segs.length) flush();
|
|
2145
|
+
if (footnote && cell2) cell2.text += (cell2.text ? "\n" : "") + `(\uC8FC: ${footnote})`;
|
|
2144
2146
|
break;
|
|
2145
2147
|
}
|
|
2146
2148
|
if (text) {
|
|
@@ -2342,7 +2344,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2342
2344
|
const sink = [];
|
|
2343
2345
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2344
2346
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2345
|
-
let flat =
|
|
2347
|
+
let flat = _chunkSCJLAOY3cjs.convertTableToText.call(void 0, st.rows);
|
|
2346
2348
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2347
2349
|
return flat;
|
|
2348
2350
|
}
|
|
@@ -2375,7 +2377,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2375
2377
|
const tag = el.tagName || el.localName || "";
|
|
2376
2378
|
const localTag = tag.replace(/^[^:]+:/, "");
|
|
2377
2379
|
if (localTag === "tbl") {
|
|
2378
|
-
if (onTbl
|
|
2380
|
+
if (onTbl) onTbl();
|
|
2379
2381
|
if (!tableCtx) {
|
|
2380
2382
|
const chan = kordocTableChannel(el, ctx);
|
|
2381
2383
|
if (chan) {
|
|
@@ -2479,7 +2481,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2479
2481
|
let url = (ch.textContent || "").trim();
|
|
2480
2482
|
if (!url) continue;
|
|
2481
2483
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2482
|
-
const safe =
|
|
2484
|
+
const safe = _chunkBLNOGMIMcjs.sanitizeHref.call(void 0, url);
|
|
2483
2485
|
if (safe) return safe;
|
|
2484
2486
|
}
|
|
2485
2487
|
return void 0;
|
|
@@ -2639,7 +2641,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2639
2641
|
case "hyperlink": {
|
|
2640
2642
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2641
2643
|
if (url) {
|
|
2642
|
-
const safe =
|
|
2644
|
+
const safe = _chunkBLNOGMIMcjs.sanitizeHref.call(void 0, url);
|
|
2643
2645
|
if (safe) href = safe;
|
|
2644
2646
|
}
|
|
2645
2647
|
walk(child, depth + 1);
|
|
@@ -2913,7 +2915,7 @@ function decompressStream(data) {
|
|
|
2913
2915
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2914
2916
|
}
|
|
2915
2917
|
function parseFileHeader(data) {
|
|
2916
|
-
if (data.length < 40) throw new (0,
|
|
2918
|
+
if (data.length < 40) throw new (0, _chunkBLNOGMIMcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2917
2919
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2918
2920
|
return {
|
|
2919
2921
|
signature: sig,
|
|
@@ -3362,13 +3364,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3362
3364
|
}
|
|
3363
3365
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3364
3366
|
for (const path of allCandidates) {
|
|
3365
|
-
if (
|
|
3367
|
+
if (_chunkBLNOGMIMcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3366
3368
|
const file = zip.file(path);
|
|
3367
3369
|
if (!file) continue;
|
|
3368
3370
|
try {
|
|
3369
3371
|
const data = await file.async("uint8array");
|
|
3370
3372
|
decompressed.total += data.length;
|
|
3371
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3373
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3372
3374
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3373
3375
|
const mimeType = imageExtToMime(ext);
|
|
3374
3376
|
imageIndex++;
|
|
@@ -3378,7 +3380,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3378
3380
|
usedPaths.add(path);
|
|
3379
3381
|
break;
|
|
3380
3382
|
} catch (err) {
|
|
3381
|
-
if (err instanceof
|
|
3383
|
+
if (err instanceof _chunkBLNOGMIMcjs.KordocError) throw err;
|
|
3382
3384
|
}
|
|
3383
3385
|
}
|
|
3384
3386
|
if (!img) _optionalChain([warnings, 'optionalAccess', _78 => _78.push, 'call', _79 => _79({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -3398,11 +3400,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3398
3400
|
if (sweepUnreferenced) {
|
|
3399
3401
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3400
3402
|
for (const file of binEntries) {
|
|
3401
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3403
|
+
if (file.dir || usedPaths.has(file.name) || _chunkBLNOGMIMcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3402
3404
|
try {
|
|
3403
3405
|
const data = await file.async("uint8array");
|
|
3404
3406
|
decompressed.total += data.length;
|
|
3405
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3407
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3406
3408
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3407
3409
|
let mimeType = imageExtToMime(ext);
|
|
3408
3410
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3416,7 +3418,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3416
3418
|
images.push(img);
|
|
3417
3419
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3418
3420
|
} catch (err) {
|
|
3419
|
-
if (err instanceof
|
|
3421
|
+
if (err instanceof _chunkBLNOGMIMcjs.KordocError) throw err;
|
|
3420
3422
|
_optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3421
3423
|
}
|
|
3422
3424
|
}
|
|
@@ -3467,7 +3469,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3467
3469
|
}
|
|
3468
3470
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3469
3471
|
const name = new TextDecoder().decode(nameBytes);
|
|
3470
|
-
if (
|
|
3472
|
+
if (_chunkBLNOGMIMcjs.isPathTraversal.call(void 0, name)) {
|
|
3471
3473
|
pos = fileStart + compSize;
|
|
3472
3474
|
continue;
|
|
3473
3475
|
}
|
|
@@ -3485,16 +3487,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3485
3487
|
continue;
|
|
3486
3488
|
}
|
|
3487
3489
|
totalDecompressed += content.length * 2;
|
|
3488
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3490
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3489
3491
|
sectionNum++;
|
|
3490
3492
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3491
3493
|
} catch (e16) {
|
|
3492
3494
|
continue;
|
|
3493
3495
|
}
|
|
3494
3496
|
}
|
|
3495
|
-
if (blocks.length === 0) throw new (0,
|
|
3497
|
+
if (blocks.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3496
3498
|
applyPageText(blocks, shared);
|
|
3497
|
-
const markdown =
|
|
3499
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks);
|
|
3498
3500
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3499
3501
|
}
|
|
3500
3502
|
async function readKordocLayout(zip) {
|
|
@@ -3519,18 +3521,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3519
3521
|
if (paths.length > 0) return paths;
|
|
3520
3522
|
}
|
|
3521
3523
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3522
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3524
|
+
return sectionFiles.map((f) => f.name).sort(_chunkBLNOGMIMcjs.compareSectionPaths);
|
|
3523
3525
|
}
|
|
3524
3526
|
function parseSectionPathsFromManifest(xml) {
|
|
3525
3527
|
const parser = createXmlParser();
|
|
3526
|
-
const doc = parser.parseFromString(
|
|
3528
|
+
const doc = parser.parseFromString(_chunkBLNOGMIMcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3527
3529
|
const items = doc.getElementsByTagName("opf:item");
|
|
3528
3530
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3529
3531
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3530
3532
|
for (let i = 0; i < items.length; i++) {
|
|
3531
3533
|
const item = items[i];
|
|
3532
3534
|
const id = item.getAttribute("id") || "";
|
|
3533
|
-
const href =
|
|
3535
|
+
const href = _chunkBLNOGMIMcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3534
3536
|
if (id && href) idToHref.set(id, href);
|
|
3535
3537
|
}
|
|
3536
3538
|
if (spine.length > 0) {
|
|
@@ -3541,7 +3543,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3541
3543
|
}
|
|
3542
3544
|
if (ordered.length > 0) return ordered;
|
|
3543
3545
|
}
|
|
3544
|
-
return Array.from(idToHref.values()).sort(
|
|
3546
|
+
return Array.from(idToHref.values()).sort(_chunkBLNOGMIMcjs.compareSectionPaths);
|
|
3545
3547
|
}
|
|
3546
3548
|
|
|
3547
3549
|
// src/hwpx/metadata.ts
|
|
@@ -3554,7 +3556,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3554
3556
|
const xml = await file.async("text");
|
|
3555
3557
|
if (decompressed) {
|
|
3556
3558
|
decompressed.total += xml.length * 2;
|
|
3557
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3559
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3558
3560
|
}
|
|
3559
3561
|
parseDublinCoreMetadata(xml, metadata);
|
|
3560
3562
|
if (metadata.title || metadata.author) return;
|
|
@@ -3564,7 +3566,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3564
3566
|
}
|
|
3565
3567
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3566
3568
|
const parser = createXmlParser();
|
|
3567
|
-
const doc = parser.parseFromString(
|
|
3569
|
+
const doc = parser.parseFromString(_chunkBLNOGMIMcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3568
3570
|
if (!doc.documentElement) return;
|
|
3569
3571
|
const getText = (tagNames) => {
|
|
3570
3572
|
for (const tag of tagNames) {
|
|
@@ -3589,7 +3591,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3589
3591
|
|
|
3590
3592
|
// src/hwpx/parser.ts
|
|
3591
3593
|
async function parseHwpxDocument(buffer, options) {
|
|
3592
|
-
|
|
3594
|
+
_chunkBLNOGMIMcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3593
3595
|
let zip;
|
|
3594
3596
|
try {
|
|
3595
3597
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3598,7 +3600,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3598
3600
|
}
|
|
3599
3601
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3600
3602
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3601
|
-
throw new (0,
|
|
3603
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3602
3604
|
}
|
|
3603
3605
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3604
3606
|
if (manifestFile) {
|
|
@@ -3610,7 +3612,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3610
3612
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3611
3613
|
}
|
|
3612
3614
|
}
|
|
3613
|
-
throw new (0,
|
|
3615
|
+
throw new (0, _chunkBLNOGMIMcjs.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.");
|
|
3614
3616
|
}
|
|
3615
3617
|
}
|
|
3616
3618
|
const decompressed = { total: 0 };
|
|
@@ -3619,7 +3621,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3619
3621
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3620
3622
|
const warnings = [];
|
|
3621
3623
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3622
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3624
|
+
if (sectionPaths.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3623
3625
|
metadata.pageCount = sectionPaths.length;
|
|
3624
3626
|
const pageFilter = _optionalChain([options, 'optionalAccess', _90 => _90.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3625
3627
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3648,7 +3650,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3648
3650
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3649
3651
|
detectHwpxHeadings(blocks, styleMap);
|
|
3650
3652
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3651
|
-
const markdown =
|
|
3653
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks);
|
|
3652
3654
|
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 };
|
|
3653
3655
|
}
|
|
3654
3656
|
|
|
@@ -4827,7 +4829,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4827
4829
|
lenientCfb = parseLenientCfb(buffer);
|
|
4828
4830
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4829
4831
|
} catch (e22) {
|
|
4830
|
-
throw new (0,
|
|
4832
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4831
4833
|
}
|
|
4832
4834
|
}
|
|
4833
4835
|
const findStream = (path) => {
|
|
@@ -4838,11 +4840,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4838
4840
|
return lenientCfb.findStream(path);
|
|
4839
4841
|
};
|
|
4840
4842
|
const headerData = findStream("/FileHeader");
|
|
4841
|
-
if (!headerData) throw new (0,
|
|
4843
|
+
if (!headerData) throw new (0, _chunkBLNOGMIMcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4842
4844
|
const header = parseFileHeader(headerData);
|
|
4843
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4844
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4845
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4845
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkBLNOGMIMcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4846
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4847
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkBLNOGMIMcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4846
4848
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4847
4849
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4848
4850
|
const metadata = {
|
|
@@ -4851,7 +4853,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4851
4853
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4852
4854
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4853
4855
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4854
|
-
if (sections.length === 0) throw new (0,
|
|
4856
|
+
if (sections.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4855
4857
|
metadata.pageCount = sections.length;
|
|
4856
4858
|
const pageFilter = _optionalChain([options, 'optionalAccess', _95 => _95.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4857
4859
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4866,22 +4868,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4866
4868
|
const sectionData = sections[si];
|
|
4867
4869
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4868
4870
|
totalDecompressed += data.length;
|
|
4869
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4871
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4870
4872
|
const records = readRecords(data);
|
|
4871
4873
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4872
4874
|
bodyBlocks.push(...sectionBlocks);
|
|
4873
4875
|
parsedSections++;
|
|
4874
4876
|
_optionalChain([options, 'optionalAccess', _97 => _97.onProgress, 'optionalCall', _98 => _98(parsedSections, totalTarget)]);
|
|
4875
4877
|
} catch (secErr) {
|
|
4876
|
-
if (secErr instanceof
|
|
4878
|
+
if (secErr instanceof _chunkBLNOGMIMcjs.KordocError) throw secErr;
|
|
4877
4879
|
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" });
|
|
4878
4880
|
}
|
|
4879
4881
|
}
|
|
4880
4882
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4881
4883
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4882
|
-
let flatBlocks =
|
|
4884
|
+
let flatBlocks = _chunkSCJLAOY3cjs.flattenLayoutTables.call(void 0, blocks);
|
|
4883
4885
|
if (_optionalChain([options, 'optionalAccess', _99 => _99.dedupeRunningHeaders])) {
|
|
4884
|
-
const deduped =
|
|
4886
|
+
const deduped = _chunkSCJLAOY3cjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4885
4887
|
const removed = flatBlocks.length - deduped.length;
|
|
4886
4888
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4887
4889
|
flatBlocks = deduped;
|
|
@@ -4890,10 +4892,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4890
4892
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4891
4893
|
}
|
|
4892
4894
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4893
|
-
let markdown =
|
|
4895
|
+
let markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4894
4896
|
if (_optionalChain([options, 'optionalAccess', _100 => _100.inlineImages]) && images.length > 0) {
|
|
4895
4897
|
try {
|
|
4896
|
-
markdown =
|
|
4898
|
+
markdown = _chunkSCJLAOY3cjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4897
4899
|
} catch (inlineErr) {
|
|
4898
4900
|
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" });
|
|
4899
4901
|
}
|
|
@@ -4957,9 +4959,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4957
4959
|
let level = 0;
|
|
4958
4960
|
if (_optionalChain([block, 'access', _105 => _105.style, 'optionalAccess', _106 => _106.fontSize]) && baseFontSize > 0) {
|
|
4959
4961
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4960
|
-
if (ratio >=
|
|
4961
|
-
else if (ratio >=
|
|
4962
|
-
else if (ratio >=
|
|
4962
|
+
if (ratio >= _chunkBLNOGMIMcjs.HEADING_RATIO_H1) level = 1;
|
|
4963
|
+
else if (ratio >= _chunkBLNOGMIMcjs.HEADING_RATIO_H2) level = 2;
|
|
4964
|
+
else if (ratio >= _chunkBLNOGMIMcjs.HEADING_RATIO_H3) level = 3;
|
|
4963
4965
|
}
|
|
4964
4966
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4965
4967
|
if (level === 0) level = 2;
|
|
@@ -5044,7 +5046,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5044
5046
|
if (!raw) break;
|
|
5045
5047
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5046
5048
|
totalDecompressed += content.length;
|
|
5047
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5049
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5048
5050
|
sections.push({ idx: i, content });
|
|
5049
5051
|
}
|
|
5050
5052
|
if (sections.length === 0) {
|
|
@@ -5056,7 +5058,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5056
5058
|
if (raw) {
|
|
5057
5059
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5058
5060
|
totalDecompressed += content.length;
|
|
5059
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5061
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5060
5062
|
sections.push({ idx, content });
|
|
5061
5063
|
}
|
|
5062
5064
|
}
|
|
@@ -5073,7 +5075,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5073
5075
|
try {
|
|
5074
5076
|
const content = decryptViewText(raw, compressed);
|
|
5075
5077
|
totalDecompressed += content.length;
|
|
5076
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5078
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5077
5079
|
sections.push({ idx: i, content });
|
|
5078
5080
|
} catch (e27) {
|
|
5079
5081
|
break;
|
|
@@ -5176,7 +5178,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5176
5178
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5177
5179
|
if (!_optionalChain([ctrl, 'optionalAccess', _113 => _113.href]) || r.end <= r.start) continue;
|
|
5178
5180
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5179
|
-
const href =
|
|
5181
|
+
const href = _chunkBLNOGMIMcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5180
5182
|
if (!href) continue;
|
|
5181
5183
|
const anchor = text.slice(r.start, r.end);
|
|
5182
5184
|
if (!anchor.trim()) continue;
|
|
@@ -5412,8 +5414,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5412
5414
|
let tableIdx = -1;
|
|
5413
5415
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5414
5416
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5415
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5416
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5417
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkSCJLAOY3cjs.MAX_ROWS);
|
|
5418
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkSCJLAOY3cjs.MAX_COLS);
|
|
5417
5419
|
tableIdx = i2;
|
|
5418
5420
|
break;
|
|
5419
5421
|
}
|
|
@@ -5462,7 +5464,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5462
5464
|
return table3;
|
|
5463
5465
|
}
|
|
5464
5466
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5465
|
-
const table2 =
|
|
5467
|
+
const table2 = _chunkSCJLAOY3cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5466
5468
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5467
5469
|
return table2.rows > 0 ? table2 : null;
|
|
5468
5470
|
}
|
|
@@ -5479,8 +5481,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5479
5481
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5480
5482
|
const cs = rec.data.readUInt16LE(12);
|
|
5481
5483
|
const rs = rec.data.readUInt16LE(14);
|
|
5482
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5483
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5484
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkSCJLAOY3cjs.MAX_COLS);
|
|
5485
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkSCJLAOY3cjs.MAX_ROWS);
|
|
5484
5486
|
}
|
|
5485
5487
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5486
5488
|
const parts = [];
|
|
@@ -5490,7 +5492,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5490
5492
|
parts.push(``);
|
|
5491
5493
|
hasStructure = true;
|
|
5492
5494
|
} else if (b.type === "table" && b.table) {
|
|
5493
|
-
const flat =
|
|
5495
|
+
const flat = _chunkSCJLAOY3cjs.convertTableToText.call(void 0, b.table.cells);
|
|
5494
5496
|
if (flat) parts.push(flat);
|
|
5495
5497
|
hasStructure = true;
|
|
5496
5498
|
} else if (b.text) {
|
|
@@ -17985,7 +17987,7 @@ function getTextContent(el) {
|
|
|
17985
17987
|
return _nullishCoalesce(_optionalChain([el, 'access', _129 => _129.textContent, 'optionalAccess', _130 => _130.trim, 'call', _131 => _131()]), () => ( ""));
|
|
17986
17988
|
}
|
|
17987
17989
|
function parseXml(text) {
|
|
17988
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17990
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkBLNOGMIMcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17989
17991
|
}
|
|
17990
17992
|
function collectRichText(root) {
|
|
17991
17993
|
let out = "";
|
|
@@ -18220,7 +18222,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18220
18222
|
cellRows.push(row);
|
|
18221
18223
|
}
|
|
18222
18224
|
if (cellRows.length > 0) {
|
|
18223
|
-
const table2 =
|
|
18225
|
+
const table2 = _chunkSCJLAOY3cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18224
18226
|
if (table2.rows > 0) {
|
|
18225
18227
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18226
18228
|
}
|
|
@@ -18228,12 +18230,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18228
18230
|
return blocks;
|
|
18229
18231
|
}
|
|
18230
18232
|
async function parseXlsxDocument(buffer, options) {
|
|
18231
|
-
|
|
18233
|
+
_chunkBLNOGMIMcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18232
18234
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18233
18235
|
const warnings = [];
|
|
18234
18236
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18235
18237
|
if (!workbookFile) {
|
|
18236
|
-
throw new (0,
|
|
18238
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18237
18239
|
}
|
|
18238
18240
|
let sharedStrings = [];
|
|
18239
18241
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18242,7 +18244,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18242
18244
|
}
|
|
18243
18245
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18244
18246
|
if (sheets.length === 0) {
|
|
18245
|
-
throw new (0,
|
|
18247
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18246
18248
|
}
|
|
18247
18249
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18248
18250
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18322,7 +18324,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18322
18324
|
} catch (e29) {
|
|
18323
18325
|
}
|
|
18324
18326
|
}
|
|
18325
|
-
const markdown =
|
|
18327
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18326
18328
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18327
18329
|
}
|
|
18328
18330
|
|
|
@@ -18773,11 +18775,11 @@ function processGlobals(records) {
|
|
|
18773
18775
|
const xfFmtIds = [];
|
|
18774
18776
|
const firstBof = records[0];
|
|
18775
18777
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18776
|
-
throw new (0,
|
|
18778
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18777
18779
|
}
|
|
18778
18780
|
const bof = decodeBof(firstBof.data);
|
|
18779
18781
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18780
|
-
throw new (0,
|
|
18782
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18781
18783
|
}
|
|
18782
18784
|
let i = 1;
|
|
18783
18785
|
while (i < records.length) {
|
|
@@ -18912,7 +18914,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18912
18914
|
cellRows.push(row);
|
|
18913
18915
|
}
|
|
18914
18916
|
if (cellRows.length > 0) {
|
|
18915
|
-
const table2 =
|
|
18917
|
+
const table2 = _chunkSCJLAOY3cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18916
18918
|
if (table2.rows > 0) {
|
|
18917
18919
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18918
18920
|
}
|
|
@@ -18925,21 +18927,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18925
18927
|
try {
|
|
18926
18928
|
cfb = parseLenientCfb(buf);
|
|
18927
18929
|
} catch (e) {
|
|
18928
|
-
throw new (0,
|
|
18930
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
18929
18931
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18930
18932
|
);
|
|
18931
18933
|
}
|
|
18932
18934
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18933
18935
|
if (!wb) {
|
|
18934
|
-
throw new (0,
|
|
18936
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18935
18937
|
}
|
|
18936
18938
|
const records = readRecords2(wb);
|
|
18937
18939
|
if (records.length === 0) {
|
|
18938
|
-
throw new (0,
|
|
18940
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18939
18941
|
}
|
|
18940
18942
|
const firstBof = decodeBof(records[0].data);
|
|
18941
18943
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18942
|
-
throw new (0,
|
|
18944
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
18943
18945
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18944
18946
|
);
|
|
18945
18947
|
}
|
|
@@ -19007,7 +19009,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
19007
19009
|
pageCount: totalSheets
|
|
19008
19010
|
};
|
|
19009
19011
|
return {
|
|
19010
|
-
markdown:
|
|
19012
|
+
markdown: _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
19011
19013
|
blocks: allBlocks,
|
|
19012
19014
|
metadata,
|
|
19013
19015
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19463,7 +19465,7 @@ function getAttr(el, localName2) {
|
|
|
19463
19465
|
return null;
|
|
19464
19466
|
}
|
|
19465
19467
|
function parseXml2(text) {
|
|
19466
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19468
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkBLNOGMIMcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19467
19469
|
}
|
|
19468
19470
|
function parseStyles(xml) {
|
|
19469
19471
|
const doc = parseXml2(xml);
|
|
@@ -19621,7 +19623,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19621
19623
|
function makeLink(text, rawHref) {
|
|
19622
19624
|
if (!text) return "";
|
|
19623
19625
|
if (!rawHref) return text;
|
|
19624
|
-
const href =
|
|
19626
|
+
const href = _chunkBLNOGMIMcjs.sanitizeHref.call(void 0, rawHref);
|
|
19625
19627
|
return href ? `[${text}](${href})` : text;
|
|
19626
19628
|
}
|
|
19627
19629
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19815,7 +19817,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19815
19817
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19816
19818
|
})
|
|
19817
19819
|
);
|
|
19818
|
-
const table2 =
|
|
19820
|
+
const table2 = _chunkSCJLAOY3cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19819
19821
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19820
19822
|
return { type: "table", table: table2 };
|
|
19821
19823
|
}
|
|
@@ -19917,12 +19919,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19917
19919
|
}
|
|
19918
19920
|
}
|
|
19919
19921
|
async function parseDocxDocument(buffer, options) {
|
|
19920
|
-
|
|
19922
|
+
_chunkBLNOGMIMcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19921
19923
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19922
19924
|
const warnings = [];
|
|
19923
19925
|
const docFile = zip.file("word/document.xml");
|
|
19924
19926
|
if (!docFile) {
|
|
19925
|
-
throw new (0,
|
|
19927
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19926
19928
|
}
|
|
19927
19929
|
let rels = /* @__PURE__ */ new Map();
|
|
19928
19930
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19969,7 +19971,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19969
19971
|
const doc = parseXml2(docXml);
|
|
19970
19972
|
const body = findElements(doc, "body");
|
|
19971
19973
|
if (body.length === 0) {
|
|
19972
|
-
throw new (0,
|
|
19974
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19973
19975
|
}
|
|
19974
19976
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19975
19977
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -20020,7 +20022,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
20020
20022
|
}
|
|
20021
20023
|
}
|
|
20022
20024
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
20023
|
-
const markdown =
|
|
20025
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks);
|
|
20024
20026
|
return {
|
|
20025
20027
|
markdown,
|
|
20026
20028
|
blocks,
|
|
@@ -20043,7 +20045,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20043
20045
|
}
|
|
20044
20046
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
20045
20047
|
const normalized = text.replace(/ /g, " ");
|
|
20046
|
-
const xml =
|
|
20048
|
+
const xml = _chunkBLNOGMIMcjs.stripDtd.call(void 0, normalized);
|
|
20047
20049
|
const warnings = [];
|
|
20048
20050
|
const parser = new (0, _xmldom.DOMParser)({
|
|
20049
20051
|
onError: (_level, msg2) => {
|
|
@@ -20083,7 +20085,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20083
20085
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.keepTrailingEmptyCols]), () => ( false)));
|
|
20084
20086
|
}
|
|
20085
20087
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20086
|
-
const markdown =
|
|
20088
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks);
|
|
20087
20089
|
return {
|
|
20088
20090
|
markdown,
|
|
20089
20091
|
blocks,
|
|
@@ -20228,7 +20230,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20228
20230
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20229
20231
|
cellRows[r].push(cell2);
|
|
20230
20232
|
}
|
|
20231
|
-
const table2 =
|
|
20233
|
+
const table2 = _chunkSCJLAOY3cjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20232
20234
|
const caption = extractShapeCaption(el);
|
|
20233
20235
|
if (caption.text && caption.before) {
|
|
20234
20236
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21610,19 +21612,19 @@ function parseCentralDirectory(buf) {
|
|
|
21610
21612
|
}
|
|
21611
21613
|
}
|
|
21612
21614
|
}
|
|
21613
|
-
if (eocdOffset < 0) throw new (0,
|
|
21615
|
+
if (eocdOffset < 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21614
21616
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21615
21617
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21616
21618
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21617
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21619
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21618
21620
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21619
|
-
throw new (0,
|
|
21621
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21620
21622
|
}
|
|
21621
21623
|
const decoder = new TextDecoder("utf-8");
|
|
21622
21624
|
const entries = [];
|
|
21623
21625
|
let pos = cdOffset;
|
|
21624
21626
|
for (let i = 0; i < totalEntries; i++) {
|
|
21625
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21627
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21626
21628
|
const flags = view.getUint16(pos + 8, true);
|
|
21627
21629
|
const method = view.getUint16(pos + 10, true);
|
|
21628
21630
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21633,7 +21635,7 @@ function parseCentralDirectory(buf) {
|
|
|
21633
21635
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21634
21636
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21635
21637
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21636
|
-
throw new (0,
|
|
21638
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21637
21639
|
}
|
|
21638
21640
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21639
21641
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21662,11 +21664,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21662
21664
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21663
21665
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21664
21666
|
for (const name of replacements.keys()) {
|
|
21665
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21667
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkBLNOGMIMcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21666
21668
|
}
|
|
21667
21669
|
if (additions) {
|
|
21668
21670
|
for (const name of additions.keys()) {
|
|
21669
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21671
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkBLNOGMIMcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21670
21672
|
}
|
|
21671
21673
|
}
|
|
21672
21674
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21685,7 +21687,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21685
21687
|
offset += seg.length;
|
|
21686
21688
|
continue;
|
|
21687
21689
|
}
|
|
21688
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21690
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkBLNOGMIMcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21689
21691
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21690
21692
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21691
21693
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21693,7 +21695,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21693
21695
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21694
21696
|
const method = e.method;
|
|
21695
21697
|
if (method !== 0 && method !== 8) {
|
|
21696
|
-
throw new (0,
|
|
21698
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 ZIP \uC555\uCD95 \uBC29\uC2DD(method=${method}): ${e.name} \u2014 STORE(0)/DEFLATE(8)\uB9CC \uAD50\uCCB4 \uAC00\uB2A5`);
|
|
21697
21699
|
}
|
|
21698
21700
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21699
21701
|
const crc = crc32(newData);
|
|
@@ -21794,7 +21796,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21794
21796
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21795
21797
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21796
21798
|
if (sectionPaths.length === 0) {
|
|
21797
|
-
throw new (0,
|
|
21799
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21798
21800
|
}
|
|
21799
21801
|
const warnings = [];
|
|
21800
21802
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22531,7 +22533,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22531
22533
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22532
22534
|
const got = m ? Number(m[1]) : NaN;
|
|
22533
22535
|
if (got !== startId + i) {
|
|
22534
|
-
throw new (0,
|
|
22536
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
22535
22537
|
`\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)`
|
|
22536
22538
|
);
|
|
22537
22539
|
}
|
|
@@ -22615,7 +22617,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22615
22617
|
}
|
|
22616
22618
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22617
22619
|
if (rows.length !== expectedBase) {
|
|
22618
|
-
throw new (0,
|
|
22620
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
22619
22621
|
`\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`
|
|
22620
22622
|
);
|
|
22621
22623
|
}
|
|
@@ -23510,7 +23512,7 @@ function escapeGfm(text) {
|
|
|
23510
23512
|
}
|
|
23511
23513
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23512
23514
|
function sanitizeText(text) {
|
|
23513
|
-
let result =
|
|
23515
|
+
let result = _chunkSCJLAOY3cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23514
23516
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23515
23517
|
const tokens = result.split(" ");
|
|
23516
23518
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23682,7 +23684,7 @@ function parseHtmlTable(raw) {
|
|
|
23682
23684
|
const cs = parseInt(_optionalChain([attrs, 'access', _285 => _285.match, 'call', _286 => _286(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _287 => _287[1]]) || "1", 10);
|
|
23683
23685
|
const rs = parseInt(_optionalChain([attrs, 'access', _288 => _288.match, 'call', _289 => _289(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _290 => _290[1]]) || "1", 10);
|
|
23684
23686
|
cellStart = m.index + m[0].length;
|
|
23685
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23687
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkSCJLAOY3cjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkSCJLAOY3cjs.MAX_ROWS) };
|
|
23686
23688
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23687
23689
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23688
23690
|
cellStart = -1;
|
|
@@ -24338,8 +24340,8 @@ function layoutHtmlRows(rows) {
|
|
|
24338
24340
|
let c = 0;
|
|
24339
24341
|
for (const cell2 of rows[r].cells) {
|
|
24340
24342
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24341
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24342
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24343
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkSCJLAOY3cjs.MAX_COLS);
|
|
24344
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkSCJLAOY3cjs.MAX_ROWS);
|
|
24343
24345
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24344
24346
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24345
24347
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -25936,11 +25938,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25936
25938
|
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>`;
|
|
25937
25939
|
}
|
|
25938
25940
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25939
|
-
if (ops.length === 0) throw new (0,
|
|
25941
|
+
if (ops.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25940
25942
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25941
25943
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25942
25944
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _392 => _392.match, 'call', _393 => _393(/(\d+)\.xml$/i), 'optionalAccess', _394 => _394[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _395 => _395.match, 'call', _396 => _396(/(\d+)\.xml$/i), 'optionalAccess', _397 => _397[1]]), () => ( 0))));
|
|
25943
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25945
|
+
if (sectionPaths.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25944
25946
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25945
25947
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25946
25948
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25981,11 +25983,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25981
25983
|
const manifestItems = [];
|
|
25982
25984
|
const placed = [];
|
|
25983
25985
|
for (const op of ops) {
|
|
25984
|
-
if (!op.anchor) throw new (0,
|
|
25985
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25986
|
+
if (!op.anchor) throw new (0, _chunkBLNOGMIMcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25987
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25986
25988
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25987
|
-
if (!MIME[ext]) throw new (0,
|
|
25988
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25989
|
+
if (!MIME[ext]) throw new (0, _chunkBLNOGMIMcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25990
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkBLNOGMIMcjs.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)`);
|
|
25989
25991
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25990
25992
|
let found = null;
|
|
25991
25993
|
let total = 0;
|
|
@@ -26018,7 +26020,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26018
26020
|
}
|
|
26019
26021
|
}
|
|
26020
26022
|
}
|
|
26021
|
-
throw new (0,
|
|
26023
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
26022
26024
|
`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)})`
|
|
26023
26025
|
);
|
|
26024
26026
|
}
|
|
@@ -26026,7 +26028,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26026
26028
|
const xml = sectionXmls[si];
|
|
26027
26029
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26028
26030
|
if (!run) {
|
|
26029
|
-
throw new (0,
|
|
26031
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26030
26032
|
}
|
|
26031
26033
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _398 => _398.charPr, 'access', _399 => _399.get, 'call', _400 => _400(run.charPr), 'optionalAccess', _401 => _401.height]), () => ( 1e3));
|
|
26032
26034
|
const fontPt = charPrHeight / 100;
|
|
@@ -26304,7 +26306,7 @@ function pick(map, keys) {
|
|
|
26304
26306
|
return out;
|
|
26305
26307
|
}
|
|
26306
26308
|
async function hwpxToProfile(input) {
|
|
26307
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26309
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkBLNOGMIMcjs.toArrayBuffer.call(void 0, input);
|
|
26308
26310
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26309
26311
|
const parser = createXmlParser();
|
|
26310
26312
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _423 => _423.file, 'call', _424 => _424(/[Hh]eader\.xml$/), 'optionalAccess', _425 => _425[0]])));
|
|
@@ -27223,7 +27225,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27223
27225
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27224
27226
|
if (paths.length > 0) return paths;
|
|
27225
27227
|
}
|
|
27226
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27228
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkBLNOGMIMcjs.compareSectionPaths);
|
|
27227
27229
|
}
|
|
27228
27230
|
function sectionPathsFromManifest(xml) {
|
|
27229
27231
|
const attr = (tag, name) => {
|
|
@@ -27233,7 +27235,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27233
27235
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27234
27236
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27235
27237
|
const id = attr(m[1], "id");
|
|
27236
|
-
const href =
|
|
27238
|
+
const href = _chunkBLNOGMIMcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27237
27239
|
if (id && href) idToHref.set(id, href);
|
|
27238
27240
|
}
|
|
27239
27241
|
const ordered = [];
|
|
@@ -27242,7 +27244,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27242
27244
|
if (href) ordered.push(href);
|
|
27243
27245
|
}
|
|
27244
27246
|
if (ordered.length > 0) return ordered;
|
|
27245
|
-
return Array.from(idToHref.values()).sort(
|
|
27247
|
+
return Array.from(idToHref.values()).sort(_chunkBLNOGMIMcjs.compareSectionPaths);
|
|
27246
27248
|
}
|
|
27247
27249
|
|
|
27248
27250
|
// src/roundtrip/patcher.ts
|
|
@@ -27353,9 +27355,9 @@ function buildOrigUnits(blocks) {
|
|
|
27353
27355
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27354
27356
|
const next = blocks[i + 1];
|
|
27355
27357
|
if (_optionalChain([next, 'optionalAccess', _458 => _458.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27356
|
-
chunk =
|
|
27358
|
+
chunk = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27357
27359
|
} else {
|
|
27358
|
-
chunk =
|
|
27360
|
+
chunk = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, [block]);
|
|
27359
27361
|
}
|
|
27360
27362
|
if (chunk) {
|
|
27361
27363
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -28958,12 +28960,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28958
28960
|
let run = null;
|
|
28959
28961
|
const flushRun = () => {
|
|
28960
28962
|
if (!run) return;
|
|
28961
|
-
push("text", run.breadcrumb,
|
|
28963
|
+
push("text", run.breadcrumb, _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28962
28964
|
run = null;
|
|
28963
28965
|
};
|
|
28964
28966
|
for (let i = 0; i < blocks.length; i++) {
|
|
28965
28967
|
const block = blocks[i];
|
|
28966
|
-
const md2 =
|
|
28968
|
+
const md2 = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, [block]);
|
|
28967
28969
|
if (!md2) continue;
|
|
28968
28970
|
if (block.type === "heading") {
|
|
28969
28971
|
flushRun();
|
|
@@ -29433,13 +29435,13 @@ async function htmlToPdf(html, options) {
|
|
|
29433
29435
|
try {
|
|
29434
29436
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29435
29437
|
} catch (e32) {
|
|
29436
|
-
throw new (0,
|
|
29438
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
29437
29439
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29438
29440
|
);
|
|
29439
29441
|
}
|
|
29440
29442
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29441
29443
|
if (!executablePath) {
|
|
29442
|
-
throw new (0,
|
|
29444
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)(
|
|
29443
29445
|
"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."
|
|
29444
29446
|
);
|
|
29445
29447
|
}
|
|
@@ -29498,7 +29500,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29498
29500
|
return htmlToPdf(html, options);
|
|
29499
29501
|
}
|
|
29500
29502
|
async function blocksToPdf(blocks, options) {
|
|
29501
|
-
const markdown =
|
|
29503
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks);
|
|
29502
29504
|
return markdownToPdf(markdown, options);
|
|
29503
29505
|
}
|
|
29504
29506
|
|
|
@@ -30392,15 +30394,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30392
30394
|
async function renderHwpxToSvg(input, options) {
|
|
30393
30395
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30394
30396
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30395
|
-
|
|
30397
|
+
_chunkBLNOGMIMcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30396
30398
|
let zip;
|
|
30397
30399
|
try {
|
|
30398
30400
|
zip = await _jszip2.default.loadAsync(input);
|
|
30399
30401
|
} catch (e33) {
|
|
30400
|
-
throw new (0,
|
|
30402
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30401
30403
|
}
|
|
30402
30404
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30403
|
-
if (secFiles.length === 0) throw new (0,
|
|
30405
|
+
if (secFiles.length === 0) throw new (0, _chunkBLNOGMIMcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30404
30406
|
const warnings = [];
|
|
30405
30407
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30406
30408
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30408,7 +30410,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30408
30410
|
const secXmls = [];
|
|
30409
30411
|
for (const f of secFiles) {
|
|
30410
30412
|
const xml = await f.async("string");
|
|
30411
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30413
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30412
30414
|
secXmls.push(xml);
|
|
30413
30415
|
}
|
|
30414
30416
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30481,9 +30483,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30481
30483
|
}
|
|
30482
30484
|
if (rendered.length === 0) {
|
|
30483
30485
|
if (noCacheSkipped) {
|
|
30484
|
-
throw new (0,
|
|
30486
|
+
throw new (0, _chunkBLNOGMIMcjs.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)");
|
|
30485
30487
|
}
|
|
30486
|
-
throw new (0,
|
|
30488
|
+
throw new (0, _chunkBLNOGMIMcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30487
30489
|
}
|
|
30488
30490
|
const GAP = 2400;
|
|
30489
30491
|
const clipDefs = [];
|
|
@@ -30519,13 +30521,13 @@ async function parse(input, options) {
|
|
|
30519
30521
|
if (typeof input === "string") {
|
|
30520
30522
|
try {
|
|
30521
30523
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30522
|
-
buffer =
|
|
30524
|
+
buffer = _chunkBLNOGMIMcjs.toArrayBuffer.call(void 0, buf);
|
|
30523
30525
|
} catch (err) {
|
|
30524
30526
|
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}`;
|
|
30525
30527
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30526
30528
|
}
|
|
30527
30529
|
} else if (Buffer.isBuffer(input)) {
|
|
30528
|
-
buffer =
|
|
30530
|
+
buffer = _chunkBLNOGMIMcjs.toArrayBuffer.call(void 0, input);
|
|
30529
30531
|
} else {
|
|
30530
30532
|
buffer = input;
|
|
30531
30533
|
}
|
|
@@ -30559,18 +30561,18 @@ async function parse(input, options) {
|
|
|
30559
30561
|
}
|
|
30560
30562
|
async function parseImage(buffer, options) {
|
|
30561
30563
|
try {
|
|
30562
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
30564
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-JWAX5EOB.cjs")));
|
|
30563
30565
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30564
30566
|
return {
|
|
30565
30567
|
success: true,
|
|
30566
30568
|
fileType: "image",
|
|
30567
|
-
markdown:
|
|
30569
|
+
markdown: _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, blocks),
|
|
30568
30570
|
blocks,
|
|
30569
30571
|
warnings: warnings.length ? warnings : void 0,
|
|
30570
30572
|
pageCount: 1
|
|
30571
30573
|
};
|
|
30572
30574
|
} catch (err) {
|
|
30573
|
-
return { success: false, fileType: "image", error:
|
|
30575
|
+
return { success: false, fileType: "image", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30574
30576
|
}
|
|
30575
30577
|
}
|
|
30576
30578
|
async function parseHwp3(buffer, options) {
|
|
@@ -30578,7 +30580,7 @@ async function parseHwp3(buffer, options) {
|
|
|
30578
30580
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30579
30581
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30580
30582
|
} catch (err) {
|
|
30581
|
-
return { success: false, fileType: "hwp3", error:
|
|
30583
|
+
return { success: false, fileType: "hwp3", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30582
30584
|
}
|
|
30583
30585
|
}
|
|
30584
30586
|
async function parseHwpx(buffer, options) {
|
|
@@ -30586,7 +30588,7 @@ async function parseHwpx(buffer, options) {
|
|
|
30586
30588
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30587
30589
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _562 => _562.length]) ? images : void 0 };
|
|
30588
30590
|
} catch (err) {
|
|
30589
|
-
return { success: false, fileType: "hwpx", error:
|
|
30591
|
+
return { success: false, fileType: "hwpx", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30590
30592
|
}
|
|
30591
30593
|
}
|
|
30592
30594
|
async function parseHwp(buffer, options) {
|
|
@@ -30611,13 +30613,13 @@ async function parseHwp(buffer, options) {
|
|
|
30611
30613
|
}
|
|
30612
30614
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _564 => _564.length]) ? images : void 0 };
|
|
30613
30615
|
} catch (err) {
|
|
30614
|
-
return { success: false, fileType: "hwp", error:
|
|
30616
|
+
return { success: false, fileType: "hwp", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30615
30617
|
}
|
|
30616
30618
|
}
|
|
30617
30619
|
async function parsePdf(buffer, options) {
|
|
30618
30620
|
let parsePdfDocument;
|
|
30619
30621
|
try {
|
|
30620
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30622
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-6RDEBLSB.cjs")));
|
|
30621
30623
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30622
30624
|
} catch (e35) {
|
|
30623
30625
|
return {
|
|
@@ -30632,7 +30634,7 @@ async function parsePdf(buffer, options) {
|
|
|
30632
30634
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30633
30635
|
} catch (err) {
|
|
30634
30636
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30635
|
-
return { success: false, fileType: "pdf", error:
|
|
30637
|
+
return { success: false, fileType: "pdf", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err), isImageBased };
|
|
30636
30638
|
}
|
|
30637
30639
|
}
|
|
30638
30640
|
async function parseXlsx(buffer, options) {
|
|
@@ -30640,7 +30642,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30640
30642
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30641
30643
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30642
30644
|
} catch (err) {
|
|
30643
|
-
return { success: false, fileType: "xlsx", error:
|
|
30645
|
+
return { success: false, fileType: "xlsx", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30644
30646
|
}
|
|
30645
30647
|
}
|
|
30646
30648
|
async function parseXls(buffer, options) {
|
|
@@ -30648,7 +30650,7 @@ async function parseXls(buffer, options) {
|
|
|
30648
30650
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30649
30651
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30650
30652
|
} catch (err) {
|
|
30651
|
-
return { success: false, fileType: "xls", error:
|
|
30653
|
+
return { success: false, fileType: "xls", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30652
30654
|
}
|
|
30653
30655
|
}
|
|
30654
30656
|
async function parseDocx(buffer, options) {
|
|
@@ -30656,7 +30658,7 @@ async function parseDocx(buffer, options) {
|
|
|
30656
30658
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30657
30659
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _565 => _565.length]) ? images : void 0 };
|
|
30658
30660
|
} catch (err) {
|
|
30659
|
-
return { success: false, fileType: "docx", error:
|
|
30661
|
+
return { success: false, fileType: "docx", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30660
30662
|
}
|
|
30661
30663
|
}
|
|
30662
30664
|
async function parseHwpml(buffer, options) {
|
|
@@ -30664,16 +30666,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30664
30666
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30665
30667
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30666
30668
|
} catch (err) {
|
|
30667
|
-
return { success: false, fileType: "hwpml", error:
|
|
30669
|
+
return { success: false, fileType: "hwpml", error: _chunkBLNOGMIMcjs.sanitizeError.call(void 0, err), code: _chunkBLNOGMIMcjs.classifyError.call(void 0, err) };
|
|
30668
30670
|
}
|
|
30669
30671
|
}
|
|
30670
30672
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30671
30673
|
let buffer;
|
|
30672
30674
|
if (typeof input === "string") {
|
|
30673
30675
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30674
|
-
buffer =
|
|
30676
|
+
buffer = _chunkBLNOGMIMcjs.toArrayBuffer.call(void 0, buf);
|
|
30675
30677
|
} else if (Buffer.isBuffer(input)) {
|
|
30676
|
-
buffer =
|
|
30678
|
+
buffer = _chunkBLNOGMIMcjs.toArrayBuffer.call(void 0, input);
|
|
30677
30679
|
} else {
|
|
30678
30680
|
buffer = input;
|
|
30679
30681
|
}
|
|
@@ -30699,7 +30701,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30699
30701
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30700
30702
|
}
|
|
30701
30703
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30702
|
-
const markdown =
|
|
30704
|
+
const markdown = _chunkSCJLAOY3cjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30703
30705
|
if (outputFormat === "hwpx") {
|
|
30704
30706
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30705
30707
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30773,5 +30775,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30773
30775
|
|
|
30774
30776
|
|
|
30775
30777
|
|
|
30776
|
-
exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
30778
|
+
exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkBLNOGMIMcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkSCJLAOY3cjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parseImage = parseImage; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
30777
30779
|
//# sourceMappingURL=index.cjs.map
|