kordoc 3.17.0 → 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 +5 -0
- package/dist/{-3KPDRR3A.js → -OUCPI6B3.js} +9 -7
- package/dist/{chunk-NKICMZ7F.js → chunk-4YEZTZAR.js} +2 -2
- package/dist/{chunk-EL2Y4BL2.cjs → chunk-5HDBLRVP.cjs} +45 -9
- package/dist/chunk-5HDBLRVP.cjs.map +1 -0
- package/dist/{chunk-HVEEFHN7.js → chunk-6Y4KKPC3.js} +2 -2
- package/dist/{chunk-E6NQWOFQ.js → chunk-GIXXV52X.js} +39 -3
- package/dist/chunk-GIXXV52X.js.map +1 -0
- package/dist/{chunk-VUS6LRVY.js → chunk-PWHM3KAA.js} +535 -83
- package/dist/chunk-PWHM3KAA.js.map +1 -0
- package/dist/{chunk-TDIDUEBH.js → chunk-VP34RO24.js} +3 -3
- package/dist/{chunk-WHMNPQXW.js → chunk-YWIYGXLI.js} +39 -3
- package/dist/chunk-YWIYGXLI.js.map +1 -0
- package/dist/{chunk-SADQWCWR.js → chunk-ZTUQYITH.js} +3 -3
- package/dist/cli.js +18 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +862 -411
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -1
- package/dist/index.d.ts +118 -1
- package/dist/index.js +592 -141
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -10
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-LHBXIKXX.js → parser-5D6BQYTX.js} +2 -2
- package/dist/{parser-CYJMOXUR.js → parser-NZAE7PBE.js} +3 -3
- package/dist/{parser-I5GC4QQ5.cjs → parser-S34YR2SH.cjs} +14 -14
- package/dist/{parser-I5GC4QQ5.cjs.map → parser-S34YR2SH.cjs.map} +1 -1
- package/dist/render-HRAW7ASR.js +10 -0
- package/dist/seal-CK64CXWO.js +10 -0
- package/dist/{watch-VT7BSLNI.js → watch-2EFXBRYK.js} +7 -7
- package/package.json +1 -1
- package/dist/chunk-E6NQWOFQ.js.map +0 -1
- package/dist/chunk-EL2Y4BL2.cjs.map +0 -1
- package/dist/chunk-VUS6LRVY.js.map +0 -1
- package/dist/chunk-WHMNPQXW.js.map +0 -1
- package/dist/render-HY7KKYPV.js +0 -10
- package/dist/seal-ITGYHENO.js +0 -10
- /package/dist/{-3KPDRR3A.js.map → -OUCPI6B3.js.map} +0 -0
- /package/dist/{chunk-NKICMZ7F.js.map → chunk-4YEZTZAR.js.map} +0 -0
- /package/dist/{chunk-HVEEFHN7.js.map → chunk-6Y4KKPC3.js.map} +0 -0
- /package/dist/{chunk-TDIDUEBH.js.map → chunk-VP34RO24.js.map} +0 -0
- /package/dist/{chunk-SADQWCWR.js.map → chunk-ZTUQYITH.js.map} +0 -0
- /package/dist/{parser-LHBXIKXX.js.map → parser-5D6BQYTX.js.map} +0 -0
- /package/dist/{parser-CYJMOXUR.js.map → parser-NZAE7PBE.js.map} +0 -0
- /package/dist/{render-HY7KKYPV.js.map → render-HRAW7ASR.js.map} +0 -0
- /package/dist/{seal-ITGYHENO.js.map → seal-CK64CXWO.js.map} +0 -0
- /package/dist/{watch-VT7BSLNI.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));
|
|
@@ -22969,7 +23241,7 @@ function parseRenderStyles(headXml) {
|
|
|
22969
23241
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
22970
23242
|
const textColor = el.getAttribute("textColor");
|
|
22971
23243
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
22972
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
23244
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _247 => _247.getAttribute, 'call', _248 => _248("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _249 => _249.getAttribute, 'call', _250 => _250("latin")])));
|
|
22973
23245
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
22974
23246
|
styles.charPr.set(id, {
|
|
22975
23247
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -22977,8 +23249,8 @@ function parseRenderStyles(headXml) {
|
|
|
22977
23249
|
italic: findChildByLocalName(el, "italic") != null,
|
|
22978
23250
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
22979
23251
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
22980
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
22981
|
-
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,
|
|
22982
23254
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
22983
23255
|
});
|
|
22984
23256
|
}
|
|
@@ -22986,7 +23258,7 @@ function parseRenderStyles(headXml) {
|
|
|
22986
23258
|
const id = el.getAttribute("id");
|
|
22987
23259
|
if (id != null) {
|
|
22988
23260
|
const align = findChildByLocalName(el, "align");
|
|
22989
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
23261
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _255 => _255.getAttribute, 'call', _256 => _256("horizontal")]) || "JUSTIFY");
|
|
22990
23262
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
22991
23263
|
}
|
|
22992
23264
|
} else if (tag === "borderFill") {
|
|
@@ -23000,7 +23272,7 @@ function parseRenderStyles(headXml) {
|
|
|
23000
23272
|
};
|
|
23001
23273
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
23002
23274
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
23003
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
23275
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _257 => _257.getAttribute, 'call', _258 => _258("faceColor")]);
|
|
23004
23276
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
23005
23277
|
styles.borderFill.set(id, bf);
|
|
23006
23278
|
}
|
|
@@ -23072,7 +23344,7 @@ function collectSites(scan) {
|
|
|
23072
23344
|
}
|
|
23073
23345
|
function attrOf(openTag, name) {
|
|
23074
23346
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
23075
|
-
return _optionalChain([m, 'optionalAccess',
|
|
23347
|
+
return _optionalChain([m, 'optionalAccess', _259 => _259[1]]);
|
|
23076
23348
|
}
|
|
23077
23349
|
function paraOpenTag(xml, para) {
|
|
23078
23350
|
const end = xml.indexOf(">", para.start);
|
|
@@ -23087,7 +23359,7 @@ function anchorRunInfo(xml, para, anchor) {
|
|
|
23087
23359
|
if (!tr) return null;
|
|
23088
23360
|
const before = xml.slice(Math.max(0, para.start), tr.contentStart);
|
|
23089
23361
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
23090
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
23362
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _260 => _260[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
23091
23363
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
23092
23364
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
23093
23365
|
if (close === -1) return null;
|
|
@@ -23114,7 +23386,7 @@ function cellContentWidthMm(xml, cell) {
|
|
|
23114
23386
|
if (width === null) return null;
|
|
23115
23387
|
let content = width;
|
|
23116
23388
|
const win = cellAddrWindow(xml, cell);
|
|
23117
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
23389
|
+
const mg = _optionalChain([win, 'optionalAccess', _261 => _261.match, 'call', _262 => _262(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
23118
23390
|
if (mg) {
|
|
23119
23391
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
23120
23392
|
}
|
|
@@ -23148,11 +23420,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
23148
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>`;
|
|
23149
23421
|
}
|
|
23150
23422
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
23151
|
-
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");
|
|
23152
23424
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
23153
23425
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
23154
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
23155
|
-
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");
|
|
23156
23428
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
23157
23429
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
23158
23430
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -23193,11 +23465,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23193
23465
|
const manifestItems = [];
|
|
23194
23466
|
const placed = [];
|
|
23195
23467
|
for (const op of ops) {
|
|
23196
|
-
if (!op.anchor) throw new (0,
|
|
23197
|
-
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");
|
|
23198
23470
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
23199
|
-
if (!MIME[ext]) throw new (0,
|
|
23200
|
-
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)`);
|
|
23201
23473
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
23202
23474
|
let found = null;
|
|
23203
23475
|
let total = 0;
|
|
@@ -23230,7 +23502,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23230
23502
|
}
|
|
23231
23503
|
}
|
|
23232
23504
|
}
|
|
23233
|
-
throw new (0,
|
|
23505
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
23234
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)})`
|
|
23235
23507
|
);
|
|
23236
23508
|
}
|
|
@@ -23238,9 +23510,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23238
23510
|
const xml = sectionXmls[si];
|
|
23239
23511
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
23240
23512
|
if (!run) {
|
|
23241
|
-
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`);
|
|
23242
23514
|
}
|
|
23243
|
-
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));
|
|
23244
23516
|
const fontPt = charPrHeight / 100;
|
|
23245
23517
|
const emMm = fontPt * 25.4 / 72;
|
|
23246
23518
|
const lineHMm = emMm;
|
|
@@ -23249,7 +23521,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23249
23521
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
23250
23522
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
23251
23523
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
23252
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
23524
|
+
const align = _optionalChain([styles, 'optionalAccess', _273 => _273.paraAlign, 'access', _274 => _274.get, 'call', _275 => _275(paraPrId)]);
|
|
23253
23525
|
let alignShiftMm = 0;
|
|
23254
23526
|
if (align === "CENTER" || align === "RIGHT") {
|
|
23255
23527
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -23313,6 +23585,184 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23313
23585
|
};
|
|
23314
23586
|
}
|
|
23315
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
|
+
|
|
23316
23766
|
// src/roundtrip/patcher.ts
|
|
23317
23767
|
|
|
23318
23768
|
|
|
@@ -23321,7 +23771,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
23321
23771
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
23322
23772
|
function patchTableRows(input) {
|
|
23323
23773
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
23324
|
-
const xml = _optionalChain([ctx, 'access',
|
|
23774
|
+
const xml = _optionalChain([ctx, 'access', _305 => _305.scans, 'access', _306 => _306[scanTable.sectionIndex], 'optionalAccess', _307 => _307.xml]);
|
|
23325
23775
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
23326
23776
|
const numRows = table.rows;
|
|
23327
23777
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -23488,7 +23938,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
23488
23938
|
const rr = scanTable.rowRanges[template];
|
|
23489
23939
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
23490
23940
|
const scan = scanSectionXml(wrapped, 0);
|
|
23491
|
-
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]]);
|
|
23492
23942
|
if (!row || row.length !== cells.length) return null;
|
|
23493
23943
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
23494
23944
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -23531,7 +23981,7 @@ function rowHeightOf(fragment) {
|
|
|
23531
23981
|
}
|
|
23532
23982
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
23533
23983
|
const from = scanTable.start + tblOpenLen;
|
|
23534
|
-
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));
|
|
23535
23985
|
const slice = xml.slice(from, to);
|
|
23536
23986
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
23537
23987
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -23720,9 +24170,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
23720
24170
|
});
|
|
23721
24171
|
}
|
|
23722
24172
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
23723
|
-
const irCell = _optionalChain([table, 'access',
|
|
24173
|
+
const irCell = _optionalChain([table, 'access', _315 => _315.cells, 'access', _316 => _316[oc.gridR], 'optionalAccess', _317 => _317[oc.gridC]]);
|
|
23724
24174
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
23725
|
-
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);
|
|
23726
24176
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
23727
24177
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
23728
24178
|
}
|
|
@@ -23790,7 +24240,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23790
24240
|
};
|
|
23791
24241
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
23792
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)");
|
|
23793
|
-
const irCell = _optionalChain([table, 'access',
|
|
24243
|
+
const irCell = _optionalChain([table, 'access', _319 => _319.cells, 'access', _320 => _320[gridR], 'optionalAccess', _321 => _321[gridC]]);
|
|
23794
24244
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
23795
24245
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23796
24246
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -23813,7 +24263,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23813
24263
|
if (newLines.length === 0) return 0;
|
|
23814
24264
|
const target = cell.paragraphs[0];
|
|
23815
24265
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
23816
|
-
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]));
|
|
23817
24267
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23818
24268
|
splices.push(...sp);
|
|
23819
24269
|
sectionIndex = target.sectionIndex;
|
|
@@ -23836,7 +24286,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23836
24286
|
}
|
|
23837
24287
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
23838
24288
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
23839
|
-
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]));
|
|
23840
24290
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23841
24291
|
splices.push(...sp);
|
|
23842
24292
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -23917,7 +24367,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
23917
24367
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
23918
24368
|
if (paths.length > 0) return paths;
|
|
23919
24369
|
}
|
|
23920
|
-
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);
|
|
23921
24371
|
}
|
|
23922
24372
|
function sectionPathsFromManifest(xml) {
|
|
23923
24373
|
const attr = (tag, name) => {
|
|
@@ -23927,7 +24377,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23927
24377
|
const idToHref = /* @__PURE__ */ new Map();
|
|
23928
24378
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
23929
24379
|
const id = attr(m[1], "id");
|
|
23930
|
-
const href =
|
|
24380
|
+
const href = _chunk5HDBLRVPcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
23931
24381
|
if (id && href) idToHref.set(id, href);
|
|
23932
24382
|
}
|
|
23933
24383
|
const ordered = [];
|
|
@@ -23936,7 +24386,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23936
24386
|
if (href) ordered.push(href);
|
|
23937
24387
|
}
|
|
23938
24388
|
if (ordered.length > 0) return ordered;
|
|
23939
|
-
return Array.from(idToHref.values()).sort(
|
|
24389
|
+
return Array.from(idToHref.values()).sort(_chunk5HDBLRVPcjs.compareSectionPaths);
|
|
23940
24390
|
}
|
|
23941
24391
|
|
|
23942
24392
|
// src/roundtrip/patcher.ts
|
|
@@ -24028,7 +24478,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
24028
24478
|
}
|
|
24029
24479
|
}
|
|
24030
24480
|
let verification;
|
|
24031
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24481
|
+
if (_optionalChain([options, 'optionalAccess', _328 => _328.verify]) !== false) {
|
|
24032
24482
|
try {
|
|
24033
24483
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
24034
24484
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -24043,20 +24493,20 @@ function buildOrigUnits(blocks) {
|
|
|
24043
24493
|
for (let i = 0; i < blocks.length; i++) {
|
|
24044
24494
|
const block = blocks[i];
|
|
24045
24495
|
let consume = 1;
|
|
24046
|
-
let
|
|
24496
|
+
let chunk2;
|
|
24047
24497
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
24048
24498
|
const next = blocks[i + 1];
|
|
24049
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
24050
|
-
|
|
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));
|
|
24051
24501
|
} else {
|
|
24052
|
-
|
|
24502
|
+
chunk2 = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, [block]);
|
|
24053
24503
|
}
|
|
24054
|
-
if (
|
|
24055
|
-
const subUnits = splitMarkdownUnits(
|
|
24504
|
+
if (chunk2) {
|
|
24505
|
+
const subUnits = splitMarkdownUnits(chunk2);
|
|
24056
24506
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
24057
24507
|
for (let s = 0; s < subUnits.length; s++) {
|
|
24058
24508
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
24059
|
-
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("**")) {
|
|
24060
24510
|
u.role = "caption";
|
|
24061
24511
|
}
|
|
24062
24512
|
units.push(u);
|
|
@@ -24167,7 +24617,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24167
24617
|
const ti = ctx.tableInsert;
|
|
24168
24618
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
24169
24619
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24170
|
-
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");
|
|
24171
24621
|
const para = mapping.para;
|
|
24172
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");
|
|
24173
24623
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -24195,7 +24645,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24195
24645
|
}
|
|
24196
24646
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
24197
24647
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24198
|
-
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)");
|
|
24199
24649
|
if (block.text && block.text.includes("\n")) {
|
|
24200
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)");
|
|
24201
24651
|
}
|
|
@@ -24226,7 +24676,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
24226
24676
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24227
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");
|
|
24228
24678
|
}
|
|
24229
|
-
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]));
|
|
24230
24680
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24231
24681
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24232
24682
|
return 1;
|
|
@@ -24412,7 +24862,7 @@ var Surgeon = (_class4 = class {
|
|
|
24412
24862
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
24413
24863
|
findEntry(path) {
|
|
24414
24864
|
const parts = path.replace(/^\//, "").split("/");
|
|
24415
|
-
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));
|
|
24416
24866
|
let current;
|
|
24417
24867
|
for (const part of parts) {
|
|
24418
24868
|
const search = (idx) => {
|
|
@@ -24625,8 +25075,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
24625
25075
|
parts.push(header, data);
|
|
24626
25076
|
};
|
|
24627
25077
|
for (let i = 0; i < recs.length; i++) {
|
|
24628
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
24629
|
-
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)));
|
|
24630
25080
|
}
|
|
24631
25081
|
return Buffer.concat(parts);
|
|
24632
25082
|
}
|
|
@@ -24744,7 +25194,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24744
25194
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
24745
25195
|
}
|
|
24746
25196
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
24747
|
-
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");
|
|
24748
25198
|
let flags;
|
|
24749
25199
|
try {
|
|
24750
25200
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -24766,7 +25216,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24766
25216
|
const scans = [];
|
|
24767
25217
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
24768
25218
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
24769
|
-
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]}`);
|
|
24770
25220
|
let stream;
|
|
24771
25221
|
try {
|
|
24772
25222
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -24817,7 +25267,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24817
25267
|
}
|
|
24818
25268
|
}
|
|
24819
25269
|
let verification;
|
|
24820
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25270
|
+
if (_optionalChain([options, 'optionalAccess', _346 => _346.verify]) !== false) {
|
|
24821
25271
|
try {
|
|
24822
25272
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
24823
25273
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -24886,19 +25336,19 @@ function resolveTableMappings(blocks, scanTables) {
|
|
|
24886
25336
|
if (scanTables[k].rows === table.rows && scanTables[k].cols === table.cols) cands.push(k);
|
|
24887
25337
|
}
|
|
24888
25338
|
if (cands.length === 0) continue;
|
|
24889
|
-
let
|
|
25339
|
+
let pick2 = cands[0];
|
|
24890
25340
|
if (cands.length > 1) {
|
|
24891
25341
|
let best = tableContentScore(table, scanTables[cands[0]]);
|
|
24892
25342
|
for (let ci = 1; ci < cands.length; ci++) {
|
|
24893
25343
|
const sc = tableContentScore(table, scanTables[cands[ci]]);
|
|
24894
25344
|
if (sc > best) {
|
|
24895
25345
|
best = sc;
|
|
24896
|
-
|
|
25346
|
+
pick2 = cands[ci];
|
|
24897
25347
|
}
|
|
24898
25348
|
}
|
|
24899
25349
|
}
|
|
24900
|
-
result.set(i, scanTables[
|
|
24901
|
-
si =
|
|
25350
|
+
result.set(i, scanTables[pick2]);
|
|
25351
|
+
si = pick2 + 1;
|
|
24902
25352
|
}
|
|
24903
25353
|
return result;
|
|
24904
25354
|
}
|
|
@@ -24907,7 +25357,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
24907
25357
|
for (const [key, scanCell] of scanTable.cells) {
|
|
24908
25358
|
const comma = key.indexOf(",");
|
|
24909
25359
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
24910
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
25360
|
+
const irCell = _optionalChain([irTable, 'access', _347 => _347.cells, 'access', _348 => _348[r], 'optionalAccess', _349 => _349[c]]);
|
|
24911
25361
|
if (!irCell) continue;
|
|
24912
25362
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
24913
25363
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -24943,7 +25393,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
24943
25393
|
}
|
|
24944
25394
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
24945
25395
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24946
|
-
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)");
|
|
24947
25397
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
24948
25398
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
24949
25399
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -25142,7 +25592,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25142
25592
|
};
|
|
25143
25593
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
25144
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)");
|
|
25145
|
-
const irCell = _optionalChain([table, 'access',
|
|
25595
|
+
const irCell = _optionalChain([table, 'access', _351 => _351.cells, 'access', _352 => _352[gridR], 'optionalAccess', _353 => _353[gridC]]);
|
|
25146
25596
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
25147
25597
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25148
25598
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25534,7 +25984,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25534
25984
|
const block = st.blocks[blockIndex];
|
|
25535
25985
|
if (!block) return void 0;
|
|
25536
25986
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
25537
|
-
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]);
|
|
25538
25988
|
if (!para) return void 0;
|
|
25539
25989
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
25540
25990
|
}
|
|
@@ -25559,7 +26009,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25559
26009
|
if (block.text && block.text.includes("\n")) {
|
|
25560
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)" };
|
|
25561
26011
|
}
|
|
25562
|
-
if (!_optionalChain([st, 'access',
|
|
26012
|
+
if (!_optionalChain([st, 'access', _358 => _358.paraMap, 'access', _359 => _359.get, 'call', _360 => _360(blockIndex), 'optionalAccess', _361 => _361.para])) {
|
|
25563
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)" };
|
|
25564
26014
|
}
|
|
25565
26015
|
return { capability: "text" };
|
|
@@ -25625,7 +26075,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25625
26075
|
continue;
|
|
25626
26076
|
}
|
|
25627
26077
|
if (block.type === "table" && block.table) {
|
|
25628
|
-
if (!_optionalChain([edit, 'access',
|
|
26078
|
+
if (!_optionalChain([edit, 'access', _362 => _362.cells, 'optionalAccess', _363 => _363.length])) {
|
|
25629
26079
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
25630
26080
|
continue;
|
|
25631
26081
|
}
|
|
@@ -25645,7 +26095,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25645
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) });
|
|
25646
26096
|
continue;
|
|
25647
26097
|
}
|
|
25648
|
-
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]]);
|
|
25649
26099
|
if (!irCell) {
|
|
25650
26100
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
25651
26101
|
continue;
|
|
@@ -25701,7 +26151,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25701
26151
|
}
|
|
25702
26152
|
if (replacements.size === 0) {
|
|
25703
26153
|
let changes2;
|
|
25704
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26154
|
+
if (_optionalChain([options, 'optionalAccess', _368 => _368.verify]) !== false) {
|
|
25705
26155
|
const units = splitMarkdownUnits(st.markdown);
|
|
25706
26156
|
changes2 = diffUnitLists(units, units);
|
|
25707
26157
|
}
|
|
@@ -25722,7 +26172,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25722
26172
|
}
|
|
25723
26173
|
this.state = newState;
|
|
25724
26174
|
let changes;
|
|
25725
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26175
|
+
if (_optionalChain([options, 'optionalAccess', _369 => _369.verify]) !== false) {
|
|
25726
26176
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
25727
26177
|
}
|
|
25728
26178
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -25742,7 +26192,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25742
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)");
|
|
25743
26193
|
}
|
|
25744
26194
|
const mapping = st.paraMap.get(blockIndex);
|
|
25745
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26195
|
+
if (!_optionalChain([mapping, 'optionalAccess', _370 => _370.para])) {
|
|
25746
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)");
|
|
25747
26197
|
}
|
|
25748
26198
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -25762,14 +26212,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25762
26212
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25763
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");
|
|
25764
26214
|
}
|
|
25765
|
-
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]));
|
|
25766
26216
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25767
26217
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25768
26218
|
return 1;
|
|
25769
26219
|
}
|
|
25770
26220
|
}, _class5);
|
|
25771
26221
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
25772
|
-
const irCell = _optionalChain([table, 'access',
|
|
26222
|
+
const irCell = _optionalChain([table, 'access', _374 => _374.cells, 'access', _375 => _375[r], 'optionalAccess', _376 => _376[c]]);
|
|
25773
26223
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
25774
26224
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
25775
26225
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -25853,11 +26303,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
25853
26303
|
breaks: false
|
|
25854
26304
|
});
|
|
25855
26305
|
function renderHtml(markdown, options) {
|
|
25856
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25857
|
-
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]), () => ( "")));
|
|
25858
26308
|
const body = md.render(markdown);
|
|
25859
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
25860
|
-
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]) ? `
|
|
25861
26311
|
.watermark {
|
|
25862
26312
|
position: fixed;
|
|
25863
26313
|
top: 50%; left: 50%;
|
|
@@ -25888,13 +26338,13 @@ async function htmlToPdf(html, options) {
|
|
|
25888
26338
|
try {
|
|
25889
26339
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
25890
26340
|
} catch (e30) {
|
|
25891
|
-
throw new (0,
|
|
26341
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
25892
26342
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
25893
26343
|
);
|
|
25894
26344
|
}
|
|
25895
26345
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
25896
26346
|
if (!executablePath) {
|
|
25897
|
-
throw new (0,
|
|
26347
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)(
|
|
25898
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."
|
|
25899
26349
|
);
|
|
25900
26350
|
}
|
|
@@ -25906,10 +26356,10 @@ async function htmlToPdf(html, options) {
|
|
|
25906
26356
|
try {
|
|
25907
26357
|
const page = await browser.newPage();
|
|
25908
26358
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
25909
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
26359
|
+
const margin = _optionalChain([options, 'optionalAccess', _381 => _381.margin]);
|
|
25910
26360
|
const pdf = await page.pdf({
|
|
25911
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25912
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
26361
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _382 => _382.pageSize]), () => ( "A4")),
|
|
26362
|
+
landscape: _optionalChain([options, 'optionalAccess', _383 => _383.orientation]) === "landscape",
|
|
25913
26363
|
printBackground: true,
|
|
25914
26364
|
margin: margin ? {
|
|
25915
26365
|
top: toCss(margin.top),
|
|
@@ -25917,9 +26367,9 @@ async function htmlToPdf(html, options) {
|
|
|
25917
26367
|
bottom: toCss(margin.bottom),
|
|
25918
26368
|
left: toCss(margin.left)
|
|
25919
26369
|
} : void 0,
|
|
25920
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
25921
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25922
|
-
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>'))
|
|
25923
26373
|
});
|
|
25924
26374
|
return Buffer.from(pdf);
|
|
25925
26375
|
} finally {
|
|
@@ -25953,7 +26403,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
25953
26403
|
return htmlToPdf(html, options);
|
|
25954
26404
|
}
|
|
25955
26405
|
async function blocksToPdf(blocks, options) {
|
|
25956
|
-
const markdown =
|
|
26406
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, blocks);
|
|
25957
26407
|
return markdownToPdf(markdown, options);
|
|
25958
26408
|
}
|
|
25959
26409
|
|
|
@@ -26047,7 +26497,7 @@ function elements(el) {
|
|
|
26047
26497
|
for (let i = 0; i < kids2.length; i++) if (kids2[i].nodeType === 1) out.push(kids2[i]);
|
|
26048
26498
|
return out;
|
|
26049
26499
|
}
|
|
26050
|
-
function
|
|
26500
|
+
function num2(el, attr, fallback = 0) {
|
|
26051
26501
|
return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
|
|
26052
26502
|
}
|
|
26053
26503
|
function shiftParaVert(p, delta) {
|
|
@@ -26055,7 +26505,7 @@ function shiftParaVert(p, delta) {
|
|
|
26055
26505
|
if (ln(lsa) !== "linesegarray") continue;
|
|
26056
26506
|
for (const seg of elements(lsa)) {
|
|
26057
26507
|
if (ln(seg) !== "lineseg") continue;
|
|
26058
|
-
seg.setAttribute("vertpos", String(
|
|
26508
|
+
seg.setAttribute("vertpos", String(num2(seg, "vertpos") + delta));
|
|
26059
26509
|
}
|
|
26060
26510
|
}
|
|
26061
26511
|
}
|
|
@@ -26145,9 +26595,9 @@ function reflowTablesIn(p, doc, styles, mode, counter) {
|
|
|
26145
26595
|
if (ln(tc) !== "tc") continue;
|
|
26146
26596
|
const csz = findChildByLocalName(tc, "cellSz");
|
|
26147
26597
|
const cm = findChildByLocalName(tc, "cellMargin");
|
|
26148
|
-
const cellW =
|
|
26149
|
-
const mL = cm ?
|
|
26150
|
-
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;
|
|
26151
26601
|
const areaW = Math.max(500, cellW - mL - mR);
|
|
26152
26602
|
const sub = findChildByLocalName(tc, "subList");
|
|
26153
26603
|
if (sub) reflowBlockFlow(sub, doc, styles, areaW, mode, counter, 0);
|
|
@@ -26163,7 +26613,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
26163
26613
|
if (ln(p) !== "p") continue;
|
|
26164
26614
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
26165
26615
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
26166
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
26616
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _388 => _388.spaceBefore]), () => ( 0)));
|
|
26167
26617
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
26168
26618
|
if (res) {
|
|
26169
26619
|
const paraH = res.paraBottom - startV;
|
|
@@ -26198,7 +26648,7 @@ function elements2(el) {
|
|
|
26198
26648
|
}
|
|
26199
26649
|
return out;
|
|
26200
26650
|
}
|
|
26201
|
-
function
|
|
26651
|
+
function num3(el, attr, fallback = 0) {
|
|
26202
26652
|
return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
|
|
26203
26653
|
}
|
|
26204
26654
|
function findFirst(el, name, depth = 0) {
|
|
@@ -26266,13 +26716,13 @@ function buildPara(p) {
|
|
|
26266
26716
|
} else if (OBJ_TAGS.has(cn)) {
|
|
26267
26717
|
const sz = findChildByLocalName(ch, "sz");
|
|
26268
26718
|
const pos = findChildByLocalName(ch, "pos");
|
|
26269
|
-
const w =
|
|
26270
|
-
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");
|
|
26271
26721
|
objs.push({
|
|
26272
26722
|
el: ch,
|
|
26273
26723
|
tag: cn,
|
|
26274
26724
|
index: chars.length,
|
|
26275
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
26725
|
+
inline: _optionalChain([pos, 'optionalAccess', _389 => _389.getAttribute, 'call', _390 => _390("treatAsChar")]) === "1",
|
|
26276
26726
|
width: w,
|
|
26277
26727
|
height: h
|
|
26278
26728
|
});
|
|
@@ -26283,12 +26733,12 @@ function buildPara(p) {
|
|
|
26283
26733
|
}
|
|
26284
26734
|
} else if (tag === "linesegarray") {
|
|
26285
26735
|
segs = elements2(runEl).filter((s) => ln2(s) === "lineseg").map((s) => ({
|
|
26286
|
-
textpos:
|
|
26287
|
-
vertpos:
|
|
26288
|
-
horzpos:
|
|
26289
|
-
horzsize:
|
|
26290
|
-
textheight:
|
|
26291
|
-
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)
|
|
26292
26742
|
}));
|
|
26293
26743
|
}
|
|
26294
26744
|
}
|
|
@@ -26458,11 +26908,11 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx) {
|
|
|
26458
26908
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
|
|
26459
26909
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26460
26910
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26461
|
-
const omT =
|
|
26911
|
+
const omT = num3(om, "top"), omB = num3(om, "bottom");
|
|
26462
26912
|
const w = o.width, h = o.height;
|
|
26463
26913
|
if (!pos) return { x: ox, y: oy + baseV };
|
|
26464
|
-
const vo =
|
|
26465
|
-
const ho =
|
|
26914
|
+
const vo = num3(pos, "vertOffset");
|
|
26915
|
+
const ho = num3(pos, "horzOffset");
|
|
26466
26916
|
const vrel = _nullishCoalesce(pos.getAttribute("vertRelTo"), () => ( "PARA"));
|
|
26467
26917
|
const hrel = _nullishCoalesce(pos.getAttribute("horzRelTo"), () => ( "PARA"));
|
|
26468
26918
|
const va = _nullishCoalesce(pos.getAttribute("vertAlign"), () => ( "TOP"));
|
|
@@ -26499,8 +26949,8 @@ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
|
|
|
26499
26949
|
if (!OBJ_TAGS.has(tag)) continue;
|
|
26500
26950
|
const sz = findChildByLocalName(ch, "sz");
|
|
26501
26951
|
const off = findChildByLocalName(ch, "offset");
|
|
26502
|
-
const sub = { el: ch, tag, index: 0, inline: true, width:
|
|
26503
|
-
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);
|
|
26504
26954
|
}
|
|
26505
26955
|
} else if (o.tag === "equation") {
|
|
26506
26956
|
warnOnce(ctx, "equation", "\uC218\uC2DD \uAC1C\uCCB4\uB294 \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5");
|
|
@@ -26518,21 +26968,21 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26518
26968
|
const el = o.el;
|
|
26519
26969
|
const orgSz = findChildByLocalName(el, "orgSz");
|
|
26520
26970
|
const curSz = findChildByLocalName(el, "curSz");
|
|
26521
|
-
const ow =
|
|
26522
|
-
const w =
|
|
26523
|
-
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;
|
|
26524
26974
|
const sx = ow > 0 ? w / ow : 1;
|
|
26525
26975
|
const sy = oh > 0 ? h / oh : 1;
|
|
26526
26976
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
26527
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
26528
|
-
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";
|
|
26529
26979
|
const hasStroke = lstyle !== "NONE";
|
|
26530
|
-
const strokeW = hasStroke ? shapeStrokePt(lineShape ?
|
|
26980
|
+
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
26531
26981
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
26532
26982
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
26533
26983
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26534
26984
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26535
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26985
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _395 => _395.getAttribute, 'call', _396 => _396("faceColor")]);
|
|
26536
26986
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
26537
26987
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
26538
26988
|
if (o.tag === "rect") {
|
|
@@ -26541,12 +26991,12 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26541
26991
|
emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fillAttr}${strokeAttr}/>`);
|
|
26542
26992
|
} else if (o.tag === "line") {
|
|
26543
26993
|
const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
|
|
26544
|
-
const x1 = x +
|
|
26545
|
-
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;
|
|
26546
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}/>`);
|
|
26547
26997
|
} else if (o.tag === "polygon" || o.tag === "curv") {
|
|
26548
26998
|
const pts = [];
|
|
26549
|
-
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)}`);
|
|
26550
27000
|
if (pts.length >= 2) emit(ctx, `<polygon points="${pts.join(" ")}"${fillAttr}${strokeAttr}/>`);
|
|
26551
27001
|
} else if (o.tag === "arc") {
|
|
26552
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"`}/>`);
|
|
@@ -26564,7 +27014,7 @@ function cellContentExtent(cell) {
|
|
|
26564
27014
|
if (ln2(p) !== "p") continue;
|
|
26565
27015
|
const m = buildPara(p);
|
|
26566
27016
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
26567
|
-
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));
|
|
26568
27018
|
for (const o of m.objs) {
|
|
26569
27019
|
if (o.inline) {
|
|
26570
27020
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -26572,11 +27022,11 @@ function cellContentExtent(cell) {
|
|
|
26572
27022
|
continue;
|
|
26573
27023
|
}
|
|
26574
27024
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26575
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
27025
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _400 => _400.getAttribute, 'call', _401 => _401("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
26576
27026
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26577
|
-
const pushed = baseV - (
|
|
27027
|
+
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
26578
27028
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
26579
|
-
ext = Math.max(ext, anchor +
|
|
27029
|
+
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
26580
27030
|
}
|
|
26581
27031
|
}
|
|
26582
27032
|
return ext;
|
|
@@ -26587,8 +27037,8 @@ function edgeLine(x1, y1, x2, y2, e) {
|
|
|
26587
27037
|
}
|
|
26588
27038
|
function collectCells(tbl) {
|
|
26589
27039
|
const inMargin = findChildByLocalName(tbl, "inMargin");
|
|
26590
|
-
const defL =
|
|
26591
|
-
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);
|
|
26592
27042
|
const cells = [];
|
|
26593
27043
|
for (const tr of elements2(tbl)) {
|
|
26594
27044
|
if (ln2(tr) !== "tr") continue;
|
|
@@ -26601,18 +27051,18 @@ function collectCells(tbl) {
|
|
|
26601
27051
|
if (!addr || !csz) continue;
|
|
26602
27052
|
cells.push({
|
|
26603
27053
|
el: tc,
|
|
26604
|
-
ca:
|
|
26605
|
-
ra:
|
|
26606
|
-
cs: Math.max(1,
|
|
26607
|
-
rs: Math.max(1,
|
|
26608
|
-
w:
|
|
26609
|
-
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"),
|
|
26610
27060
|
bfId: tc.getAttribute("borderFillIDRef"),
|
|
26611
27061
|
sub: findChildByLocalName(tc, "subList"),
|
|
26612
|
-
marginL: cm ?
|
|
26613
|
-
marginR: cm ?
|
|
26614
|
-
marginT: cm ?
|
|
26615
|
-
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
|
|
26616
27066
|
});
|
|
26617
27067
|
}
|
|
26618
27068
|
}
|
|
@@ -26642,7 +27092,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26642
27092
|
const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
|
|
26643
27093
|
const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
|
|
26644
27094
|
const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
|
|
26645
|
-
const colX = solveBoundaries(colCons, nCols,
|
|
27095
|
+
const colX = solveBoundaries(colCons, nCols, num3(tblSz, "width") || void 0);
|
|
26646
27096
|
const rowH = solveRowHeights(
|
|
26647
27097
|
cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
|
|
26648
27098
|
nRows
|
|
@@ -26658,7 +27108,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26658
27108
|
}));
|
|
26659
27109
|
for (const g of geom) {
|
|
26660
27110
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
26661
|
-
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)}"/>`);
|
|
26662
27112
|
}
|
|
26663
27113
|
for (const g of geom) {
|
|
26664
27114
|
const { c } = g;
|
|
@@ -26694,9 +27144,9 @@ function imageSymbol(loaded, ctx) {
|
|
|
26694
27144
|
}
|
|
26695
27145
|
function drawPic(pic, x, y, ctx) {
|
|
26696
27146
|
const sz = findChildByLocalName(pic, "sz");
|
|
26697
|
-
const w =
|
|
27147
|
+
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
26698
27148
|
const img = findFirst(pic, "img");
|
|
26699
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
27149
|
+
const ref = _optionalChain([img, 'optionalAccess', _403 => _403.getAttribute, 'call', _404 => _404("binaryItemIDRef")]);
|
|
26700
27150
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
26701
27151
|
if (!loaded) {
|
|
26702
27152
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -26707,11 +27157,11 @@ function drawPic(pic, x, y, ctx) {
|
|
|
26707
27157
|
const clip = findChildByLocalName(pic, "imgClip");
|
|
26708
27158
|
const imgDim = findChildByLocalName(pic, "imgDim");
|
|
26709
27159
|
const orgSz = findChildByLocalName(pic, "orgSz");
|
|
26710
|
-
const dimW =
|
|
26711
|
-
const refW = dimW > 0 ? dimW :
|
|
26712
|
-
const refH = dimH > 0 ? dimH :
|
|
26713
|
-
const cl =
|
|
26714
|
-
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);
|
|
26715
27165
|
const cropped = refW > 0 && refH > 0 && clip != null && (cl > 0 || ct > 0 || cr < refW || cb < refH) && cr > cl && cb > ct;
|
|
26716
27166
|
const symId = imageSymbol(loaded, ctx);
|
|
26717
27167
|
if (cropped) {
|
|
@@ -26734,23 +27184,23 @@ function sniffMime(name, bytes) {
|
|
|
26734
27184
|
function readSectionGeom(root) {
|
|
26735
27185
|
const pagePr = findFirst(root, "pagePr");
|
|
26736
27186
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
26737
|
-
let PW =
|
|
26738
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
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) {
|
|
26739
27189
|
const t = PW;
|
|
26740
27190
|
PW = PH;
|
|
26741
27191
|
PH = t;
|
|
26742
27192
|
}
|
|
26743
|
-
const ML =
|
|
26744
|
-
const MT =
|
|
26745
|
-
const BODY_H = PH - MT -
|
|
26746
|
-
const BODY_W = PW - ML -
|
|
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);
|
|
26747
27197
|
return { PW, PH, ML, MT, BODY_W, BODY_H };
|
|
26748
27198
|
}
|
|
26749
27199
|
function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
26750
27200
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = geom;
|
|
26751
27201
|
if (!hasCache) reflowSection(root, ctxBase.styles, { BODY_W, BODY_H }, reflowMode);
|
|
26752
27202
|
const colPr = findFirst(root, "colPr");
|
|
26753
|
-
const multiCol =
|
|
27203
|
+
const multiCol = num3(colPr, "colCount", 1) > 1;
|
|
26754
27204
|
const paraSegPages = /* @__PURE__ */ new Map();
|
|
26755
27205
|
let nPages = 1;
|
|
26756
27206
|
let maxTopV = 0;
|
|
@@ -26765,13 +27215,13 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
26765
27215
|
const pagesOf = [];
|
|
26766
27216
|
let paraFirst = true;
|
|
26767
27217
|
for (const s of segEls) {
|
|
26768
|
-
const v =
|
|
26769
|
-
const h =
|
|
27218
|
+
const v = num3(s, "vertpos");
|
|
27219
|
+
const h = num3(s, "horzpos");
|
|
26770
27220
|
const brk = v < prevV ? !multiCol || h <= prevH : paraFirst && v === prevV && h <= prevH;
|
|
26771
27221
|
if (brk) cur++;
|
|
26772
27222
|
paraFirst = false;
|
|
26773
27223
|
pagesOf.push(cur);
|
|
26774
|
-
maxTopV = Math.max(maxTopV, v +
|
|
27224
|
+
maxTopV = Math.max(maxTopV, v + num3(s, "textheight", 1e3));
|
|
26775
27225
|
prevV = v;
|
|
26776
27226
|
prevH = h;
|
|
26777
27227
|
}
|
|
@@ -26793,17 +27243,17 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
26793
27243
|
return { pages: ctx.pages, pageH };
|
|
26794
27244
|
}
|
|
26795
27245
|
async function renderHwpxToSvg(input, options) {
|
|
26796
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27246
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _407 => _407.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
26797
27247
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
26798
|
-
|
|
27248
|
+
_chunk5HDBLRVPcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
26799
27249
|
let zip;
|
|
26800
27250
|
try {
|
|
26801
27251
|
zip = await _jszip2.default.loadAsync(input);
|
|
26802
27252
|
} catch (e31) {
|
|
26803
|
-
throw new (0,
|
|
27253
|
+
throw new (0, _chunk5HDBLRVPcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
26804
27254
|
}
|
|
26805
27255
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
26806
|
-
if (secFiles.length === 0) throw new (0,
|
|
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");
|
|
26807
27257
|
const warnings = [];
|
|
26808
27258
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
26809
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() };
|
|
@@ -26811,7 +27261,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26811
27261
|
const secXmls = [];
|
|
26812
27262
|
for (const f of secFiles) {
|
|
26813
27263
|
const xml = await f.async("string");
|
|
26814
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
27264
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk5HDBLRVPcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
26815
27265
|
secXmls.push(xml);
|
|
26816
27266
|
}
|
|
26817
27267
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -26835,7 +27285,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26835
27285
|
let href = binmap.get(ref);
|
|
26836
27286
|
if (!href) {
|
|
26837
27287
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
26838
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
27288
|
+
href = _optionalChain([cand, 'optionalAccess', _408 => _408.name]);
|
|
26839
27289
|
}
|
|
26840
27290
|
if (!href) continue;
|
|
26841
27291
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -26856,7 +27306,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26856
27306
|
styles,
|
|
26857
27307
|
images,
|
|
26858
27308
|
defs: [],
|
|
26859
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27309
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _409 => _409.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
26860
27310
|
warnings,
|
|
26861
27311
|
warned: /* @__PURE__ */ new Set(),
|
|
26862
27312
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -26866,7 +27316,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26866
27316
|
for (let si = 0; si < secXmls.length; si++) {
|
|
26867
27317
|
const secXml = secXmls[si];
|
|
26868
27318
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
26869
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
27319
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _410 => _410.reflow])) {
|
|
26870
27320
|
noCacheSkipped = true;
|
|
26871
27321
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
26872
27322
|
continue;
|
|
@@ -26878,14 +27328,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26878
27328
|
continue;
|
|
26879
27329
|
}
|
|
26880
27330
|
const geom = readSectionGeom(root);
|
|
26881
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27331
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _411 => _411.reflowMode]), () => ( "keep")));
|
|
26882
27332
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
26883
27333
|
}
|
|
26884
27334
|
if (rendered.length === 0) {
|
|
26885
27335
|
if (noCacheSkipped) {
|
|
26886
|
-
throw new (0,
|
|
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)");
|
|
26887
27337
|
}
|
|
26888
|
-
throw new (0,
|
|
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");
|
|
26889
27339
|
}
|
|
26890
27340
|
const GAP = 2400;
|
|
26891
27341
|
const clipDefs = [];
|
|
@@ -26917,17 +27367,17 @@ ${groups.join("\n")}
|
|
|
26917
27367
|
// src/index.ts
|
|
26918
27368
|
async function parse(input, options) {
|
|
26919
27369
|
let buffer;
|
|
26920
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
27370
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _412 => _412.filePath]) ? { ...options, filePath: input } : options;
|
|
26921
27371
|
if (typeof input === "string") {
|
|
26922
27372
|
try {
|
|
26923
27373
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26924
|
-
buffer =
|
|
27374
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, buf);
|
|
26925
27375
|
} catch (err) {
|
|
26926
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}`;
|
|
26927
27377
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
26928
27378
|
}
|
|
26929
27379
|
} else if (Buffer.isBuffer(input)) {
|
|
26930
|
-
buffer =
|
|
27380
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, input);
|
|
26931
27381
|
} else {
|
|
26932
27382
|
buffer = input;
|
|
26933
27383
|
}
|
|
@@ -26962,21 +27412,21 @@ async function parseHwp3(buffer, options) {
|
|
|
26962
27412
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
26963
27413
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
26964
27414
|
} catch (err) {
|
|
26965
|
-
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) };
|
|
26966
27416
|
}
|
|
26967
27417
|
}
|
|
26968
27418
|
async function parseHwpx(buffer, options) {
|
|
26969
27419
|
try {
|
|
26970
27420
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
26971
|
-
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 };
|
|
26972
27422
|
} catch (err) {
|
|
26973
|
-
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) };
|
|
26974
27424
|
}
|
|
26975
27425
|
}
|
|
26976
27426
|
async function parseHwp(buffer, options) {
|
|
26977
27427
|
try {
|
|
26978
27428
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
26979
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
27429
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _414 => _414.filePath])) {
|
|
26980
27430
|
try {
|
|
26981
27431
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
26982
27432
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -26993,15 +27443,15 @@ async function parseHwp(buffer, options) {
|
|
|
26993
27443
|
} catch (e32) {
|
|
26994
27444
|
}
|
|
26995
27445
|
}
|
|
26996
|
-
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 };
|
|
26997
27447
|
} catch (err) {
|
|
26998
|
-
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) };
|
|
26999
27449
|
}
|
|
27000
27450
|
}
|
|
27001
27451
|
async function parsePdf(buffer, options) {
|
|
27002
27452
|
let parsePdfDocument;
|
|
27003
27453
|
try {
|
|
27004
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
27454
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-S34YR2SH.cjs")));
|
|
27005
27455
|
parsePdfDocument = mod.parsePdfDocument;
|
|
27006
27456
|
} catch (e33) {
|
|
27007
27457
|
return {
|
|
@@ -27016,7 +27466,7 @@ async function parsePdf(buffer, options) {
|
|
|
27016
27466
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
27017
27467
|
} catch (err) {
|
|
27018
27468
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
27019
|
-
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 };
|
|
27020
27470
|
}
|
|
27021
27471
|
}
|
|
27022
27472
|
async function parseXlsx(buffer, options) {
|
|
@@ -27024,7 +27474,7 @@ async function parseXlsx(buffer, options) {
|
|
|
27024
27474
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
27025
27475
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
27026
27476
|
} catch (err) {
|
|
27027
|
-
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) };
|
|
27028
27478
|
}
|
|
27029
27479
|
}
|
|
27030
27480
|
async function parseXls(buffer, options) {
|
|
@@ -27032,15 +27482,15 @@ async function parseXls(buffer, options) {
|
|
|
27032
27482
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
27033
27483
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
27034
27484
|
} catch (err) {
|
|
27035
|
-
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) };
|
|
27036
27486
|
}
|
|
27037
27487
|
}
|
|
27038
27488
|
async function parseDocx(buffer, options) {
|
|
27039
27489
|
try {
|
|
27040
27490
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
27041
|
-
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 };
|
|
27042
27492
|
} catch (err) {
|
|
27043
|
-
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) };
|
|
27044
27494
|
}
|
|
27045
27495
|
}
|
|
27046
27496
|
async function parseHwpml(buffer, options) {
|
|
@@ -27048,16 +27498,16 @@ async function parseHwpml(buffer, options) {
|
|
|
27048
27498
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
27049
27499
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
27050
27500
|
} catch (err) {
|
|
27051
|
-
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) };
|
|
27052
27502
|
}
|
|
27053
27503
|
}
|
|
27054
27504
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
27055
27505
|
let buffer;
|
|
27056
27506
|
if (typeof input === "string") {
|
|
27057
27507
|
const buf = await _promises.readFile.call(void 0, input);
|
|
27058
|
-
buffer =
|
|
27508
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, buf);
|
|
27059
27509
|
} else if (Buffer.isBuffer(input)) {
|
|
27060
|
-
buffer =
|
|
27510
|
+
buffer = _chunk5HDBLRVPcjs.toArrayBuffer.call(void 0, input);
|
|
27061
27511
|
} else {
|
|
27062
27512
|
buffer = input;
|
|
27063
27513
|
}
|
|
@@ -27083,7 +27533,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27083
27533
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
27084
27534
|
}
|
|
27085
27535
|
const fill = fillFormFields(parsed.blocks, values);
|
|
27086
|
-
const markdown =
|
|
27536
|
+
const markdown = _chunk5HDBLRVPcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
27087
27537
|
if (outputFormat === "hwpx") {
|
|
27088
27538
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
27089
27539
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -27146,5 +27596,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27146
27596
|
|
|
27147
27597
|
|
|
27148
27598
|
|
|
27149
|
-
|
|
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;
|
|
27150
27601
|
//# sourceMappingURL=index.cjs.map
|