kordoc 3.8.2 → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/{-FEHSMPVO.js → -F5IXBLQQ.js} +3 -3
- package/dist/{chunk-553VTUVP.js → chunk-7J73IGMK.js} +2 -2
- package/dist/{chunk-DP37KF2X.js → chunk-B27QMVL7.js} +39 -4
- package/dist/chunk-B27QMVL7.js.map +1 -0
- package/dist/{chunk-JHZUFBUV.js → chunk-KIWKBRCJ.js} +2 -2
- package/dist/{chunk-YBPNKFJW.cjs → chunk-XL6O3VAY.cjs} +2 -2
- package/dist/{chunk-YBPNKFJW.cjs.map → chunk-XL6O3VAY.cjs.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +251 -216
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-KNQDRLZQ.js → parser-6GP535ZB.js} +153 -7
- package/dist/parser-6GP535ZB.js.map +1 -0
- package/dist/{parser-NR2TYGO3.js → parser-TM3AS25T.js} +153 -7
- package/dist/parser-TM3AS25T.js.map +1 -0
- package/dist/{parser-NS4ZPD7B.cjs → parser-WWKYMRGJ.cjs} +177 -31
- package/dist/parser-WWKYMRGJ.cjs.map +1 -0
- package/dist/{watch-XCWADLPU.js → watch-HETTZ7BO.js} +3 -3
- package/package.json +2 -1
- package/dist/chunk-DP37KF2X.js.map +0 -1
- package/dist/parser-KNQDRLZQ.js.map +0 -1
- package/dist/parser-NR2TYGO3.js.map +0 -1
- package/dist/parser-NS4ZPD7B.cjs.map +0 -1
- /package/dist/{-FEHSMPVO.js.map → -F5IXBLQQ.js.map} +0 -0
- /package/dist/{chunk-553VTUVP.js.map → chunk-7J73IGMK.js.map} +0 -0
- /package/dist/{chunk-JHZUFBUV.js.map → chunk-KIWKBRCJ.js.map} +0 -0
- /package/dist/{watch-XCWADLPU.js.map → watch-HETTZ7BO.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkXL6O3VAYcjs = require('./chunk-XL6O3VAY.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, _chunkXL6O3VAYcjs.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, _chunkXL6O3VAYcjs.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(_chunkXL6O3VAYcjs.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 >= _chunkXL6O3VAYcjs.HEADING_RATIO_H1) level = 1;
|
|
619
|
+
else if (ratio >= _chunkXL6O3VAYcjs.HEADING_RATIO_H2) level = 2;
|
|
620
|
+
else if (ratio >= _chunkXL6O3VAYcjs.HEADING_RATIO_H3) level = 3;
|
|
621
621
|
}
|
|
622
622
|
const compactText = text.replace(/\s+/g, "");
|
|
623
623
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1165,7 +1165,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1165
1165
|
|
|
1166
1166
|
// src/hwpx/table-build.ts
|
|
1167
1167
|
function buildTableWithCellMeta(state) {
|
|
1168
|
-
const table =
|
|
1168
|
+
const table = _chunkXL6O3VAYcjs.buildTable.call(void 0, state.rows);
|
|
1169
1169
|
if (state.caption) table.caption = state.caption;
|
|
1170
1170
|
const anchors = [];
|
|
1171
1171
|
{
|
|
@@ -1235,7 +1235,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1235
1235
|
const cell = parentTable.cell;
|
|
1236
1236
|
(cell.blocks ??= []).push(block);
|
|
1237
1237
|
cell.hasStructure = true;
|
|
1238
|
-
let flat =
|
|
1238
|
+
let flat = _chunkXL6O3VAYcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1239
1239
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1240
1240
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1241
1241
|
} else {
|
|
@@ -1247,7 +1247,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1247
1247
|
// src/hwpx/section-walker.ts
|
|
1248
1248
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1249
1249
|
const parser = createXmlParser(warnings);
|
|
1250
|
-
const doc = parser.parseFromString(
|
|
1250
|
+
const doc = parser.parseFromString(_chunkXL6O3VAYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1251
1251
|
if (!doc.documentElement) return [];
|
|
1252
1252
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1253
1253
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1338,8 +1338,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1338
1338
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1339
1339
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1340
1340
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1341
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1342
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1341
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkXL6O3VAYcjs.MAX_COLS);
|
|
1342
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkXL6O3VAYcjs.MAX_ROWS);
|
|
1343
1343
|
}
|
|
1344
1344
|
break;
|
|
1345
1345
|
case "p": {
|
|
@@ -1561,7 +1561,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1561
1561
|
let url = (ch.textContent || "").trim();
|
|
1562
1562
|
if (!url) continue;
|
|
1563
1563
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1564
|
-
const safe =
|
|
1564
|
+
const safe = _chunkXL6O3VAYcjs.sanitizeHref.call(void 0, url);
|
|
1565
1565
|
if (safe) return safe;
|
|
1566
1566
|
}
|
|
1567
1567
|
return void 0;
|
|
@@ -1696,7 +1696,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1696
1696
|
case "hyperlink": {
|
|
1697
1697
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1698
1698
|
if (url) {
|
|
1699
|
-
const safe =
|
|
1699
|
+
const safe = _chunkXL6O3VAYcjs.sanitizeHref.call(void 0, url);
|
|
1700
1700
|
if (safe) href = safe;
|
|
1701
1701
|
}
|
|
1702
1702
|
walk(child);
|
|
@@ -1882,13 +1882,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1882
1882
|
}
|
|
1883
1883
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1884
1884
|
for (const path of allCandidates) {
|
|
1885
|
-
if (
|
|
1885
|
+
if (_chunkXL6O3VAYcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1886
1886
|
const file = zip.file(path);
|
|
1887
1887
|
if (!file) continue;
|
|
1888
1888
|
try {
|
|
1889
1889
|
const data = await file.async("uint8array");
|
|
1890
1890
|
decompressed.total += data.length;
|
|
1891
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1891
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1892
1892
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1893
1893
|
const mimeType = imageExtToMime(ext);
|
|
1894
1894
|
imageIndex++;
|
|
@@ -1897,7 +1897,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1897
1897
|
images.push(img);
|
|
1898
1898
|
break;
|
|
1899
1899
|
} catch (err) {
|
|
1900
|
-
if (err instanceof
|
|
1900
|
+
if (err instanceof _chunkXL6O3VAYcjs.KordocError) throw err;
|
|
1901
1901
|
}
|
|
1902
1902
|
}
|
|
1903
1903
|
if (!img) _optionalChain([warnings, 'optionalAccess', _41 => _41.push, 'call', _42 => _42({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -1959,7 +1959,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1959
1959
|
}
|
|
1960
1960
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1961
1961
|
const name = new TextDecoder().decode(nameBytes);
|
|
1962
|
-
if (
|
|
1962
|
+
if (_chunkXL6O3VAYcjs.isPathTraversal.call(void 0, name)) {
|
|
1963
1963
|
pos = fileStart + compSize;
|
|
1964
1964
|
continue;
|
|
1965
1965
|
}
|
|
@@ -1977,16 +1977,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1977
1977
|
continue;
|
|
1978
1978
|
}
|
|
1979
1979
|
totalDecompressed += content.length * 2;
|
|
1980
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1980
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1981
1981
|
sectionNum++;
|
|
1982
1982
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1983
1983
|
} catch (e13) {
|
|
1984
1984
|
continue;
|
|
1985
1985
|
}
|
|
1986
1986
|
}
|
|
1987
|
-
if (blocks.length === 0) throw new (0,
|
|
1987
|
+
if (blocks.length === 0) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1988
1988
|
applyPageText(blocks, shared);
|
|
1989
|
-
const markdown =
|
|
1989
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1990
1990
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1991
1991
|
}
|
|
1992
1992
|
async function resolveSectionPaths(zip) {
|
|
@@ -2000,18 +2000,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2000
2000
|
if (paths.length > 0) return paths;
|
|
2001
2001
|
}
|
|
2002
2002
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2003
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2003
|
+
return sectionFiles.map((f) => f.name).sort(_chunkXL6O3VAYcjs.compareSectionPaths);
|
|
2004
2004
|
}
|
|
2005
2005
|
function parseSectionPathsFromManifest(xml) {
|
|
2006
2006
|
const parser = createXmlParser();
|
|
2007
|
-
const doc = parser.parseFromString(
|
|
2007
|
+
const doc = parser.parseFromString(_chunkXL6O3VAYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2008
2008
|
const items = doc.getElementsByTagName("opf:item");
|
|
2009
2009
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2010
2010
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2011
2011
|
for (let i = 0; i < items.length; i++) {
|
|
2012
2012
|
const item = items[i];
|
|
2013
2013
|
const id = item.getAttribute("id") || "";
|
|
2014
|
-
const href =
|
|
2014
|
+
const href = _chunkXL6O3VAYcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2015
2015
|
if (id && href) idToHref.set(id, href);
|
|
2016
2016
|
}
|
|
2017
2017
|
if (spine.length > 0) {
|
|
@@ -2022,7 +2022,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
if (ordered.length > 0) return ordered;
|
|
2024
2024
|
}
|
|
2025
|
-
return Array.from(idToHref.values()).sort(
|
|
2025
|
+
return Array.from(idToHref.values()).sort(_chunkXL6O3VAYcjs.compareSectionPaths);
|
|
2026
2026
|
}
|
|
2027
2027
|
|
|
2028
2028
|
// src/hwpx/metadata.ts
|
|
@@ -2035,7 +2035,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2035
2035
|
const xml = await file.async("text");
|
|
2036
2036
|
if (decompressed) {
|
|
2037
2037
|
decompressed.total += xml.length * 2;
|
|
2038
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2038
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2039
2039
|
}
|
|
2040
2040
|
parseDublinCoreMetadata(xml, metadata);
|
|
2041
2041
|
if (metadata.title || metadata.author) return;
|
|
@@ -2045,7 +2045,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2047
2047
|
const parser = createXmlParser();
|
|
2048
|
-
const doc = parser.parseFromString(
|
|
2048
|
+
const doc = parser.parseFromString(_chunkXL6O3VAYcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2049
2049
|
if (!doc.documentElement) return;
|
|
2050
2050
|
const getText = (tagNames) => {
|
|
2051
2051
|
for (const tag of tagNames) {
|
|
@@ -2070,7 +2070,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2070
2070
|
|
|
2071
2071
|
// src/hwpx/parser.ts
|
|
2072
2072
|
async function parseHwpxDocument(buffer, options) {
|
|
2073
|
-
|
|
2073
|
+
_chunkXL6O3VAYcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2074
2074
|
let zip;
|
|
2075
2075
|
try {
|
|
2076
2076
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2079,7 +2079,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2079
2079
|
}
|
|
2080
2080
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2081
2081
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2082
|
-
throw new (0,
|
|
2082
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2083
2083
|
}
|
|
2084
2084
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2085
2085
|
if (manifestFile) {
|
|
@@ -2091,7 +2091,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2091
2091
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2092
2092
|
}
|
|
2093
2093
|
}
|
|
2094
|
-
throw new (0,
|
|
2094
|
+
throw new (0, _chunkXL6O3VAYcjs.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
2095
|
}
|
|
2096
2096
|
}
|
|
2097
2097
|
const decompressed = { total: 0 };
|
|
@@ -2100,7 +2100,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2100
2100
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2101
2101
|
const warnings = [];
|
|
2102
2102
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2103
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2103
|
+
if (sectionPaths.length === 0) throw new (0, _chunkXL6O3VAYcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2104
2104
|
metadata.pageCount = sectionPaths.length;
|
|
2105
2105
|
const pageFilter = _optionalChain([options, 'optionalAccess', _48 => _48.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2106
2106
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2114,12 +2114,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2114
2114
|
try {
|
|
2115
2115
|
const xml = await file.async("text");
|
|
2116
2116
|
decompressed.total += xml.length * 2;
|
|
2117
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2117
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2118
2118
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2119
2119
|
parsedSections++;
|
|
2120
2120
|
_optionalChain([options, 'optionalAccess', _49 => _49.onProgress, 'optionalCall', _50 => _50(parsedSections, totalTarget)]);
|
|
2121
2121
|
} catch (secErr) {
|
|
2122
|
-
if (secErr instanceof
|
|
2122
|
+
if (secErr instanceof _chunkXL6O3VAYcjs.KordocError) throw secErr;
|
|
2123
2123
|
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
2124
|
}
|
|
2125
2125
|
}
|
|
@@ -2127,7 +2127,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2127
2127
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2128
2128
|
detectHwpxHeadings(blocks, styleMap);
|
|
2129
2129
|
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 =
|
|
2130
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2131
2131
|
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
2132
|
}
|
|
2133
2133
|
|
|
@@ -2194,7 +2194,7 @@ function decompressStream(data) {
|
|
|
2194
2194
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2195
2195
|
}
|
|
2196
2196
|
function parseFileHeader(data) {
|
|
2197
|
-
if (data.length < 40) throw new (0,
|
|
2197
|
+
if (data.length < 40) throw new (0, _chunkXL6O3VAYcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2198
2198
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2199
2199
|
return {
|
|
2200
2200
|
signature: sig,
|
|
@@ -3728,7 +3728,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3728
3728
|
lenientCfb = parseLenientCfb(buffer);
|
|
3729
3729
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3730
3730
|
} catch (e21) {
|
|
3731
|
-
throw new (0,
|
|
3731
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3732
3732
|
}
|
|
3733
3733
|
}
|
|
3734
3734
|
const findStream = (path) => {
|
|
@@ -3739,11 +3739,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3739
3739
|
return lenientCfb.findStream(path);
|
|
3740
3740
|
};
|
|
3741
3741
|
const headerData = findStream("/FileHeader");
|
|
3742
|
-
if (!headerData) throw new (0,
|
|
3742
|
+
if (!headerData) throw new (0, _chunkXL6O3VAYcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3743
3743
|
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,
|
|
3744
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkXL6O3VAYcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3745
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3746
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkXL6O3VAYcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3747
3747
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3748
3748
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3749
3749
|
const metadata = {
|
|
@@ -3752,7 +3752,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3752
3752
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3753
3753
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3754
3754
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3755
|
-
if (sections.length === 0) throw new (0,
|
|
3755
|
+
if (sections.length === 0) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3756
3756
|
metadata.pageCount = sections.length;
|
|
3757
3757
|
const pageFilter = _optionalChain([options, 'optionalAccess', _54 => _54.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3758
3758
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3766,25 +3766,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3766
3766
|
const sectionData = sections[si];
|
|
3767
3767
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3768
3768
|
totalDecompressed += data.length;
|
|
3769
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3769
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3770
3770
|
const records = readRecords(data);
|
|
3771
3771
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3772
3772
|
bodyBlocks.push(...sectionBlocks);
|
|
3773
3773
|
parsedSections++;
|
|
3774
3774
|
_optionalChain([options, 'optionalAccess', _55 => _55.onProgress, 'optionalCall', _56 => _56(parsedSections, totalTarget)]);
|
|
3775
3775
|
} catch (secErr) {
|
|
3776
|
-
if (secErr instanceof
|
|
3776
|
+
if (secErr instanceof _chunkXL6O3VAYcjs.KordocError) throw secErr;
|
|
3777
3777
|
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
3778
|
}
|
|
3779
3779
|
}
|
|
3780
3780
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3781
3781
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3782
|
-
const flatBlocks =
|
|
3782
|
+
const flatBlocks = _chunkXL6O3VAYcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3783
3783
|
if (docInfo) {
|
|
3784
3784
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3785
3785
|
}
|
|
3786
3786
|
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 =
|
|
3787
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3788
3788
|
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
3789
|
}
|
|
3790
3790
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3844,9 +3844,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3844
3844
|
let level = 0;
|
|
3845
3845
|
if (_optionalChain([block, 'access', _61 => _61.style, 'optionalAccess', _62 => _62.fontSize]) && baseFontSize > 0) {
|
|
3846
3846
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3847
|
-
if (ratio >=
|
|
3848
|
-
else if (ratio >=
|
|
3849
|
-
else if (ratio >=
|
|
3847
|
+
if (ratio >= _chunkXL6O3VAYcjs.HEADING_RATIO_H1) level = 1;
|
|
3848
|
+
else if (ratio >= _chunkXL6O3VAYcjs.HEADING_RATIO_H2) level = 2;
|
|
3849
|
+
else if (ratio >= _chunkXL6O3VAYcjs.HEADING_RATIO_H3) level = 3;
|
|
3850
3850
|
}
|
|
3851
3851
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3852
3852
|
if (level === 0) level = 2;
|
|
@@ -3931,7 +3931,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3931
3931
|
if (!raw) break;
|
|
3932
3932
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3933
3933
|
totalDecompressed += content.length;
|
|
3934
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3934
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3935
3935
|
sections.push({ idx: i, content });
|
|
3936
3936
|
}
|
|
3937
3937
|
if (sections.length === 0) {
|
|
@@ -3943,7 +3943,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3943
3943
|
if (raw) {
|
|
3944
3944
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3945
3945
|
totalDecompressed += content.length;
|
|
3946
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3946
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3947
3947
|
sections.push({ idx, content });
|
|
3948
3948
|
}
|
|
3949
3949
|
}
|
|
@@ -3960,7 +3960,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3960
3960
|
try {
|
|
3961
3961
|
const content = decryptViewText(raw, compressed);
|
|
3962
3962
|
totalDecompressed += content.length;
|
|
3963
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3963
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3964
3964
|
sections.push({ idx: i, content });
|
|
3965
3965
|
} catch (e26) {
|
|
3966
3966
|
break;
|
|
@@ -4063,7 +4063,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4063
4063
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4064
4064
|
if (!_optionalChain([ctrl, 'optionalAccess', _69 => _69.href]) || r.end <= r.start) continue;
|
|
4065
4065
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4066
|
-
const href =
|
|
4066
|
+
const href = _chunkXL6O3VAYcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4067
4067
|
if (!href) continue;
|
|
4068
4068
|
const anchor = text.slice(r.start, r.end);
|
|
4069
4069
|
if (!anchor.trim()) continue;
|
|
@@ -4296,8 +4296,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4296
4296
|
let tableIdx = -1;
|
|
4297
4297
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4298
4298
|
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),
|
|
4299
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkXL6O3VAYcjs.MAX_ROWS);
|
|
4300
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkXL6O3VAYcjs.MAX_COLS);
|
|
4301
4301
|
tableIdx = i2;
|
|
4302
4302
|
break;
|
|
4303
4303
|
}
|
|
@@ -4346,7 +4346,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4346
4346
|
return table2;
|
|
4347
4347
|
}
|
|
4348
4348
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4349
|
-
const table =
|
|
4349
|
+
const table = _chunkXL6O3VAYcjs.buildTable.call(void 0, cellRows);
|
|
4350
4350
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4351
4351
|
return table.rows > 0 ? table : null;
|
|
4352
4352
|
}
|
|
@@ -4363,8 +4363,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4363
4363
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4364
4364
|
const cs = rec.data.readUInt16LE(12);
|
|
4365
4365
|
const rs = rec.data.readUInt16LE(14);
|
|
4366
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4367
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4366
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkXL6O3VAYcjs.MAX_COLS);
|
|
4367
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkXL6O3VAYcjs.MAX_ROWS);
|
|
4368
4368
|
}
|
|
4369
4369
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4370
4370
|
const parts = [];
|
|
@@ -4374,7 +4374,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4374
4374
|
parts.push(``);
|
|
4375
4375
|
hasStructure = true;
|
|
4376
4376
|
} else if (b.type === "table" && b.table) {
|
|
4377
|
-
const flat =
|
|
4377
|
+
const flat = _chunkXL6O3VAYcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4378
4378
|
if (flat) parts.push(flat);
|
|
4379
4379
|
hasStructure = true;
|
|
4380
4380
|
} else if (b.text) {
|
|
@@ -16802,13 +16802,16 @@ function getElements(parent, tagName) {
|
|
|
16802
16802
|
const nodes = parent.getElementsByTagName(tagName);
|
|
16803
16803
|
const result = [];
|
|
16804
16804
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
16805
|
+
if (result.length > 0) return result;
|
|
16806
|
+
const nsNodes = _optionalChain([parent, 'access', _82 => _82.getElementsByTagNameNS, 'optionalCall', _83 => _83("*", tagName)]);
|
|
16807
|
+
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
16805
16808
|
return result;
|
|
16806
16809
|
}
|
|
16807
16810
|
function getTextContent(el) {
|
|
16808
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
16811
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _84 => _84.textContent, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()]), () => ( ""));
|
|
16809
16812
|
}
|
|
16810
16813
|
function parseXml(text) {
|
|
16811
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16814
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkXL6O3VAYcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16812
16815
|
}
|
|
16813
16816
|
function parseSharedStrings(xml) {
|
|
16814
16817
|
const doc = parseXml(xml);
|
|
@@ -16945,14 +16948,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16945
16948
|
const merge = mergeMap.get(key);
|
|
16946
16949
|
row.push({
|
|
16947
16950
|
text,
|
|
16948
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16949
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16951
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _87 => _87.colSpan]), () => ( 1)),
|
|
16952
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _88 => _88.rowSpan]), () => ( 1))
|
|
16950
16953
|
});
|
|
16951
16954
|
}
|
|
16952
16955
|
cellRows.push(row);
|
|
16953
16956
|
}
|
|
16954
16957
|
if (cellRows.length > 0) {
|
|
16955
|
-
const table =
|
|
16958
|
+
const table = _chunkXL6O3VAYcjs.buildTable.call(void 0, cellRows);
|
|
16956
16959
|
if (table.rows > 0) {
|
|
16957
16960
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16958
16961
|
}
|
|
@@ -16960,12 +16963,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16960
16963
|
return blocks;
|
|
16961
16964
|
}
|
|
16962
16965
|
async function parseXlsxDocument(buffer, options) {
|
|
16963
|
-
|
|
16966
|
+
_chunkXL6O3VAYcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16964
16967
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16965
16968
|
const warnings = [];
|
|
16966
16969
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16967
16970
|
if (!workbookFile) {
|
|
16968
|
-
throw new (0,
|
|
16971
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16969
16972
|
}
|
|
16970
16973
|
let sharedStrings = [];
|
|
16971
16974
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16974,7 +16977,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16974
16977
|
}
|
|
16975
16978
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16976
16979
|
if (sheets.length === 0) {
|
|
16977
|
-
throw new (0,
|
|
16980
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16978
16981
|
}
|
|
16979
16982
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16980
16983
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16982,7 +16985,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16982
16985
|
relsMap = parseRels(await relsFile.async("text"));
|
|
16983
16986
|
}
|
|
16984
16987
|
let pageFilter = null;
|
|
16985
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
16988
|
+
if (_optionalChain([options, 'optionalAccess', _89 => _89.pages])) {
|
|
16986
16989
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
16987
16990
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
16988
16991
|
}
|
|
@@ -16991,7 +16994,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16991
16994
|
for (let i = 0; i < processedSheets; i++) {
|
|
16992
16995
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
16993
16996
|
const sheet = sheets[i];
|
|
16994
|
-
_optionalChain([options, 'optionalAccess',
|
|
16997
|
+
_optionalChain([options, 'optionalAccess', _90 => _90.onProgress, 'optionalCall', _91 => _91(i + 1, processedSheets)]);
|
|
16995
16998
|
let sheetPath = relsMap.get(sheet.rId);
|
|
16996
16999
|
if (sheetPath) {
|
|
16997
17000
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17046,7 +17049,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17046
17049
|
} catch (e27) {
|
|
17047
17050
|
}
|
|
17048
17051
|
}
|
|
17049
|
-
const markdown =
|
|
17052
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17050
17053
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17051
17054
|
}
|
|
17052
17055
|
|
|
@@ -17453,11 +17456,11 @@ function processGlobals(records) {
|
|
|
17453
17456
|
let encrypted = false;
|
|
17454
17457
|
const firstBof = records[0];
|
|
17455
17458
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17456
|
-
throw new (0,
|
|
17459
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17457
17460
|
}
|
|
17458
17461
|
const bof = decodeBof(firstBof.data);
|
|
17459
17462
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17460
|
-
throw new (0,
|
|
17463
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17461
17464
|
}
|
|
17462
17465
|
let i = 1;
|
|
17463
17466
|
while (i < records.length) {
|
|
@@ -17565,14 +17568,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17565
17568
|
const merge = mergeMap.get(key);
|
|
17566
17569
|
row.push({
|
|
17567
17570
|
text: grid[r][c],
|
|
17568
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17569
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17571
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _92 => _92.colSpan]), () => ( 1)),
|
|
17572
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _93 => _93.rowSpan]), () => ( 1))
|
|
17570
17573
|
});
|
|
17571
17574
|
}
|
|
17572
17575
|
cellRows.push(row);
|
|
17573
17576
|
}
|
|
17574
17577
|
if (cellRows.length > 0) {
|
|
17575
|
-
const table =
|
|
17578
|
+
const table = _chunkXL6O3VAYcjs.buildTable.call(void 0, cellRows);
|
|
17576
17579
|
if (table.rows > 0) {
|
|
17577
17580
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17578
17581
|
}
|
|
@@ -17585,21 +17588,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17585
17588
|
try {
|
|
17586
17589
|
cfb = parseLenientCfb(buf);
|
|
17587
17590
|
} catch (e) {
|
|
17588
|
-
throw new (0,
|
|
17591
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)(
|
|
17589
17592
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17590
17593
|
);
|
|
17591
17594
|
}
|
|
17592
17595
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17593
17596
|
if (!wb) {
|
|
17594
|
-
throw new (0,
|
|
17597
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17595
17598
|
}
|
|
17596
17599
|
const records = readRecords2(wb);
|
|
17597
17600
|
if (records.length === 0) {
|
|
17598
|
-
throw new (0,
|
|
17601
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17599
17602
|
}
|
|
17600
17603
|
const firstBof = decodeBof(records[0].data);
|
|
17601
17604
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17602
|
-
throw new (0,
|
|
17605
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)(
|
|
17603
17606
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17604
17607
|
);
|
|
17605
17608
|
}
|
|
@@ -17620,7 +17623,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17620
17623
|
}
|
|
17621
17624
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17622
17625
|
let pageFilter = null;
|
|
17623
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17626
|
+
if (_optionalChain([options, 'optionalAccess', _94 => _94.pages])) {
|
|
17624
17627
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17625
17628
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17626
17629
|
}
|
|
@@ -17629,7 +17632,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17629
17632
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17630
17633
|
const meta = globals.sheets[i];
|
|
17631
17634
|
if (meta.dt !== 0) continue;
|
|
17632
|
-
_optionalChain([options, 'optionalAccess',
|
|
17635
|
+
_optionalChain([options, 'optionalAccess', _95 => _95.onProgress, 'optionalCall', _96 => _96(i + 1, totalSheets)]);
|
|
17633
17636
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
17634
17637
|
if (bofIdx < 0) {
|
|
17635
17638
|
warnings.push({
|
|
@@ -17659,7 +17662,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17659
17662
|
pageCount: totalSheets
|
|
17660
17663
|
};
|
|
17661
17664
|
return {
|
|
17662
|
-
markdown:
|
|
17665
|
+
markdown: _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17663
17666
|
blocks: allBlocks,
|
|
17664
17667
|
metadata,
|
|
17665
17668
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17672,7 +17675,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17672
17675
|
|
|
17673
17676
|
// src/docx/equation.ts
|
|
17674
17677
|
function lname(el) {
|
|
17675
|
-
return el.localName || _optionalChain([el, 'access',
|
|
17678
|
+
return el.localName || _optionalChain([el, 'access', _97 => _97.tagName, 'optionalAccess', _98 => _98.replace, 'call', _99 => _99(/^[^:]+:/, "")]) || "";
|
|
17676
17679
|
}
|
|
17677
17680
|
function kids(parent, name) {
|
|
17678
17681
|
const out = [];
|
|
@@ -18045,7 +18048,7 @@ function isDisplayMath(el) {
|
|
|
18045
18048
|
// src/docx/parser.ts
|
|
18046
18049
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
18047
18050
|
function matchesLocal(el, localName2) {
|
|
18048
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
18051
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _100 => _100.tagName, 'optionalAccess', _101 => _101.endsWith, 'call', _102 => _102(`:${localName2}`)]), () => ( false)));
|
|
18049
18052
|
}
|
|
18050
18053
|
function effectiveChildElements(parent) {
|
|
18051
18054
|
const result = [];
|
|
@@ -18078,7 +18081,7 @@ function findElements(parent, localName2) {
|
|
|
18078
18081
|
const child = children[i];
|
|
18079
18082
|
if (child.nodeType === 1) {
|
|
18080
18083
|
const el = child;
|
|
18081
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
18084
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _103 => _103.tagName, 'optionalAccess', _104 => _104.endsWith, 'call', _105 => _105(`:${localName2}`)])) {
|
|
18082
18085
|
result.push(el);
|
|
18083
18086
|
}
|
|
18084
18087
|
walk(el);
|
|
@@ -18097,7 +18100,7 @@ function getAttr(el, localName2) {
|
|
|
18097
18100
|
return null;
|
|
18098
18101
|
}
|
|
18099
18102
|
function parseXml2(text) {
|
|
18100
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18103
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkXL6O3VAYcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18101
18104
|
}
|
|
18102
18105
|
function parseStyles(xml) {
|
|
18103
18106
|
const doc = parseXml2(xml);
|
|
@@ -18199,7 +18202,7 @@ function collectOmmlRoots(p) {
|
|
|
18199
18202
|
const child = children[i];
|
|
18200
18203
|
if (child.nodeType !== 1) continue;
|
|
18201
18204
|
const el = child;
|
|
18202
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
18205
|
+
const tag = el.localName || _optionalChain([el, 'access', _106 => _106.tagName, 'optionalAccess', _107 => _107.replace, 'call', _108 => _108(/^[^:]+:/, "")]) || "";
|
|
18203
18206
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
18204
18207
|
out.push(el);
|
|
18205
18208
|
} else {
|
|
@@ -18288,7 +18291,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18288
18291
|
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18289
18292
|
if (!text) return null;
|
|
18290
18293
|
const style = styles.get(styleId);
|
|
18291
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
18294
|
+
if (_optionalChain([style, 'optionalAccess', _109 => _109.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
18292
18295
|
return {
|
|
18293
18296
|
type: "heading",
|
|
18294
18297
|
text,
|
|
@@ -18297,8 +18300,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18297
18300
|
}
|
|
18298
18301
|
if (numId && numId !== "0") {
|
|
18299
18302
|
const numDef = numbering.get(numId);
|
|
18300
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
18301
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
18303
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _110 => _110.get, 'call', _111 => _111(ilvl)]);
|
|
18304
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _112 => _112.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
18302
18305
|
return { type: "list", text, listType };
|
|
18303
18306
|
}
|
|
18304
18307
|
const block = { type: "paragraph", text };
|
|
@@ -18339,7 +18342,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
|
18339
18342
|
const pElements = getChildElements(tc, "p");
|
|
18340
18343
|
for (const p of pElements) {
|
|
18341
18344
|
const block = parseParagraph2(p, styles, numbering, footnotes, rels);
|
|
18342
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
18345
|
+
if (_optionalChain([block, 'optionalAccess', _113 => _113.text])) cellTexts.push(block.text);
|
|
18343
18346
|
}
|
|
18344
18347
|
row.push({ text: cellTexts.join("\n"), colSpan, rowSpan });
|
|
18345
18348
|
}
|
|
@@ -18352,7 +18355,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
|
18352
18355
|
if (!cell || cell.rowSpan === 0) continue;
|
|
18353
18356
|
let span = 1;
|
|
18354
18357
|
for (let nr = r + 1; nr < rows.length; nr++) {
|
|
18355
|
-
if (_optionalChain([rows, 'access',
|
|
18358
|
+
if (_optionalChain([rows, 'access', _114 => _114[nr], 'access', _115 => _115[c], 'optionalAccess', _116 => _116.rowSpan]) === 0) span++;
|
|
18356
18359
|
else break;
|
|
18357
18360
|
}
|
|
18358
18361
|
cell.rowSpan = span;
|
|
@@ -18396,7 +18399,7 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18396
18399
|
try {
|
|
18397
18400
|
const data = await imgFile.async("uint8array");
|
|
18398
18401
|
imgIdx++;
|
|
18399
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
18402
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _117 => _117.split, 'call', _118 => _118("."), 'access', _119 => _119.pop, 'call', _120 => _120(), 'optionalAccess', _121 => _121.toLowerCase, 'call', _122 => _122()]), () => ( "png"));
|
|
18400
18403
|
const mimeMap = {
|
|
18401
18404
|
png: "image/png",
|
|
18402
18405
|
jpg: "image/jpeg",
|
|
@@ -18420,12 +18423,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18420
18423
|
return { blocks, images };
|
|
18421
18424
|
}
|
|
18422
18425
|
async function parseDocxDocument(buffer, options) {
|
|
18423
|
-
|
|
18426
|
+
_chunkXL6O3VAYcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18424
18427
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18425
18428
|
const warnings = [];
|
|
18426
18429
|
const docFile = zip.file("word/document.xml");
|
|
18427
18430
|
if (!docFile) {
|
|
18428
|
-
throw new (0,
|
|
18431
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18429
18432
|
}
|
|
18430
18433
|
let rels = /* @__PURE__ */ new Map();
|
|
18431
18434
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18472,13 +18475,13 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18472
18475
|
const doc = parseXml2(docXml);
|
|
18473
18476
|
const body = findElements(doc, "body");
|
|
18474
18477
|
if (body.length === 0) {
|
|
18475
|
-
throw new (0,
|
|
18478
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18476
18479
|
}
|
|
18477
18480
|
const blocks = [];
|
|
18478
18481
|
const bodyEl = body[0];
|
|
18479
18482
|
const topLevel = effectiveChildElements(bodyEl);
|
|
18480
18483
|
for (const el of topLevel) {
|
|
18481
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
18484
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _123 => _123.tagName, 'optionalAccess', _124 => _124.split, 'call', _125 => _125(":"), 'access', _126 => _126.pop, 'call', _127 => _127()])));
|
|
18482
18485
|
if (localName2 === "p") {
|
|
18483
18486
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18484
18487
|
if (block) blocks.push(block);
|
|
@@ -18513,7 +18516,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18513
18516
|
}
|
|
18514
18517
|
}
|
|
18515
18518
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18516
|
-
const markdown =
|
|
18519
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18517
18520
|
return {
|
|
18518
18521
|
markdown,
|
|
18519
18522
|
blocks,
|
|
@@ -18536,7 +18539,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18536
18539
|
}
|
|
18537
18540
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18538
18541
|
const normalized = text.replace(/ /g, " ");
|
|
18539
|
-
const xml =
|
|
18542
|
+
const xml = _chunkXL6O3VAYcjs.stripDtd.call(void 0, normalized);
|
|
18540
18543
|
const warnings = [];
|
|
18541
18544
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18542
18545
|
onError: (_level, msg2) => {
|
|
@@ -18564,7 +18567,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18564
18567
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18565
18568
|
}
|
|
18566
18569
|
const blocks = [];
|
|
18567
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
18570
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _128 => _128.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18568
18571
|
let sectionIdx = 0;
|
|
18569
18572
|
const children = body.childNodes;
|
|
18570
18573
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18576,7 +18579,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18576
18579
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18577
18580
|
}
|
|
18578
18581
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18579
|
-
const markdown =
|
|
18582
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18580
18583
|
return {
|
|
18581
18584
|
markdown,
|
|
18582
18585
|
blocks,
|
|
@@ -18625,6 +18628,7 @@ function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderF
|
|
|
18625
18628
|
if (tag === "P") {
|
|
18626
18629
|
if (!inHeaderFooter) {
|
|
18627
18630
|
parseParagraph3(el, blocks, paraShapeMap, sectionNum);
|
|
18631
|
+
walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings);
|
|
18628
18632
|
}
|
|
18629
18633
|
continue;
|
|
18630
18634
|
}
|
|
@@ -18641,12 +18645,27 @@ function walkContent(node, blocks, paraShapeMap, sectionNum, warnings, inHeaderF
|
|
|
18641
18645
|
walkContent(el, blocks, paraShapeMap, sectionNum, warnings, inHeaderFooter, depth + 1);
|
|
18642
18646
|
}
|
|
18643
18647
|
}
|
|
18648
|
+
function walkTablesInP(node, blocks, paraShapeMap, sectionNum, warnings, depth = 0) {
|
|
18649
|
+
if (depth > MAX_XML_DEPTH2) return;
|
|
18650
|
+
const children = node.childNodes;
|
|
18651
|
+
for (let i = 0; i < children.length; i++) {
|
|
18652
|
+
const el = children[i];
|
|
18653
|
+
if (el.nodeType !== 1) continue;
|
|
18654
|
+
const tag = localName(el);
|
|
18655
|
+
if (tag === "TABLE") {
|
|
18656
|
+
parseTable2(el, blocks, paraShapeMap, sectionNum, warnings);
|
|
18657
|
+
continue;
|
|
18658
|
+
}
|
|
18659
|
+
if (tag === "FOOTNOTE" || tag === "ENDNOTE" || tag === "HEADER" || tag === "FOOTER") continue;
|
|
18660
|
+
walkTablesInP(el, blocks, paraShapeMap, sectionNum, warnings, depth + 1);
|
|
18661
|
+
}
|
|
18662
|
+
}
|
|
18644
18663
|
function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
18645
18664
|
const paraShapeId = _nullishCoalesce(el.getAttribute("ParaShape"), () => ( ""));
|
|
18646
18665
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
18647
18666
|
const text = extractParagraphText(el);
|
|
18648
18667
|
if (!text) return;
|
|
18649
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
18668
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _129 => _129.headingLevel]) != null) {
|
|
18650
18669
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
18651
18670
|
} else {
|
|
18652
18671
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -18718,7 +18737,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18718
18737
|
const cellRows = grid.map(
|
|
18719
18738
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18720
18739
|
);
|
|
18721
|
-
const table =
|
|
18740
|
+
const table = _chunkXL6O3VAYcjs.buildTable.call(void 0, cellRows);
|
|
18722
18741
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18723
18742
|
}
|
|
18724
18743
|
function extractCellText(cellEl) {
|
|
@@ -18736,13 +18755,29 @@ function collectCellText(node, parts, depth) {
|
|
|
18736
18755
|
if (tag === "P") {
|
|
18737
18756
|
const t = extractParagraphText(el);
|
|
18738
18757
|
if (t) parts.push(t);
|
|
18758
|
+
collectNestedTableText(el, parts, depth + 1);
|
|
18739
18759
|
} else if (tag === "TABLE") {
|
|
18740
|
-
|
|
18760
|
+
collectCellText(el, parts, depth + 1);
|
|
18741
18761
|
} else {
|
|
18742
18762
|
collectCellText(el, parts, depth + 1);
|
|
18743
18763
|
}
|
|
18744
18764
|
}
|
|
18745
18765
|
}
|
|
18766
|
+
function collectNestedTableText(node, parts, depth) {
|
|
18767
|
+
if (depth > 20) return;
|
|
18768
|
+
const children = node.childNodes;
|
|
18769
|
+
for (let i = 0; i < children.length; i++) {
|
|
18770
|
+
const el = children[i];
|
|
18771
|
+
if (el.nodeType !== 1) continue;
|
|
18772
|
+
const tag = localName(el);
|
|
18773
|
+
if (tag === "TABLE") {
|
|
18774
|
+
collectCellText(el, parts, depth + 1);
|
|
18775
|
+
continue;
|
|
18776
|
+
}
|
|
18777
|
+
if (tag === "FOOTNOTE" || tag === "ENDNOTE" || tag === "HEADER" || tag === "FOOTER") continue;
|
|
18778
|
+
collectNestedTableText(el, parts, depth + 1);
|
|
18779
|
+
}
|
|
18780
|
+
}
|
|
18746
18781
|
function localName(el) {
|
|
18747
18782
|
return (el.tagName || el.localName || "").replace(/^[^:]+:/, "");
|
|
18748
18783
|
}
|
|
@@ -19079,8 +19114,8 @@ function extractFromTable(table) {
|
|
|
19079
19114
|
if (table.cols >= 2) {
|
|
19080
19115
|
for (let r = 0; r < table.rows; r++) {
|
|
19081
19116
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
19082
|
-
const labelCell = _optionalChain([table, 'access',
|
|
19083
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19117
|
+
const labelCell = _optionalChain([table, 'access', _130 => _130.cells, 'access', _131 => _131[r], 'optionalAccess', _132 => _132[c]]);
|
|
19118
|
+
const valueCell = _optionalChain([table, 'access', _133 => _133.cells, 'access', _134 => _134[r], 'optionalAccess', _135 => _135[c + 1]]);
|
|
19084
19119
|
if (!labelCell || !valueCell) continue;
|
|
19085
19120
|
if (isLabelCell(labelCell.text)) {
|
|
19086
19121
|
fields.push({
|
|
@@ -19102,8 +19137,8 @@ function extractFromTable(table) {
|
|
|
19102
19137
|
if (allLabels) {
|
|
19103
19138
|
for (let r = 1; r < table.rows; r++) {
|
|
19104
19139
|
for (let c = 0; c < table.cols; c++) {
|
|
19105
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19106
|
-
const value = _nullishCoalesce(_optionalChain([table, 'access',
|
|
19140
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _136 => _136[c], 'optionalAccess', _137 => _137.text, 'access', _138 => _138.trim, 'call', _139 => _139()]), () => ( ""));
|
|
19141
|
+
const value = _nullishCoalesce(_optionalChain([table, 'access', _140 => _140.cells, 'access', _141 => _141[r], 'optionalAccess', _142 => _142[c], 'optionalAccess', _143 => _143.text, 'access', _144 => _144.trim, 'call', _145 => _145()]), () => ( ""));
|
|
19107
19142
|
if (label && value) {
|
|
19108
19143
|
fields.push({ label, value, row: r, col: c });
|
|
19109
19144
|
}
|
|
@@ -19196,7 +19231,7 @@ function fillFormFields(blocks, values) {
|
|
|
19196
19231
|
for (const table of allTables) {
|
|
19197
19232
|
for (let r = 0; r < table.rows; r++) {
|
|
19198
19233
|
for (let c = 0; c < table.cols; c++) {
|
|
19199
|
-
const cell = _optionalChain([table, 'access',
|
|
19234
|
+
const cell = _optionalChain([table, 'access', _146 => _146.cells, 'access', _147 => _147[r], 'optionalAccess', _148 => _148[c]]);
|
|
19200
19235
|
if (!cell) continue;
|
|
19201
19236
|
const result = fillInCellPatterns(cell.text, cursor, matchedLabels);
|
|
19202
19237
|
if (result) {
|
|
@@ -19228,7 +19263,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19228
19263
|
out.push(block.table);
|
|
19229
19264
|
for (const row of block.table.cells) {
|
|
19230
19265
|
for (const cell of row) {
|
|
19231
|
-
if (_optionalChain([cell, 'optionalAccess',
|
|
19266
|
+
if (_optionalChain([cell, 'optionalAccess', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) out.push(...collectIRTables(cell.blocks, depth + 1));
|
|
19232
19267
|
}
|
|
19233
19268
|
}
|
|
19234
19269
|
}
|
|
@@ -19239,7 +19274,7 @@ function coveredPositions(table) {
|
|
|
19239
19274
|
for (let r = 0; r < table.rows; r++) {
|
|
19240
19275
|
for (let c = 0; c < table.cols; c++) {
|
|
19241
19276
|
if (covered.has(`${r},${c}`)) continue;
|
|
19242
|
-
const cell = _optionalChain([table, 'access',
|
|
19277
|
+
const cell = _optionalChain([table, 'access', _151 => _151.cells, 'access', _152 => _152[r], 'optionalAccess', _153 => _153[c]]);
|
|
19243
19278
|
if (!cell) continue;
|
|
19244
19279
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
19245
19280
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -19273,7 +19308,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19273
19308
|
if (matchKey === void 0) continue;
|
|
19274
19309
|
const newValue = values.consume(matchKey);
|
|
19275
19310
|
if (newValue === void 0) continue;
|
|
19276
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19311
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _154 => _154.has, 'call', _155 => _155(valueCell)])) {
|
|
19277
19312
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19278
19313
|
} else {
|
|
19279
19314
|
valueCell.text = newValue;
|
|
@@ -19298,7 +19333,7 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19298
19333
|
for (let c = 0; c < table.cols; c++) {
|
|
19299
19334
|
if (covered.has(`${r},${c}`)) continue;
|
|
19300
19335
|
const headerCell = headerRow[c];
|
|
19301
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19336
|
+
const valueCell = _optionalChain([table, 'access', _156 => _156.cells, 'access', _157 => _157[r], 'optionalAccess', _158 => _158[c]]);
|
|
19302
19337
|
if (!headerCell || !valueCell) continue;
|
|
19303
19338
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19304
19339
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
@@ -19891,19 +19926,19 @@ function parseCentralDirectory(buf) {
|
|
|
19891
19926
|
}
|
|
19892
19927
|
}
|
|
19893
19928
|
}
|
|
19894
|
-
if (eocdOffset < 0) throw new (0,
|
|
19929
|
+
if (eocdOffset < 0) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19895
19930
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19896
19931
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19897
19932
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19898
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19933
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19899
19934
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19900
|
-
throw new (0,
|
|
19935
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19901
19936
|
}
|
|
19902
19937
|
const decoder = new TextDecoder("utf-8");
|
|
19903
19938
|
const entries = [];
|
|
19904
19939
|
let pos = cdOffset;
|
|
19905
19940
|
for (let i = 0; i < totalEntries; i++) {
|
|
19906
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19941
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19907
19942
|
const flags = view.getUint16(pos + 8, true);
|
|
19908
19943
|
const method = view.getUint16(pos + 10, true);
|
|
19909
19944
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19914,7 +19949,7 @@ function parseCentralDirectory(buf) {
|
|
|
19914
19949
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19915
19950
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19916
19951
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19917
|
-
throw new (0,
|
|
19952
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19918
19953
|
}
|
|
19919
19954
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19920
19955
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19943,7 +19978,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19943
19978
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19944
19979
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19945
19980
|
for (const name of replacements.keys()) {
|
|
19946
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19981
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkXL6O3VAYcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19947
19982
|
}
|
|
19948
19983
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19949
19984
|
const segments = [];
|
|
@@ -19961,7 +19996,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19961
19996
|
offset += seg.length;
|
|
19962
19997
|
continue;
|
|
19963
19998
|
}
|
|
19964
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
19999
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkXL6O3VAYcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19965
20000
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19966
20001
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19967
20002
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20016,7 +20051,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20016
20051
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20017
20052
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20018
20053
|
if (sectionPaths.length === 0) {
|
|
20019
|
-
throw new (0,
|
|
20054
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20020
20055
|
}
|
|
20021
20056
|
const normalizedValues = normalizeValues(values);
|
|
20022
20057
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20175,7 +20210,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20175
20210
|
}
|
|
20176
20211
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20177
20212
|
const existing = ledger.get(para);
|
|
20178
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20213
|
+
if (_optionalChain([existing, 'optionalAccess', _159 => _159.fullText]) !== void 0) continue;
|
|
20179
20214
|
const text = matchText(para);
|
|
20180
20215
|
for (const seg of scanInlineSegments(text)) {
|
|
20181
20216
|
const matchKey = findMatchingKey(normalizeLabel(seg.label), cursor);
|
|
@@ -20414,8 +20449,8 @@ function charWidthEm1000(cp) {
|
|
|
20414
20449
|
var SPACE_EM_FIXED = 500;
|
|
20415
20450
|
var SPACE_EM_FONT = 300;
|
|
20416
20451
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20417
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20418
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20452
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _160 => _160.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20453
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _161 => _161.spacingPct]), () => ( 0));
|
|
20419
20454
|
let em = 0;
|
|
20420
20455
|
for (const ch of text) {
|
|
20421
20456
|
const cp = ch.codePointAt(0);
|
|
@@ -20428,8 +20463,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20428
20463
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20429
20464
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20430
20465
|
const EPS = 0.5;
|
|
20431
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20432
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20466
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _162 => _162.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20467
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _163 => _163.spacingPct]), () => ( 0));
|
|
20433
20468
|
const k = height * ratioPct / 100 / 1e3;
|
|
20434
20469
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20435
20470
|
const charW = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20655,16 +20690,16 @@ var PARA_LIST = 7;
|
|
|
20655
20690
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20656
20691
|
function resolveTheme(theme) {
|
|
20657
20692
|
return {
|
|
20658
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20659
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20660
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20661
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20662
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20663
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20693
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _164 => _164.headingColors, 'optionalAccess', _165 => _165[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20694
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _166 => _166.headingColors, 'optionalAccess', _167 => _167[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20695
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _168 => _168.headingColors, 'optionalAccess', _169 => _169[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20696
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _170 => _170.headingColors, 'optionalAccess', _171 => _171[4]]), () => ( _optionalChain([theme, 'optionalAccess', _172 => _172.headingColors, 'optionalAccess', _173 => _173[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20697
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _174 => _174.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20698
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _175 => _175.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20664
20699
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20665
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20666
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20667
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
20700
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _176 => _176.quoteColor]) !== void 0,
|
|
20701
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _177 => _177.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _178 => _178.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20702
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _179 => _179.tableHeaderBold])
|
|
20668
20703
|
};
|
|
20669
20704
|
}
|
|
20670
20705
|
function escapeXml(text) {
|
|
@@ -20968,7 +21003,7 @@ ${base.join("\n")}
|
|
|
20968
21003
|
</hh:paraProperties>`;
|
|
20969
21004
|
}
|
|
20970
21005
|
function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
20971
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
21006
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _180 => _180.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
20972
21007
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants);
|
|
20973
21008
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
20974
21009
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -21313,7 +21348,7 @@ function escapeGfm(text) {
|
|
|
21313
21348
|
}
|
|
21314
21349
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21315
21350
|
function sanitizeText(text) {
|
|
21316
|
-
let result =
|
|
21351
|
+
let result = _chunkXL6O3VAYcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21317
21352
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21318
21353
|
const tokens = result.split(" ");
|
|
21319
21354
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21343,7 +21378,7 @@ function replicateGfmTable(table) {
|
|
|
21343
21378
|
for (let r = 0; r < numRows; r++) {
|
|
21344
21379
|
for (let c = 0; c < numCols; c++) {
|
|
21345
21380
|
if (skip.has(`${r},${c}`)) continue;
|
|
21346
|
-
const cell = _optionalChain([cells, 'access',
|
|
21381
|
+
const cell = _optionalChain([cells, 'access', _181 => _181[r], 'optionalAccess', _182 => _182[c]]);
|
|
21347
21382
|
if (!cell) continue;
|
|
21348
21383
|
display[r][c] = {
|
|
21349
21384
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -21397,7 +21432,7 @@ function unescapeGfmCell(text) {
|
|
|
21397
21432
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\~/g, "~");
|
|
21398
21433
|
}
|
|
21399
21434
|
function replicateCellInnerHtml(cell) {
|
|
21400
|
-
if (_optionalChain([cell, 'access',
|
|
21435
|
+
if (_optionalChain([cell, 'access', _183 => _183.blocks, 'optionalAccess', _184 => _184.length])) {
|
|
21401
21436
|
return cell.blocks.map((b) => {
|
|
21402
21437
|
if (b.type === "table" && b.table) {
|
|
21403
21438
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -21436,7 +21471,7 @@ function replicateHtmlTable(table) {
|
|
|
21436
21471
|
const rowCells = [];
|
|
21437
21472
|
for (let c = 0; c < numCols; c++) {
|
|
21438
21473
|
if (skip.has(`${r},${c}`)) continue;
|
|
21439
|
-
const cell = _optionalChain([cells, 'access',
|
|
21474
|
+
const cell = _optionalChain([cells, 'access', _185 => _185[r], 'optionalAccess', _186 => _186[c]]);
|
|
21440
21475
|
if (!cell) continue;
|
|
21441
21476
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
21442
21477
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -21482,8 +21517,8 @@ function parseHtmlTable(raw) {
|
|
|
21482
21517
|
}
|
|
21483
21518
|
} else {
|
|
21484
21519
|
if (!isClose) {
|
|
21485
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
21486
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
21520
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _187 => _187.match, 'call', _188 => _188(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _189 => _189[1]]) || "1", 10);
|
|
21521
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _190 => _190.match, 'call', _191 => _191(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _192 => _192[1]]) || "1", 10);
|
|
21487
21522
|
cellStart = m.index + m[0].length;
|
|
21488
21523
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
21489
21524
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -21700,8 +21735,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21700
21735
|
case "list_item": {
|
|
21701
21736
|
if (gongmun && gongmunList) {
|
|
21702
21737
|
const info = gongmunList.get(blockIdx);
|
|
21703
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
21704
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
21738
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _193 => _193.depth]), () => ( 0));
|
|
21739
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _194 => _194.marker]), () => ( ""));
|
|
21705
21740
|
const content = block.text || "";
|
|
21706
21741
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
21707
21742
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -21778,8 +21813,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
21778
21813
|
|
|
21779
21814
|
// src/hwpx/generator.ts
|
|
21780
21815
|
async function markdownToHwpx(markdown, options) {
|
|
21781
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
21782
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
21816
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _195 => _195.theme]));
|
|
21817
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _196 => _196.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
21783
21818
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
21784
21819
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
21785
21820
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
@@ -21788,7 +21823,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
21788
21823
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
21789
21824
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
21790
21825
|
zip.file("Contents/content.hpf", generateManifest());
|
|
21791
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
21826
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _197 => _197.variants]), () => ( []))));
|
|
21792
21827
|
zip.file("Contents/section0.xml", sectionXml);
|
|
21793
21828
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
21794
21829
|
return await zip.generateAsync({ type: "arraybuffer" });
|
|
@@ -21936,7 +21971,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
21936
21971
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
21937
21972
|
function patchTableRows(input) {
|
|
21938
21973
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
21939
|
-
const xml = _optionalChain([ctx, 'access',
|
|
21974
|
+
const xml = _optionalChain([ctx, 'access', _198 => _198.scans, 'access', _199 => _199[scanTable.sectionIndex], 'optionalAccess', _200 => _200.xml]);
|
|
21940
21975
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
21941
21976
|
const numRows = table.rows;
|
|
21942
21977
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -22103,7 +22138,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
22103
22138
|
const rr = scanTable.rowRanges[template];
|
|
22104
22139
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
22105
22140
|
const scan = scanSectionXml(wrapped, 0);
|
|
22106
|
-
const row = _optionalChain([scan, 'access',
|
|
22141
|
+
const row = _optionalChain([scan, 'access', _201 => _201.tables, 'access', _202 => _202[0], 'optionalAccess', _203 => _203.rows, 'access', _204 => _204[0]]);
|
|
22107
22142
|
if (!row || row.length !== cells.length) return null;
|
|
22108
22143
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
22109
22144
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -22146,7 +22181,7 @@ function rowHeightOf(fragment) {
|
|
|
22146
22181
|
}
|
|
22147
22182
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
22148
22183
|
const from = scanTable.start + tblOpenLen;
|
|
22149
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
22184
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _205 => _205.rowRanges, 'access', _206 => _206[0], 'optionalAccess', _207 => _207.start]), () => ( from));
|
|
22150
22185
|
const slice = xml.slice(from, to);
|
|
22151
22186
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
22152
22187
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -22335,9 +22370,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
22335
22370
|
});
|
|
22336
22371
|
}
|
|
22337
22372
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
22338
|
-
const irCell = _optionalChain([table, 'access',
|
|
22373
|
+
const irCell = _optionalChain([table, 'access', _208 => _208.cells, 'access', _209 => _209[oc.gridR], 'optionalAccess', _210 => _210[oc.gridC]]);
|
|
22339
22374
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
22340
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
22375
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _211 => _211.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
22341
22376
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
22342
22377
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
22343
22378
|
}
|
|
@@ -22405,7 +22440,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22405
22440
|
};
|
|
22406
22441
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
22407
22442
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
22408
|
-
const irCell = _optionalChain([table, 'access',
|
|
22443
|
+
const irCell = _optionalChain([table, 'access', _212 => _212.cells, 'access', _213 => _213[gridR], 'optionalAccess', _214 => _214[gridC]]);
|
|
22409
22444
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
22410
22445
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
22411
22446
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -22428,7 +22463,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22428
22463
|
if (newLines.length === 0) return 0;
|
|
22429
22464
|
const target = cell.paragraphs[0];
|
|
22430
22465
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
22431
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
22466
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _215 => _215.scans, 'access', _216 => _216[target.sectionIndex], 'optionalAccess', _217 => _217.xml]));
|
|
22432
22467
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22433
22468
|
splices.push(...sp);
|
|
22434
22469
|
sectionIndex = target.sectionIndex;
|
|
@@ -22451,7 +22486,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
22451
22486
|
}
|
|
22452
22487
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
22453
22488
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
22454
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
22489
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _218 => _218.scans, 'access', _219 => _219[nonEmpty[i].sectionIndex], 'optionalAccess', _220 => _220.xml]));
|
|
22455
22490
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22456
22491
|
splices.push(...sp);
|
|
22457
22492
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -22532,7 +22567,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
22532
22567
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
22533
22568
|
if (paths.length > 0) return paths;
|
|
22534
22569
|
}
|
|
22535
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
22570
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkXL6O3VAYcjs.compareSectionPaths);
|
|
22536
22571
|
}
|
|
22537
22572
|
function sectionPathsFromManifest(xml) {
|
|
22538
22573
|
const attr = (tag, name) => {
|
|
@@ -22542,7 +22577,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22542
22577
|
const idToHref = /* @__PURE__ */ new Map();
|
|
22543
22578
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
22544
22579
|
const id = attr(m[1], "id");
|
|
22545
|
-
const href =
|
|
22580
|
+
const href = _chunkXL6O3VAYcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
22546
22581
|
if (id && href) idToHref.set(id, href);
|
|
22547
22582
|
}
|
|
22548
22583
|
const ordered = [];
|
|
@@ -22551,7 +22586,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
22551
22586
|
if (href) ordered.push(href);
|
|
22552
22587
|
}
|
|
22553
22588
|
if (ordered.length > 0) return ordered;
|
|
22554
|
-
return Array.from(idToHref.values()).sort(
|
|
22589
|
+
return Array.from(idToHref.values()).sort(_chunkXL6O3VAYcjs.compareSectionPaths);
|
|
22555
22590
|
}
|
|
22556
22591
|
|
|
22557
22592
|
// src/roundtrip/patcher.ts
|
|
@@ -22643,7 +22678,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
22643
22678
|
}
|
|
22644
22679
|
}
|
|
22645
22680
|
let verification;
|
|
22646
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22681
|
+
if (_optionalChain([options, 'optionalAccess', _221 => _221.verify]) !== false) {
|
|
22647
22682
|
try {
|
|
22648
22683
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
22649
22684
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -22661,17 +22696,17 @@ function buildOrigUnits(blocks) {
|
|
|
22661
22696
|
let chunk;
|
|
22662
22697
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
22663
22698
|
const next = blocks[i + 1];
|
|
22664
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
22665
|
-
chunk =
|
|
22699
|
+
if (_optionalChain([next, 'optionalAccess', _222 => _222.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
22700
|
+
chunk = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
22666
22701
|
} else {
|
|
22667
|
-
chunk =
|
|
22702
|
+
chunk = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, [block]);
|
|
22668
22703
|
}
|
|
22669
22704
|
if (chunk) {
|
|
22670
22705
|
const subUnits = splitMarkdownUnits(chunk);
|
|
22671
22706
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
22672
22707
|
for (let s = 0; s < subUnits.length; s++) {
|
|
22673
22708
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
22674
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
22709
|
+
if (block.type === "table" && _optionalChain([block, 'access', _223 => _223.table, 'optionalAccess', _224 => _224.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
22675
22710
|
u.role = "caption";
|
|
22676
22711
|
}
|
|
22677
22712
|
units.push(u);
|
|
@@ -22782,7 +22817,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
22782
22817
|
const ti = ctx.tableInsert;
|
|
22783
22818
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
22784
22819
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22785
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22820
|
+
if (!_optionalChain([mapping, 'optionalAccess', _225 => _225.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
|
|
22786
22821
|
const para = mapping.para;
|
|
22787
22822
|
if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
|
|
22788
22823
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -22810,7 +22845,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
22810
22845
|
}
|
|
22811
22846
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
22812
22847
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22813
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22848
|
+
if (!_optionalChain([mapping, 'optionalAccess', _226 => _226.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
22814
22849
|
if (block.text && block.text.includes("\n")) {
|
|
22815
22850
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
22816
22851
|
}
|
|
@@ -22841,7 +22876,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
22841
22876
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
22842
22877
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
22843
22878
|
}
|
|
22844
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
22879
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _227 => _227.scans, 'access', _228 => _228[mapping.para.sectionIndex], 'optionalAccess', _229 => _229.xml]));
|
|
22845
22880
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
22846
22881
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
22847
22882
|
return 1;
|
|
@@ -23027,7 +23062,7 @@ var Surgeon = (_class4 = class {
|
|
|
23027
23062
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
23028
23063
|
findEntry(path) {
|
|
23029
23064
|
const parts = path.replace(/^\//, "").split("/");
|
|
23030
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
23065
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _230 => _230.entries, 'access', _231 => _231[0], 'optionalAccess', _232 => _232.child]), () => ( -1));
|
|
23031
23066
|
let current;
|
|
23032
23067
|
for (const part of parts) {
|
|
23033
23068
|
const search = (idx) => {
|
|
@@ -23240,8 +23275,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
23240
23275
|
parts.push(header, data);
|
|
23241
23276
|
};
|
|
23242
23277
|
for (let i = 0; i < recs.length; i++) {
|
|
23243
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
23244
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
23278
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _233 => _233.get, 'call', _234 => _234(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
23279
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _235 => _235.get, 'call', _236 => _236(i)]), () => ( recs[i].data)));
|
|
23245
23280
|
}
|
|
23246
23281
|
return Buffer.concat(parts);
|
|
23247
23282
|
}
|
|
@@ -23359,7 +23394,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23359
23394
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
23360
23395
|
}
|
|
23361
23396
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
23362
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
23397
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _237 => _237.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
23363
23398
|
let flags;
|
|
23364
23399
|
try {
|
|
23365
23400
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -23381,7 +23416,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23381
23416
|
const scans = [];
|
|
23382
23417
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
23383
23418
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
23384
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
23419
|
+
if (!_optionalChain([entry, 'optionalAccess', _238 => _238.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
23385
23420
|
let stream;
|
|
23386
23421
|
try {
|
|
23387
23422
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -23432,7 +23467,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
23432
23467
|
}
|
|
23433
23468
|
}
|
|
23434
23469
|
let verification;
|
|
23435
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23470
|
+
if (_optionalChain([options, 'optionalAccess', _239 => _239.verify]) !== false) {
|
|
23436
23471
|
try {
|
|
23437
23472
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
23438
23473
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -23521,7 +23556,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
23521
23556
|
for (const [key, scanCell] of scanTable.cells) {
|
|
23522
23557
|
const comma = key.indexOf(",");
|
|
23523
23558
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
23524
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
23559
|
+
const irCell = _optionalChain([irTable, 'access', _240 => _240.cells, 'access', _241 => _241[r], 'optionalAccess', _242 => _242[c]]);
|
|
23525
23560
|
if (!irCell) continue;
|
|
23526
23561
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
23527
23562
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -23557,7 +23592,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
23557
23592
|
}
|
|
23558
23593
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
23559
23594
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
23560
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
23595
|
+
if (!_optionalChain([mapping, 'optionalAccess', _243 => _243.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
23561
23596
|
if (block.text && block.text.includes("\n")) {
|
|
23562
23597
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
23563
23598
|
}
|
|
@@ -23733,7 +23768,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
23733
23768
|
};
|
|
23734
23769
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
23735
23770
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
23736
|
-
const irCell = _optionalChain([table, 'access',
|
|
23771
|
+
const irCell = _optionalChain([table, 'access', _244 => _244.cells, 'access', _245 => _245[gridR], 'optionalAccess', _246 => _246[gridC]]);
|
|
23737
23772
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
23738
23773
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23739
23774
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -24008,7 +24043,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24008
24043
|
const block = st.blocks[blockIndex];
|
|
24009
24044
|
if (!block) return void 0;
|
|
24010
24045
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
24011
|
-
const para = _optionalChain([st, 'access',
|
|
24046
|
+
const para = _optionalChain([st, 'access', _247 => _247.paraMap, 'access', _248 => _248.get, 'call', _249 => _249(blockIndex), 'optionalAccess', _250 => _250.para]);
|
|
24012
24047
|
if (!para) return void 0;
|
|
24013
24048
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
24014
24049
|
}
|
|
@@ -24033,7 +24068,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24033
24068
|
if (block.text && block.text.includes("\n")) {
|
|
24034
24069
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
|
|
24035
24070
|
}
|
|
24036
|
-
if (!_optionalChain([st, 'access',
|
|
24071
|
+
if (!_optionalChain([st, 'access', _251 => _251.paraMap, 'access', _252 => _252.get, 'call', _253 => _253(blockIndex), 'optionalAccess', _254 => _254.para])) {
|
|
24037
24072
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
|
|
24038
24073
|
}
|
|
24039
24074
|
return { capability: "text" };
|
|
@@ -24099,7 +24134,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24099
24134
|
continue;
|
|
24100
24135
|
}
|
|
24101
24136
|
if (block.type === "table" && block.table) {
|
|
24102
|
-
if (!_optionalChain([edit, 'access',
|
|
24137
|
+
if (!_optionalChain([edit, 'access', _255 => _255.cells, 'optionalAccess', _256 => _256.length])) {
|
|
24103
24138
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
24104
24139
|
continue;
|
|
24105
24140
|
}
|
|
@@ -24119,7 +24154,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24119
24154
|
skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
|
|
24120
24155
|
continue;
|
|
24121
24156
|
}
|
|
24122
|
-
const irCell = _optionalChain([block, 'access',
|
|
24157
|
+
const irCell = _optionalChain([block, 'access', _257 => _257.table, 'access', _258 => _258.cells, 'access', _259 => _259[cellEdit.row], 'optionalAccess', _260 => _260[cellEdit.col]]);
|
|
24123
24158
|
if (!irCell) {
|
|
24124
24159
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
24125
24160
|
continue;
|
|
@@ -24175,7 +24210,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24175
24210
|
}
|
|
24176
24211
|
if (replacements.size === 0) {
|
|
24177
24212
|
let changes2;
|
|
24178
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24213
|
+
if (_optionalChain([options, 'optionalAccess', _261 => _261.verify]) !== false) {
|
|
24179
24214
|
const units = splitMarkdownUnits(st.markdown);
|
|
24180
24215
|
changes2 = diffUnitLists(units, units);
|
|
24181
24216
|
}
|
|
@@ -24196,7 +24231,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24196
24231
|
}
|
|
24197
24232
|
this.state = newState;
|
|
24198
24233
|
let changes;
|
|
24199
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24234
|
+
if (_optionalChain([options, 'optionalAccess', _262 => _262.verify]) !== false) {
|
|
24200
24235
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
24201
24236
|
}
|
|
24202
24237
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -24216,7 +24251,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24216
24251
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
24217
24252
|
}
|
|
24218
24253
|
const mapping = st.paraMap.get(blockIndex);
|
|
24219
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24254
|
+
if (!_optionalChain([mapping, 'optionalAccess', _263 => _263.para])) {
|
|
24220
24255
|
return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
24221
24256
|
}
|
|
24222
24257
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -24236,14 +24271,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
24236
24271
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24237
24272
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
24238
24273
|
}
|
|
24239
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
24274
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _264 => _264.scans, 'access', _265 => _265[mapping.para.sectionIndex], 'optionalAccess', _266 => _266.xml]));
|
|
24240
24275
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24241
24276
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24242
24277
|
return 1;
|
|
24243
24278
|
}
|
|
24244
24279
|
}, _class5);
|
|
24245
24280
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
24246
|
-
const irCell = _optionalChain([table, 'access',
|
|
24281
|
+
const irCell = _optionalChain([table, 'access', _267 => _267.cells, 'access', _268 => _268[r], 'optionalAccess', _269 => _269[c]]);
|
|
24247
24282
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
24248
24283
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
24249
24284
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -24327,11 +24362,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
24327
24362
|
breaks: false
|
|
24328
24363
|
});
|
|
24329
24364
|
function renderHtml(markdown, options) {
|
|
24330
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24331
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24365
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _270 => _270.preset]), () => ( "default"));
|
|
24366
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _271 => _271.extraCss]), () => ( "")));
|
|
24332
24367
|
const body = md.render(markdown);
|
|
24333
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
24334
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
24368
|
+
const watermark = _optionalChain([options, 'optionalAccess', _272 => _272.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
24369
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _273 => _273.watermark]) ? `
|
|
24335
24370
|
.watermark {
|
|
24336
24371
|
position: fixed;
|
|
24337
24372
|
top: 50%; left: 50%;
|
|
@@ -24362,13 +24397,13 @@ async function htmlToPdf(html, options) {
|
|
|
24362
24397
|
try {
|
|
24363
24398
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
24364
24399
|
} catch (e30) {
|
|
24365
|
-
throw new (0,
|
|
24400
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)(
|
|
24366
24401
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
24367
24402
|
);
|
|
24368
24403
|
}
|
|
24369
24404
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
24370
24405
|
if (!executablePath) {
|
|
24371
|
-
throw new (0,
|
|
24406
|
+
throw new (0, _chunkXL6O3VAYcjs.KordocError)(
|
|
24372
24407
|
"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."
|
|
24373
24408
|
);
|
|
24374
24409
|
}
|
|
@@ -24380,10 +24415,10 @@ async function htmlToPdf(html, options) {
|
|
|
24380
24415
|
try {
|
|
24381
24416
|
const page = await browser.newPage();
|
|
24382
24417
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
24383
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
24418
|
+
const margin = _optionalChain([options, 'optionalAccess', _274 => _274.margin]);
|
|
24384
24419
|
const pdf = await page.pdf({
|
|
24385
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24386
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
24420
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _275 => _275.pageSize]), () => ( "A4")),
|
|
24421
|
+
landscape: _optionalChain([options, 'optionalAccess', _276 => _276.orientation]) === "landscape",
|
|
24387
24422
|
printBackground: true,
|
|
24388
24423
|
margin: margin ? {
|
|
24389
24424
|
top: toCss(margin.top),
|
|
@@ -24391,9 +24426,9 @@ async function htmlToPdf(html, options) {
|
|
|
24391
24426
|
bottom: toCss(margin.bottom),
|
|
24392
24427
|
left: toCss(margin.left)
|
|
24393
24428
|
} : void 0,
|
|
24394
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
24395
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24396
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
24429
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _277 => _277.header]) || _optionalChain([options, 'optionalAccess', _278 => _278.footer])),
|
|
24430
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _279 => _279.header]), () => ( "<div></div>")),
|
|
24431
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _280 => _280.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
24397
24432
|
});
|
|
24398
24433
|
return Buffer.from(pdf);
|
|
24399
24434
|
} finally {
|
|
@@ -24427,24 +24462,24 @@ async function markdownToPdf(markdown, options) {
|
|
|
24427
24462
|
return htmlToPdf(html, options);
|
|
24428
24463
|
}
|
|
24429
24464
|
async function blocksToPdf(blocks, options) {
|
|
24430
|
-
const markdown =
|
|
24465
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, blocks);
|
|
24431
24466
|
return markdownToPdf(markdown, options);
|
|
24432
24467
|
}
|
|
24433
24468
|
|
|
24434
24469
|
// src/index.ts
|
|
24435
24470
|
async function parse(input, options) {
|
|
24436
24471
|
let buffer;
|
|
24437
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
24472
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _281 => _281.filePath]) ? { ...options, filePath: input } : options;
|
|
24438
24473
|
if (typeof input === "string") {
|
|
24439
24474
|
try {
|
|
24440
24475
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24441
|
-
buffer =
|
|
24476
|
+
buffer = _chunkXL6O3VAYcjs.toArrayBuffer.call(void 0, buf);
|
|
24442
24477
|
} catch (err) {
|
|
24443
24478
|
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}`;
|
|
24444
24479
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
24445
24480
|
}
|
|
24446
24481
|
} else if (Buffer.isBuffer(input)) {
|
|
24447
|
-
buffer =
|
|
24482
|
+
buffer = _chunkXL6O3VAYcjs.toArrayBuffer.call(void 0, input);
|
|
24448
24483
|
} else {
|
|
24449
24484
|
buffer = input;
|
|
24450
24485
|
}
|
|
@@ -24479,21 +24514,21 @@ async function parseHwp3(buffer, options) {
|
|
|
24479
24514
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
24480
24515
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
24481
24516
|
} catch (err) {
|
|
24482
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24517
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24483
24518
|
}
|
|
24484
24519
|
}
|
|
24485
24520
|
async function parseHwpx(buffer, options) {
|
|
24486
24521
|
try {
|
|
24487
24522
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
24488
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
24523
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _282 => _282.length]) ? images : void 0 };
|
|
24489
24524
|
} catch (err) {
|
|
24490
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24525
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24491
24526
|
}
|
|
24492
24527
|
}
|
|
24493
24528
|
async function parseHwp(buffer, options) {
|
|
24494
24529
|
try {
|
|
24495
24530
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
24496
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
24531
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _283 => _283.filePath])) {
|
|
24497
24532
|
try {
|
|
24498
24533
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
24499
24534
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -24510,15 +24545,15 @@ async function parseHwp(buffer, options) {
|
|
|
24510
24545
|
} catch (e31) {
|
|
24511
24546
|
}
|
|
24512
24547
|
}
|
|
24513
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
24548
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _284 => _284.length]) ? images : void 0 };
|
|
24514
24549
|
} catch (err) {
|
|
24515
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24550
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24516
24551
|
}
|
|
24517
24552
|
}
|
|
24518
24553
|
async function parsePdf(buffer, options) {
|
|
24519
24554
|
let parsePdfDocument;
|
|
24520
24555
|
try {
|
|
24521
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
24556
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-WWKYMRGJ.cjs")));
|
|
24522
24557
|
parsePdfDocument = mod.parsePdfDocument;
|
|
24523
24558
|
} catch (e32) {
|
|
24524
24559
|
return {
|
|
@@ -24533,7 +24568,7 @@ async function parsePdf(buffer, options) {
|
|
|
24533
24568
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
24534
24569
|
} catch (err) {
|
|
24535
24570
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
24536
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24571
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err), isImageBased };
|
|
24537
24572
|
}
|
|
24538
24573
|
}
|
|
24539
24574
|
async function parseXlsx(buffer, options) {
|
|
@@ -24541,7 +24576,7 @@ async function parseXlsx(buffer, options) {
|
|
|
24541
24576
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
24542
24577
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
24543
24578
|
} catch (err) {
|
|
24544
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24579
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24545
24580
|
}
|
|
24546
24581
|
}
|
|
24547
24582
|
async function parseXls(buffer, options) {
|
|
@@ -24549,15 +24584,15 @@ async function parseXls(buffer, options) {
|
|
|
24549
24584
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
24550
24585
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
24551
24586
|
} catch (err) {
|
|
24552
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24587
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24553
24588
|
}
|
|
24554
24589
|
}
|
|
24555
24590
|
async function parseDocx(buffer, options) {
|
|
24556
24591
|
try {
|
|
24557
24592
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
24558
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
24593
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _285 => _285.length]) ? images : void 0 };
|
|
24559
24594
|
} catch (err) {
|
|
24560
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24595
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24561
24596
|
}
|
|
24562
24597
|
}
|
|
24563
24598
|
async function parseHwpml(buffer, options) {
|
|
@@ -24565,16 +24600,16 @@ async function parseHwpml(buffer, options) {
|
|
|
24565
24600
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
24566
24601
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
24567
24602
|
} catch (err) {
|
|
24568
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
24603
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkXL6O3VAYcjs.classifyError.call(void 0, err) };
|
|
24569
24604
|
}
|
|
24570
24605
|
}
|
|
24571
24606
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
24572
24607
|
let buffer;
|
|
24573
24608
|
if (typeof input === "string") {
|
|
24574
24609
|
const buf = await _promises.readFile.call(void 0, input);
|
|
24575
|
-
buffer =
|
|
24610
|
+
buffer = _chunkXL6O3VAYcjs.toArrayBuffer.call(void 0, buf);
|
|
24576
24611
|
} else if (Buffer.isBuffer(input)) {
|
|
24577
|
-
buffer =
|
|
24612
|
+
buffer = _chunkXL6O3VAYcjs.toArrayBuffer.call(void 0, input);
|
|
24578
24613
|
} else {
|
|
24579
24614
|
buffer = input;
|
|
24580
24615
|
}
|
|
@@ -24600,7 +24635,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24600
24635
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
24601
24636
|
}
|
|
24602
24637
|
const fill = fillFormFields(parsed.blocks, values);
|
|
24603
|
-
const markdown =
|
|
24638
|
+
const markdown = _chunkXL6O3VAYcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
24604
24639
|
if (outputFormat === "hwpx") {
|
|
24605
24640
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
24606
24641
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -24658,5 +24693,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
24658
24693
|
|
|
24659
24694
|
|
|
24660
24695
|
|
|
24661
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
24696
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkXL6O3VAYcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkXL6O3VAYcjs.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;
|
|
24662
24697
|
//# sourceMappingURL=index.cjs.map
|