kordoc 3.8.4 → 3.9.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 +12 -0
- package/dist/{-ZAIG6FWT.js → -6CLKMLK2.js} +3 -3
- package/dist/{chunk-T4SGNVVS.js → chunk-EZ5GBTBE.js} +2 -2
- package/dist/{chunk-6EDNKPXQ.js → chunk-ITPZD7XK.js} +344 -5
- package/dist/chunk-ITPZD7XK.js.map +1 -0
- package/dist/{chunk-Z3O36LBJ.cjs → chunk-VHXUD3PW.cjs} +2 -2
- package/dist/{chunk-Z3O36LBJ.cjs.map → chunk-VHXUD3PW.cjs.map} +1 -1
- package/dist/{chunk-2UDAEQPW.js → chunk-XKDA4FDM.js} +2 -2
- package/dist/cli.js +4 -4
- package/dist/index.cjs +454 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +343 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-PR7CPMM4.js → parser-LVI45MVF.js} +2 -2
- package/dist/{parser-ZVKCFXR3.cjs → parser-N4G5KQBE.cjs} +14 -14
- package/dist/{parser-ZVKCFXR3.cjs.map → parser-N4G5KQBE.cjs.map} +1 -1
- package/dist/{parser-2THIF623.js → parser-NCNME2Z6.js} +2 -2
- package/dist/{watch-2HYPNMOB.js → watch-XSLV62BH.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-6EDNKPXQ.js.map +0 -1
- /package/dist/{-ZAIG6FWT.js.map → -6CLKMLK2.js.map} +0 -0
- /package/dist/{chunk-T4SGNVVS.js.map → chunk-EZ5GBTBE.js.map} +0 -0
- /package/dist/{chunk-2UDAEQPW.js.map → chunk-XKDA4FDM.js.map} +0 -0
- /package/dist/{parser-PR7CPMM4.js.map → parser-LVI45MVF.js.map} +0 -0
- /package/dist/{parser-2THIF623.js.map → parser-NCNME2Z6.js.map} +0 -0
- /package/dist/{watch-2HYPNMOB.js.map → watch-XSLV62BH.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkVHXUD3PWcjs = require('./chunk-VHXUD3PW.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, _chunkVHXUD3PWcjs.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, _chunkVHXUD3PWcjs.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(_chunkVHXUD3PWcjs.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 >= _chunkVHXUD3PWcjs.HEADING_RATIO_H1) level = 1;
|
|
619
|
+
else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H2) level = 2;
|
|
620
|
+
else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H3) level = 3;
|
|
621
621
|
}
|
|
622
622
|
const compactText = text.replace(/\s+/g, "");
|
|
623
623
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -667,8 +667,10 @@ var CONVERT_MAP = {
|
|
|
667
667
|
SUCC: "\\succ",
|
|
668
668
|
UPLUS: "\\uplus",
|
|
669
669
|
"\xB1": "\\pm",
|
|
670
|
+
"+-": "\\pm",
|
|
670
671
|
"-+": "\\mp",
|
|
671
672
|
"\xF7": "\\div",
|
|
673
|
+
cdot: "\\cdot",
|
|
672
674
|
CIRC: "\\circ",
|
|
673
675
|
BULLET: "\\bullet",
|
|
674
676
|
DEG: " ^\\circ",
|
|
@@ -1057,6 +1059,10 @@ function hmlToLatex(hmlEqStr) {
|
|
|
1057
1059
|
const t = tokens[i];
|
|
1058
1060
|
if (t in CONVERT_MAP) tokens[i] = CONVERT_MAP[t];
|
|
1059
1061
|
else if (t in MIDDLE_CONVERT_MAP) tokens[i] = MIDDLE_CONVERT_MAP[t];
|
|
1062
|
+
else {
|
|
1063
|
+
const quoted = /^"(.+)"$/.exec(t);
|
|
1064
|
+
if (quoted) tokens[i] = `\\text{${quoted[1]}}`;
|
|
1065
|
+
}
|
|
1060
1066
|
}
|
|
1061
1067
|
tokens = tokens.filter((tok) => tok.length !== 0);
|
|
1062
1068
|
tokens = replaceBracket(tokens);
|
|
@@ -1165,7 +1171,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1165
1171
|
|
|
1166
1172
|
// src/hwpx/table-build.ts
|
|
1167
1173
|
function buildTableWithCellMeta(state) {
|
|
1168
|
-
const table =
|
|
1174
|
+
const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, state.rows);
|
|
1169
1175
|
if (state.caption) table.caption = state.caption;
|
|
1170
1176
|
const anchors = [];
|
|
1171
1177
|
{
|
|
@@ -1235,7 +1241,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1235
1241
|
const cell = parentTable.cell;
|
|
1236
1242
|
(cell.blocks ??= []).push(block);
|
|
1237
1243
|
cell.hasStructure = true;
|
|
1238
|
-
let flat =
|
|
1244
|
+
let flat = _chunkVHXUD3PWcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1239
1245
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1240
1246
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1241
1247
|
} else {
|
|
@@ -1247,7 +1253,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1247
1253
|
// src/hwpx/section-walker.ts
|
|
1248
1254
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1249
1255
|
const parser = createXmlParser(warnings);
|
|
1250
|
-
const doc = parser.parseFromString(
|
|
1256
|
+
const doc = parser.parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1251
1257
|
if (!doc.documentElement) return [];
|
|
1252
1258
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1253
1259
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1338,8 +1344,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1338
1344
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1339
1345
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1340
1346
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1341
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1342
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1347
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkVHXUD3PWcjs.MAX_COLS);
|
|
1348
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkVHXUD3PWcjs.MAX_ROWS);
|
|
1343
1349
|
}
|
|
1344
1350
|
break;
|
|
1345
1351
|
case "p": {
|
|
@@ -1561,7 +1567,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1561
1567
|
let url = (ch.textContent || "").trim();
|
|
1562
1568
|
if (!url) continue;
|
|
1563
1569
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1564
|
-
const safe =
|
|
1570
|
+
const safe = _chunkVHXUD3PWcjs.sanitizeHref.call(void 0, url);
|
|
1565
1571
|
if (safe) return safe;
|
|
1566
1572
|
}
|
|
1567
1573
|
return void 0;
|
|
@@ -1696,7 +1702,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1696
1702
|
case "hyperlink": {
|
|
1697
1703
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1698
1704
|
if (url) {
|
|
1699
|
-
const safe =
|
|
1705
|
+
const safe = _chunkVHXUD3PWcjs.sanitizeHref.call(void 0, url);
|
|
1700
1706
|
if (safe) href = safe;
|
|
1701
1707
|
}
|
|
1702
1708
|
walk(child);
|
|
@@ -1882,13 +1888,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1882
1888
|
}
|
|
1883
1889
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1884
1890
|
for (const path of allCandidates) {
|
|
1885
|
-
if (
|
|
1891
|
+
if (_chunkVHXUD3PWcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1886
1892
|
const file = zip.file(path);
|
|
1887
1893
|
if (!file) continue;
|
|
1888
1894
|
try {
|
|
1889
1895
|
const data = await file.async("uint8array");
|
|
1890
1896
|
decompressed.total += data.length;
|
|
1891
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1897
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1892
1898
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1893
1899
|
const mimeType = imageExtToMime(ext);
|
|
1894
1900
|
imageIndex++;
|
|
@@ -1897,7 +1903,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1897
1903
|
images.push(img);
|
|
1898
1904
|
break;
|
|
1899
1905
|
} catch (err) {
|
|
1900
|
-
if (err instanceof
|
|
1906
|
+
if (err instanceof _chunkVHXUD3PWcjs.KordocError) throw err;
|
|
1901
1907
|
}
|
|
1902
1908
|
}
|
|
1903
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" })]);
|
|
@@ -1959,7 +1965,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1959
1965
|
}
|
|
1960
1966
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1961
1967
|
const name = new TextDecoder().decode(nameBytes);
|
|
1962
|
-
if (
|
|
1968
|
+
if (_chunkVHXUD3PWcjs.isPathTraversal.call(void 0, name)) {
|
|
1963
1969
|
pos = fileStart + compSize;
|
|
1964
1970
|
continue;
|
|
1965
1971
|
}
|
|
@@ -1977,16 +1983,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1977
1983
|
continue;
|
|
1978
1984
|
}
|
|
1979
1985
|
totalDecompressed += content.length * 2;
|
|
1980
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1986
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1981
1987
|
sectionNum++;
|
|
1982
1988
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1983
1989
|
} catch (e13) {
|
|
1984
1990
|
continue;
|
|
1985
1991
|
}
|
|
1986
1992
|
}
|
|
1987
|
-
if (blocks.length === 0) throw new (0,
|
|
1993
|
+
if (blocks.length === 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1988
1994
|
applyPageText(blocks, shared);
|
|
1989
|
-
const markdown =
|
|
1995
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1990
1996
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1991
1997
|
}
|
|
1992
1998
|
async function resolveSectionPaths(zip) {
|
|
@@ -2000,18 +2006,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2000
2006
|
if (paths.length > 0) return paths;
|
|
2001
2007
|
}
|
|
2002
2008
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2003
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2009
|
+
return sectionFiles.map((f) => f.name).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
|
|
2004
2010
|
}
|
|
2005
2011
|
function parseSectionPathsFromManifest(xml) {
|
|
2006
2012
|
const parser = createXmlParser();
|
|
2007
|
-
const doc = parser.parseFromString(
|
|
2013
|
+
const doc = parser.parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2008
2014
|
const items = doc.getElementsByTagName("opf:item");
|
|
2009
2015
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2010
2016
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2011
2017
|
for (let i = 0; i < items.length; i++) {
|
|
2012
2018
|
const item = items[i];
|
|
2013
2019
|
const id = item.getAttribute("id") || "";
|
|
2014
|
-
const href =
|
|
2020
|
+
const href = _chunkVHXUD3PWcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2015
2021
|
if (id && href) idToHref.set(id, href);
|
|
2016
2022
|
}
|
|
2017
2023
|
if (spine.length > 0) {
|
|
@@ -2022,7 +2028,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2022
2028
|
}
|
|
2023
2029
|
if (ordered.length > 0) return ordered;
|
|
2024
2030
|
}
|
|
2025
|
-
return Array.from(idToHref.values()).sort(
|
|
2031
|
+
return Array.from(idToHref.values()).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
|
|
2026
2032
|
}
|
|
2027
2033
|
|
|
2028
2034
|
// src/hwpx/metadata.ts
|
|
@@ -2035,7 +2041,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2035
2041
|
const xml = await file.async("text");
|
|
2036
2042
|
if (decompressed) {
|
|
2037
2043
|
decompressed.total += xml.length * 2;
|
|
2038
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2044
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2039
2045
|
}
|
|
2040
2046
|
parseDublinCoreMetadata(xml, metadata);
|
|
2041
2047
|
if (metadata.title || metadata.author) return;
|
|
@@ -2045,7 +2051,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2045
2051
|
}
|
|
2046
2052
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2047
2053
|
const parser = createXmlParser();
|
|
2048
|
-
const doc = parser.parseFromString(
|
|
2054
|
+
const doc = parser.parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2049
2055
|
if (!doc.documentElement) return;
|
|
2050
2056
|
const getText = (tagNames) => {
|
|
2051
2057
|
for (const tag of tagNames) {
|
|
@@ -2070,7 +2076,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2070
2076
|
|
|
2071
2077
|
// src/hwpx/parser.ts
|
|
2072
2078
|
async function parseHwpxDocument(buffer, options) {
|
|
2073
|
-
|
|
2079
|
+
_chunkVHXUD3PWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2074
2080
|
let zip;
|
|
2075
2081
|
try {
|
|
2076
2082
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2079,7 +2085,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2079
2085
|
}
|
|
2080
2086
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2081
2087
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2082
|
-
throw new (0,
|
|
2088
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2083
2089
|
}
|
|
2084
2090
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2085
2091
|
if (manifestFile) {
|
|
@@ -2091,7 +2097,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2091
2097
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2092
2098
|
}
|
|
2093
2099
|
}
|
|
2094
|
-
throw new (0,
|
|
2100
|
+
throw new (0, _chunkVHXUD3PWcjs.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.");
|
|
2095
2101
|
}
|
|
2096
2102
|
}
|
|
2097
2103
|
const decompressed = { total: 0 };
|
|
@@ -2100,7 +2106,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2100
2106
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2101
2107
|
const warnings = [];
|
|
2102
2108
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2103
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2109
|
+
if (sectionPaths.length === 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2104
2110
|
metadata.pageCount = sectionPaths.length;
|
|
2105
2111
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2106
2112
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2114,12 +2120,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2114
2120
|
try {
|
|
2115
2121
|
const xml = await file.async("text");
|
|
2116
2122
|
decompressed.total += xml.length * 2;
|
|
2117
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2123
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2118
2124
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2119
2125
|
parsedSections++;
|
|
2120
2126
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2121
2127
|
} catch (secErr) {
|
|
2122
|
-
if (secErr instanceof
|
|
2128
|
+
if (secErr instanceof _chunkVHXUD3PWcjs.KordocError) throw secErr;
|
|
2123
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" });
|
|
2124
2130
|
}
|
|
2125
2131
|
}
|
|
@@ -2127,7 +2133,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2127
2133
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2128
2134
|
detectHwpxHeadings(blocks, styleMap);
|
|
2129
2135
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2130
|
-
const markdown =
|
|
2136
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2131
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 };
|
|
2132
2138
|
}
|
|
2133
2139
|
|
|
@@ -2194,7 +2200,7 @@ function decompressStream(data) {
|
|
|
2194
2200
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2195
2201
|
}
|
|
2196
2202
|
function parseFileHeader(data) {
|
|
2197
|
-
if (data.length < 40) throw new (0,
|
|
2203
|
+
if (data.length < 40) throw new (0, _chunkVHXUD3PWcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2198
2204
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2199
2205
|
return {
|
|
2200
2206
|
signature: sig,
|
|
@@ -3728,7 +3734,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3728
3734
|
lenientCfb = parseLenientCfb(buffer);
|
|
3729
3735
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3730
3736
|
} catch (e21) {
|
|
3731
|
-
throw new (0,
|
|
3737
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3732
3738
|
}
|
|
3733
3739
|
}
|
|
3734
3740
|
const findStream = (path) => {
|
|
@@ -3739,11 +3745,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3739
3745
|
return lenientCfb.findStream(path);
|
|
3740
3746
|
};
|
|
3741
3747
|
const headerData = findStream("/FileHeader");
|
|
3742
|
-
if (!headerData) throw new (0,
|
|
3748
|
+
if (!headerData) throw new (0, _chunkVHXUD3PWcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3743
3749
|
const header = parseFileHeader(headerData);
|
|
3744
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3745
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3746
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3750
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkVHXUD3PWcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3751
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3752
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkVHXUD3PWcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3747
3753
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3748
3754
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3749
3755
|
const metadata = {
|
|
@@ -3752,7 +3758,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3752
3758
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3753
3759
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3754
3760
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3755
|
-
if (sections.length === 0) throw new (0,
|
|
3761
|
+
if (sections.length === 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3756
3762
|
metadata.pageCount = sections.length;
|
|
3757
3763
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3758
3764
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3766,25 +3772,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3766
3772
|
const sectionData = sections[si];
|
|
3767
3773
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3768
3774
|
totalDecompressed += data.length;
|
|
3769
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3775
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3770
3776
|
const records = readRecords(data);
|
|
3771
3777
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3772
3778
|
bodyBlocks.push(...sectionBlocks);
|
|
3773
3779
|
parsedSections++;
|
|
3774
3780
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3775
3781
|
} catch (secErr) {
|
|
3776
|
-
if (secErr instanceof
|
|
3782
|
+
if (secErr instanceof _chunkVHXUD3PWcjs.KordocError) throw secErr;
|
|
3777
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" });
|
|
3778
3784
|
}
|
|
3779
3785
|
}
|
|
3780
3786
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3781
3787
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3782
|
-
const flatBlocks =
|
|
3788
|
+
const flatBlocks = _chunkVHXUD3PWcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3783
3789
|
if (docInfo) {
|
|
3784
3790
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3785
3791
|
}
|
|
3786
3792
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3787
|
-
const markdown =
|
|
3793
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3788
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 };
|
|
3789
3795
|
}
|
|
3790
3796
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3844,9 +3850,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3844
3850
|
let level = 0;
|
|
3845
3851
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3846
3852
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3847
|
-
if (ratio >=
|
|
3848
|
-
else if (ratio >=
|
|
3849
|
-
else if (ratio >=
|
|
3853
|
+
if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H1) level = 1;
|
|
3854
|
+
else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H2) level = 2;
|
|
3855
|
+
else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H3) level = 3;
|
|
3850
3856
|
}
|
|
3851
3857
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3852
3858
|
if (level === 0) level = 2;
|
|
@@ -3931,7 +3937,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3931
3937
|
if (!raw) break;
|
|
3932
3938
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3933
3939
|
totalDecompressed += content.length;
|
|
3934
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3940
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3935
3941
|
sections.push({ idx: i, content });
|
|
3936
3942
|
}
|
|
3937
3943
|
if (sections.length === 0) {
|
|
@@ -3943,7 +3949,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3943
3949
|
if (raw) {
|
|
3944
3950
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3945
3951
|
totalDecompressed += content.length;
|
|
3946
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3952
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3947
3953
|
sections.push({ idx, content });
|
|
3948
3954
|
}
|
|
3949
3955
|
}
|
|
@@ -3960,7 +3966,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3960
3966
|
try {
|
|
3961
3967
|
const content = decryptViewText(raw, compressed);
|
|
3962
3968
|
totalDecompressed += content.length;
|
|
3963
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3969
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3964
3970
|
sections.push({ idx: i, content });
|
|
3965
3971
|
} catch (e26) {
|
|
3966
3972
|
break;
|
|
@@ -4063,7 +4069,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4063
4069
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4064
4070
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
4065
4071
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4066
|
-
const href =
|
|
4072
|
+
const href = _chunkVHXUD3PWcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4067
4073
|
if (!href) continue;
|
|
4068
4074
|
const anchor = text.slice(r.start, r.end);
|
|
4069
4075
|
if (!anchor.trim()) continue;
|
|
@@ -4296,8 +4302,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4296
4302
|
let tableIdx = -1;
|
|
4297
4303
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4298
4304
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4299
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4300
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4305
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkVHXUD3PWcjs.MAX_ROWS);
|
|
4306
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkVHXUD3PWcjs.MAX_COLS);
|
|
4301
4307
|
tableIdx = i2;
|
|
4302
4308
|
break;
|
|
4303
4309
|
}
|
|
@@ -4346,7 +4352,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4346
4352
|
return table2;
|
|
4347
4353
|
}
|
|
4348
4354
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4349
|
-
const table =
|
|
4355
|
+
const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
|
|
4350
4356
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4351
4357
|
return table.rows > 0 ? table : null;
|
|
4352
4358
|
}
|
|
@@ -4363,8 +4369,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4363
4369
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4364
4370
|
const cs = rec.data.readUInt16LE(12);
|
|
4365
4371
|
const rs = rec.data.readUInt16LE(14);
|
|
4366
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4367
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4372
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkVHXUD3PWcjs.MAX_COLS);
|
|
4373
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkVHXUD3PWcjs.MAX_ROWS);
|
|
4368
4374
|
}
|
|
4369
4375
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4370
4376
|
const parts = [];
|
|
@@ -4374,7 +4380,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4374
4380
|
parts.push(``);
|
|
4375
4381
|
hasStructure = true;
|
|
4376
4382
|
} else if (b.type === "table" && b.table) {
|
|
4377
|
-
const flat =
|
|
4383
|
+
const flat = _chunkVHXUD3PWcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4378
4384
|
if (flat) parts.push(flat);
|
|
4379
4385
|
hasStructure = true;
|
|
4380
4386
|
} else if (b.text) {
|
|
@@ -16811,7 +16817,7 @@ function getTextContent(el) {
|
|
|
16811
16817
|
return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
|
|
16812
16818
|
}
|
|
16813
16819
|
function parseXml(text) {
|
|
16814
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16820
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16815
16821
|
}
|
|
16816
16822
|
function parseSharedStrings(xml) {
|
|
16817
16823
|
const doc = parseXml(xml);
|
|
@@ -16955,7 +16961,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16955
16961
|
cellRows.push(row);
|
|
16956
16962
|
}
|
|
16957
16963
|
if (cellRows.length > 0) {
|
|
16958
|
-
const table =
|
|
16964
|
+
const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
|
|
16959
16965
|
if (table.rows > 0) {
|
|
16960
16966
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16961
16967
|
}
|
|
@@ -16963,12 +16969,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16963
16969
|
return blocks;
|
|
16964
16970
|
}
|
|
16965
16971
|
async function parseXlsxDocument(buffer, options) {
|
|
16966
|
-
|
|
16972
|
+
_chunkVHXUD3PWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16967
16973
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16968
16974
|
const warnings = [];
|
|
16969
16975
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16970
16976
|
if (!workbookFile) {
|
|
16971
|
-
throw new (0,
|
|
16977
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16972
16978
|
}
|
|
16973
16979
|
let sharedStrings = [];
|
|
16974
16980
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16977,7 +16983,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16977
16983
|
}
|
|
16978
16984
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16979
16985
|
if (sheets.length === 0) {
|
|
16980
|
-
throw new (0,
|
|
16986
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16981
16987
|
}
|
|
16982
16988
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16983
16989
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17049,7 +17055,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17049
17055
|
} catch (e27) {
|
|
17050
17056
|
}
|
|
17051
17057
|
}
|
|
17052
|
-
const markdown =
|
|
17058
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17053
17059
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17054
17060
|
}
|
|
17055
17061
|
|
|
@@ -17456,11 +17462,11 @@ function processGlobals(records) {
|
|
|
17456
17462
|
let encrypted = false;
|
|
17457
17463
|
const firstBof = records[0];
|
|
17458
17464
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17459
|
-
throw new (0,
|
|
17465
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17460
17466
|
}
|
|
17461
17467
|
const bof = decodeBof(firstBof.data);
|
|
17462
17468
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17463
|
-
throw new (0,
|
|
17469
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17464
17470
|
}
|
|
17465
17471
|
let i = 1;
|
|
17466
17472
|
while (i < records.length) {
|
|
@@ -17575,7 +17581,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17575
17581
|
cellRows.push(row);
|
|
17576
17582
|
}
|
|
17577
17583
|
if (cellRows.length > 0) {
|
|
17578
|
-
const table =
|
|
17584
|
+
const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
|
|
17579
17585
|
if (table.rows > 0) {
|
|
17580
17586
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17581
17587
|
}
|
|
@@ -17588,21 +17594,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17588
17594
|
try {
|
|
17589
17595
|
cfb = parseLenientCfb(buf);
|
|
17590
17596
|
} catch (e) {
|
|
17591
|
-
throw new (0,
|
|
17597
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)(
|
|
17592
17598
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17593
17599
|
);
|
|
17594
17600
|
}
|
|
17595
17601
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17596
17602
|
if (!wb) {
|
|
17597
|
-
throw new (0,
|
|
17603
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17598
17604
|
}
|
|
17599
17605
|
const records = readRecords2(wb);
|
|
17600
17606
|
if (records.length === 0) {
|
|
17601
|
-
throw new (0,
|
|
17607
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17602
17608
|
}
|
|
17603
17609
|
const firstBof = decodeBof(records[0].data);
|
|
17604
17610
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17605
|
-
throw new (0,
|
|
17611
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)(
|
|
17606
17612
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17607
17613
|
);
|
|
17608
17614
|
}
|
|
@@ -17662,7 +17668,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17662
17668
|
pageCount: totalSheets
|
|
17663
17669
|
};
|
|
17664
17670
|
return {
|
|
17665
|
-
markdown:
|
|
17671
|
+
markdown: _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17666
17672
|
blocks: allBlocks,
|
|
17667
17673
|
metadata,
|
|
17668
17674
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18100,7 +18106,7 @@ function getAttr(el, localName2) {
|
|
|
18100
18106
|
return null;
|
|
18101
18107
|
}
|
|
18102
18108
|
function parseXml2(text) {
|
|
18103
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18109
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18104
18110
|
}
|
|
18105
18111
|
function parseStyles(xml) {
|
|
18106
18112
|
const doc = parseXml2(xml);
|
|
@@ -18361,7 +18367,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
|
18361
18367
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18362
18368
|
})
|
|
18363
18369
|
);
|
|
18364
|
-
const table =
|
|
18370
|
+
const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
|
|
18365
18371
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18366
18372
|
return { type: "table", table };
|
|
18367
18373
|
}
|
|
@@ -18428,12 +18434,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18428
18434
|
return { blocks, images };
|
|
18429
18435
|
}
|
|
18430
18436
|
async function parseDocxDocument(buffer, options) {
|
|
18431
|
-
|
|
18437
|
+
_chunkVHXUD3PWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18432
18438
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18433
18439
|
const warnings = [];
|
|
18434
18440
|
const docFile = zip.file("word/document.xml");
|
|
18435
18441
|
if (!docFile) {
|
|
18436
|
-
throw new (0,
|
|
18442
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18437
18443
|
}
|
|
18438
18444
|
let rels = /* @__PURE__ */ new Map();
|
|
18439
18445
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18480,7 +18486,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18480
18486
|
const doc = parseXml2(docXml);
|
|
18481
18487
|
const body = findElements(doc, "body");
|
|
18482
18488
|
if (body.length === 0) {
|
|
18483
|
-
throw new (0,
|
|
18489
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18484
18490
|
}
|
|
18485
18491
|
const blocks = [];
|
|
18486
18492
|
const bodyEl = body[0];
|
|
@@ -18525,7 +18531,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18525
18531
|
}
|
|
18526
18532
|
}
|
|
18527
18533
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18528
|
-
const markdown =
|
|
18534
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18529
18535
|
return {
|
|
18530
18536
|
markdown,
|
|
18531
18537
|
blocks,
|
|
@@ -18548,7 +18554,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18548
18554
|
}
|
|
18549
18555
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18550
18556
|
const normalized = text.replace(/ /g, " ");
|
|
18551
|
-
const xml =
|
|
18557
|
+
const xml = _chunkVHXUD3PWcjs.stripDtd.call(void 0, normalized);
|
|
18552
18558
|
const warnings = [];
|
|
18553
18559
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18554
18560
|
onError: (_level, msg2) => {
|
|
@@ -18588,7 +18594,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18588
18594
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18589
18595
|
}
|
|
18590
18596
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18591
|
-
const markdown =
|
|
18597
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18592
18598
|
return {
|
|
18593
18599
|
markdown,
|
|
18594
18600
|
blocks,
|
|
@@ -18746,7 +18752,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18746
18752
|
const cellRows = grid.map(
|
|
18747
18753
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18748
18754
|
);
|
|
18749
|
-
const table =
|
|
18755
|
+
const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
|
|
18750
18756
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18751
18757
|
}
|
|
18752
18758
|
function extractCellText(cellEl) {
|
|
@@ -19935,19 +19941,19 @@ function parseCentralDirectory(buf) {
|
|
|
19935
19941
|
}
|
|
19936
19942
|
}
|
|
19937
19943
|
}
|
|
19938
|
-
if (eocdOffset < 0) throw new (0,
|
|
19944
|
+
if (eocdOffset < 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19939
19945
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19940
19946
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19941
19947
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19942
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19948
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19943
19949
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19944
|
-
throw new (0,
|
|
19950
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19945
19951
|
}
|
|
19946
19952
|
const decoder = new TextDecoder("utf-8");
|
|
19947
19953
|
const entries = [];
|
|
19948
19954
|
let pos = cdOffset;
|
|
19949
19955
|
for (let i = 0; i < totalEntries; i++) {
|
|
19950
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19956
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19951
19957
|
const flags = view.getUint16(pos + 8, true);
|
|
19952
19958
|
const method = view.getUint16(pos + 10, true);
|
|
19953
19959
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19958,7 +19964,7 @@ function parseCentralDirectory(buf) {
|
|
|
19958
19964
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19959
19965
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19960
19966
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19961
|
-
throw new (0,
|
|
19967
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19962
19968
|
}
|
|
19963
19969
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19964
19970
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19987,7 +19993,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19987
19993
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19988
19994
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19989
19995
|
for (const name of replacements.keys()) {
|
|
19990
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19996
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkVHXUD3PWcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19991
19997
|
}
|
|
19992
19998
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19993
19999
|
const segments = [];
|
|
@@ -20005,7 +20011,7 @@ function patchZipEntries(original, replacements) {
|
|
|
20005
20011
|
offset += seg.length;
|
|
20006
20012
|
continue;
|
|
20007
20013
|
}
|
|
20008
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20014
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20009
20015
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20010
20016
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20011
20017
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20060,7 +20066,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20060
20066
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20061
20067
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20062
20068
|
if (sectionPaths.length === 0) {
|
|
20063
|
-
throw new (0,
|
|
20069
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20064
20070
|
}
|
|
20065
20071
|
const normalizedValues = normalizeValues(values);
|
|
20066
20072
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20773,6 +20779,16 @@ function buildPrvText(blocks) {
|
|
|
20773
20779
|
}
|
|
20774
20780
|
return lines.join("\n").slice(0, 1024);
|
|
20775
20781
|
}
|
|
20782
|
+
function findMathDelim(s, from) {
|
|
20783
|
+
let i = s.indexOf("$$", from);
|
|
20784
|
+
while (i > 0) {
|
|
20785
|
+
let backslashes = 0;
|
|
20786
|
+
for (let j = i - 1; j >= 0 && s[j] === "\\"; j--) backslashes++;
|
|
20787
|
+
if (backslashes % 2 === 0) break;
|
|
20788
|
+
i = s.indexOf("$$", i + 1);
|
|
20789
|
+
}
|
|
20790
|
+
return i;
|
|
20791
|
+
}
|
|
20776
20792
|
function parseMarkdownToBlocks(md2) {
|
|
20777
20793
|
const lines = md2.split("\n");
|
|
20778
20794
|
const blocks = [];
|
|
@@ -20783,6 +20799,45 @@ function parseMarkdownToBlocks(md2) {
|
|
|
20783
20799
|
i++;
|
|
20784
20800
|
continue;
|
|
20785
20801
|
}
|
|
20802
|
+
const mathOpen = /^\s*\$\$/.exec(line);
|
|
20803
|
+
if (mathOpen) {
|
|
20804
|
+
const afterOpen = line.slice(mathOpen[0].length);
|
|
20805
|
+
const closeSame = findMathDelim(afterOpen, 0);
|
|
20806
|
+
if (closeSame >= 0) {
|
|
20807
|
+
const inner = afterOpen.slice(0, closeSame).trim();
|
|
20808
|
+
const trailing2 = afterOpen.slice(closeSame + 2).trim();
|
|
20809
|
+
if (inner) blocks.push({ type: "equation", text: inner });
|
|
20810
|
+
if (trailing2) blocks.push({ type: "paragraph", text: trailing2 });
|
|
20811
|
+
i++;
|
|
20812
|
+
continue;
|
|
20813
|
+
}
|
|
20814
|
+
const mathLines = [];
|
|
20815
|
+
if (afterOpen.trim()) mathLines.push(afterOpen);
|
|
20816
|
+
let closed = false;
|
|
20817
|
+
let trailing = "";
|
|
20818
|
+
let j = i + 1;
|
|
20819
|
+
for (; j < lines.length; j++) {
|
|
20820
|
+
const l = lines[j];
|
|
20821
|
+
if (!l.trim() || /^\s*(`{3,}|~{3,})/.test(l)) break;
|
|
20822
|
+
const end = findMathDelim(l, 0);
|
|
20823
|
+
if (end >= 0) {
|
|
20824
|
+
const before = l.slice(0, end);
|
|
20825
|
+
if (before.trim()) mathLines.push(before);
|
|
20826
|
+
trailing = l.slice(end + 2).trim();
|
|
20827
|
+
closed = true;
|
|
20828
|
+
j++;
|
|
20829
|
+
break;
|
|
20830
|
+
}
|
|
20831
|
+
mathLines.push(l);
|
|
20832
|
+
}
|
|
20833
|
+
if (closed) {
|
|
20834
|
+
const text = mathLines.join("\n").trim();
|
|
20835
|
+
if (text) blocks.push({ type: "equation", text });
|
|
20836
|
+
if (trailing) blocks.push({ type: "paragraph", text: trailing });
|
|
20837
|
+
i = j;
|
|
20838
|
+
continue;
|
|
20839
|
+
}
|
|
20840
|
+
}
|
|
20786
20841
|
const fenceMatch = line.match(/^(`{3,}|~{3,})(.*)$/);
|
|
20787
20842
|
if (fenceMatch) {
|
|
20788
20843
|
const fence = fenceMatch[1];
|
|
@@ -21175,6 +21230,7 @@ function precomputeGongmunList(blocks, gongmun) {
|
|
|
21175
21230
|
i++;
|
|
21176
21231
|
continue;
|
|
21177
21232
|
}
|
|
21233
|
+
const passThrough = (t) => t === "table" || t === "html_table" || t === "equation";
|
|
21178
21234
|
const run = [];
|
|
21179
21235
|
while (i < blocks.length) {
|
|
21180
21236
|
const t = blocks[i].type;
|
|
@@ -21183,9 +21239,9 @@ function precomputeGongmunList(blocks, gongmun) {
|
|
|
21183
21239
|
i++;
|
|
21184
21240
|
continue;
|
|
21185
21241
|
}
|
|
21186
|
-
if (t
|
|
21242
|
+
if (passThrough(t)) {
|
|
21187
21243
|
let j = i + 1;
|
|
21188
|
-
while (j < blocks.length && (blocks[j].type
|
|
21244
|
+
while (j < blocks.length && passThrough(blocks[j].type)) j++;
|
|
21189
21245
|
if (j < blocks.length && blocks[j].type === "list_item") {
|
|
21190
21246
|
i = j;
|
|
21191
21247
|
continue;
|
|
@@ -21381,7 +21437,7 @@ function escapeGfm(text) {
|
|
|
21381
21437
|
}
|
|
21382
21438
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21383
21439
|
function sanitizeText(text) {
|
|
21384
|
-
let result =
|
|
21440
|
+
let result = _chunkVHXUD3PWcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21385
21441
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21386
21442
|
const tokens = result.split(" ");
|
|
21387
21443
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21711,6 +21767,280 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3) {
|
|
|
21711
21767
|
return `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="2" noShading="0"><hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${cellH * rowCnt}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trXmls.join("") + `</hp:tbl>`;
|
|
21712
21768
|
}
|
|
21713
21769
|
|
|
21770
|
+
// src/hwpx/equation-generate.ts
|
|
21771
|
+
var MAX_EQUATION_SOURCE = 1e4;
|
|
21772
|
+
var MAX_GROUP_DEPTH = 64;
|
|
21773
|
+
var COMMAND_MAP = {
|
|
21774
|
+
alpha: "alpha",
|
|
21775
|
+
beta: "beta",
|
|
21776
|
+
gamma: "gamma",
|
|
21777
|
+
delta: "delta",
|
|
21778
|
+
epsilon: "epsilon",
|
|
21779
|
+
zeta: "zeta",
|
|
21780
|
+
eta: "eta",
|
|
21781
|
+
theta: "theta",
|
|
21782
|
+
iota: "iota",
|
|
21783
|
+
kappa: "kappa",
|
|
21784
|
+
lambda: "lambda",
|
|
21785
|
+
mu: "mu",
|
|
21786
|
+
nu: "nu",
|
|
21787
|
+
xi: "xi",
|
|
21788
|
+
pi: "pi",
|
|
21789
|
+
rho: "rho",
|
|
21790
|
+
sigma: "sigma",
|
|
21791
|
+
tau: "tau",
|
|
21792
|
+
upsilon: "upsilon",
|
|
21793
|
+
phi: "phi",
|
|
21794
|
+
chi: "chi",
|
|
21795
|
+
psi: "psi",
|
|
21796
|
+
omega: "omega",
|
|
21797
|
+
Gamma: "GAMMA",
|
|
21798
|
+
Delta: "DELTA",
|
|
21799
|
+
Theta: "THETA",
|
|
21800
|
+
Lambda: "LAMBDA",
|
|
21801
|
+
Xi: "XI",
|
|
21802
|
+
Pi: "PI",
|
|
21803
|
+
Sigma: "SIGMA",
|
|
21804
|
+
Upsilon: "UPSILON",
|
|
21805
|
+
Phi: "PHI",
|
|
21806
|
+
Psi: "PSI",
|
|
21807
|
+
Omega: "OMEGA",
|
|
21808
|
+
le: "LEQ",
|
|
21809
|
+
leq: "LEQ",
|
|
21810
|
+
ge: "GEQ",
|
|
21811
|
+
geq: "GEQ",
|
|
21812
|
+
ne: "!=",
|
|
21813
|
+
neq: "!=",
|
|
21814
|
+
pm: "+-",
|
|
21815
|
+
mp: "-+",
|
|
21816
|
+
times: "TIMES",
|
|
21817
|
+
cdot: "cdot",
|
|
21818
|
+
ast: "AST",
|
|
21819
|
+
circ: "CIRC",
|
|
21820
|
+
bullet: "BULLET",
|
|
21821
|
+
in: "IN",
|
|
21822
|
+
notin: "NOTIN",
|
|
21823
|
+
subset: "SUBSET",
|
|
21824
|
+
subseteq: "SUBSETEQ",
|
|
21825
|
+
supset: "SUPERSET",
|
|
21826
|
+
supseteq: "SUPSETEQ",
|
|
21827
|
+
cup: "CUP",
|
|
21828
|
+
cap: "SMALLINTER",
|
|
21829
|
+
emptyset: "EMPTYSET",
|
|
21830
|
+
forall: "FORALL",
|
|
21831
|
+
exists: "EXIST",
|
|
21832
|
+
infinity: "INF",
|
|
21833
|
+
infty: "INF",
|
|
21834
|
+
partial: "Partial",
|
|
21835
|
+
nabla: "NABLA",
|
|
21836
|
+
int: "int",
|
|
21837
|
+
iint: "dint",
|
|
21838
|
+
iiint: "tint",
|
|
21839
|
+
oint: "oint",
|
|
21840
|
+
sum: "sum",
|
|
21841
|
+
prod: "prod",
|
|
21842
|
+
lim: "lim",
|
|
21843
|
+
to: "->",
|
|
21844
|
+
rightarrow: "->",
|
|
21845
|
+
leftarrow: "larrow",
|
|
21846
|
+
leftrightarrow: "<->",
|
|
21847
|
+
Rightarrow: "RARROW",
|
|
21848
|
+
Leftarrow: "LARROW",
|
|
21849
|
+
Leftrightarrow: "LRARROW",
|
|
21850
|
+
cdots: "CDOTS",
|
|
21851
|
+
ldots: "LDOTS",
|
|
21852
|
+
vdots: "VDOTS",
|
|
21853
|
+
ddots: "DDOTS"
|
|
21854
|
+
};
|
|
21855
|
+
var ACCENT_COMMANDS = {
|
|
21856
|
+
bar: "bar",
|
|
21857
|
+
overline: "bar",
|
|
21858
|
+
vec: "vec",
|
|
21859
|
+
overrightarrow: "vec",
|
|
21860
|
+
hat: "hat",
|
|
21861
|
+
widehat: "hat",
|
|
21862
|
+
tilde: "tilde",
|
|
21863
|
+
widetilde: "tilde",
|
|
21864
|
+
dot: "dot",
|
|
21865
|
+
ddot: "ddot",
|
|
21866
|
+
underline: "under"
|
|
21867
|
+
};
|
|
21868
|
+
var RESERVED_WORDS = new Set(
|
|
21869
|
+
[...Object.keys(CONVERT_MAP), ...Object.keys(MIDDLE_CONVERT_MAP), "over", "root", "of"].filter((w) => /^[A-Za-z]+$/.test(w))
|
|
21870
|
+
);
|
|
21871
|
+
function skipSpaces(input, idx) {
|
|
21872
|
+
while (idx < input.length && /\s/.test(input[idx])) idx++;
|
|
21873
|
+
return idx;
|
|
21874
|
+
}
|
|
21875
|
+
function normalizeEqEdit(input) {
|
|
21876
|
+
return input.replace(/\s+/g, " ").trim();
|
|
21877
|
+
}
|
|
21878
|
+
function stripMathDelimiters(input) {
|
|
21879
|
+
let s = input.trim();
|
|
21880
|
+
if (s.startsWith("$$") && s.endsWith("$$")) s = s.slice(2, -2).trim();
|
|
21881
|
+
if (s.startsWith("\\[") && s.endsWith("\\]")) s = s.slice(2, -2).trim();
|
|
21882
|
+
return s;
|
|
21883
|
+
}
|
|
21884
|
+
function readBalanced(input, idx, open, close) {
|
|
21885
|
+
let depth = 1;
|
|
21886
|
+
let cursor = idx + 1;
|
|
21887
|
+
while (cursor < input.length) {
|
|
21888
|
+
const ch = input[cursor];
|
|
21889
|
+
if (ch === "\\") {
|
|
21890
|
+
cursor += 2;
|
|
21891
|
+
continue;
|
|
21892
|
+
}
|
|
21893
|
+
if (ch === open) depth++;
|
|
21894
|
+
else if (ch === close) depth--;
|
|
21895
|
+
if (depth === 0) {
|
|
21896
|
+
return { value: input.slice(idx + 1, cursor), next: cursor + 1 };
|
|
21897
|
+
}
|
|
21898
|
+
cursor++;
|
|
21899
|
+
}
|
|
21900
|
+
return { value: input.slice(idx + 1), next: input.length };
|
|
21901
|
+
}
|
|
21902
|
+
function readGroupOrToken(input, idx, depth) {
|
|
21903
|
+
const start = skipSpaces(input, idx);
|
|
21904
|
+
if (depth > MAX_GROUP_DEPTH) return { value: input.slice(start), next: input.length };
|
|
21905
|
+
if (input[start] === "{") {
|
|
21906
|
+
const group = readBalanced(input, start, "{", "}");
|
|
21907
|
+
return { value: convertLatexFragment(group.value, depth + 1), next: group.next };
|
|
21908
|
+
}
|
|
21909
|
+
if (input[start] === "\\") {
|
|
21910
|
+
const cmd = readCommand(input, start, depth + 1);
|
|
21911
|
+
return { value: cmd.value, next: cmd.next };
|
|
21912
|
+
}
|
|
21913
|
+
return { value: _nullishCoalesce(input[start], () => ( "")), next: Math.min(start + 1, input.length) };
|
|
21914
|
+
}
|
|
21915
|
+
function readCommandName(input, idx) {
|
|
21916
|
+
if (input[idx + 1] === "\\") return { value: "\\", next: idx + 2 };
|
|
21917
|
+
const match = /^[A-Za-z]+/.exec(input.slice(idx + 1));
|
|
21918
|
+
if (match) return { value: match[0], next: idx + 1 + match[0].length };
|
|
21919
|
+
return { value: _nullishCoalesce(input[idx + 1], () => ( "")), next: Math.min(idx + 2, input.length) };
|
|
21920
|
+
}
|
|
21921
|
+
function readCommand(input, idx, depth) {
|
|
21922
|
+
const name = readCommandName(input, idx);
|
|
21923
|
+
const command = name.value;
|
|
21924
|
+
if (command === "\\") return { value: "#", next: name.next };
|
|
21925
|
+
if (command === "frac") {
|
|
21926
|
+
const num = readGroupOrToken(input, name.next, depth);
|
|
21927
|
+
const den = readGroupOrToken(input, num.next, depth);
|
|
21928
|
+
return { value: `{${num.value}} over {${den.value}}`, next: den.next };
|
|
21929
|
+
}
|
|
21930
|
+
if (command === "sqrt") {
|
|
21931
|
+
let cursor = skipSpaces(input, name.next);
|
|
21932
|
+
let root = null;
|
|
21933
|
+
if (input[cursor] === "[") {
|
|
21934
|
+
const opt = readBalanced(input, cursor, "[", "]");
|
|
21935
|
+
root = { value: convertLatexFragment(opt.value, depth + 1), next: opt.next };
|
|
21936
|
+
cursor = opt.next;
|
|
21937
|
+
}
|
|
21938
|
+
const body = readGroupOrToken(input, cursor, depth);
|
|
21939
|
+
if (root) return { value: `root {${root.value}} of {${body.value}}`, next: body.next };
|
|
21940
|
+
return { value: `sqrt{${body.value}}`, next: body.next };
|
|
21941
|
+
}
|
|
21942
|
+
if (command === "begin") {
|
|
21943
|
+
const env = readGroupOrToken(input, name.next, depth);
|
|
21944
|
+
const endTag = `\\end{${env.value}}`;
|
|
21945
|
+
const endIdx = input.indexOf(endTag, env.next);
|
|
21946
|
+
if (endIdx === -1) return { value: env.value, next: env.next };
|
|
21947
|
+
const body = convertLatexFragment(input.slice(env.next, endIdx), depth + 1);
|
|
21948
|
+
if (env.value === "matrix" || env.value === "pmatrix" || env.value === "bmatrix") {
|
|
21949
|
+
return { value: `{${env.value}{${body}}}`, next: endIdx + endTag.length };
|
|
21950
|
+
}
|
|
21951
|
+
return { value: body, next: endIdx + endTag.length };
|
|
21952
|
+
}
|
|
21953
|
+
if (command === "left" || command === "right") {
|
|
21954
|
+
const kw = command === "left" ? "LEFT" : "RIGHT";
|
|
21955
|
+
const cursor = skipSpaces(input, name.next);
|
|
21956
|
+
let delimiter = _nullishCoalesce(input[cursor], () => ( ""));
|
|
21957
|
+
let next = delimiter ? cursor + 1 : cursor;
|
|
21958
|
+
if (delimiter === "\\") {
|
|
21959
|
+
const escaped = readCommandName(input, cursor);
|
|
21960
|
+
delimiter = escaped.value === "\\" ? "\\" : _nullishCoalesce(COMMAND_MAP[escaped.value], () => ( escaped.value));
|
|
21961
|
+
next = escaped.next;
|
|
21962
|
+
}
|
|
21963
|
+
return { value: delimiter ? `${kw} ${delimiter}` : kw, next };
|
|
21964
|
+
}
|
|
21965
|
+
if (command in ACCENT_COMMANDS) {
|
|
21966
|
+
const body = readGroupOrToken(input, name.next, depth);
|
|
21967
|
+
return { value: `${ACCENT_COMMANDS[command]}{${body.value}}`, next: body.next };
|
|
21968
|
+
}
|
|
21969
|
+
if (command === "mathrm" || command === "text") {
|
|
21970
|
+
const start = skipSpaces(input, name.next);
|
|
21971
|
+
if (input[start] === "{") {
|
|
21972
|
+
const group = readBalanced(input, start, "{", "}");
|
|
21973
|
+
return { value: `"${group.value}"`, next: group.next };
|
|
21974
|
+
}
|
|
21975
|
+
const tok = readGroupOrToken(input, start, depth);
|
|
21976
|
+
return { value: `"${tok.value}"`, next: tok.next };
|
|
21977
|
+
}
|
|
21978
|
+
return { value: _nullishCoalesce(COMMAND_MAP[command], () => ( command)), next: name.next };
|
|
21979
|
+
}
|
|
21980
|
+
function convertLatexFragment(input, depth) {
|
|
21981
|
+
if (depth > MAX_GROUP_DEPTH) return normalizeEqEdit(input);
|
|
21982
|
+
let out = "";
|
|
21983
|
+
let idx = 0;
|
|
21984
|
+
while (idx < input.length) {
|
|
21985
|
+
const ch = input[idx];
|
|
21986
|
+
if (ch === "\\") {
|
|
21987
|
+
const cmd = readCommand(input, idx, depth + 1);
|
|
21988
|
+
out += ` ${cmd.value} `;
|
|
21989
|
+
idx = cmd.next;
|
|
21990
|
+
continue;
|
|
21991
|
+
}
|
|
21992
|
+
if (ch === "{") {
|
|
21993
|
+
const group = readBalanced(input, idx, "{", "}");
|
|
21994
|
+
out += `{${convertLatexFragment(group.value, depth + 1)}}`;
|
|
21995
|
+
idx = group.next;
|
|
21996
|
+
continue;
|
|
21997
|
+
}
|
|
21998
|
+
if (ch === "_" || ch === "^") {
|
|
21999
|
+
const script = readGroupOrToken(input, idx + 1, depth);
|
|
22000
|
+
out += ` ${ch}{${script.value}}`;
|
|
22001
|
+
idx = script.next;
|
|
22002
|
+
continue;
|
|
22003
|
+
}
|
|
22004
|
+
if (ch === "&") {
|
|
22005
|
+
out += " & ";
|
|
22006
|
+
idx++;
|
|
22007
|
+
continue;
|
|
22008
|
+
}
|
|
22009
|
+
out += ch;
|
|
22010
|
+
idx++;
|
|
22011
|
+
}
|
|
22012
|
+
return normalizeEqEdit(out);
|
|
22013
|
+
}
|
|
22014
|
+
function quoteReservedKeywords(latex) {
|
|
22015
|
+
return latex.replace(/([_^])\s*\{\s*([A-Za-z]+)\s*\}/g, (match, op, word) => RESERVED_WORDS.has(word) ? `${op}{"${word}"}` : match);
|
|
22016
|
+
}
|
|
22017
|
+
function latexLikeToEqEdit(input) {
|
|
22018
|
+
const src = stripMathDelimiters(input);
|
|
22019
|
+
if (src.length > MAX_EQUATION_SOURCE) return normalizeEqEdit(src);
|
|
22020
|
+
return convertLatexFragment(quoteReservedKeywords(src), 0);
|
|
22021
|
+
}
|
|
22022
|
+
function estimateEquationMetrics(script) {
|
|
22023
|
+
const cleaned = script.replace(/[{}\\^_]/g, "").replace(/\s+/g, " ").trim();
|
|
22024
|
+
const width = Math.min(Math.max(cleaned.length, 5) * 700 + 2e3, 4e4);
|
|
22025
|
+
const rowCount = Math.max(1, (_nullishCoalesce(script.match(/#/g), () => ( []))).length + 1);
|
|
22026
|
+
if (/\bmatrix\b|#/.test(script)) {
|
|
22027
|
+
if (rowCount >= 4) return { width, height: 5500, baseline: 55 };
|
|
22028
|
+
if (rowCount === 3) return { width, height: 4500, baseline: 60 };
|
|
22029
|
+
return { width, height: 3260, baseline: 63 };
|
|
22030
|
+
}
|
|
22031
|
+
if (/\bover\b|\broot\b|\bsqrt\b/.test(script)) return { width, height: 3010, baseline: 69 };
|
|
22032
|
+
return { width, height: 1450, baseline: 71 };
|
|
22033
|
+
}
|
|
22034
|
+
function generateEquationXml(script, zOrder = 0) {
|
|
22035
|
+
const { width, height, baseline } = estimateEquationMetrics(script);
|
|
22036
|
+
const eqId = 2000000001 + zOrder;
|
|
22037
|
+
return `<hp:equation id="${eqId}" zOrder="${zOrder}" numberingType="EQUATION" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" version="Equation Version 60" baseLine="${baseline}" textColor="#000000" baseUnit="1200" lineMode="CHAR" font="HYhwpEQ"><hp:sz width="${width}" widthRelTo="ABSOLUTE" height="${height}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="56" right="56" top="0" bottom="0"/><hp:shapeComment>\uC218\uC2DD\uC785\uB2C8\uB2E4.</hp:shapeComment><hp:script>${escapeXml(script)}</hp:script></hp:equation>`;
|
|
22038
|
+
}
|
|
22039
|
+
function generateEquationParagraph(input, zOrder = 0) {
|
|
22040
|
+
const script = latexLikeToEqEdit(input);
|
|
22041
|
+
return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${generateEquationXml(script, zOrder)}</hp:run></hp:p>`;
|
|
22042
|
+
}
|
|
22043
|
+
|
|
21714
22044
|
// src/hwpx/gen-section.ts
|
|
21715
22045
|
function generateSecPr(gongmun) {
|
|
21716
22046
|
const m = gongmun ? {
|
|
@@ -21758,6 +22088,15 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21758
22088
|
xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
|
|
21759
22089
|
break;
|
|
21760
22090
|
}
|
|
22091
|
+
case "equation": {
|
|
22092
|
+
if (isFirst) {
|
|
22093
|
+
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
|
|
22094
|
+
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
22095
|
+
isFirst = false;
|
|
22096
|
+
}
|
|
22097
|
+
xml = generateEquationParagraph(block.text || "", blockIdx);
|
|
22098
|
+
break;
|
|
22099
|
+
}
|
|
21761
22100
|
case "blockquote":
|
|
21762
22101
|
xml = generateParagraph(
|
|
21763
22102
|
block.text || "",
|
|
@@ -22603,7 +22942,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
22603
22942
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
22604
22943
|
if (paths.length > 0) return paths;
|
|
22605
22944
|
}
|
|
22606
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
22945
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
|
|
22607
22946
|
}
|
|
22608
22947
|
function sectionPathsFromManifest(xml) {
|
|
22609
22948
|
const attr = (tag, name) => {
|
|
@@ -22613,7 +22952,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22613
22952
|
const idToHref = /* @__PURE__ */ new Map();
|
|
22614
22953
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
22615
22954
|
const id = attr(m[1], "id");
|
|
22616
|
-
const href =
|
|
22955
|
+
const href = _chunkVHXUD3PWcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
22617
22956
|
if (id && href) idToHref.set(id, href);
|
|
22618
22957
|
}
|
|
22619
22958
|
const ordered = [];
|
|
@@ -22622,7 +22961,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22622
22961
|
if (href) ordered.push(href);
|
|
22623
22962
|
}
|
|
22624
22963
|
if (ordered.length > 0) return ordered;
|
|
22625
|
-
return Array.from(idToHref.values()).sort(
|
|
22964
|
+
return Array.from(idToHref.values()).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
|
|
22626
22965
|
}
|
|
22627
22966
|
|
|
22628
22967
|
// src/roundtrip/patcher.ts
|
|
@@ -22733,9 +23072,9 @@ function buildOrigUnits(blocks) {
|
|
|
22733
23072
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
22734
23073
|
const next = blocks[i + 1];
|
|
22735
23074
|
if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
22736
|
-
chunk =
|
|
23075
|
+
chunk = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
22737
23076
|
} else {
|
|
22738
|
-
chunk =
|
|
23077
|
+
chunk = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, [block]);
|
|
22739
23078
|
}
|
|
22740
23079
|
if (chunk) {
|
|
22741
23080
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -24433,13 +24772,13 @@ async function htmlToPdf(html, options) {
|
|
|
24433
24772
|
try {
|
|
24434
24773
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
24435
24774
|
} catch (e30) {
|
|
24436
|
-
throw new (0,
|
|
24775
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)(
|
|
24437
24776
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
24438
24777
|
);
|
|
24439
24778
|
}
|
|
24440
24779
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
24441
24780
|
if (!executablePath) {
|
|
24442
|
-
throw new (0,
|
|
24781
|
+
throw new (0, _chunkVHXUD3PWcjs.KordocError)(
|
|
24443
24782
|
"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."
|
|
24444
24783
|
);
|
|
24445
24784
|
}
|
|
@@ -24498,7 +24837,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
24498
24837
|
return htmlToPdf(html, options);
|
|
24499
24838
|
}
|
|
24500
24839
|
async function blocksToPdf(blocks, options) {
|
|
24501
|
-
const markdown =
|
|
24840
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
|
|
24502
24841
|
return markdownToPdf(markdown, options);
|
|
24503
24842
|
}
|
|
24504
24843
|
|
|
@@ -24509,13 +24848,13 @@ async function parse(input, options) {
|
|
|
24509
24848
|
if (typeof input === "string") {
|
|
24510
24849
|
try {
|
|
24511
24850
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24512
|
-
buffer =
|
|
24851
|
+
buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, buf);
|
|
24513
24852
|
} catch (err) {
|
|
24514
24853
|
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}`;
|
|
24515
24854
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
24516
24855
|
}
|
|
24517
24856
|
} else if (Buffer.isBuffer(input)) {
|
|
24518
|
-
buffer =
|
|
24857
|
+
buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, input);
|
|
24519
24858
|
} else {
|
|
24520
24859
|
buffer = input;
|
|
24521
24860
|
}
|
|
@@ -24550,7 +24889,7 @@ async function parseHwp3(buffer, options) {
|
|
|
24550
24889
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
24551
24890
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
24552
24891
|
} catch (err) {
|
|
24553
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24892
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24554
24893
|
}
|
|
24555
24894
|
}
|
|
24556
24895
|
async function parseHwpx(buffer, options) {
|
|
@@ -24558,7 +24897,7 @@ async function parseHwpx(buffer, options) {
|
|
|
24558
24897
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
24559
24898
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _277 => _277.length]) ? images : void 0 };
|
|
24560
24899
|
} catch (err) {
|
|
24561
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24900
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24562
24901
|
}
|
|
24563
24902
|
}
|
|
24564
24903
|
async function parseHwp(buffer, options) {
|
|
@@ -24583,13 +24922,13 @@ async function parseHwp(buffer, options) {
|
|
|
24583
24922
|
}
|
|
24584
24923
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _279 => _279.length]) ? images : void 0 };
|
|
24585
24924
|
} catch (err) {
|
|
24586
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24925
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24587
24926
|
}
|
|
24588
24927
|
}
|
|
24589
24928
|
async function parsePdf(buffer, options) {
|
|
24590
24929
|
let parsePdfDocument;
|
|
24591
24930
|
try {
|
|
24592
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
24931
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-N4G5KQBE.cjs")));
|
|
24593
24932
|
parsePdfDocument = mod.parsePdfDocument;
|
|
24594
24933
|
} catch (e32) {
|
|
24595
24934
|
return {
|
|
@@ -24604,7 +24943,7 @@ async function parsePdf(buffer, options) {
|
|
|
24604
24943
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
24605
24944
|
} catch (err) {
|
|
24606
24945
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
24607
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24946
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err), isImageBased };
|
|
24608
24947
|
}
|
|
24609
24948
|
}
|
|
24610
24949
|
async function parseXlsx(buffer, options) {
|
|
@@ -24612,7 +24951,7 @@ async function parseXlsx(buffer, options) {
|
|
|
24612
24951
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
24613
24952
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
24614
24953
|
} catch (err) {
|
|
24615
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24954
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24616
24955
|
}
|
|
24617
24956
|
}
|
|
24618
24957
|
async function parseXls(buffer, options) {
|
|
@@ -24620,7 +24959,7 @@ async function parseXls(buffer, options) {
|
|
|
24620
24959
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
24621
24960
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
24622
24961
|
} catch (err) {
|
|
24623
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24962
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24624
24963
|
}
|
|
24625
24964
|
}
|
|
24626
24965
|
async function parseDocx(buffer, options) {
|
|
@@ -24628,7 +24967,7 @@ async function parseDocx(buffer, options) {
|
|
|
24628
24967
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
24629
24968
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _280 => _280.length]) ? images : void 0 };
|
|
24630
24969
|
} catch (err) {
|
|
24631
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24970
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24632
24971
|
}
|
|
24633
24972
|
}
|
|
24634
24973
|
async function parseHwpml(buffer, options) {
|
|
@@ -24636,16 +24975,16 @@ async function parseHwpml(buffer, options) {
|
|
|
24636
24975
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
24637
24976
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
24638
24977
|
} catch (err) {
|
|
24639
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24978
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
|
|
24640
24979
|
}
|
|
24641
24980
|
}
|
|
24642
24981
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
24643
24982
|
let buffer;
|
|
24644
24983
|
if (typeof input === "string") {
|
|
24645
24984
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24646
|
-
buffer =
|
|
24985
|
+
buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, buf);
|
|
24647
24986
|
} else if (Buffer.isBuffer(input)) {
|
|
24648
|
-
buffer =
|
|
24987
|
+
buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, input);
|
|
24649
24988
|
} else {
|
|
24650
24989
|
buffer = input;
|
|
24651
24990
|
}
|
|
@@ -24671,7 +25010,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24671
25010
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
24672
25011
|
}
|
|
24673
25012
|
const fill = fillFormFields(parsed.blocks, values);
|
|
24674
|
-
const markdown =
|
|
25013
|
+
const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
24675
25014
|
if (outputFormat === "hwpx") {
|
|
24676
25015
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
24677
25016
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -24729,5 +25068,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24729
25068
|
|
|
24730
25069
|
|
|
24731
25070
|
|
|
24732
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
25071
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkVHXUD3PWcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkVHXUD3PWcjs.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.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord;
|
|
24733
25072
|
//# sourceMappingURL=index.cjs.map
|