kordoc 3.16.1 → 3.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-YVONYEEN.js → -C4FVXHIP.js} +7 -7
- package/dist/{chunk-K4L563FA.js → chunk-4WI7QXEG.js} +2 -2
- package/dist/{chunk-VNIQK4AL.cjs → chunk-72LLOLFX.cjs} +2 -2
- package/dist/{chunk-VNIQK4AL.cjs.map → chunk-72LLOLFX.cjs.map} +1 -1
- package/dist/{chunk-CDFCA37S.js → chunk-E4Y73XRH.js} +3 -3
- package/dist/{chunk-QOPY6URE.js → chunk-EJ2ZIYTO.js} +2 -2
- package/dist/{chunk-I6T3DKYK.js → chunk-EUEKDZ7O.js} +7 -7
- package/dist/{chunk-IY3NX4FT.js → chunk-HECUYZZK.js} +2 -2
- package/dist/{chunk-F62GOZFB.js → chunk-IS3IK7UT.js} +2 -2
- package/dist/{chunk-7WUTJXKP.js → chunk-WR5LHRXO.js} +3 -3
- package/dist/cli.js +12 -12
- package/dist/index.cjs +128 -128
- package/dist/index.js +2 -2
- package/dist/mcp.js +8 -8
- package/dist/{parser-B4O7CW5Q.js → parser-CMPNM6ZL.js} +4 -4
- package/dist/parser-CMPNM6ZL.js.map +1 -0
- package/dist/{parser-BNEAMKUF.js → parser-GWL72XYS.js} +3 -3
- package/dist/parser-GWL72XYS.js.map +1 -0
- package/dist/{parser-3O2UF6VO.cjs → parser-YVRTKGKO.cjs} +15 -15
- package/dist/{parser-3O2UF6VO.cjs.map → parser-YVRTKGKO.cjs.map} +1 -1
- package/dist/render-A2LFMJCP.js +10 -0
- package/dist/seal-KA4VAV2Z.js +10 -0
- package/dist/{watch-RLF5F3TN.js → watch-WLI6K3IR.js} +7 -7
- package/package.json +1 -1
- package/dist/parser-B4O7CW5Q.js.map +0 -1
- package/dist/parser-BNEAMKUF.js.map +0 -1
- package/dist/render-QCNMRR7L.js +0 -10
- package/dist/seal-REDSMUI5.js +0 -10
- /package/dist/{-YVONYEEN.js.map → -C4FVXHIP.js.map} +0 -0
- /package/dist/{chunk-K4L563FA.js.map → chunk-4WI7QXEG.js.map} +0 -0
- /package/dist/{chunk-CDFCA37S.js.map → chunk-E4Y73XRH.js.map} +0 -0
- /package/dist/{chunk-QOPY6URE.js.map → chunk-EJ2ZIYTO.js.map} +0 -0
- /package/dist/{chunk-I6T3DKYK.js.map → chunk-EUEKDZ7O.js.map} +0 -0
- /package/dist/{chunk-IY3NX4FT.js.map → chunk-HECUYZZK.js.map} +0 -0
- /package/dist/{chunk-F62GOZFB.js.map → chunk-IS3IK7UT.js.map} +0 -0
- /package/dist/{chunk-7WUTJXKP.js.map → chunk-WR5LHRXO.js.map} +0 -0
- /package/dist/{render-QCNMRR7L.js.map → render-A2LFMJCP.js.map} +0 -0
- /package/dist/{seal-REDSMUI5.js.map → seal-KA4VAV2Z.js.map} +0 -0
- /package/dist/{watch-RLF5F3TN.js.map → watch-WLI6K3IR.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunk72LLOLFXcjs = require('./chunk-72LLOLFX.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, _chunk72LLOLFXcjs.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, _chunk72LLOLFXcjs.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(_chunk72LLOLFXcjs.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 >= _chunk72LLOLFXcjs.HEADING_RATIO_H1) level = 1;
|
|
619
|
+
else if (ratio >= _chunk72LLOLFXcjs.HEADING_RATIO_H2) level = 2;
|
|
620
|
+
else if (ratio >= _chunk72LLOLFXcjs.HEADING_RATIO_H3) level = 3;
|
|
621
621
|
}
|
|
622
622
|
const compactText = text.replace(/\s+/g, "");
|
|
623
623
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1194,7 +1194,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1194
1194
|
|
|
1195
1195
|
// src/hwpx/table-build.ts
|
|
1196
1196
|
function buildTableWithCellMeta(state) {
|
|
1197
|
-
const table =
|
|
1197
|
+
const table = _chunk72LLOLFXcjs.buildTable.call(void 0, state.rows);
|
|
1198
1198
|
if (state.caption) table.caption = state.caption;
|
|
1199
1199
|
const anchors = [];
|
|
1200
1200
|
{
|
|
@@ -1264,7 +1264,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1264
1264
|
const cell = parentTable.cell;
|
|
1265
1265
|
(cell.blocks ??= []).push(block);
|
|
1266
1266
|
cell.hasStructure = true;
|
|
1267
|
-
let flat =
|
|
1267
|
+
let flat = _chunk72LLOLFXcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1268
1268
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1269
1269
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1270
1270
|
} else {
|
|
@@ -1276,7 +1276,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1276
1276
|
// src/hwpx/section-walker.ts
|
|
1277
1277
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1278
1278
|
const parser = createXmlParser(warnings);
|
|
1279
|
-
const doc = parser.parseFromString(
|
|
1279
|
+
const doc = parser.parseFromString(_chunk72LLOLFXcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1280
1280
|
if (!doc.documentElement) return [];
|
|
1281
1281
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1282
1282
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1367,8 +1367,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1367
1367
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1368
1368
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1369
1369
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1370
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1371
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1370
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunk72LLOLFXcjs.MAX_COLS);
|
|
1371
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunk72LLOLFXcjs.MAX_ROWS);
|
|
1372
1372
|
}
|
|
1373
1373
|
break;
|
|
1374
1374
|
case "p": {
|
|
@@ -1590,7 +1590,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1590
1590
|
let url = (ch.textContent || "").trim();
|
|
1591
1591
|
if (!url) continue;
|
|
1592
1592
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1593
|
-
const safe =
|
|
1593
|
+
const safe = _chunk72LLOLFXcjs.sanitizeHref.call(void 0, url);
|
|
1594
1594
|
if (safe) return safe;
|
|
1595
1595
|
}
|
|
1596
1596
|
return void 0;
|
|
@@ -1725,7 +1725,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1725
1725
|
case "hyperlink": {
|
|
1726
1726
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1727
1727
|
if (url) {
|
|
1728
|
-
const safe =
|
|
1728
|
+
const safe = _chunk72LLOLFXcjs.sanitizeHref.call(void 0, url);
|
|
1729
1729
|
if (safe) href = safe;
|
|
1730
1730
|
}
|
|
1731
1731
|
walk(child);
|
|
@@ -1911,13 +1911,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1911
1911
|
}
|
|
1912
1912
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1913
1913
|
for (const path of allCandidates) {
|
|
1914
|
-
if (
|
|
1914
|
+
if (_chunk72LLOLFXcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1915
1915
|
const file = zip.file(path);
|
|
1916
1916
|
if (!file) continue;
|
|
1917
1917
|
try {
|
|
1918
1918
|
const data = await file.async("uint8array");
|
|
1919
1919
|
decompressed.total += data.length;
|
|
1920
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1920
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1921
1921
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1922
1922
|
const mimeType = imageExtToMime(ext);
|
|
1923
1923
|
imageIndex++;
|
|
@@ -1926,7 +1926,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1926
1926
|
images.push(img);
|
|
1927
1927
|
break;
|
|
1928
1928
|
} catch (err) {
|
|
1929
|
-
if (err instanceof
|
|
1929
|
+
if (err instanceof _chunk72LLOLFXcjs.KordocError) throw err;
|
|
1930
1930
|
}
|
|
1931
1931
|
}
|
|
1932
1932
|
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" })]);
|
|
@@ -1988,7 +1988,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1988
1988
|
}
|
|
1989
1989
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1990
1990
|
const name = new TextDecoder().decode(nameBytes);
|
|
1991
|
-
if (
|
|
1991
|
+
if (_chunk72LLOLFXcjs.isPathTraversal.call(void 0, name)) {
|
|
1992
1992
|
pos = fileStart + compSize;
|
|
1993
1993
|
continue;
|
|
1994
1994
|
}
|
|
@@ -2006,16 +2006,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2006
2006
|
continue;
|
|
2007
2007
|
}
|
|
2008
2008
|
totalDecompressed += content.length * 2;
|
|
2009
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2009
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2010
2010
|
sectionNum++;
|
|
2011
2011
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2012
2012
|
} catch (e13) {
|
|
2013
2013
|
continue;
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
|
-
if (blocks.length === 0) throw new (0,
|
|
2016
|
+
if (blocks.length === 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2017
2017
|
applyPageText(blocks, shared);
|
|
2018
|
-
const markdown =
|
|
2018
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2019
2019
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2020
2020
|
}
|
|
2021
2021
|
async function resolveSectionPaths(zip) {
|
|
@@ -2029,18 +2029,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2029
2029
|
if (paths.length > 0) return paths;
|
|
2030
2030
|
}
|
|
2031
2031
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2032
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2032
|
+
return sectionFiles.map((f) => f.name).sort(_chunk72LLOLFXcjs.compareSectionPaths);
|
|
2033
2033
|
}
|
|
2034
2034
|
function parseSectionPathsFromManifest(xml) {
|
|
2035
2035
|
const parser = createXmlParser();
|
|
2036
|
-
const doc = parser.parseFromString(
|
|
2036
|
+
const doc = parser.parseFromString(_chunk72LLOLFXcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2037
2037
|
const items = doc.getElementsByTagName("opf:item");
|
|
2038
2038
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2039
2039
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2040
2040
|
for (let i = 0; i < items.length; i++) {
|
|
2041
2041
|
const item = items[i];
|
|
2042
2042
|
const id = item.getAttribute("id") || "";
|
|
2043
|
-
const href =
|
|
2043
|
+
const href = _chunk72LLOLFXcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2044
2044
|
if (id && href) idToHref.set(id, href);
|
|
2045
2045
|
}
|
|
2046
2046
|
if (spine.length > 0) {
|
|
@@ -2051,7 +2051,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2051
2051
|
}
|
|
2052
2052
|
if (ordered.length > 0) return ordered;
|
|
2053
2053
|
}
|
|
2054
|
-
return Array.from(idToHref.values()).sort(
|
|
2054
|
+
return Array.from(idToHref.values()).sort(_chunk72LLOLFXcjs.compareSectionPaths);
|
|
2055
2055
|
}
|
|
2056
2056
|
|
|
2057
2057
|
// src/hwpx/metadata.ts
|
|
@@ -2064,7 +2064,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2064
2064
|
const xml = await file.async("text");
|
|
2065
2065
|
if (decompressed) {
|
|
2066
2066
|
decompressed.total += xml.length * 2;
|
|
2067
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2067
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2068
2068
|
}
|
|
2069
2069
|
parseDublinCoreMetadata(xml, metadata);
|
|
2070
2070
|
if (metadata.title || metadata.author) return;
|
|
@@ -2074,7 +2074,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2074
2074
|
}
|
|
2075
2075
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2076
2076
|
const parser = createXmlParser();
|
|
2077
|
-
const doc = parser.parseFromString(
|
|
2077
|
+
const doc = parser.parseFromString(_chunk72LLOLFXcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2078
2078
|
if (!doc.documentElement) return;
|
|
2079
2079
|
const getText = (tagNames) => {
|
|
2080
2080
|
for (const tag of tagNames) {
|
|
@@ -2099,7 +2099,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2099
2099
|
|
|
2100
2100
|
// src/hwpx/parser.ts
|
|
2101
2101
|
async function parseHwpxDocument(buffer, options) {
|
|
2102
|
-
|
|
2102
|
+
_chunk72LLOLFXcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2103
2103
|
let zip;
|
|
2104
2104
|
try {
|
|
2105
2105
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2108,7 +2108,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2108
2108
|
}
|
|
2109
2109
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2110
2110
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2111
|
-
throw new (0,
|
|
2111
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2112
2112
|
}
|
|
2113
2113
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2114
2114
|
if (manifestFile) {
|
|
@@ -2120,7 +2120,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2120
2120
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2121
2121
|
}
|
|
2122
2122
|
}
|
|
2123
|
-
throw new (0,
|
|
2123
|
+
throw new (0, _chunk72LLOLFXcjs.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.");
|
|
2124
2124
|
}
|
|
2125
2125
|
}
|
|
2126
2126
|
const decompressed = { total: 0 };
|
|
@@ -2129,7 +2129,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2129
2129
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2130
2130
|
const warnings = [];
|
|
2131
2131
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2132
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2132
|
+
if (sectionPaths.length === 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2133
2133
|
metadata.pageCount = sectionPaths.length;
|
|
2134
2134
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2135
2135
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2143,12 +2143,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2143
2143
|
try {
|
|
2144
2144
|
const xml = await file.async("text");
|
|
2145
2145
|
decompressed.total += xml.length * 2;
|
|
2146
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2146
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2147
2147
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2148
2148
|
parsedSections++;
|
|
2149
2149
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2150
2150
|
} catch (secErr) {
|
|
2151
|
-
if (secErr instanceof
|
|
2151
|
+
if (secErr instanceof _chunk72LLOLFXcjs.KordocError) throw secErr;
|
|
2152
2152
|
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" });
|
|
2153
2153
|
}
|
|
2154
2154
|
}
|
|
@@ -2156,7 +2156,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2156
2156
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2157
2157
|
detectHwpxHeadings(blocks, styleMap);
|
|
2158
2158
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2159
|
-
const markdown =
|
|
2159
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2160
2160
|
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 };
|
|
2161
2161
|
}
|
|
2162
2162
|
|
|
@@ -2223,7 +2223,7 @@ function decompressStream(data) {
|
|
|
2223
2223
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2224
2224
|
}
|
|
2225
2225
|
function parseFileHeader(data) {
|
|
2226
|
-
if (data.length < 40) throw new (0,
|
|
2226
|
+
if (data.length < 40) throw new (0, _chunk72LLOLFXcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2227
2227
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2228
2228
|
return {
|
|
2229
2229
|
signature: sig,
|
|
@@ -3756,7 +3756,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3756
3756
|
lenientCfb = parseLenientCfb(buffer);
|
|
3757
3757
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3758
3758
|
} catch (e21) {
|
|
3759
|
-
throw new (0,
|
|
3759
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3760
3760
|
}
|
|
3761
3761
|
}
|
|
3762
3762
|
const findStream = (path) => {
|
|
@@ -3767,11 +3767,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3767
3767
|
return lenientCfb.findStream(path);
|
|
3768
3768
|
};
|
|
3769
3769
|
const headerData = findStream("/FileHeader");
|
|
3770
|
-
if (!headerData) throw new (0,
|
|
3770
|
+
if (!headerData) throw new (0, _chunk72LLOLFXcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3771
3771
|
const header = parseFileHeader(headerData);
|
|
3772
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3773
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3774
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3772
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunk72LLOLFXcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3773
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3774
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunk72LLOLFXcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3775
3775
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3776
3776
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3777
3777
|
const metadata = {
|
|
@@ -3780,7 +3780,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3780
3780
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3781
3781
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3782
3782
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3783
|
-
if (sections.length === 0) throw new (0,
|
|
3783
|
+
if (sections.length === 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3784
3784
|
metadata.pageCount = sections.length;
|
|
3785
3785
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3786
3786
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3794,25 +3794,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3794
3794
|
const sectionData = sections[si];
|
|
3795
3795
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3796
3796
|
totalDecompressed += data.length;
|
|
3797
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3797
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3798
3798
|
const records = readRecords(data);
|
|
3799
3799
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3800
3800
|
bodyBlocks.push(...sectionBlocks);
|
|
3801
3801
|
parsedSections++;
|
|
3802
3802
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3803
3803
|
} catch (secErr) {
|
|
3804
|
-
if (secErr instanceof
|
|
3804
|
+
if (secErr instanceof _chunk72LLOLFXcjs.KordocError) throw secErr;
|
|
3805
3805
|
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" });
|
|
3806
3806
|
}
|
|
3807
3807
|
}
|
|
3808
3808
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3809
3809
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3810
|
-
const flatBlocks =
|
|
3810
|
+
const flatBlocks = _chunk72LLOLFXcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3811
3811
|
if (docInfo) {
|
|
3812
3812
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3813
3813
|
}
|
|
3814
3814
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3815
|
-
const markdown =
|
|
3815
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3816
3816
|
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 };
|
|
3817
3817
|
}
|
|
3818
3818
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3872,9 +3872,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3872
3872
|
let level = 0;
|
|
3873
3873
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3874
3874
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3875
|
-
if (ratio >=
|
|
3876
|
-
else if (ratio >=
|
|
3877
|
-
else if (ratio >=
|
|
3875
|
+
if (ratio >= _chunk72LLOLFXcjs.HEADING_RATIO_H1) level = 1;
|
|
3876
|
+
else if (ratio >= _chunk72LLOLFXcjs.HEADING_RATIO_H2) level = 2;
|
|
3877
|
+
else if (ratio >= _chunk72LLOLFXcjs.HEADING_RATIO_H3) level = 3;
|
|
3878
3878
|
}
|
|
3879
3879
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3880
3880
|
if (level === 0) level = 2;
|
|
@@ -3959,7 +3959,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3959
3959
|
if (!raw) break;
|
|
3960
3960
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3961
3961
|
totalDecompressed += content.length;
|
|
3962
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3962
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3963
3963
|
sections.push({ idx: i, content });
|
|
3964
3964
|
}
|
|
3965
3965
|
if (sections.length === 0) {
|
|
@@ -3971,7 +3971,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3971
3971
|
if (raw) {
|
|
3972
3972
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3973
3973
|
totalDecompressed += content.length;
|
|
3974
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3974
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3975
3975
|
sections.push({ idx, content });
|
|
3976
3976
|
}
|
|
3977
3977
|
}
|
|
@@ -3988,7 +3988,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3988
3988
|
try {
|
|
3989
3989
|
const content = decryptViewText(raw, compressed);
|
|
3990
3990
|
totalDecompressed += content.length;
|
|
3991
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3991
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3992
3992
|
sections.push({ idx: i, content });
|
|
3993
3993
|
} catch (e26) {
|
|
3994
3994
|
break;
|
|
@@ -4091,7 +4091,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4091
4091
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4092
4092
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
4093
4093
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4094
|
-
const href =
|
|
4094
|
+
const href = _chunk72LLOLFXcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4095
4095
|
if (!href) continue;
|
|
4096
4096
|
const anchor = text.slice(r.start, r.end);
|
|
4097
4097
|
if (!anchor.trim()) continue;
|
|
@@ -4324,8 +4324,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4324
4324
|
let tableIdx = -1;
|
|
4325
4325
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4326
4326
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4327
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4328
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4327
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunk72LLOLFXcjs.MAX_ROWS);
|
|
4328
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunk72LLOLFXcjs.MAX_COLS);
|
|
4329
4329
|
tableIdx = i2;
|
|
4330
4330
|
break;
|
|
4331
4331
|
}
|
|
@@ -4374,7 +4374,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4374
4374
|
return table2;
|
|
4375
4375
|
}
|
|
4376
4376
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4377
|
-
const table =
|
|
4377
|
+
const table = _chunk72LLOLFXcjs.buildTable.call(void 0, cellRows);
|
|
4378
4378
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4379
4379
|
return table.rows > 0 ? table : null;
|
|
4380
4380
|
}
|
|
@@ -4391,8 +4391,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4391
4391
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4392
4392
|
const cs = rec.data.readUInt16LE(12);
|
|
4393
4393
|
const rs = rec.data.readUInt16LE(14);
|
|
4394
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4395
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4394
|
+
if (cs > 0) colSpan = Math.min(cs, _chunk72LLOLFXcjs.MAX_COLS);
|
|
4395
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunk72LLOLFXcjs.MAX_ROWS);
|
|
4396
4396
|
}
|
|
4397
4397
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4398
4398
|
const parts = [];
|
|
@@ -4402,7 +4402,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4402
4402
|
parts.push(``);
|
|
4403
4403
|
hasStructure = true;
|
|
4404
4404
|
} else if (b.type === "table" && b.table) {
|
|
4405
|
-
const flat =
|
|
4405
|
+
const flat = _chunk72LLOLFXcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4406
4406
|
if (flat) parts.push(flat);
|
|
4407
4407
|
hasStructure = true;
|
|
4408
4408
|
} else if (b.text) {
|
|
@@ -16839,7 +16839,7 @@ function getTextContent(el) {
|
|
|
16839
16839
|
return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
|
|
16840
16840
|
}
|
|
16841
16841
|
function parseXml(text) {
|
|
16842
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16842
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk72LLOLFXcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16843
16843
|
}
|
|
16844
16844
|
function parseSharedStrings(xml) {
|
|
16845
16845
|
const doc = parseXml(xml);
|
|
@@ -16983,7 +16983,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16983
16983
|
cellRows.push(row);
|
|
16984
16984
|
}
|
|
16985
16985
|
if (cellRows.length > 0) {
|
|
16986
|
-
const table =
|
|
16986
|
+
const table = _chunk72LLOLFXcjs.buildTable.call(void 0, cellRows);
|
|
16987
16987
|
if (table.rows > 0) {
|
|
16988
16988
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16989
16989
|
}
|
|
@@ -16991,12 +16991,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16991
16991
|
return blocks;
|
|
16992
16992
|
}
|
|
16993
16993
|
async function parseXlsxDocument(buffer, options) {
|
|
16994
|
-
|
|
16994
|
+
_chunk72LLOLFXcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16995
16995
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16996
16996
|
const warnings = [];
|
|
16997
16997
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16998
16998
|
if (!workbookFile) {
|
|
16999
|
-
throw new (0,
|
|
16999
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17000
17000
|
}
|
|
17001
17001
|
let sharedStrings = [];
|
|
17002
17002
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17005,7 +17005,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17005
17005
|
}
|
|
17006
17006
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
17007
17007
|
if (sheets.length === 0) {
|
|
17008
|
-
throw new (0,
|
|
17008
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17009
17009
|
}
|
|
17010
17010
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17011
17011
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17077,7 +17077,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17077
17077
|
} catch (e27) {
|
|
17078
17078
|
}
|
|
17079
17079
|
}
|
|
17080
|
-
const markdown =
|
|
17080
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17081
17081
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17082
17082
|
}
|
|
17083
17083
|
|
|
@@ -17484,11 +17484,11 @@ function processGlobals(records) {
|
|
|
17484
17484
|
let encrypted = false;
|
|
17485
17485
|
const firstBof = records[0];
|
|
17486
17486
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17487
|
-
throw new (0,
|
|
17487
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17488
17488
|
}
|
|
17489
17489
|
const bof = decodeBof(firstBof.data);
|
|
17490
17490
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17491
|
-
throw new (0,
|
|
17491
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17492
17492
|
}
|
|
17493
17493
|
let i = 1;
|
|
17494
17494
|
while (i < records.length) {
|
|
@@ -17603,7 +17603,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17603
17603
|
cellRows.push(row);
|
|
17604
17604
|
}
|
|
17605
17605
|
if (cellRows.length > 0) {
|
|
17606
|
-
const table =
|
|
17606
|
+
const table = _chunk72LLOLFXcjs.buildTable.call(void 0, cellRows);
|
|
17607
17607
|
if (table.rows > 0) {
|
|
17608
17608
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17609
17609
|
}
|
|
@@ -17616,21 +17616,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17616
17616
|
try {
|
|
17617
17617
|
cfb = parseLenientCfb(buf);
|
|
17618
17618
|
} catch (e) {
|
|
17619
|
-
throw new (0,
|
|
17619
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)(
|
|
17620
17620
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17621
17621
|
);
|
|
17622
17622
|
}
|
|
17623
17623
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17624
17624
|
if (!wb) {
|
|
17625
|
-
throw new (0,
|
|
17625
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17626
17626
|
}
|
|
17627
17627
|
const records = readRecords2(wb);
|
|
17628
17628
|
if (records.length === 0) {
|
|
17629
|
-
throw new (0,
|
|
17629
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17630
17630
|
}
|
|
17631
17631
|
const firstBof = decodeBof(records[0].data);
|
|
17632
17632
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17633
|
-
throw new (0,
|
|
17633
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)(
|
|
17634
17634
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17635
17635
|
);
|
|
17636
17636
|
}
|
|
@@ -17690,7 +17690,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17690
17690
|
pageCount: totalSheets
|
|
17691
17691
|
};
|
|
17692
17692
|
return {
|
|
17693
|
-
markdown:
|
|
17693
|
+
markdown: _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17694
17694
|
blocks: allBlocks,
|
|
17695
17695
|
metadata,
|
|
17696
17696
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18128,7 +18128,7 @@ function getAttr(el, localName2) {
|
|
|
18128
18128
|
return null;
|
|
18129
18129
|
}
|
|
18130
18130
|
function parseXml2(text) {
|
|
18131
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18131
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk72LLOLFXcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18132
18132
|
}
|
|
18133
18133
|
function parseStyles(xml) {
|
|
18134
18134
|
const doc = parseXml2(xml);
|
|
@@ -18413,7 +18413,7 @@ ${cell.text}` : cell.text;
|
|
|
18413
18413
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18414
18414
|
})
|
|
18415
18415
|
);
|
|
18416
|
-
const table =
|
|
18416
|
+
const table = _chunk72LLOLFXcjs.buildTable.call(void 0, cellRows);
|
|
18417
18417
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18418
18418
|
return { type: "table", table };
|
|
18419
18419
|
}
|
|
@@ -18480,12 +18480,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18480
18480
|
return { blocks, images };
|
|
18481
18481
|
}
|
|
18482
18482
|
async function parseDocxDocument(buffer, options) {
|
|
18483
|
-
|
|
18483
|
+
_chunk72LLOLFXcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18484
18484
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18485
18485
|
const warnings = [];
|
|
18486
18486
|
const docFile = zip.file("word/document.xml");
|
|
18487
18487
|
if (!docFile) {
|
|
18488
|
-
throw new (0,
|
|
18488
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18489
18489
|
}
|
|
18490
18490
|
let rels = /* @__PURE__ */ new Map();
|
|
18491
18491
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18532,7 +18532,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18532
18532
|
const doc = parseXml2(docXml);
|
|
18533
18533
|
const body = findElements(doc, "body");
|
|
18534
18534
|
if (body.length === 0) {
|
|
18535
|
-
throw new (0,
|
|
18535
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18536
18536
|
}
|
|
18537
18537
|
const blocks = [];
|
|
18538
18538
|
const bodyEl = body[0];
|
|
@@ -18577,7 +18577,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18577
18577
|
}
|
|
18578
18578
|
}
|
|
18579
18579
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18580
|
-
const markdown =
|
|
18580
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18581
18581
|
return {
|
|
18582
18582
|
markdown,
|
|
18583
18583
|
blocks,
|
|
@@ -18600,7 +18600,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18600
18600
|
}
|
|
18601
18601
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18602
18602
|
const normalized = text.replace(/ /g, " ");
|
|
18603
|
-
const xml =
|
|
18603
|
+
const xml = _chunk72LLOLFXcjs.stripDtd.call(void 0, normalized);
|
|
18604
18604
|
const warnings = [];
|
|
18605
18605
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18606
18606
|
onError: (_level, msg2) => {
|
|
@@ -18640,7 +18640,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18640
18640
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18641
18641
|
}
|
|
18642
18642
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18643
|
-
const markdown =
|
|
18643
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18644
18644
|
return {
|
|
18645
18645
|
markdown,
|
|
18646
18646
|
blocks,
|
|
@@ -18798,7 +18798,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18798
18798
|
const cellRows = grid.map(
|
|
18799
18799
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18800
18800
|
);
|
|
18801
|
-
const table =
|
|
18801
|
+
const table = _chunk72LLOLFXcjs.buildTable.call(void 0, cellRows);
|
|
18802
18802
|
const caption = extractShapeCaption(el);
|
|
18803
18803
|
if (caption.text && caption.before) {
|
|
18804
18804
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20126,19 +20126,19 @@ function parseCentralDirectory(buf) {
|
|
|
20126
20126
|
}
|
|
20127
20127
|
}
|
|
20128
20128
|
}
|
|
20129
|
-
if (eocdOffset < 0) throw new (0,
|
|
20129
|
+
if (eocdOffset < 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20130
20130
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20131
20131
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20132
20132
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20133
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20133
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20134
20134
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20135
|
-
throw new (0,
|
|
20135
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20136
20136
|
}
|
|
20137
20137
|
const decoder = new TextDecoder("utf-8");
|
|
20138
20138
|
const entries = [];
|
|
20139
20139
|
let pos = cdOffset;
|
|
20140
20140
|
for (let i = 0; i < totalEntries; i++) {
|
|
20141
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20141
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20142
20142
|
const flags = view.getUint16(pos + 8, true);
|
|
20143
20143
|
const method = view.getUint16(pos + 10, true);
|
|
20144
20144
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20149,7 +20149,7 @@ function parseCentralDirectory(buf) {
|
|
|
20149
20149
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20150
20150
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20151
20151
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20152
|
-
throw new (0,
|
|
20152
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20153
20153
|
}
|
|
20154
20154
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20155
20155
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20178,11 +20178,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20178
20178
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20179
20179
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20180
20180
|
for (const name of replacements.keys()) {
|
|
20181
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20181
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunk72LLOLFXcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20182
20182
|
}
|
|
20183
20183
|
if (additions) {
|
|
20184
20184
|
for (const name of additions.keys()) {
|
|
20185
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20185
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunk72LLOLFXcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20186
20186
|
}
|
|
20187
20187
|
}
|
|
20188
20188
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20201,7 +20201,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20201
20201
|
offset += seg.length;
|
|
20202
20202
|
continue;
|
|
20203
20203
|
}
|
|
20204
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20204
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunk72LLOLFXcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20205
20205
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20206
20206
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20207
20207
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20307,7 +20307,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20307
20307
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20308
20308
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20309
20309
|
if (sectionPaths.length === 0) {
|
|
20310
|
-
throw new (0,
|
|
20310
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20311
20311
|
}
|
|
20312
20312
|
const normalizedValues = normalizeValues(values);
|
|
20313
20313
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -21901,7 +21901,7 @@ function escapeGfm(text) {
|
|
|
21901
21901
|
}
|
|
21902
21902
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21903
21903
|
function sanitizeText(text) {
|
|
21904
|
-
let result =
|
|
21904
|
+
let result = _chunk72LLOLFXcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21905
21905
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21906
21906
|
const tokens = result.split(" ");
|
|
21907
21907
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23072,11 +23072,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
23072
23072
|
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>`;
|
|
23073
23073
|
}
|
|
23074
23074
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
23075
|
-
if (ops.length === 0) throw new (0,
|
|
23075
|
+
if (ops.length === 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23076
23076
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
23077
23077
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
23078
23078
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _222 => _222.match, 'call', _223 => _223(/(\d+)\.xml$/i), 'optionalAccess', _224 => _224[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _225 => _225.match, 'call', _226 => _226(/(\d+)\.xml$/i), 'optionalAccess', _227 => _227[1]]), () => ( 0))));
|
|
23079
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
23079
|
+
if (sectionPaths.length === 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23080
23080
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
23081
23081
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
23082
23082
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -23117,11 +23117,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23117
23117
|
const manifestItems = [];
|
|
23118
23118
|
const placed = [];
|
|
23119
23119
|
for (const op of ops) {
|
|
23120
|
-
if (!op.anchor) throw new (0,
|
|
23121
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
23120
|
+
if (!op.anchor) throw new (0, _chunk72LLOLFXcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23121
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunk72LLOLFXcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23122
23122
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
23123
|
-
if (!MIME[ext]) throw new (0,
|
|
23124
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
23123
|
+
if (!MIME[ext]) throw new (0, _chunk72LLOLFXcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
23124
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunk72LLOLFXcjs.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)`);
|
|
23125
23125
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
23126
23126
|
let found = null;
|
|
23127
23127
|
let total = 0;
|
|
@@ -23154,7 +23154,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23154
23154
|
}
|
|
23155
23155
|
}
|
|
23156
23156
|
}
|
|
23157
|
-
throw new (0,
|
|
23157
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)(
|
|
23158
23158
|
`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)})`
|
|
23159
23159
|
);
|
|
23160
23160
|
}
|
|
@@ -23162,7 +23162,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23162
23162
|
const xml = sectionXmls[si];
|
|
23163
23163
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
23164
23164
|
if (!run) {
|
|
23165
|
-
throw new (0,
|
|
23165
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
23166
23166
|
}
|
|
23167
23167
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _228 => _228.charPr, 'access', _229 => _229.get, 'call', _230 => _230(run.charPr), 'optionalAccess', _231 => _231.height]), () => ( 1e3));
|
|
23168
23168
|
const fontPt = charPrHeight / 100;
|
|
@@ -23841,7 +23841,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
23841
23841
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
23842
23842
|
if (paths.length > 0) return paths;
|
|
23843
23843
|
}
|
|
23844
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
23844
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk72LLOLFXcjs.compareSectionPaths);
|
|
23845
23845
|
}
|
|
23846
23846
|
function sectionPathsFromManifest(xml) {
|
|
23847
23847
|
const attr = (tag, name) => {
|
|
@@ -23851,7 +23851,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23851
23851
|
const idToHref = /* @__PURE__ */ new Map();
|
|
23852
23852
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
23853
23853
|
const id = attr(m[1], "id");
|
|
23854
|
-
const href =
|
|
23854
|
+
const href = _chunk72LLOLFXcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
23855
23855
|
if (id && href) idToHref.set(id, href);
|
|
23856
23856
|
}
|
|
23857
23857
|
const ordered = [];
|
|
@@ -23860,7 +23860,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23860
23860
|
if (href) ordered.push(href);
|
|
23861
23861
|
}
|
|
23862
23862
|
if (ordered.length > 0) return ordered;
|
|
23863
|
-
return Array.from(idToHref.values()).sort(
|
|
23863
|
+
return Array.from(idToHref.values()).sort(_chunk72LLOLFXcjs.compareSectionPaths);
|
|
23864
23864
|
}
|
|
23865
23865
|
|
|
23866
23866
|
// src/roundtrip/patcher.ts
|
|
@@ -23971,9 +23971,9 @@ function buildOrigUnits(blocks) {
|
|
|
23971
23971
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
23972
23972
|
const next = blocks[i + 1];
|
|
23973
23973
|
if (_optionalChain([next, 'optionalAccess', _259 => _259.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
23974
|
-
chunk =
|
|
23974
|
+
chunk = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
23975
23975
|
} else {
|
|
23976
|
-
chunk =
|
|
23976
|
+
chunk = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, [block]);
|
|
23977
23977
|
}
|
|
23978
23978
|
if (chunk) {
|
|
23979
23979
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -25812,13 +25812,13 @@ async function htmlToPdf(html, options) {
|
|
|
25812
25812
|
try {
|
|
25813
25813
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
25814
25814
|
} catch (e30) {
|
|
25815
|
-
throw new (0,
|
|
25815
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)(
|
|
25816
25816
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
25817
25817
|
);
|
|
25818
25818
|
}
|
|
25819
25819
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
25820
25820
|
if (!executablePath) {
|
|
25821
|
-
throw new (0,
|
|
25821
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)(
|
|
25822
25822
|
"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."
|
|
25823
25823
|
);
|
|
25824
25824
|
}
|
|
@@ -25877,7 +25877,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
25877
25877
|
return htmlToPdf(html, options);
|
|
25878
25878
|
}
|
|
25879
25879
|
async function blocksToPdf(blocks, options) {
|
|
25880
|
-
const markdown =
|
|
25880
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, blocks);
|
|
25881
25881
|
return markdownToPdf(markdown, options);
|
|
25882
25882
|
}
|
|
25883
25883
|
|
|
@@ -26653,20 +26653,20 @@ function sniffMime(name, bytes) {
|
|
|
26653
26653
|
async function renderHwpxToSvg(input, options) {
|
|
26654
26654
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _335 => _335.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
26655
26655
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
26656
|
-
|
|
26656
|
+
_chunk72LLOLFXcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
26657
26657
|
let zip;
|
|
26658
26658
|
try {
|
|
26659
26659
|
zip = await _jszip2.default.loadAsync(input);
|
|
26660
26660
|
} catch (e31) {
|
|
26661
|
-
throw new (0,
|
|
26661
|
+
throw new (0, _chunk72LLOLFXcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
26662
26662
|
}
|
|
26663
26663
|
const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
|
|
26664
|
-
if (!secFile) throw new (0,
|
|
26664
|
+
if (!secFile) throw new (0, _chunk72LLOLFXcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
26665
26665
|
const secXml = await secFile.async("string");
|
|
26666
|
-
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
26666
|
+
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
26667
26667
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
26668
26668
|
if (!hasCache && !_optionalChain([options, 'optionalAccess', _336 => _336.reflow])) {
|
|
26669
|
-
throw new (0,
|
|
26669
|
+
throw new (0, _chunk72LLOLFXcjs.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)");
|
|
26670
26670
|
}
|
|
26671
26671
|
const warnings = [];
|
|
26672
26672
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
@@ -26712,7 +26712,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26712
26712
|
}
|
|
26713
26713
|
const doc = createXmlParser().parseFromString(secXml, "text/xml");
|
|
26714
26714
|
const root = doc.documentElement;
|
|
26715
|
-
if (!root) throw new (0,
|
|
26715
|
+
if (!root) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
|
|
26716
26716
|
const pagePr = findFirst(root, "pagePr");
|
|
26717
26717
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
26718
26718
|
const PW = num2(pagePr, "width", 59528), PH = num2(pagePr, "height", 84188);
|
|
@@ -26786,13 +26786,13 @@ async function parse(input, options) {
|
|
|
26786
26786
|
if (typeof input === "string") {
|
|
26787
26787
|
try {
|
|
26788
26788
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26789
|
-
buffer =
|
|
26789
|
+
buffer = _chunk72LLOLFXcjs.toArrayBuffer.call(void 0, buf);
|
|
26790
26790
|
} catch (err) {
|
|
26791
26791
|
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}`;
|
|
26792
26792
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
26793
26793
|
}
|
|
26794
26794
|
} else if (Buffer.isBuffer(input)) {
|
|
26795
|
-
buffer =
|
|
26795
|
+
buffer = _chunk72LLOLFXcjs.toArrayBuffer.call(void 0, input);
|
|
26796
26796
|
} else {
|
|
26797
26797
|
buffer = input;
|
|
26798
26798
|
}
|
|
@@ -26827,7 +26827,7 @@ async function parseHwp3(buffer, options) {
|
|
|
26827
26827
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
26828
26828
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
26829
26829
|
} catch (err) {
|
|
26830
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26830
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26831
26831
|
}
|
|
26832
26832
|
}
|
|
26833
26833
|
async function parseHwpx(buffer, options) {
|
|
@@ -26835,7 +26835,7 @@ async function parseHwpx(buffer, options) {
|
|
|
26835
26835
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
26836
26836
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _341 => _341.length]) ? images : void 0 };
|
|
26837
26837
|
} catch (err) {
|
|
26838
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26838
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26839
26839
|
}
|
|
26840
26840
|
}
|
|
26841
26841
|
async function parseHwp(buffer, options) {
|
|
@@ -26860,13 +26860,13 @@ async function parseHwp(buffer, options) {
|
|
|
26860
26860
|
}
|
|
26861
26861
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _343 => _343.length]) ? images : void 0 };
|
|
26862
26862
|
} catch (err) {
|
|
26863
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26863
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26864
26864
|
}
|
|
26865
26865
|
}
|
|
26866
26866
|
async function parsePdf(buffer, options) {
|
|
26867
26867
|
let parsePdfDocument;
|
|
26868
26868
|
try {
|
|
26869
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
26869
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-YVRTKGKO.cjs")));
|
|
26870
26870
|
parsePdfDocument = mod.parsePdfDocument;
|
|
26871
26871
|
} catch (e33) {
|
|
26872
26872
|
return {
|
|
@@ -26881,7 +26881,7 @@ async function parsePdf(buffer, options) {
|
|
|
26881
26881
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
26882
26882
|
} catch (err) {
|
|
26883
26883
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
26884
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26884
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err), isImageBased };
|
|
26885
26885
|
}
|
|
26886
26886
|
}
|
|
26887
26887
|
async function parseXlsx(buffer, options) {
|
|
@@ -26889,7 +26889,7 @@ async function parseXlsx(buffer, options) {
|
|
|
26889
26889
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
26890
26890
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
26891
26891
|
} catch (err) {
|
|
26892
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26892
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26893
26893
|
}
|
|
26894
26894
|
}
|
|
26895
26895
|
async function parseXls(buffer, options) {
|
|
@@ -26897,7 +26897,7 @@ async function parseXls(buffer, options) {
|
|
|
26897
26897
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
26898
26898
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
26899
26899
|
} catch (err) {
|
|
26900
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26900
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26901
26901
|
}
|
|
26902
26902
|
}
|
|
26903
26903
|
async function parseDocx(buffer, options) {
|
|
@@ -26905,7 +26905,7 @@ async function parseDocx(buffer, options) {
|
|
|
26905
26905
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
26906
26906
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _344 => _344.length]) ? images : void 0 };
|
|
26907
26907
|
} catch (err) {
|
|
26908
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26908
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26909
26909
|
}
|
|
26910
26910
|
}
|
|
26911
26911
|
async function parseHwpml(buffer, options) {
|
|
@@ -26913,16 +26913,16 @@ async function parseHwpml(buffer, options) {
|
|
|
26913
26913
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
26914
26914
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
26915
26915
|
} catch (err) {
|
|
26916
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26916
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk72LLOLFXcjs.classifyError.call(void 0, err) };
|
|
26917
26917
|
}
|
|
26918
26918
|
}
|
|
26919
26919
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
26920
26920
|
let buffer;
|
|
26921
26921
|
if (typeof input === "string") {
|
|
26922
26922
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26923
|
-
buffer =
|
|
26923
|
+
buffer = _chunk72LLOLFXcjs.toArrayBuffer.call(void 0, buf);
|
|
26924
26924
|
} else if (Buffer.isBuffer(input)) {
|
|
26925
|
-
buffer =
|
|
26925
|
+
buffer = _chunk72LLOLFXcjs.toArrayBuffer.call(void 0, input);
|
|
26926
26926
|
} else {
|
|
26927
26927
|
buffer = input;
|
|
26928
26928
|
}
|
|
@@ -26948,7 +26948,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
26948
26948
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
26949
26949
|
}
|
|
26950
26950
|
const fill = fillFormFields(parsed.blocks, values);
|
|
26951
|
-
const markdown =
|
|
26951
|
+
const markdown = _chunk72LLOLFXcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
26952
26952
|
if (outputFormat === "hwpx") {
|
|
26953
26953
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
26954
26954
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -27011,5 +27011,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27011
27011
|
|
|
27012
27012
|
|
|
27013
27013
|
|
|
27014
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
27014
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunk72LLOLFXcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk72LLOLFXcjs.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.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.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.validateHwpx = validateHwpx;
|
|
27015
27015
|
//# sourceMappingURL=index.cjs.map
|