kordoc 3.12.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/{-OPZIF3QT.js → -MRPDPE2X.js} +5 -5
- package/dist/{chunk-ILR7GF3W.js → chunk-33CIKNL4.js} +2 -2
- package/dist/{chunk-2C5GCXPJ.cjs → chunk-MEXUFQVC.cjs} +2 -2
- package/dist/{chunk-2C5GCXPJ.cjs.map → chunk-MEXUFQVC.cjs.map} +1 -1
- package/dist/{chunk-NGKIAZ6G.js → chunk-O4WFPOFN.js} +2 -2
- package/dist/{chunk-7Z43WEML.js → chunk-Q6UXVJXI.js} +2 -2
- package/dist/{chunk-RUYSNNYZ.js → chunk-TWACKS3K.js} +21 -5
- package/dist/{chunk-RUYSNNYZ.js.map → chunk-TWACKS3K.js.map} +1 -1
- package/dist/{chunk-BUDM6ULT.js → chunk-YXOT7P5B.js} +2 -2
- package/dist/cli.js +7 -7
- package/dist/index.cjs +134 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +5 -5
- package/dist/{parser-PCTX7LGN.cjs → parser-DZBI3EA2.cjs} +66 -14
- package/dist/parser-DZBI3EA2.cjs.map +1 -0
- package/dist/{parser-5FSEFR3R.js → parser-XUNGOH76.js} +55 -3
- package/dist/{parser-AWEGMHHV.js.map → parser-XUNGOH76.js.map} +1 -1
- package/dist/{parser-AWEGMHHV.js → parser-Z3IL2ESY.js} +54 -2
- package/dist/{parser-5FSEFR3R.js.map → parser-Z3IL2ESY.js.map} +1 -1
- package/dist/render-VZ4OGHZU.js +9 -0
- package/dist/{watch-Y7BAYXJE.js → watch-G5NFIT5L.js} +5 -5
- package/package.json +1 -1
- package/dist/parser-PCTX7LGN.cjs.map +0 -1
- package/dist/render-ATQNKOT2.js +0 -9
- /package/dist/{-OPZIF3QT.js.map → -MRPDPE2X.js.map} +0 -0
- /package/dist/{chunk-ILR7GF3W.js.map → chunk-33CIKNL4.js.map} +0 -0
- /package/dist/{chunk-NGKIAZ6G.js.map → chunk-O4WFPOFN.js.map} +0 -0
- /package/dist/{chunk-7Z43WEML.js.map → chunk-Q6UXVJXI.js.map} +0 -0
- /package/dist/{chunk-BUDM6ULT.js.map → chunk-YXOT7P5B.js.map} +0 -0
- /package/dist/{render-ATQNKOT2.js.map → render-VZ4OGHZU.js.map} +0 -0
- /package/dist/{watch-Y7BAYXJE.js.map → watch-G5NFIT5L.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkMEXUFQVCcjs = require('./chunk-MEXUFQVC.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -405,7 +405,7 @@ function createSectionShared() {
|
|
|
405
405
|
function createXmlParser(warnings) {
|
|
406
406
|
return new (0, _xmldom.DOMParser)({
|
|
407
407
|
onError(level, msg2) {
|
|
408
|
-
if (level === "fatalError") throw new (0,
|
|
408
|
+
if (level === "fatalError") throw new (0, _chunkMEXUFQVCcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
409
409
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
410
410
|
}
|
|
411
411
|
});
|
|
@@ -460,10 +460,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
460
460
|
const xml = await file.async("text");
|
|
461
461
|
if (decompressed) {
|
|
462
462
|
decompressed.total += xml.length * 2;
|
|
463
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
463
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
464
464
|
}
|
|
465
465
|
const parser = createXmlParser();
|
|
466
|
-
const doc = parser.parseFromString(
|
|
466
|
+
const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
467
467
|
if (!doc.documentElement) continue;
|
|
468
468
|
parseCharProperties(doc, result.charProperties);
|
|
469
469
|
parseStyleElements(doc, result.styles);
|
|
@@ -615,9 +615,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
615
615
|
let level = 0;
|
|
616
616
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
|
|
617
617
|
const ratio = block.style.fontSize / baseFontSize;
|
|
618
|
-
if (ratio >=
|
|
619
|
-
else if (ratio >=
|
|
620
|
-
else if (ratio >=
|
|
618
|
+
if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H1) level = 1;
|
|
619
|
+
else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H2) level = 2;
|
|
620
|
+
else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H3) level = 3;
|
|
621
621
|
}
|
|
622
622
|
const compactText = text.replace(/\s+/g, "");
|
|
623
623
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1171,7 +1171,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1171
1171
|
|
|
1172
1172
|
// src/hwpx/table-build.ts
|
|
1173
1173
|
function buildTableWithCellMeta(state) {
|
|
1174
|
-
const table =
|
|
1174
|
+
const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, state.rows);
|
|
1175
1175
|
if (state.caption) table.caption = state.caption;
|
|
1176
1176
|
const anchors = [];
|
|
1177
1177
|
{
|
|
@@ -1241,7 +1241,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1241
1241
|
const cell = parentTable.cell;
|
|
1242
1242
|
(cell.blocks ??= []).push(block);
|
|
1243
1243
|
cell.hasStructure = true;
|
|
1244
|
-
let flat =
|
|
1244
|
+
let flat = _chunkMEXUFQVCcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1245
1245
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1246
1246
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1247
1247
|
} else {
|
|
@@ -1253,7 +1253,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1253
1253
|
// src/hwpx/section-walker.ts
|
|
1254
1254
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1255
1255
|
const parser = createXmlParser(warnings);
|
|
1256
|
-
const doc = parser.parseFromString(
|
|
1256
|
+
const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1257
1257
|
if (!doc.documentElement) return [];
|
|
1258
1258
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1259
1259
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1344,8 +1344,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1344
1344
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1345
1345
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1346
1346
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1347
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1348
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1347
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkMEXUFQVCcjs.MAX_COLS);
|
|
1348
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkMEXUFQVCcjs.MAX_ROWS);
|
|
1349
1349
|
}
|
|
1350
1350
|
break;
|
|
1351
1351
|
case "p": {
|
|
@@ -1567,7 +1567,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1567
1567
|
let url = (ch.textContent || "").trim();
|
|
1568
1568
|
if (!url) continue;
|
|
1569
1569
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1570
|
-
const safe =
|
|
1570
|
+
const safe = _chunkMEXUFQVCcjs.sanitizeHref.call(void 0, url);
|
|
1571
1571
|
if (safe) return safe;
|
|
1572
1572
|
}
|
|
1573
1573
|
return void 0;
|
|
@@ -1702,7 +1702,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1702
1702
|
case "hyperlink": {
|
|
1703
1703
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1704
1704
|
if (url) {
|
|
1705
|
-
const safe =
|
|
1705
|
+
const safe = _chunkMEXUFQVCcjs.sanitizeHref.call(void 0, url);
|
|
1706
1706
|
if (safe) href = safe;
|
|
1707
1707
|
}
|
|
1708
1708
|
walk(child);
|
|
@@ -1888,13 +1888,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1888
1888
|
}
|
|
1889
1889
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1890
1890
|
for (const path of allCandidates) {
|
|
1891
|
-
if (
|
|
1891
|
+
if (_chunkMEXUFQVCcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1892
1892
|
const file = zip.file(path);
|
|
1893
1893
|
if (!file) continue;
|
|
1894
1894
|
try {
|
|
1895
1895
|
const data = await file.async("uint8array");
|
|
1896
1896
|
decompressed.total += data.length;
|
|
1897
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1897
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1898
1898
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1899
1899
|
const mimeType = imageExtToMime(ext);
|
|
1900
1900
|
imageIndex++;
|
|
@@ -1903,7 +1903,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1903
1903
|
images.push(img);
|
|
1904
1904
|
break;
|
|
1905
1905
|
} catch (err) {
|
|
1906
|
-
if (err instanceof
|
|
1906
|
+
if (err instanceof _chunkMEXUFQVCcjs.KordocError) throw err;
|
|
1907
1907
|
}
|
|
1908
1908
|
}
|
|
1909
1909
|
if (!img) _optionalChain([warnings, 'optionalAccess', _38 => _38.push, 'call', _39 => _39({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -1965,7 +1965,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1965
1965
|
}
|
|
1966
1966
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1967
1967
|
const name = new TextDecoder().decode(nameBytes);
|
|
1968
|
-
if (
|
|
1968
|
+
if (_chunkMEXUFQVCcjs.isPathTraversal.call(void 0, name)) {
|
|
1969
1969
|
pos = fileStart + compSize;
|
|
1970
1970
|
continue;
|
|
1971
1971
|
}
|
|
@@ -1983,16 +1983,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1983
1983
|
continue;
|
|
1984
1984
|
}
|
|
1985
1985
|
totalDecompressed += content.length * 2;
|
|
1986
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1986
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1987
1987
|
sectionNum++;
|
|
1988
1988
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1989
1989
|
} catch (e13) {
|
|
1990
1990
|
continue;
|
|
1991
1991
|
}
|
|
1992
1992
|
}
|
|
1993
|
-
if (blocks.length === 0) throw new (0,
|
|
1993
|
+
if (blocks.length === 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1994
1994
|
applyPageText(blocks, shared);
|
|
1995
|
-
const markdown =
|
|
1995
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1996
1996
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1997
1997
|
}
|
|
1998
1998
|
async function resolveSectionPaths(zip) {
|
|
@@ -2006,18 +2006,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2006
2006
|
if (paths.length > 0) return paths;
|
|
2007
2007
|
}
|
|
2008
2008
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2009
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2009
|
+
return sectionFiles.map((f) => f.name).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
|
|
2010
2010
|
}
|
|
2011
2011
|
function parseSectionPathsFromManifest(xml) {
|
|
2012
2012
|
const parser = createXmlParser();
|
|
2013
|
-
const doc = parser.parseFromString(
|
|
2013
|
+
const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2014
2014
|
const items = doc.getElementsByTagName("opf:item");
|
|
2015
2015
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2016
2016
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2017
2017
|
for (let i = 0; i < items.length; i++) {
|
|
2018
2018
|
const item = items[i];
|
|
2019
2019
|
const id = item.getAttribute("id") || "";
|
|
2020
|
-
const href =
|
|
2020
|
+
const href = _chunkMEXUFQVCcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2021
2021
|
if (id && href) idToHref.set(id, href);
|
|
2022
2022
|
}
|
|
2023
2023
|
if (spine.length > 0) {
|
|
@@ -2028,7 +2028,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2028
2028
|
}
|
|
2029
2029
|
if (ordered.length > 0) return ordered;
|
|
2030
2030
|
}
|
|
2031
|
-
return Array.from(idToHref.values()).sort(
|
|
2031
|
+
return Array.from(idToHref.values()).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
|
|
2032
2032
|
}
|
|
2033
2033
|
|
|
2034
2034
|
// src/hwpx/metadata.ts
|
|
@@ -2041,7 +2041,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2041
2041
|
const xml = await file.async("text");
|
|
2042
2042
|
if (decompressed) {
|
|
2043
2043
|
decompressed.total += xml.length * 2;
|
|
2044
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2044
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2045
2045
|
}
|
|
2046
2046
|
parseDublinCoreMetadata(xml, metadata);
|
|
2047
2047
|
if (metadata.title || metadata.author) return;
|
|
@@ -2051,7 +2051,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2051
2051
|
}
|
|
2052
2052
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2053
2053
|
const parser = createXmlParser();
|
|
2054
|
-
const doc = parser.parseFromString(
|
|
2054
|
+
const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2055
2055
|
if (!doc.documentElement) return;
|
|
2056
2056
|
const getText = (tagNames) => {
|
|
2057
2057
|
for (const tag of tagNames) {
|
|
@@ -2076,7 +2076,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2076
2076
|
|
|
2077
2077
|
// src/hwpx/parser.ts
|
|
2078
2078
|
async function parseHwpxDocument(buffer, options) {
|
|
2079
|
-
|
|
2079
|
+
_chunkMEXUFQVCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2080
2080
|
let zip;
|
|
2081
2081
|
try {
|
|
2082
2082
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2085,7 +2085,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2085
2085
|
}
|
|
2086
2086
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2087
2087
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2088
|
-
throw new (0,
|
|
2088
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2089
2089
|
}
|
|
2090
2090
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2091
2091
|
if (manifestFile) {
|
|
@@ -2097,7 +2097,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2097
2097
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
2100
|
-
throw new (0,
|
|
2100
|
+
throw new (0, _chunkMEXUFQVCcjs.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.");
|
|
2101
2101
|
}
|
|
2102
2102
|
}
|
|
2103
2103
|
const decompressed = { total: 0 };
|
|
@@ -2106,7 +2106,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2106
2106
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2107
2107
|
const warnings = [];
|
|
2108
2108
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2109
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2109
|
+
if (sectionPaths.length === 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2110
2110
|
metadata.pageCount = sectionPaths.length;
|
|
2111
2111
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2112
2112
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2120,12 +2120,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2120
2120
|
try {
|
|
2121
2121
|
const xml = await file.async("text");
|
|
2122
2122
|
decompressed.total += xml.length * 2;
|
|
2123
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2123
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2124
2124
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2125
2125
|
parsedSections++;
|
|
2126
2126
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2127
2127
|
} catch (secErr) {
|
|
2128
|
-
if (secErr instanceof
|
|
2128
|
+
if (secErr instanceof _chunkMEXUFQVCcjs.KordocError) throw secErr;
|
|
2129
2129
|
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" });
|
|
2130
2130
|
}
|
|
2131
2131
|
}
|
|
@@ -2133,7 +2133,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2133
2133
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2134
2134
|
detectHwpxHeadings(blocks, styleMap);
|
|
2135
2135
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2136
|
-
const markdown =
|
|
2136
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2137
2137
|
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 };
|
|
2138
2138
|
}
|
|
2139
2139
|
|
|
@@ -2200,7 +2200,7 @@ function decompressStream(data) {
|
|
|
2200
2200
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2201
2201
|
}
|
|
2202
2202
|
function parseFileHeader(data) {
|
|
2203
|
-
if (data.length < 40) throw new (0,
|
|
2203
|
+
if (data.length < 40) throw new (0, _chunkMEXUFQVCcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2204
2204
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2205
2205
|
return {
|
|
2206
2206
|
signature: sig,
|
|
@@ -3734,7 +3734,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3734
3734
|
lenientCfb = parseLenientCfb(buffer);
|
|
3735
3735
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3736
3736
|
} catch (e21) {
|
|
3737
|
-
throw new (0,
|
|
3737
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3738
3738
|
}
|
|
3739
3739
|
}
|
|
3740
3740
|
const findStream = (path) => {
|
|
@@ -3745,11 +3745,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3745
3745
|
return lenientCfb.findStream(path);
|
|
3746
3746
|
};
|
|
3747
3747
|
const headerData = findStream("/FileHeader");
|
|
3748
|
-
if (!headerData) throw new (0,
|
|
3748
|
+
if (!headerData) throw new (0, _chunkMEXUFQVCcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3749
3749
|
const header = parseFileHeader(headerData);
|
|
3750
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3751
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3752
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3750
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3751
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3752
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkMEXUFQVCcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3753
3753
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3754
3754
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3755
3755
|
const metadata = {
|
|
@@ -3758,7 +3758,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3758
3758
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3759
3759
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3760
3760
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3761
|
-
if (sections.length === 0) throw new (0,
|
|
3761
|
+
if (sections.length === 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3762
3762
|
metadata.pageCount = sections.length;
|
|
3763
3763
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3764
3764
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3772,25 +3772,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3772
3772
|
const sectionData = sections[si];
|
|
3773
3773
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3774
3774
|
totalDecompressed += data.length;
|
|
3775
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3775
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3776
3776
|
const records = readRecords(data);
|
|
3777
3777
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3778
3778
|
bodyBlocks.push(...sectionBlocks);
|
|
3779
3779
|
parsedSections++;
|
|
3780
3780
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3781
3781
|
} catch (secErr) {
|
|
3782
|
-
if (secErr instanceof
|
|
3782
|
+
if (secErr instanceof _chunkMEXUFQVCcjs.KordocError) throw secErr;
|
|
3783
3783
|
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" });
|
|
3784
3784
|
}
|
|
3785
3785
|
}
|
|
3786
3786
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3787
3787
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3788
|
-
const flatBlocks =
|
|
3788
|
+
const flatBlocks = _chunkMEXUFQVCcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3789
3789
|
if (docInfo) {
|
|
3790
3790
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3791
3791
|
}
|
|
3792
3792
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3793
|
-
const markdown =
|
|
3793
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3794
3794
|
return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3795
3795
|
}
|
|
3796
3796
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3850,9 +3850,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3850
3850
|
let level = 0;
|
|
3851
3851
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3852
3852
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3853
|
-
if (ratio >=
|
|
3854
|
-
else if (ratio >=
|
|
3855
|
-
else if (ratio >=
|
|
3853
|
+
if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H1) level = 1;
|
|
3854
|
+
else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H2) level = 2;
|
|
3855
|
+
else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H3) level = 3;
|
|
3856
3856
|
}
|
|
3857
3857
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3858
3858
|
if (level === 0) level = 2;
|
|
@@ -3937,7 +3937,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3937
3937
|
if (!raw) break;
|
|
3938
3938
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3939
3939
|
totalDecompressed += content.length;
|
|
3940
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3940
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3941
3941
|
sections.push({ idx: i, content });
|
|
3942
3942
|
}
|
|
3943
3943
|
if (sections.length === 0) {
|
|
@@ -3949,7 +3949,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3949
3949
|
if (raw) {
|
|
3950
3950
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3951
3951
|
totalDecompressed += content.length;
|
|
3952
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3952
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3953
3953
|
sections.push({ idx, content });
|
|
3954
3954
|
}
|
|
3955
3955
|
}
|
|
@@ -3966,7 +3966,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3966
3966
|
try {
|
|
3967
3967
|
const content = decryptViewText(raw, compressed);
|
|
3968
3968
|
totalDecompressed += content.length;
|
|
3969
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3969
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3970
3970
|
sections.push({ idx: i, content });
|
|
3971
3971
|
} catch (e26) {
|
|
3972
3972
|
break;
|
|
@@ -4069,7 +4069,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4069
4069
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4070
4070
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
4071
4071
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4072
|
-
const href =
|
|
4072
|
+
const href = _chunkMEXUFQVCcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4073
4073
|
if (!href) continue;
|
|
4074
4074
|
const anchor = text.slice(r.start, r.end);
|
|
4075
4075
|
if (!anchor.trim()) continue;
|
|
@@ -4302,8 +4302,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4302
4302
|
let tableIdx = -1;
|
|
4303
4303
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4304
4304
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4305
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4306
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4305
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkMEXUFQVCcjs.MAX_ROWS);
|
|
4306
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkMEXUFQVCcjs.MAX_COLS);
|
|
4307
4307
|
tableIdx = i2;
|
|
4308
4308
|
break;
|
|
4309
4309
|
}
|
|
@@ -4352,7 +4352,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4352
4352
|
return table2;
|
|
4353
4353
|
}
|
|
4354
4354
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4355
|
-
const table =
|
|
4355
|
+
const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
|
|
4356
4356
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4357
4357
|
return table.rows > 0 ? table : null;
|
|
4358
4358
|
}
|
|
@@ -4369,8 +4369,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4369
4369
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4370
4370
|
const cs = rec.data.readUInt16LE(12);
|
|
4371
4371
|
const rs = rec.data.readUInt16LE(14);
|
|
4372
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4373
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4372
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkMEXUFQVCcjs.MAX_COLS);
|
|
4373
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkMEXUFQVCcjs.MAX_ROWS);
|
|
4374
4374
|
}
|
|
4375
4375
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4376
4376
|
const parts = [];
|
|
@@ -4380,7 +4380,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4380
4380
|
parts.push(``);
|
|
4381
4381
|
hasStructure = true;
|
|
4382
4382
|
} else if (b.type === "table" && b.table) {
|
|
4383
|
-
const flat =
|
|
4383
|
+
const flat = _chunkMEXUFQVCcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4384
4384
|
if (flat) parts.push(flat);
|
|
4385
4385
|
hasStructure = true;
|
|
4386
4386
|
} else if (b.text) {
|
|
@@ -16817,7 +16817,7 @@ function getTextContent(el) {
|
|
|
16817
16817
|
return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
|
|
16818
16818
|
}
|
|
16819
16819
|
function parseXml(text) {
|
|
16820
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16820
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16821
16821
|
}
|
|
16822
16822
|
function parseSharedStrings(xml) {
|
|
16823
16823
|
const doc = parseXml(xml);
|
|
@@ -16961,7 +16961,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16961
16961
|
cellRows.push(row);
|
|
16962
16962
|
}
|
|
16963
16963
|
if (cellRows.length > 0) {
|
|
16964
|
-
const table =
|
|
16964
|
+
const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
|
|
16965
16965
|
if (table.rows > 0) {
|
|
16966
16966
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16967
16967
|
}
|
|
@@ -16969,12 +16969,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16969
16969
|
return blocks;
|
|
16970
16970
|
}
|
|
16971
16971
|
async function parseXlsxDocument(buffer, options) {
|
|
16972
|
-
|
|
16972
|
+
_chunkMEXUFQVCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16973
16973
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16974
16974
|
const warnings = [];
|
|
16975
16975
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16976
16976
|
if (!workbookFile) {
|
|
16977
|
-
throw new (0,
|
|
16977
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16978
16978
|
}
|
|
16979
16979
|
let sharedStrings = [];
|
|
16980
16980
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16983,7 +16983,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16983
16983
|
}
|
|
16984
16984
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16985
16985
|
if (sheets.length === 0) {
|
|
16986
|
-
throw new (0,
|
|
16986
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16987
16987
|
}
|
|
16988
16988
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16989
16989
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17055,7 +17055,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17055
17055
|
} catch (e27) {
|
|
17056
17056
|
}
|
|
17057
17057
|
}
|
|
17058
|
-
const markdown =
|
|
17058
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17059
17059
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17060
17060
|
}
|
|
17061
17061
|
|
|
@@ -17462,11 +17462,11 @@ function processGlobals(records) {
|
|
|
17462
17462
|
let encrypted = false;
|
|
17463
17463
|
const firstBof = records[0];
|
|
17464
17464
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17465
|
-
throw new (0,
|
|
17465
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17466
17466
|
}
|
|
17467
17467
|
const bof = decodeBof(firstBof.data);
|
|
17468
17468
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17469
|
-
throw new (0,
|
|
17469
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17470
17470
|
}
|
|
17471
17471
|
let i = 1;
|
|
17472
17472
|
while (i < records.length) {
|
|
@@ -17581,7 +17581,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17581
17581
|
cellRows.push(row);
|
|
17582
17582
|
}
|
|
17583
17583
|
if (cellRows.length > 0) {
|
|
17584
|
-
const table =
|
|
17584
|
+
const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
|
|
17585
17585
|
if (table.rows > 0) {
|
|
17586
17586
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17587
17587
|
}
|
|
@@ -17594,21 +17594,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17594
17594
|
try {
|
|
17595
17595
|
cfb = parseLenientCfb(buf);
|
|
17596
17596
|
} catch (e) {
|
|
17597
|
-
throw new (0,
|
|
17597
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)(
|
|
17598
17598
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17599
17599
|
);
|
|
17600
17600
|
}
|
|
17601
17601
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17602
17602
|
if (!wb) {
|
|
17603
|
-
throw new (0,
|
|
17603
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17604
17604
|
}
|
|
17605
17605
|
const records = readRecords2(wb);
|
|
17606
17606
|
if (records.length === 0) {
|
|
17607
|
-
throw new (0,
|
|
17607
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17608
17608
|
}
|
|
17609
17609
|
const firstBof = decodeBof(records[0].data);
|
|
17610
17610
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17611
|
-
throw new (0,
|
|
17611
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)(
|
|
17612
17612
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17613
17613
|
);
|
|
17614
17614
|
}
|
|
@@ -17668,7 +17668,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17668
17668
|
pageCount: totalSheets
|
|
17669
17669
|
};
|
|
17670
17670
|
return {
|
|
17671
|
-
markdown:
|
|
17671
|
+
markdown: _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17672
17672
|
blocks: allBlocks,
|
|
17673
17673
|
metadata,
|
|
17674
17674
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18106,7 +18106,7 @@ function getAttr(el, localName2) {
|
|
|
18106
18106
|
return null;
|
|
18107
18107
|
}
|
|
18108
18108
|
function parseXml2(text) {
|
|
18109
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18109
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18110
18110
|
}
|
|
18111
18111
|
function parseStyles(xml) {
|
|
18112
18112
|
const doc = parseXml2(xml);
|
|
@@ -18367,7 +18367,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
|
18367
18367
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18368
18368
|
})
|
|
18369
18369
|
);
|
|
18370
|
-
const table =
|
|
18370
|
+
const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
|
|
18371
18371
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18372
18372
|
return { type: "table", table };
|
|
18373
18373
|
}
|
|
@@ -18434,12 +18434,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18434
18434
|
return { blocks, images };
|
|
18435
18435
|
}
|
|
18436
18436
|
async function parseDocxDocument(buffer, options) {
|
|
18437
|
-
|
|
18437
|
+
_chunkMEXUFQVCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18438
18438
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18439
18439
|
const warnings = [];
|
|
18440
18440
|
const docFile = zip.file("word/document.xml");
|
|
18441
18441
|
if (!docFile) {
|
|
18442
|
-
throw new (0,
|
|
18442
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18443
18443
|
}
|
|
18444
18444
|
let rels = /* @__PURE__ */ new Map();
|
|
18445
18445
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18486,7 +18486,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18486
18486
|
const doc = parseXml2(docXml);
|
|
18487
18487
|
const body = findElements(doc, "body");
|
|
18488
18488
|
if (body.length === 0) {
|
|
18489
|
-
throw new (0,
|
|
18489
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18490
18490
|
}
|
|
18491
18491
|
const blocks = [];
|
|
18492
18492
|
const bodyEl = body[0];
|
|
@@ -18531,7 +18531,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18531
18531
|
}
|
|
18532
18532
|
}
|
|
18533
18533
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18534
|
-
const markdown =
|
|
18534
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18535
18535
|
return {
|
|
18536
18536
|
markdown,
|
|
18537
18537
|
blocks,
|
|
@@ -18554,7 +18554,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18554
18554
|
}
|
|
18555
18555
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18556
18556
|
const normalized = text.replace(/ /g, " ");
|
|
18557
|
-
const xml =
|
|
18557
|
+
const xml = _chunkMEXUFQVCcjs.stripDtd.call(void 0, normalized);
|
|
18558
18558
|
const warnings = [];
|
|
18559
18559
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18560
18560
|
onError: (_level, msg2) => {
|
|
@@ -18594,7 +18594,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18594
18594
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18595
18595
|
}
|
|
18596
18596
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18597
|
-
const markdown =
|
|
18597
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18598
18598
|
return {
|
|
18599
18599
|
markdown,
|
|
18600
18600
|
blocks,
|
|
@@ -18752,8 +18752,24 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18752
18752
|
const cellRows = grid.map(
|
|
18753
18753
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18754
18754
|
);
|
|
18755
|
-
const table =
|
|
18755
|
+
const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
|
|
18756
|
+
const caption = extractShapeCaption(el);
|
|
18757
|
+
if (caption.text && caption.before) {
|
|
18758
|
+
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
18759
|
+
}
|
|
18756
18760
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18761
|
+
if (caption.text && !caption.before) {
|
|
18762
|
+
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
18763
|
+
}
|
|
18764
|
+
}
|
|
18765
|
+
function extractShapeCaption(tableEl) {
|
|
18766
|
+
const shape = findChild(tableEl, "SHAPEOBJECT");
|
|
18767
|
+
const caption = shape && findChild(shape, "CAPTION");
|
|
18768
|
+
if (!caption) return { text: "", before: false };
|
|
18769
|
+
const parts = [];
|
|
18770
|
+
collectCellText2(caption, parts, 0);
|
|
18771
|
+
const side = _nullishCoalesce(caption.getAttribute("Side"), () => ( ""));
|
|
18772
|
+
return { text: parts.filter(Boolean).join("\n").trim(), before: side === "Top" || side === "Left" };
|
|
18757
18773
|
}
|
|
18758
18774
|
function extractCellText(cellEl) {
|
|
18759
18775
|
const textParts = [];
|
|
@@ -19941,19 +19957,19 @@ function parseCentralDirectory(buf) {
|
|
|
19941
19957
|
}
|
|
19942
19958
|
}
|
|
19943
19959
|
}
|
|
19944
|
-
if (eocdOffset < 0) throw new (0,
|
|
19960
|
+
if (eocdOffset < 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19945
19961
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19946
19962
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19947
19963
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19948
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19964
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19949
19965
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19950
|
-
throw new (0,
|
|
19966
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19951
19967
|
}
|
|
19952
19968
|
const decoder = new TextDecoder("utf-8");
|
|
19953
19969
|
const entries = [];
|
|
19954
19970
|
let pos = cdOffset;
|
|
19955
19971
|
for (let i = 0; i < totalEntries; i++) {
|
|
19956
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19972
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19957
19973
|
const flags = view.getUint16(pos + 8, true);
|
|
19958
19974
|
const method = view.getUint16(pos + 10, true);
|
|
19959
19975
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19964,7 +19980,7 @@ function parseCentralDirectory(buf) {
|
|
|
19964
19980
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19965
19981
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19966
19982
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19967
|
-
throw new (0,
|
|
19983
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19968
19984
|
}
|
|
19969
19985
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19970
19986
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19993,7 +20009,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19993
20009
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19994
20010
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19995
20011
|
for (const name of replacements.keys()) {
|
|
19996
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20012
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkMEXUFQVCcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19997
20013
|
}
|
|
19998
20014
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19999
20015
|
const segments = [];
|
|
@@ -20011,7 +20027,7 @@ function patchZipEntries(original, replacements) {
|
|
|
20011
20027
|
offset += seg.length;
|
|
20012
20028
|
continue;
|
|
20013
20029
|
}
|
|
20014
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20030
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20015
20031
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20016
20032
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20017
20033
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20066,7 +20082,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20066
20082
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20067
20083
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20068
20084
|
if (sectionPaths.length === 0) {
|
|
20069
|
-
throw new (0,
|
|
20085
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20070
20086
|
}
|
|
20071
20087
|
const normalizedValues = normalizeValues(values);
|
|
20072
20088
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -21437,7 +21453,7 @@ function escapeGfm(text) {
|
|
|
21437
21453
|
}
|
|
21438
21454
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21439
21455
|
function sanitizeText(text) {
|
|
21440
|
-
let result =
|
|
21456
|
+
let result = _chunkMEXUFQVCcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21441
21457
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21442
21458
|
const tokens = result.split(" ");
|
|
21443
21459
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -22942,7 +22958,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
22942
22958
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
22943
22959
|
if (paths.length > 0) return paths;
|
|
22944
22960
|
}
|
|
22945
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
22961
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
|
|
22946
22962
|
}
|
|
22947
22963
|
function sectionPathsFromManifest(xml) {
|
|
22948
22964
|
const attr = (tag, name) => {
|
|
@@ -22952,7 +22968,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22952
22968
|
const idToHref = /* @__PURE__ */ new Map();
|
|
22953
22969
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
22954
22970
|
const id = attr(m[1], "id");
|
|
22955
|
-
const href =
|
|
22971
|
+
const href = _chunkMEXUFQVCcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
22956
22972
|
if (id && href) idToHref.set(id, href);
|
|
22957
22973
|
}
|
|
22958
22974
|
const ordered = [];
|
|
@@ -22961,7 +22977,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22961
22977
|
if (href) ordered.push(href);
|
|
22962
22978
|
}
|
|
22963
22979
|
if (ordered.length > 0) return ordered;
|
|
22964
|
-
return Array.from(idToHref.values()).sort(
|
|
22980
|
+
return Array.from(idToHref.values()).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
|
|
22965
22981
|
}
|
|
22966
22982
|
|
|
22967
22983
|
// src/roundtrip/patcher.ts
|
|
@@ -23072,9 +23088,9 @@ function buildOrigUnits(blocks) {
|
|
|
23072
23088
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
23073
23089
|
const next = blocks[i + 1];
|
|
23074
23090
|
if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
23075
|
-
chunk =
|
|
23091
|
+
chunk = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
23076
23092
|
} else {
|
|
23077
|
-
chunk =
|
|
23093
|
+
chunk = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, [block]);
|
|
23078
23094
|
}
|
|
23079
23095
|
if (chunk) {
|
|
23080
23096
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -24772,13 +24788,13 @@ async function htmlToPdf(html, options) {
|
|
|
24772
24788
|
try {
|
|
24773
24789
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
24774
24790
|
} catch (e30) {
|
|
24775
|
-
throw new (0,
|
|
24791
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)(
|
|
24776
24792
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
24777
24793
|
);
|
|
24778
24794
|
}
|
|
24779
24795
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
24780
24796
|
if (!executablePath) {
|
|
24781
|
-
throw new (0,
|
|
24797
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)(
|
|
24782
24798
|
"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."
|
|
24783
24799
|
);
|
|
24784
24800
|
}
|
|
@@ -24837,7 +24853,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
24837
24853
|
return htmlToPdf(html, options);
|
|
24838
24854
|
}
|
|
24839
24855
|
async function blocksToPdf(blocks, options) {
|
|
24840
|
-
const markdown =
|
|
24856
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
|
|
24841
24857
|
return markdownToPdf(markdown, options);
|
|
24842
24858
|
}
|
|
24843
24859
|
|
|
@@ -25392,14 +25408,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
25392
25408
|
try {
|
|
25393
25409
|
zip = await _jszip2.default.loadAsync(input);
|
|
25394
25410
|
} catch (e31) {
|
|
25395
|
-
throw new (0,
|
|
25411
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
25396
25412
|
}
|
|
25397
25413
|
const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
|
|
25398
|
-
if (!secFile) throw new (0,
|
|
25414
|
+
if (!secFile) throw new (0, _chunkMEXUFQVCcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
25399
25415
|
const secXml = await secFile.async("string");
|
|
25400
|
-
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
25416
|
+
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
25401
25417
|
if (!secXml.includes("linesegarray")) {
|
|
25402
|
-
throw new (0,
|
|
25418
|
+
throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5");
|
|
25403
25419
|
}
|
|
25404
25420
|
const warnings = [];
|
|
25405
25421
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
@@ -25433,7 +25449,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
25433
25449
|
}
|
|
25434
25450
|
const doc = createXmlParser().parseFromString(secXml, "text/xml");
|
|
25435
25451
|
const root = doc.documentElement;
|
|
25436
|
-
if (!root) throw new (0,
|
|
25452
|
+
if (!root) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
|
|
25437
25453
|
const pagePr = findFirst(root, "pagePr");
|
|
25438
25454
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
25439
25455
|
const PW = num(pagePr, "width", 59528), PH = num(pagePr, "height", 84188);
|
|
@@ -25471,13 +25487,13 @@ async function parse(input, options) {
|
|
|
25471
25487
|
if (typeof input === "string") {
|
|
25472
25488
|
try {
|
|
25473
25489
|
const buf = await _promises.readFile.call(void 0, input);
|
|
25474
|
-
buffer =
|
|
25490
|
+
buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, buf);
|
|
25475
25491
|
} catch (err) {
|
|
25476
25492
|
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}`;
|
|
25477
25493
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
25478
25494
|
}
|
|
25479
25495
|
} else if (Buffer.isBuffer(input)) {
|
|
25480
|
-
buffer =
|
|
25496
|
+
buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, input);
|
|
25481
25497
|
} else {
|
|
25482
25498
|
buffer = input;
|
|
25483
25499
|
}
|
|
@@ -25512,7 +25528,7 @@ async function parseHwp3(buffer, options) {
|
|
|
25512
25528
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
25513
25529
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
25514
25530
|
} catch (err) {
|
|
25515
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25531
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25516
25532
|
}
|
|
25517
25533
|
}
|
|
25518
25534
|
async function parseHwpx(buffer, options) {
|
|
@@ -25520,7 +25536,7 @@ async function parseHwpx(buffer, options) {
|
|
|
25520
25536
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
25521
25537
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _297 => _297.length]) ? images : void 0 };
|
|
25522
25538
|
} catch (err) {
|
|
25523
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25539
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25524
25540
|
}
|
|
25525
25541
|
}
|
|
25526
25542
|
async function parseHwp(buffer, options) {
|
|
@@ -25545,13 +25561,13 @@ async function parseHwp(buffer, options) {
|
|
|
25545
25561
|
}
|
|
25546
25562
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _299 => _299.length]) ? images : void 0 };
|
|
25547
25563
|
} catch (err) {
|
|
25548
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25564
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25549
25565
|
}
|
|
25550
25566
|
}
|
|
25551
25567
|
async function parsePdf(buffer, options) {
|
|
25552
25568
|
let parsePdfDocument;
|
|
25553
25569
|
try {
|
|
25554
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
25570
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-DZBI3EA2.cjs")));
|
|
25555
25571
|
parsePdfDocument = mod.parsePdfDocument;
|
|
25556
25572
|
} catch (e33) {
|
|
25557
25573
|
return {
|
|
@@ -25566,7 +25582,7 @@ async function parsePdf(buffer, options) {
|
|
|
25566
25582
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
25567
25583
|
} catch (err) {
|
|
25568
25584
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
25569
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25585
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err), isImageBased };
|
|
25570
25586
|
}
|
|
25571
25587
|
}
|
|
25572
25588
|
async function parseXlsx(buffer, options) {
|
|
@@ -25574,7 +25590,7 @@ async function parseXlsx(buffer, options) {
|
|
|
25574
25590
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
25575
25591
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
25576
25592
|
} catch (err) {
|
|
25577
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25593
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25578
25594
|
}
|
|
25579
25595
|
}
|
|
25580
25596
|
async function parseXls(buffer, options) {
|
|
@@ -25582,7 +25598,7 @@ async function parseXls(buffer, options) {
|
|
|
25582
25598
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
25583
25599
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
25584
25600
|
} catch (err) {
|
|
25585
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25601
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25586
25602
|
}
|
|
25587
25603
|
}
|
|
25588
25604
|
async function parseDocx(buffer, options) {
|
|
@@ -25590,7 +25606,7 @@ async function parseDocx(buffer, options) {
|
|
|
25590
25606
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
25591
25607
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _300 => _300.length]) ? images : void 0 };
|
|
25592
25608
|
} catch (err) {
|
|
25593
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25609
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25594
25610
|
}
|
|
25595
25611
|
}
|
|
25596
25612
|
async function parseHwpml(buffer, options) {
|
|
@@ -25598,16 +25614,16 @@ async function parseHwpml(buffer, options) {
|
|
|
25598
25614
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
25599
25615
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
25600
25616
|
} catch (err) {
|
|
25601
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
25617
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
|
|
25602
25618
|
}
|
|
25603
25619
|
}
|
|
25604
25620
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
25605
25621
|
let buffer;
|
|
25606
25622
|
if (typeof input === "string") {
|
|
25607
25623
|
const buf = await _promises.readFile.call(void 0, input);
|
|
25608
|
-
buffer =
|
|
25624
|
+
buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, buf);
|
|
25609
25625
|
} else if (Buffer.isBuffer(input)) {
|
|
25610
|
-
buffer =
|
|
25626
|
+
buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, input);
|
|
25611
25627
|
} else {
|
|
25612
25628
|
buffer = input;
|
|
25613
25629
|
}
|
|
@@ -25633,7 +25649,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
25633
25649
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
25634
25650
|
}
|
|
25635
25651
|
const fill = fillFormFields(parsed.blocks, values);
|
|
25636
|
-
const markdown =
|
|
25652
|
+
const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
25637
25653
|
if (outputFormat === "hwpx") {
|
|
25638
25654
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
25639
25655
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -25692,5 +25708,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
25692
25708
|
|
|
25693
25709
|
|
|
25694
25710
|
|
|
25695
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
25711
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkMEXUFQVCcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkMEXUFQVCcjs.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.fitRatioForFewerLines = fitRatioForFewerLines; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; 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.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord;
|
|
25696
25712
|
//# sourceMappingURL=index.cjs.map
|