kordoc 3.16.2 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -12
- package/dist/{-C4FVXHIP.js → -OUCPI6B3.js} +9 -7
- package/dist/{chunk-HECUYZZK.js → chunk-4YEZTZAR.js} +79 -3
- package/dist/chunk-4YEZTZAR.js.map +1 -0
- package/dist/{chunk-72LLOLFX.cjs → chunk-5HDBLRVP.cjs} +45 -9
- package/dist/chunk-5HDBLRVP.cjs.map +1 -0
- package/dist/{chunk-4WI7QXEG.js → chunk-6Y4KKPC3.js} +2 -2
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-EJ2ZIYTO.js → chunk-GIXXV52X.js} +39 -3
- package/dist/chunk-GIXXV52X.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-EUEKDZ7O.js → chunk-PWHM3KAA.js} +535 -83
- package/dist/chunk-PWHM3KAA.js.map +1 -0
- package/dist/{chunk-WR5LHRXO.js → chunk-VP34RO24.js} +3 -3
- package/dist/{chunk-IS3IK7UT.js → chunk-YWIYGXLI.js} +39 -3
- package/dist/chunk-YWIYGXLI.js.map +1 -0
- package/dist/{chunk-E4Y73XRH.js → chunk-ZTUQYITH.js} +127 -68
- package/dist/chunk-ZTUQYITH.js.map +1 -0
- package/dist/cli.js +18 -15
- package/dist/cli.js.map +1 -1
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/index.cjs +1045 -459
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -3
- package/dist/index.d.ts +121 -3
- package/dist/index.js +784 -198
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -10
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-GWL72XYS.js → parser-5D6BQYTX.js} +2 -2
- package/dist/{parser-CMPNM6ZL.js → parser-NZAE7PBE.js} +3 -3
- package/dist/{parser-YVRTKGKO.cjs → parser-S34YR2SH.cjs} +14 -14
- package/dist/parser-S34YR2SH.cjs.map +1 -0
- package/dist/provider-G4C2V2PD.cjs.map +1 -1
- package/dist/render-HRAW7ASR.js +10 -0
- package/dist/seal-CK64CXWO.js +10 -0
- package/dist/{watch-WLI6K3IR.js → watch-2EFXBRYK.js} +7 -7
- package/package.json +1 -1
- package/dist/chunk-72LLOLFX.cjs.map +0 -1
- package/dist/chunk-E4Y73XRH.js.map +0 -1
- package/dist/chunk-EJ2ZIYTO.js.map +0 -1
- package/dist/chunk-EUEKDZ7O.js.map +0 -1
- package/dist/chunk-HECUYZZK.js.map +0 -1
- package/dist/chunk-IS3IK7UT.js.map +0 -1
- package/dist/parser-YVRTKGKO.cjs.map +0 -1
- package/dist/render-A2LFMJCP.js +0 -10
- package/dist/seal-KA4VAV2Z.js +0 -10
- /package/dist/{-C4FVXHIP.js.map → -OUCPI6B3.js.map} +0 -0
- /package/dist/{chunk-4WI7QXEG.js.map → chunk-6Y4KKPC3.js.map} +0 -0
- /package/dist/{chunk-WR5LHRXO.js.map → chunk-VP34RO24.js.map} +0 -0
- /package/dist/{parser-GWL72XYS.js.map → parser-5D6BQYTX.js.map} +0 -0
- /package/dist/{parser-CMPNM6ZL.js.map → parser-NZAE7PBE.js.map} +0 -0
- /package/dist/{render-A2LFMJCP.js.map → render-HRAW7ASR.js.map} +0 -0
- /package/dist/{seal-KA4VAV2Z.js.map → seal-CK64CXWO.js.map} +0 -0
- /package/dist/{watch-WLI6K3IR.js.map → watch-2EFXBRYK.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
var _chunk5HDBLRVPcjs = require('./chunk-5HDBLRVP.cjs');
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -405,7 +406,7 @@ function createSectionShared() {
|
|
|
405
406
|
function createXmlParser(warnings) {
|
|
406
407
|
return new (0, _xmldom.DOMParser)({
|
|
407
408
|
onError(level, msg2) {
|
|
408
|
-
if (level === "fatalError") throw new (0,
|
|
409
|
+
if (level === "fatalError") throw new (0, _chunk5HDBLRVPcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
409
410
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
410
411
|
}
|
|
411
412
|
});
|
|
@@ -460,10 +461,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
460
461
|
const xml = await file.async("text");
|
|
461
462
|
if (decompressed) {
|
|
462
463
|
decompressed.total += xml.length * 2;
|
|
463
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
464
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
464
465
|
}
|
|
465
466
|
const parser = createXmlParser();
|
|
466
|
-
const doc = parser.parseFromString(
|
|
467
|
+
const doc = parser.parseFromString(_chunk5HDBLRVPcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
467
468
|
if (!doc.documentElement) continue;
|
|
468
469
|
parseCharProperties(doc, result.charProperties);
|
|
469
470
|
parseStyleElements(doc, result.styles);
|
|
@@ -615,9 +616,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
615
616
|
let level = 0;
|
|
616
617
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
|
|
617
618
|
const ratio = block.style.fontSize / baseFontSize;
|
|
618
|
-
if (ratio >=
|
|
619
|
-
else if (ratio >=
|
|
620
|
-
else if (ratio >=
|
|
619
|
+
if (ratio >= _chunk5HDBLRVPcjs.HEADING_RATIO_H1) level = 1;
|
|
620
|
+
else if (ratio >= _chunk5HDBLRVPcjs.HEADING_RATIO_H2) level = 2;
|
|
621
|
+
else if (ratio >= _chunk5HDBLRVPcjs.HEADING_RATIO_H3) level = 3;
|
|
621
622
|
}
|
|
622
623
|
const compactText = text.replace(/\s+/g, "");
|
|
623
624
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1194,7 +1195,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1194
1195
|
|
|
1195
1196
|
// src/hwpx/table-build.ts
|
|
1196
1197
|
function buildTableWithCellMeta(state) {
|
|
1197
|
-
const table =
|
|
1198
|
+
const table = _chunk5HDBLRVPcjs.buildTable.call(void 0, state.rows);
|
|
1198
1199
|
if (state.caption) table.caption = state.caption;
|
|
1199
1200
|
const anchors = [];
|
|
1200
1201
|
{
|
|
@@ -1264,7 +1265,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1264
1265
|
const cell = parentTable.cell;
|
|
1265
1266
|
(cell.blocks ??= []).push(block);
|
|
1266
1267
|
cell.hasStructure = true;
|
|
1267
|
-
let flat =
|
|
1268
|
+
let flat = _chunk5HDBLRVPcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1268
1269
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1269
1270
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1270
1271
|
} else {
|
|
@@ -1276,7 +1277,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1276
1277
|
// src/hwpx/section-walker.ts
|
|
1277
1278
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1278
1279
|
const parser = createXmlParser(warnings);
|
|
1279
|
-
const doc = parser.parseFromString(
|
|
1280
|
+
const doc = parser.parseFromString(_chunk5HDBLRVPcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1280
1281
|
if (!doc.documentElement) return [];
|
|
1281
1282
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1282
1283
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1367,8 +1368,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1367
1368
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1368
1369
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1369
1370
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1370
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1371
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1371
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunk5HDBLRVPcjs.MAX_COLS);
|
|
1372
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunk5HDBLRVPcjs.MAX_ROWS);
|
|
1372
1373
|
}
|
|
1373
1374
|
break;
|
|
1374
1375
|
case "p": {
|
|
@@ -1590,7 +1591,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1590
1591
|
let url = (ch.textContent || "").trim();
|
|
1591
1592
|
if (!url) continue;
|
|
1592
1593
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1593
|
-
const safe =
|
|
1594
|
+
const safe = _chunk5HDBLRVPcjs.sanitizeHref.call(void 0, url);
|
|
1594
1595
|
if (safe) return safe;
|
|
1595
1596
|
}
|
|
1596
1597
|
return void 0;
|
|
@@ -1725,7 +1726,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1725
1726
|
case "hyperlink": {
|
|
1726
1727
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1727
1728
|
if (url) {
|
|
1728
|
-
const safe =
|
|
1729
|
+
const safe = _chunk5HDBLRVPcjs.sanitizeHref.call(void 0, url);
|
|
1729
1730
|
if (safe) href = safe;
|
|
1730
1731
|
}
|
|
1731
1732
|
walk(child);
|
|
@@ -1911,13 +1912,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1911
1912
|
}
|
|
1912
1913
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1913
1914
|
for (const path of allCandidates) {
|
|
1914
|
-
if (
|
|
1915
|
+
if (_chunk5HDBLRVPcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1915
1916
|
const file = zip.file(path);
|
|
1916
1917
|
if (!file) continue;
|
|
1917
1918
|
try {
|
|
1918
1919
|
const data = await file.async("uint8array");
|
|
1919
1920
|
decompressed.total += data.length;
|
|
1920
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1921
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1921
1922
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1922
1923
|
const mimeType = imageExtToMime(ext);
|
|
1923
1924
|
imageIndex++;
|
|
@@ -1926,7 +1927,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1926
1927
|
images.push(img);
|
|
1927
1928
|
break;
|
|
1928
1929
|
} catch (err) {
|
|
1929
|
-
if (err instanceof
|
|
1930
|
+
if (err instanceof _chunk5HDBLRVPcjs.KordocError) throw err;
|
|
1930
1931
|
}
|
|
1931
1932
|
}
|
|
1932
1933
|
if (!img) _optionalChain([warnings, 'optionalAccess', _38 => _38.push, 'call', _39 => _39({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -1988,7 +1989,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1988
1989
|
}
|
|
1989
1990
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1990
1991
|
const name = new TextDecoder().decode(nameBytes);
|
|
1991
|
-
if (
|
|
1992
|
+
if (_chunk5HDBLRVPcjs.isPathTraversal.call(void 0, name)) {
|
|
1992
1993
|
pos = fileStart + compSize;
|
|
1993
1994
|
continue;
|
|
1994
1995
|
}
|
|
@@ -2006,16 +2007,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2006
2007
|
continue;
|
|
2007
2008
|
}
|
|
2008
2009
|
totalDecompressed += content.length * 2;
|
|
2009
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2010
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2010
2011
|
sectionNum++;
|
|
2011
2012
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2012
2013
|
} catch (e13) {
|
|
2013
2014
|
continue;
|
|
2014
2015
|
}
|
|
2015
2016
|
}
|
|
2016
|
-
if (blocks.length === 0) throw new (0,
|
|
2017
|
+
if (blocks.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2017
2018
|
applyPageText(blocks, shared);
|
|
2018
|
-
const markdown =
|
|
2019
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2019
2020
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2020
2021
|
}
|
|
2021
2022
|
async function resolveSectionPaths(zip) {
|
|
@@ -2029,18 +2030,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2029
2030
|
if (paths.length > 0) return paths;
|
|
2030
2031
|
}
|
|
2031
2032
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2032
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2033
|
+
return sectionFiles.map((f) => f.name).sort(_chunk5HDBLRVPcjs.compareSectionPaths);
|
|
2033
2034
|
}
|
|
2034
2035
|
function parseSectionPathsFromManifest(xml) {
|
|
2035
2036
|
const parser = createXmlParser();
|
|
2036
|
-
const doc = parser.parseFromString(
|
|
2037
|
+
const doc = parser.parseFromString(_chunk5HDBLRVPcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2037
2038
|
const items = doc.getElementsByTagName("opf:item");
|
|
2038
2039
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2039
2040
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2040
2041
|
for (let i = 0; i < items.length; i++) {
|
|
2041
2042
|
const item = items[i];
|
|
2042
2043
|
const id = item.getAttribute("id") || "";
|
|
2043
|
-
const href =
|
|
2044
|
+
const href = _chunk5HDBLRVPcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2044
2045
|
if (id && href) idToHref.set(id, href);
|
|
2045
2046
|
}
|
|
2046
2047
|
if (spine.length > 0) {
|
|
@@ -2051,7 +2052,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2051
2052
|
}
|
|
2052
2053
|
if (ordered.length > 0) return ordered;
|
|
2053
2054
|
}
|
|
2054
|
-
return Array.from(idToHref.values()).sort(
|
|
2055
|
+
return Array.from(idToHref.values()).sort(_chunk5HDBLRVPcjs.compareSectionPaths);
|
|
2055
2056
|
}
|
|
2056
2057
|
|
|
2057
2058
|
// src/hwpx/metadata.ts
|
|
@@ -2064,7 +2065,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2064
2065
|
const xml = await file.async("text");
|
|
2065
2066
|
if (decompressed) {
|
|
2066
2067
|
decompressed.total += xml.length * 2;
|
|
2067
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2068
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2068
2069
|
}
|
|
2069
2070
|
parseDublinCoreMetadata(xml, metadata);
|
|
2070
2071
|
if (metadata.title || metadata.author) return;
|
|
@@ -2074,7 +2075,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2074
2075
|
}
|
|
2075
2076
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2076
2077
|
const parser = createXmlParser();
|
|
2077
|
-
const doc = parser.parseFromString(
|
|
2078
|
+
const doc = parser.parseFromString(_chunk5HDBLRVPcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2078
2079
|
if (!doc.documentElement) return;
|
|
2079
2080
|
const getText = (tagNames) => {
|
|
2080
2081
|
for (const tag of tagNames) {
|
|
@@ -2099,7 +2100,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2099
2100
|
|
|
2100
2101
|
// src/hwpx/parser.ts
|
|
2101
2102
|
async function parseHwpxDocument(buffer, options) {
|
|
2102
|
-
|
|
2103
|
+
_chunk5HDBLRVPcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2103
2104
|
let zip;
|
|
2104
2105
|
try {
|
|
2105
2106
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2108,7 +2109,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2108
2109
|
}
|
|
2109
2110
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2110
2111
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2111
|
-
throw new (0,
|
|
2112
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2112
2113
|
}
|
|
2113
2114
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2114
2115
|
if (manifestFile) {
|
|
@@ -2120,7 +2121,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2120
2121
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2121
2122
|
}
|
|
2122
2123
|
}
|
|
2123
|
-
throw new (0,
|
|
2124
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
2124
2125
|
}
|
|
2125
2126
|
}
|
|
2126
2127
|
const decompressed = { total: 0 };
|
|
@@ -2129,7 +2130,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2129
2130
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2130
2131
|
const warnings = [];
|
|
2131
2132
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2132
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2133
|
+
if (sectionPaths.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2133
2134
|
metadata.pageCount = sectionPaths.length;
|
|
2134
2135
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2135
2136
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2143,12 +2144,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2143
2144
|
try {
|
|
2144
2145
|
const xml = await file.async("text");
|
|
2145
2146
|
decompressed.total += xml.length * 2;
|
|
2146
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2147
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2147
2148
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2148
2149
|
parsedSections++;
|
|
2149
2150
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2150
2151
|
} catch (secErr) {
|
|
2151
|
-
if (secErr instanceof
|
|
2152
|
+
if (secErr instanceof _chunk5HDBLRVPcjs.KordocError) throw secErr;
|
|
2152
2153
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
2153
2154
|
}
|
|
2154
2155
|
}
|
|
@@ -2156,7 +2157,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2156
2157
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2157
2158
|
detectHwpxHeadings(blocks, styleMap);
|
|
2158
2159
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2159
|
-
const markdown =
|
|
2160
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2160
2161
|
return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
2161
2162
|
}
|
|
2162
2163
|
|
|
@@ -2223,7 +2224,7 @@ function decompressStream(data) {
|
|
|
2223
2224
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2224
2225
|
}
|
|
2225
2226
|
function parseFileHeader(data) {
|
|
2226
|
-
if (data.length < 40) throw new (0,
|
|
2227
|
+
if (data.length < 40) throw new (0, _chunk5HDBLRVPcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2227
2228
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2228
2229
|
return {
|
|
2229
2230
|
signature: sig,
|
|
@@ -2530,11 +2531,11 @@ function formatRoman(n, upper) {
|
|
|
2530
2531
|
const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
|
|
2531
2532
|
const symbols = upper ? ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] : ["m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"];
|
|
2532
2533
|
let result = "";
|
|
2533
|
-
let
|
|
2534
|
+
let num4 = n;
|
|
2534
2535
|
for (let i = 0; i < values.length; i++) {
|
|
2535
|
-
while (
|
|
2536
|
+
while (num4 >= values[i]) {
|
|
2536
2537
|
result += symbols[i];
|
|
2537
|
-
|
|
2538
|
+
num4 -= values[i];
|
|
2538
2539
|
}
|
|
2539
2540
|
}
|
|
2540
2541
|
return result;
|
|
@@ -2542,11 +2543,11 @@ function formatRoman(n, upper) {
|
|
|
2542
2543
|
function formatLatin(n, upper) {
|
|
2543
2544
|
if (n <= 0) return "";
|
|
2544
2545
|
let result = "";
|
|
2545
|
-
let
|
|
2546
|
-
while (
|
|
2547
|
-
|
|
2548
|
-
result = String.fromCharCode((upper ? 65 : 97) +
|
|
2549
|
-
|
|
2546
|
+
let num4 = n;
|
|
2547
|
+
while (num4 > 0) {
|
|
2548
|
+
num4--;
|
|
2549
|
+
result = String.fromCharCode((upper ? 65 : 97) + num4 % 26) + result;
|
|
2550
|
+
num4 = Math.floor(num4 / 26);
|
|
2550
2551
|
}
|
|
2551
2552
|
return result;
|
|
2552
2553
|
}
|
|
@@ -2554,15 +2555,15 @@ function formatEastAsianNumber(n, digits, units, zero) {
|
|
|
2554
2555
|
if (n === 0) return zero;
|
|
2555
2556
|
if (n < 0 || n > 99999) return String(n);
|
|
2556
2557
|
let result = "";
|
|
2557
|
-
let
|
|
2558
|
+
let num4 = n;
|
|
2558
2559
|
let unit = 0;
|
|
2559
|
-
while (
|
|
2560
|
-
const d =
|
|
2560
|
+
while (num4 > 0) {
|
|
2561
|
+
const d = num4 % 10;
|
|
2561
2562
|
if (d > 0) {
|
|
2562
2563
|
const digitStr = d === 1 && unit > 0 ? "" : digits[d];
|
|
2563
2564
|
result = digitStr + units[unit] + result;
|
|
2564
2565
|
}
|
|
2565
|
-
|
|
2566
|
+
num4 = Math.floor(num4 / 10);
|
|
2566
2567
|
unit++;
|
|
2567
2568
|
}
|
|
2568
2569
|
return result;
|
|
@@ -2609,8 +2610,8 @@ function expandNumberingFormat(formatStr, counters, numbering) {
|
|
|
2609
2610
|
const idx = levelRef - 1;
|
|
2610
2611
|
const counterVal = _nullishCoalesce(counters[idx], () => ( 0));
|
|
2611
2612
|
const start = _nullishCoalesce(numbering.startNumbers[idx], () => ( 1));
|
|
2612
|
-
const
|
|
2613
|
-
result += formatNumber(
|
|
2613
|
+
const num4 = counterVal > 0 ? start - 1 + counterVal : start;
|
|
2614
|
+
result += formatNumber(num4, headFormatToNumFmt(_nullishCoalesce(numbering.numberFormats[idx], () => ( 0))));
|
|
2614
2615
|
i += 2;
|
|
2615
2616
|
continue;
|
|
2616
2617
|
}
|
|
@@ -2759,6 +2760,141 @@ function extractHwp5ImagesLenient(lcfb, blocks, warnings) {
|
|
|
2759
2760
|
return resolveImageBlocks(binDataMap, blocks, warnings);
|
|
2760
2761
|
}
|
|
2761
2762
|
|
|
2763
|
+
// src/image/transcode.ts
|
|
2764
|
+
|
|
2765
|
+
var CRC_TABLE = (() => {
|
|
2766
|
+
const table = new Uint32Array(256);
|
|
2767
|
+
for (let n = 0; n < 256; n++) {
|
|
2768
|
+
let c = n;
|
|
2769
|
+
for (let k = 0; k < 8; k++) {
|
|
2770
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
2771
|
+
}
|
|
2772
|
+
table[n] = c >>> 0;
|
|
2773
|
+
}
|
|
2774
|
+
return table;
|
|
2775
|
+
})();
|
|
2776
|
+
function crc32(bytes) {
|
|
2777
|
+
let c = 4294967295;
|
|
2778
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
2779
|
+
c = CRC_TABLE[(c ^ bytes[i]) & 255] ^ c >>> 8;
|
|
2780
|
+
}
|
|
2781
|
+
return (c ^ 4294967295) >>> 0;
|
|
2782
|
+
}
|
|
2783
|
+
var BI_RGB = 0;
|
|
2784
|
+
var MAX_DIM = 32767;
|
|
2785
|
+
var MAX_PIXELS = 64e6;
|
|
2786
|
+
function bmpToPng(bmp) {
|
|
2787
|
+
if (bmp.length < 54) return null;
|
|
2788
|
+
if (bmp[0] !== 66 || bmp[1] !== 77) return null;
|
|
2789
|
+
const dv = new DataView(bmp.buffer, bmp.byteOffset, bmp.byteLength);
|
|
2790
|
+
const dataOffset = dv.getUint32(10, true);
|
|
2791
|
+
const headerSize = dv.getUint32(14, true);
|
|
2792
|
+
if (headerSize < 40) return null;
|
|
2793
|
+
const width = dv.getInt32(18, true);
|
|
2794
|
+
const rawHeight = dv.getInt32(22, true);
|
|
2795
|
+
const bitCount = dv.getUint16(28, true);
|
|
2796
|
+
const compression = dv.getUint32(30, true);
|
|
2797
|
+
if (compression !== BI_RGB) return null;
|
|
2798
|
+
if (bitCount !== 24 && bitCount !== 32) return null;
|
|
2799
|
+
if (width <= 0 || rawHeight === 0) return null;
|
|
2800
|
+
if (width > MAX_DIM || Math.abs(rawHeight) > MAX_DIM) return null;
|
|
2801
|
+
const topDown = rawHeight < 0;
|
|
2802
|
+
const height = Math.abs(rawHeight);
|
|
2803
|
+
if (width * height > MAX_PIXELS) return null;
|
|
2804
|
+
const bytesPerPixel = bitCount >> 3;
|
|
2805
|
+
const rowStride = width * bytesPerPixel + 3 & ~3;
|
|
2806
|
+
if (dataOffset + rowStride * height > bmp.length) return null;
|
|
2807
|
+
const rgba = new Uint8Array(width * height * 4);
|
|
2808
|
+
let anyAlpha = 0;
|
|
2809
|
+
for (let y = 0; y < height; y++) {
|
|
2810
|
+
const srcRow = topDown ? y : height - 1 - y;
|
|
2811
|
+
let src = dataOffset + srcRow * rowStride;
|
|
2812
|
+
let dst = y * width * 4;
|
|
2813
|
+
for (let x = 0; x < width; x++) {
|
|
2814
|
+
rgba[dst] = bmp[src + 2];
|
|
2815
|
+
rgba[dst + 1] = bmp[src + 1];
|
|
2816
|
+
rgba[dst + 2] = bmp[src];
|
|
2817
|
+
const a = bitCount === 32 ? bmp[src + 3] : 255;
|
|
2818
|
+
rgba[dst + 3] = a;
|
|
2819
|
+
anyAlpha |= a;
|
|
2820
|
+
src += bytesPerPixel;
|
|
2821
|
+
dst += 4;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
if (bitCount === 32 && anyAlpha === 0) {
|
|
2825
|
+
for (let i = 3; i < rgba.length; i += 4) rgba[i] = 255;
|
|
2826
|
+
}
|
|
2827
|
+
return encodePng(width, height, rgba);
|
|
2828
|
+
}
|
|
2829
|
+
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
2830
|
+
function chunk(type, data) {
|
|
2831
|
+
const body = new Uint8Array(4 + data.length);
|
|
2832
|
+
body[0] = type.charCodeAt(0);
|
|
2833
|
+
body[1] = type.charCodeAt(1);
|
|
2834
|
+
body[2] = type.charCodeAt(2);
|
|
2835
|
+
body[3] = type.charCodeAt(3);
|
|
2836
|
+
body.set(data, 4);
|
|
2837
|
+
const out = new Uint8Array(8 + data.length + 4);
|
|
2838
|
+
const dv = new DataView(out.buffer);
|
|
2839
|
+
dv.setUint32(0, data.length, false);
|
|
2840
|
+
out.set(body, 4);
|
|
2841
|
+
dv.setUint32(8 + data.length, crc32(body), false);
|
|
2842
|
+
return out;
|
|
2843
|
+
}
|
|
2844
|
+
function encodePng(width, height, rgba) {
|
|
2845
|
+
const ihdr = new Uint8Array(13);
|
|
2846
|
+
const iv = new DataView(ihdr.buffer);
|
|
2847
|
+
iv.setUint32(0, width, false);
|
|
2848
|
+
iv.setUint32(4, height, false);
|
|
2849
|
+
ihdr[8] = 8;
|
|
2850
|
+
ihdr[9] = 6;
|
|
2851
|
+
const stride = width * 4;
|
|
2852
|
+
const raw = new Uint8Array((stride + 1) * height);
|
|
2853
|
+
for (let y = 0; y < height; y++) {
|
|
2854
|
+
const rowStart = y * (stride + 1);
|
|
2855
|
+
raw[rowStart] = 0;
|
|
2856
|
+
raw.set(rgba.subarray(y * stride, y * stride + stride), rowStart + 1);
|
|
2857
|
+
}
|
|
2858
|
+
const idat = _zlib.deflateSync.call(void 0, raw);
|
|
2859
|
+
const ihdrChunk = chunk("IHDR", ihdr);
|
|
2860
|
+
const idatChunk = chunk("IDAT", idat);
|
|
2861
|
+
const iendChunk = chunk("IEND", new Uint8Array(0));
|
|
2862
|
+
const out = new Uint8Array(PNG_SIGNATURE.length + ihdrChunk.length + idatChunk.length + iendChunk.length);
|
|
2863
|
+
let o = 0;
|
|
2864
|
+
out.set(PNG_SIGNATURE, o);
|
|
2865
|
+
o += PNG_SIGNATURE.length;
|
|
2866
|
+
out.set(ihdrChunk, o);
|
|
2867
|
+
o += ihdrChunk.length;
|
|
2868
|
+
out.set(idatChunk, o);
|
|
2869
|
+
o += idatChunk.length;
|
|
2870
|
+
out.set(iendChunk, o);
|
|
2871
|
+
return out;
|
|
2872
|
+
}
|
|
2873
|
+
var MAX_INLINE_MD_BYTES = 4 * 1024 * 1024;
|
|
2874
|
+
function escapeRegExp(s) {
|
|
2875
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2876
|
+
}
|
|
2877
|
+
function inlineImagesIntoMarkdown(markdown, images, opts) {
|
|
2878
|
+
const compress = _optionalChain([opts, 'optionalAccess', _50 => _50.compress]) !== false;
|
|
2879
|
+
let out = markdown;
|
|
2880
|
+
for (const img of images) {
|
|
2881
|
+
let bytes = img.data;
|
|
2882
|
+
let mime = img.mimeType;
|
|
2883
|
+
if (compress && mime === "image/bmp") {
|
|
2884
|
+
const png = bmpToPng(img.data);
|
|
2885
|
+
if (png) {
|
|
2886
|
+
bytes = png;
|
|
2887
|
+
mime = "image/png";
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
const base64 = Buffer.from(bytes).toString("base64");
|
|
2891
|
+
const dataUri = `data:${mime};base64,${base64}`;
|
|
2892
|
+
const re = new RegExp(`!\\[image\\]\\((?:images/)?${escapeRegExp(img.filename)}\\)`, "g");
|
|
2893
|
+
out = out.replace(re, () => ``);
|
|
2894
|
+
}
|
|
2895
|
+
return out;
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2762
2898
|
// src/hwp5/aes.ts
|
|
2763
2899
|
var S_BOX = new Uint8Array([
|
|
2764
2900
|
99,
|
|
@@ -3756,22 +3892,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3756
3892
|
lenientCfb = parseLenientCfb(buffer);
|
|
3757
3893
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3758
3894
|
} catch (e21) {
|
|
3759
|
-
throw new (0,
|
|
3895
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3760
3896
|
}
|
|
3761
3897
|
}
|
|
3762
3898
|
const findStream = (path) => {
|
|
3763
3899
|
if (cfb) {
|
|
3764
3900
|
const entry = CFB.find(cfb, path);
|
|
3765
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
3901
|
+
return _optionalChain([entry, 'optionalAccess', _51 => _51.content]) ? Buffer.from(entry.content) : null;
|
|
3766
3902
|
}
|
|
3767
3903
|
return lenientCfb.findStream(path);
|
|
3768
3904
|
};
|
|
3769
3905
|
const headerData = findStream("/FileHeader");
|
|
3770
|
-
if (!headerData) throw new (0,
|
|
3906
|
+
if (!headerData) throw new (0, _chunk5HDBLRVPcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3771
3907
|
const header = parseFileHeader(headerData);
|
|
3772
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3773
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3774
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3908
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunk5HDBLRVPcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3909
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3910
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunk5HDBLRVPcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3775
3911
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3776
3912
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3777
3913
|
const metadata = {
|
|
@@ -3780,9 +3916,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
3780
3916
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3781
3917
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3782
3918
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3783
|
-
if (sections.length === 0) throw new (0,
|
|
3919
|
+
if (sections.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3784
3920
|
metadata.pageCount = sections.length;
|
|
3785
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3921
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _52 => _52.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3786
3922
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
3787
3923
|
const bodyBlocks = [];
|
|
3788
3924
|
const doc = createHwp5DocState();
|
|
@@ -3794,31 +3930,44 @@ function parseHwp5Document(buffer, options) {
|
|
|
3794
3930
|
const sectionData = sections[si];
|
|
3795
3931
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3796
3932
|
totalDecompressed += data.length;
|
|
3797
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3933
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3798
3934
|
const records = readRecords(data);
|
|
3799
3935
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3800
3936
|
bodyBlocks.push(...sectionBlocks);
|
|
3801
3937
|
parsedSections++;
|
|
3802
|
-
_optionalChain([options, 'optionalAccess',
|
|
3938
|
+
_optionalChain([options, 'optionalAccess', _53 => _53.onProgress, 'optionalCall', _54 => _54(parsedSections, totalTarget)]);
|
|
3803
3939
|
} catch (secErr) {
|
|
3804
|
-
if (secErr instanceof
|
|
3940
|
+
if (secErr instanceof _chunk5HDBLRVPcjs.KordocError) throw secErr;
|
|
3805
3941
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3806
3942
|
}
|
|
3807
3943
|
}
|
|
3808
3944
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3809
3945
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3810
|
-
|
|
3946
|
+
let flatBlocks = _chunk5HDBLRVPcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3947
|
+
if (_optionalChain([options, 'optionalAccess', _55 => _55.dedupeRunningHeaders])) {
|
|
3948
|
+
const deduped = _chunk5HDBLRVPcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
3949
|
+
const removed = flatBlocks.length - deduped.length;
|
|
3950
|
+
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
3951
|
+
flatBlocks = deduped;
|
|
3952
|
+
}
|
|
3811
3953
|
if (docInfo) {
|
|
3812
3954
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3813
3955
|
}
|
|
3814
3956
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3815
|
-
|
|
3957
|
+
let markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3958
|
+
if (_optionalChain([options, 'optionalAccess', _56 => _56.inlineImages]) && images.length > 0) {
|
|
3959
|
+
try {
|
|
3960
|
+
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
3961
|
+
} catch (inlineErr) {
|
|
3962
|
+
warnings.push({ message: `\uC774\uBBF8\uC9C0 \uC778\uB77C\uC778 \uC2E4\uD328 \u2014 \uC6D0\uBCF8 \uD30C\uC77C \uCC38\uC870\uB85C \uD3F4\uBC31: ${inlineErr instanceof Error ? inlineErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "SKIPPED_IMAGE" });
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3816
3965
|
return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3817
3966
|
}
|
|
3818
3967
|
function parseDocInfoStream(cfb, compressed) {
|
|
3819
3968
|
try {
|
|
3820
3969
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
3821
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3970
|
+
if (!_optionalChain([entry, 'optionalAccess', _57 => _57.content])) return null;
|
|
3822
3971
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
3823
3972
|
const records = readRecords(data);
|
|
3824
3973
|
return parseDocInfo(records);
|
|
@@ -3839,7 +3988,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3839
3988
|
let baseFontSize = 0;
|
|
3840
3989
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
3841
3990
|
for (const b of blocks) {
|
|
3842
|
-
if (_optionalChain([b, 'access',
|
|
3991
|
+
if (_optionalChain([b, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && b.text) {
|
|
3843
3992
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
3844
3993
|
}
|
|
3845
3994
|
}
|
|
@@ -3855,7 +4004,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3855
4004
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
3856
4005
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
3857
4006
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
3858
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4007
|
+
if (_optionalChain([cs, 'optionalAccess', _60 => _60.fontSize]) > 0) {
|
|
3859
4008
|
baseFontSize = cs.fontSize / 10;
|
|
3860
4009
|
break;
|
|
3861
4010
|
}
|
|
@@ -3870,11 +4019,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3870
4019
|
if (text.length === 0 || text.length > 200) continue;
|
|
3871
4020
|
if (/^\d+$/.test(text)) continue;
|
|
3872
4021
|
let level = 0;
|
|
3873
|
-
if (_optionalChain([block, 'access',
|
|
4022
|
+
if (_optionalChain([block, 'access', _61 => _61.style, 'optionalAccess', _62 => _62.fontSize]) && baseFontSize > 0) {
|
|
3874
4023
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3875
|
-
if (ratio >=
|
|
3876
|
-
else if (ratio >=
|
|
3877
|
-
else if (ratio >=
|
|
4024
|
+
if (ratio >= _chunk5HDBLRVPcjs.HEADING_RATIO_H1) level = 1;
|
|
4025
|
+
else if (ratio >= _chunk5HDBLRVPcjs.HEADING_RATIO_H2) level = 2;
|
|
4026
|
+
else if (ratio >= _chunk5HDBLRVPcjs.HEADING_RATIO_H3) level = 3;
|
|
3878
4027
|
}
|
|
3879
4028
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3880
4029
|
if (level === 0) level = 2;
|
|
@@ -3890,7 +4039,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3890
4039
|
function extractHwp5Metadata(cfb, metadata) {
|
|
3891
4040
|
try {
|
|
3892
4041
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
3893
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4042
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _63 => _63.content])) return;
|
|
3894
4043
|
const data = Buffer.from(summaryEntry.content);
|
|
3895
4044
|
if (data.length < 48) return;
|
|
3896
4045
|
const numSets = data.readUInt32LE(24);
|
|
@@ -3923,7 +4072,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
3923
4072
|
const sections = [];
|
|
3924
4073
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
3925
4074
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
3926
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4075
|
+
if (!_optionalChain([entry, 'optionalAccess', _64 => _64.content])) break;
|
|
3927
4076
|
try {
|
|
3928
4077
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
3929
4078
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -3937,13 +4086,13 @@ function findSections(cfb) {
|
|
|
3937
4086
|
const sections = [];
|
|
3938
4087
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
3939
4088
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
3940
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4089
|
+
if (!_optionalChain([entry, 'optionalAccess', _65 => _65.content])) break;
|
|
3941
4090
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
3942
4091
|
}
|
|
3943
4092
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
3944
4093
|
for (const entry of cfb.FileIndex) {
|
|
3945
4094
|
if (sections.length >= MAX_SECTIONS) break;
|
|
3946
|
-
if (_optionalChain([entry, 'access',
|
|
4095
|
+
if (_optionalChain([entry, 'access', _66 => _66.name, 'optionalAccess', _67 => _67.startsWith, 'call', _68 => _68("Section")]) && entry.content) {
|
|
3947
4096
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
3948
4097
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
3949
4098
|
}
|
|
@@ -3959,7 +4108,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3959
4108
|
if (!raw) break;
|
|
3960
4109
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3961
4110
|
totalDecompressed += content.length;
|
|
3962
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4111
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3963
4112
|
sections.push({ idx: i, content });
|
|
3964
4113
|
}
|
|
3965
4114
|
if (sections.length === 0) {
|
|
@@ -3971,7 +4120,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3971
4120
|
if (raw) {
|
|
3972
4121
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3973
4122
|
totalDecompressed += content.length;
|
|
3974
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4123
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3975
4124
|
sections.push({ idx, content });
|
|
3976
4125
|
}
|
|
3977
4126
|
}
|
|
@@ -3988,7 +4137,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3988
4137
|
try {
|
|
3989
4138
|
const content = decryptViewText(raw, compressed);
|
|
3990
4139
|
totalDecompressed += content.length;
|
|
3991
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4140
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3992
4141
|
sections.push({ idx: i, content });
|
|
3993
4142
|
} catch (e26) {
|
|
3994
4143
|
break;
|
|
@@ -4089,9 +4238,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4089
4238
|
const applied = [];
|
|
4090
4239
|
for (const r of ranges) {
|
|
4091
4240
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4092
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
4241
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _69 => _69.href]) || r.end <= r.start) continue;
|
|
4093
4242
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4094
|
-
const href =
|
|
4243
|
+
const href = _chunk5HDBLRVPcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4095
4244
|
if (!href) continue;
|
|
4096
4245
|
const anchor = text.slice(r.start, r.end);
|
|
4097
4246
|
if (!anchor.trim()) continue;
|
|
@@ -4109,7 +4258,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4109
4258
|
}
|
|
4110
4259
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
4111
4260
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
4112
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
4261
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _70 => _70.docInfo, 'optionalAccess', _71 => _71.numberings, 'access', _72 => _72[nid - 1]]) : void 0;
|
|
4113
4262
|
if (numbering) {
|
|
4114
4263
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
4115
4264
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -4119,7 +4268,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4119
4268
|
}
|
|
4120
4269
|
}
|
|
4121
4270
|
} else if (ps.headType === 3) {
|
|
4122
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
4271
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _73 => _73.docInfo, 'optionalAccess', _74 => _74.bullets, 'access', _75 => _75[ps.numberingId - 1]]) : void 0;
|
|
4123
4272
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
4124
4273
|
}
|
|
4125
4274
|
}
|
|
@@ -4178,11 +4327,11 @@ function applyCtrlEffect(ctrl, records, ctx) {
|
|
|
4178
4327
|
const attr = ctrl.data.readUInt32LE(4);
|
|
4179
4328
|
const type = attr & 15;
|
|
4180
4329
|
const format = attr >>> 4 & 255;
|
|
4181
|
-
const
|
|
4182
|
-
ctx.doc.autoCounters.set(type,
|
|
4330
|
+
const num4 = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
|
|
4331
|
+
ctx.doc.autoCounters.set(type, num4 + 1);
|
|
4183
4332
|
const prefix = ctrl.data.length >= 14 ? wcharAt(ctrl.data, 12) : "";
|
|
4184
4333
|
const suffix = ctrl.data.length >= 16 ? wcharAt(ctrl.data, 14) : "";
|
|
4185
|
-
ctrl.inlineText = `${prefix}${formatNumber(
|
|
4334
|
+
ctrl.inlineText = `${prefix}${formatNumber(num4, shapeFormatToNumFmt(format))}${suffix}`;
|
|
4186
4335
|
}
|
|
4187
4336
|
return;
|
|
4188
4337
|
}
|
|
@@ -4190,8 +4339,8 @@ function applyCtrlEffect(ctrl, records, ctx) {
|
|
|
4190
4339
|
if (ctrl.data.length >= 10) {
|
|
4191
4340
|
const attr = ctrl.data.readUInt32LE(4);
|
|
4192
4341
|
const type = attr & 15;
|
|
4193
|
-
const
|
|
4194
|
-
if (
|
|
4342
|
+
const num4 = ctrl.data.readUInt16LE(8);
|
|
4343
|
+
if (num4 > 0) ctx.doc.autoCounters.set(type, num4);
|
|
4195
4344
|
}
|
|
4196
4345
|
return;
|
|
4197
4346
|
}
|
|
@@ -4253,7 +4402,7 @@ function blocksPlainText(blocks, sep) {
|
|
|
4253
4402
|
return parts.join(sep).trim();
|
|
4254
4403
|
}
|
|
4255
4404
|
function applyNoteEffect(ctrl, records, ctx, autoType) {
|
|
4256
|
-
const
|
|
4405
|
+
const num4 = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
|
|
4257
4406
|
let before = "";
|
|
4258
4407
|
let after = "";
|
|
4259
4408
|
let shape = 0;
|
|
@@ -4264,11 +4413,11 @@ function applyNoteEffect(ctrl, records, ctx, autoType) {
|
|
|
4264
4413
|
if (ctrl.data.length >= 16) {
|
|
4265
4414
|
shape = ctrl.data.readUInt32LE(12) & 255;
|
|
4266
4415
|
}
|
|
4267
|
-
const formatted = formatNumber(
|
|
4416
|
+
const formatted = formatNumber(num4, shapeFormatToNumFmt(shape));
|
|
4268
4417
|
const marker = before || after ? `${before}${formatted}${after}` : `${formatted})`;
|
|
4269
4418
|
const content = blocksPlainText(parseListHeaderParagraphs(ctrl, records, ctx), " ");
|
|
4270
|
-
if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <=
|
|
4271
|
-
ctx.doc.autoCounters.set(autoType,
|
|
4419
|
+
if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num4) {
|
|
4420
|
+
ctx.doc.autoCounters.set(autoType, num4 + 1);
|
|
4272
4421
|
}
|
|
4273
4422
|
ctrl.inlineText = marker;
|
|
4274
4423
|
if (content) ctrl.footnote = content.startsWith(marker) ? content : `${marker} ${content}`;
|
|
@@ -4324,8 +4473,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4324
4473
|
let tableIdx = -1;
|
|
4325
4474
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4326
4475
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4327
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4328
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4476
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunk5HDBLRVPcjs.MAX_ROWS);
|
|
4477
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunk5HDBLRVPcjs.MAX_COLS);
|
|
4329
4478
|
tableIdx = i2;
|
|
4330
4479
|
break;
|
|
4331
4480
|
}
|
|
@@ -4365,7 +4514,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4365
4514
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
4366
4515
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
4367
4516
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
4368
|
-
if (_optionalChain([c, 'access',
|
|
4517
|
+
if (_optionalChain([c, 'access', _76 => _76.blocks, 'optionalAccess', _77 => _77.length])) ir.blocks = c.blocks;
|
|
4369
4518
|
if (c.isHeader) ir.isHeader = true;
|
|
4370
4519
|
return ir;
|
|
4371
4520
|
}));
|
|
@@ -4374,7 +4523,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4374
4523
|
return table2;
|
|
4375
4524
|
}
|
|
4376
4525
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4377
|
-
const table =
|
|
4526
|
+
const table = _chunk5HDBLRVPcjs.buildTable.call(void 0, cellRows);
|
|
4378
4527
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4379
4528
|
return table.rows > 0 ? table : null;
|
|
4380
4529
|
}
|
|
@@ -4391,8 +4540,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4391
4540
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4392
4541
|
const cs = rec.data.readUInt16LE(12);
|
|
4393
4542
|
const rs = rec.data.readUInt16LE(14);
|
|
4394
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4395
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4543
|
+
if (cs > 0) colSpan = Math.min(cs, _chunk5HDBLRVPcjs.MAX_COLS);
|
|
4544
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunk5HDBLRVPcjs.MAX_ROWS);
|
|
4396
4545
|
}
|
|
4397
4546
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4398
4547
|
const parts = [];
|
|
@@ -4402,7 +4551,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4402
4551
|
parts.push(``);
|
|
4403
4552
|
hasStructure = true;
|
|
4404
4553
|
} else if (b.type === "table" && b.table) {
|
|
4405
|
-
const flat =
|
|
4554
|
+
const flat = _chunk5HDBLRVPcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4406
4555
|
if (flat) parts.push(flat);
|
|
4407
4556
|
hasStructure = true;
|
|
4408
4557
|
} else if (b.text) {
|
|
@@ -4499,8 +4648,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
4499
4648
|
if (data.length < 73) return null;
|
|
4500
4649
|
const binDataId = data.readUInt16LE(71);
|
|
4501
4650
|
if (binDataId === 0) return null;
|
|
4502
|
-
const item = _optionalChain([ctx, 'access',
|
|
4503
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
4651
|
+
const item = _optionalChain([ctx, 'access', _78 => _78.docInfo, 'optionalAccess', _79 => _79.binData, 'access', _80 => _80[binDataId - 1]]);
|
|
4652
|
+
if (_optionalChain([item, 'optionalAccess', _81 => _81.kind]) === "link") {
|
|
4504
4653
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
4505
4654
|
return null;
|
|
4506
4655
|
}
|
|
@@ -16806,9 +16955,9 @@ var MAX_ROWS2 = 1e4;
|
|
|
16806
16955
|
var MAX_COLS2 = 200;
|
|
16807
16956
|
function cleanNumericValue(raw) {
|
|
16808
16957
|
if (!/^-?\d+\.\d+$/.test(raw)) return raw;
|
|
16809
|
-
const
|
|
16810
|
-
if (!isFinite(
|
|
16811
|
-
const cleaned = parseFloat(
|
|
16958
|
+
const num4 = parseFloat(raw);
|
|
16959
|
+
if (!isFinite(num4)) return raw;
|
|
16960
|
+
const cleaned = parseFloat(num4.toPrecision(15)).toString();
|
|
16812
16961
|
return cleaned;
|
|
16813
16962
|
}
|
|
16814
16963
|
function parseCellRef(ref) {
|
|
@@ -16831,15 +16980,15 @@ function getElements(parent, tagName) {
|
|
|
16831
16980
|
const result = [];
|
|
16832
16981
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
16833
16982
|
if (result.length > 0) return result;
|
|
16834
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
16983
|
+
const nsNodes = _optionalChain([parent, 'access', _82 => _82.getElementsByTagNameNS, 'optionalCall', _83 => _83("*", tagName)]);
|
|
16835
16984
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
16836
16985
|
return result;
|
|
16837
16986
|
}
|
|
16838
16987
|
function getTextContent(el) {
|
|
16839
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
16988
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _84 => _84.textContent, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()]), () => ( ""));
|
|
16840
16989
|
}
|
|
16841
16990
|
function parseXml(text) {
|
|
16842
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16991
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk5HDBLRVPcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16843
16992
|
}
|
|
16844
16993
|
function parseSharedStrings(xml) {
|
|
16845
16994
|
const doc = parseXml(xml);
|
|
@@ -16976,14 +17125,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16976
17125
|
const merge = mergeMap.get(key);
|
|
16977
17126
|
row.push({
|
|
16978
17127
|
text,
|
|
16979
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16980
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17128
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _87 => _87.colSpan]), () => ( 1)),
|
|
17129
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _88 => _88.rowSpan]), () => ( 1))
|
|
16981
17130
|
});
|
|
16982
17131
|
}
|
|
16983
17132
|
cellRows.push(row);
|
|
16984
17133
|
}
|
|
16985
17134
|
if (cellRows.length > 0) {
|
|
16986
|
-
const table =
|
|
17135
|
+
const table = _chunk5HDBLRVPcjs.buildTable.call(void 0, cellRows);
|
|
16987
17136
|
if (table.rows > 0) {
|
|
16988
17137
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16989
17138
|
}
|
|
@@ -16991,12 +17140,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16991
17140
|
return blocks;
|
|
16992
17141
|
}
|
|
16993
17142
|
async function parseXlsxDocument(buffer, options) {
|
|
16994
|
-
|
|
17143
|
+
_chunk5HDBLRVPcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16995
17144
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16996
17145
|
const warnings = [];
|
|
16997
17146
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16998
17147
|
if (!workbookFile) {
|
|
16999
|
-
throw new (0,
|
|
17148
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17000
17149
|
}
|
|
17001
17150
|
let sharedStrings = [];
|
|
17002
17151
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17005,7 +17154,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17005
17154
|
}
|
|
17006
17155
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
17007
17156
|
if (sheets.length === 0) {
|
|
17008
|
-
throw new (0,
|
|
17157
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17009
17158
|
}
|
|
17010
17159
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17011
17160
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17013,7 +17162,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17013
17162
|
relsMap = parseRels(await relsFile.async("text"));
|
|
17014
17163
|
}
|
|
17015
17164
|
let pageFilter = null;
|
|
17016
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17165
|
+
if (_optionalChain([options, 'optionalAccess', _89 => _89.pages])) {
|
|
17017
17166
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17018
17167
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
17019
17168
|
}
|
|
@@ -17022,7 +17171,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17022
17171
|
for (let i = 0; i < processedSheets; i++) {
|
|
17023
17172
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17024
17173
|
const sheet = sheets[i];
|
|
17025
|
-
_optionalChain([options, 'optionalAccess',
|
|
17174
|
+
_optionalChain([options, 'optionalAccess', _90 => _90.onProgress, 'optionalCall', _91 => _91(i + 1, processedSheets)]);
|
|
17026
17175
|
let sheetPath = relsMap.get(sheet.rId);
|
|
17027
17176
|
if (sheetPath) {
|
|
17028
17177
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17077,7 +17226,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17077
17226
|
} catch (e27) {
|
|
17078
17227
|
}
|
|
17079
17228
|
}
|
|
17080
|
-
const markdown =
|
|
17229
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17081
17230
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17082
17231
|
}
|
|
17083
17232
|
|
|
@@ -17151,17 +17300,17 @@ function decodeRk(rk) {
|
|
|
17151
17300
|
const fDiv100 = (rk & 1) !== 0;
|
|
17152
17301
|
const fInt = (rk & 2) !== 0;
|
|
17153
17302
|
const val30 = rk >> 2;
|
|
17154
|
-
let
|
|
17303
|
+
let num4;
|
|
17155
17304
|
if (fInt) {
|
|
17156
|
-
|
|
17305
|
+
num4 = val30;
|
|
17157
17306
|
} else {
|
|
17158
17307
|
const high32 = (rk & 4294967292) >>> 0;
|
|
17159
17308
|
const buf = Buffer.alloc(8);
|
|
17160
17309
|
buf.writeUInt32LE(0, 0);
|
|
17161
17310
|
buf.writeUInt32LE(high32, 4);
|
|
17162
|
-
|
|
17311
|
+
num4 = buf.readDoubleLE(0);
|
|
17163
17312
|
}
|
|
17164
|
-
return fDiv100 ?
|
|
17313
|
+
return fDiv100 ? num4 / 100 : num4;
|
|
17165
17314
|
}
|
|
17166
17315
|
function decodeMulRk(data) {
|
|
17167
17316
|
if (data.length < 6) return null;
|
|
@@ -17484,11 +17633,11 @@ function processGlobals(records) {
|
|
|
17484
17633
|
let encrypted = false;
|
|
17485
17634
|
const firstBof = records[0];
|
|
17486
17635
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17487
|
-
throw new (0,
|
|
17636
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17488
17637
|
}
|
|
17489
17638
|
const bof = decodeBof(firstBof.data);
|
|
17490
17639
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17491
|
-
throw new (0,
|
|
17640
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17492
17641
|
}
|
|
17493
17642
|
let i = 1;
|
|
17494
17643
|
while (i < records.length) {
|
|
@@ -17596,14 +17745,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17596
17745
|
const merge = mergeMap.get(key);
|
|
17597
17746
|
row.push({
|
|
17598
17747
|
text: grid[r][c],
|
|
17599
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17600
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17748
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _92 => _92.colSpan]), () => ( 1)),
|
|
17749
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _93 => _93.rowSpan]), () => ( 1))
|
|
17601
17750
|
});
|
|
17602
17751
|
}
|
|
17603
17752
|
cellRows.push(row);
|
|
17604
17753
|
}
|
|
17605
17754
|
if (cellRows.length > 0) {
|
|
17606
|
-
const table =
|
|
17755
|
+
const table = _chunk5HDBLRVPcjs.buildTable.call(void 0, cellRows);
|
|
17607
17756
|
if (table.rows > 0) {
|
|
17608
17757
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17609
17758
|
}
|
|
@@ -17616,21 +17765,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17616
17765
|
try {
|
|
17617
17766
|
cfb = parseLenientCfb(buf);
|
|
17618
17767
|
} catch (e) {
|
|
17619
|
-
throw new (0,
|
|
17768
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
17620
17769
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17621
17770
|
);
|
|
17622
17771
|
}
|
|
17623
17772
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17624
17773
|
if (!wb) {
|
|
17625
|
-
throw new (0,
|
|
17774
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17626
17775
|
}
|
|
17627
17776
|
const records = readRecords2(wb);
|
|
17628
17777
|
if (records.length === 0) {
|
|
17629
|
-
throw new (0,
|
|
17778
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17630
17779
|
}
|
|
17631
17780
|
const firstBof = decodeBof(records[0].data);
|
|
17632
17781
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17633
|
-
throw new (0,
|
|
17782
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
17634
17783
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17635
17784
|
);
|
|
17636
17785
|
}
|
|
@@ -17651,7 +17800,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17651
17800
|
}
|
|
17652
17801
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17653
17802
|
let pageFilter = null;
|
|
17654
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17803
|
+
if (_optionalChain([options, 'optionalAccess', _94 => _94.pages])) {
|
|
17655
17804
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17656
17805
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17657
17806
|
}
|
|
@@ -17660,7 +17809,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17660
17809
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17661
17810
|
const meta = globals.sheets[i];
|
|
17662
17811
|
if (meta.dt !== 0) continue;
|
|
17663
|
-
_optionalChain([options, 'optionalAccess',
|
|
17812
|
+
_optionalChain([options, 'optionalAccess', _95 => _95.onProgress, 'optionalCall', _96 => _96(i + 1, totalSheets)]);
|
|
17664
17813
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
17665
17814
|
if (bofIdx < 0) {
|
|
17666
17815
|
warnings.push({
|
|
@@ -17690,7 +17839,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17690
17839
|
pageCount: totalSheets
|
|
17691
17840
|
};
|
|
17692
17841
|
return {
|
|
17693
|
-
markdown:
|
|
17842
|
+
markdown: _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17694
17843
|
blocks: allBlocks,
|
|
17695
17844
|
metadata,
|
|
17696
17845
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17703,7 +17852,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17703
17852
|
|
|
17704
17853
|
// src/docx/equation.ts
|
|
17705
17854
|
function lname(el) {
|
|
17706
|
-
return el.localName || _optionalChain([el, 'access',
|
|
17855
|
+
return el.localName || _optionalChain([el, 'access', _97 => _97.tagName, 'optionalAccess', _98 => _98.replace, 'call', _99 => _99(/^[^:]+:/, "")]) || "";
|
|
17707
17856
|
}
|
|
17708
17857
|
function kids(parent, name) {
|
|
17709
17858
|
const out = [];
|
|
@@ -17861,9 +18010,9 @@ function nodeToLatex(el) {
|
|
|
17861
18010
|
case "f": {
|
|
17862
18011
|
const n = firstKid(el, "num");
|
|
17863
18012
|
const d = firstKid(el, "den");
|
|
17864
|
-
const
|
|
18013
|
+
const num4 = n ? childrenToLatex(n) : "";
|
|
17865
18014
|
const den = d ? childrenToLatex(d) : "";
|
|
17866
|
-
return "\\frac" + grp(
|
|
18015
|
+
return "\\frac" + grp(num4) + grp(den);
|
|
17867
18016
|
}
|
|
17868
18017
|
// 첨자
|
|
17869
18018
|
case "sSup": {
|
|
@@ -18076,7 +18225,7 @@ function isDisplayMath(el) {
|
|
|
18076
18225
|
// src/docx/parser.ts
|
|
18077
18226
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
18078
18227
|
function matchesLocal(el, localName2) {
|
|
18079
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
18228
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _100 => _100.tagName, 'optionalAccess', _101 => _101.endsWith, 'call', _102 => _102(`:${localName2}`)]), () => ( false)));
|
|
18080
18229
|
}
|
|
18081
18230
|
function effectiveChildElements(parent) {
|
|
18082
18231
|
const result = [];
|
|
@@ -18109,7 +18258,7 @@ function findElements(parent, localName2) {
|
|
|
18109
18258
|
const child = children[i];
|
|
18110
18259
|
if (child.nodeType === 1) {
|
|
18111
18260
|
const el = child;
|
|
18112
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
18261
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _103 => _103.tagName, 'optionalAccess', _104 => _104.endsWith, 'call', _105 => _105(`:${localName2}`)])) {
|
|
18113
18262
|
result.push(el);
|
|
18114
18263
|
}
|
|
18115
18264
|
walk(el);
|
|
@@ -18128,7 +18277,7 @@ function getAttr(el, localName2) {
|
|
|
18128
18277
|
return null;
|
|
18129
18278
|
}
|
|
18130
18279
|
function parseXml2(text) {
|
|
18131
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18280
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk5HDBLRVPcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18132
18281
|
}
|
|
18133
18282
|
function parseStyles(xml) {
|
|
18134
18283
|
const doc = parseXml2(xml);
|
|
@@ -18230,7 +18379,7 @@ function collectOmmlRoots(p) {
|
|
|
18230
18379
|
const child = children[i];
|
|
18231
18380
|
if (child.nodeType !== 1) continue;
|
|
18232
18381
|
const el = child;
|
|
18233
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
18382
|
+
const tag = el.localName || _optionalChain([el, 'access', _106 => _106.tagName, 'optionalAccess', _107 => _107.replace, 'call', _108 => _108(/^[^:]+:/, "")]) || "";
|
|
18234
18383
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
18235
18384
|
out.push(el);
|
|
18236
18385
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -18320,7 +18469,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18320
18469
|
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18321
18470
|
if (!text) return null;
|
|
18322
18471
|
const style = styles.get(styleId);
|
|
18323
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
18472
|
+
if (_optionalChain([style, 'optionalAccess', _109 => _109.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
18324
18473
|
return {
|
|
18325
18474
|
type: "heading",
|
|
18326
18475
|
text,
|
|
@@ -18329,8 +18478,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18329
18478
|
}
|
|
18330
18479
|
if (numId && numId !== "0") {
|
|
18331
18480
|
const numDef = numbering.get(numId);
|
|
18332
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
18333
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
18481
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _110 => _110.get, 'call', _111 => _111(ilvl)]);
|
|
18482
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _112 => _112.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
18334
18483
|
return { type: "list", text, listType };
|
|
18335
18484
|
}
|
|
18336
18485
|
const block = { type: "paragraph", text };
|
|
@@ -18413,7 +18562,7 @@ ${cell.text}` : cell.text;
|
|
|
18413
18562
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18414
18563
|
})
|
|
18415
18564
|
);
|
|
18416
|
-
const table =
|
|
18565
|
+
const table = _chunk5HDBLRVPcjs.buildTable.call(void 0, cellRows);
|
|
18417
18566
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18418
18567
|
return { type: "table", table };
|
|
18419
18568
|
}
|
|
@@ -18423,10 +18572,10 @@ function collectCellText(tc, styles, numbering, footnotes, rels, depth) {
|
|
|
18423
18572
|
for (const el of effectiveChildElements(tc)) {
|
|
18424
18573
|
if (matchesLocal(el, "p")) {
|
|
18425
18574
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18426
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
18575
|
+
if (_optionalChain([block, 'optionalAccess', _113 => _113.text])) parts.push(block.text);
|
|
18427
18576
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
18428
18577
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
18429
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
18578
|
+
if (_optionalChain([tb, 'optionalAccess', _114 => _114.text])) parts.push(tb.text);
|
|
18430
18579
|
}
|
|
18431
18580
|
} else if (matchesLocal(el, "tbl")) {
|
|
18432
18581
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -18456,7 +18605,7 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18456
18605
|
try {
|
|
18457
18606
|
const data = await imgFile.async("uint8array");
|
|
18458
18607
|
imgIdx++;
|
|
18459
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
18608
|
+
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access', _115 => _115.split, 'call', _116 => _116("."), 'access', _117 => _117.pop, 'call', _118 => _118(), 'optionalAccess', _119 => _119.toLowerCase, 'call', _120 => _120()]), () => ( "png"));
|
|
18460
18609
|
const mimeMap = {
|
|
18461
18610
|
png: "image/png",
|
|
18462
18611
|
jpg: "image/jpeg",
|
|
@@ -18480,12 +18629,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18480
18629
|
return { blocks, images };
|
|
18481
18630
|
}
|
|
18482
18631
|
async function parseDocxDocument(buffer, options) {
|
|
18483
|
-
|
|
18632
|
+
_chunk5HDBLRVPcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18484
18633
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18485
18634
|
const warnings = [];
|
|
18486
18635
|
const docFile = zip.file("word/document.xml");
|
|
18487
18636
|
if (!docFile) {
|
|
18488
|
-
throw new (0,
|
|
18637
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18489
18638
|
}
|
|
18490
18639
|
let rels = /* @__PURE__ */ new Map();
|
|
18491
18640
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18532,13 +18681,13 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18532
18681
|
const doc = parseXml2(docXml);
|
|
18533
18682
|
const body = findElements(doc, "body");
|
|
18534
18683
|
if (body.length === 0) {
|
|
18535
|
-
throw new (0,
|
|
18684
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18536
18685
|
}
|
|
18537
18686
|
const blocks = [];
|
|
18538
18687
|
const bodyEl = body[0];
|
|
18539
18688
|
const topLevel = effectiveChildElements(bodyEl);
|
|
18540
18689
|
for (const el of topLevel) {
|
|
18541
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
18690
|
+
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access', _121 => _121.tagName, 'optionalAccess', _122 => _122.split, 'call', _123 => _123(":"), 'access', _124 => _124.pop, 'call', _125 => _125()])));
|
|
18542
18691
|
if (localName2 === "p") {
|
|
18543
18692
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18544
18693
|
if (block) blocks.push(block);
|
|
@@ -18577,7 +18726,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18577
18726
|
}
|
|
18578
18727
|
}
|
|
18579
18728
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18580
|
-
const markdown =
|
|
18729
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18581
18730
|
return {
|
|
18582
18731
|
markdown,
|
|
18583
18732
|
blocks,
|
|
@@ -18600,7 +18749,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18600
18749
|
}
|
|
18601
18750
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18602
18751
|
const normalized = text.replace(/ /g, " ");
|
|
18603
|
-
const xml =
|
|
18752
|
+
const xml = _chunk5HDBLRVPcjs.stripDtd.call(void 0, normalized);
|
|
18604
18753
|
const warnings = [];
|
|
18605
18754
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18606
18755
|
onError: (_level, msg2) => {
|
|
@@ -18628,7 +18777,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18628
18777
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18629
18778
|
}
|
|
18630
18779
|
const blocks = [];
|
|
18631
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
18780
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _126 => _126.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18632
18781
|
let sectionIdx = 0;
|
|
18633
18782
|
const children = body.childNodes;
|
|
18634
18783
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18640,7 +18789,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18640
18789
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18641
18790
|
}
|
|
18642
18791
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18643
|
-
const markdown =
|
|
18792
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18644
18793
|
return {
|
|
18645
18794
|
markdown,
|
|
18646
18795
|
blocks,
|
|
@@ -18726,7 +18875,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
18726
18875
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
18727
18876
|
const text = extractParagraphText(el);
|
|
18728
18877
|
if (!text) return;
|
|
18729
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
18878
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _127 => _127.headingLevel]) != null) {
|
|
18730
18879
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
18731
18880
|
} else {
|
|
18732
18881
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -18798,7 +18947,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18798
18947
|
const cellRows = grid.map(
|
|
18799
18948
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18800
18949
|
);
|
|
18801
|
-
const table =
|
|
18950
|
+
const table = _chunk5HDBLRVPcjs.buildTable.call(void 0, cellRows);
|
|
18802
18951
|
const caption = extractShapeCaption(el);
|
|
18803
18952
|
if (caption.text && caption.before) {
|
|
18804
18953
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -19058,7 +19207,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
19058
19207
|
(match, prefix, suffix) => {
|
|
19059
19208
|
const label = prefix + suffix;
|
|
19060
19209
|
const normalizedLabel = normalizeLabel(label);
|
|
19061
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19210
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _128 => _128.has, 'call', _129 => _129(normalizedLabel)])) return match;
|
|
19062
19211
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
19063
19212
|
if (matchKey === void 0) return match;
|
|
19064
19213
|
const newValue = values.consume(matchKey);
|
|
@@ -19308,8 +19457,8 @@ function extractFromTable(table) {
|
|
|
19308
19457
|
if (table.cols >= 2) {
|
|
19309
19458
|
for (let r = 0; r < table.rows; r++) {
|
|
19310
19459
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
19311
|
-
const labelCell = _optionalChain([table, 'access',
|
|
19312
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19460
|
+
const labelCell = _optionalChain([table, 'access', _130 => _130.cells, 'access', _131 => _131[r], 'optionalAccess', _132 => _132[c]]);
|
|
19461
|
+
const valueCell = _optionalChain([table, 'access', _133 => _133.cells, 'access', _134 => _134[r], 'optionalAccess', _135 => _135[c + 1]]);
|
|
19313
19462
|
if (!labelCell || !valueCell) continue;
|
|
19314
19463
|
if (isLabelCell(labelCell.text)) {
|
|
19315
19464
|
fields.push({
|
|
@@ -19331,8 +19480,8 @@ function extractFromTable(table) {
|
|
|
19331
19480
|
if (allLabels) {
|
|
19332
19481
|
for (let r = 1; r < table.rows; r++) {
|
|
19333
19482
|
for (let c = 0; c < table.cols; c++) {
|
|
19334
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19335
|
-
const value = _nullishCoalesce(_optionalChain([table, 'access',
|
|
19483
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _136 => _136[c], 'optionalAccess', _137 => _137.text, 'access', _138 => _138.trim, 'call', _139 => _139()]), () => ( ""));
|
|
19484
|
+
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()]), () => ( ""));
|
|
19336
19485
|
if (label && value) {
|
|
19337
19486
|
fields.push({ label, value, row: r, col: c });
|
|
19338
19487
|
}
|
|
@@ -19425,7 +19574,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
19425
19574
|
for (const table of allTables) {
|
|
19426
19575
|
for (let r = 0; r < table.rows; r++) {
|
|
19427
19576
|
for (let c = 0; c < table.cols; c++) {
|
|
19428
|
-
const cell = _optionalChain([table, 'access',
|
|
19577
|
+
const cell = _optionalChain([table, 'access', _146 => _146.cells, 'access', _147 => _147[r], 'optionalAccess', _148 => _148[c]]);
|
|
19429
19578
|
if (!cell) continue;
|
|
19430
19579
|
const result = fillInCellPatterns(cell.text, cursor, matchedLabels, blockedLabels);
|
|
19431
19580
|
if (result) {
|
|
@@ -19457,7 +19606,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19457
19606
|
out.push(block.table);
|
|
19458
19607
|
for (const row of block.table.cells) {
|
|
19459
19608
|
for (const cell of row) {
|
|
19460
|
-
if (_optionalChain([cell, 'optionalAccess',
|
|
19609
|
+
if (_optionalChain([cell, 'optionalAccess', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) out.push(...collectIRTables(cell.blocks, depth + 1));
|
|
19461
19610
|
}
|
|
19462
19611
|
}
|
|
19463
19612
|
}
|
|
@@ -19468,7 +19617,7 @@ function coveredPositions(table) {
|
|
|
19468
19617
|
for (let r = 0; r < table.rows; r++) {
|
|
19469
19618
|
for (let c = 0; c < table.cols; c++) {
|
|
19470
19619
|
if (covered.has(`${r},${c}`)) continue;
|
|
19471
|
-
const cell = _optionalChain([table, 'access',
|
|
19620
|
+
const cell = _optionalChain([table, 'access', _151 => _151.cells, 'access', _152 => _152[r], 'optionalAccess', _153 => _153[c]]);
|
|
19472
19621
|
if (!cell) continue;
|
|
19473
19622
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
19474
19623
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -19498,12 +19647,12 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells, blo
|
|
|
19498
19647
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
19499
19648
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
19500
19649
|
if (!normalizedCellLabel) continue;
|
|
19501
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19650
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _154 => _154.has, 'call', _155 => _155(normalizedCellLabel)])) continue;
|
|
19502
19651
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
19503
19652
|
if (matchKey === void 0) continue;
|
|
19504
19653
|
const newValue = values.consume(matchKey);
|
|
19505
19654
|
if (newValue === void 0) continue;
|
|
19506
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19655
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _156 => _156.has, 'call', _157 => _157(valueCell)])) {
|
|
19507
19656
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19508
19657
|
} else {
|
|
19509
19658
|
valueCell.text = newValue;
|
|
@@ -19529,10 +19678,10 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells, blo
|
|
|
19529
19678
|
for (let c = 0; c < table.cols; c++) {
|
|
19530
19679
|
if (covered.has(`${r},${c}`)) continue;
|
|
19531
19680
|
const headerCell = headerRow[c];
|
|
19532
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19681
|
+
const valueCell = _optionalChain([table, 'access', _158 => _158.cells, 'access', _159 => _159[r], 'optionalAccess', _160 => _160[c]]);
|
|
19533
19682
|
if (!headerCell || !valueCell) continue;
|
|
19534
19683
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19535
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19684
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _161 => _161.has, 'call', _162 => _162(headerLabel)])) continue;
|
|
19536
19685
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
19537
19686
|
if (matchKey === void 0) continue;
|
|
19538
19687
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -19558,7 +19707,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
19558
19707
|
let pos = 0;
|
|
19559
19708
|
for (const seg of segments) {
|
|
19560
19709
|
const nlabel = normalizeLabel(seg.label);
|
|
19561
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19710
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _163 => _163.has, 'call', _164 => _164(nlabel)])) continue;
|
|
19562
19711
|
const matchKey = findMatchingKey(nlabel, values);
|
|
19563
19712
|
if (matchKey === void 0) continue;
|
|
19564
19713
|
const newValue = values.consume(matchKey);
|
|
@@ -20126,19 +20275,19 @@ function parseCentralDirectory(buf) {
|
|
|
20126
20275
|
}
|
|
20127
20276
|
}
|
|
20128
20277
|
}
|
|
20129
|
-
if (eocdOffset < 0) throw new (0,
|
|
20278
|
+
if (eocdOffset < 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20130
20279
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20131
20280
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20132
20281
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20133
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20282
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20134
20283
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20135
|
-
throw new (0,
|
|
20284
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20136
20285
|
}
|
|
20137
20286
|
const decoder = new TextDecoder("utf-8");
|
|
20138
20287
|
const entries = [];
|
|
20139
20288
|
let pos = cdOffset;
|
|
20140
20289
|
for (let i = 0; i < totalEntries; i++) {
|
|
20141
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20290
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20142
20291
|
const flags = view.getUint16(pos + 8, true);
|
|
20143
20292
|
const method = view.getUint16(pos + 10, true);
|
|
20144
20293
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20149,7 +20298,7 @@ function parseCentralDirectory(buf) {
|
|
|
20149
20298
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20150
20299
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20151
20300
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20152
|
-
throw new (0,
|
|
20301
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20153
20302
|
}
|
|
20154
20303
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20155
20304
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20158,7 +20307,7 @@ function parseCentralDirectory(buf) {
|
|
|
20158
20307
|
}
|
|
20159
20308
|
return { entries, cdOffset, cdSize, eocdOffset };
|
|
20160
20309
|
}
|
|
20161
|
-
var
|
|
20310
|
+
var CRC_TABLE2 = (() => {
|
|
20162
20311
|
const table = new Uint32Array(256);
|
|
20163
20312
|
for (let n = 0; n < 256; n++) {
|
|
20164
20313
|
let c = n;
|
|
@@ -20167,10 +20316,10 @@ var CRC_TABLE = (() => {
|
|
|
20167
20316
|
}
|
|
20168
20317
|
return table;
|
|
20169
20318
|
})();
|
|
20170
|
-
function
|
|
20319
|
+
function crc322(data) {
|
|
20171
20320
|
let crc = 4294967295;
|
|
20172
20321
|
for (let i = 0; i < data.length; i++) {
|
|
20173
|
-
crc =
|
|
20322
|
+
crc = CRC_TABLE2[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
20174
20323
|
}
|
|
20175
20324
|
return (crc ^ 4294967295) >>> 0;
|
|
20176
20325
|
}
|
|
@@ -20178,11 +20327,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20178
20327
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20179
20328
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20180
20329
|
for (const name of replacements.keys()) {
|
|
20181
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20330
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunk5HDBLRVPcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20182
20331
|
}
|
|
20183
20332
|
if (additions) {
|
|
20184
20333
|
for (const name of additions.keys()) {
|
|
20185
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20334
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunk5HDBLRVPcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20186
20335
|
}
|
|
20187
20336
|
}
|
|
20188
20337
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20201,7 +20350,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20201
20350
|
offset += seg.length;
|
|
20202
20351
|
continue;
|
|
20203
20352
|
}
|
|
20204
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20353
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunk5HDBLRVPcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20205
20354
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20206
20355
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20207
20356
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20209,7 +20358,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20209
20358
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
20210
20359
|
const method = e.method;
|
|
20211
20360
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
20212
|
-
const crc =
|
|
20361
|
+
const crc = crc322(newData);
|
|
20213
20362
|
const flags = e.flags & ~8;
|
|
20214
20363
|
hview.setUint16(6, flags, true);
|
|
20215
20364
|
hview.setUint32(14, crc, true);
|
|
@@ -20227,7 +20376,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20227
20376
|
const deflated = new Uint8Array(_zlib.deflateRawSync.call(void 0, data));
|
|
20228
20377
|
const method = deflated.length < data.length ? 8 : 0;
|
|
20229
20378
|
const compData = method === 8 ? deflated : data;
|
|
20230
|
-
const crc =
|
|
20379
|
+
const crc = crc322(data);
|
|
20231
20380
|
const header = new Uint8Array(30 + nameBytes.length);
|
|
20232
20381
|
const hv = new DataView(header.buffer);
|
|
20233
20382
|
hv.setUint32(0, LOCAL_SIG, true);
|
|
@@ -20307,7 +20456,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20307
20456
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20308
20457
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20309
20458
|
if (sectionPaths.length === 0) {
|
|
20310
|
-
throw new (0,
|
|
20459
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20311
20460
|
}
|
|
20312
20461
|
const normalizedValues = normalizeValues(values);
|
|
20313
20462
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20380,7 +20529,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20380
20529
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
20381
20530
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
20382
20531
|
if (!normalizedCellLabel) continue;
|
|
20383
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20532
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _165 => _165.has, 'call', _166 => _166(normalizedCellLabel)])) continue;
|
|
20384
20533
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
20385
20534
|
if (matchKey === void 0) continue;
|
|
20386
20535
|
if (patternApplied.has(valueCell)) {
|
|
@@ -20438,7 +20587,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20438
20587
|
const dataCells = table.rows[rowIdx];
|
|
20439
20588
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
20440
20589
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
20441
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20590
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _167 => _167.has, 'call', _168 => _168(headerLabel)])) continue;
|
|
20442
20591
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
20443
20592
|
if (matchKey === void 0) continue;
|
|
20444
20593
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -20471,11 +20620,11 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20471
20620
|
}
|
|
20472
20621
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20473
20622
|
const existing = ledger.get(para);
|
|
20474
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20623
|
+
if (_optionalChain([existing, 'optionalAccess', _169 => _169.fullText]) !== void 0) continue;
|
|
20475
20624
|
const text = matchText(para);
|
|
20476
20625
|
for (const seg of scanInlineSegments(text)) {
|
|
20477
20626
|
const nlabel = normalizeLabel(seg.label);
|
|
20478
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20627
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _170 => _170.has, 'call', _171 => _171(nlabel)])) continue;
|
|
20479
20628
|
const matchKey = findMatchingKey(nlabel, cursor);
|
|
20480
20629
|
if (matchKey === void 0) continue;
|
|
20481
20630
|
const newValue = cursor.consume(matchKey);
|
|
@@ -20712,8 +20861,8 @@ function charWidthEm1000(cp) {
|
|
|
20712
20861
|
var SPACE_EM_FIXED = 500;
|
|
20713
20862
|
var SPACE_EM_FONT = 300;
|
|
20714
20863
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20715
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20716
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20864
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _172 => _172.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20865
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _173 => _173.spacingPct]), () => ( 0));
|
|
20717
20866
|
let em = 0;
|
|
20718
20867
|
for (const ch of text) {
|
|
20719
20868
|
const cp = ch.codePointAt(0);
|
|
@@ -20726,8 +20875,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20726
20875
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20727
20876
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20728
20877
|
const EPS = 0.5;
|
|
20729
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20730
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20878
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _174 => _174.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20879
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _175 => _175.spacingPct]), () => ( 0));
|
|
20731
20880
|
const k = height * ratioPct / 100 / 1e3;
|
|
20732
20881
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20733
20882
|
const charW2 = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20953,16 +21102,16 @@ var PARA_LIST = 7;
|
|
|
20953
21102
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20954
21103
|
function resolveTheme(theme) {
|
|
20955
21104
|
return {
|
|
20956
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20957
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20958
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20959
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20960
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20961
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21105
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _176 => _176.headingColors, 'optionalAccess', _177 => _177[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21106
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _178 => _178.headingColors, 'optionalAccess', _179 => _179[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21107
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _180 => _180.headingColors, 'optionalAccess', _181 => _181[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21108
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _182 => _182.headingColors, 'optionalAccess', _183 => _183[4]]), () => ( _optionalChain([theme, 'optionalAccess', _184 => _184.headingColors, 'optionalAccess', _185 => _185[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21109
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _186 => _186.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21110
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _187 => _187.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20962
21111
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20963
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20964
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20965
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
21112
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _188 => _188.quoteColor]) !== void 0,
|
|
21113
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _189 => _189.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _190 => _190.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21114
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _191 => _191.tableHeaderBold])
|
|
20966
21115
|
};
|
|
20967
21116
|
}
|
|
20968
21117
|
function escapeXml(text) {
|
|
@@ -21256,7 +21405,7 @@ function generateManifest(chartParts = []) {
|
|
|
21256
21405
|
</opf:spine>
|
|
21257
21406
|
</opf:package>`;
|
|
21258
21407
|
}
|
|
21259
|
-
function buildCharProperties(theme, gongmun, ratioVariants = []) {
|
|
21408
|
+
function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls = []) {
|
|
21260
21409
|
let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
|
|
21261
21410
|
if (gongmun) {
|
|
21262
21411
|
body = gongmun.bodyHeight;
|
|
@@ -21288,6 +21437,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = []) {
|
|
|
21288
21437
|
charPr(rows.length + 3, body, true, true, 0, theme.body, r)
|
|
21289
21438
|
);
|
|
21290
21439
|
}
|
|
21440
|
+
rows.push(...extraCharPrXmls);
|
|
21291
21441
|
return `<hh:charProperties itemCnt="${rows.length}">
|
|
21292
21442
|
${rows.join("\n")}
|
|
21293
21443
|
</hh:charProperties>`;
|
|
@@ -21341,9 +21491,9 @@ ${heads}
|
|
|
21341
21491
|
</hh:numbering>
|
|
21342
21492
|
</hh:numberings>`;
|
|
21343
21493
|
}
|
|
21344
|
-
function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
21345
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
21346
|
-
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants);
|
|
21494
|
+
function generateHeaderXml(theme, gongmun, ratioVariants = [], remap = null) {
|
|
21495
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _192 => _192.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
21496
|
+
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _193 => _193.charPrXmls]), () => ( [])));
|
|
21347
21497
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21348
21498
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
21349
21499
|
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" xmlns:hc="${NS_CORE}" version="1.4" secCnt="1">
|
|
@@ -21398,7 +21548,7 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21398
21548
|
</hh:font>
|
|
21399
21549
|
</hh:fontface>
|
|
21400
21550
|
</hh:fontfaces>
|
|
21401
|
-
<hh:borderFills itemCnt="2">
|
|
21551
|
+
<hh:borderFills itemCnt="${2 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _194 => _194.borderFillXmls, 'access', _195 => _195.length]), () => ( 0)))}">
|
|
21402
21552
|
<hh:borderFill id="1" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
21403
21553
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
21404
21554
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -21414,7 +21564,7 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21414
21564
|
<hh:rightBorder type="SOLID" width="0.12 mm" color="#000000"/>
|
|
21415
21565
|
<hh:topBorder type="SOLID" width="0.12 mm" color="#000000"/>
|
|
21416
21566
|
<hh:bottomBorder type="SOLID" width="0.12 mm" color="#000000"/>
|
|
21417
|
-
</hh:borderFill
|
|
21567
|
+
</hh:borderFill>${remap && remap.borderFillXmls.length ? "\n" + remap.borderFillXmls.join("\n") : ""}
|
|
21418
21568
|
</hh:borderFills>
|
|
21419
21569
|
${charPropsXml}
|
|
21420
21570
|
<hh:tabProperties itemCnt="0"/>
|
|
@@ -21539,8 +21689,8 @@ function parseChartFence(text) {
|
|
|
21539
21689
|
const spec = chartSpec(type);
|
|
21540
21690
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
21541
21691
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
21542
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
21543
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
21692
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _196 => _196.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
21693
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _197 => _197[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
21544
21694
|
if (!spec.scatter) {
|
|
21545
21695
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
21546
21696
|
}
|
|
@@ -21582,7 +21732,7 @@ function serSpPr(color, stroke) {
|
|
|
21582
21732
|
return stroke ? `<c:spPr><a:ln w="28575" cap="flat" cmpd="sng" algn="ctr">${f}<a:prstDash val="solid"/><a:round/></a:ln></c:spPr>` : `<c:spPr>${f}</c:spPr>`;
|
|
21583
21733
|
}
|
|
21584
21734
|
function dPtXml(pointColors, pie) {
|
|
21585
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
21735
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _198 => _198.length])) return "";
|
|
21586
21736
|
return pointColors.map((col, i) => {
|
|
21587
21737
|
const f = chartColorFill(col);
|
|
21588
21738
|
if (!f) return "";
|
|
@@ -21901,7 +22051,7 @@ function escapeGfm(text) {
|
|
|
21901
22051
|
}
|
|
21902
22052
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21903
22053
|
function sanitizeText(text) {
|
|
21904
|
-
let result =
|
|
22054
|
+
let result = _chunk5HDBLRVPcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21905
22055
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21906
22056
|
const tokens = result.split(" ");
|
|
21907
22057
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21931,7 +22081,7 @@ function replicateGfmTable(table) {
|
|
|
21931
22081
|
for (let r = 0; r < numRows; r++) {
|
|
21932
22082
|
for (let c = 0; c < numCols; c++) {
|
|
21933
22083
|
if (skip.has(`${r},${c}`)) continue;
|
|
21934
|
-
const cell = _optionalChain([cells, 'access',
|
|
22084
|
+
const cell = _optionalChain([cells, 'access', _199 => _199[r], 'optionalAccess', _200 => _200[c]]);
|
|
21935
22085
|
if (!cell) continue;
|
|
21936
22086
|
display[r][c] = {
|
|
21937
22087
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -21985,7 +22135,7 @@ function unescapeGfmCell(text) {
|
|
|
21985
22135
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
21986
22136
|
}
|
|
21987
22137
|
function replicateCellInnerHtml(cell) {
|
|
21988
|
-
if (_optionalChain([cell, 'access',
|
|
22138
|
+
if (_optionalChain([cell, 'access', _201 => _201.blocks, 'optionalAccess', _202 => _202.length])) {
|
|
21989
22139
|
return cell.blocks.map((b) => {
|
|
21990
22140
|
if (b.type === "table" && b.table) {
|
|
21991
22141
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -22024,7 +22174,7 @@ function replicateHtmlTable(table) {
|
|
|
22024
22174
|
const rowCells = [];
|
|
22025
22175
|
for (let c = 0; c < numCols; c++) {
|
|
22026
22176
|
if (skip.has(`${r},${c}`)) continue;
|
|
22027
|
-
const cell = _optionalChain([cells, 'access',
|
|
22177
|
+
const cell = _optionalChain([cells, 'access', _203 => _203[r], 'optionalAccess', _204 => _204[c]]);
|
|
22028
22178
|
if (!cell) continue;
|
|
22029
22179
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
22030
22180
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -22070,8 +22220,8 @@ function parseHtmlTable(raw) {
|
|
|
22070
22220
|
}
|
|
22071
22221
|
} else {
|
|
22072
22222
|
if (!isClose) {
|
|
22073
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
22074
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
22223
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _205 => _205.match, 'call', _206 => _206(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _207 => _207[1]]) || "1", 10);
|
|
22224
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _208 => _208.match, 'call', _209 => _209(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _210 => _210[1]]) || "1", 10);
|
|
22075
22225
|
cellStart = m.index + m[0].length;
|
|
22076
22226
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
22077
22227
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -22146,23 +22296,47 @@ var tableIdCounter = TABLE_ID_BASE;
|
|
|
22146
22296
|
function nextTableId() {
|
|
22147
22297
|
return ++tableIdCounter;
|
|
22148
22298
|
}
|
|
22149
|
-
|
|
22299
|
+
var warnedTables = /* @__PURE__ */ new Set();
|
|
22300
|
+
function warnProfileMismatch(tblId, tp, rowCnt, colCnt) {
|
|
22301
|
+
if (warnedTables.has(tblId)) return;
|
|
22302
|
+
warnedTables.add(tblId);
|
|
22303
|
+
console.warn(`[kordoc] format profile: table ${tp.rows}x${tp.cols} vs document ${rowCnt}x${colCnt} \u2014 \uD504\uB85C\uD544 \uBB34\uC2DC`);
|
|
22304
|
+
}
|
|
22305
|
+
function usableProfile(tp, tblId, rowCnt, colCnt) {
|
|
22306
|
+
if (!tp) return null;
|
|
22307
|
+
if (tp.rows !== rowCnt || tp.cols !== colCnt) {
|
|
22308
|
+
warnProfileMismatch(tblId, tp, rowCnt, colCnt);
|
|
22309
|
+
return null;
|
|
22310
|
+
}
|
|
22311
|
+
return tp;
|
|
22312
|
+
}
|
|
22313
|
+
function resolveColWidths(tp, colCnt, fallbackTotal) {
|
|
22314
|
+
if (_optionalChain([tp, 'optionalAccess', _211 => _211.colWidths]) && tp.colWidths.length === colCnt) return tp.colWidths;
|
|
22315
|
+
const w = _optionalChain([tp, 'optionalAccess', _212 => _212.width]) ? Math.floor(tp.width / colCnt) : Math.floor(fallbackTotal / colCnt);
|
|
22316
|
+
return Array(colCnt).fill(w);
|
|
22317
|
+
}
|
|
22318
|
+
function generateTable(rows, theme, tp = null) {
|
|
22150
22319
|
const rowCnt = rows.length;
|
|
22151
22320
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
22152
|
-
const cellW = Math.floor(44e3 / colCnt);
|
|
22153
22321
|
const cellH = 1500;
|
|
22154
|
-
const tblW = cellW * colCnt;
|
|
22155
|
-
const tblH = cellH * rowCnt;
|
|
22156
22322
|
const tblId = nextTableId();
|
|
22323
|
+
const prof = usableProfile(tp, tblId, rowCnt, colCnt);
|
|
22324
|
+
const colW = resolveColWidths(prof, colCnt, 44e3);
|
|
22325
|
+
const tblW = colW.reduce((a, b) => a + b, 0);
|
|
22326
|
+
const tblH = cellH * rowCnt;
|
|
22157
22327
|
const useHeaderStyle = theme.tableHeader !== theme.body || theme.tableHeaderBold;
|
|
22158
22328
|
const trElements = rows.map((row, rowIdx) => {
|
|
22159
22329
|
const cells = row.length < colCnt ? [...row, ...Array(colCnt - row.length).fill("")] : row;
|
|
22160
22330
|
const isHeaderRow = rowIdx === 0;
|
|
22161
22331
|
const headerCharPr = isHeaderRow && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
22162
22332
|
const tdElements = cells.map((cell, colIdx) => {
|
|
22163
|
-
const
|
|
22333
|
+
const k = `${rowIdx},${colIdx}`;
|
|
22334
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _213 => _213.cellBf, 'access', _214 => _214.get, 'call', _215 => _215(k)]), () => ( 2));
|
|
22335
|
+
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _216 => _216.cellChar, 'access', _217 => _217.get, 'call', _218 => _218(k)]), () => ( headerCharPr));
|
|
22336
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _219 => _219.cellH, 'access', _220 => _220.get, 'call', _221 => _221(k)]), () => ( cellH));
|
|
22337
|
+
const runs = generateRuns(cell, ch);
|
|
22164
22338
|
const p = `<hp:p paraPrIDRef="0" styleIDRef="0">${runs}</hp:p>`;
|
|
22165
|
-
return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="
|
|
22339
|
+
return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${p}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${colW[colIdx]}" height="${h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22166
22340
|
}).join("");
|
|
22167
22341
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
22168
22342
|
}).join("");
|
|
@@ -22193,35 +22367,42 @@ function layoutHtmlRows(rows) {
|
|
|
22193
22367
|
function unescapeHtml(s) {
|
|
22194
22368
|
return s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
22195
22369
|
}
|
|
22196
|
-
function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3) {
|
|
22370
|
+
function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, tp = null) {
|
|
22197
22371
|
const rows = parseHtmlTable(rawHtml);
|
|
22198
22372
|
if (!rows || rows.length === 0) return null;
|
|
22199
22373
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
22200
22374
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
22201
|
-
const colW = Math.floor(totalWidth / colCnt);
|
|
22202
22375
|
const cellH = 1500;
|
|
22203
|
-
const tblW = colW * colCnt;
|
|
22204
22376
|
const tblId = nextTableId();
|
|
22377
|
+
const prof = usableProfile(tp, tblId, rowCnt, colCnt);
|
|
22378
|
+
const colW = resolveColWidths(prof, colCnt, totalWidth);
|
|
22379
|
+
const tblW = colW.reduce((a, b) => a + b, 0);
|
|
22205
22380
|
const useHeaderStyle = theme.tableHeader !== theme.body || theme.tableHeaderBold;
|
|
22381
|
+
const spanW = (c, colSpan) => colW.slice(c, c + colSpan).reduce((a, b) => a + b, 0);
|
|
22206
22382
|
const tcXmls = placed.map((cell) => {
|
|
22383
|
+
const k = `${cell.r},${cell.c}`;
|
|
22384
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _222 => _222.cellBf, 'access', _223 => _223.get, 'call', _224 => _224(k)]), () => ( 2));
|
|
22207
22385
|
const headerCharPr = cell.isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
22386
|
+
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _225 => _225.cellChar, 'access', _226 => _226.get, 'call', _227 => _227(k)]), () => ( headerCharPr));
|
|
22208
22387
|
const { lines } = htmlCellInnerToLines(cell.inner);
|
|
22209
22388
|
const paras = lines.map(
|
|
22210
|
-
(line) => `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${
|
|
22389
|
+
(line) => `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${ch}"><hp:t>${escapeXml(unescapeHtml(line))}</hp:t></hp:run></hp:p>`
|
|
22211
22390
|
);
|
|
22391
|
+
const cellW = spanW(cell.c, cell.colSpan);
|
|
22212
22392
|
let nestedH = 0;
|
|
22213
22393
|
for (const nested of extractTopLevelTables(cell.inner)) {
|
|
22214
|
-
const nestedXml = generateHtmlTableXml(nested, theme, Math.max(
|
|
22394
|
+
const nestedXml = generateHtmlTableXml(nested, theme, Math.max(cellW - 1020, 4e3));
|
|
22215
22395
|
if (nestedXml) {
|
|
22216
22396
|
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${nestedXml}</hp:run></hp:p>`);
|
|
22217
22397
|
nestedH += (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH + 300;
|
|
22218
22398
|
}
|
|
22219
22399
|
}
|
|
22220
22400
|
if (paras.length === 0) {
|
|
22221
|
-
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${
|
|
22401
|
+
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${ch}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
22222
22402
|
}
|
|
22223
|
-
const
|
|
22224
|
-
|
|
22403
|
+
const contentH = Math.max(cellH * cell.rowSpan, Math.max(lines.length, 1) * 800 + nestedH);
|
|
22404
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _228 => _228.cellH, 'access', _229 => _229.get, 'call', _230 => _230(k)]), () => ( 0)), contentH);
|
|
22405
|
+
return `<hp:tc name="" header="${cell.isHeader ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${paras.join("")}</hp:subList><hp:cellAddr colAddr="${cell.c}" rowAddr="${cell.r}"/><hp:cellSpan colSpan="${cell.colSpan}" rowSpan="${cell.rowSpan}"/><hp:cellSz width="${cellW}" height="${cellHeight}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22225
22406
|
});
|
|
22226
22407
|
const trXmls = [];
|
|
22227
22408
|
for (let r = 0; r < rowCnt; r++) {
|
|
@@ -22387,9 +22568,9 @@ function readCommand(input, idx, depth) {
|
|
|
22387
22568
|
const command = name.value;
|
|
22388
22569
|
if (command === "\\") return { value: "#", next: name.next };
|
|
22389
22570
|
if (command === "frac") {
|
|
22390
|
-
const
|
|
22391
|
-
const den = readGroupOrToken(input,
|
|
22392
|
-
return { value: `{${
|
|
22571
|
+
const num4 = readGroupOrToken(input, name.next, depth);
|
|
22572
|
+
const den = readGroupOrToken(input, num4.next, depth);
|
|
22573
|
+
return { value: `{${num4.value}} over {${den.value}}`, next: den.next };
|
|
22393
22574
|
}
|
|
22394
22575
|
if (command === "sqrt") {
|
|
22395
22576
|
let cursor = skipSpaces(input, name.next);
|
|
@@ -22520,9 +22701,10 @@ function generateSecPr(gongmun) {
|
|
|
22520
22701
|
} : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
|
|
22521
22702
|
return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
|
|
22522
22703
|
}
|
|
22523
|
-
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null) {
|
|
22704
|
+
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, remap = null) {
|
|
22524
22705
|
const paraXmls = [];
|
|
22525
22706
|
let isFirst = true;
|
|
22707
|
+
let tableSeq = 0;
|
|
22526
22708
|
const orderedCounters = {};
|
|
22527
22709
|
let prevWasOrdered = false;
|
|
22528
22710
|
for (let blockIdx = 0; blockIdx < blocks.length; blockIdx++) {
|
|
@@ -22589,8 +22771,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22589
22771
|
case "list_item": {
|
|
22590
22772
|
if (gongmun && gongmunList) {
|
|
22591
22773
|
const info = gongmunList.get(blockIdx);
|
|
22592
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22593
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22774
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _231 => _231.depth]), () => ( 0));
|
|
22775
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _232 => _232.marker]), () => ( ""));
|
|
22594
22776
|
const content = block.text || "";
|
|
22595
22777
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
22596
22778
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -22630,11 +22812,12 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22630
22812
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
22631
22813
|
isFirst = false;
|
|
22632
22814
|
}
|
|
22633
|
-
xml = generateTable(block.rows, theme);
|
|
22815
|
+
xml = generateTable(block.rows, theme, _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _233 => _233.tables, 'access', _234 => _234.get, 'call', _235 => _235(tableSeq)]), () => ( null)));
|
|
22816
|
+
tableSeq++;
|
|
22634
22817
|
}
|
|
22635
22818
|
break;
|
|
22636
22819
|
case "html_table": {
|
|
22637
|
-
const tbl = generateHtmlTableXml(block.text || "", theme);
|
|
22820
|
+
const tbl = generateHtmlTableXml(block.text || "", theme, 44e3, _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _236 => _236.tables, 'access', _237 => _237.get, 'call', _238 => _238(tableSeq)]), () => ( null)));
|
|
22638
22821
|
if (tbl) {
|
|
22639
22822
|
if (isFirst) {
|
|
22640
22823
|
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
|
|
@@ -22642,6 +22825,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22642
22825
|
isFirst = false;
|
|
22643
22826
|
}
|
|
22644
22827
|
xml = `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${tbl}</hp:run></hp:p>`;
|
|
22828
|
+
tableSeq++;
|
|
22645
22829
|
} else {
|
|
22646
22830
|
const plain = (block.text || "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
22647
22831
|
xml = plain ? generateParagraph(plain) : "";
|
|
@@ -22668,20 +22852,108 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22668
22852
|
</hs:sec>`;
|
|
22669
22853
|
}
|
|
22670
22854
|
|
|
22855
|
+
// src/hwpx/gen-profile.ts
|
|
22856
|
+
function parseHu(s) {
|
|
22857
|
+
if (s == null) return void 0;
|
|
22858
|
+
const n = parseInt(String(s).trim(), 10);
|
|
22859
|
+
return Number.isFinite(n) ? n : void 0;
|
|
22860
|
+
}
|
|
22861
|
+
function edgeXml(tag, d) {
|
|
22862
|
+
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22863
|
+
}
|
|
22864
|
+
function borderFillDefToXml(id, def) {
|
|
22865
|
+
const fill = _optionalChain([def, 'access', _239 => _239.fill, 'optionalAccess', _240 => _240.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22866
|
+
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22867
|
+
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22868
|
+
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
22869
|
+
${edgeXml("leftBorder", def.leftBorder)}
|
|
22870
|
+
${edgeXml("rightBorder", def.rightBorder)}
|
|
22871
|
+
${edgeXml("topBorder", def.topBorder)}
|
|
22872
|
+
${edgeXml("bottomBorder", def.bottomBorder)}${fill ? `
|
|
22873
|
+
${fill}` : ""}
|
|
22874
|
+
</hh:borderFill>`;
|
|
22875
|
+
}
|
|
22876
|
+
function profileCharPrXml(id, def) {
|
|
22877
|
+
const height = _nullishCoalesce(parseHu(def.height_hwpunit), () => ( 1e3));
|
|
22878
|
+
const color = _nullishCoalesce(def.textColor, () => ( "#000000"));
|
|
22879
|
+
const font = def.fontRef_hangul != null ? parseInt(def.fontRef_hangul, 10) || 0 : 0;
|
|
22880
|
+
const boldAttr = def.bold ? ` bold="1"` : "";
|
|
22881
|
+
const italicAttr = def.italic ? ` italic="1"` : "";
|
|
22882
|
+
const underline = def.underline ? `
|
|
22883
|
+
<hh:underline type="BOTTOM" shape="SOLID" color="${color}"/>` : "";
|
|
22884
|
+
return ` <hh:charPr id="${id}" height="${height}" textColor="${color}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="1"${boldAttr}${italicAttr}>
|
|
22885
|
+
<hh:fontRef hangul="${font}" latin="${font}" hanja="${font}" japanese="${font}" other="${font}" symbol="${font}" user="${font}"/>
|
|
22886
|
+
<hh:ratio hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22887
|
+
<hh:spacing hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
22888
|
+
<hh:relSz hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22889
|
+
<hh:offset hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>${underline}
|
|
22890
|
+
</hh:charPr>`;
|
|
22891
|
+
}
|
|
22892
|
+
function buildProfileRemap(profile, charPrBase, borderFillBase = 3) {
|
|
22893
|
+
const remap = { borderFillXmls: [], charPrXmls: [], tables: /* @__PURE__ */ new Map() };
|
|
22894
|
+
let bfNext = borderFillBase;
|
|
22895
|
+
let charNext = charPrBase;
|
|
22896
|
+
for (const t of profile.tables) {
|
|
22897
|
+
const localBf = {};
|
|
22898
|
+
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_border_fills, () => ( {})))) {
|
|
22899
|
+
const gid = bfNext++;
|
|
22900
|
+
remap.borderFillXmls.push(borderFillDefToXml(gid, def));
|
|
22901
|
+
localBf[key] = gid;
|
|
22902
|
+
}
|
|
22903
|
+
const localChar = {};
|
|
22904
|
+
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_char_prs, () => ( {})))) {
|
|
22905
|
+
const gid = charNext++;
|
|
22906
|
+
remap.charPrXmls.push(profileCharPrXml(gid, def));
|
|
22907
|
+
localChar[key] = gid;
|
|
22908
|
+
}
|
|
22909
|
+
let colWidths;
|
|
22910
|
+
if (t.col_widths_hwpunit && t.col_widths_hwpunit.length === t.cols) {
|
|
22911
|
+
const parsed = t.col_widths_hwpunit.map(parseHu);
|
|
22912
|
+
if (parsed.every((n) => n != null)) colWidths = parsed;
|
|
22913
|
+
}
|
|
22914
|
+
const tr = {
|
|
22915
|
+
rows: t.rows,
|
|
22916
|
+
cols: t.cols,
|
|
22917
|
+
width: parseHu(t.width_hwpunit),
|
|
22918
|
+
colWidths,
|
|
22919
|
+
cellBf: /* @__PURE__ */ new Map(),
|
|
22920
|
+
cellChar: /* @__PURE__ */ new Map(),
|
|
22921
|
+
cellH: /* @__PURE__ */ new Map()
|
|
22922
|
+
};
|
|
22923
|
+
for (const cell of t.cells) {
|
|
22924
|
+
const k = `${cell.row},${cell.col}`;
|
|
22925
|
+
if (cell.borderFillIDRef != null && cell.borderFillIDRef in localBf) {
|
|
22926
|
+
tr.cellBf.set(k, localBf[cell.borderFillIDRef]);
|
|
22927
|
+
}
|
|
22928
|
+
if (cell.charPrIDRef != null && cell.charPrIDRef in localChar) {
|
|
22929
|
+
tr.cellChar.set(k, localChar[cell.charPrIDRef]);
|
|
22930
|
+
}
|
|
22931
|
+
const h = parseHu(cell.height_hwpunit);
|
|
22932
|
+
if (h != null) tr.cellH.set(k, h);
|
|
22933
|
+
}
|
|
22934
|
+
remap.tables.set(t.table_index, tr);
|
|
22935
|
+
}
|
|
22936
|
+
return remap;
|
|
22937
|
+
}
|
|
22938
|
+
function profileCharPrBase(ratioVariantCount) {
|
|
22939
|
+
return CHAR_VARIANT_BASE + ratioVariantCount * 4;
|
|
22940
|
+
}
|
|
22941
|
+
|
|
22671
22942
|
// src/hwpx/generator.ts
|
|
22672
22943
|
async function markdownToHwpx(markdown, options) {
|
|
22673
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
22674
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
22944
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _241 => _241.theme]));
|
|
22945
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _242 => _242.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
22675
22946
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
22676
22947
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
22677
22948
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
22949
|
+
const remap = _optionalChain([options, 'optionalAccess', _243 => _243.profile]) ? buildProfileRemap(options.profile, profileCharPrBase(_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _244 => _244.variants, 'optionalAccess', _245 => _245.length]), () => ( 0)))) : null;
|
|
22678
22950
|
const chartParts = [];
|
|
22679
|
-
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts);
|
|
22951
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, remap);
|
|
22680
22952
|
const zip = new (0, _jszip2.default)();
|
|
22681
22953
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
22682
22954
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
22683
22955
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
22684
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
22956
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _246 => _246.variants]), () => ( [])), remap));
|
|
22685
22957
|
zip.file("Contents/section0.xml", sectionXml);
|
|
22686
22958
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
22687
22959
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -22836,6 +23108,77 @@ var DEFAULT_PARA_GEOM = {
|
|
|
22836
23108
|
spaceAfter: 0
|
|
22837
23109
|
};
|
|
22838
23110
|
var DEFAULT_CHAR = { height: 1e3, bold: false, italic: false, underline: false, ratio: 100, spacing: 0 };
|
|
23111
|
+
var FONT_ALIASES = {
|
|
23112
|
+
"\uD568\uCD08\uB86C\uBC14\uD0D5": "'HCR Batang','\uD568\uCD08\uB86C\uBC14\uD0D5','\uD55C\uCEF4\uBC14\uD0D5'",
|
|
23113
|
+
"\uD55C\uCEF4\uBC14\uD0D5": "'HCR Batang','\uD568\uCD08\uB86C\uBC14\uD0D5','\uD55C\uCEF4\uBC14\uD0D5'",
|
|
23114
|
+
"\uD568\uCD08\uB86C\uB3CB\uC6C0": "'HCR Dotum','\uD568\uCD08\uB86C\uB3CB\uC6C0','\uD55C\uCEF4\uB3CB\uC6C0'",
|
|
23115
|
+
"\uD55C\uCEF4\uB3CB\uC6C0": "'HCR Dotum','\uD568\uCD08\uB86C\uB3CB\uC6C0','\uD55C\uCEF4\uB3CB\uC6C0'",
|
|
23116
|
+
"\uB9D1\uC740 \uACE0\uB515": "'Malgun Gothic','\uB9D1\uC740 \uACE0\uB515'",
|
|
23117
|
+
"\uB9D1\uC740\uACE0\uB515": "'Malgun Gothic','\uB9D1\uC740 \uACE0\uB515'",
|
|
23118
|
+
"\uAD74\uB9BC": "'Gulim','\uAD74\uB9BC'",
|
|
23119
|
+
"\uAD74\uB9BC\uCCB4": "'GulimChe','\uAD74\uB9BC\uCCB4','Gulim'",
|
|
23120
|
+
"\uB3CB\uC6C0": "'Dotum','\uB3CB\uC6C0'",
|
|
23121
|
+
"\uB3CB\uC6C0\uCCB4": "'DotumChe','\uB3CB\uC6C0\uCCB4','Dotum'",
|
|
23122
|
+
"\uBC14\uD0D5": "'Batang','\uBC14\uD0D5'",
|
|
23123
|
+
"\uBC14\uD0D5\uCCB4": "'BatangChe','\uBC14\uD0D5\uCCB4','Batang'",
|
|
23124
|
+
"\uAD81\uC11C": "'Gungsuh','\uAD81\uC11C'",
|
|
23125
|
+
"\uAD81\uC11C\uCCB4": "'GungsuhChe','\uAD81\uC11C\uCCB4','Gungsuh'",
|
|
23126
|
+
"\uB098\uB214\uACE0\uB515": "'NanumGothic','\uB098\uB214\uACE0\uB515'",
|
|
23127
|
+
"\uB098\uB214\uBA85\uC870": "'NanumMyeongjo','\uB098\uB214\uBA85\uC870'",
|
|
23128
|
+
"\uB9D1\uC740 \uACE0\uB515 Semilight": "'Malgun Gothic Semilight','\uB9D1\uC740 \uACE0\uB515'"
|
|
23129
|
+
};
|
|
23130
|
+
function isSerifFace(face) {
|
|
23131
|
+
return /바탕|명조|Batang|Myeong|Mincho|궁서|Gungsuh|Serif|신명|순명|Song|송/i.test(face);
|
|
23132
|
+
}
|
|
23133
|
+
function cssQuote(name) {
|
|
23134
|
+
return /^[A-Za-z0-9_-]+$/.test(name) ? name : `'${name.replace(/['"\\]/g, "")}'`;
|
|
23135
|
+
}
|
|
23136
|
+
function hwpFaceToCssStack(face) {
|
|
23137
|
+
const trimmed = (_nullishCoalesce(face, () => ( ""))).trim();
|
|
23138
|
+
if (!trimmed) return "";
|
|
23139
|
+
const generic = isSerifFace(trimmed) ? "'HCR Batang','Batang','Noto Serif KR',serif" : "'Malgun Gothic','HCR Dotum','Noto Sans KR',sans-serif";
|
|
23140
|
+
const head = _nullishCoalesce(FONT_ALIASES[trimmed], () => ( cssQuote(trimmed)));
|
|
23141
|
+
return `${head},${generic}`;
|
|
23142
|
+
}
|
|
23143
|
+
function collectHangulFonts(root) {
|
|
23144
|
+
const map = /* @__PURE__ */ new Map();
|
|
23145
|
+
const findFaces = (el, depth) => {
|
|
23146
|
+
if (depth > 24) return null;
|
|
23147
|
+
for (const ch of Array.from(el.childNodes)) {
|
|
23148
|
+
if (ch.nodeType !== 1) continue;
|
|
23149
|
+
const e = ch;
|
|
23150
|
+
if ((e.tagName || "").replace(/^[^:]+:/, "") === "fontfaces") return e;
|
|
23151
|
+
const f = findFaces(e, depth + 1);
|
|
23152
|
+
if (f) return f;
|
|
23153
|
+
}
|
|
23154
|
+
return null;
|
|
23155
|
+
};
|
|
23156
|
+
const faces = findFaces(root, 0);
|
|
23157
|
+
if (!faces) return map;
|
|
23158
|
+
let group = null;
|
|
23159
|
+
let firstGroup = null;
|
|
23160
|
+
for (const ch of Array.from(faces.childNodes)) {
|
|
23161
|
+
if (ch.nodeType !== 1) continue;
|
|
23162
|
+
const e = ch;
|
|
23163
|
+
if ((e.tagName || "").replace(/^[^:]+:/, "") !== "fontface") continue;
|
|
23164
|
+
if (!firstGroup) firstGroup = e;
|
|
23165
|
+
if ((_nullishCoalesce(e.getAttribute("lang"), () => ( ""))).toUpperCase() === "HANGUL") {
|
|
23166
|
+
group = e;
|
|
23167
|
+
break;
|
|
23168
|
+
}
|
|
23169
|
+
}
|
|
23170
|
+
group = _nullishCoalesce(group, () => ( firstGroup));
|
|
23171
|
+
if (!group) return map;
|
|
23172
|
+
for (const ch of Array.from(group.childNodes)) {
|
|
23173
|
+
if (ch.nodeType !== 1) continue;
|
|
23174
|
+
const e = ch;
|
|
23175
|
+
if ((e.tagName || "").replace(/^[^:]+:/, "") !== "font") continue;
|
|
23176
|
+
const id = e.getAttribute("id");
|
|
23177
|
+
const face = e.getAttribute("face");
|
|
23178
|
+
if (id != null && face) map.set(id, face);
|
|
23179
|
+
}
|
|
23180
|
+
return map;
|
|
23181
|
+
}
|
|
22839
23182
|
function borderWidthPt(v) {
|
|
22840
23183
|
const n = parseFloat(_nullishCoalesce(v, () => ( "")));
|
|
22841
23184
|
if (!Number.isFinite(n)) return 0.34;
|
|
@@ -22887,6 +23230,7 @@ function parseRenderStyles(headXml) {
|
|
|
22887
23230
|
const doc = createXmlParser().parseFromString(headXml, "text/xml");
|
|
22888
23231
|
const root = doc.documentElement;
|
|
22889
23232
|
if (!root) return styles;
|
|
23233
|
+
const hangulFonts = collectHangulFonts(root);
|
|
22890
23234
|
const walk = (el) => {
|
|
22891
23235
|
const tag = (el.tagName || "").replace(/^[^:]+:/, "");
|
|
22892
23236
|
if (tag === "charPr") {
|
|
@@ -22896,21 +23240,25 @@ function parseRenderStyles(headXml) {
|
|
|
22896
23240
|
const spacingEl = findChildByLocalName(el, "spacing");
|
|
22897
23241
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
22898
23242
|
const textColor = el.getAttribute("textColor");
|
|
23243
|
+
const fontRef = findChildByLocalName(el, "fontRef");
|
|
23244
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _247 => _247.getAttribute, 'call', _248 => _248("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _249 => _249.getAttribute, 'call', _250 => _250("latin")])));
|
|
23245
|
+
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
22899
23246
|
styles.charPr.set(id, {
|
|
22900
23247
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
22901
23248
|
bold: findChildByLocalName(el, "bold") != null,
|
|
22902
23249
|
italic: findChildByLocalName(el, "italic") != null,
|
|
22903
23250
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
22904
23251
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
22905
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
22906
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
23252
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _251 => _251.getAttribute, 'call', _252 => _252("hangul")])) || 100,
|
|
23253
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _253 => _253.getAttribute, 'call', _254 => _254("hangul")])) || 0,
|
|
23254
|
+
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
22907
23255
|
});
|
|
22908
23256
|
}
|
|
22909
23257
|
} else if (tag === "paraPr") {
|
|
22910
23258
|
const id = el.getAttribute("id");
|
|
22911
23259
|
if (id != null) {
|
|
22912
23260
|
const align = findChildByLocalName(el, "align");
|
|
22913
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
23261
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _255 => _255.getAttribute, 'call', _256 => _256("horizontal")]) || "JUSTIFY");
|
|
22914
23262
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
22915
23263
|
}
|
|
22916
23264
|
} else if (tag === "borderFill") {
|
|
@@ -22924,7 +23272,7 @@ function parseRenderStyles(headXml) {
|
|
|
22924
23272
|
};
|
|
22925
23273
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
22926
23274
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
22927
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
23275
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _257 => _257.getAttribute, 'call', _258 => _258("faceColor")]);
|
|
22928
23276
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
22929
23277
|
styles.borderFill.set(id, bf);
|
|
22930
23278
|
}
|
|
@@ -22996,7 +23344,7 @@ function collectSites(scan) {
|
|
|
22996
23344
|
}
|
|
22997
23345
|
function attrOf(openTag, name) {
|
|
22998
23346
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
22999
|
-
return _optionalChain([m, 'optionalAccess',
|
|
23347
|
+
return _optionalChain([m, 'optionalAccess', _259 => _259[1]]);
|
|
23000
23348
|
}
|
|
23001
23349
|
function paraOpenTag(xml, para) {
|
|
23002
23350
|
const end = xml.indexOf(">", para.start);
|
|
@@ -23011,7 +23359,7 @@ function anchorRunInfo(xml, para, anchor) {
|
|
|
23011
23359
|
if (!tr) return null;
|
|
23012
23360
|
const before = xml.slice(Math.max(0, para.start), tr.contentStart);
|
|
23013
23361
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
23014
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
23362
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _260 => _260[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
23015
23363
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
23016
23364
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
23017
23365
|
if (close === -1) return null;
|
|
@@ -23038,7 +23386,7 @@ function cellContentWidthMm(xml, cell) {
|
|
|
23038
23386
|
if (width === null) return null;
|
|
23039
23387
|
let content = width;
|
|
23040
23388
|
const win = cellAddrWindow(xml, cell);
|
|
23041
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
23389
|
+
const mg = _optionalChain([win, 'optionalAccess', _261 => _261.match, 'call', _262 => _262(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
23042
23390
|
if (mg) {
|
|
23043
23391
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
23044
23392
|
}
|
|
@@ -23072,11 +23420,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
23072
23420
|
return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
|
|
23073
23421
|
}
|
|
23074
23422
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
23075
|
-
if (ops.length === 0) throw new (0,
|
|
23423
|
+
if (ops.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23076
23424
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
23077
23425
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
23078
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
23079
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
23426
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _263 => _263.match, 'call', _264 => _264(/(\d+)\.xml$/i), 'optionalAccess', _265 => _265[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _266 => _266.match, 'call', _267 => _267(/(\d+)\.xml$/i), 'optionalAccess', _268 => _268[1]]), () => ( 0))));
|
|
23427
|
+
if (sectionPaths.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23080
23428
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
23081
23429
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
23082
23430
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -23117,11 +23465,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23117
23465
|
const manifestItems = [];
|
|
23118
23466
|
const placed = [];
|
|
23119
23467
|
for (const op of ops) {
|
|
23120
|
-
if (!op.anchor) throw new (0,
|
|
23121
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
23468
|
+
if (!op.anchor) throw new (0, _chunk5HDBLRVPcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23469
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23122
23470
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
23123
|
-
if (!MIME[ext]) throw new (0,
|
|
23124
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
23471
|
+
if (!MIME[ext]) throw new (0, _chunk5HDBLRVPcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
23472
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunk5HDBLRVPcjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
23125
23473
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
23126
23474
|
let found = null;
|
|
23127
23475
|
let total = 0;
|
|
@@ -23154,7 +23502,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23154
23502
|
}
|
|
23155
23503
|
}
|
|
23156
23504
|
}
|
|
23157
|
-
throw new (0,
|
|
23505
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
23158
23506
|
`place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
|
|
23159
23507
|
);
|
|
23160
23508
|
}
|
|
@@ -23162,9 +23510,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23162
23510
|
const xml = sectionXmls[si];
|
|
23163
23511
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
23164
23512
|
if (!run) {
|
|
23165
|
-
throw new (0,
|
|
23513
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
23166
23514
|
}
|
|
23167
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
23515
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _269 => _269.charPr, 'access', _270 => _270.get, 'call', _271 => _271(run.charPr), 'optionalAccess', _272 => _272.height]), () => ( 1e3));
|
|
23168
23516
|
const fontPt = charPrHeight / 100;
|
|
23169
23517
|
const emMm = fontPt * 25.4 / 72;
|
|
23170
23518
|
const lineHMm = emMm;
|
|
@@ -23173,7 +23521,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23173
23521
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
23174
23522
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
23175
23523
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
23176
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
23524
|
+
const align = _optionalChain([styles, 'optionalAccess', _273 => _273.paraAlign, 'access', _274 => _274.get, 'call', _275 => _275(paraPrId)]);
|
|
23177
23525
|
let alignShiftMm = 0;
|
|
23178
23526
|
if (align === "CENTER" || align === "RIGHT") {
|
|
23179
23527
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -23237,6 +23585,184 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23237
23585
|
};
|
|
23238
23586
|
}
|
|
23239
23587
|
|
|
23588
|
+
// src/hwpx/extract-profile.ts
|
|
23589
|
+
|
|
23590
|
+
function elemsByLocal(root, name) {
|
|
23591
|
+
const all = root.getElementsByTagName("*");
|
|
23592
|
+
const out = [];
|
|
23593
|
+
for (let i = 0; i < all.length; i++) {
|
|
23594
|
+
const el = all[i];
|
|
23595
|
+
const tag = (el.tagName || el.localName || "").replace(/^[^:]+:/, "");
|
|
23596
|
+
if (tag === name) out.push(el);
|
|
23597
|
+
}
|
|
23598
|
+
return out;
|
|
23599
|
+
}
|
|
23600
|
+
function borderDefOf(el) {
|
|
23601
|
+
if (!el) return void 0;
|
|
23602
|
+
const type = el.getAttribute("type") || "NONE";
|
|
23603
|
+
const width = el.getAttribute("width") || "0.1 mm";
|
|
23604
|
+
const color = el.getAttribute("color") || "#000000";
|
|
23605
|
+
return { type, width, color };
|
|
23606
|
+
}
|
|
23607
|
+
function parseBorderFills(headerDoc) {
|
|
23608
|
+
const map = /* @__PURE__ */ new Map();
|
|
23609
|
+
for (const bf of elemsByLocal(headerDoc, "borderFill")) {
|
|
23610
|
+
const id = bf.getAttribute("id");
|
|
23611
|
+
if (!id) continue;
|
|
23612
|
+
const def = {
|
|
23613
|
+
leftBorder: borderDefOf(findChildByLocalName(bf, "leftBorder")),
|
|
23614
|
+
rightBorder: borderDefOf(findChildByLocalName(bf, "rightBorder")),
|
|
23615
|
+
topBorder: borderDefOf(findChildByLocalName(bf, "topBorder")),
|
|
23616
|
+
bottomBorder: borderDefOf(findChildByLocalName(bf, "bottomBorder"))
|
|
23617
|
+
};
|
|
23618
|
+
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
23619
|
+
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
23620
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _276 => _276.getAttribute, 'call', _277 => _277("faceColor")]);
|
|
23621
|
+
if (face && face !== "none") def.fill = { faceColor: face };
|
|
23622
|
+
map.set(id, def);
|
|
23623
|
+
}
|
|
23624
|
+
return map;
|
|
23625
|
+
}
|
|
23626
|
+
function parseCharPrs(headerDoc) {
|
|
23627
|
+
const map = /* @__PURE__ */ new Map();
|
|
23628
|
+
for (const cp of elemsByLocal(headerDoc, "charPr")) {
|
|
23629
|
+
const id = cp.getAttribute("id");
|
|
23630
|
+
if (!id) continue;
|
|
23631
|
+
const def = {};
|
|
23632
|
+
const h = cp.getAttribute("height");
|
|
23633
|
+
if (h) def.height_hwpunit = h;
|
|
23634
|
+
const color = cp.getAttribute("textColor");
|
|
23635
|
+
if (color) def.textColor = color;
|
|
23636
|
+
if (cp.getAttribute("bold") === "1") def.bold = true;
|
|
23637
|
+
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
23638
|
+
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
23639
|
+
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
23640
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _278 => _278.getAttribute, 'call', _279 => _279("hangul")]);
|
|
23641
|
+
if (hangul) def.fontRef_hangul = hangul;
|
|
23642
|
+
map.set(id, def);
|
|
23643
|
+
}
|
|
23644
|
+
return map;
|
|
23645
|
+
}
|
|
23646
|
+
function isTopLevelTable(tbl) {
|
|
23647
|
+
let p = tbl.parentNode;
|
|
23648
|
+
while (p) {
|
|
23649
|
+
const tag = (p.tagName || p.localName || "").replace(/^[^:]+:/, "");
|
|
23650
|
+
if (tag === "tbl") return false;
|
|
23651
|
+
p = p.parentNode;
|
|
23652
|
+
}
|
|
23653
|
+
return true;
|
|
23654
|
+
}
|
|
23655
|
+
function num(s) {
|
|
23656
|
+
if (s == null) return void 0;
|
|
23657
|
+
const n = parseInt(s, 10);
|
|
23658
|
+
return Number.isFinite(n) ? n : void 0;
|
|
23659
|
+
}
|
|
23660
|
+
function parseTable3(tbl, tableIndex, borderFills, charPrs) {
|
|
23661
|
+
const rows = _nullishCoalesce(num(tbl.getAttribute("rowCnt")), () => ( 0));
|
|
23662
|
+
const cols = _nullishCoalesce(num(tbl.getAttribute("colCnt")), () => ( 0));
|
|
23663
|
+
const sz = findChildByLocalName(tbl, "sz");
|
|
23664
|
+
const width = _optionalChain([sz, 'optionalAccess', _280 => _280.getAttribute, 'call', _281 => _281("width")]) || void 0;
|
|
23665
|
+
const cells = [];
|
|
23666
|
+
const usedBf = /* @__PURE__ */ new Set();
|
|
23667
|
+
const usedCp = /* @__PURE__ */ new Set();
|
|
23668
|
+
const colWidths = new Array(cols).fill(void 0);
|
|
23669
|
+
for (const tc of elemsByLocal(tbl, "tc")) {
|
|
23670
|
+
if (nearestTable(tc) !== tbl) continue;
|
|
23671
|
+
const addr = findChildByLocalName(tc, "cellAddr");
|
|
23672
|
+
const span = findChildByLocalName(tc, "cellSpan");
|
|
23673
|
+
const csz = findChildByLocalName(tc, "cellSz");
|
|
23674
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _282 => _282.getAttribute, 'call', _283 => _283("rowAddr")])), () => ( 0));
|
|
23675
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _284 => _284.getAttribute, 'call', _285 => _285("colAddr")])), () => ( 0));
|
|
23676
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _286 => _286.getAttribute, 'call', _287 => _287("colSpan")])), () => ( 1));
|
|
23677
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _288 => _288.getAttribute, 'call', _289 => _289("rowSpan")])), () => ( 1));
|
|
23678
|
+
const bfId = tc.getAttribute("borderFillIDRef") || void 0;
|
|
23679
|
+
const cpId = firstRunCharPr(tc);
|
|
23680
|
+
const cell = { row, col, rowSpan, colSpan };
|
|
23681
|
+
const w = _optionalChain([csz, 'optionalAccess', _290 => _290.getAttribute, 'call', _291 => _291("width")]);
|
|
23682
|
+
const hh = _optionalChain([csz, 'optionalAccess', _292 => _292.getAttribute, 'call', _293 => _293("height")]);
|
|
23683
|
+
if (w) cell.width_hwpunit = w;
|
|
23684
|
+
if (hh) cell.height_hwpunit = hh;
|
|
23685
|
+
if (bfId) {
|
|
23686
|
+
cell.borderFillIDRef = bfId;
|
|
23687
|
+
usedBf.add(bfId);
|
|
23688
|
+
}
|
|
23689
|
+
if (cpId) {
|
|
23690
|
+
cell.charPrIDRef = cpId;
|
|
23691
|
+
usedCp.add(cpId);
|
|
23692
|
+
}
|
|
23693
|
+
cells.push(cell);
|
|
23694
|
+
if (row === 0 && colSpan === 1 && col < cols && w) colWidths[col] = w;
|
|
23695
|
+
}
|
|
23696
|
+
const table = {
|
|
23697
|
+
table_index: tableIndex,
|
|
23698
|
+
rows,
|
|
23699
|
+
cols,
|
|
23700
|
+
cells,
|
|
23701
|
+
used_border_fills: pick(borderFills, usedBf)
|
|
23702
|
+
};
|
|
23703
|
+
if (width) table.width_hwpunit = width;
|
|
23704
|
+
if (colWidths.every((w) => w != null)) table.col_widths_hwpunit = colWidths;
|
|
23705
|
+
const cp = pick(charPrs, usedCp);
|
|
23706
|
+
if (Object.keys(cp).length) table.used_char_prs = cp;
|
|
23707
|
+
return table;
|
|
23708
|
+
}
|
|
23709
|
+
function nearestTable(tc) {
|
|
23710
|
+
let p = tc.parentNode;
|
|
23711
|
+
while (p) {
|
|
23712
|
+
const tag = (p.tagName || p.localName || "").replace(/^[^:]+:/, "");
|
|
23713
|
+
if (tag === "tbl") return p;
|
|
23714
|
+
p = p.parentNode;
|
|
23715
|
+
}
|
|
23716
|
+
return null;
|
|
23717
|
+
}
|
|
23718
|
+
function firstRunCharPr(tc) {
|
|
23719
|
+
for (const run of elemsByLocal(tc, "run")) {
|
|
23720
|
+
if (nearestCell(run) !== tc) continue;
|
|
23721
|
+
const id = run.getAttribute("charPrIDRef");
|
|
23722
|
+
if (id) return id;
|
|
23723
|
+
}
|
|
23724
|
+
return void 0;
|
|
23725
|
+
}
|
|
23726
|
+
function nearestCell(el) {
|
|
23727
|
+
let p = el.parentNode;
|
|
23728
|
+
while (p) {
|
|
23729
|
+
const tag = (p.tagName || p.localName || "").replace(/^[^:]+:/, "");
|
|
23730
|
+
if (tag === "tc") return p;
|
|
23731
|
+
p = p.parentNode;
|
|
23732
|
+
}
|
|
23733
|
+
return null;
|
|
23734
|
+
}
|
|
23735
|
+
function pick(map, keys) {
|
|
23736
|
+
const out = {};
|
|
23737
|
+
for (const k of keys) {
|
|
23738
|
+
const v = map.get(k);
|
|
23739
|
+
if (v !== void 0) out[k] = v;
|
|
23740
|
+
}
|
|
23741
|
+
return out;
|
|
23742
|
+
}
|
|
23743
|
+
async function hwpxToProfile(input) {
|
|
23744
|
+
const buf = input instanceof ArrayBuffer ? input : _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, input);
|
|
23745
|
+
const zip = await _jszip2.default.loadAsync(buf);
|
|
23746
|
+
const parser = createXmlParser();
|
|
23747
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _294 => _294.file, 'call', _295 => _295(/[Hh]eader\.xml$/), 'optionalAccess', _296 => _296[0]])));
|
|
23748
|
+
let headerXml = "<root/>";
|
|
23749
|
+
if (headerFile) headerXml = await headerFile.async("text");
|
|
23750
|
+
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
23751
|
+
const borderFills = parseBorderFills(headerDoc);
|
|
23752
|
+
const charPrs = parseCharPrs(headerDoc);
|
|
23753
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _297 => _297.name, 'access', _298 => _298.match, 'call', _299 => _299(/(\d+)\.xml$/), 'optionalAccess', _300 => _300[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _301 => _301.name, 'access', _302 => _302.match, 'call', _303 => _303(/(\d+)\.xml$/), 'optionalAccess', _304 => _304[1]]), () => ( null))), () => ( 0))));
|
|
23754
|
+
const tables = [];
|
|
23755
|
+
let tableIndex = 0;
|
|
23756
|
+
for (const f of sectionFiles) {
|
|
23757
|
+
const doc = parser.parseFromString(await f.async("text"), "text/xml");
|
|
23758
|
+
for (const tbl of elemsByLocal(doc, "tbl")) {
|
|
23759
|
+
if (!isTopLevelTable(tbl)) continue;
|
|
23760
|
+
tables.push(parseTable3(tbl, tableIndex++, borderFills, charPrs));
|
|
23761
|
+
}
|
|
23762
|
+
}
|
|
23763
|
+
return { schema_version: "0.1.0", tables };
|
|
23764
|
+
}
|
|
23765
|
+
|
|
23240
23766
|
// src/roundtrip/patcher.ts
|
|
23241
23767
|
|
|
23242
23768
|
|
|
@@ -23245,7 +23771,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
23245
23771
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
23246
23772
|
function patchTableRows(input) {
|
|
23247
23773
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
23248
|
-
const xml = _optionalChain([ctx, 'access',
|
|
23774
|
+
const xml = _optionalChain([ctx, 'access', _305 => _305.scans, 'access', _306 => _306[scanTable.sectionIndex], 'optionalAccess', _307 => _307.xml]);
|
|
23249
23775
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
23250
23776
|
const numRows = table.rows;
|
|
23251
23777
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -23412,7 +23938,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
23412
23938
|
const rr = scanTable.rowRanges[template];
|
|
23413
23939
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
23414
23940
|
const scan = scanSectionXml(wrapped, 0);
|
|
23415
|
-
const row = _optionalChain([scan, 'access',
|
|
23941
|
+
const row = _optionalChain([scan, 'access', _308 => _308.tables, 'access', _309 => _309[0], 'optionalAccess', _310 => _310.rows, 'access', _311 => _311[0]]);
|
|
23416
23942
|
if (!row || row.length !== cells.length) return null;
|
|
23417
23943
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
23418
23944
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -23455,7 +23981,7 @@ function rowHeightOf(fragment) {
|
|
|
23455
23981
|
}
|
|
23456
23982
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
23457
23983
|
const from = scanTable.start + tblOpenLen;
|
|
23458
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
23984
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _312 => _312.rowRanges, 'access', _313 => _313[0], 'optionalAccess', _314 => _314.start]), () => ( from));
|
|
23459
23985
|
const slice = xml.slice(from, to);
|
|
23460
23986
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
23461
23987
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -23644,9 +24170,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
23644
24170
|
});
|
|
23645
24171
|
}
|
|
23646
24172
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
23647
|
-
const irCell = _optionalChain([table, 'access',
|
|
24173
|
+
const irCell = _optionalChain([table, 'access', _315 => _315.cells, 'access', _316 => _316[oc.gridR], 'optionalAccess', _317 => _317[oc.gridC]]);
|
|
23648
24174
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
23649
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
24175
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _318 => _318.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
23650
24176
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
23651
24177
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
23652
24178
|
}
|
|
@@ -23714,7 +24240,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23714
24240
|
};
|
|
23715
24241
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
23716
24242
|
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)");
|
|
23717
|
-
const irCell = _optionalChain([table, 'access',
|
|
24243
|
+
const irCell = _optionalChain([table, 'access', _319 => _319.cells, 'access', _320 => _320[gridR], 'optionalAccess', _321 => _321[gridC]]);
|
|
23718
24244
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
23719
24245
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23720
24246
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -23737,7 +24263,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23737
24263
|
if (newLines.length === 0) return 0;
|
|
23738
24264
|
const target = cell.paragraphs[0];
|
|
23739
24265
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
23740
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
24266
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _322 => _322.scans, 'access', _323 => _323[target.sectionIndex], 'optionalAccess', _324 => _324.xml]));
|
|
23741
24267
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23742
24268
|
splices.push(...sp);
|
|
23743
24269
|
sectionIndex = target.sectionIndex;
|
|
@@ -23760,7 +24286,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23760
24286
|
}
|
|
23761
24287
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
23762
24288
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
23763
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
24289
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _325 => _325.scans, 'access', _326 => _326[nonEmpty[i].sectionIndex], 'optionalAccess', _327 => _327.xml]));
|
|
23764
24290
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23765
24291
|
splices.push(...sp);
|
|
23766
24292
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -23841,7 +24367,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
23841
24367
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
23842
24368
|
if (paths.length > 0) return paths;
|
|
23843
24369
|
}
|
|
23844
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
24370
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk5HDBLRVPcjs.compareSectionPaths);
|
|
23845
24371
|
}
|
|
23846
24372
|
function sectionPathsFromManifest(xml) {
|
|
23847
24373
|
const attr = (tag, name) => {
|
|
@@ -23851,7 +24377,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23851
24377
|
const idToHref = /* @__PURE__ */ new Map();
|
|
23852
24378
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
23853
24379
|
const id = attr(m[1], "id");
|
|
23854
|
-
const href =
|
|
24380
|
+
const href = _chunk5HDBLRVPcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
23855
24381
|
if (id && href) idToHref.set(id, href);
|
|
23856
24382
|
}
|
|
23857
24383
|
const ordered = [];
|
|
@@ -23860,7 +24386,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23860
24386
|
if (href) ordered.push(href);
|
|
23861
24387
|
}
|
|
23862
24388
|
if (ordered.length > 0) return ordered;
|
|
23863
|
-
return Array.from(idToHref.values()).sort(
|
|
24389
|
+
return Array.from(idToHref.values()).sort(_chunk5HDBLRVPcjs.compareSectionPaths);
|
|
23864
24390
|
}
|
|
23865
24391
|
|
|
23866
24392
|
// src/roundtrip/patcher.ts
|
|
@@ -23952,7 +24478,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
23952
24478
|
}
|
|
23953
24479
|
}
|
|
23954
24480
|
let verification;
|
|
23955
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24481
|
+
if (_optionalChain([options, 'optionalAccess', _328 => _328.verify]) !== false) {
|
|
23956
24482
|
try {
|
|
23957
24483
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
23958
24484
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -23967,20 +24493,20 @@ function buildOrigUnits(blocks) {
|
|
|
23967
24493
|
for (let i = 0; i < blocks.length; i++) {
|
|
23968
24494
|
const block = blocks[i];
|
|
23969
24495
|
let consume = 1;
|
|
23970
|
-
let
|
|
24496
|
+
let chunk2;
|
|
23971
24497
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
23972
24498
|
const next = blocks[i + 1];
|
|
23973
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
23974
|
-
|
|
24499
|
+
if (_optionalChain([next, 'optionalAccess', _329 => _329.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
24500
|
+
chunk2 = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
23975
24501
|
} else {
|
|
23976
|
-
|
|
24502
|
+
chunk2 = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, [block]);
|
|
23977
24503
|
}
|
|
23978
|
-
if (
|
|
23979
|
-
const subUnits = splitMarkdownUnits(
|
|
24504
|
+
if (chunk2) {
|
|
24505
|
+
const subUnits = splitMarkdownUnits(chunk2);
|
|
23980
24506
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
23981
24507
|
for (let s = 0; s < subUnits.length; s++) {
|
|
23982
24508
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
23983
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
24509
|
+
if (block.type === "table" && _optionalChain([block, 'access', _330 => _330.table, 'optionalAccess', _331 => _331.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
23984
24510
|
u.role = "caption";
|
|
23985
24511
|
}
|
|
23986
24512
|
units.push(u);
|
|
@@ -24091,7 +24617,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24091
24617
|
const ti = ctx.tableInsert;
|
|
24092
24618
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
24093
24619
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24094
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24620
|
+
if (!_optionalChain([mapping, 'optionalAccess', _332 => _332.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");
|
|
24095
24621
|
const para = mapping.para;
|
|
24096
24622
|
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");
|
|
24097
24623
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -24119,7 +24645,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24119
24645
|
}
|
|
24120
24646
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
24121
24647
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24122
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24648
|
+
if (!_optionalChain([mapping, 'optionalAccess', _333 => _333.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)");
|
|
24123
24649
|
if (block.text && block.text.includes("\n")) {
|
|
24124
24650
|
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)");
|
|
24125
24651
|
}
|
|
@@ -24150,7 +24676,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
24150
24676
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24151
24677
|
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");
|
|
24152
24678
|
}
|
|
24153
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
24679
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _334 => _334.scans, 'access', _335 => _335[mapping.para.sectionIndex], 'optionalAccess', _336 => _336.xml]));
|
|
24154
24680
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24155
24681
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24156
24682
|
return 1;
|
|
@@ -24336,7 +24862,7 @@ var Surgeon = (_class4 = class {
|
|
|
24336
24862
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
24337
24863
|
findEntry(path) {
|
|
24338
24864
|
const parts = path.replace(/^\//, "").split("/");
|
|
24339
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
24865
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _337 => _337.entries, 'access', _338 => _338[0], 'optionalAccess', _339 => _339.child]), () => ( -1));
|
|
24340
24866
|
let current;
|
|
24341
24867
|
for (const part of parts) {
|
|
24342
24868
|
const search = (idx) => {
|
|
@@ -24549,8 +25075,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
24549
25075
|
parts.push(header, data);
|
|
24550
25076
|
};
|
|
24551
25077
|
for (let i = 0; i < recs.length; i++) {
|
|
24552
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
24553
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
25078
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _340 => _340.get, 'call', _341 => _341(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
25079
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _342 => _342.get, 'call', _343 => _343(i)]), () => ( recs[i].data)));
|
|
24554
25080
|
}
|
|
24555
25081
|
return Buffer.concat(parts);
|
|
24556
25082
|
}
|
|
@@ -24668,7 +25194,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24668
25194
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
24669
25195
|
}
|
|
24670
25196
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
24671
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
25197
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _344 => _344.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
24672
25198
|
let flags;
|
|
24673
25199
|
try {
|
|
24674
25200
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -24690,7 +25216,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24690
25216
|
const scans = [];
|
|
24691
25217
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
24692
25218
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
24693
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
25219
|
+
if (!_optionalChain([entry, 'optionalAccess', _345 => _345.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
24694
25220
|
let stream;
|
|
24695
25221
|
try {
|
|
24696
25222
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -24741,7 +25267,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24741
25267
|
}
|
|
24742
25268
|
}
|
|
24743
25269
|
let verification;
|
|
24744
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25270
|
+
if (_optionalChain([options, 'optionalAccess', _346 => _346.verify]) !== false) {
|
|
24745
25271
|
try {
|
|
24746
25272
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
24747
25273
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -24810,19 +25336,19 @@ function resolveTableMappings(blocks, scanTables) {
|
|
|
24810
25336
|
if (scanTables[k].rows === table.rows && scanTables[k].cols === table.cols) cands.push(k);
|
|
24811
25337
|
}
|
|
24812
25338
|
if (cands.length === 0) continue;
|
|
24813
|
-
let
|
|
25339
|
+
let pick2 = cands[0];
|
|
24814
25340
|
if (cands.length > 1) {
|
|
24815
25341
|
let best = tableContentScore(table, scanTables[cands[0]]);
|
|
24816
25342
|
for (let ci = 1; ci < cands.length; ci++) {
|
|
24817
25343
|
const sc = tableContentScore(table, scanTables[cands[ci]]);
|
|
24818
25344
|
if (sc > best) {
|
|
24819
25345
|
best = sc;
|
|
24820
|
-
|
|
25346
|
+
pick2 = cands[ci];
|
|
24821
25347
|
}
|
|
24822
25348
|
}
|
|
24823
25349
|
}
|
|
24824
|
-
result.set(i, scanTables[
|
|
24825
|
-
si =
|
|
25350
|
+
result.set(i, scanTables[pick2]);
|
|
25351
|
+
si = pick2 + 1;
|
|
24826
25352
|
}
|
|
24827
25353
|
return result;
|
|
24828
25354
|
}
|
|
@@ -24831,7 +25357,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
24831
25357
|
for (const [key, scanCell] of scanTable.cells) {
|
|
24832
25358
|
const comma = key.indexOf(",");
|
|
24833
25359
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
24834
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
25360
|
+
const irCell = _optionalChain([irTable, 'access', _347 => _347.cells, 'access', _348 => _348[r], 'optionalAccess', _349 => _349[c]]);
|
|
24835
25361
|
if (!irCell) continue;
|
|
24836
25362
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
24837
25363
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -24867,7 +25393,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
24867
25393
|
}
|
|
24868
25394
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
24869
25395
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24870
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25396
|
+
if (!_optionalChain([mapping, 'optionalAccess', _350 => _350.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)");
|
|
24871
25397
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
24872
25398
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
24873
25399
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -25066,7 +25592,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25066
25592
|
};
|
|
25067
25593
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
25068
25594
|
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)");
|
|
25069
|
-
const irCell = _optionalChain([table, 'access',
|
|
25595
|
+
const irCell = _optionalChain([table, 'access', _351 => _351.cells, 'access', _352 => _352[gridR], 'optionalAccess', _353 => _353[gridC]]);
|
|
25070
25596
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
25071
25597
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25072
25598
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25458,7 +25984,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25458
25984
|
const block = st.blocks[blockIndex];
|
|
25459
25985
|
if (!block) return void 0;
|
|
25460
25986
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
25461
|
-
const para = _optionalChain([st, 'access',
|
|
25987
|
+
const para = _optionalChain([st, 'access', _354 => _354.paraMap, 'access', _355 => _355.get, 'call', _356 => _356(blockIndex), 'optionalAccess', _357 => _357.para]);
|
|
25462
25988
|
if (!para) return void 0;
|
|
25463
25989
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
25464
25990
|
}
|
|
@@ -25483,7 +26009,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25483
26009
|
if (block.text && block.text.includes("\n")) {
|
|
25484
26010
|
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)" };
|
|
25485
26011
|
}
|
|
25486
|
-
if (!_optionalChain([st, 'access',
|
|
26012
|
+
if (!_optionalChain([st, 'access', _358 => _358.paraMap, 'access', _359 => _359.get, 'call', _360 => _360(blockIndex), 'optionalAccess', _361 => _361.para])) {
|
|
25487
26013
|
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)" };
|
|
25488
26014
|
}
|
|
25489
26015
|
return { capability: "text" };
|
|
@@ -25549,7 +26075,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25549
26075
|
continue;
|
|
25550
26076
|
}
|
|
25551
26077
|
if (block.type === "table" && block.table) {
|
|
25552
|
-
if (!_optionalChain([edit, 'access',
|
|
26078
|
+
if (!_optionalChain([edit, 'access', _362 => _362.cells, 'optionalAccess', _363 => _363.length])) {
|
|
25553
26079
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
25554
26080
|
continue;
|
|
25555
26081
|
}
|
|
@@ -25569,7 +26095,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25569
26095
|
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) });
|
|
25570
26096
|
continue;
|
|
25571
26097
|
}
|
|
25572
|
-
const irCell = _optionalChain([block, 'access',
|
|
26098
|
+
const irCell = _optionalChain([block, 'access', _364 => _364.table, 'access', _365 => _365.cells, 'access', _366 => _366[cellEdit.row], 'optionalAccess', _367 => _367[cellEdit.col]]);
|
|
25573
26099
|
if (!irCell) {
|
|
25574
26100
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
25575
26101
|
continue;
|
|
@@ -25625,7 +26151,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25625
26151
|
}
|
|
25626
26152
|
if (replacements.size === 0) {
|
|
25627
26153
|
let changes2;
|
|
25628
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26154
|
+
if (_optionalChain([options, 'optionalAccess', _368 => _368.verify]) !== false) {
|
|
25629
26155
|
const units = splitMarkdownUnits(st.markdown);
|
|
25630
26156
|
changes2 = diffUnitLists(units, units);
|
|
25631
26157
|
}
|
|
@@ -25646,7 +26172,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25646
26172
|
}
|
|
25647
26173
|
this.state = newState;
|
|
25648
26174
|
let changes;
|
|
25649
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26175
|
+
if (_optionalChain([options, 'optionalAccess', _369 => _369.verify]) !== false) {
|
|
25650
26176
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
25651
26177
|
}
|
|
25652
26178
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -25666,7 +26192,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25666
26192
|
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)");
|
|
25667
26193
|
}
|
|
25668
26194
|
const mapping = st.paraMap.get(blockIndex);
|
|
25669
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26195
|
+
if (!_optionalChain([mapping, 'optionalAccess', _370 => _370.para])) {
|
|
25670
26196
|
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)");
|
|
25671
26197
|
}
|
|
25672
26198
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -25686,14 +26212,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25686
26212
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25687
26213
|
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");
|
|
25688
26214
|
}
|
|
25689
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
26215
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _371 => _371.scans, 'access', _372 => _372[mapping.para.sectionIndex], 'optionalAccess', _373 => _373.xml]));
|
|
25690
26216
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25691
26217
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25692
26218
|
return 1;
|
|
25693
26219
|
}
|
|
25694
26220
|
}, _class5);
|
|
25695
26221
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
25696
|
-
const irCell = _optionalChain([table, 'access',
|
|
26222
|
+
const irCell = _optionalChain([table, 'access', _374 => _374.cells, 'access', _375 => _375[r], 'optionalAccess', _376 => _376[c]]);
|
|
25697
26223
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
25698
26224
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
25699
26225
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -25777,11 +26303,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
25777
26303
|
breaks: false
|
|
25778
26304
|
});
|
|
25779
26305
|
function renderHtml(markdown, options) {
|
|
25780
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25781
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26306
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _377 => _377.preset]), () => ( "default"));
|
|
26307
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _378 => _378.extraCss]), () => ( "")));
|
|
25782
26308
|
const body = md.render(markdown);
|
|
25783
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
25784
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
26309
|
+
const watermark = _optionalChain([options, 'optionalAccess', _379 => _379.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
26310
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _380 => _380.watermark]) ? `
|
|
25785
26311
|
.watermark {
|
|
25786
26312
|
position: fixed;
|
|
25787
26313
|
top: 50%; left: 50%;
|
|
@@ -25812,13 +26338,13 @@ async function htmlToPdf(html, options) {
|
|
|
25812
26338
|
try {
|
|
25813
26339
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
25814
26340
|
} catch (e30) {
|
|
25815
|
-
throw new (0,
|
|
26341
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
25816
26342
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
25817
26343
|
);
|
|
25818
26344
|
}
|
|
25819
26345
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
25820
26346
|
if (!executablePath) {
|
|
25821
|
-
throw new (0,
|
|
26347
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
25822
26348
|
"Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
|
|
25823
26349
|
);
|
|
25824
26350
|
}
|
|
@@ -25830,10 +26356,10 @@ async function htmlToPdf(html, options) {
|
|
|
25830
26356
|
try {
|
|
25831
26357
|
const page = await browser.newPage();
|
|
25832
26358
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
25833
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
26359
|
+
const margin = _optionalChain([options, 'optionalAccess', _381 => _381.margin]);
|
|
25834
26360
|
const pdf = await page.pdf({
|
|
25835
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25836
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
26361
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _382 => _382.pageSize]), () => ( "A4")),
|
|
26362
|
+
landscape: _optionalChain([options, 'optionalAccess', _383 => _383.orientation]) === "landscape",
|
|
25837
26363
|
printBackground: true,
|
|
25838
26364
|
margin: margin ? {
|
|
25839
26365
|
top: toCss(margin.top),
|
|
@@ -25841,9 +26367,9 @@ async function htmlToPdf(html, options) {
|
|
|
25841
26367
|
bottom: toCss(margin.bottom),
|
|
25842
26368
|
left: toCss(margin.left)
|
|
25843
26369
|
} : void 0,
|
|
25844
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
25845
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25846
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26370
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _384 => _384.header]) || _optionalChain([options, 'optionalAccess', _385 => _385.footer])),
|
|
26371
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _386 => _386.header]), () => ( "<div></div>")),
|
|
26372
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _387 => _387.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
25847
26373
|
});
|
|
25848
26374
|
return Buffer.from(pdf);
|
|
25849
26375
|
} finally {
|
|
@@ -25877,7 +26403,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
25877
26403
|
return htmlToPdf(html, options);
|
|
25878
26404
|
}
|
|
25879
26405
|
async function blocksToPdf(blocks, options) {
|
|
25880
|
-
const markdown =
|
|
26406
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
25881
26407
|
return markdownToPdf(markdown, options);
|
|
25882
26408
|
}
|
|
25883
26409
|
|
|
@@ -25971,7 +26497,7 @@ function elements(el) {
|
|
|
25971
26497
|
for (let i = 0; i < kids2.length; i++) if (kids2[i].nodeType === 1) out.push(kids2[i]);
|
|
25972
26498
|
return out;
|
|
25973
26499
|
}
|
|
25974
|
-
function
|
|
26500
|
+
function num2(el, attr, fallback = 0) {
|
|
25975
26501
|
return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
|
|
25976
26502
|
}
|
|
25977
26503
|
function shiftParaVert(p, delta) {
|
|
@@ -25979,7 +26505,7 @@ function shiftParaVert(p, delta) {
|
|
|
25979
26505
|
if (ln(lsa) !== "linesegarray") continue;
|
|
25980
26506
|
for (const seg of elements(lsa)) {
|
|
25981
26507
|
if (ln(seg) !== "lineseg") continue;
|
|
25982
|
-
seg.setAttribute("vertpos", String(
|
|
26508
|
+
seg.setAttribute("vertpos", String(num2(seg, "vertpos") + delta));
|
|
25983
26509
|
}
|
|
25984
26510
|
}
|
|
25985
26511
|
}
|
|
@@ -26034,7 +26560,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode) {
|
|
|
26034
26560
|
const lsa = doc.createElement("hp:linesegarray");
|
|
26035
26561
|
for (let li = 0; li < wrap.starts.length; li++) {
|
|
26036
26562
|
const startReal = wrap.starts[li];
|
|
26037
|
-
const textpos = startReal < realIdx.length ? realIdx[startReal] :
|
|
26563
|
+
const textpos = startReal < realIdx.length ? realIdx[startReal] : 0;
|
|
26038
26564
|
const vertpos = startV + li * pitch;
|
|
26039
26565
|
const isFirst = li === 0;
|
|
26040
26566
|
const seg = doc.createElement("hp:lineseg");
|
|
@@ -26069,9 +26595,9 @@ function reflowTablesIn(p, doc, styles, mode, counter) {
|
|
|
26069
26595
|
if (ln(tc) !== "tc") continue;
|
|
26070
26596
|
const csz = findChildByLocalName(tc, "cellSz");
|
|
26071
26597
|
const cm = findChildByLocalName(tc, "cellMargin");
|
|
26072
|
-
const cellW =
|
|
26073
|
-
const mL = cm ?
|
|
26074
|
-
const mR = cm ?
|
|
26598
|
+
const cellW = num2(csz, "width");
|
|
26599
|
+
const mL = cm ? num2(cm, "left", 141) : 141;
|
|
26600
|
+
const mR = cm ? num2(cm, "right", 141) : 141;
|
|
26075
26601
|
const areaW = Math.max(500, cellW - mL - mR);
|
|
26076
26602
|
const sub = findChildByLocalName(tc, "subList");
|
|
26077
26603
|
if (sub) reflowBlockFlow(sub, doc, styles, areaW, mode, counter, 0);
|
|
@@ -26087,7 +26613,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
26087
26613
|
if (ln(p) !== "p") continue;
|
|
26088
26614
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
26089
26615
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
26090
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
26616
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _388 => _388.spaceBefore]), () => ( 0)));
|
|
26091
26617
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
26092
26618
|
if (res) {
|
|
26093
26619
|
const paraH = res.paraBottom - startV;
|
|
@@ -26122,7 +26648,7 @@ function elements2(el) {
|
|
|
26122
26648
|
}
|
|
26123
26649
|
return out;
|
|
26124
26650
|
}
|
|
26125
|
-
function
|
|
26651
|
+
function num3(el, attr, fallback = 0) {
|
|
26126
26652
|
return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
|
|
26127
26653
|
}
|
|
26128
26654
|
function findFirst(el, name, depth = 0) {
|
|
@@ -26190,13 +26716,13 @@ function buildPara(p) {
|
|
|
26190
26716
|
} else if (OBJ_TAGS.has(cn)) {
|
|
26191
26717
|
const sz = findChildByLocalName(ch, "sz");
|
|
26192
26718
|
const pos = findChildByLocalName(ch, "pos");
|
|
26193
|
-
const w =
|
|
26194
|
-
const h =
|
|
26719
|
+
const w = num3(sz, "width") || num3(findChildByLocalName(ch, "curSz"), "width") || num3(findChildByLocalName(ch, "orgSz"), "width");
|
|
26720
|
+
const h = num3(sz, "height") || num3(findChildByLocalName(ch, "curSz"), "height") || num3(findChildByLocalName(ch, "orgSz"), "height");
|
|
26195
26721
|
objs.push({
|
|
26196
26722
|
el: ch,
|
|
26197
26723
|
tag: cn,
|
|
26198
26724
|
index: chars.length,
|
|
26199
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
26725
|
+
inline: _optionalChain([pos, 'optionalAccess', _389 => _389.getAttribute, 'call', _390 => _390("treatAsChar")]) === "1",
|
|
26200
26726
|
width: w,
|
|
26201
26727
|
height: h
|
|
26202
26728
|
});
|
|
@@ -26207,12 +26733,12 @@ function buildPara(p) {
|
|
|
26207
26733
|
}
|
|
26208
26734
|
} else if (tag === "linesegarray") {
|
|
26209
26735
|
segs = elements2(runEl).filter((s) => ln2(s) === "lineseg").map((s) => ({
|
|
26210
|
-
textpos:
|
|
26211
|
-
vertpos:
|
|
26212
|
-
horzpos:
|
|
26213
|
-
horzsize:
|
|
26214
|
-
textheight:
|
|
26215
|
-
baseline:
|
|
26736
|
+
textpos: num3(s, "textpos"),
|
|
26737
|
+
vertpos: num3(s, "vertpos"),
|
|
26738
|
+
horzpos: num3(s, "horzpos"),
|
|
26739
|
+
horzsize: num3(s, "horzsize"),
|
|
26740
|
+
textheight: num3(s, "textheight", 1e3),
|
|
26741
|
+
baseline: num3(s, "baseline", 850)
|
|
26216
26742
|
}));
|
|
26217
26743
|
}
|
|
26218
26744
|
}
|
|
@@ -26314,6 +26840,7 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
26314
26840
|
}
|
|
26315
26841
|
if (text.trim().length > 0) {
|
|
26316
26842
|
const attrs = [`x="${pt(cx)}"`, `y="${pt(y)}"`, `font-size="${pt(st.height)}"`];
|
|
26843
|
+
if (st.fontFamily) attrs.push(`font-family="${st.fontFamily}"`);
|
|
26317
26844
|
if ([...text].length > 1 && sw > 50) {
|
|
26318
26845
|
attrs.push(`textLength="${pt(sw)}"`, `lengthAdjust="${plan.scale < 1 ? "spacingAndGlyphs" : "spacing"}"`);
|
|
26319
26846
|
}
|
|
@@ -26381,11 +26908,11 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx) {
|
|
|
26381
26908
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
|
|
26382
26909
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26383
26910
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26384
|
-
const omT =
|
|
26911
|
+
const omT = num3(om, "top"), omB = num3(om, "bottom");
|
|
26385
26912
|
const w = o.width, h = o.height;
|
|
26386
26913
|
if (!pos) return { x: ox, y: oy + baseV };
|
|
26387
|
-
const vo =
|
|
26388
|
-
const ho =
|
|
26914
|
+
const vo = num3(pos, "vertOffset");
|
|
26915
|
+
const ho = num3(pos, "horzOffset");
|
|
26389
26916
|
const vrel = _nullishCoalesce(pos.getAttribute("vertRelTo"), () => ( "PARA"));
|
|
26390
26917
|
const hrel = _nullishCoalesce(pos.getAttribute("horzRelTo"), () => ( "PARA"));
|
|
26391
26918
|
const va = _nullishCoalesce(pos.getAttribute("vertAlign"), () => ( "TOP"));
|
|
@@ -26422,8 +26949,8 @@ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
|
|
|
26422
26949
|
if (!OBJ_TAGS.has(tag)) continue;
|
|
26423
26950
|
const sz = findChildByLocalName(ch, "sz");
|
|
26424
26951
|
const off = findChildByLocalName(ch, "offset");
|
|
26425
|
-
const sub = { el: ch, tag, index: 0, inline: true, width:
|
|
26426
|
-
drawObject(sub, x +
|
|
26952
|
+
const sub = { el: ch, tag, index: 0, inline: true, width: num3(sz, "width"), height: num3(sz, "height") };
|
|
26953
|
+
drawObject(sub, x + num3(off, "x"), y + num3(off, "y"), baseV, areaW, ctx, depth + 1);
|
|
26427
26954
|
}
|
|
26428
26955
|
} else if (o.tag === "equation") {
|
|
26429
26956
|
warnOnce(ctx, "equation", "\uC218\uC2DD \uAC1C\uCCB4\uB294 \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5");
|
|
@@ -26441,21 +26968,21 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26441
26968
|
const el = o.el;
|
|
26442
26969
|
const orgSz = findChildByLocalName(el, "orgSz");
|
|
26443
26970
|
const curSz = findChildByLocalName(el, "curSz");
|
|
26444
|
-
const ow =
|
|
26445
|
-
const w =
|
|
26446
|
-
const h =
|
|
26971
|
+
const ow = num3(orgSz, "width"), oh = num3(orgSz, "height");
|
|
26972
|
+
const w = num3(curSz, "width") || ow || o.width;
|
|
26973
|
+
const h = num3(curSz, "height") || oh || o.height;
|
|
26447
26974
|
const sx = ow > 0 ? w / ow : 1;
|
|
26448
26975
|
const sy = oh > 0 ? h / oh : 1;
|
|
26449
26976
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
26450
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
26451
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
26977
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _391 => _391.getAttribute, 'call', _392 => _392("style")]), () => ( "SOLID"));
|
|
26978
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _393 => _393.getAttribute, 'call', _394 => _394("color")]) || "#000000";
|
|
26452
26979
|
const hasStroke = lstyle !== "NONE";
|
|
26453
|
-
const strokeW = hasStroke ? shapeStrokePt(lineShape ?
|
|
26980
|
+
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
26454
26981
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
26455
26982
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
26456
26983
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26457
26984
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26458
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26985
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _395 => _395.getAttribute, 'call', _396 => _396("faceColor")]);
|
|
26459
26986
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
26460
26987
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
26461
26988
|
if (o.tag === "rect") {
|
|
@@ -26464,12 +26991,12 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26464
26991
|
emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fillAttr}${strokeAttr}/>`);
|
|
26465
26992
|
} else if (o.tag === "line") {
|
|
26466
26993
|
const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
|
|
26467
|
-
const x1 = x +
|
|
26468
|
-
const x2 = x +
|
|
26994
|
+
const x1 = x + num3(s, "x") * sx, y1 = y + num3(s, "y") * sy;
|
|
26995
|
+
const x2 = x + num3(e, "x") * sx, y2 = y + num3(e, "y") * sy;
|
|
26469
26996
|
emit(ctx, `<line x1="${pt(x1)}" y1="${pt(y1)}" x2="${pt(x2)}" y2="${pt(y2)}" stroke="${escapeXml3(strokeCol)}" stroke-width="${(strokeW || 0.3).toFixed(2)}"${dash}/>`);
|
|
26470
26997
|
} else if (o.tag === "polygon" || o.tag === "curv") {
|
|
26471
26998
|
const pts = [];
|
|
26472
|
-
for (const c of elements2(el)) if (ln2(c) === "pt") pts.push(`${pt(x +
|
|
26999
|
+
for (const c of elements2(el)) if (ln2(c) === "pt") pts.push(`${pt(x + num3(c, "x") * sx)},${pt(y + num3(c, "y") * sy)}`);
|
|
26473
27000
|
if (pts.length >= 2) emit(ctx, `<polygon points="${pts.join(" ")}"${fillAttr}${strokeAttr}/>`);
|
|
26474
27001
|
} else if (o.tag === "arc") {
|
|
26475
27002
|
emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}" fill="none"${strokeAttr || ` stroke="${escapeXml3(strokeCol)}" stroke-width="0.3"`}/>`);
|
|
@@ -26487,15 +27014,19 @@ function cellContentExtent(cell) {
|
|
|
26487
27014
|
if (ln2(p) !== "p") continue;
|
|
26488
27015
|
const m = buildPara(p);
|
|
26489
27016
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
26490
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
27017
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _397 => _397.segs, 'access', _398 => _398[0], 'optionalAccess', _399 => _399.vertpos]), () => ( 0));
|
|
26491
27018
|
for (const o of m.objs) {
|
|
26492
|
-
if (o.inline)
|
|
27019
|
+
if (o.inline) {
|
|
27020
|
+
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
27021
|
+
ext = Math.max(ext, baseV + h);
|
|
27022
|
+
continue;
|
|
27023
|
+
}
|
|
26493
27024
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26494
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
27025
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _400 => _400.getAttribute, 'call', _401 => _401("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
26495
27026
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26496
|
-
const pushed = baseV - (
|
|
27027
|
+
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
26497
27028
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
26498
|
-
ext = Math.max(ext, anchor +
|
|
27029
|
+
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
26499
27030
|
}
|
|
26500
27031
|
}
|
|
26501
27032
|
return ext;
|
|
@@ -26506,8 +27037,8 @@ function edgeLine(x1, y1, x2, y2, e) {
|
|
|
26506
27037
|
}
|
|
26507
27038
|
function collectCells(tbl) {
|
|
26508
27039
|
const inMargin = findChildByLocalName(tbl, "inMargin");
|
|
26509
|
-
const defL =
|
|
26510
|
-
const defT =
|
|
27040
|
+
const defL = num3(inMargin, "left", 141), defR = num3(inMargin, "right", 141);
|
|
27041
|
+
const defT = num3(inMargin, "top", 141), defB = num3(inMargin, "bottom", 141);
|
|
26511
27042
|
const cells = [];
|
|
26512
27043
|
for (const tr of elements2(tbl)) {
|
|
26513
27044
|
if (ln2(tr) !== "tr") continue;
|
|
@@ -26520,18 +27051,18 @@ function collectCells(tbl) {
|
|
|
26520
27051
|
if (!addr || !csz) continue;
|
|
26521
27052
|
cells.push({
|
|
26522
27053
|
el: tc,
|
|
26523
|
-
ca:
|
|
26524
|
-
ra:
|
|
26525
|
-
cs: Math.max(1,
|
|
26526
|
-
rs: Math.max(1,
|
|
26527
|
-
w:
|
|
26528
|
-
h:
|
|
27054
|
+
ca: num3(addr, "colAddr"),
|
|
27055
|
+
ra: num3(addr, "rowAddr"),
|
|
27056
|
+
cs: Math.max(1, num3(span, "colSpan", 1)),
|
|
27057
|
+
rs: Math.max(1, num3(span, "rowSpan", 1)),
|
|
27058
|
+
w: num3(csz, "width"),
|
|
27059
|
+
h: num3(csz, "height"),
|
|
26529
27060
|
bfId: tc.getAttribute("borderFillIDRef"),
|
|
26530
27061
|
sub: findChildByLocalName(tc, "subList"),
|
|
26531
|
-
marginL: cm ?
|
|
26532
|
-
marginR: cm ?
|
|
26533
|
-
marginT: cm ?
|
|
26534
|
-
marginB: cm ?
|
|
27062
|
+
marginL: cm ? num3(cm, "left", defL) : defL,
|
|
27063
|
+
marginR: cm ? num3(cm, "right", defR) : defR,
|
|
27064
|
+
marginT: cm ? num3(cm, "top", defT) : defT,
|
|
27065
|
+
marginB: cm ? num3(cm, "bottom", defB) : defB
|
|
26535
27066
|
});
|
|
26536
27067
|
}
|
|
26537
27068
|
}
|
|
@@ -26561,7 +27092,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26561
27092
|
const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
|
|
26562
27093
|
const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
|
|
26563
27094
|
const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
|
|
26564
|
-
const colX = solveBoundaries(colCons, nCols,
|
|
27095
|
+
const colX = solveBoundaries(colCons, nCols, num3(tblSz, "width") || void 0);
|
|
26565
27096
|
const rowH = solveRowHeights(
|
|
26566
27097
|
cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
|
|
26567
27098
|
nRows
|
|
@@ -26577,7 +27108,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26577
27108
|
}));
|
|
26578
27109
|
for (const g of geom) {
|
|
26579
27110
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
26580
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
27111
|
+
if (_optionalChain([bf, 'optionalAccess', _402 => _402.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
26581
27112
|
}
|
|
26582
27113
|
for (const g of geom) {
|
|
26583
27114
|
const { c } = g;
|
|
@@ -26613,9 +27144,9 @@ function imageSymbol(loaded, ctx) {
|
|
|
26613
27144
|
}
|
|
26614
27145
|
function drawPic(pic, x, y, ctx) {
|
|
26615
27146
|
const sz = findChildByLocalName(pic, "sz");
|
|
26616
|
-
const w =
|
|
27147
|
+
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
26617
27148
|
const img = findFirst(pic, "img");
|
|
26618
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
27149
|
+
const ref = _optionalChain([img, 'optionalAccess', _403 => _403.getAttribute, 'call', _404 => _404("binaryItemIDRef")]);
|
|
26619
27150
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
26620
27151
|
if (!loaded) {
|
|
26621
27152
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -26626,11 +27157,11 @@ function drawPic(pic, x, y, ctx) {
|
|
|
26626
27157
|
const clip = findChildByLocalName(pic, "imgClip");
|
|
26627
27158
|
const imgDim = findChildByLocalName(pic, "imgDim");
|
|
26628
27159
|
const orgSz = findChildByLocalName(pic, "orgSz");
|
|
26629
|
-
const dimW =
|
|
26630
|
-
const refW = dimW > 0 ? dimW :
|
|
26631
|
-
const refH = dimH > 0 ? dimH :
|
|
26632
|
-
const cl =
|
|
26633
|
-
const cr =
|
|
27160
|
+
const dimW = num3(imgDim, "dimwidth"), dimH = num3(imgDim, "dimheight");
|
|
27161
|
+
const refW = dimW > 0 ? dimW : num3(orgSz, "width");
|
|
27162
|
+
const refH = dimH > 0 ? dimH : num3(orgSz, "height");
|
|
27163
|
+
const cl = num3(clip, "left"), ct = num3(clip, "top");
|
|
27164
|
+
const cr = num3(clip, "right", refW), cb = num3(clip, "bottom", refH);
|
|
26634
27165
|
const cropped = refW > 0 && refH > 0 && clip != null && (cl > 0 || ct > 0 || cr < refW || cb < refH) && cr > cl && cb > ct;
|
|
26635
27166
|
const symId = imageSymbol(loaded, ctx);
|
|
26636
27167
|
if (cropped) {
|
|
@@ -26650,28 +27181,89 @@ function sniffMime(name, bytes) {
|
|
|
26650
27181
|
if (lower.endsWith(".svg")) return "image/svg+xml";
|
|
26651
27182
|
return "image/jpeg";
|
|
26652
27183
|
}
|
|
27184
|
+
function readSectionGeom(root) {
|
|
27185
|
+
const pagePr = findFirst(root, "pagePr");
|
|
27186
|
+
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
27187
|
+
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
27188
|
+
if (_optionalChain([pagePr, 'optionalAccess', _405 => _405.getAttribute, 'call', _406 => _406("landscape")]) === "NARROWLY" && PW < PH) {
|
|
27189
|
+
const t = PW;
|
|
27190
|
+
PW = PH;
|
|
27191
|
+
PH = t;
|
|
27192
|
+
}
|
|
27193
|
+
const ML = num3(margin, "left", 8504);
|
|
27194
|
+
const MT = num3(margin, "top", 5668) + num3(margin, "header", 0);
|
|
27195
|
+
const BODY_H = PH - MT - num3(margin, "bottom", 4252) - num3(margin, "footer", 0);
|
|
27196
|
+
const BODY_W = PW - ML - num3(margin, "right", 8504);
|
|
27197
|
+
return { PW, PH, ML, MT, BODY_W, BODY_H };
|
|
27198
|
+
}
|
|
27199
|
+
function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
27200
|
+
const { PW, PH, ML, MT, BODY_W, BODY_H } = geom;
|
|
27201
|
+
if (!hasCache) reflowSection(root, ctxBase.styles, { BODY_W, BODY_H }, reflowMode);
|
|
27202
|
+
const colPr = findFirst(root, "colPr");
|
|
27203
|
+
const multiCol = num3(colPr, "colCount", 1) > 1;
|
|
27204
|
+
const paraSegPages = /* @__PURE__ */ new Map();
|
|
27205
|
+
let nPages = 1;
|
|
27206
|
+
let maxTopV = 0;
|
|
27207
|
+
{
|
|
27208
|
+
let prevV = Number.NEGATIVE_INFINITY;
|
|
27209
|
+
let prevH = Number.NEGATIVE_INFINITY;
|
|
27210
|
+
let cur = 0;
|
|
27211
|
+
for (const p of elements2(root)) {
|
|
27212
|
+
if (ln2(p) !== "p") continue;
|
|
27213
|
+
const lsa = findChildByLocalName(p, "linesegarray");
|
|
27214
|
+
const segEls = lsa ? elements2(lsa).filter((s) => ln2(s) === "lineseg") : [];
|
|
27215
|
+
const pagesOf = [];
|
|
27216
|
+
let paraFirst = true;
|
|
27217
|
+
for (const s of segEls) {
|
|
27218
|
+
const v = num3(s, "vertpos");
|
|
27219
|
+
const h = num3(s, "horzpos");
|
|
27220
|
+
const brk = v < prevV ? !multiCol || h <= prevH : paraFirst && v === prevV && h <= prevH;
|
|
27221
|
+
if (brk) cur++;
|
|
27222
|
+
paraFirst = false;
|
|
27223
|
+
pagesOf.push(cur);
|
|
27224
|
+
maxTopV = Math.max(maxTopV, v + num3(s, "textheight", 1e3));
|
|
27225
|
+
prevV = v;
|
|
27226
|
+
prevH = h;
|
|
27227
|
+
}
|
|
27228
|
+
paraSegPages.set(p, pagesOf);
|
|
27229
|
+
nPages = Math.max(nPages, cur + 1);
|
|
27230
|
+
}
|
|
27231
|
+
}
|
|
27232
|
+
const ctx = {
|
|
27233
|
+
...ctxBase,
|
|
27234
|
+
pages: Array.from({ length: nPages }, () => []),
|
|
27235
|
+
page: 0,
|
|
27236
|
+
geom
|
|
27237
|
+
};
|
|
27238
|
+
for (const p of elements2(root)) {
|
|
27239
|
+
if (ln2(p) !== "p") continue;
|
|
27240
|
+
drawPara(p, ML, MT, BODY_W, ctx, 0, paraSegPages.get(p));
|
|
27241
|
+
}
|
|
27242
|
+
const pageH = nPages === 1 ? Math.max(PH, MT + maxTopV + 2e3) : PH;
|
|
27243
|
+
return { pages: ctx.pages, pageH };
|
|
27244
|
+
}
|
|
26653
27245
|
async function renderHwpxToSvg(input, options) {
|
|
26654
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27246
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _407 => _407.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
26655
27247
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
26656
|
-
|
|
27248
|
+
_chunk5HDBLRVPcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
26657
27249
|
let zip;
|
|
26658
27250
|
try {
|
|
26659
27251
|
zip = await _jszip2.default.loadAsync(input);
|
|
26660
27252
|
} catch (e31) {
|
|
26661
|
-
throw new (0,
|
|
26662
|
-
}
|
|
26663
|
-
const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
|
|
26664
|
-
if (!secFile) throw new (0, _chunk72LLOLFXcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
26665
|
-
const secXml = await secFile.async("string");
|
|
26666
|
-
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
26667
|
-
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
26668
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess', _336 => _336.reflow])) {
|
|
26669
|
-
throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
|
|
27253
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
26670
27254
|
}
|
|
27255
|
+
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
27256
|
+
if (secFiles.length === 0) throw new (0, _chunk5HDBLRVPcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
26671
27257
|
const warnings = [];
|
|
26672
27258
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
26673
27259
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
26674
27260
|
if (!headFile) warnings.push("header.xml \uC5C6\uC74C \u2014 \uAE30\uBCF8 \uC2A4\uD0C0\uC77C\uB85C \uB80C\uB354");
|
|
27261
|
+
const secXmls = [];
|
|
27262
|
+
for (const f of secFiles) {
|
|
27263
|
+
const xml = await f.async("string");
|
|
27264
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
27265
|
+
secXmls.push(xml);
|
|
27266
|
+
}
|
|
26675
27267
|
const binmap = /* @__PURE__ */ new Map();
|
|
26676
27268
|
const hpf = zip.file(/content\.hpf$/i)[0];
|
|
26677
27269
|
if (hpf) {
|
|
@@ -26683,7 +27275,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26683
27275
|
const MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
|
|
26684
27276
|
const images = /* @__PURE__ */ new Map();
|
|
26685
27277
|
const refs = /* @__PURE__ */ new Set();
|
|
26686
|
-
for (const m of
|
|
27278
|
+
for (const xml of secXmls) for (const m of xml.matchAll(/binaryItemIDRef="([^"]+)"/g)) refs.add(m[1]);
|
|
26687
27279
|
let totalImgBytes = 0;
|
|
26688
27280
|
for (const ref of refs) {
|
|
26689
27281
|
if (images.size >= MAX_IMAGE_REFS) {
|
|
@@ -26693,7 +27285,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26693
27285
|
let href = binmap.get(ref);
|
|
26694
27286
|
if (!href) {
|
|
26695
27287
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
26696
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
27288
|
+
href = _optionalChain([cand, 'optionalAccess', _408 => _408.name]);
|
|
26697
27289
|
}
|
|
26698
27290
|
if (!href) continue;
|
|
26699
27291
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -26710,89 +27302,82 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26710
27302
|
totalImgBytes += bytes.length;
|
|
26711
27303
|
images.set(ref, { dataUri: `data:${sniffMime(href, bytes)};base64,${Buffer.from(bytes).toString("base64")}` });
|
|
26712
27304
|
}
|
|
26713
|
-
const
|
|
26714
|
-
const root = doc.documentElement;
|
|
26715
|
-
if (!root) throw new (0, _chunk72LLOLFXcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
|
|
26716
|
-
const pagePr = findFirst(root, "pagePr");
|
|
26717
|
-
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
26718
|
-
const PW = num2(pagePr, "width", 59528), PH = num2(pagePr, "height", 84188);
|
|
26719
|
-
const ML = num2(margin, "left", 8504);
|
|
26720
|
-
const MT = num2(margin, "top", 5668) + num2(margin, "header", 0);
|
|
26721
|
-
const BODY_H = PH - MT - num2(margin, "bottom", 4252) - num2(margin, "footer", 0);
|
|
26722
|
-
const BODY_W = PW - ML - num2(margin, "right", 8504);
|
|
26723
|
-
if (!hasCache) reflowSection(root, styles, { BODY_W, BODY_H }, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _338 => _338.reflowMode]), () => ( "keep")));
|
|
26724
|
-
const colPr = findFirst(root, "colPr");
|
|
26725
|
-
const multiCol = num2(colPr, "colCount", 1) > 1;
|
|
26726
|
-
const paraSegPages = /* @__PURE__ */ new Map();
|
|
26727
|
-
let nPages = 1;
|
|
26728
|
-
let maxTopV = 0;
|
|
26729
|
-
{
|
|
26730
|
-
let prevV = Number.NEGATIVE_INFINITY;
|
|
26731
|
-
let prevH = Number.NEGATIVE_INFINITY;
|
|
26732
|
-
let cur = 0;
|
|
26733
|
-
for (const p of elements2(root)) {
|
|
26734
|
-
if (ln2(p) !== "p") continue;
|
|
26735
|
-
const lsa = findChildByLocalName(p, "linesegarray");
|
|
26736
|
-
const segEls = lsa ? elements2(lsa).filter((s) => ln2(s) === "lineseg") : [];
|
|
26737
|
-
const pagesOf = [];
|
|
26738
|
-
for (const s of segEls) {
|
|
26739
|
-
const v = num2(s, "vertpos");
|
|
26740
|
-
const h = num2(s, "horzpos");
|
|
26741
|
-
if (v < prevV && (!multiCol || h <= prevH)) cur++;
|
|
26742
|
-
pagesOf.push(cur);
|
|
26743
|
-
maxTopV = Math.max(maxTopV, v + num2(s, "textheight", 1e3));
|
|
26744
|
-
prevV = v;
|
|
26745
|
-
prevH = h;
|
|
26746
|
-
}
|
|
26747
|
-
paraSegPages.set(p, pagesOf);
|
|
26748
|
-
nPages = Math.max(nPages, cur + 1);
|
|
26749
|
-
}
|
|
26750
|
-
}
|
|
26751
|
-
const ctx = {
|
|
26752
|
-
pages: Array.from({ length: nPages }, () => []),
|
|
26753
|
-
page: 0,
|
|
26754
|
-
geom: { PW, PH, ML, MT, BODY_W, BODY_H },
|
|
27305
|
+
const ctxBase = {
|
|
26755
27306
|
styles,
|
|
26756
27307
|
images,
|
|
26757
27308
|
defs: [],
|
|
26758
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27309
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _409 => _409.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
26759
27310
|
warnings,
|
|
26760
27311
|
warned: /* @__PURE__ */ new Set(),
|
|
26761
27312
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
26762
27313
|
};
|
|
26763
|
-
|
|
26764
|
-
|
|
26765
|
-
|
|
27314
|
+
const rendered = [];
|
|
27315
|
+
let noCacheSkipped = false;
|
|
27316
|
+
for (let si = 0; si < secXmls.length; si++) {
|
|
27317
|
+
const secXml = secXmls[si];
|
|
27318
|
+
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
27319
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _410 => _410.reflow])) {
|
|
27320
|
+
noCacheSkipped = true;
|
|
27321
|
+
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
27322
|
+
continue;
|
|
27323
|
+
}
|
|
27324
|
+
const doc = createXmlParser().parseFromString(secXml, "text/xml");
|
|
27325
|
+
const root = doc.documentElement;
|
|
27326
|
+
if (!root) {
|
|
27327
|
+
warnings.push(`\uAD6C\uC5ED ${si} XML \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uC0DD\uB7B5`);
|
|
27328
|
+
continue;
|
|
27329
|
+
}
|
|
27330
|
+
const geom = readSectionGeom(root);
|
|
27331
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _411 => _411.reflowMode]), () => ( "keep")));
|
|
27332
|
+
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
27333
|
+
}
|
|
27334
|
+
if (rendered.length === 0) {
|
|
27335
|
+
if (noCacheSkipped) {
|
|
27336
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
|
|
27337
|
+
}
|
|
27338
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
26766
27339
|
}
|
|
26767
|
-
const pageH = nPages === 1 ? Math.max(PH, MT + maxTopV + 2e3) : PH;
|
|
26768
27340
|
const GAP = 2400;
|
|
26769
|
-
const
|
|
26770
|
-
const
|
|
26771
|
-
|
|
27341
|
+
const clipDefs = [];
|
|
27342
|
+
const groups = [];
|
|
27343
|
+
let y = 0;
|
|
27344
|
+
let maxPW = 0;
|
|
27345
|
+
let pageNo = 0;
|
|
27346
|
+
for (const rs of rendered) {
|
|
27347
|
+
maxPW = Math.max(maxPW, rs.PW);
|
|
27348
|
+
clipDefs.push(`<clipPath id="${rs.clipId}"><rect x="0" y="0" width="${pt(rs.PW)}" height="${pt(rs.pageH)}"/></clipPath>`);
|
|
27349
|
+
for (const buf of rs.pages) {
|
|
27350
|
+
pageNo++;
|
|
27351
|
+
groups.push(
|
|
27352
|
+
`<g data-page="${pageNo}" transform="translate(0 ${pt(y)})"><rect width="${pt(rs.PW)}" height="${pt(rs.pageH)}" fill="white" stroke="#c9c7c4" stroke-width="0.75"/><g clip-path="url(#${rs.clipId})">
|
|
26772
27353
|
${buf.join("\n")}
|
|
26773
27354
|
</g></g>`
|
|
26774
|
-
|
|
26775
|
-
|
|
26776
|
-
|
|
26777
|
-
|
|
27355
|
+
);
|
|
27356
|
+
y += rs.pageH + GAP;
|
|
27357
|
+
}
|
|
27358
|
+
}
|
|
27359
|
+
const totalH = Math.max(0, y - GAP);
|
|
27360
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${pt(maxPW)} ${pt(totalH)}" width="${pt(maxPW)}pt" height="${pt(totalH)}pt" font-family="'HCR Batang','\uD568\uCD08\uB86C\uBC14\uD0D5','Hancom Batang',AppleMyungjo,'Noto Serif CJK KR',serif" xml:space="preserve">
|
|
27361
|
+
<defs>${clipDefs.join("")}${ctxBase.defs.join("")}</defs>
|
|
27362
|
+
${groups.join("\n")}
|
|
26778
27363
|
</svg>`;
|
|
26779
|
-
return { svg, width: Math.round(
|
|
27364
|
+
return { svg, width: Math.round(maxPW) / 100, height: Math.round(totalH) / 100, pageCount: pageNo, warnings, stats: ctxBase.stats };
|
|
26780
27365
|
}
|
|
26781
27366
|
|
|
26782
27367
|
// src/index.ts
|
|
26783
27368
|
async function parse(input, options) {
|
|
26784
27369
|
let buffer;
|
|
26785
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
27370
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _412 => _412.filePath]) ? { ...options, filePath: input } : options;
|
|
26786
27371
|
if (typeof input === "string") {
|
|
26787
27372
|
try {
|
|
26788
27373
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26789
|
-
buffer =
|
|
27374
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, buf);
|
|
26790
27375
|
} catch (err) {
|
|
26791
27376
|
const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
|
|
26792
27377
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
26793
27378
|
}
|
|
26794
27379
|
} else if (Buffer.isBuffer(input)) {
|
|
26795
|
-
buffer =
|
|
27380
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, input);
|
|
26796
27381
|
} else {
|
|
26797
27382
|
buffer = input;
|
|
26798
27383
|
}
|
|
@@ -26827,21 +27412,21 @@ async function parseHwp3(buffer, options) {
|
|
|
26827
27412
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
26828
27413
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
26829
27414
|
} catch (err) {
|
|
26830
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27415
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26831
27416
|
}
|
|
26832
27417
|
}
|
|
26833
27418
|
async function parseHwpx(buffer, options) {
|
|
26834
27419
|
try {
|
|
26835
27420
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
26836
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27421
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _413 => _413.length]) ? images : void 0 };
|
|
26837
27422
|
} catch (err) {
|
|
26838
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27423
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26839
27424
|
}
|
|
26840
27425
|
}
|
|
26841
27426
|
async function parseHwp(buffer, options) {
|
|
26842
27427
|
try {
|
|
26843
27428
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
26844
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
27429
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _414 => _414.filePath])) {
|
|
26845
27430
|
try {
|
|
26846
27431
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
26847
27432
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -26858,15 +27443,15 @@ async function parseHwp(buffer, options) {
|
|
|
26858
27443
|
} catch (e32) {
|
|
26859
27444
|
}
|
|
26860
27445
|
}
|
|
26861
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27446
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _415 => _415.length]) ? images : void 0 };
|
|
26862
27447
|
} catch (err) {
|
|
26863
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27448
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26864
27449
|
}
|
|
26865
27450
|
}
|
|
26866
27451
|
async function parsePdf(buffer, options) {
|
|
26867
27452
|
let parsePdfDocument;
|
|
26868
27453
|
try {
|
|
26869
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
27454
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-S34YR2SH.cjs")));
|
|
26870
27455
|
parsePdfDocument = mod.parsePdfDocument;
|
|
26871
27456
|
} catch (e33) {
|
|
26872
27457
|
return {
|
|
@@ -26881,7 +27466,7 @@ async function parsePdf(buffer, options) {
|
|
|
26881
27466
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
26882
27467
|
} catch (err) {
|
|
26883
27468
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
26884
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27469
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err), isImageBased };
|
|
26885
27470
|
}
|
|
26886
27471
|
}
|
|
26887
27472
|
async function parseXlsx(buffer, options) {
|
|
@@ -26889,7 +27474,7 @@ async function parseXlsx(buffer, options) {
|
|
|
26889
27474
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
26890
27475
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
26891
27476
|
} catch (err) {
|
|
26892
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27477
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26893
27478
|
}
|
|
26894
27479
|
}
|
|
26895
27480
|
async function parseXls(buffer, options) {
|
|
@@ -26897,15 +27482,15 @@ async function parseXls(buffer, options) {
|
|
|
26897
27482
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
26898
27483
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
26899
27484
|
} catch (err) {
|
|
26900
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27485
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26901
27486
|
}
|
|
26902
27487
|
}
|
|
26903
27488
|
async function parseDocx(buffer, options) {
|
|
26904
27489
|
try {
|
|
26905
27490
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
26906
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27491
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _416 => _416.length]) ? images : void 0 };
|
|
26907
27492
|
} catch (err) {
|
|
26908
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27493
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26909
27494
|
}
|
|
26910
27495
|
}
|
|
26911
27496
|
async function parseHwpml(buffer, options) {
|
|
@@ -26913,16 +27498,16 @@ async function parseHwpml(buffer, options) {
|
|
|
26913
27498
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
26914
27499
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
26915
27500
|
} catch (err) {
|
|
26916
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27501
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk5HDBLRVPcjs.classifyError.call(void 0, err) };
|
|
26917
27502
|
}
|
|
26918
27503
|
}
|
|
26919
27504
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
26920
27505
|
let buffer;
|
|
26921
27506
|
if (typeof input === "string") {
|
|
26922
27507
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26923
|
-
buffer =
|
|
27508
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, buf);
|
|
26924
27509
|
} else if (Buffer.isBuffer(input)) {
|
|
26925
|
-
buffer =
|
|
27510
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, input);
|
|
26926
27511
|
} else {
|
|
26927
27512
|
buffer = input;
|
|
26928
27513
|
}
|
|
@@ -26948,7 +27533,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
26948
27533
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
26949
27534
|
}
|
|
26950
27535
|
const fill = fillFormFields(parsed.blocks, values);
|
|
26951
|
-
const markdown =
|
|
27536
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
26952
27537
|
if (outputFormat === "hwpx") {
|
|
26953
27538
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
26954
27539
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -27011,5 +27596,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27011
27596
|
|
|
27012
27597
|
|
|
27013
27598
|
|
|
27014
|
-
|
|
27599
|
+
|
|
27600
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunk5HDBLRVPcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk5HDBLRVPcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.hwpxToProfile = hwpxToProfile; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.validateHwpx = validateHwpx;
|
|
27015
27601
|
//# sourceMappingURL=index.cjs.map
|