kordoc 3.17.0 → 3.18.1
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 → -V66QW3WA.js} +9 -7
- package/dist/{chunk-WHMNPQXW.js → chunk-2IBFK5ZO.js} +39 -3
- package/dist/chunk-2IBFK5ZO.js.map +1 -0
- package/dist/{chunk-NKICMZ7F.js → chunk-4RGDFDQ2.js} +2 -2
- package/dist/{chunk-VUS6LRVY.js → chunk-7K5P4RNT.js} +571 -83
- package/dist/chunk-7K5P4RNT.js.map +1 -0
- package/dist/{chunk-TDIDUEBH.js → chunk-NZJAXMN7.js} +3 -3
- package/dist/{chunk-SADQWCWR.js → chunk-QMJJI6TD.js} +3 -3
- package/dist/{chunk-EL2Y4BL2.cjs → chunk-R2H34FY5.cjs} +45 -9
- package/dist/chunk-R2H34FY5.cjs.map +1 -0
- package/dist/{chunk-E6NQWOFQ.js → chunk-UHYPUIRH.js} +39 -3
- package/dist/chunk-UHYPUIRH.js.map +1 -0
- package/dist/{chunk-HVEEFHN7.js → chunk-UNV7F3FK.js} +2 -2
- package/dist/cli.js +19 -16
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +899 -411
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -1
- package/dist/index.d.ts +124 -1
- package/dist/index.js +629 -141
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +10 -9
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-CYJMOXUR.js → parser-DOBK652H.js} +3 -3
- package/dist/{parser-LHBXIKXX.js → parser-JBBA5A5E.js} +2 -2
- package/dist/{parser-I5GC4QQ5.cjs → parser-XEY5MRGV.cjs} +14 -14
- package/dist/{parser-I5GC4QQ5.cjs.map → parser-XEY5MRGV.cjs.map} +1 -1
- package/dist/render-VX4H2S4F.js +10 -0
- package/dist/seal-6Z6H4YXN.js +10 -0
- package/dist/{watch-VT7BSLNI.js → watch-2MNRQWGV.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 → -V66QW3WA.js.map} +0 -0
- /package/dist/{chunk-NKICMZ7F.js.map → chunk-4RGDFDQ2.js.map} +0 -0
- /package/dist/{chunk-TDIDUEBH.js.map → chunk-NZJAXMN7.js.map} +0 -0
- /package/dist/{chunk-SADQWCWR.js.map → chunk-QMJJI6TD.js.map} +0 -0
- /package/dist/{chunk-HVEEFHN7.js.map → chunk-UNV7F3FK.js.map} +0 -0
- /package/dist/{parser-CYJMOXUR.js.map → parser-DOBK652H.js.map} +0 -0
- /package/dist/{parser-LHBXIKXX.js.map → parser-JBBA5A5E.js.map} +0 -0
- /package/dist/{render-HY7KKYPV.js.map → render-VX4H2S4F.js.map} +0 -0
- /package/dist/{seal-ITGYHENO.js.map → seal-6Z6H4YXN.js.map} +0 -0
- /package/dist/{watch-VT7BSLNI.js.map → watch-2MNRQWGV.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
var _chunkR2H34FY5cjs = require('./chunk-R2H34FY5.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, _chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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(_chunkR2H34FY5cjs.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 >= _chunkR2H34FY5cjs.HEADING_RATIO_H1) level = 1;
|
|
620
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H2) level = 2;
|
|
621
|
+
else if (ratio >= _chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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(_chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.MAX_COLS);
|
|
1372
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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 (_chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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 _chunkR2H34FY5cjs.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 (_chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
2033
2034
|
}
|
|
2034
2035
|
function parseSectionPathsFromManifest(xml) {
|
|
2035
2036
|
const parser = createXmlParser();
|
|
2036
|
-
const doc = parser.parseFromString(
|
|
2037
|
+
const doc = parser.parseFromString(_chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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(_chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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(_chunkR2H34FY5cjs.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
|
+
_chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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 _chunkR2H34FY5cjs.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 = _chunkR2H34FY5cjs.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, _chunkR2H34FY5cjs.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,143 @@ 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 = 36e6;
|
|
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
|
+
function escapeRegExp(s) {
|
|
2874
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2875
|
+
}
|
|
2876
|
+
function inlineImagesIntoMarkdown(markdown, images, opts) {
|
|
2877
|
+
const compress = _optionalChain([opts, 'optionalAccess', _50 => _50.compress]) !== false;
|
|
2878
|
+
let out = markdown;
|
|
2879
|
+
for (const img of images) {
|
|
2880
|
+
let bytes = img.data;
|
|
2881
|
+
let mime = img.mimeType;
|
|
2882
|
+
if (compress && mime === "image/bmp") {
|
|
2883
|
+
const png = bmpToPng(img.data);
|
|
2884
|
+
if (png) {
|
|
2885
|
+
bytes = png;
|
|
2886
|
+
mime = "image/png";
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
const base64 = Buffer.from(bytes).toString("base64");
|
|
2890
|
+
const dataUri = `data:${mime};base64,${base64}`;
|
|
2891
|
+
const name = escapeRegExp(img.filename);
|
|
2892
|
+
const mdRe = new RegExp(`!\\[image\\]\\((?:images/)?${name}\\)`, "g");
|
|
2893
|
+
out = out.replace(mdRe, () => ``);
|
|
2894
|
+
const imgTagRe = new RegExp(`(<img\\b[^>]*\\bsrc=")(?:images/)?${name}(")`, "g");
|
|
2895
|
+
out = out.replace(imgTagRe, (_m, pre, post) => `${pre}${dataUri}${post}`);
|
|
2896
|
+
}
|
|
2897
|
+
return out;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2762
2900
|
// src/hwp5/aes.ts
|
|
2763
2901
|
var S_BOX = new Uint8Array([
|
|
2764
2902
|
99,
|
|
@@ -3756,22 +3894,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3756
3894
|
lenientCfb = parseLenientCfb(buffer);
|
|
3757
3895
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3758
3896
|
} catch (e21) {
|
|
3759
|
-
throw new (0,
|
|
3897
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3760
3898
|
}
|
|
3761
3899
|
}
|
|
3762
3900
|
const findStream = (path) => {
|
|
3763
3901
|
if (cfb) {
|
|
3764
3902
|
const entry = CFB.find(cfb, path);
|
|
3765
|
-
return _optionalChain([entry, 'optionalAccess',
|
|
3903
|
+
return _optionalChain([entry, 'optionalAccess', _51 => _51.content]) ? Buffer.from(entry.content) : null;
|
|
3766
3904
|
}
|
|
3767
3905
|
return lenientCfb.findStream(path);
|
|
3768
3906
|
};
|
|
3769
3907
|
const headerData = findStream("/FileHeader");
|
|
3770
|
-
if (!headerData) throw new (0,
|
|
3908
|
+
if (!headerData) throw new (0, _chunkR2H34FY5cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3771
3909
|
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,
|
|
3910
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkR2H34FY5cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3911
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3912
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkR2H34FY5cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3775
3913
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3776
3914
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3777
3915
|
const metadata = {
|
|
@@ -3780,9 +3918,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
3780
3918
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3781
3919
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3782
3920
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3783
|
-
if (sections.length === 0) throw new (0,
|
|
3921
|
+
if (sections.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3784
3922
|
metadata.pageCount = sections.length;
|
|
3785
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3923
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _52 => _52.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3786
3924
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
3787
3925
|
const bodyBlocks = [];
|
|
3788
3926
|
const doc = createHwp5DocState();
|
|
@@ -3794,31 +3932,44 @@ function parseHwp5Document(buffer, options) {
|
|
|
3794
3932
|
const sectionData = sections[si];
|
|
3795
3933
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3796
3934
|
totalDecompressed += data.length;
|
|
3797
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3935
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3798
3936
|
const records = readRecords(data);
|
|
3799
3937
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3800
3938
|
bodyBlocks.push(...sectionBlocks);
|
|
3801
3939
|
parsedSections++;
|
|
3802
|
-
_optionalChain([options, 'optionalAccess',
|
|
3940
|
+
_optionalChain([options, 'optionalAccess', _53 => _53.onProgress, 'optionalCall', _54 => _54(parsedSections, totalTarget)]);
|
|
3803
3941
|
} catch (secErr) {
|
|
3804
|
-
if (secErr instanceof
|
|
3942
|
+
if (secErr instanceof _chunkR2H34FY5cjs.KordocError) throw secErr;
|
|
3805
3943
|
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
3944
|
}
|
|
3807
3945
|
}
|
|
3808
3946
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3809
3947
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3810
|
-
|
|
3948
|
+
let flatBlocks = _chunkR2H34FY5cjs.flattenLayoutTables.call(void 0, blocks);
|
|
3949
|
+
if (_optionalChain([options, 'optionalAccess', _55 => _55.dedupeRunningHeaders])) {
|
|
3950
|
+
const deduped = _chunkR2H34FY5cjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
3951
|
+
const removed = flatBlocks.length - deduped.length;
|
|
3952
|
+
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
3953
|
+
flatBlocks = deduped;
|
|
3954
|
+
}
|
|
3811
3955
|
if (docInfo) {
|
|
3812
3956
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3813
3957
|
}
|
|
3814
3958
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3815
|
-
|
|
3959
|
+
let markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3960
|
+
if (_optionalChain([options, 'optionalAccess', _56 => _56.inlineImages]) && images.length > 0) {
|
|
3961
|
+
try {
|
|
3962
|
+
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
3963
|
+
} catch (inlineErr) {
|
|
3964
|
+
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" });
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3816
3967
|
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
3968
|
}
|
|
3818
3969
|
function parseDocInfoStream(cfb, compressed) {
|
|
3819
3970
|
try {
|
|
3820
3971
|
const entry = CFB.find(cfb, "/DocInfo");
|
|
3821
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
3972
|
+
if (!_optionalChain([entry, 'optionalAccess', _57 => _57.content])) return null;
|
|
3822
3973
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
3823
3974
|
const records = readRecords(data);
|
|
3824
3975
|
return parseDocInfo(records);
|
|
@@ -3839,7 +3990,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3839
3990
|
let baseFontSize = 0;
|
|
3840
3991
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
3841
3992
|
for (const b of blocks) {
|
|
3842
|
-
if (_optionalChain([b, 'access',
|
|
3993
|
+
if (_optionalChain([b, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && b.text) {
|
|
3843
3994
|
sizeFreq.set(b.style.fontSize, (sizeFreq.get(b.style.fontSize) || 0) + b.text.length);
|
|
3844
3995
|
}
|
|
3845
3996
|
}
|
|
@@ -3855,7 +4006,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3855
4006
|
const name = (style.nameKo || style.name).toLowerCase();
|
|
3856
4007
|
if (name.includes("\uBC14\uD0D5") || name.includes("\uBCF8\uBB38") || name === "normal" || name === "body") {
|
|
3857
4008
|
const cs = docInfo.charShapes[style.charShapeId];
|
|
3858
|
-
if (_optionalChain([cs, 'optionalAccess',
|
|
4009
|
+
if (_optionalChain([cs, 'optionalAccess', _60 => _60.fontSize]) > 0) {
|
|
3859
4010
|
baseFontSize = cs.fontSize / 10;
|
|
3860
4011
|
break;
|
|
3861
4012
|
}
|
|
@@ -3870,11 +4021,11 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3870
4021
|
if (text.length === 0 || text.length > 200) continue;
|
|
3871
4022
|
if (/^\d+$/.test(text)) continue;
|
|
3872
4023
|
let level = 0;
|
|
3873
|
-
if (_optionalChain([block, 'access',
|
|
4024
|
+
if (_optionalChain([block, 'access', _61 => _61.style, 'optionalAccess', _62 => _62.fontSize]) && baseFontSize > 0) {
|
|
3874
4025
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3875
|
-
if (ratio >=
|
|
3876
|
-
else if (ratio >=
|
|
3877
|
-
else if (ratio >=
|
|
4026
|
+
if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H1) level = 1;
|
|
4027
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H2) level = 2;
|
|
4028
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H3) level = 3;
|
|
3878
4029
|
}
|
|
3879
4030
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3880
4031
|
if (level === 0) level = 2;
|
|
@@ -3890,7 +4041,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3890
4041
|
function extractHwp5Metadata(cfb, metadata) {
|
|
3891
4042
|
try {
|
|
3892
4043
|
const summaryEntry = CFB.find(cfb, "/HwpSummaryInformation") || CFB.find(cfb, "/SummaryInformation");
|
|
3893
|
-
if (!_optionalChain([summaryEntry, 'optionalAccess',
|
|
4044
|
+
if (!_optionalChain([summaryEntry, 'optionalAccess', _63 => _63.content])) return;
|
|
3894
4045
|
const data = Buffer.from(summaryEntry.content);
|
|
3895
4046
|
if (data.length < 48) return;
|
|
3896
4047
|
const numSets = data.readUInt32LE(24);
|
|
@@ -3923,7 +4074,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
3923
4074
|
const sections = [];
|
|
3924
4075
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
3925
4076
|
const entry = CFB.find(cfb, `/ViewText/Section${i}`);
|
|
3926
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4077
|
+
if (!_optionalChain([entry, 'optionalAccess', _64 => _64.content])) break;
|
|
3927
4078
|
try {
|
|
3928
4079
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
3929
4080
|
sections.push({ idx: i, content: decrypted });
|
|
@@ -3937,13 +4088,13 @@ function findSections(cfb) {
|
|
|
3937
4088
|
const sections = [];
|
|
3938
4089
|
for (let i = 0; i < MAX_SECTIONS; i++) {
|
|
3939
4090
|
const entry = CFB.find(cfb, `/BodyText/Section${i}`);
|
|
3940
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
4091
|
+
if (!_optionalChain([entry, 'optionalAccess', _65 => _65.content])) break;
|
|
3941
4092
|
sections.push({ idx: i, content: Buffer.from(entry.content) });
|
|
3942
4093
|
}
|
|
3943
4094
|
if (sections.length === 0 && cfb.FileIndex) {
|
|
3944
4095
|
for (const entry of cfb.FileIndex) {
|
|
3945
4096
|
if (sections.length >= MAX_SECTIONS) break;
|
|
3946
|
-
if (_optionalChain([entry, 'access',
|
|
4097
|
+
if (_optionalChain([entry, 'access', _66 => _66.name, 'optionalAccess', _67 => _67.startsWith, 'call', _68 => _68("Section")]) && entry.content) {
|
|
3947
4098
|
const idx = parseInt(entry.name.replace("Section", ""), 10) || 0;
|
|
3948
4099
|
sections.push({ idx, content: Buffer.from(entry.content) });
|
|
3949
4100
|
}
|
|
@@ -3959,7 +4110,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3959
4110
|
if (!raw) break;
|
|
3960
4111
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3961
4112
|
totalDecompressed += content.length;
|
|
3962
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4113
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3963
4114
|
sections.push({ idx: i, content });
|
|
3964
4115
|
}
|
|
3965
4116
|
if (sections.length === 0) {
|
|
@@ -3971,7 +4122,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3971
4122
|
if (raw) {
|
|
3972
4123
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3973
4124
|
totalDecompressed += content.length;
|
|
3974
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4125
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3975
4126
|
sections.push({ idx, content });
|
|
3976
4127
|
}
|
|
3977
4128
|
}
|
|
@@ -3988,7 +4139,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3988
4139
|
try {
|
|
3989
4140
|
const content = decryptViewText(raw, compressed);
|
|
3990
4141
|
totalDecompressed += content.length;
|
|
3991
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4142
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3992
4143
|
sections.push({ idx: i, content });
|
|
3993
4144
|
} catch (e26) {
|
|
3994
4145
|
break;
|
|
@@ -4089,9 +4240,9 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4089
4240
|
const applied = [];
|
|
4090
4241
|
for (const r of ranges) {
|
|
4091
4242
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4092
|
-
if (!_optionalChain([ctrl, 'optionalAccess',
|
|
4243
|
+
if (!_optionalChain([ctrl, 'optionalAccess', _69 => _69.href]) || r.end <= r.start) continue;
|
|
4093
4244
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4094
|
-
const href =
|
|
4245
|
+
const href = _chunkR2H34FY5cjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4095
4246
|
if (!href) continue;
|
|
4096
4247
|
const anchor = text.slice(r.start, r.end);
|
|
4097
4248
|
if (!anchor.trim()) continue;
|
|
@@ -4109,7 +4260,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4109
4260
|
}
|
|
4110
4261
|
if (ps.headType === 1 || ps.headType === 2) {
|
|
4111
4262
|
const nid = ps.numberingId || (ps.headType === 1 ? ctx.doc.outlineNumberingId : 0);
|
|
4112
|
-
const numbering = nid >= 1 ? _optionalChain([ctx, 'access',
|
|
4263
|
+
const numbering = nid >= 1 ? _optionalChain([ctx, 'access', _70 => _70.docInfo, 'optionalAccess', _71 => _71.numberings, 'access', _72 => _72[nid - 1]]) : void 0;
|
|
4113
4264
|
if (numbering) {
|
|
4114
4265
|
const counters = ctx.doc.numbering.advance(nid, ps.paraLevel);
|
|
4115
4266
|
const fmt = numbering.levelFormats[Math.min(ps.paraLevel, 6)];
|
|
@@ -4119,7 +4270,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4119
4270
|
}
|
|
4120
4271
|
}
|
|
4121
4272
|
} else if (ps.headType === 3) {
|
|
4122
|
-
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access',
|
|
4273
|
+
const bullet = ps.numberingId >= 1 ? _optionalChain([ctx, 'access', _73 => _73.docInfo, 'optionalAccess', _74 => _74.bullets, 'access', _75 => _75[ps.numberingId - 1]]) : void 0;
|
|
4123
4274
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
4124
4275
|
}
|
|
4125
4276
|
}
|
|
@@ -4178,11 +4329,11 @@ function applyCtrlEffect(ctrl, records, ctx) {
|
|
|
4178
4329
|
const attr = ctrl.data.readUInt32LE(4);
|
|
4179
4330
|
const type = attr & 15;
|
|
4180
4331
|
const format = attr >>> 4 & 255;
|
|
4181
|
-
const
|
|
4182
|
-
ctx.doc.autoCounters.set(type,
|
|
4332
|
+
const num4 = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
|
|
4333
|
+
ctx.doc.autoCounters.set(type, num4 + 1);
|
|
4183
4334
|
const prefix = ctrl.data.length >= 14 ? wcharAt(ctrl.data, 12) : "";
|
|
4184
4335
|
const suffix = ctrl.data.length >= 16 ? wcharAt(ctrl.data, 14) : "";
|
|
4185
|
-
ctrl.inlineText = `${prefix}${formatNumber(
|
|
4336
|
+
ctrl.inlineText = `${prefix}${formatNumber(num4, shapeFormatToNumFmt(format))}${suffix}`;
|
|
4186
4337
|
}
|
|
4187
4338
|
return;
|
|
4188
4339
|
}
|
|
@@ -4190,8 +4341,8 @@ function applyCtrlEffect(ctrl, records, ctx) {
|
|
|
4190
4341
|
if (ctrl.data.length >= 10) {
|
|
4191
4342
|
const attr = ctrl.data.readUInt32LE(4);
|
|
4192
4343
|
const type = attr & 15;
|
|
4193
|
-
const
|
|
4194
|
-
if (
|
|
4344
|
+
const num4 = ctrl.data.readUInt16LE(8);
|
|
4345
|
+
if (num4 > 0) ctx.doc.autoCounters.set(type, num4);
|
|
4195
4346
|
}
|
|
4196
4347
|
return;
|
|
4197
4348
|
}
|
|
@@ -4253,7 +4404,7 @@ function blocksPlainText(blocks, sep) {
|
|
|
4253
4404
|
return parts.join(sep).trim();
|
|
4254
4405
|
}
|
|
4255
4406
|
function applyNoteEffect(ctrl, records, ctx, autoType) {
|
|
4256
|
-
const
|
|
4407
|
+
const num4 = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
|
|
4257
4408
|
let before = "";
|
|
4258
4409
|
let after = "";
|
|
4259
4410
|
let shape = 0;
|
|
@@ -4264,11 +4415,11 @@ function applyNoteEffect(ctrl, records, ctx, autoType) {
|
|
|
4264
4415
|
if (ctrl.data.length >= 16) {
|
|
4265
4416
|
shape = ctrl.data.readUInt32LE(12) & 255;
|
|
4266
4417
|
}
|
|
4267
|
-
const formatted = formatNumber(
|
|
4418
|
+
const formatted = formatNumber(num4, shapeFormatToNumFmt(shape));
|
|
4268
4419
|
const marker = before || after ? `${before}${formatted}${after}` : `${formatted})`;
|
|
4269
4420
|
const content = blocksPlainText(parseListHeaderParagraphs(ctrl, records, ctx), " ");
|
|
4270
|
-
if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <=
|
|
4271
|
-
ctx.doc.autoCounters.set(autoType,
|
|
4421
|
+
if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num4) {
|
|
4422
|
+
ctx.doc.autoCounters.set(autoType, num4 + 1);
|
|
4272
4423
|
}
|
|
4273
4424
|
ctrl.inlineText = marker;
|
|
4274
4425
|
if (content) ctrl.footnote = content.startsWith(marker) ? content : `${marker} ${content}`;
|
|
@@ -4324,8 +4475,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4324
4475
|
let tableIdx = -1;
|
|
4325
4476
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4326
4477
|
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),
|
|
4478
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkR2H34FY5cjs.MAX_ROWS);
|
|
4479
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkR2H34FY5cjs.MAX_COLS);
|
|
4329
4480
|
tableIdx = i2;
|
|
4330
4481
|
break;
|
|
4331
4482
|
}
|
|
@@ -4365,7 +4516,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4365
4516
|
const cellRows2 = arrangeCells(rows, cols, cells);
|
|
4366
4517
|
const irCells = cellRows2.map((row) => row.map((c) => {
|
|
4367
4518
|
const ir = { text: c.text.trim(), colSpan: c.colSpan, rowSpan: c.rowSpan };
|
|
4368
|
-
if (_optionalChain([c, 'access',
|
|
4519
|
+
if (_optionalChain([c, 'access', _76 => _76.blocks, 'optionalAccess', _77 => _77.length])) ir.blocks = c.blocks;
|
|
4369
4520
|
if (c.isHeader) ir.isHeader = true;
|
|
4370
4521
|
return ir;
|
|
4371
4522
|
}));
|
|
@@ -4374,7 +4525,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4374
4525
|
return table2;
|
|
4375
4526
|
}
|
|
4376
4527
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4377
|
-
const table =
|
|
4528
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
4378
4529
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4379
4530
|
return table.rows > 0 ? table : null;
|
|
4380
4531
|
}
|
|
@@ -4391,8 +4542,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4391
4542
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4392
4543
|
const cs = rec.data.readUInt16LE(12);
|
|
4393
4544
|
const rs = rec.data.readUInt16LE(14);
|
|
4394
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4395
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4545
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkR2H34FY5cjs.MAX_COLS);
|
|
4546
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkR2H34FY5cjs.MAX_ROWS);
|
|
4396
4547
|
}
|
|
4397
4548
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4398
4549
|
const parts = [];
|
|
@@ -4402,7 +4553,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4402
4553
|
parts.push(``);
|
|
4403
4554
|
hasStructure = true;
|
|
4404
4555
|
} else if (b.type === "table" && b.table) {
|
|
4405
|
-
const flat =
|
|
4556
|
+
const flat = _chunkR2H34FY5cjs.convertTableToText.call(void 0, b.table.cells);
|
|
4406
4557
|
if (flat) parts.push(flat);
|
|
4407
4558
|
hasStructure = true;
|
|
4408
4559
|
} else if (b.text) {
|
|
@@ -4499,8 +4650,8 @@ function pictureToImageBlock(data, ctx) {
|
|
|
4499
4650
|
if (data.length < 73) return null;
|
|
4500
4651
|
const binDataId = data.readUInt16LE(71);
|
|
4501
4652
|
if (binDataId === 0) return null;
|
|
4502
|
-
const item = _optionalChain([ctx, 'access',
|
|
4503
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
4653
|
+
const item = _optionalChain([ctx, 'access', _78 => _78.docInfo, 'optionalAccess', _79 => _79.binData, 'access', _80 => _80[binDataId - 1]]);
|
|
4654
|
+
if (_optionalChain([item, 'optionalAccess', _81 => _81.kind]) === "link") {
|
|
4504
4655
|
ctx.warnings.push({ page: ctx.sectionNum, message: `\uC678\uBD80 \uC5F0\uACB0 \uC774\uBBF8\uC9C0 (binDataId ${binDataId})`, code: "SKIPPED_IMAGE" });
|
|
4505
4656
|
return null;
|
|
4506
4657
|
}
|
|
@@ -16806,9 +16957,9 @@ var MAX_ROWS2 = 1e4;
|
|
|
16806
16957
|
var MAX_COLS2 = 200;
|
|
16807
16958
|
function cleanNumericValue(raw) {
|
|
16808
16959
|
if (!/^-?\d+\.\d+$/.test(raw)) return raw;
|
|
16809
|
-
const
|
|
16810
|
-
if (!isFinite(
|
|
16811
|
-
const cleaned = parseFloat(
|
|
16960
|
+
const num4 = parseFloat(raw);
|
|
16961
|
+
if (!isFinite(num4)) return raw;
|
|
16962
|
+
const cleaned = parseFloat(num4.toPrecision(15)).toString();
|
|
16812
16963
|
return cleaned;
|
|
16813
16964
|
}
|
|
16814
16965
|
function parseCellRef(ref) {
|
|
@@ -16831,15 +16982,15 @@ function getElements(parent, tagName) {
|
|
|
16831
16982
|
const result = [];
|
|
16832
16983
|
for (let i = 0; i < nodes.length; i++) result.push(nodes[i]);
|
|
16833
16984
|
if (result.length > 0) return result;
|
|
16834
|
-
const nsNodes = _optionalChain([parent, 'access',
|
|
16985
|
+
const nsNodes = _optionalChain([parent, 'access', _82 => _82.getElementsByTagNameNS, 'optionalCall', _83 => _83("*", tagName)]);
|
|
16835
16986
|
if (nsNodes) for (let i = 0; i < nsNodes.length; i++) result.push(nsNodes[i]);
|
|
16836
16987
|
return result;
|
|
16837
16988
|
}
|
|
16838
16989
|
function getTextContent(el) {
|
|
16839
|
-
return _nullishCoalesce(_optionalChain([el, 'access',
|
|
16990
|
+
return _nullishCoalesce(_optionalChain([el, 'access', _84 => _84.textContent, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()]), () => ( ""));
|
|
16840
16991
|
}
|
|
16841
16992
|
function parseXml(text) {
|
|
16842
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16993
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
16843
16994
|
}
|
|
16844
16995
|
function parseSharedStrings(xml) {
|
|
16845
16996
|
const doc = parseXml(xml);
|
|
@@ -16976,14 +17127,14 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16976
17127
|
const merge = mergeMap.get(key);
|
|
16977
17128
|
row.push({
|
|
16978
17129
|
text,
|
|
16979
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
16980
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17130
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _87 => _87.colSpan]), () => ( 1)),
|
|
17131
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _88 => _88.rowSpan]), () => ( 1))
|
|
16981
17132
|
});
|
|
16982
17133
|
}
|
|
16983
17134
|
cellRows.push(row);
|
|
16984
17135
|
}
|
|
16985
17136
|
if (cellRows.length > 0) {
|
|
16986
|
-
const table =
|
|
17137
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
16987
17138
|
if (table.rows > 0) {
|
|
16988
17139
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16989
17140
|
}
|
|
@@ -16991,12 +17142,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16991
17142
|
return blocks;
|
|
16992
17143
|
}
|
|
16993
17144
|
async function parseXlsxDocument(buffer, options) {
|
|
16994
|
-
|
|
17145
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16995
17146
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16996
17147
|
const warnings = [];
|
|
16997
17148
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16998
17149
|
if (!workbookFile) {
|
|
16999
|
-
throw new (0,
|
|
17150
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17000
17151
|
}
|
|
17001
17152
|
let sharedStrings = [];
|
|
17002
17153
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17005,7 +17156,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17005
17156
|
}
|
|
17006
17157
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
17007
17158
|
if (sheets.length === 0) {
|
|
17008
|
-
throw new (0,
|
|
17159
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17009
17160
|
}
|
|
17010
17161
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17011
17162
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17013,7 +17164,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17013
17164
|
relsMap = parseRels(await relsFile.async("text"));
|
|
17014
17165
|
}
|
|
17015
17166
|
let pageFilter = null;
|
|
17016
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17167
|
+
if (_optionalChain([options, 'optionalAccess', _89 => _89.pages])) {
|
|
17017
17168
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17018
17169
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
17019
17170
|
}
|
|
@@ -17022,7 +17173,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17022
17173
|
for (let i = 0; i < processedSheets; i++) {
|
|
17023
17174
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17024
17175
|
const sheet = sheets[i];
|
|
17025
|
-
_optionalChain([options, 'optionalAccess',
|
|
17176
|
+
_optionalChain([options, 'optionalAccess', _90 => _90.onProgress, 'optionalCall', _91 => _91(i + 1, processedSheets)]);
|
|
17026
17177
|
let sheetPath = relsMap.get(sheet.rId);
|
|
17027
17178
|
if (sheetPath) {
|
|
17028
17179
|
if (!sheetPath.startsWith("xl/") && !sheetPath.startsWith("/")) {
|
|
@@ -17077,7 +17228,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17077
17228
|
} catch (e27) {
|
|
17078
17229
|
}
|
|
17079
17230
|
}
|
|
17080
|
-
const markdown =
|
|
17231
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
17081
17232
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17082
17233
|
}
|
|
17083
17234
|
|
|
@@ -17151,17 +17302,17 @@ function decodeRk(rk) {
|
|
|
17151
17302
|
const fDiv100 = (rk & 1) !== 0;
|
|
17152
17303
|
const fInt = (rk & 2) !== 0;
|
|
17153
17304
|
const val30 = rk >> 2;
|
|
17154
|
-
let
|
|
17305
|
+
let num4;
|
|
17155
17306
|
if (fInt) {
|
|
17156
|
-
|
|
17307
|
+
num4 = val30;
|
|
17157
17308
|
} else {
|
|
17158
17309
|
const high32 = (rk & 4294967292) >>> 0;
|
|
17159
17310
|
const buf = Buffer.alloc(8);
|
|
17160
17311
|
buf.writeUInt32LE(0, 0);
|
|
17161
17312
|
buf.writeUInt32LE(high32, 4);
|
|
17162
|
-
|
|
17313
|
+
num4 = buf.readDoubleLE(0);
|
|
17163
17314
|
}
|
|
17164
|
-
return fDiv100 ?
|
|
17315
|
+
return fDiv100 ? num4 / 100 : num4;
|
|
17165
17316
|
}
|
|
17166
17317
|
function decodeMulRk(data) {
|
|
17167
17318
|
if (data.length < 6) return null;
|
|
@@ -17484,11 +17635,11 @@ function processGlobals(records) {
|
|
|
17484
17635
|
let encrypted = false;
|
|
17485
17636
|
const firstBof = records[0];
|
|
17486
17637
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17487
|
-
throw new (0,
|
|
17638
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17488
17639
|
}
|
|
17489
17640
|
const bof = decodeBof(firstBof.data);
|
|
17490
17641
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17491
|
-
throw new (0,
|
|
17642
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17492
17643
|
}
|
|
17493
17644
|
let i = 1;
|
|
17494
17645
|
while (i < records.length) {
|
|
@@ -17596,14 +17747,14 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17596
17747
|
const merge = mergeMap.get(key);
|
|
17597
17748
|
row.push({
|
|
17598
17749
|
text: grid[r][c],
|
|
17599
|
-
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17600
|
-
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess',
|
|
17750
|
+
colSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _92 => _92.colSpan]), () => ( 1)),
|
|
17751
|
+
rowSpan: _nullishCoalesce(_optionalChain([merge, 'optionalAccess', _93 => _93.rowSpan]), () => ( 1))
|
|
17601
17752
|
});
|
|
17602
17753
|
}
|
|
17603
17754
|
cellRows.push(row);
|
|
17604
17755
|
}
|
|
17605
17756
|
if (cellRows.length > 0) {
|
|
17606
|
-
const table =
|
|
17757
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
17607
17758
|
if (table.rows > 0) {
|
|
17608
17759
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17609
17760
|
}
|
|
@@ -17616,21 +17767,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17616
17767
|
try {
|
|
17617
17768
|
cfb = parseLenientCfb(buf);
|
|
17618
17769
|
} catch (e) {
|
|
17619
|
-
throw new (0,
|
|
17770
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
17620
17771
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17621
17772
|
);
|
|
17622
17773
|
}
|
|
17623
17774
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17624
17775
|
if (!wb) {
|
|
17625
|
-
throw new (0,
|
|
17776
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17626
17777
|
}
|
|
17627
17778
|
const records = readRecords2(wb);
|
|
17628
17779
|
if (records.length === 0) {
|
|
17629
|
-
throw new (0,
|
|
17780
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17630
17781
|
}
|
|
17631
17782
|
const firstBof = decodeBof(records[0].data);
|
|
17632
17783
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17633
|
-
throw new (0,
|
|
17784
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
17634
17785
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17635
17786
|
);
|
|
17636
17787
|
}
|
|
@@ -17651,7 +17802,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17651
17802
|
}
|
|
17652
17803
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17653
17804
|
let pageFilter = null;
|
|
17654
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
17805
|
+
if (_optionalChain([options, 'optionalAccess', _94 => _94.pages])) {
|
|
17655
17806
|
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17656
17807
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17657
17808
|
}
|
|
@@ -17660,7 +17811,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17660
17811
|
if (pageFilter && !pageFilter.has(i + 1)) continue;
|
|
17661
17812
|
const meta = globals.sheets[i];
|
|
17662
17813
|
if (meta.dt !== 0) continue;
|
|
17663
|
-
_optionalChain([options, 'optionalAccess',
|
|
17814
|
+
_optionalChain([options, 'optionalAccess', _95 => _95.onProgress, 'optionalCall', _96 => _96(i + 1, totalSheets)]);
|
|
17664
17815
|
const bofIdx = findSheetBofIndex(records, meta.lbPlyPos);
|
|
17665
17816
|
if (bofIdx < 0) {
|
|
17666
17817
|
warnings.push({
|
|
@@ -17690,7 +17841,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17690
17841
|
pageCount: totalSheets
|
|
17691
17842
|
};
|
|
17692
17843
|
return {
|
|
17693
|
-
markdown:
|
|
17844
|
+
markdown: _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17694
17845
|
blocks: allBlocks,
|
|
17695
17846
|
metadata,
|
|
17696
17847
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -17703,7 +17854,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17703
17854
|
|
|
17704
17855
|
// src/docx/equation.ts
|
|
17705
17856
|
function lname(el) {
|
|
17706
|
-
return el.localName || _optionalChain([el, 'access',
|
|
17857
|
+
return el.localName || _optionalChain([el, 'access', _97 => _97.tagName, 'optionalAccess', _98 => _98.replace, 'call', _99 => _99(/^[^:]+:/, "")]) || "";
|
|
17707
17858
|
}
|
|
17708
17859
|
function kids(parent, name) {
|
|
17709
17860
|
const out = [];
|
|
@@ -17861,9 +18012,9 @@ function nodeToLatex(el) {
|
|
|
17861
18012
|
case "f": {
|
|
17862
18013
|
const n = firstKid(el, "num");
|
|
17863
18014
|
const d = firstKid(el, "den");
|
|
17864
|
-
const
|
|
18015
|
+
const num4 = n ? childrenToLatex(n) : "";
|
|
17865
18016
|
const den = d ? childrenToLatex(d) : "";
|
|
17866
|
-
return "\\frac" + grp(
|
|
18017
|
+
return "\\frac" + grp(num4) + grp(den);
|
|
17867
18018
|
}
|
|
17868
18019
|
// 첨자
|
|
17869
18020
|
case "sSup": {
|
|
@@ -18076,7 +18227,7 @@ function isDisplayMath(el) {
|
|
|
18076
18227
|
// src/docx/parser.ts
|
|
18077
18228
|
var MAX_DECOMPRESS_SIZE4 = 100 * 1024 * 1024;
|
|
18078
18229
|
function matchesLocal(el, localName2) {
|
|
18079
|
-
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access',
|
|
18230
|
+
return el.localName === localName2 || (_nullishCoalesce(_optionalChain([el, 'access', _100 => _100.tagName, 'optionalAccess', _101 => _101.endsWith, 'call', _102 => _102(`:${localName2}`)]), () => ( false)));
|
|
18080
18231
|
}
|
|
18081
18232
|
function effectiveChildElements(parent) {
|
|
18082
18233
|
const result = [];
|
|
@@ -18109,7 +18260,7 @@ function findElements(parent, localName2) {
|
|
|
18109
18260
|
const child = children[i];
|
|
18110
18261
|
if (child.nodeType === 1) {
|
|
18111
18262
|
const el = child;
|
|
18112
|
-
if (el.localName === localName2 || _optionalChain([el, 'access',
|
|
18263
|
+
if (el.localName === localName2 || _optionalChain([el, 'access', _103 => _103.tagName, 'optionalAccess', _104 => _104.endsWith, 'call', _105 => _105(`:${localName2}`)])) {
|
|
18113
18264
|
result.push(el);
|
|
18114
18265
|
}
|
|
18115
18266
|
walk(el);
|
|
@@ -18128,7 +18279,7 @@ function getAttr(el, localName2) {
|
|
|
18128
18279
|
return null;
|
|
18129
18280
|
}
|
|
18130
18281
|
function parseXml2(text) {
|
|
18131
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18282
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
18132
18283
|
}
|
|
18133
18284
|
function parseStyles(xml) {
|
|
18134
18285
|
const doc = parseXml2(xml);
|
|
@@ -18230,7 +18381,7 @@ function collectOmmlRoots(p) {
|
|
|
18230
18381
|
const child = children[i];
|
|
18231
18382
|
if (child.nodeType !== 1) continue;
|
|
18232
18383
|
const el = child;
|
|
18233
|
-
const tag = el.localName || _optionalChain([el, 'access',
|
|
18384
|
+
const tag = el.localName || _optionalChain([el, 'access', _106 => _106.tagName, 'optionalAccess', _107 => _107.replace, 'call', _108 => _108(/^[^:]+:/, "")]) || "";
|
|
18234
18385
|
if (tag === "oMath" || tag === "oMathPara") {
|
|
18235
18386
|
out.push(el);
|
|
18236
18387
|
} else if (tag === "txbxContent" || tag === "Fallback") {
|
|
@@ -18320,7 +18471,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18320
18471
|
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18321
18472
|
if (!text) return null;
|
|
18322
18473
|
const style = styles.get(styleId);
|
|
18323
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
18474
|
+
if (_optionalChain([style, 'optionalAccess', _109 => _109.outlineLevel]) !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
18324
18475
|
return {
|
|
18325
18476
|
type: "heading",
|
|
18326
18477
|
text,
|
|
@@ -18329,8 +18480,8 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18329
18480
|
}
|
|
18330
18481
|
if (numId && numId !== "0") {
|
|
18331
18482
|
const numDef = numbering.get(numId);
|
|
18332
|
-
const levelInfo = _optionalChain([numDef, 'optionalAccess',
|
|
18333
|
-
const listType = _optionalChain([levelInfo, 'optionalAccess',
|
|
18483
|
+
const levelInfo = _optionalChain([numDef, 'optionalAccess', _110 => _110.get, 'call', _111 => _111(ilvl)]);
|
|
18484
|
+
const listType = _optionalChain([levelInfo, 'optionalAccess', _112 => _112.numFmt]) === "bullet" ? "unordered" : "ordered";
|
|
18334
18485
|
return { type: "list", text, listType };
|
|
18335
18486
|
}
|
|
18336
18487
|
const block = { type: "paragraph", text };
|
|
@@ -18413,7 +18564,7 @@ ${cell.text}` : cell.text;
|
|
|
18413
18564
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18414
18565
|
})
|
|
18415
18566
|
);
|
|
18416
|
-
const table =
|
|
18567
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
18417
18568
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18418
18569
|
return { type: "table", table };
|
|
18419
18570
|
}
|
|
@@ -18423,10 +18574,10 @@ function collectCellText(tc, styles, numbering, footnotes, rels, depth) {
|
|
|
18423
18574
|
for (const el of effectiveChildElements(tc)) {
|
|
18424
18575
|
if (matchesLocal(el, "p")) {
|
|
18425
18576
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18426
|
-
if (_optionalChain([block, 'optionalAccess',
|
|
18577
|
+
if (_optionalChain([block, 'optionalAccess', _113 => _113.text])) parts.push(block.text);
|
|
18427
18578
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
18428
18579
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
18429
|
-
if (_optionalChain([tb, 'optionalAccess',
|
|
18580
|
+
if (_optionalChain([tb, 'optionalAccess', _114 => _114.text])) parts.push(tb.text);
|
|
18430
18581
|
}
|
|
18431
18582
|
} else if (matchesLocal(el, "tbl")) {
|
|
18432
18583
|
for (const tr of getChildElements(el, "tr")) {
|
|
@@ -18456,7 +18607,7 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18456
18607
|
try {
|
|
18457
18608
|
const data = await imgFile.async("uint8array");
|
|
18458
18609
|
imgIdx++;
|
|
18459
|
-
const ext = _nullishCoalesce(_optionalChain([imgPath, 'access',
|
|
18610
|
+
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
18611
|
const mimeMap = {
|
|
18461
18612
|
png: "image/png",
|
|
18462
18613
|
jpg: "image/jpeg",
|
|
@@ -18480,12 +18631,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18480
18631
|
return { blocks, images };
|
|
18481
18632
|
}
|
|
18482
18633
|
async function parseDocxDocument(buffer, options) {
|
|
18483
|
-
|
|
18634
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18484
18635
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18485
18636
|
const warnings = [];
|
|
18486
18637
|
const docFile = zip.file("word/document.xml");
|
|
18487
18638
|
if (!docFile) {
|
|
18488
|
-
throw new (0,
|
|
18639
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18489
18640
|
}
|
|
18490
18641
|
let rels = /* @__PURE__ */ new Map();
|
|
18491
18642
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18532,13 +18683,13 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18532
18683
|
const doc = parseXml2(docXml);
|
|
18533
18684
|
const body = findElements(doc, "body");
|
|
18534
18685
|
if (body.length === 0) {
|
|
18535
|
-
throw new (0,
|
|
18686
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18536
18687
|
}
|
|
18537
18688
|
const blocks = [];
|
|
18538
18689
|
const bodyEl = body[0];
|
|
18539
18690
|
const topLevel = effectiveChildElements(bodyEl);
|
|
18540
18691
|
for (const el of topLevel) {
|
|
18541
|
-
const localName2 = _nullishCoalesce(el.localName, () => ( _optionalChain([el, 'access',
|
|
18692
|
+
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
18693
|
if (localName2 === "p") {
|
|
18543
18694
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
18544
18695
|
if (block) blocks.push(block);
|
|
@@ -18577,7 +18728,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18577
18728
|
}
|
|
18578
18729
|
}
|
|
18579
18730
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18580
|
-
const markdown =
|
|
18731
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18581
18732
|
return {
|
|
18582
18733
|
markdown,
|
|
18583
18734
|
blocks,
|
|
@@ -18600,7 +18751,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18600
18751
|
}
|
|
18601
18752
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18602
18753
|
const normalized = text.replace(/ /g, " ");
|
|
18603
|
-
const xml =
|
|
18754
|
+
const xml = _chunkR2H34FY5cjs.stripDtd.call(void 0, normalized);
|
|
18604
18755
|
const warnings = [];
|
|
18605
18756
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18606
18757
|
onError: (_level, msg2) => {
|
|
@@ -18628,7 +18779,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18628
18779
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18629
18780
|
}
|
|
18630
18781
|
const blocks = [];
|
|
18631
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
18782
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _126 => _126.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18632
18783
|
let sectionIdx = 0;
|
|
18633
18784
|
const children = body.childNodes;
|
|
18634
18785
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18640,7 +18791,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18640
18791
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18641
18792
|
}
|
|
18642
18793
|
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 =
|
|
18794
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18644
18795
|
return {
|
|
18645
18796
|
markdown,
|
|
18646
18797
|
blocks,
|
|
@@ -18726,7 +18877,7 @@ function parseParagraph3(el, blocks, paraShapeMap, sectionNum) {
|
|
|
18726
18877
|
const shapeInfo = paraShapeMap.get(paraShapeId);
|
|
18727
18878
|
const text = extractParagraphText(el);
|
|
18728
18879
|
if (!text) return;
|
|
18729
|
-
if (_optionalChain([shapeInfo, 'optionalAccess',
|
|
18880
|
+
if (_optionalChain([shapeInfo, 'optionalAccess', _127 => _127.headingLevel]) != null) {
|
|
18730
18881
|
blocks.push({ type: "heading", text, level: shapeInfo.headingLevel, pageNumber: sectionNum });
|
|
18731
18882
|
} else {
|
|
18732
18883
|
blocks.push({ type: "paragraph", text, pageNumber: sectionNum });
|
|
@@ -18798,7 +18949,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18798
18949
|
const cellRows = grid.map(
|
|
18799
18950
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18800
18951
|
);
|
|
18801
|
-
const table =
|
|
18952
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
18802
18953
|
const caption = extractShapeCaption(el);
|
|
18803
18954
|
if (caption.text && caption.before) {
|
|
18804
18955
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -19058,7 +19209,7 @@ function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
|
19058
19209
|
(match, prefix, suffix) => {
|
|
19059
19210
|
const label = prefix + suffix;
|
|
19060
19211
|
const normalizedLabel = normalizeLabel(label);
|
|
19061
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19212
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _128 => _128.has, 'call', _129 => _129(normalizedLabel)])) return match;
|
|
19062
19213
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
19063
19214
|
if (matchKey === void 0) return match;
|
|
19064
19215
|
const newValue = values.consume(matchKey);
|
|
@@ -19308,8 +19459,8 @@ function extractFromTable(table) {
|
|
|
19308
19459
|
if (table.cols >= 2) {
|
|
19309
19460
|
for (let r = 0; r < table.rows; r++) {
|
|
19310
19461
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
19311
|
-
const labelCell = _optionalChain([table, 'access',
|
|
19312
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19462
|
+
const labelCell = _optionalChain([table, 'access', _130 => _130.cells, 'access', _131 => _131[r], 'optionalAccess', _132 => _132[c]]);
|
|
19463
|
+
const valueCell = _optionalChain([table, 'access', _133 => _133.cells, 'access', _134 => _134[r], 'optionalAccess', _135 => _135[c + 1]]);
|
|
19313
19464
|
if (!labelCell || !valueCell) continue;
|
|
19314
19465
|
if (isLabelCell(labelCell.text)) {
|
|
19315
19466
|
fields.push({
|
|
@@ -19331,8 +19482,8 @@ function extractFromTable(table) {
|
|
|
19331
19482
|
if (allLabels) {
|
|
19332
19483
|
for (let r = 1; r < table.rows; r++) {
|
|
19333
19484
|
for (let c = 0; c < table.cols; c++) {
|
|
19334
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19335
|
-
const value = _nullishCoalesce(_optionalChain([table, 'access',
|
|
19485
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _136 => _136[c], 'optionalAccess', _137 => _137.text, 'access', _138 => _138.trim, 'call', _139 => _139()]), () => ( ""));
|
|
19486
|
+
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
19487
|
if (label && value) {
|
|
19337
19488
|
fields.push({ label, value, row: r, col: c });
|
|
19338
19489
|
}
|
|
@@ -19425,7 +19576,7 @@ function fillFormFields(blocks, values, blockedLabels) {
|
|
|
19425
19576
|
for (const table of allTables) {
|
|
19426
19577
|
for (let r = 0; r < table.rows; r++) {
|
|
19427
19578
|
for (let c = 0; c < table.cols; c++) {
|
|
19428
|
-
const cell = _optionalChain([table, 'access',
|
|
19579
|
+
const cell = _optionalChain([table, 'access', _146 => _146.cells, 'access', _147 => _147[r], 'optionalAccess', _148 => _148[c]]);
|
|
19429
19580
|
if (!cell) continue;
|
|
19430
19581
|
const result = fillInCellPatterns(cell.text, cursor, matchedLabels, blockedLabels);
|
|
19431
19582
|
if (result) {
|
|
@@ -19457,7 +19608,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19457
19608
|
out.push(block.table);
|
|
19458
19609
|
for (const row of block.table.cells) {
|
|
19459
19610
|
for (const cell of row) {
|
|
19460
|
-
if (_optionalChain([cell, 'optionalAccess',
|
|
19611
|
+
if (_optionalChain([cell, 'optionalAccess', _149 => _149.blocks, 'optionalAccess', _150 => _150.length])) out.push(...collectIRTables(cell.blocks, depth + 1));
|
|
19461
19612
|
}
|
|
19462
19613
|
}
|
|
19463
19614
|
}
|
|
@@ -19468,7 +19619,7 @@ function coveredPositions(table) {
|
|
|
19468
19619
|
for (let r = 0; r < table.rows; r++) {
|
|
19469
19620
|
for (let c = 0; c < table.cols; c++) {
|
|
19470
19621
|
if (covered.has(`${r},${c}`)) continue;
|
|
19471
|
-
const cell = _optionalChain([table, 'access',
|
|
19622
|
+
const cell = _optionalChain([table, 'access', _151 => _151.cells, 'access', _152 => _152[r], 'optionalAccess', _153 => _153[c]]);
|
|
19472
19623
|
if (!cell) continue;
|
|
19473
19624
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
19474
19625
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -19498,12 +19649,12 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells, blo
|
|
|
19498
19649
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
19499
19650
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
19500
19651
|
if (!normalizedCellLabel) continue;
|
|
19501
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19652
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _154 => _154.has, 'call', _155 => _155(normalizedCellLabel)])) continue;
|
|
19502
19653
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
19503
19654
|
if (matchKey === void 0) continue;
|
|
19504
19655
|
const newValue = values.consume(matchKey);
|
|
19505
19656
|
if (newValue === void 0) continue;
|
|
19506
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19657
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _156 => _156.has, 'call', _157 => _157(valueCell)])) {
|
|
19507
19658
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19508
19659
|
} else {
|
|
19509
19660
|
valueCell.text = newValue;
|
|
@@ -19529,10 +19680,10 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells, blo
|
|
|
19529
19680
|
for (let c = 0; c < table.cols; c++) {
|
|
19530
19681
|
if (covered.has(`${r},${c}`)) continue;
|
|
19531
19682
|
const headerCell = headerRow[c];
|
|
19532
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19683
|
+
const valueCell = _optionalChain([table, 'access', _158 => _158.cells, 'access', _159 => _159[r], 'optionalAccess', _160 => _160[c]]);
|
|
19533
19684
|
if (!headerCell || !valueCell) continue;
|
|
19534
19685
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19535
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19686
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _161 => _161.has, 'call', _162 => _162(headerLabel)])) continue;
|
|
19536
19687
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
19537
19688
|
if (matchKey === void 0) continue;
|
|
19538
19689
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -19558,7 +19709,7 @@ function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
|
19558
19709
|
let pos = 0;
|
|
19559
19710
|
for (const seg of segments) {
|
|
19560
19711
|
const nlabel = normalizeLabel(seg.label);
|
|
19561
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
19712
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _163 => _163.has, 'call', _164 => _164(nlabel)])) continue;
|
|
19562
19713
|
const matchKey = findMatchingKey(nlabel, values);
|
|
19563
19714
|
if (matchKey === void 0) continue;
|
|
19564
19715
|
const newValue = values.consume(matchKey);
|
|
@@ -20126,19 +20277,19 @@ function parseCentralDirectory(buf) {
|
|
|
20126
20277
|
}
|
|
20127
20278
|
}
|
|
20128
20279
|
}
|
|
20129
|
-
if (eocdOffset < 0) throw new (0,
|
|
20280
|
+
if (eocdOffset < 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20130
20281
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20131
20282
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20132
20283
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20133
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20284
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20134
20285
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20135
|
-
throw new (0,
|
|
20286
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20136
20287
|
}
|
|
20137
20288
|
const decoder = new TextDecoder("utf-8");
|
|
20138
20289
|
const entries = [];
|
|
20139
20290
|
let pos = cdOffset;
|
|
20140
20291
|
for (let i = 0; i < totalEntries; i++) {
|
|
20141
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20292
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20142
20293
|
const flags = view.getUint16(pos + 8, true);
|
|
20143
20294
|
const method = view.getUint16(pos + 10, true);
|
|
20144
20295
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20149,7 +20300,7 @@ function parseCentralDirectory(buf) {
|
|
|
20149
20300
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20150
20301
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20151
20302
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20152
|
-
throw new (0,
|
|
20303
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20153
20304
|
}
|
|
20154
20305
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20155
20306
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20158,7 +20309,7 @@ function parseCentralDirectory(buf) {
|
|
|
20158
20309
|
}
|
|
20159
20310
|
return { entries, cdOffset, cdSize, eocdOffset };
|
|
20160
20311
|
}
|
|
20161
|
-
var
|
|
20312
|
+
var CRC_TABLE2 = (() => {
|
|
20162
20313
|
const table = new Uint32Array(256);
|
|
20163
20314
|
for (let n = 0; n < 256; n++) {
|
|
20164
20315
|
let c = n;
|
|
@@ -20167,10 +20318,10 @@ var CRC_TABLE = (() => {
|
|
|
20167
20318
|
}
|
|
20168
20319
|
return table;
|
|
20169
20320
|
})();
|
|
20170
|
-
function
|
|
20321
|
+
function crc322(data) {
|
|
20171
20322
|
let crc = 4294967295;
|
|
20172
20323
|
for (let i = 0; i < data.length; i++) {
|
|
20173
|
-
crc =
|
|
20324
|
+
crc = CRC_TABLE2[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
20174
20325
|
}
|
|
20175
20326
|
return (crc ^ 4294967295) >>> 0;
|
|
20176
20327
|
}
|
|
@@ -20178,11 +20329,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20178
20329
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20179
20330
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20180
20331
|
for (const name of replacements.keys()) {
|
|
20181
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20332
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkR2H34FY5cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20182
20333
|
}
|
|
20183
20334
|
if (additions) {
|
|
20184
20335
|
for (const name of additions.keys()) {
|
|
20185
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20336
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkR2H34FY5cjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20186
20337
|
}
|
|
20187
20338
|
}
|
|
20188
20339
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20201,7 +20352,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20201
20352
|
offset += seg.length;
|
|
20202
20353
|
continue;
|
|
20203
20354
|
}
|
|
20204
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20355
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20205
20356
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20206
20357
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20207
20358
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20209,7 +20360,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20209
20360
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
20210
20361
|
const method = e.method;
|
|
20211
20362
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
20212
|
-
const crc =
|
|
20363
|
+
const crc = crc322(newData);
|
|
20213
20364
|
const flags = e.flags & ~8;
|
|
20214
20365
|
hview.setUint16(6, flags, true);
|
|
20215
20366
|
hview.setUint32(14, crc, true);
|
|
@@ -20227,7 +20378,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20227
20378
|
const deflated = new Uint8Array(_zlib.deflateRawSync.call(void 0, data));
|
|
20228
20379
|
const method = deflated.length < data.length ? 8 : 0;
|
|
20229
20380
|
const compData = method === 8 ? deflated : data;
|
|
20230
|
-
const crc =
|
|
20381
|
+
const crc = crc322(data);
|
|
20231
20382
|
const header = new Uint8Array(30 + nameBytes.length);
|
|
20232
20383
|
const hv = new DataView(header.buffer);
|
|
20233
20384
|
hv.setUint32(0, LOCAL_SIG, true);
|
|
@@ -20307,7 +20458,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20307
20458
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20308
20459
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20309
20460
|
if (sectionPaths.length === 0) {
|
|
20310
|
-
throw new (0,
|
|
20461
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20311
20462
|
}
|
|
20312
20463
|
const normalizedValues = normalizeValues(values);
|
|
20313
20464
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20380,7 +20531,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20380
20531
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
20381
20532
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
20382
20533
|
if (!normalizedCellLabel) continue;
|
|
20383
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20534
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _165 => _165.has, 'call', _166 => _166(normalizedCellLabel)])) continue;
|
|
20384
20535
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
20385
20536
|
if (matchKey === void 0) continue;
|
|
20386
20537
|
if (patternApplied.has(valueCell)) {
|
|
@@ -20438,7 +20589,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20438
20589
|
const dataCells = table.rows[rowIdx];
|
|
20439
20590
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
20440
20591
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
20441
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20592
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _167 => _167.has, 'call', _168 => _168(headerLabel)])) continue;
|
|
20442
20593
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
20443
20594
|
if (matchKey === void 0) continue;
|
|
20444
20595
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -20471,11 +20622,11 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20471
20622
|
}
|
|
20472
20623
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20473
20624
|
const existing = ledger.get(para);
|
|
20474
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20625
|
+
if (_optionalChain([existing, 'optionalAccess', _169 => _169.fullText]) !== void 0) continue;
|
|
20475
20626
|
const text = matchText(para);
|
|
20476
20627
|
for (const seg of scanInlineSegments(text)) {
|
|
20477
20628
|
const nlabel = normalizeLabel(seg.label);
|
|
20478
|
-
if (_optionalChain([blockedLabels, 'optionalAccess',
|
|
20629
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _170 => _170.has, 'call', _171 => _171(nlabel)])) continue;
|
|
20479
20630
|
const matchKey = findMatchingKey(nlabel, cursor);
|
|
20480
20631
|
if (matchKey === void 0) continue;
|
|
20481
20632
|
const newValue = cursor.consume(matchKey);
|
|
@@ -20712,8 +20863,8 @@ function charWidthEm1000(cp) {
|
|
|
20712
20863
|
var SPACE_EM_FIXED = 500;
|
|
20713
20864
|
var SPACE_EM_FONT = 300;
|
|
20714
20865
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20715
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20716
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20866
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _172 => _172.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20867
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _173 => _173.spacingPct]), () => ( 0));
|
|
20717
20868
|
let em = 0;
|
|
20718
20869
|
for (const ch of text) {
|
|
20719
20870
|
const cp = ch.codePointAt(0);
|
|
@@ -20726,8 +20877,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20726
20877
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20727
20878
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20728
20879
|
const EPS = 0.5;
|
|
20729
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20730
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20880
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _174 => _174.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20881
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _175 => _175.spacingPct]), () => ( 0));
|
|
20731
20882
|
const k = height * ratioPct / 100 / 1e3;
|
|
20732
20883
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20733
20884
|
const charW2 = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20953,16 +21104,16 @@ var PARA_LIST = 7;
|
|
|
20953
21104
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20954
21105
|
function resolveTheme(theme) {
|
|
20955
21106
|
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',
|
|
21107
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _176 => _176.headingColors, 'optionalAccess', _177 => _177[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21108
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _178 => _178.headingColors, 'optionalAccess', _179 => _179[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21109
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _180 => _180.headingColors, 'optionalAccess', _181 => _181[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21110
|
+
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)),
|
|
21111
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _186 => _186.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21112
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _187 => _187.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20962
21113
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20963
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20964
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20965
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
21114
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _188 => _188.quoteColor]) !== void 0,
|
|
21115
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _189 => _189.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _190 => _190.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21116
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _191 => _191.tableHeaderBold])
|
|
20966
21117
|
};
|
|
20967
21118
|
}
|
|
20968
21119
|
function escapeXml(text) {
|
|
@@ -21256,7 +21407,7 @@ function generateManifest(chartParts = []) {
|
|
|
21256
21407
|
</opf:spine>
|
|
21257
21408
|
</opf:package>`;
|
|
21258
21409
|
}
|
|
21259
|
-
function buildCharProperties(theme, gongmun, ratioVariants = []) {
|
|
21410
|
+
function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls = []) {
|
|
21260
21411
|
let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
|
|
21261
21412
|
if (gongmun) {
|
|
21262
21413
|
body = gongmun.bodyHeight;
|
|
@@ -21288,6 +21439,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = []) {
|
|
|
21288
21439
|
charPr(rows.length + 3, body, true, true, 0, theme.body, r)
|
|
21289
21440
|
);
|
|
21290
21441
|
}
|
|
21442
|
+
rows.push(...extraCharPrXmls);
|
|
21291
21443
|
return `<hh:charProperties itemCnt="${rows.length}">
|
|
21292
21444
|
${rows.join("\n")}
|
|
21293
21445
|
</hh:charProperties>`;
|
|
@@ -21341,9 +21493,9 @@ ${heads}
|
|
|
21341
21493
|
</hh:numbering>
|
|
21342
21494
|
</hh:numberings>`;
|
|
21343
21495
|
}
|
|
21344
|
-
function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
21345
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
21346
|
-
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants);
|
|
21496
|
+
function generateHeaderXml(theme, gongmun, ratioVariants = [], remap = null) {
|
|
21497
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _192 => _192.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
21498
|
+
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _193 => _193.charPrXmls]), () => ( [])));
|
|
21347
21499
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21348
21500
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
21349
21501
|
<hh:head xmlns:hh="${NS_HEAD}" xmlns:hp="${NS_PARA}" xmlns:hc="${NS_CORE}" version="1.4" secCnt="1">
|
|
@@ -21398,7 +21550,7 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21398
21550
|
</hh:font>
|
|
21399
21551
|
</hh:fontface>
|
|
21400
21552
|
</hh:fontfaces>
|
|
21401
|
-
<hh:borderFills itemCnt="2">
|
|
21553
|
+
<hh:borderFills itemCnt="${2 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _194 => _194.borderFillXmls, 'access', _195 => _195.length]), () => ( 0)))}">
|
|
21402
21554
|
<hh:borderFill id="1" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
21403
21555
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
21404
21556
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -21414,7 +21566,7 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21414
21566
|
<hh:rightBorder type="SOLID" width="0.12 mm" color="#000000"/>
|
|
21415
21567
|
<hh:topBorder type="SOLID" width="0.12 mm" color="#000000"/>
|
|
21416
21568
|
<hh:bottomBorder type="SOLID" width="0.12 mm" color="#000000"/>
|
|
21417
|
-
</hh:borderFill
|
|
21569
|
+
</hh:borderFill>${remap && remap.borderFillXmls.length ? "\n" + remap.borderFillXmls.join("\n") : ""}
|
|
21418
21570
|
</hh:borderFills>
|
|
21419
21571
|
${charPropsXml}
|
|
21420
21572
|
<hh:tabProperties itemCnt="0"/>
|
|
@@ -21539,8 +21691,8 @@ function parseChartFence(text) {
|
|
|
21539
21691
|
const spec = chartSpec(type);
|
|
21540
21692
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
21541
21693
|
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',
|
|
21694
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _196 => _196.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
21695
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _197 => _197[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
21544
21696
|
if (!spec.scatter) {
|
|
21545
21697
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
21546
21698
|
}
|
|
@@ -21582,7 +21734,7 @@ function serSpPr(color, stroke) {
|
|
|
21582
21734
|
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
21735
|
}
|
|
21584
21736
|
function dPtXml(pointColors, pie) {
|
|
21585
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
21737
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _198 => _198.length])) return "";
|
|
21586
21738
|
return pointColors.map((col, i) => {
|
|
21587
21739
|
const f = chartColorFill(col);
|
|
21588
21740
|
if (!f) return "";
|
|
@@ -21901,7 +22053,7 @@ function escapeGfm(text) {
|
|
|
21901
22053
|
}
|
|
21902
22054
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21903
22055
|
function sanitizeText(text) {
|
|
21904
|
-
let result =
|
|
22056
|
+
let result = _chunkR2H34FY5cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21905
22057
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21906
22058
|
const tokens = result.split(" ");
|
|
21907
22059
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21931,7 +22083,7 @@ function replicateGfmTable(table) {
|
|
|
21931
22083
|
for (let r = 0; r < numRows; r++) {
|
|
21932
22084
|
for (let c = 0; c < numCols; c++) {
|
|
21933
22085
|
if (skip.has(`${r},${c}`)) continue;
|
|
21934
|
-
const cell = _optionalChain([cells, 'access',
|
|
22086
|
+
const cell = _optionalChain([cells, 'access', _199 => _199[r], 'optionalAccess', _200 => _200[c]]);
|
|
21935
22087
|
if (!cell) continue;
|
|
21936
22088
|
display[r][c] = {
|
|
21937
22089
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -21985,7 +22137,7 @@ function unescapeGfmCell(text) {
|
|
|
21985
22137
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
21986
22138
|
}
|
|
21987
22139
|
function replicateCellInnerHtml(cell) {
|
|
21988
|
-
if (_optionalChain([cell, 'access',
|
|
22140
|
+
if (_optionalChain([cell, 'access', _201 => _201.blocks, 'optionalAccess', _202 => _202.length])) {
|
|
21989
22141
|
return cell.blocks.map((b) => {
|
|
21990
22142
|
if (b.type === "table" && b.table) {
|
|
21991
22143
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -22024,7 +22176,7 @@ function replicateHtmlTable(table) {
|
|
|
22024
22176
|
const rowCells = [];
|
|
22025
22177
|
for (let c = 0; c < numCols; c++) {
|
|
22026
22178
|
if (skip.has(`${r},${c}`)) continue;
|
|
22027
|
-
const cell = _optionalChain([cells, 'access',
|
|
22179
|
+
const cell = _optionalChain([cells, 'access', _203 => _203[r], 'optionalAccess', _204 => _204[c]]);
|
|
22028
22180
|
if (!cell) continue;
|
|
22029
22181
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
22030
22182
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -22070,8 +22222,8 @@ function parseHtmlTable(raw) {
|
|
|
22070
22222
|
}
|
|
22071
22223
|
} else {
|
|
22072
22224
|
if (!isClose) {
|
|
22073
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
22074
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
22225
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _205 => _205.match, 'call', _206 => _206(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _207 => _207[1]]) || "1", 10);
|
|
22226
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _208 => _208.match, 'call', _209 => _209(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _210 => _210[1]]) || "1", 10);
|
|
22075
22227
|
cellStart = m.index + m[0].length;
|
|
22076
22228
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
22077
22229
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -22140,29 +22292,157 @@ function removeNestedTables(html) {
|
|
|
22140
22292
|
return result;
|
|
22141
22293
|
}
|
|
22142
22294
|
|
|
22295
|
+
// src/hwpx/gen-profile.ts
|
|
22296
|
+
function normalizeAnchor(s) {
|
|
22297
|
+
return s.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "").slice(0, 24);
|
|
22298
|
+
}
|
|
22299
|
+
function takeProfile(remap, rows, cols, anchor, seq) {
|
|
22300
|
+
if (!remap) return null;
|
|
22301
|
+
for (const t of remap.tables) {
|
|
22302
|
+
if (t.used) continue;
|
|
22303
|
+
if (t.rows !== rows || t.cols !== cols) continue;
|
|
22304
|
+
if (t.anchor && anchor) {
|
|
22305
|
+
if (t.anchor !== anchor) continue;
|
|
22306
|
+
} else if (t.index !== seq) {
|
|
22307
|
+
continue;
|
|
22308
|
+
}
|
|
22309
|
+
t.used = true;
|
|
22310
|
+
return t;
|
|
22311
|
+
}
|
|
22312
|
+
return null;
|
|
22313
|
+
}
|
|
22314
|
+
function parseHu(s) {
|
|
22315
|
+
if (s == null) return void 0;
|
|
22316
|
+
const n = parseInt(String(s).trim(), 10);
|
|
22317
|
+
return Number.isFinite(n) ? n : void 0;
|
|
22318
|
+
}
|
|
22319
|
+
function edgeXml(tag, d) {
|
|
22320
|
+
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22321
|
+
}
|
|
22322
|
+
function borderFillDefToXml(id, def) {
|
|
22323
|
+
const fill = _optionalChain([def, 'access', _211 => _211.fill, 'optionalAccess', _212 => _212.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22324
|
+
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22325
|
+
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22326
|
+
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
22327
|
+
${edgeXml("leftBorder", def.leftBorder)}
|
|
22328
|
+
${edgeXml("rightBorder", def.rightBorder)}
|
|
22329
|
+
${edgeXml("topBorder", def.topBorder)}
|
|
22330
|
+
${edgeXml("bottomBorder", def.bottomBorder)}${fill ? `
|
|
22331
|
+
${fill}` : ""}
|
|
22332
|
+
</hh:borderFill>`;
|
|
22333
|
+
}
|
|
22334
|
+
var PROFILE_FONT_MAX = 2;
|
|
22335
|
+
function profileCharPrXml(id, def) {
|
|
22336
|
+
const height = _nullishCoalesce(parseHu(def.height_hwpunit), () => ( 1e3));
|
|
22337
|
+
const color = _nullishCoalesce(def.textColor, () => ( "#000000"));
|
|
22338
|
+
const rawFont = def.fontRef_hangul != null ? parseInt(def.fontRef_hangul, 10) || 0 : 0;
|
|
22339
|
+
const font = rawFont >= 0 && rawFont <= PROFILE_FONT_MAX ? rawFont : 0;
|
|
22340
|
+
const boldAttr = def.bold ? ` bold="1"` : "";
|
|
22341
|
+
const italicAttr = def.italic ? ` italic="1"` : "";
|
|
22342
|
+
const underline = def.underline ? `
|
|
22343
|
+
<hh:underline type="BOTTOM" shape="SOLID" color="${color}"/>` : "";
|
|
22344
|
+
return ` <hh:charPr id="${id}" height="${height}" textColor="${color}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="1"${boldAttr}${italicAttr}>
|
|
22345
|
+
<hh:fontRef hangul="${font}" latin="${font}" hanja="${font}" japanese="${font}" other="${font}" symbol="${font}" user="${font}"/>
|
|
22346
|
+
<hh:ratio hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22347
|
+
<hh:spacing hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
22348
|
+
<hh:relSz hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22349
|
+
<hh:offset hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>${underline}
|
|
22350
|
+
</hh:charPr>`;
|
|
22351
|
+
}
|
|
22352
|
+
function buildProfileRemap(profile, charPrBase, borderFillBase = 3) {
|
|
22353
|
+
const remap = { borderFillXmls: [], charPrXmls: [], tables: [] };
|
|
22354
|
+
let bfNext = borderFillBase;
|
|
22355
|
+
let charNext = charPrBase;
|
|
22356
|
+
for (const t of profile.tables) {
|
|
22357
|
+
const localBf = {};
|
|
22358
|
+
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_border_fills, () => ( {})))) {
|
|
22359
|
+
const gid = bfNext++;
|
|
22360
|
+
remap.borderFillXmls.push(borderFillDefToXml(gid, def));
|
|
22361
|
+
localBf[key] = gid;
|
|
22362
|
+
}
|
|
22363
|
+
const localChar = {};
|
|
22364
|
+
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_char_prs, () => ( {})))) {
|
|
22365
|
+
const gid = charNext++;
|
|
22366
|
+
remap.charPrXmls.push(profileCharPrXml(gid, def));
|
|
22367
|
+
localChar[key] = gid;
|
|
22368
|
+
}
|
|
22369
|
+
let colWidths;
|
|
22370
|
+
if (t.col_widths_hwpunit && t.col_widths_hwpunit.length === t.cols) {
|
|
22371
|
+
const parsed = t.col_widths_hwpunit.map(parseHu);
|
|
22372
|
+
if (parsed.every((n) => n != null)) colWidths = parsed;
|
|
22373
|
+
}
|
|
22374
|
+
const tr = {
|
|
22375
|
+
index: t.table_index,
|
|
22376
|
+
rows: t.rows,
|
|
22377
|
+
cols: t.cols,
|
|
22378
|
+
// 재정규화 — 추출기는 정규화해 담지만 손편집된 프로필 JSON도 같은 키 공간으로
|
|
22379
|
+
anchor: t.anchor_text ? normalizeAnchor(t.anchor_text) : void 0,
|
|
22380
|
+
width: parseHu(t.width_hwpunit),
|
|
22381
|
+
colWidths,
|
|
22382
|
+
cellBf: /* @__PURE__ */ new Map(),
|
|
22383
|
+
cellChar: /* @__PURE__ */ new Map(),
|
|
22384
|
+
cellH: /* @__PURE__ */ new Map()
|
|
22385
|
+
};
|
|
22386
|
+
for (const cell of t.cells) {
|
|
22387
|
+
const k = `${cell.row},${cell.col}`;
|
|
22388
|
+
if (cell.borderFillIDRef != null && cell.borderFillIDRef in localBf) {
|
|
22389
|
+
tr.cellBf.set(k, localBf[cell.borderFillIDRef]);
|
|
22390
|
+
}
|
|
22391
|
+
if (cell.charPrIDRef != null && cell.charPrIDRef in localChar) {
|
|
22392
|
+
tr.cellChar.set(k, localChar[cell.charPrIDRef]);
|
|
22393
|
+
}
|
|
22394
|
+
const h = parseHu(cell.height_hwpunit);
|
|
22395
|
+
if (h != null) tr.cellH.set(k, h);
|
|
22396
|
+
}
|
|
22397
|
+
remap.tables.push(tr);
|
|
22398
|
+
}
|
|
22399
|
+
return remap;
|
|
22400
|
+
}
|
|
22401
|
+
function profileCharPrBase(ratioVariantCount) {
|
|
22402
|
+
return CHAR_VARIANT_BASE + ratioVariantCount * 4;
|
|
22403
|
+
}
|
|
22404
|
+
|
|
22143
22405
|
// src/hwpx/gen-table.ts
|
|
22144
22406
|
var TABLE_ID_BASE = 1e3;
|
|
22145
22407
|
var tableIdCounter = TABLE_ID_BASE;
|
|
22146
22408
|
function nextTableId() {
|
|
22147
22409
|
return ++tableIdCounter;
|
|
22148
22410
|
}
|
|
22149
|
-
function
|
|
22411
|
+
function anchorOfMarkdownCell(cell) {
|
|
22412
|
+
return normalizeAnchor(cell.replace(/!\[[^\]]*\]\([^)]*\)/g, ""));
|
|
22413
|
+
}
|
|
22414
|
+
function anchorOfHtmlCell(inner) {
|
|
22415
|
+
const noNested = inner.replace(/<table[\s\S]*?<\/table>/gi, "");
|
|
22416
|
+
const { lines } = htmlCellInnerToLines(noNested);
|
|
22417
|
+
return normalizeAnchor(lines.join(""));
|
|
22418
|
+
}
|
|
22419
|
+
function resolveColWidths(tp, colCnt, fallbackTotal) {
|
|
22420
|
+
if (_optionalChain([tp, 'optionalAccess', _213 => _213.colWidths]) && tp.colWidths.length === colCnt) return tp.colWidths;
|
|
22421
|
+
const w = _optionalChain([tp, 'optionalAccess', _214 => _214.width]) ? Math.floor(tp.width / colCnt) : Math.floor(fallbackTotal / colCnt);
|
|
22422
|
+
return Array(colCnt).fill(w);
|
|
22423
|
+
}
|
|
22424
|
+
function generateTable(rows, theme, remap = null, seq = 0) {
|
|
22150
22425
|
const rowCnt = rows.length;
|
|
22151
22426
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
22152
|
-
const cellW = Math.floor(44e3 / colCnt);
|
|
22153
22427
|
const cellH = 1500;
|
|
22154
|
-
const tblW = cellW * colCnt;
|
|
22155
|
-
const tblH = cellH * rowCnt;
|
|
22156
22428
|
const tblId = nextTableId();
|
|
22429
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _215 => _215[0], 'optionalAccess', _216 => _216[0]]), () => ( ""))), seq);
|
|
22430
|
+
const colW = resolveColWidths(prof, colCnt, 44e3);
|
|
22431
|
+
const tblW = colW.reduce((a, b) => a + b, 0);
|
|
22432
|
+
const tblH = cellH * rowCnt;
|
|
22157
22433
|
const useHeaderStyle = theme.tableHeader !== theme.body || theme.tableHeaderBold;
|
|
22158
22434
|
const trElements = rows.map((row, rowIdx) => {
|
|
22159
22435
|
const cells = row.length < colCnt ? [...row, ...Array(colCnt - row.length).fill("")] : row;
|
|
22160
22436
|
const isHeaderRow = rowIdx === 0;
|
|
22161
22437
|
const headerCharPr = isHeaderRow && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
22162
22438
|
const tdElements = cells.map((cell, colIdx) => {
|
|
22163
|
-
const
|
|
22439
|
+
const k = `${rowIdx},${colIdx}`;
|
|
22440
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _217 => _217.cellBf, 'access', _218 => _218.get, 'call', _219 => _219(k)]), () => ( 2));
|
|
22441
|
+
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _220 => _220.cellChar, 'access', _221 => _221.get, 'call', _222 => _222(k)]), () => ( headerCharPr));
|
|
22442
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _223 => _223.cellH, 'access', _224 => _224.get, 'call', _225 => _225(k)]), () => ( cellH));
|
|
22443
|
+
const runs = generateRuns(cell, ch);
|
|
22164
22444
|
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="
|
|
22445
|
+
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
22446
|
}).join("");
|
|
22167
22447
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
22168
22448
|
}).join("");
|
|
@@ -22193,35 +22473,43 @@ function layoutHtmlRows(rows) {
|
|
|
22193
22473
|
function unescapeHtml(s) {
|
|
22194
22474
|
return s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
22195
22475
|
}
|
|
22196
|
-
function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3) {
|
|
22476
|
+
function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, remap = null, seq = 0) {
|
|
22197
22477
|
const rows = parseHtmlTable(rawHtml);
|
|
22198
22478
|
if (!rows || rows.length === 0) return null;
|
|
22199
22479
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
22200
22480
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
22201
|
-
const colW = Math.floor(totalWidth / colCnt);
|
|
22202
22481
|
const cellH = 1500;
|
|
22203
|
-
const tblW = colW * colCnt;
|
|
22204
22482
|
const tblId = nextTableId();
|
|
22483
|
+
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
22484
|
+
const prof = takeProfile(remap, rowCnt, colCnt, first ? anchorOfHtmlCell(first.inner) : "", seq);
|
|
22485
|
+
const colW = resolveColWidths(prof, colCnt, totalWidth);
|
|
22486
|
+
const tblW = colW.reduce((a, b) => a + b, 0);
|
|
22205
22487
|
const useHeaderStyle = theme.tableHeader !== theme.body || theme.tableHeaderBold;
|
|
22488
|
+
const spanW = (c, colSpan) => colW.slice(c, c + colSpan).reduce((a, b) => a + b, 0);
|
|
22206
22489
|
const tcXmls = placed.map((cell) => {
|
|
22490
|
+
const k = `${cell.r},${cell.c}`;
|
|
22491
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _226 => _226.cellBf, 'access', _227 => _227.get, 'call', _228 => _228(k)]), () => ( 2));
|
|
22207
22492
|
const headerCharPr = cell.isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
22493
|
+
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _229 => _229.cellChar, 'access', _230 => _230.get, 'call', _231 => _231(k)]), () => ( headerCharPr));
|
|
22208
22494
|
const { lines } = htmlCellInnerToLines(cell.inner);
|
|
22209
22495
|
const paras = lines.map(
|
|
22210
|
-
(line) => `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${
|
|
22496
|
+
(line) => `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${ch}"><hp:t>${escapeXml(unescapeHtml(line))}</hp:t></hp:run></hp:p>`
|
|
22211
22497
|
);
|
|
22498
|
+
const cellW = spanW(cell.c, cell.colSpan);
|
|
22212
22499
|
let nestedH = 0;
|
|
22213
22500
|
for (const nested of extractTopLevelTables(cell.inner)) {
|
|
22214
|
-
const nestedXml = generateHtmlTableXml(nested, theme, Math.max(
|
|
22501
|
+
const nestedXml = generateHtmlTableXml(nested, theme, Math.max(cellW - 1020, 4e3));
|
|
22215
22502
|
if (nestedXml) {
|
|
22216
22503
|
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${nestedXml}</hp:run></hp:p>`);
|
|
22217
22504
|
nestedH += (_nullishCoalesce(nested.match(/<tr[\s>]/gi), () => ( []))).length * cellH + 300;
|
|
22218
22505
|
}
|
|
22219
22506
|
}
|
|
22220
22507
|
if (paras.length === 0) {
|
|
22221
|
-
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${
|
|
22508
|
+
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${ch}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
22222
22509
|
}
|
|
22223
|
-
const
|
|
22224
|
-
|
|
22510
|
+
const contentH = Math.max(cellH * cell.rowSpan, Math.max(lines.length, 1) * 800 + nestedH);
|
|
22511
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _232 => _232.cellH, 'access', _233 => _233.get, 'call', _234 => _234(k)]), () => ( 0)), contentH);
|
|
22512
|
+
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
22513
|
});
|
|
22226
22514
|
const trXmls = [];
|
|
22227
22515
|
for (let r = 0; r < rowCnt; r++) {
|
|
@@ -22387,9 +22675,9 @@ function readCommand(input, idx, depth) {
|
|
|
22387
22675
|
const command = name.value;
|
|
22388
22676
|
if (command === "\\") return { value: "#", next: name.next };
|
|
22389
22677
|
if (command === "frac") {
|
|
22390
|
-
const
|
|
22391
|
-
const den = readGroupOrToken(input,
|
|
22392
|
-
return { value: `{${
|
|
22678
|
+
const num4 = readGroupOrToken(input, name.next, depth);
|
|
22679
|
+
const den = readGroupOrToken(input, num4.next, depth);
|
|
22680
|
+
return { value: `{${num4.value}} over {${den.value}}`, next: den.next };
|
|
22393
22681
|
}
|
|
22394
22682
|
if (command === "sqrt") {
|
|
22395
22683
|
let cursor = skipSpaces(input, name.next);
|
|
@@ -22520,9 +22808,10 @@ function generateSecPr(gongmun) {
|
|
|
22520
22808
|
} : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
|
|
22521
22809
|
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
22810
|
}
|
|
22523
|
-
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null) {
|
|
22811
|
+
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, remap = null) {
|
|
22524
22812
|
const paraXmls = [];
|
|
22525
22813
|
let isFirst = true;
|
|
22814
|
+
let tableSeq = 0;
|
|
22526
22815
|
const orderedCounters = {};
|
|
22527
22816
|
let prevWasOrdered = false;
|
|
22528
22817
|
for (let blockIdx = 0; blockIdx < blocks.length; blockIdx++) {
|
|
@@ -22589,8 +22878,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22589
22878
|
case "list_item": {
|
|
22590
22879
|
if (gongmun && gongmunList) {
|
|
22591
22880
|
const info = gongmunList.get(blockIdx);
|
|
22592
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22593
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22881
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _235 => _235.depth]), () => ( 0));
|
|
22882
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _236 => _236.marker]), () => ( ""));
|
|
22594
22883
|
const content = block.text || "";
|
|
22595
22884
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
22596
22885
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -22630,11 +22919,11 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22630
22919
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
22631
22920
|
isFirst = false;
|
|
22632
22921
|
}
|
|
22633
|
-
xml = generateTable(block.rows, theme);
|
|
22922
|
+
xml = generateTable(block.rows, theme, remap, tableSeq++);
|
|
22634
22923
|
}
|
|
22635
22924
|
break;
|
|
22636
22925
|
case "html_table": {
|
|
22637
|
-
const tbl = generateHtmlTableXml(block.text || "", theme);
|
|
22926
|
+
const tbl = generateHtmlTableXml(block.text || "", theme, 44e3, remap, tableSeq++);
|
|
22638
22927
|
if (tbl) {
|
|
22639
22928
|
if (isFirst) {
|
|
22640
22929
|
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
|
|
@@ -22670,18 +22959,25 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22670
22959
|
|
|
22671
22960
|
// src/hwpx/generator.ts
|
|
22672
22961
|
async function markdownToHwpx(markdown, options) {
|
|
22673
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
22674
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
22962
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _237 => _237.theme]));
|
|
22963
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _238 => _238.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
22675
22964
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
22676
22965
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
22677
22966
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
22967
|
+
const remap = _optionalChain([options, 'optionalAccess', _239 => _239.profile]) ? buildProfileRemap(options.profile, profileCharPrBase(_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _240 => _240.variants, 'optionalAccess', _241 => _241.length]), () => ( 0)))) : null;
|
|
22678
22968
|
const chartParts = [];
|
|
22679
|
-
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts);
|
|
22969
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, remap);
|
|
22970
|
+
if (remap && remap.tables.length > 0) {
|
|
22971
|
+
const unused = remap.tables.filter((t) => !t.used).length;
|
|
22972
|
+
if (unused === remap.tables.length) {
|
|
22973
|
+
console.warn(`[kordoc] format profile: \uD504\uB85C\uD544 \uD45C ${unused}\uAC1C\uAC00 \uBB38\uC11C \uD45C\uC640 \uB9E4\uCE6D\uB418\uC9C0 \uC54A\uC544 \uBBF8\uC801\uC6A9 (\uD589\xB7\uC5F4/\uCCAB \uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
22974
|
+
}
|
|
22975
|
+
}
|
|
22680
22976
|
const zip = new (0, _jszip2.default)();
|
|
22681
22977
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
22682
22978
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
22683
22979
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
22684
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
22980
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _242 => _242.variants]), () => ( [])), remap));
|
|
22685
22981
|
zip.file("Contents/section0.xml", sectionXml);
|
|
22686
22982
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
22687
22983
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -22969,7 +23265,7 @@ function parseRenderStyles(headXml) {
|
|
|
22969
23265
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
22970
23266
|
const textColor = el.getAttribute("textColor");
|
|
22971
23267
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
22972
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
23268
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _243 => _243.getAttribute, 'call', _244 => _244("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _245 => _245.getAttribute, 'call', _246 => _246("latin")])));
|
|
22973
23269
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
22974
23270
|
styles.charPr.set(id, {
|
|
22975
23271
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -22977,8 +23273,8 @@ function parseRenderStyles(headXml) {
|
|
|
22977
23273
|
italic: findChildByLocalName(el, "italic") != null,
|
|
22978
23274
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
22979
23275
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
22980
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
22981
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
23276
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _247 => _247.getAttribute, 'call', _248 => _248("hangul")])) || 100,
|
|
23277
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _249 => _249.getAttribute, 'call', _250 => _250("hangul")])) || 0,
|
|
22982
23278
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
22983
23279
|
});
|
|
22984
23280
|
}
|
|
@@ -22986,7 +23282,7 @@ function parseRenderStyles(headXml) {
|
|
|
22986
23282
|
const id = el.getAttribute("id");
|
|
22987
23283
|
if (id != null) {
|
|
22988
23284
|
const align = findChildByLocalName(el, "align");
|
|
22989
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
23285
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _251 => _251.getAttribute, 'call', _252 => _252("horizontal")]) || "JUSTIFY");
|
|
22990
23286
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
22991
23287
|
}
|
|
22992
23288
|
} else if (tag === "borderFill") {
|
|
@@ -23000,7 +23296,7 @@ function parseRenderStyles(headXml) {
|
|
|
23000
23296
|
};
|
|
23001
23297
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
23002
23298
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
23003
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
23299
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _253 => _253.getAttribute, 'call', _254 => _254("faceColor")]);
|
|
23004
23300
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
23005
23301
|
styles.borderFill.set(id, bf);
|
|
23006
23302
|
}
|
|
@@ -23072,7 +23368,7 @@ function collectSites(scan) {
|
|
|
23072
23368
|
}
|
|
23073
23369
|
function attrOf(openTag, name) {
|
|
23074
23370
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
23075
|
-
return _optionalChain([m, 'optionalAccess',
|
|
23371
|
+
return _optionalChain([m, 'optionalAccess', _255 => _255[1]]);
|
|
23076
23372
|
}
|
|
23077
23373
|
function paraOpenTag(xml, para) {
|
|
23078
23374
|
const end = xml.indexOf(">", para.start);
|
|
@@ -23087,7 +23383,7 @@ function anchorRunInfo(xml, para, anchor) {
|
|
|
23087
23383
|
if (!tr) return null;
|
|
23088
23384
|
const before = xml.slice(Math.max(0, para.start), tr.contentStart);
|
|
23089
23385
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
23090
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
23386
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _256 => _256[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
23091
23387
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
23092
23388
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
23093
23389
|
if (close === -1) return null;
|
|
@@ -23114,7 +23410,7 @@ function cellContentWidthMm(xml, cell) {
|
|
|
23114
23410
|
if (width === null) return null;
|
|
23115
23411
|
let content = width;
|
|
23116
23412
|
const win = cellAddrWindow(xml, cell);
|
|
23117
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
23413
|
+
const mg = _optionalChain([win, 'optionalAccess', _257 => _257.match, 'call', _258 => _258(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
23118
23414
|
if (mg) {
|
|
23119
23415
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
23120
23416
|
}
|
|
@@ -23148,11 +23444,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
23148
23444
|
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
23445
|
}
|
|
23150
23446
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
23151
|
-
if (ops.length === 0) throw new (0,
|
|
23447
|
+
if (ops.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23152
23448
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
23153
23449
|
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,
|
|
23450
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _259 => _259.match, 'call', _260 => _260(/(\d+)\.xml$/i), 'optionalAccess', _261 => _261[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _262 => _262.match, 'call', _263 => _263(/(\d+)\.xml$/i), 'optionalAccess', _264 => _264[1]]), () => ( 0))));
|
|
23451
|
+
if (sectionPaths.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23156
23452
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
23157
23453
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
23158
23454
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -23193,11 +23489,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23193
23489
|
const manifestItems = [];
|
|
23194
23490
|
const placed = [];
|
|
23195
23491
|
for (const op of ops) {
|
|
23196
|
-
if (!op.anchor) throw new (0,
|
|
23197
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
23492
|
+
if (!op.anchor) throw new (0, _chunkR2H34FY5cjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23493
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23198
23494
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
23199
|
-
if (!MIME[ext]) throw new (0,
|
|
23200
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
23495
|
+
if (!MIME[ext]) throw new (0, _chunkR2H34FY5cjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
23496
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkR2H34FY5cjs.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
23497
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
23202
23498
|
let found = null;
|
|
23203
23499
|
let total = 0;
|
|
@@ -23230,7 +23526,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23230
23526
|
}
|
|
23231
23527
|
}
|
|
23232
23528
|
}
|
|
23233
|
-
throw new (0,
|
|
23529
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
23234
23530
|
`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
23531
|
);
|
|
23236
23532
|
}
|
|
@@ -23238,9 +23534,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23238
23534
|
const xml = sectionXmls[si];
|
|
23239
23535
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
23240
23536
|
if (!run) {
|
|
23241
|
-
throw new (0,
|
|
23537
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
23242
23538
|
}
|
|
23243
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
23539
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _265 => _265.charPr, 'access', _266 => _266.get, 'call', _267 => _267(run.charPr), 'optionalAccess', _268 => _268.height]), () => ( 1e3));
|
|
23244
23540
|
const fontPt = charPrHeight / 100;
|
|
23245
23541
|
const emMm = fontPt * 25.4 / 72;
|
|
23246
23542
|
const lineHMm = emMm;
|
|
@@ -23249,7 +23545,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23249
23545
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
23250
23546
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
23251
23547
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
23252
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
23548
|
+
const align = _optionalChain([styles, 'optionalAccess', _269 => _269.paraAlign, 'access', _270 => _270.get, 'call', _271 => _271(paraPrId)]);
|
|
23253
23549
|
let alignShiftMm = 0;
|
|
23254
23550
|
if (align === "CENTER" || align === "RIGHT") {
|
|
23255
23551
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -23313,6 +23609,197 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23313
23609
|
};
|
|
23314
23610
|
}
|
|
23315
23611
|
|
|
23612
|
+
// src/hwpx/extract-profile.ts
|
|
23613
|
+
|
|
23614
|
+
function elemsByLocal(root, name) {
|
|
23615
|
+
const all = root.getElementsByTagName("*");
|
|
23616
|
+
const out = [];
|
|
23617
|
+
for (let i = 0; i < all.length; i++) {
|
|
23618
|
+
const el = all[i];
|
|
23619
|
+
const tag = (el.tagName || el.localName || "").replace(/^[^:]+:/, "");
|
|
23620
|
+
if (tag === name) out.push(el);
|
|
23621
|
+
}
|
|
23622
|
+
return out;
|
|
23623
|
+
}
|
|
23624
|
+
function borderDefOf(el) {
|
|
23625
|
+
if (!el) return void 0;
|
|
23626
|
+
const type = el.getAttribute("type") || "NONE";
|
|
23627
|
+
const width = el.getAttribute("width") || "0.1 mm";
|
|
23628
|
+
const color = el.getAttribute("color") || "#000000";
|
|
23629
|
+
return { type, width, color };
|
|
23630
|
+
}
|
|
23631
|
+
function parseBorderFills(headerDoc) {
|
|
23632
|
+
const map = /* @__PURE__ */ new Map();
|
|
23633
|
+
for (const bf of elemsByLocal(headerDoc, "borderFill")) {
|
|
23634
|
+
const id = bf.getAttribute("id");
|
|
23635
|
+
if (!id) continue;
|
|
23636
|
+
const def = {
|
|
23637
|
+
leftBorder: borderDefOf(findChildByLocalName(bf, "leftBorder")),
|
|
23638
|
+
rightBorder: borderDefOf(findChildByLocalName(bf, "rightBorder")),
|
|
23639
|
+
topBorder: borderDefOf(findChildByLocalName(bf, "topBorder")),
|
|
23640
|
+
bottomBorder: borderDefOf(findChildByLocalName(bf, "bottomBorder"))
|
|
23641
|
+
};
|
|
23642
|
+
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
23643
|
+
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
23644
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _272 => _272.getAttribute, 'call', _273 => _273("faceColor")]);
|
|
23645
|
+
if (face && face !== "none") def.fill = { faceColor: face };
|
|
23646
|
+
map.set(id, def);
|
|
23647
|
+
}
|
|
23648
|
+
return map;
|
|
23649
|
+
}
|
|
23650
|
+
function parseCharPrs(headerDoc) {
|
|
23651
|
+
const map = /* @__PURE__ */ new Map();
|
|
23652
|
+
for (const cp of elemsByLocal(headerDoc, "charPr")) {
|
|
23653
|
+
const id = cp.getAttribute("id");
|
|
23654
|
+
if (!id) continue;
|
|
23655
|
+
const def = {};
|
|
23656
|
+
const h = cp.getAttribute("height");
|
|
23657
|
+
if (h) def.height_hwpunit = h;
|
|
23658
|
+
const color = cp.getAttribute("textColor");
|
|
23659
|
+
if (color) def.textColor = color;
|
|
23660
|
+
if (cp.getAttribute("bold") === "1") def.bold = true;
|
|
23661
|
+
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
23662
|
+
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
23663
|
+
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
23664
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _274 => _274.getAttribute, 'call', _275 => _275("hangul")]);
|
|
23665
|
+
if (hangul) def.fontRef_hangul = hangul;
|
|
23666
|
+
map.set(id, def);
|
|
23667
|
+
}
|
|
23668
|
+
return map;
|
|
23669
|
+
}
|
|
23670
|
+
function isTopLevelTable(tbl) {
|
|
23671
|
+
let p = tbl.parentNode;
|
|
23672
|
+
while (p) {
|
|
23673
|
+
const tag = (p.tagName || p.localName || "").replace(/^[^:]+:/, "");
|
|
23674
|
+
if (tag === "tbl") return false;
|
|
23675
|
+
p = p.parentNode;
|
|
23676
|
+
}
|
|
23677
|
+
return true;
|
|
23678
|
+
}
|
|
23679
|
+
function num(s) {
|
|
23680
|
+
if (s == null) return void 0;
|
|
23681
|
+
const n = parseInt(s, 10);
|
|
23682
|
+
return Number.isFinite(n) ? n : void 0;
|
|
23683
|
+
}
|
|
23684
|
+
function parseTable3(tbl, tableIndex, borderFills, charPrs) {
|
|
23685
|
+
const rows = _nullishCoalesce(num(tbl.getAttribute("rowCnt")), () => ( 0));
|
|
23686
|
+
const cols = _nullishCoalesce(num(tbl.getAttribute("colCnt")), () => ( 0));
|
|
23687
|
+
const sz = findChildByLocalName(tbl, "sz");
|
|
23688
|
+
const width = _optionalChain([sz, 'optionalAccess', _276 => _276.getAttribute, 'call', _277 => _277("width")]) || void 0;
|
|
23689
|
+
const cells = [];
|
|
23690
|
+
const usedBf = /* @__PURE__ */ new Set();
|
|
23691
|
+
const usedCp = /* @__PURE__ */ new Set();
|
|
23692
|
+
const colWidths = new Array(cols).fill(void 0);
|
|
23693
|
+
let anchorText = "";
|
|
23694
|
+
for (const tc of elemsByLocal(tbl, "tc")) {
|
|
23695
|
+
if (nearestTable(tc) !== tbl) continue;
|
|
23696
|
+
const addr = findChildByLocalName(tc, "cellAddr");
|
|
23697
|
+
const span = findChildByLocalName(tc, "cellSpan");
|
|
23698
|
+
const csz = findChildByLocalName(tc, "cellSz");
|
|
23699
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _278 => _278.getAttribute, 'call', _279 => _279("rowAddr")])), () => ( 0));
|
|
23700
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _280 => _280.getAttribute, 'call', _281 => _281("colAddr")])), () => ( 0));
|
|
23701
|
+
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc);
|
|
23702
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _282 => _282.getAttribute, 'call', _283 => _283("colSpan")])), () => ( 1));
|
|
23703
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _284 => _284.getAttribute, 'call', _285 => _285("rowSpan")])), () => ( 1));
|
|
23704
|
+
const bfId = tc.getAttribute("borderFillIDRef") || void 0;
|
|
23705
|
+
const cpId = firstRunCharPr(tc);
|
|
23706
|
+
const cell = { row, col, rowSpan, colSpan };
|
|
23707
|
+
const w = _optionalChain([csz, 'optionalAccess', _286 => _286.getAttribute, 'call', _287 => _287("width")]);
|
|
23708
|
+
const hh = _optionalChain([csz, 'optionalAccess', _288 => _288.getAttribute, 'call', _289 => _289("height")]);
|
|
23709
|
+
if (w) cell.width_hwpunit = w;
|
|
23710
|
+
if (hh) cell.height_hwpunit = hh;
|
|
23711
|
+
if (bfId) {
|
|
23712
|
+
cell.borderFillIDRef = bfId;
|
|
23713
|
+
usedBf.add(bfId);
|
|
23714
|
+
}
|
|
23715
|
+
if (cpId) {
|
|
23716
|
+
cell.charPrIDRef = cpId;
|
|
23717
|
+
usedCp.add(cpId);
|
|
23718
|
+
}
|
|
23719
|
+
cells.push(cell);
|
|
23720
|
+
if (row === 0 && colSpan === 1 && col < cols && w) colWidths[col] = w;
|
|
23721
|
+
}
|
|
23722
|
+
const table = {
|
|
23723
|
+
table_index: tableIndex,
|
|
23724
|
+
rows,
|
|
23725
|
+
cols,
|
|
23726
|
+
cells,
|
|
23727
|
+
used_border_fills: pick(borderFills, usedBf)
|
|
23728
|
+
};
|
|
23729
|
+
const anchor = normalizeAnchor(anchorText);
|
|
23730
|
+
if (anchor) table.anchor_text = anchor;
|
|
23731
|
+
if (width) table.width_hwpunit = width;
|
|
23732
|
+
if (colWidths.every((w) => w != null)) table.col_widths_hwpunit = colWidths;
|
|
23733
|
+
const cp = pick(charPrs, usedCp);
|
|
23734
|
+
if (Object.keys(cp).length) table.used_char_prs = cp;
|
|
23735
|
+
return table;
|
|
23736
|
+
}
|
|
23737
|
+
function nearestTable(tc) {
|
|
23738
|
+
let p = tc.parentNode;
|
|
23739
|
+
while (p) {
|
|
23740
|
+
const tag = (p.tagName || p.localName || "").replace(/^[^:]+:/, "");
|
|
23741
|
+
if (tag === "tbl") return p;
|
|
23742
|
+
p = p.parentNode;
|
|
23743
|
+
}
|
|
23744
|
+
return null;
|
|
23745
|
+
}
|
|
23746
|
+
function firstRunCharPr(tc) {
|
|
23747
|
+
for (const run of elemsByLocal(tc, "run")) {
|
|
23748
|
+
if (nearestCell(run) !== tc) continue;
|
|
23749
|
+
const id = run.getAttribute("charPrIDRef");
|
|
23750
|
+
if (id) return id;
|
|
23751
|
+
}
|
|
23752
|
+
return void 0;
|
|
23753
|
+
}
|
|
23754
|
+
function nearestCell(el) {
|
|
23755
|
+
let p = el.parentNode;
|
|
23756
|
+
while (p) {
|
|
23757
|
+
const tag = (p.tagName || p.localName || "").replace(/^[^:]+:/, "");
|
|
23758
|
+
if (tag === "tc") return p;
|
|
23759
|
+
p = p.parentNode;
|
|
23760
|
+
}
|
|
23761
|
+
return null;
|
|
23762
|
+
}
|
|
23763
|
+
function directCellText(tc) {
|
|
23764
|
+
let out = "";
|
|
23765
|
+
for (const t of elemsByLocal(tc, "t")) {
|
|
23766
|
+
if (nearestCell(t) !== tc) continue;
|
|
23767
|
+
out += _nullishCoalesce(t.textContent, () => ( ""));
|
|
23768
|
+
if (out.length >= 64) break;
|
|
23769
|
+
}
|
|
23770
|
+
return out;
|
|
23771
|
+
}
|
|
23772
|
+
function pick(map, keys) {
|
|
23773
|
+
const out = {};
|
|
23774
|
+
for (const k of keys) {
|
|
23775
|
+
const v = map.get(k);
|
|
23776
|
+
if (v !== void 0) out[k] = v;
|
|
23777
|
+
}
|
|
23778
|
+
return out;
|
|
23779
|
+
}
|
|
23780
|
+
async function hwpxToProfile(input) {
|
|
23781
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, input);
|
|
23782
|
+
const zip = await _jszip2.default.loadAsync(buf);
|
|
23783
|
+
const parser = createXmlParser();
|
|
23784
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _290 => _290.file, 'call', _291 => _291(/[Hh]eader\.xml$/), 'optionalAccess', _292 => _292[0]])));
|
|
23785
|
+
let headerXml = "<root/>";
|
|
23786
|
+
if (headerFile) headerXml = await headerFile.async("text");
|
|
23787
|
+
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
23788
|
+
const borderFills = parseBorderFills(headerDoc);
|
|
23789
|
+
const charPrs = parseCharPrs(headerDoc);
|
|
23790
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _293 => _293.name, 'access', _294 => _294.match, 'call', _295 => _295(/(\d+)\.xml$/), 'optionalAccess', _296 => _296[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _297 => _297.name, 'access', _298 => _298.match, 'call', _299 => _299(/(\d+)\.xml$/), 'optionalAccess', _300 => _300[1]]), () => ( null))), () => ( 0))));
|
|
23791
|
+
const tables = [];
|
|
23792
|
+
let tableIndex = 0;
|
|
23793
|
+
for (const f of sectionFiles) {
|
|
23794
|
+
const doc = parser.parseFromString(await f.async("text"), "text/xml");
|
|
23795
|
+
for (const tbl of elemsByLocal(doc, "tbl")) {
|
|
23796
|
+
if (!isTopLevelTable(tbl)) continue;
|
|
23797
|
+
tables.push(parseTable3(tbl, tableIndex++, borderFills, charPrs));
|
|
23798
|
+
}
|
|
23799
|
+
}
|
|
23800
|
+
return { schema_version: "0.2.0", tables };
|
|
23801
|
+
}
|
|
23802
|
+
|
|
23316
23803
|
// src/roundtrip/patcher.ts
|
|
23317
23804
|
|
|
23318
23805
|
|
|
@@ -23321,7 +23808,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
23321
23808
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
23322
23809
|
function patchTableRows(input) {
|
|
23323
23810
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
23324
|
-
const xml = _optionalChain([ctx, 'access',
|
|
23811
|
+
const xml = _optionalChain([ctx, 'access', _301 => _301.scans, 'access', _302 => _302[scanTable.sectionIndex], 'optionalAccess', _303 => _303.xml]);
|
|
23325
23812
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
23326
23813
|
const numRows = table.rows;
|
|
23327
23814
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -23488,7 +23975,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
23488
23975
|
const rr = scanTable.rowRanges[template];
|
|
23489
23976
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
23490
23977
|
const scan = scanSectionXml(wrapped, 0);
|
|
23491
|
-
const row = _optionalChain([scan, 'access',
|
|
23978
|
+
const row = _optionalChain([scan, 'access', _304 => _304.tables, 'access', _305 => _305[0], 'optionalAccess', _306 => _306.rows, 'access', _307 => _307[0]]);
|
|
23492
23979
|
if (!row || row.length !== cells.length) return null;
|
|
23493
23980
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
23494
23981
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -23531,7 +24018,7 @@ function rowHeightOf(fragment) {
|
|
|
23531
24018
|
}
|
|
23532
24019
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
23533
24020
|
const from = scanTable.start + tblOpenLen;
|
|
23534
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
24021
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _308 => _308.rowRanges, 'access', _309 => _309[0], 'optionalAccess', _310 => _310.start]), () => ( from));
|
|
23535
24022
|
const slice = xml.slice(from, to);
|
|
23536
24023
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
23537
24024
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -23720,9 +24207,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
23720
24207
|
});
|
|
23721
24208
|
}
|
|
23722
24209
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
23723
|
-
const irCell = _optionalChain([table, 'access',
|
|
24210
|
+
const irCell = _optionalChain([table, 'access', _311 => _311.cells, 'access', _312 => _312[oc.gridR], 'optionalAccess', _313 => _313[oc.gridC]]);
|
|
23724
24211
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
23725
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
24212
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _314 => _314.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
23726
24213
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
23727
24214
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
23728
24215
|
}
|
|
@@ -23790,7 +24277,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23790
24277
|
};
|
|
23791
24278
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
23792
24279
|
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',
|
|
24280
|
+
const irCell = _optionalChain([table, 'access', _315 => _315.cells, 'access', _316 => _316[gridR], 'optionalAccess', _317 => _317[gridC]]);
|
|
23794
24281
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
23795
24282
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23796
24283
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -23813,7 +24300,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23813
24300
|
if (newLines.length === 0) return 0;
|
|
23814
24301
|
const target = cell.paragraphs[0];
|
|
23815
24302
|
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',
|
|
24303
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _318 => _318.scans, 'access', _319 => _319[target.sectionIndex], 'optionalAccess', _320 => _320.xml]));
|
|
23817
24304
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23818
24305
|
splices.push(...sp);
|
|
23819
24306
|
sectionIndex = target.sectionIndex;
|
|
@@ -23836,7 +24323,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23836
24323
|
}
|
|
23837
24324
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
23838
24325
|
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',
|
|
24326
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _321 => _321.scans, 'access', _322 => _322[nonEmpty[i].sectionIndex], 'optionalAccess', _323 => _323.xml]));
|
|
23840
24327
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23841
24328
|
splices.push(...sp);
|
|
23842
24329
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -23917,7 +24404,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
23917
24404
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
23918
24405
|
if (paths.length > 0) return paths;
|
|
23919
24406
|
}
|
|
23920
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
24407
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
23921
24408
|
}
|
|
23922
24409
|
function sectionPathsFromManifest(xml) {
|
|
23923
24410
|
const attr = (tag, name) => {
|
|
@@ -23927,7 +24414,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23927
24414
|
const idToHref = /* @__PURE__ */ new Map();
|
|
23928
24415
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
23929
24416
|
const id = attr(m[1], "id");
|
|
23930
|
-
const href =
|
|
24417
|
+
const href = _chunkR2H34FY5cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
23931
24418
|
if (id && href) idToHref.set(id, href);
|
|
23932
24419
|
}
|
|
23933
24420
|
const ordered = [];
|
|
@@ -23936,7 +24423,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23936
24423
|
if (href) ordered.push(href);
|
|
23937
24424
|
}
|
|
23938
24425
|
if (ordered.length > 0) return ordered;
|
|
23939
|
-
return Array.from(idToHref.values()).sort(
|
|
24426
|
+
return Array.from(idToHref.values()).sort(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
23940
24427
|
}
|
|
23941
24428
|
|
|
23942
24429
|
// src/roundtrip/patcher.ts
|
|
@@ -24028,7 +24515,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
24028
24515
|
}
|
|
24029
24516
|
}
|
|
24030
24517
|
let verification;
|
|
24031
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24518
|
+
if (_optionalChain([options, 'optionalAccess', _324 => _324.verify]) !== false) {
|
|
24032
24519
|
try {
|
|
24033
24520
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
24034
24521
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -24043,20 +24530,20 @@ function buildOrigUnits(blocks) {
|
|
|
24043
24530
|
for (let i = 0; i < blocks.length; i++) {
|
|
24044
24531
|
const block = blocks[i];
|
|
24045
24532
|
let consume = 1;
|
|
24046
|
-
let
|
|
24533
|
+
let chunk2;
|
|
24047
24534
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
24048
24535
|
const next = blocks[i + 1];
|
|
24049
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
24050
|
-
|
|
24536
|
+
if (_optionalChain([next, 'optionalAccess', _325 => _325.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
24537
|
+
chunk2 = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
24051
24538
|
} else {
|
|
24052
|
-
|
|
24539
|
+
chunk2 = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, [block]);
|
|
24053
24540
|
}
|
|
24054
|
-
if (
|
|
24055
|
-
const subUnits = splitMarkdownUnits(
|
|
24541
|
+
if (chunk2) {
|
|
24542
|
+
const subUnits = splitMarkdownUnits(chunk2);
|
|
24056
24543
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
24057
24544
|
for (let s = 0; s < subUnits.length; s++) {
|
|
24058
24545
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
24059
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
24546
|
+
if (block.type === "table" && _optionalChain([block, 'access', _326 => _326.table, 'optionalAccess', _327 => _327.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
24060
24547
|
u.role = "caption";
|
|
24061
24548
|
}
|
|
24062
24549
|
units.push(u);
|
|
@@ -24167,7 +24654,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24167
24654
|
const ti = ctx.tableInsert;
|
|
24168
24655
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
24169
24656
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24170
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24657
|
+
if (!_optionalChain([mapping, 'optionalAccess', _328 => _328.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
24658
|
const para = mapping.para;
|
|
24172
24659
|
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
24660
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -24195,7 +24682,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24195
24682
|
}
|
|
24196
24683
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
24197
24684
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24198
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24685
|
+
if (!_optionalChain([mapping, 'optionalAccess', _329 => _329.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
24686
|
if (block.text && block.text.includes("\n")) {
|
|
24200
24687
|
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
24688
|
}
|
|
@@ -24226,7 +24713,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
24226
24713
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24227
24714
|
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
24715
|
}
|
|
24229
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
24716
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _330 => _330.scans, 'access', _331 => _331[mapping.para.sectionIndex], 'optionalAccess', _332 => _332.xml]));
|
|
24230
24717
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24231
24718
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24232
24719
|
return 1;
|
|
@@ -24412,7 +24899,7 @@ var Surgeon = (_class4 = class {
|
|
|
24412
24899
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
24413
24900
|
findEntry(path) {
|
|
24414
24901
|
const parts = path.replace(/^\//, "").split("/");
|
|
24415
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
24902
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _333 => _333.entries, 'access', _334 => _334[0], 'optionalAccess', _335 => _335.child]), () => ( -1));
|
|
24416
24903
|
let current;
|
|
24417
24904
|
for (const part of parts) {
|
|
24418
24905
|
const search = (idx) => {
|
|
@@ -24625,8 +25112,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
24625
25112
|
parts.push(header, data);
|
|
24626
25113
|
};
|
|
24627
25114
|
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',
|
|
25115
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _336 => _336.get, 'call', _337 => _337(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
25116
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _338 => _338.get, 'call', _339 => _339(i)]), () => ( recs[i].data)));
|
|
24630
25117
|
}
|
|
24631
25118
|
return Buffer.concat(parts);
|
|
24632
25119
|
}
|
|
@@ -24744,7 +25231,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24744
25231
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
24745
25232
|
}
|
|
24746
25233
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
24747
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
25234
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _340 => _340.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
24748
25235
|
let flags;
|
|
24749
25236
|
try {
|
|
24750
25237
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -24766,7 +25253,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24766
25253
|
const scans = [];
|
|
24767
25254
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
24768
25255
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
24769
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
25256
|
+
if (!_optionalChain([entry, 'optionalAccess', _341 => _341.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
24770
25257
|
let stream;
|
|
24771
25258
|
try {
|
|
24772
25259
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -24817,7 +25304,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24817
25304
|
}
|
|
24818
25305
|
}
|
|
24819
25306
|
let verification;
|
|
24820
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25307
|
+
if (_optionalChain([options, 'optionalAccess', _342 => _342.verify]) !== false) {
|
|
24821
25308
|
try {
|
|
24822
25309
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
24823
25310
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -24886,19 +25373,19 @@ function resolveTableMappings(blocks, scanTables) {
|
|
|
24886
25373
|
if (scanTables[k].rows === table.rows && scanTables[k].cols === table.cols) cands.push(k);
|
|
24887
25374
|
}
|
|
24888
25375
|
if (cands.length === 0) continue;
|
|
24889
|
-
let
|
|
25376
|
+
let pick2 = cands[0];
|
|
24890
25377
|
if (cands.length > 1) {
|
|
24891
25378
|
let best = tableContentScore(table, scanTables[cands[0]]);
|
|
24892
25379
|
for (let ci = 1; ci < cands.length; ci++) {
|
|
24893
25380
|
const sc = tableContentScore(table, scanTables[cands[ci]]);
|
|
24894
25381
|
if (sc > best) {
|
|
24895
25382
|
best = sc;
|
|
24896
|
-
|
|
25383
|
+
pick2 = cands[ci];
|
|
24897
25384
|
}
|
|
24898
25385
|
}
|
|
24899
25386
|
}
|
|
24900
|
-
result.set(i, scanTables[
|
|
24901
|
-
si =
|
|
25387
|
+
result.set(i, scanTables[pick2]);
|
|
25388
|
+
si = pick2 + 1;
|
|
24902
25389
|
}
|
|
24903
25390
|
return result;
|
|
24904
25391
|
}
|
|
@@ -24907,7 +25394,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
24907
25394
|
for (const [key, scanCell] of scanTable.cells) {
|
|
24908
25395
|
const comma = key.indexOf(",");
|
|
24909
25396
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
24910
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
25397
|
+
const irCell = _optionalChain([irTable, 'access', _343 => _343.cells, 'access', _344 => _344[r], 'optionalAccess', _345 => _345[c]]);
|
|
24911
25398
|
if (!irCell) continue;
|
|
24912
25399
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
24913
25400
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -24943,7 +25430,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
24943
25430
|
}
|
|
24944
25431
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
24945
25432
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24946
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25433
|
+
if (!_optionalChain([mapping, 'optionalAccess', _346 => _346.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
25434
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
24948
25435
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
24949
25436
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -25142,7 +25629,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25142
25629
|
};
|
|
25143
25630
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
25144
25631
|
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',
|
|
25632
|
+
const irCell = _optionalChain([table, 'access', _347 => _347.cells, 'access', _348 => _348[gridR], 'optionalAccess', _349 => _349[gridC]]);
|
|
25146
25633
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
25147
25634
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25148
25635
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25534,7 +26021,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25534
26021
|
const block = st.blocks[blockIndex];
|
|
25535
26022
|
if (!block) return void 0;
|
|
25536
26023
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
25537
|
-
const para = _optionalChain([st, 'access',
|
|
26024
|
+
const para = _optionalChain([st, 'access', _350 => _350.paraMap, 'access', _351 => _351.get, 'call', _352 => _352(blockIndex), 'optionalAccess', _353 => _353.para]);
|
|
25538
26025
|
if (!para) return void 0;
|
|
25539
26026
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
25540
26027
|
}
|
|
@@ -25559,7 +26046,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25559
26046
|
if (block.text && block.text.includes("\n")) {
|
|
25560
26047
|
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
26048
|
}
|
|
25562
|
-
if (!_optionalChain([st, 'access',
|
|
26049
|
+
if (!_optionalChain([st, 'access', _354 => _354.paraMap, 'access', _355 => _355.get, 'call', _356 => _356(blockIndex), 'optionalAccess', _357 => _357.para])) {
|
|
25563
26050
|
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
26051
|
}
|
|
25565
26052
|
return { capability: "text" };
|
|
@@ -25625,7 +26112,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25625
26112
|
continue;
|
|
25626
26113
|
}
|
|
25627
26114
|
if (block.type === "table" && block.table) {
|
|
25628
|
-
if (!_optionalChain([edit, 'access',
|
|
26115
|
+
if (!_optionalChain([edit, 'access', _358 => _358.cells, 'optionalAccess', _359 => _359.length])) {
|
|
25629
26116
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
25630
26117
|
continue;
|
|
25631
26118
|
}
|
|
@@ -25645,7 +26132,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25645
26132
|
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
26133
|
continue;
|
|
25647
26134
|
}
|
|
25648
|
-
const irCell = _optionalChain([block, 'access',
|
|
26135
|
+
const irCell = _optionalChain([block, 'access', _360 => _360.table, 'access', _361 => _361.cells, 'access', _362 => _362[cellEdit.row], 'optionalAccess', _363 => _363[cellEdit.col]]);
|
|
25649
26136
|
if (!irCell) {
|
|
25650
26137
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
25651
26138
|
continue;
|
|
@@ -25701,7 +26188,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25701
26188
|
}
|
|
25702
26189
|
if (replacements.size === 0) {
|
|
25703
26190
|
let changes2;
|
|
25704
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26191
|
+
if (_optionalChain([options, 'optionalAccess', _364 => _364.verify]) !== false) {
|
|
25705
26192
|
const units = splitMarkdownUnits(st.markdown);
|
|
25706
26193
|
changes2 = diffUnitLists(units, units);
|
|
25707
26194
|
}
|
|
@@ -25722,7 +26209,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25722
26209
|
}
|
|
25723
26210
|
this.state = newState;
|
|
25724
26211
|
let changes;
|
|
25725
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26212
|
+
if (_optionalChain([options, 'optionalAccess', _365 => _365.verify]) !== false) {
|
|
25726
26213
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
25727
26214
|
}
|
|
25728
26215
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -25742,7 +26229,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25742
26229
|
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
26230
|
}
|
|
25744
26231
|
const mapping = st.paraMap.get(blockIndex);
|
|
25745
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26232
|
+
if (!_optionalChain([mapping, 'optionalAccess', _366 => _366.para])) {
|
|
25746
26233
|
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
26234
|
}
|
|
25748
26235
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -25762,14 +26249,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25762
26249
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25763
26250
|
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
26251
|
}
|
|
25765
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
26252
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _367 => _367.scans, 'access', _368 => _368[mapping.para.sectionIndex], 'optionalAccess', _369 => _369.xml]));
|
|
25766
26253
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25767
26254
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25768
26255
|
return 1;
|
|
25769
26256
|
}
|
|
25770
26257
|
}, _class5);
|
|
25771
26258
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
25772
|
-
const irCell = _optionalChain([table, 'access',
|
|
26259
|
+
const irCell = _optionalChain([table, 'access', _370 => _370.cells, 'access', _371 => _371[r], 'optionalAccess', _372 => _372[c]]);
|
|
25773
26260
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
25774
26261
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
25775
26262
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -25853,11 +26340,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
25853
26340
|
breaks: false
|
|
25854
26341
|
});
|
|
25855
26342
|
function renderHtml(markdown, options) {
|
|
25856
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25857
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26343
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _373 => _373.preset]), () => ( "default"));
|
|
26344
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.extraCss]), () => ( "")));
|
|
25858
26345
|
const body = md.render(markdown);
|
|
25859
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
25860
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
26346
|
+
const watermark = _optionalChain([options, 'optionalAccess', _375 => _375.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
26347
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _376 => _376.watermark]) ? `
|
|
25861
26348
|
.watermark {
|
|
25862
26349
|
position: fixed;
|
|
25863
26350
|
top: 50%; left: 50%;
|
|
@@ -25888,13 +26375,13 @@ async function htmlToPdf(html, options) {
|
|
|
25888
26375
|
try {
|
|
25889
26376
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
25890
26377
|
} catch (e30) {
|
|
25891
|
-
throw new (0,
|
|
26378
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
25892
26379
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
25893
26380
|
);
|
|
25894
26381
|
}
|
|
25895
26382
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
25896
26383
|
if (!executablePath) {
|
|
25897
|
-
throw new (0,
|
|
26384
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
25898
26385
|
"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
26386
|
);
|
|
25900
26387
|
}
|
|
@@ -25906,10 +26393,10 @@ async function htmlToPdf(html, options) {
|
|
|
25906
26393
|
try {
|
|
25907
26394
|
const page = await browser.newPage();
|
|
25908
26395
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
25909
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
26396
|
+
const margin = _optionalChain([options, 'optionalAccess', _377 => _377.margin]);
|
|
25910
26397
|
const pdf = await page.pdf({
|
|
25911
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25912
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
26398
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _378 => _378.pageSize]), () => ( "A4")),
|
|
26399
|
+
landscape: _optionalChain([options, 'optionalAccess', _379 => _379.orientation]) === "landscape",
|
|
25913
26400
|
printBackground: true,
|
|
25914
26401
|
margin: margin ? {
|
|
25915
26402
|
top: toCss(margin.top),
|
|
@@ -25917,9 +26404,9 @@ async function htmlToPdf(html, options) {
|
|
|
25917
26404
|
bottom: toCss(margin.bottom),
|
|
25918
26405
|
left: toCss(margin.left)
|
|
25919
26406
|
} : void 0,
|
|
25920
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
25921
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25922
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26407
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _380 => _380.header]) || _optionalChain([options, 'optionalAccess', _381 => _381.footer])),
|
|
26408
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _382 => _382.header]), () => ( "<div></div>")),
|
|
26409
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _383 => _383.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
25923
26410
|
});
|
|
25924
26411
|
return Buffer.from(pdf);
|
|
25925
26412
|
} finally {
|
|
@@ -25953,7 +26440,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
25953
26440
|
return htmlToPdf(html, options);
|
|
25954
26441
|
}
|
|
25955
26442
|
async function blocksToPdf(blocks, options) {
|
|
25956
|
-
const markdown =
|
|
26443
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
25957
26444
|
return markdownToPdf(markdown, options);
|
|
25958
26445
|
}
|
|
25959
26446
|
|
|
@@ -26047,7 +26534,7 @@ function elements(el) {
|
|
|
26047
26534
|
for (let i = 0; i < kids2.length; i++) if (kids2[i].nodeType === 1) out.push(kids2[i]);
|
|
26048
26535
|
return out;
|
|
26049
26536
|
}
|
|
26050
|
-
function
|
|
26537
|
+
function num2(el, attr, fallback = 0) {
|
|
26051
26538
|
return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
|
|
26052
26539
|
}
|
|
26053
26540
|
function shiftParaVert(p, delta) {
|
|
@@ -26055,7 +26542,7 @@ function shiftParaVert(p, delta) {
|
|
|
26055
26542
|
if (ln(lsa) !== "linesegarray") continue;
|
|
26056
26543
|
for (const seg of elements(lsa)) {
|
|
26057
26544
|
if (ln(seg) !== "lineseg") continue;
|
|
26058
|
-
seg.setAttribute("vertpos", String(
|
|
26545
|
+
seg.setAttribute("vertpos", String(num2(seg, "vertpos") + delta));
|
|
26059
26546
|
}
|
|
26060
26547
|
}
|
|
26061
26548
|
}
|
|
@@ -26145,9 +26632,9 @@ function reflowTablesIn(p, doc, styles, mode, counter) {
|
|
|
26145
26632
|
if (ln(tc) !== "tc") continue;
|
|
26146
26633
|
const csz = findChildByLocalName(tc, "cellSz");
|
|
26147
26634
|
const cm = findChildByLocalName(tc, "cellMargin");
|
|
26148
|
-
const cellW =
|
|
26149
|
-
const mL = cm ?
|
|
26150
|
-
const mR = cm ?
|
|
26635
|
+
const cellW = num2(csz, "width");
|
|
26636
|
+
const mL = cm ? num2(cm, "left", 141) : 141;
|
|
26637
|
+
const mR = cm ? num2(cm, "right", 141) : 141;
|
|
26151
26638
|
const areaW = Math.max(500, cellW - mL - mR);
|
|
26152
26639
|
const sub = findChildByLocalName(tc, "subList");
|
|
26153
26640
|
if (sub) reflowBlockFlow(sub, doc, styles, areaW, mode, counter, 0);
|
|
@@ -26163,7 +26650,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
26163
26650
|
if (ln(p) !== "p") continue;
|
|
26164
26651
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
26165
26652
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
26166
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
26653
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _384 => _384.spaceBefore]), () => ( 0)));
|
|
26167
26654
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
26168
26655
|
if (res) {
|
|
26169
26656
|
const paraH = res.paraBottom - startV;
|
|
@@ -26198,7 +26685,7 @@ function elements2(el) {
|
|
|
26198
26685
|
}
|
|
26199
26686
|
return out;
|
|
26200
26687
|
}
|
|
26201
|
-
function
|
|
26688
|
+
function num3(el, attr, fallback = 0) {
|
|
26202
26689
|
return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
|
|
26203
26690
|
}
|
|
26204
26691
|
function findFirst(el, name, depth = 0) {
|
|
@@ -26266,13 +26753,13 @@ function buildPara(p) {
|
|
|
26266
26753
|
} else if (OBJ_TAGS.has(cn)) {
|
|
26267
26754
|
const sz = findChildByLocalName(ch, "sz");
|
|
26268
26755
|
const pos = findChildByLocalName(ch, "pos");
|
|
26269
|
-
const w =
|
|
26270
|
-
const h =
|
|
26756
|
+
const w = num3(sz, "width") || num3(findChildByLocalName(ch, "curSz"), "width") || num3(findChildByLocalName(ch, "orgSz"), "width");
|
|
26757
|
+
const h = num3(sz, "height") || num3(findChildByLocalName(ch, "curSz"), "height") || num3(findChildByLocalName(ch, "orgSz"), "height");
|
|
26271
26758
|
objs.push({
|
|
26272
26759
|
el: ch,
|
|
26273
26760
|
tag: cn,
|
|
26274
26761
|
index: chars.length,
|
|
26275
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
26762
|
+
inline: _optionalChain([pos, 'optionalAccess', _385 => _385.getAttribute, 'call', _386 => _386("treatAsChar")]) === "1",
|
|
26276
26763
|
width: w,
|
|
26277
26764
|
height: h
|
|
26278
26765
|
});
|
|
@@ -26283,12 +26770,12 @@ function buildPara(p) {
|
|
|
26283
26770
|
}
|
|
26284
26771
|
} else if (tag === "linesegarray") {
|
|
26285
26772
|
segs = elements2(runEl).filter((s) => ln2(s) === "lineseg").map((s) => ({
|
|
26286
|
-
textpos:
|
|
26287
|
-
vertpos:
|
|
26288
|
-
horzpos:
|
|
26289
|
-
horzsize:
|
|
26290
|
-
textheight:
|
|
26291
|
-
baseline:
|
|
26773
|
+
textpos: num3(s, "textpos"),
|
|
26774
|
+
vertpos: num3(s, "vertpos"),
|
|
26775
|
+
horzpos: num3(s, "horzpos"),
|
|
26776
|
+
horzsize: num3(s, "horzsize"),
|
|
26777
|
+
textheight: num3(s, "textheight", 1e3),
|
|
26778
|
+
baseline: num3(s, "baseline", 850)
|
|
26292
26779
|
}));
|
|
26293
26780
|
}
|
|
26294
26781
|
}
|
|
@@ -26458,11 +26945,11 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx) {
|
|
|
26458
26945
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
|
|
26459
26946
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26460
26947
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26461
|
-
const omT =
|
|
26948
|
+
const omT = num3(om, "top"), omB = num3(om, "bottom");
|
|
26462
26949
|
const w = o.width, h = o.height;
|
|
26463
26950
|
if (!pos) return { x: ox, y: oy + baseV };
|
|
26464
|
-
const vo =
|
|
26465
|
-
const ho =
|
|
26951
|
+
const vo = num3(pos, "vertOffset");
|
|
26952
|
+
const ho = num3(pos, "horzOffset");
|
|
26466
26953
|
const vrel = _nullishCoalesce(pos.getAttribute("vertRelTo"), () => ( "PARA"));
|
|
26467
26954
|
const hrel = _nullishCoalesce(pos.getAttribute("horzRelTo"), () => ( "PARA"));
|
|
26468
26955
|
const va = _nullishCoalesce(pos.getAttribute("vertAlign"), () => ( "TOP"));
|
|
@@ -26499,8 +26986,8 @@ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
|
|
|
26499
26986
|
if (!OBJ_TAGS.has(tag)) continue;
|
|
26500
26987
|
const sz = findChildByLocalName(ch, "sz");
|
|
26501
26988
|
const off = findChildByLocalName(ch, "offset");
|
|
26502
|
-
const sub = { el: ch, tag, index: 0, inline: true, width:
|
|
26503
|
-
drawObject(sub, x +
|
|
26989
|
+
const sub = { el: ch, tag, index: 0, inline: true, width: num3(sz, "width"), height: num3(sz, "height") };
|
|
26990
|
+
drawObject(sub, x + num3(off, "x"), y + num3(off, "y"), baseV, areaW, ctx, depth + 1);
|
|
26504
26991
|
}
|
|
26505
26992
|
} else if (o.tag === "equation") {
|
|
26506
26993
|
warnOnce(ctx, "equation", "\uC218\uC2DD \uAC1C\uCCB4\uB294 \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5");
|
|
@@ -26518,21 +27005,21 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26518
27005
|
const el = o.el;
|
|
26519
27006
|
const orgSz = findChildByLocalName(el, "orgSz");
|
|
26520
27007
|
const curSz = findChildByLocalName(el, "curSz");
|
|
26521
|
-
const ow =
|
|
26522
|
-
const w =
|
|
26523
|
-
const h =
|
|
27008
|
+
const ow = num3(orgSz, "width"), oh = num3(orgSz, "height");
|
|
27009
|
+
const w = num3(curSz, "width") || ow || o.width;
|
|
27010
|
+
const h = num3(curSz, "height") || oh || o.height;
|
|
26524
27011
|
const sx = ow > 0 ? w / ow : 1;
|
|
26525
27012
|
const sy = oh > 0 ? h / oh : 1;
|
|
26526
27013
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
26527
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
26528
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
27014
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _387 => _387.getAttribute, 'call', _388 => _388("style")]), () => ( "SOLID"));
|
|
27015
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _389 => _389.getAttribute, 'call', _390 => _390("color")]) || "#000000";
|
|
26529
27016
|
const hasStroke = lstyle !== "NONE";
|
|
26530
|
-
const strokeW = hasStroke ? shapeStrokePt(lineShape ?
|
|
27017
|
+
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
26531
27018
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
26532
27019
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
26533
27020
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26534
27021
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26535
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
27022
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _391 => _391.getAttribute, 'call', _392 => _392("faceColor")]);
|
|
26536
27023
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
26537
27024
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
26538
27025
|
if (o.tag === "rect") {
|
|
@@ -26541,12 +27028,12 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26541
27028
|
emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fillAttr}${strokeAttr}/>`);
|
|
26542
27029
|
} else if (o.tag === "line") {
|
|
26543
27030
|
const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
|
|
26544
|
-
const x1 = x +
|
|
26545
|
-
const x2 = x +
|
|
27031
|
+
const x1 = x + num3(s, "x") * sx, y1 = y + num3(s, "y") * sy;
|
|
27032
|
+
const x2 = x + num3(e, "x") * sx, y2 = y + num3(e, "y") * sy;
|
|
26546
27033
|
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
27034
|
} else if (o.tag === "polygon" || o.tag === "curv") {
|
|
26548
27035
|
const pts = [];
|
|
26549
|
-
for (const c of elements2(el)) if (ln2(c) === "pt") pts.push(`${pt(x +
|
|
27036
|
+
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
27037
|
if (pts.length >= 2) emit(ctx, `<polygon points="${pts.join(" ")}"${fillAttr}${strokeAttr}/>`);
|
|
26551
27038
|
} else if (o.tag === "arc") {
|
|
26552
27039
|
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 +27051,7 @@ function cellContentExtent(cell) {
|
|
|
26564
27051
|
if (ln2(p) !== "p") continue;
|
|
26565
27052
|
const m = buildPara(p);
|
|
26566
27053
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
26567
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
27054
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _393 => _393.segs, 'access', _394 => _394[0], 'optionalAccess', _395 => _395.vertpos]), () => ( 0));
|
|
26568
27055
|
for (const o of m.objs) {
|
|
26569
27056
|
if (o.inline) {
|
|
26570
27057
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -26572,11 +27059,11 @@ function cellContentExtent(cell) {
|
|
|
26572
27059
|
continue;
|
|
26573
27060
|
}
|
|
26574
27061
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26575
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
27062
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _396 => _396.getAttribute, 'call', _397 => _397("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
26576
27063
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26577
|
-
const pushed = baseV - (
|
|
27064
|
+
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
26578
27065
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
26579
|
-
ext = Math.max(ext, anchor +
|
|
27066
|
+
ext = Math.max(ext, anchor + num3(om, "top") + num3(pos, "vertOffset") + o.height);
|
|
26580
27067
|
}
|
|
26581
27068
|
}
|
|
26582
27069
|
return ext;
|
|
@@ -26587,8 +27074,8 @@ function edgeLine(x1, y1, x2, y2, e) {
|
|
|
26587
27074
|
}
|
|
26588
27075
|
function collectCells(tbl) {
|
|
26589
27076
|
const inMargin = findChildByLocalName(tbl, "inMargin");
|
|
26590
|
-
const defL =
|
|
26591
|
-
const defT =
|
|
27077
|
+
const defL = num3(inMargin, "left", 141), defR = num3(inMargin, "right", 141);
|
|
27078
|
+
const defT = num3(inMargin, "top", 141), defB = num3(inMargin, "bottom", 141);
|
|
26592
27079
|
const cells = [];
|
|
26593
27080
|
for (const tr of elements2(tbl)) {
|
|
26594
27081
|
if (ln2(tr) !== "tr") continue;
|
|
@@ -26601,18 +27088,18 @@ function collectCells(tbl) {
|
|
|
26601
27088
|
if (!addr || !csz) continue;
|
|
26602
27089
|
cells.push({
|
|
26603
27090
|
el: tc,
|
|
26604
|
-
ca:
|
|
26605
|
-
ra:
|
|
26606
|
-
cs: Math.max(1,
|
|
26607
|
-
rs: Math.max(1,
|
|
26608
|
-
w:
|
|
26609
|
-
h:
|
|
27091
|
+
ca: num3(addr, "colAddr"),
|
|
27092
|
+
ra: num3(addr, "rowAddr"),
|
|
27093
|
+
cs: Math.max(1, num3(span, "colSpan", 1)),
|
|
27094
|
+
rs: Math.max(1, num3(span, "rowSpan", 1)),
|
|
27095
|
+
w: num3(csz, "width"),
|
|
27096
|
+
h: num3(csz, "height"),
|
|
26610
27097
|
bfId: tc.getAttribute("borderFillIDRef"),
|
|
26611
27098
|
sub: findChildByLocalName(tc, "subList"),
|
|
26612
|
-
marginL: cm ?
|
|
26613
|
-
marginR: cm ?
|
|
26614
|
-
marginT: cm ?
|
|
26615
|
-
marginB: cm ?
|
|
27099
|
+
marginL: cm ? num3(cm, "left", defL) : defL,
|
|
27100
|
+
marginR: cm ? num3(cm, "right", defR) : defR,
|
|
27101
|
+
marginT: cm ? num3(cm, "top", defT) : defT,
|
|
27102
|
+
marginB: cm ? num3(cm, "bottom", defB) : defB
|
|
26616
27103
|
});
|
|
26617
27104
|
}
|
|
26618
27105
|
}
|
|
@@ -26642,7 +27129,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26642
27129
|
const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
|
|
26643
27130
|
const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
|
|
26644
27131
|
const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
|
|
26645
|
-
const colX = solveBoundaries(colCons, nCols,
|
|
27132
|
+
const colX = solveBoundaries(colCons, nCols, num3(tblSz, "width") || void 0);
|
|
26646
27133
|
const rowH = solveRowHeights(
|
|
26647
27134
|
cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
|
|
26648
27135
|
nRows
|
|
@@ -26658,7 +27145,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26658
27145
|
}));
|
|
26659
27146
|
for (const g of geom) {
|
|
26660
27147
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
26661
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
27148
|
+
if (_optionalChain([bf, 'optionalAccess', _398 => _398.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
27149
|
}
|
|
26663
27150
|
for (const g of geom) {
|
|
26664
27151
|
const { c } = g;
|
|
@@ -26694,9 +27181,9 @@ function imageSymbol(loaded, ctx) {
|
|
|
26694
27181
|
}
|
|
26695
27182
|
function drawPic(pic, x, y, ctx) {
|
|
26696
27183
|
const sz = findChildByLocalName(pic, "sz");
|
|
26697
|
-
const w =
|
|
27184
|
+
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
26698
27185
|
const img = findFirst(pic, "img");
|
|
26699
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
27186
|
+
const ref = _optionalChain([img, 'optionalAccess', _399 => _399.getAttribute, 'call', _400 => _400("binaryItemIDRef")]);
|
|
26700
27187
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
26701
27188
|
if (!loaded) {
|
|
26702
27189
|
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 +27194,11 @@ function drawPic(pic, x, y, ctx) {
|
|
|
26707
27194
|
const clip = findChildByLocalName(pic, "imgClip");
|
|
26708
27195
|
const imgDim = findChildByLocalName(pic, "imgDim");
|
|
26709
27196
|
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 =
|
|
27197
|
+
const dimW = num3(imgDim, "dimwidth"), dimH = num3(imgDim, "dimheight");
|
|
27198
|
+
const refW = dimW > 0 ? dimW : num3(orgSz, "width");
|
|
27199
|
+
const refH = dimH > 0 ? dimH : num3(orgSz, "height");
|
|
27200
|
+
const cl = num3(clip, "left"), ct = num3(clip, "top");
|
|
27201
|
+
const cr = num3(clip, "right", refW), cb = num3(clip, "bottom", refH);
|
|
26715
27202
|
const cropped = refW > 0 && refH > 0 && clip != null && (cl > 0 || ct > 0 || cr < refW || cb < refH) && cr > cl && cb > ct;
|
|
26716
27203
|
const symId = imageSymbol(loaded, ctx);
|
|
26717
27204
|
if (cropped) {
|
|
@@ -26734,23 +27221,23 @@ function sniffMime(name, bytes) {
|
|
|
26734
27221
|
function readSectionGeom(root) {
|
|
26735
27222
|
const pagePr = findFirst(root, "pagePr");
|
|
26736
27223
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
26737
|
-
let PW =
|
|
26738
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
27224
|
+
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
27225
|
+
if (_optionalChain([pagePr, 'optionalAccess', _401 => _401.getAttribute, 'call', _402 => _402("landscape")]) === "NARROWLY" && PW < PH) {
|
|
26739
27226
|
const t = PW;
|
|
26740
27227
|
PW = PH;
|
|
26741
27228
|
PH = t;
|
|
26742
27229
|
}
|
|
26743
|
-
const ML =
|
|
26744
|
-
const MT =
|
|
26745
|
-
const BODY_H = PH - MT -
|
|
26746
|
-
const BODY_W = PW - ML -
|
|
27230
|
+
const ML = num3(margin, "left", 8504);
|
|
27231
|
+
const MT = num3(margin, "top", 5668) + num3(margin, "header", 0);
|
|
27232
|
+
const BODY_H = PH - MT - num3(margin, "bottom", 4252) - num3(margin, "footer", 0);
|
|
27233
|
+
const BODY_W = PW - ML - num3(margin, "right", 8504);
|
|
26747
27234
|
return { PW, PH, ML, MT, BODY_W, BODY_H };
|
|
26748
27235
|
}
|
|
26749
27236
|
function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
26750
27237
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = geom;
|
|
26751
27238
|
if (!hasCache) reflowSection(root, ctxBase.styles, { BODY_W, BODY_H }, reflowMode);
|
|
26752
27239
|
const colPr = findFirst(root, "colPr");
|
|
26753
|
-
const multiCol =
|
|
27240
|
+
const multiCol = num3(colPr, "colCount", 1) > 1;
|
|
26754
27241
|
const paraSegPages = /* @__PURE__ */ new Map();
|
|
26755
27242
|
let nPages = 1;
|
|
26756
27243
|
let maxTopV = 0;
|
|
@@ -26765,13 +27252,13 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
26765
27252
|
const pagesOf = [];
|
|
26766
27253
|
let paraFirst = true;
|
|
26767
27254
|
for (const s of segEls) {
|
|
26768
|
-
const v =
|
|
26769
|
-
const h =
|
|
27255
|
+
const v = num3(s, "vertpos");
|
|
27256
|
+
const h = num3(s, "horzpos");
|
|
26770
27257
|
const brk = v < prevV ? !multiCol || h <= prevH : paraFirst && v === prevV && h <= prevH;
|
|
26771
27258
|
if (brk) cur++;
|
|
26772
27259
|
paraFirst = false;
|
|
26773
27260
|
pagesOf.push(cur);
|
|
26774
|
-
maxTopV = Math.max(maxTopV, v +
|
|
27261
|
+
maxTopV = Math.max(maxTopV, v + num3(s, "textheight", 1e3));
|
|
26775
27262
|
prevV = v;
|
|
26776
27263
|
prevH = h;
|
|
26777
27264
|
}
|
|
@@ -26793,17 +27280,17 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
26793
27280
|
return { pages: ctx.pages, pageH };
|
|
26794
27281
|
}
|
|
26795
27282
|
async function renderHwpxToSvg(input, options) {
|
|
26796
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27283
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _403 => _403.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
26797
27284
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
26798
|
-
|
|
27285
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
26799
27286
|
let zip;
|
|
26800
27287
|
try {
|
|
26801
27288
|
zip = await _jszip2.default.loadAsync(input);
|
|
26802
27289
|
} catch (e31) {
|
|
26803
|
-
throw new (0,
|
|
27290
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
26804
27291
|
}
|
|
26805
27292
|
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,
|
|
27293
|
+
if (secFiles.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
26807
27294
|
const warnings = [];
|
|
26808
27295
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
26809
27296
|
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 +27298,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26811
27298
|
const secXmls = [];
|
|
26812
27299
|
for (const f of secFiles) {
|
|
26813
27300
|
const xml = await f.async("string");
|
|
26814
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
27301
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
26815
27302
|
secXmls.push(xml);
|
|
26816
27303
|
}
|
|
26817
27304
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -26835,7 +27322,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26835
27322
|
let href = binmap.get(ref);
|
|
26836
27323
|
if (!href) {
|
|
26837
27324
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
26838
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
27325
|
+
href = _optionalChain([cand, 'optionalAccess', _404 => _404.name]);
|
|
26839
27326
|
}
|
|
26840
27327
|
if (!href) continue;
|
|
26841
27328
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -26856,7 +27343,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26856
27343
|
styles,
|
|
26857
27344
|
images,
|
|
26858
27345
|
defs: [],
|
|
26859
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27346
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _405 => _405.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
26860
27347
|
warnings,
|
|
26861
27348
|
warned: /* @__PURE__ */ new Set(),
|
|
26862
27349
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -26866,7 +27353,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26866
27353
|
for (let si = 0; si < secXmls.length; si++) {
|
|
26867
27354
|
const secXml = secXmls[si];
|
|
26868
27355
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
26869
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
27356
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _406 => _406.reflow])) {
|
|
26870
27357
|
noCacheSkipped = true;
|
|
26871
27358
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
26872
27359
|
continue;
|
|
@@ -26878,14 +27365,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26878
27365
|
continue;
|
|
26879
27366
|
}
|
|
26880
27367
|
const geom = readSectionGeom(root);
|
|
26881
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27368
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _407 => _407.reflowMode]), () => ( "keep")));
|
|
26882
27369
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
26883
27370
|
}
|
|
26884
27371
|
if (rendered.length === 0) {
|
|
26885
27372
|
if (noCacheSkipped) {
|
|
26886
|
-
throw new (0,
|
|
27373
|
+
throw new (0, _chunkR2H34FY5cjs.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
27374
|
}
|
|
26888
|
-
throw new (0,
|
|
27375
|
+
throw new (0, _chunkR2H34FY5cjs.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
27376
|
}
|
|
26890
27377
|
const GAP = 2400;
|
|
26891
27378
|
const clipDefs = [];
|
|
@@ -26917,17 +27404,17 @@ ${groups.join("\n")}
|
|
|
26917
27404
|
// src/index.ts
|
|
26918
27405
|
async function parse(input, options) {
|
|
26919
27406
|
let buffer;
|
|
26920
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
27407
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _408 => _408.filePath]) ? { ...options, filePath: input } : options;
|
|
26921
27408
|
if (typeof input === "string") {
|
|
26922
27409
|
try {
|
|
26923
27410
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26924
|
-
buffer =
|
|
27411
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, buf);
|
|
26925
27412
|
} catch (err) {
|
|
26926
27413
|
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
27414
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
26928
27415
|
}
|
|
26929
27416
|
} else if (Buffer.isBuffer(input)) {
|
|
26930
|
-
buffer =
|
|
27417
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, input);
|
|
26931
27418
|
} else {
|
|
26932
27419
|
buffer = input;
|
|
26933
27420
|
}
|
|
@@ -26962,21 +27449,21 @@ async function parseHwp3(buffer, options) {
|
|
|
26962
27449
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
26963
27450
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
26964
27451
|
} catch (err) {
|
|
26965
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27452
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
26966
27453
|
}
|
|
26967
27454
|
}
|
|
26968
27455
|
async function parseHwpx(buffer, options) {
|
|
26969
27456
|
try {
|
|
26970
27457
|
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',
|
|
27458
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _409 => _409.length]) ? images : void 0 };
|
|
26972
27459
|
} catch (err) {
|
|
26973
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27460
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
26974
27461
|
}
|
|
26975
27462
|
}
|
|
26976
27463
|
async function parseHwp(buffer, options) {
|
|
26977
27464
|
try {
|
|
26978
27465
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
26979
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
27466
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _410 => _410.filePath])) {
|
|
26980
27467
|
try {
|
|
26981
27468
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
26982
27469
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -26993,15 +27480,15 @@ async function parseHwp(buffer, options) {
|
|
|
26993
27480
|
} catch (e32) {
|
|
26994
27481
|
}
|
|
26995
27482
|
}
|
|
26996
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27483
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _411 => _411.length]) ? images : void 0 };
|
|
26997
27484
|
} catch (err) {
|
|
26998
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27485
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
26999
27486
|
}
|
|
27000
27487
|
}
|
|
27001
27488
|
async function parsePdf(buffer, options) {
|
|
27002
27489
|
let parsePdfDocument;
|
|
27003
27490
|
try {
|
|
27004
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
27491
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-XEY5MRGV.cjs")));
|
|
27005
27492
|
parsePdfDocument = mod.parsePdfDocument;
|
|
27006
27493
|
} catch (e33) {
|
|
27007
27494
|
return {
|
|
@@ -27016,7 +27503,7 @@ async function parsePdf(buffer, options) {
|
|
|
27016
27503
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
27017
27504
|
} catch (err) {
|
|
27018
27505
|
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:
|
|
27506
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err), isImageBased };
|
|
27020
27507
|
}
|
|
27021
27508
|
}
|
|
27022
27509
|
async function parseXlsx(buffer, options) {
|
|
@@ -27024,7 +27511,7 @@ async function parseXlsx(buffer, options) {
|
|
|
27024
27511
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
27025
27512
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
27026
27513
|
} catch (err) {
|
|
27027
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27514
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27028
27515
|
}
|
|
27029
27516
|
}
|
|
27030
27517
|
async function parseXls(buffer, options) {
|
|
@@ -27032,15 +27519,15 @@ async function parseXls(buffer, options) {
|
|
|
27032
27519
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
27033
27520
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
27034
27521
|
} catch (err) {
|
|
27035
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27522
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27036
27523
|
}
|
|
27037
27524
|
}
|
|
27038
27525
|
async function parseDocx(buffer, options) {
|
|
27039
27526
|
try {
|
|
27040
27527
|
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',
|
|
27528
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _412 => _412.length]) ? images : void 0 };
|
|
27042
27529
|
} catch (err) {
|
|
27043
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27530
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27044
27531
|
}
|
|
27045
27532
|
}
|
|
27046
27533
|
async function parseHwpml(buffer, options) {
|
|
@@ -27048,16 +27535,16 @@ async function parseHwpml(buffer, options) {
|
|
|
27048
27535
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
27049
27536
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
27050
27537
|
} catch (err) {
|
|
27051
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27538
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27052
27539
|
}
|
|
27053
27540
|
}
|
|
27054
27541
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
27055
27542
|
let buffer;
|
|
27056
27543
|
if (typeof input === "string") {
|
|
27057
27544
|
const buf = await _promises.readFile.call(void 0, input);
|
|
27058
|
-
buffer =
|
|
27545
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, buf);
|
|
27059
27546
|
} else if (Buffer.isBuffer(input)) {
|
|
27060
|
-
buffer =
|
|
27547
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, input);
|
|
27061
27548
|
} else {
|
|
27062
27549
|
buffer = input;
|
|
27063
27550
|
}
|
|
@@ -27083,7 +27570,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27083
27570
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
27084
27571
|
}
|
|
27085
27572
|
const fill = fillFormFields(parsed.blocks, values);
|
|
27086
|
-
const markdown =
|
|
27573
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
27087
27574
|
if (outputFormat === "hwpx") {
|
|
27088
27575
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
27089
27576
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -27146,5 +27633,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27146
27633
|
|
|
27147
27634
|
|
|
27148
27635
|
|
|
27149
|
-
|
|
27636
|
+
|
|
27637
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkR2H34FY5cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkR2H34FY5cjs.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
27638
|
//# sourceMappingURL=index.cjs.map
|