kordoc 3.16.0 → 3.16.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 +1 -1
- package/dist/{-H7N62NZU.js → -YVONYEEN.js} +7 -7
- package/dist/{chunk-FGL7BH4P.js → chunk-7WUTJXKP.js} +49 -20
- package/dist/chunk-7WUTJXKP.js.map +1 -0
- package/dist/{chunk-5RHRQ7HK.js → chunk-CDFCA37S.js} +8 -4
- package/dist/chunk-CDFCA37S.js.map +1 -0
- package/dist/{chunk-LYL4IL3E.js → chunk-F62GOZFB.js} +13 -6
- package/dist/chunk-F62GOZFB.js.map +1 -0
- package/dist/{chunk-WD5NUUU6.js → chunk-I6T3DKYK.js} +315 -262
- package/dist/chunk-I6T3DKYK.js.map +1 -0
- package/dist/{chunk-JFNWJFKP.js → chunk-IY3NX4FT.js} +2 -2
- package/dist/{chunk-IC56KHBL.js → chunk-K4L563FA.js} +2 -2
- package/dist/{chunk-Q7EGGW3H.js → chunk-QOPY6URE.js} +13 -6
- package/dist/chunk-QOPY6URE.js.map +1 -0
- package/dist/{chunk-BIP4JAVG.cjs → chunk-VNIQK4AL.cjs} +13 -6
- package/dist/chunk-VNIQK4AL.cjs.map +1 -0
- package/dist/cli.js +56 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +586 -502
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +358 -274
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +25 -16
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-6V7F3GET.cjs → parser-3O2UF6VO.cjs} +35 -22
- package/dist/parser-3O2UF6VO.cjs.map +1 -0
- package/dist/{parser-HBHCD7TE.js → parser-B4O7CW5Q.js} +24 -11
- package/dist/parser-B4O7CW5Q.js.map +1 -0
- package/dist/{parser-5G247XYD.js → parser-BNEAMKUF.js} +23 -10
- package/dist/parser-BNEAMKUF.js.map +1 -0
- package/dist/render-QCNMRR7L.js +10 -0
- package/dist/seal-REDSMUI5.js +10 -0
- package/dist/{watch-HIYNOSFD.js → watch-RLF5F3TN.js} +7 -7
- package/package.json +2 -5
- package/dist/chunk-5RHRQ7HK.js.map +0 -1
- package/dist/chunk-BIP4JAVG.cjs.map +0 -1
- package/dist/chunk-FGL7BH4P.js.map +0 -1
- package/dist/chunk-LYL4IL3E.js.map +0 -1
- package/dist/chunk-Q7EGGW3H.js.map +0 -1
- package/dist/chunk-WD5NUUU6.js.map +0 -1
- package/dist/parser-5G247XYD.js.map +0 -1
- package/dist/parser-6V7F3GET.cjs.map +0 -1
- package/dist/parser-HBHCD7TE.js.map +0 -1
- package/dist/render-VA4NHROW.js +0 -10
- package/dist/seal-UVDRGHEF.js +0 -10
- /package/dist/{-H7N62NZU.js.map → -YVONYEEN.js.map} +0 -0
- /package/dist/{chunk-JFNWJFKP.js.map → chunk-IY3NX4FT.js.map} +0 -0
- /package/dist/{chunk-IC56KHBL.js.map → chunk-K4L563FA.js.map} +0 -0
- /package/dist/{render-VA4NHROW.js.map → render-QCNMRR7L.js.map} +0 -0
- /package/dist/{seal-UVDRGHEF.js.map → seal-REDSMUI5.js.map} +0 -0
- /package/dist/{watch-HIYNOSFD.js.map → watch-RLF5F3TN.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkVNIQK4ALcjs = require('./chunk-VNIQK4AL.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -405,7 +405,7 @@ function createSectionShared() {
|
|
|
405
405
|
function createXmlParser(warnings) {
|
|
406
406
|
return new (0, _xmldom.DOMParser)({
|
|
407
407
|
onError(level, msg2) {
|
|
408
|
-
if (level === "fatalError") throw new (0,
|
|
408
|
+
if (level === "fatalError") throw new (0, _chunkVNIQK4ALcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
409
409
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
410
410
|
}
|
|
411
411
|
});
|
|
@@ -460,10 +460,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
460
460
|
const xml = await file.async("text");
|
|
461
461
|
if (decompressed) {
|
|
462
462
|
decompressed.total += xml.length * 2;
|
|
463
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
463
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
464
464
|
}
|
|
465
465
|
const parser = createXmlParser();
|
|
466
|
-
const doc = parser.parseFromString(
|
|
466
|
+
const doc = parser.parseFromString(_chunkVNIQK4ALcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
467
467
|
if (!doc.documentElement) continue;
|
|
468
468
|
parseCharProperties(doc, result.charProperties);
|
|
469
469
|
parseStyleElements(doc, result.styles);
|
|
@@ -615,9 +615,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
615
615
|
let level = 0;
|
|
616
616
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
|
|
617
617
|
const ratio = block.style.fontSize / baseFontSize;
|
|
618
|
-
if (ratio >=
|
|
619
|
-
else if (ratio >=
|
|
620
|
-
else if (ratio >=
|
|
618
|
+
if (ratio >= _chunkVNIQK4ALcjs.HEADING_RATIO_H1) level = 1;
|
|
619
|
+
else if (ratio >= _chunkVNIQK4ALcjs.HEADING_RATIO_H2) level = 2;
|
|
620
|
+
else if (ratio >= _chunkVNIQK4ALcjs.HEADING_RATIO_H3) level = 3;
|
|
621
621
|
}
|
|
622
622
|
const compactText = text.replace(/\s+/g, "");
|
|
623
623
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -929,8 +929,8 @@ function maskLiteralSpans(eqString) {
|
|
|
929
929
|
function findKeywordToken(eqString, word, from = 0) {
|
|
930
930
|
const masked = maskLiteralSpans(eqString);
|
|
931
931
|
for (let i = masked.indexOf(word, from); i !== -1; i = masked.indexOf(word, i + 1)) {
|
|
932
|
-
const okL = i === 0 || masked[i - 1]
|
|
933
|
-
const okR = i + word.length === masked.length || masked[i + word.length]
|
|
932
|
+
const okL = i === 0 || /\s/.test(masked[i - 1]);
|
|
933
|
+
const okR = i + word.length === masked.length || /\s/.test(masked[i + word.length]);
|
|
934
934
|
if (okL && okR) return i;
|
|
935
935
|
}
|
|
936
936
|
return -1;
|
|
@@ -941,11 +941,22 @@ function replaceFrac(eqString) {
|
|
|
941
941
|
const cursor = findKeywordToken(eqString, hmlFrac);
|
|
942
942
|
if (cursor === -1) break;
|
|
943
943
|
try {
|
|
944
|
-
|
|
945
|
-
|
|
944
|
+
let end = cursor;
|
|
945
|
+
while (end > 0 && /\s/.test(eqString[end - 1])) end--;
|
|
946
|
+
let numStart, numEnd, wrapped;
|
|
947
|
+
if (end > 0 && eqString[end - 1] === "}") {
|
|
948
|
+
[numStart, numEnd] = findBrackets(eqString, end - 1, 0);
|
|
949
|
+
wrapped = eqString.slice(numStart, numEnd);
|
|
950
|
+
} else {
|
|
951
|
+
numEnd = end;
|
|
952
|
+
numStart = end;
|
|
953
|
+
while (numStart > 0 && !/\s/.test(eqString[numStart - 1])) numStart--;
|
|
954
|
+
if (numStart === numEnd) throw new Error("empty numerator");
|
|
955
|
+
wrapped = "{" + eqString.slice(numStart, numEnd) + "}";
|
|
956
|
+
}
|
|
946
957
|
const beforeFrac = eqString.slice(0, numStart);
|
|
947
958
|
const afterFrac = eqString.slice(cursor + hmlFrac.length);
|
|
948
|
-
eqString = beforeFrac + "\\frac" +
|
|
959
|
+
eqString = beforeFrac + "\\frac" + wrapped + afterFrac;
|
|
949
960
|
} catch (e7) {
|
|
950
961
|
return eqString;
|
|
951
962
|
}
|
|
@@ -1183,7 +1194,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1183
1194
|
|
|
1184
1195
|
// src/hwpx/table-build.ts
|
|
1185
1196
|
function buildTableWithCellMeta(state) {
|
|
1186
|
-
const table =
|
|
1197
|
+
const table = _chunkVNIQK4ALcjs.buildTable.call(void 0, state.rows);
|
|
1187
1198
|
if (state.caption) table.caption = state.caption;
|
|
1188
1199
|
const anchors = [];
|
|
1189
1200
|
{
|
|
@@ -1253,7 +1264,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1253
1264
|
const cell = parentTable.cell;
|
|
1254
1265
|
(cell.blocks ??= []).push(block);
|
|
1255
1266
|
cell.hasStructure = true;
|
|
1256
|
-
let flat =
|
|
1267
|
+
let flat = _chunkVNIQK4ALcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1257
1268
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1258
1269
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1259
1270
|
} else {
|
|
@@ -1265,7 +1276,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1265
1276
|
// src/hwpx/section-walker.ts
|
|
1266
1277
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1267
1278
|
const parser = createXmlParser(warnings);
|
|
1268
|
-
const doc = parser.parseFromString(
|
|
1279
|
+
const doc = parser.parseFromString(_chunkVNIQK4ALcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1269
1280
|
if (!doc.documentElement) return [];
|
|
1270
1281
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1271
1282
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1356,8 +1367,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1356
1367
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1357
1368
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1358
1369
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1359
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1360
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1370
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkVNIQK4ALcjs.MAX_COLS);
|
|
1371
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkVNIQK4ALcjs.MAX_ROWS);
|
|
1361
1372
|
}
|
|
1362
1373
|
break;
|
|
1363
1374
|
case "p": {
|
|
@@ -1579,7 +1590,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1579
1590
|
let url = (ch.textContent || "").trim();
|
|
1580
1591
|
if (!url) continue;
|
|
1581
1592
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1582
|
-
const safe =
|
|
1593
|
+
const safe = _chunkVNIQK4ALcjs.sanitizeHref.call(void 0, url);
|
|
1583
1594
|
if (safe) return safe;
|
|
1584
1595
|
}
|
|
1585
1596
|
return void 0;
|
|
@@ -1714,7 +1725,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1714
1725
|
case "hyperlink": {
|
|
1715
1726
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1716
1727
|
if (url) {
|
|
1717
|
-
const safe =
|
|
1728
|
+
const safe = _chunkVNIQK4ALcjs.sanitizeHref.call(void 0, url);
|
|
1718
1729
|
if (safe) href = safe;
|
|
1719
1730
|
}
|
|
1720
1731
|
walk(child);
|
|
@@ -1900,13 +1911,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1900
1911
|
}
|
|
1901
1912
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1902
1913
|
for (const path of allCandidates) {
|
|
1903
|
-
if (
|
|
1914
|
+
if (_chunkVNIQK4ALcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1904
1915
|
const file = zip.file(path);
|
|
1905
1916
|
if (!file) continue;
|
|
1906
1917
|
try {
|
|
1907
1918
|
const data = await file.async("uint8array");
|
|
1908
1919
|
decompressed.total += data.length;
|
|
1909
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1920
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1910
1921
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1911
1922
|
const mimeType = imageExtToMime(ext);
|
|
1912
1923
|
imageIndex++;
|
|
@@ -1915,7 +1926,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1915
1926
|
images.push(img);
|
|
1916
1927
|
break;
|
|
1917
1928
|
} catch (err) {
|
|
1918
|
-
if (err instanceof
|
|
1929
|
+
if (err instanceof _chunkVNIQK4ALcjs.KordocError) throw err;
|
|
1919
1930
|
}
|
|
1920
1931
|
}
|
|
1921
1932
|
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" })]);
|
|
@@ -1977,7 +1988,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1977
1988
|
}
|
|
1978
1989
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1979
1990
|
const name = new TextDecoder().decode(nameBytes);
|
|
1980
|
-
if (
|
|
1991
|
+
if (_chunkVNIQK4ALcjs.isPathTraversal.call(void 0, name)) {
|
|
1981
1992
|
pos = fileStart + compSize;
|
|
1982
1993
|
continue;
|
|
1983
1994
|
}
|
|
@@ -1995,16 +2006,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1995
2006
|
continue;
|
|
1996
2007
|
}
|
|
1997
2008
|
totalDecompressed += content.length * 2;
|
|
1998
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2009
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1999
2010
|
sectionNum++;
|
|
2000
2011
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2001
2012
|
} catch (e13) {
|
|
2002
2013
|
continue;
|
|
2003
2014
|
}
|
|
2004
2015
|
}
|
|
2005
|
-
if (blocks.length === 0) throw new (0,
|
|
2016
|
+
if (blocks.length === 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2006
2017
|
applyPageText(blocks, shared);
|
|
2007
|
-
const markdown =
|
|
2018
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2008
2019
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2009
2020
|
}
|
|
2010
2021
|
async function resolveSectionPaths(zip) {
|
|
@@ -2018,18 +2029,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2018
2029
|
if (paths.length > 0) return paths;
|
|
2019
2030
|
}
|
|
2020
2031
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2021
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2032
|
+
return sectionFiles.map((f) => f.name).sort(_chunkVNIQK4ALcjs.compareSectionPaths);
|
|
2022
2033
|
}
|
|
2023
2034
|
function parseSectionPathsFromManifest(xml) {
|
|
2024
2035
|
const parser = createXmlParser();
|
|
2025
|
-
const doc = parser.parseFromString(
|
|
2036
|
+
const doc = parser.parseFromString(_chunkVNIQK4ALcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2026
2037
|
const items = doc.getElementsByTagName("opf:item");
|
|
2027
2038
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2028
2039
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2029
2040
|
for (let i = 0; i < items.length; i++) {
|
|
2030
2041
|
const item = items[i];
|
|
2031
2042
|
const id = item.getAttribute("id") || "";
|
|
2032
|
-
const href =
|
|
2043
|
+
const href = _chunkVNIQK4ALcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2033
2044
|
if (id && href) idToHref.set(id, href);
|
|
2034
2045
|
}
|
|
2035
2046
|
if (spine.length > 0) {
|
|
@@ -2040,7 +2051,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2040
2051
|
}
|
|
2041
2052
|
if (ordered.length > 0) return ordered;
|
|
2042
2053
|
}
|
|
2043
|
-
return Array.from(idToHref.values()).sort(
|
|
2054
|
+
return Array.from(idToHref.values()).sort(_chunkVNIQK4ALcjs.compareSectionPaths);
|
|
2044
2055
|
}
|
|
2045
2056
|
|
|
2046
2057
|
// src/hwpx/metadata.ts
|
|
@@ -2053,7 +2064,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2053
2064
|
const xml = await file.async("text");
|
|
2054
2065
|
if (decompressed) {
|
|
2055
2066
|
decompressed.total += xml.length * 2;
|
|
2056
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2067
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2057
2068
|
}
|
|
2058
2069
|
parseDublinCoreMetadata(xml, metadata);
|
|
2059
2070
|
if (metadata.title || metadata.author) return;
|
|
@@ -2063,7 +2074,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2063
2074
|
}
|
|
2064
2075
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2065
2076
|
const parser = createXmlParser();
|
|
2066
|
-
const doc = parser.parseFromString(
|
|
2077
|
+
const doc = parser.parseFromString(_chunkVNIQK4ALcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2067
2078
|
if (!doc.documentElement) return;
|
|
2068
2079
|
const getText = (tagNames) => {
|
|
2069
2080
|
for (const tag of tagNames) {
|
|
@@ -2088,7 +2099,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2088
2099
|
|
|
2089
2100
|
// src/hwpx/parser.ts
|
|
2090
2101
|
async function parseHwpxDocument(buffer, options) {
|
|
2091
|
-
|
|
2102
|
+
_chunkVNIQK4ALcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2092
2103
|
let zip;
|
|
2093
2104
|
try {
|
|
2094
2105
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2097,7 +2108,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2097
2108
|
}
|
|
2098
2109
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2099
2110
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2100
|
-
throw new (0,
|
|
2111
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2101
2112
|
}
|
|
2102
2113
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2103
2114
|
if (manifestFile) {
|
|
@@ -2109,7 +2120,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2109
2120
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2110
2121
|
}
|
|
2111
2122
|
}
|
|
2112
|
-
throw new (0,
|
|
2123
|
+
throw new (0, _chunkVNIQK4ALcjs.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.");
|
|
2113
2124
|
}
|
|
2114
2125
|
}
|
|
2115
2126
|
const decompressed = { total: 0 };
|
|
@@ -2118,7 +2129,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2118
2129
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2119
2130
|
const warnings = [];
|
|
2120
2131
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2121
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2132
|
+
if (sectionPaths.length === 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2122
2133
|
metadata.pageCount = sectionPaths.length;
|
|
2123
2134
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2124
2135
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2132,12 +2143,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2132
2143
|
try {
|
|
2133
2144
|
const xml = await file.async("text");
|
|
2134
2145
|
decompressed.total += xml.length * 2;
|
|
2135
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2146
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2136
2147
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2137
2148
|
parsedSections++;
|
|
2138
2149
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2139
2150
|
} catch (secErr) {
|
|
2140
|
-
if (secErr instanceof
|
|
2151
|
+
if (secErr instanceof _chunkVNIQK4ALcjs.KordocError) throw secErr;
|
|
2141
2152
|
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" });
|
|
2142
2153
|
}
|
|
2143
2154
|
}
|
|
@@ -2145,7 +2156,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2145
2156
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2146
2157
|
detectHwpxHeadings(blocks, styleMap);
|
|
2147
2158
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2148
|
-
const markdown =
|
|
2159
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2149
2160
|
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 };
|
|
2150
2161
|
}
|
|
2151
2162
|
|
|
@@ -2212,7 +2223,7 @@ function decompressStream(data) {
|
|
|
2212
2223
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2213
2224
|
}
|
|
2214
2225
|
function parseFileHeader(data) {
|
|
2215
|
-
if (data.length < 40) throw new (0,
|
|
2226
|
+
if (data.length < 40) throw new (0, _chunkVNIQK4ALcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2216
2227
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2217
2228
|
return {
|
|
2218
2229
|
signature: sig,
|
|
@@ -3745,7 +3756,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3745
3756
|
lenientCfb = parseLenientCfb(buffer);
|
|
3746
3757
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3747
3758
|
} catch (e21) {
|
|
3748
|
-
throw new (0,
|
|
3759
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3749
3760
|
}
|
|
3750
3761
|
}
|
|
3751
3762
|
const findStream = (path) => {
|
|
@@ -3756,11 +3767,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3756
3767
|
return lenientCfb.findStream(path);
|
|
3757
3768
|
};
|
|
3758
3769
|
const headerData = findStream("/FileHeader");
|
|
3759
|
-
if (!headerData) throw new (0,
|
|
3770
|
+
if (!headerData) throw new (0, _chunkVNIQK4ALcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3760
3771
|
const header = parseFileHeader(headerData);
|
|
3761
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3762
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3763
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3772
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkVNIQK4ALcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3773
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3774
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkVNIQK4ALcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3764
3775
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3765
3776
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3766
3777
|
const metadata = {
|
|
@@ -3769,7 +3780,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3769
3780
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3770
3781
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3771
3782
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3772
|
-
if (sections.length === 0) throw new (0,
|
|
3783
|
+
if (sections.length === 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3773
3784
|
metadata.pageCount = sections.length;
|
|
3774
3785
|
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3775
3786
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3783,25 +3794,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3783
3794
|
const sectionData = sections[si];
|
|
3784
3795
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3785
3796
|
totalDecompressed += data.length;
|
|
3786
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3797
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3787
3798
|
const records = readRecords(data);
|
|
3788
3799
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3789
3800
|
bodyBlocks.push(...sectionBlocks);
|
|
3790
3801
|
parsedSections++;
|
|
3791
3802
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3792
3803
|
} catch (secErr) {
|
|
3793
|
-
if (secErr instanceof
|
|
3804
|
+
if (secErr instanceof _chunkVNIQK4ALcjs.KordocError) throw secErr;
|
|
3794
3805
|
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" });
|
|
3795
3806
|
}
|
|
3796
3807
|
}
|
|
3797
3808
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3798
3809
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3799
|
-
const flatBlocks =
|
|
3810
|
+
const flatBlocks = _chunkVNIQK4ALcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3800
3811
|
if (docInfo) {
|
|
3801
3812
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3802
3813
|
}
|
|
3803
3814
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3804
|
-
const markdown =
|
|
3815
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3805
3816
|
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 };
|
|
3806
3817
|
}
|
|
3807
3818
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3861,9 +3872,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3861
3872
|
let level = 0;
|
|
3862
3873
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3863
3874
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3864
|
-
if (ratio >=
|
|
3865
|
-
else if (ratio >=
|
|
3866
|
-
else if (ratio >=
|
|
3875
|
+
if (ratio >= _chunkVNIQK4ALcjs.HEADING_RATIO_H1) level = 1;
|
|
3876
|
+
else if (ratio >= _chunkVNIQK4ALcjs.HEADING_RATIO_H2) level = 2;
|
|
3877
|
+
else if (ratio >= _chunkVNIQK4ALcjs.HEADING_RATIO_H3) level = 3;
|
|
3867
3878
|
}
|
|
3868
3879
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3869
3880
|
if (level === 0) level = 2;
|
|
@@ -3948,7 +3959,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3948
3959
|
if (!raw) break;
|
|
3949
3960
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3950
3961
|
totalDecompressed += content.length;
|
|
3951
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3962
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3952
3963
|
sections.push({ idx: i, content });
|
|
3953
3964
|
}
|
|
3954
3965
|
if (sections.length === 0) {
|
|
@@ -3960,7 +3971,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3960
3971
|
if (raw) {
|
|
3961
3972
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3962
3973
|
totalDecompressed += content.length;
|
|
3963
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3974
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3964
3975
|
sections.push({ idx, content });
|
|
3965
3976
|
}
|
|
3966
3977
|
}
|
|
@@ -3977,7 +3988,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3977
3988
|
try {
|
|
3978
3989
|
const content = decryptViewText(raw, compressed);
|
|
3979
3990
|
totalDecompressed += content.length;
|
|
3980
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3991
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3981
3992
|
sections.push({ idx: i, content });
|
|
3982
3993
|
} catch (e26) {
|
|
3983
3994
|
break;
|
|
@@ -4080,7 +4091,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4080
4091
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4081
4092
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
4082
4093
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4083
|
-
const href =
|
|
4094
|
+
const href = _chunkVNIQK4ALcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4084
4095
|
if (!href) continue;
|
|
4085
4096
|
const anchor = text.slice(r.start, r.end);
|
|
4086
4097
|
if (!anchor.trim()) continue;
|
|
@@ -4313,8 +4324,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4313
4324
|
let tableIdx = -1;
|
|
4314
4325
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4315
4326
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4316
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4317
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4327
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkVNIQK4ALcjs.MAX_ROWS);
|
|
4328
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkVNIQK4ALcjs.MAX_COLS);
|
|
4318
4329
|
tableIdx = i2;
|
|
4319
4330
|
break;
|
|
4320
4331
|
}
|
|
@@ -4363,7 +4374,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4363
4374
|
return table2;
|
|
4364
4375
|
}
|
|
4365
4376
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4366
|
-
const table =
|
|
4377
|
+
const table = _chunkVNIQK4ALcjs.buildTable.call(void 0, cellRows);
|
|
4367
4378
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4368
4379
|
return table.rows > 0 ? table : null;
|
|
4369
4380
|
}
|
|
@@ -4380,8 +4391,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4380
4391
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4381
4392
|
const cs = rec.data.readUInt16LE(12);
|
|
4382
4393
|
const rs = rec.data.readUInt16LE(14);
|
|
4383
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4384
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4394
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkVNIQK4ALcjs.MAX_COLS);
|
|
4395
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkVNIQK4ALcjs.MAX_ROWS);
|
|
4385
4396
|
}
|
|
4386
4397
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4387
4398
|
const parts = [];
|
|
@@ -4391,7 +4402,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4391
4402
|
parts.push(``);
|
|
4392
4403
|
hasStructure = true;
|
|
4393
4404
|
} else if (b.type === "table" && b.table) {
|
|
4394
|
-
const flat =
|
|
4405
|
+
const flat = _chunkVNIQK4ALcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4395
4406
|
if (flat) parts.push(flat);
|
|
4396
4407
|
hasStructure = true;
|
|
4397
4408
|
} else if (b.text) {
|
|
@@ -16828,7 +16839,7 @@ function getTextContent(el) {
|
|
|
16828
16839
|
return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
|
|
16829
16840
|
}
|
|
16830
16841
|
function parseXml(text) {
|
|
16831
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16842
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkVNIQK4ALcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16832
16843
|
}
|
|
16833
16844
|
function parseSharedStrings(xml) {
|
|
16834
16845
|
const doc = parseXml(xml);
|
|
@@ -16972,7 +16983,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16972
16983
|
cellRows.push(row);
|
|
16973
16984
|
}
|
|
16974
16985
|
if (cellRows.length > 0) {
|
|
16975
|
-
const table =
|
|
16986
|
+
const table = _chunkVNIQK4ALcjs.buildTable.call(void 0, cellRows);
|
|
16976
16987
|
if (table.rows > 0) {
|
|
16977
16988
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16978
16989
|
}
|
|
@@ -16980,12 +16991,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16980
16991
|
return blocks;
|
|
16981
16992
|
}
|
|
16982
16993
|
async function parseXlsxDocument(buffer, options) {
|
|
16983
|
-
|
|
16994
|
+
_chunkVNIQK4ALcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16984
16995
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16985
16996
|
const warnings = [];
|
|
16986
16997
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16987
16998
|
if (!workbookFile) {
|
|
16988
|
-
throw new (0,
|
|
16999
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16989
17000
|
}
|
|
16990
17001
|
let sharedStrings = [];
|
|
16991
17002
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16994,7 +17005,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16994
17005
|
}
|
|
16995
17006
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16996
17007
|
if (sheets.length === 0) {
|
|
16997
|
-
throw new (0,
|
|
17008
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16998
17009
|
}
|
|
16999
17010
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17000
17011
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17066,7 +17077,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17066
17077
|
} catch (e27) {
|
|
17067
17078
|
}
|
|
17068
17079
|
}
|
|
17069
|
-
const markdown =
|
|
17080
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17070
17081
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17071
17082
|
}
|
|
17072
17083
|
|
|
@@ -17473,11 +17484,11 @@ function processGlobals(records) {
|
|
|
17473
17484
|
let encrypted = false;
|
|
17474
17485
|
const firstBof = records[0];
|
|
17475
17486
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17476
|
-
throw new (0,
|
|
17487
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17477
17488
|
}
|
|
17478
17489
|
const bof = decodeBof(firstBof.data);
|
|
17479
17490
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17480
|
-
throw new (0,
|
|
17491
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17481
17492
|
}
|
|
17482
17493
|
let i = 1;
|
|
17483
17494
|
while (i < records.length) {
|
|
@@ -17592,7 +17603,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17592
17603
|
cellRows.push(row);
|
|
17593
17604
|
}
|
|
17594
17605
|
if (cellRows.length > 0) {
|
|
17595
|
-
const table =
|
|
17606
|
+
const table = _chunkVNIQK4ALcjs.buildTable.call(void 0, cellRows);
|
|
17596
17607
|
if (table.rows > 0) {
|
|
17597
17608
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17598
17609
|
}
|
|
@@ -17605,21 +17616,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17605
17616
|
try {
|
|
17606
17617
|
cfb = parseLenientCfb(buf);
|
|
17607
17618
|
} catch (e) {
|
|
17608
|
-
throw new (0,
|
|
17619
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)(
|
|
17609
17620
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17610
17621
|
);
|
|
17611
17622
|
}
|
|
17612
17623
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17613
17624
|
if (!wb) {
|
|
17614
|
-
throw new (0,
|
|
17625
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17615
17626
|
}
|
|
17616
17627
|
const records = readRecords2(wb);
|
|
17617
17628
|
if (records.length === 0) {
|
|
17618
|
-
throw new (0,
|
|
17629
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17619
17630
|
}
|
|
17620
17631
|
const firstBof = decodeBof(records[0].data);
|
|
17621
17632
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17622
|
-
throw new (0,
|
|
17633
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)(
|
|
17623
17634
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17624
17635
|
);
|
|
17625
17636
|
}
|
|
@@ -17679,7 +17690,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17679
17690
|
pageCount: totalSheets
|
|
17680
17691
|
};
|
|
17681
17692
|
return {
|
|
17682
|
-
markdown:
|
|
17693
|
+
markdown: _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17683
17694
|
blocks: allBlocks,
|
|
17684
17695
|
metadata,
|
|
17685
17696
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18117,7 +18128,7 @@ function getAttr(el, localName2) {
|
|
|
18117
18128
|
return null;
|
|
18118
18129
|
}
|
|
18119
18130
|
function parseXml2(text) {
|
|
18120
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18131
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkVNIQK4ALcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18121
18132
|
}
|
|
18122
18133
|
function parseStyles(xml) {
|
|
18123
18134
|
const doc = parseXml2(xml);
|
|
@@ -18351,7 +18362,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
|
|
|
18351
18362
|
if (trPrEls.length > 0) {
|
|
18352
18363
|
const gridBeforeEls = getChildElements(trPrEls[0], "gridBefore");
|
|
18353
18364
|
if (gridBeforeEls.length > 0) {
|
|
18354
|
-
col = parseInt(_nullishCoalesce(getAttr(gridBeforeEls[0], "val"), () => ( "0")), 10) || 0;
|
|
18365
|
+
col = Math.max(0, parseInt(_nullishCoalesce(getAttr(gridBeforeEls[0], "val"), () => ( "0")), 10) || 0);
|
|
18355
18366
|
}
|
|
18356
18367
|
}
|
|
18357
18368
|
for (const tc of getChildElements(tr, "tc")) {
|
|
@@ -18402,7 +18413,7 @@ ${cell.text}` : cell.text;
|
|
|
18402
18413
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18403
18414
|
})
|
|
18404
18415
|
);
|
|
18405
|
-
const table =
|
|
18416
|
+
const table = _chunkVNIQK4ALcjs.buildTable.call(void 0, cellRows);
|
|
18406
18417
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18407
18418
|
return { type: "table", table };
|
|
18408
18419
|
}
|
|
@@ -18469,12 +18480,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18469
18480
|
return { blocks, images };
|
|
18470
18481
|
}
|
|
18471
18482
|
async function parseDocxDocument(buffer, options) {
|
|
18472
|
-
|
|
18483
|
+
_chunkVNIQK4ALcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18473
18484
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18474
18485
|
const warnings = [];
|
|
18475
18486
|
const docFile = zip.file("word/document.xml");
|
|
18476
18487
|
if (!docFile) {
|
|
18477
|
-
throw new (0,
|
|
18488
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18478
18489
|
}
|
|
18479
18490
|
let rels = /* @__PURE__ */ new Map();
|
|
18480
18491
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18521,7 +18532,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18521
18532
|
const doc = parseXml2(docXml);
|
|
18522
18533
|
const body = findElements(doc, "body");
|
|
18523
18534
|
if (body.length === 0) {
|
|
18524
|
-
throw new (0,
|
|
18535
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18525
18536
|
}
|
|
18526
18537
|
const blocks = [];
|
|
18527
18538
|
const bodyEl = body[0];
|
|
@@ -18566,7 +18577,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18566
18577
|
}
|
|
18567
18578
|
}
|
|
18568
18579
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18569
|
-
const markdown =
|
|
18580
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18570
18581
|
return {
|
|
18571
18582
|
markdown,
|
|
18572
18583
|
blocks,
|
|
@@ -18589,7 +18600,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18589
18600
|
}
|
|
18590
18601
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18591
18602
|
const normalized = text.replace(/ /g, " ");
|
|
18592
|
-
const xml =
|
|
18603
|
+
const xml = _chunkVNIQK4ALcjs.stripDtd.call(void 0, normalized);
|
|
18593
18604
|
const warnings = [];
|
|
18594
18605
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18595
18606
|
onError: (_level, msg2) => {
|
|
@@ -18629,7 +18640,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18629
18640
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18630
18641
|
}
|
|
18631
18642
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18632
|
-
const markdown =
|
|
18643
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18633
18644
|
return {
|
|
18634
18645
|
markdown,
|
|
18635
18646
|
blocks,
|
|
@@ -18787,7 +18798,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18787
18798
|
const cellRows = grid.map(
|
|
18788
18799
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18789
18800
|
);
|
|
18790
|
-
const table =
|
|
18801
|
+
const table = _chunkVNIQK4ALcjs.buildTable.call(void 0, cellRows);
|
|
18791
18802
|
const caption = extractShapeCaption(el);
|
|
18792
18803
|
if (caption.text && caption.before) {
|
|
18793
18804
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -18880,34 +18891,47 @@ function countSections(body) {
|
|
|
18880
18891
|
|
|
18881
18892
|
// src/form/match.ts
|
|
18882
18893
|
function parseYMD(v) {
|
|
18883
|
-
const d = v.replace(/\D/g, "");
|
|
18884
18894
|
let y, m, day;
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
-
|
|
18892
|
-
|
|
18893
|
-
|
|
18894
|
-
|
|
18895
|
+
const parts = v.split(/[^0-9]+/).filter(Boolean);
|
|
18896
|
+
if (parts.length === 3) {
|
|
18897
|
+
const [yp, mp, dp] = parts;
|
|
18898
|
+
const yn = +yp;
|
|
18899
|
+
y = yp.length >= 3 ? yp : String(yn <= 29 ? 2e3 + yn : 1900 + yn);
|
|
18900
|
+
m = mp.padStart(2, "0");
|
|
18901
|
+
day = dp.padStart(2, "0");
|
|
18902
|
+
} else {
|
|
18903
|
+
const d = v.replace(/\D/g, "");
|
|
18904
|
+
if (d.length >= 8) {
|
|
18905
|
+
y = d.slice(0, 4);
|
|
18906
|
+
m = d.slice(4, 6);
|
|
18907
|
+
day = d.slice(6, 8);
|
|
18908
|
+
} else if (d.length === 6) {
|
|
18909
|
+
const yy = +d.slice(0, 2);
|
|
18910
|
+
y = String(yy <= 29 ? 2e3 + yy : 1900 + yy);
|
|
18911
|
+
m = d.slice(2, 4);
|
|
18912
|
+
day = d.slice(4, 6);
|
|
18913
|
+
} else return null;
|
|
18914
|
+
}
|
|
18915
|
+
if (+m < 1 || +m > 12 || +day < 1 || +day > 31) return null;
|
|
18895
18916
|
return { y, yy: y.slice(2), m, d: day };
|
|
18896
18917
|
}
|
|
18897
18918
|
function fmtDate(v, style) {
|
|
18898
18919
|
const p = parseYMD(v);
|
|
18899
18920
|
if (!p) return v;
|
|
18900
|
-
return (style || "yyyy-mm-dd").replace(/yyyy/
|
|
18921
|
+
return (style || "yyyy-mm-dd").replace(/yyyy/gi, p.y).replace(/yy/gi, p.yy).replace(/mm/gi, p.m).replace(/dd/gi, p.d).replace(/(?<![a-z])m(?![a-z])/gi, String(+p.m)).replace(/(?<![a-z])d(?![a-z])/gi, String(+p.d));
|
|
18901
18922
|
}
|
|
18902
18923
|
function maskDigits(v, pattern) {
|
|
18903
18924
|
const ds = v.replace(/\D/g, "");
|
|
18925
|
+
const need = (_nullishCoalesce(pattern.match(/#/g), () => ( []))).length;
|
|
18926
|
+
if (need === 0 || ds.length !== need) return v;
|
|
18904
18927
|
let i = 0;
|
|
18905
|
-
return pattern.replace(/#/g, () =>
|
|
18928
|
+
return pattern.replace(/#/g, () => ds[i++]);
|
|
18906
18929
|
}
|
|
18907
18930
|
function fmtPhone(v, style) {
|
|
18908
18931
|
const d = v.replace(/\D/g, "");
|
|
18909
18932
|
if (d.length < 9) return v;
|
|
18910
|
-
const
|
|
18933
|
+
const areaLen = d.startsWith("02") ? 2 : 3;
|
|
18934
|
+
const a = d.slice(0, areaLen), b = d.slice(areaLen, -4), c = d.slice(-4);
|
|
18911
18935
|
switch (style) {
|
|
18912
18936
|
case "digits":
|
|
18913
18937
|
return d;
|
|
@@ -18916,9 +18940,9 @@ function fmtPhone(v, style) {
|
|
|
18916
18940
|
case "space":
|
|
18917
18941
|
return `${a} ${b} ${c}`;
|
|
18918
18942
|
case "intl":
|
|
18919
|
-
return `+82-${d.slice(1,
|
|
18943
|
+
return `+82-${d.slice(1, areaLen)}-${b}-${c}`;
|
|
18920
18944
|
case "intl-paren":
|
|
18921
|
-
return `82)${d.slice(1,
|
|
18945
|
+
return `82)${d.slice(1, areaLen)}-${b}-${c}`;
|
|
18922
18946
|
default:
|
|
18923
18947
|
return `${a}-${b}-${c}`;
|
|
18924
18948
|
}
|
|
@@ -18946,7 +18970,10 @@ function formatFillValue(value, format) {
|
|
|
18946
18970
|
if (kind === "phone") return fmtPhone(value, style);
|
|
18947
18971
|
if (kind === "rrn") return fmtRRN(value, style);
|
|
18948
18972
|
if (kind === "mask") return maskDigits(value, style);
|
|
18949
|
-
if (kind === "digits")
|
|
18973
|
+
if (kind === "digits") {
|
|
18974
|
+
const only = value.replace(/\D/g, "");
|
|
18975
|
+
return only || value;
|
|
18976
|
+
}
|
|
18950
18977
|
if (kind === "upper") return value.toUpperCase();
|
|
18951
18978
|
if (kind === "lower") return value.toLowerCase();
|
|
18952
18979
|
if (kind === "nospace") return value.replace(/\s+/g, "");
|
|
@@ -19023,7 +19050,7 @@ function isKeywordLabel(text) {
|
|
|
19023
19050
|
}
|
|
19024
19051
|
return false;
|
|
19025
19052
|
}
|
|
19026
|
-
function fillInCellPatterns(cellText, values, matchedLabels) {
|
|
19053
|
+
function fillInCellPatterns(cellText, values, matchedLabels, blockedLabels) {
|
|
19027
19054
|
let text = cellText;
|
|
19028
19055
|
const matches = [];
|
|
19029
19056
|
text = text.replace(
|
|
@@ -19031,6 +19058,7 @@ function fillInCellPatterns(cellText, values, matchedLabels) {
|
|
|
19031
19058
|
(match, prefix, suffix) => {
|
|
19032
19059
|
const label = prefix + suffix;
|
|
19033
19060
|
const normalizedLabel = normalizeLabel(label);
|
|
19061
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _125 => _125.has, 'call', _126 => _126(normalizedLabel)])) return match;
|
|
19034
19062
|
const matchKey = values.available(normalizedLabel) ? normalizedLabel : values.available(normalizeLabel(prefix)) ? normalizeLabel(prefix) : void 0;
|
|
19035
19063
|
if (matchKey === void 0) return match;
|
|
19036
19064
|
const newValue = values.consume(matchKey);
|
|
@@ -19126,8 +19154,12 @@ async function fillWithUniqueGuard(values, run) {
|
|
|
19126
19154
|
};
|
|
19127
19155
|
const dup = new Set([...counts].filter(([k, n]) => n >= 2 && !isArrayValue(k)).map(([k]) => k));
|
|
19128
19156
|
if (dup.size === 0) return { ...first, rejected: [] };
|
|
19157
|
+
const blockedLabels = /* @__PURE__ */ new Set();
|
|
19158
|
+
for (const f of first.filled) {
|
|
19159
|
+
if (f.key && dup.has(f.key)) blockedLabels.add(normalizeLabel(f.label));
|
|
19160
|
+
}
|
|
19129
19161
|
const filtered = Object.fromEntries(Object.entries(values).filter(([label]) => !dup.has(normalizeLabel(label))));
|
|
19130
|
-
const second = await run(filtered);
|
|
19162
|
+
const second = await run(filtered, blockedLabels);
|
|
19131
19163
|
const rejected = Object.keys(values).filter((label) => dup.has(normalizeLabel(label)));
|
|
19132
19164
|
return { ...second, rejected };
|
|
19133
19165
|
}
|
|
@@ -19276,8 +19308,8 @@ function extractFromTable(table) {
|
|
|
19276
19308
|
if (table.cols >= 2) {
|
|
19277
19309
|
for (let r = 0; r < table.rows; r++) {
|
|
19278
19310
|
for (let c = 0; c < table.cols - 1; c++) {
|
|
19279
|
-
const labelCell = _optionalChain([table, 'access',
|
|
19280
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19311
|
+
const labelCell = _optionalChain([table, 'access', _127 => _127.cells, 'access', _128 => _128[r], 'optionalAccess', _129 => _129[c]]);
|
|
19312
|
+
const valueCell = _optionalChain([table, 'access', _130 => _130.cells, 'access', _131 => _131[r], 'optionalAccess', _132 => _132[c + 1]]);
|
|
19281
19313
|
if (!labelCell || !valueCell) continue;
|
|
19282
19314
|
if (isLabelCell(labelCell.text)) {
|
|
19283
19315
|
fields.push({
|
|
@@ -19299,8 +19331,8 @@ function extractFromTable(table) {
|
|
|
19299
19331
|
if (allLabels) {
|
|
19300
19332
|
for (let r = 1; r < table.rows; r++) {
|
|
19301
19333
|
for (let c = 0; c < table.cols; c++) {
|
|
19302
|
-
const label = _nullishCoalesce(_optionalChain([headerRow, 'access',
|
|
19303
|
-
const value = _nullishCoalesce(_optionalChain([table, 'access',
|
|
19334
|
+
const label = _nullishCoalesce(_optionalChain([headerRow, 'access', _133 => _133[c], 'optionalAccess', _134 => _134.text, 'access', _135 => _135.trim, 'call', _136 => _136()]), () => ( ""));
|
|
19335
|
+
const value = _nullishCoalesce(_optionalChain([table, 'access', _137 => _137.cells, 'access', _138 => _138[r], 'optionalAccess', _139 => _139[c], 'optionalAccess', _140 => _140.text, 'access', _141 => _141.trim, 'call', _142 => _142()]), () => ( ""));
|
|
19304
19336
|
if (label && value) {
|
|
19305
19337
|
fields.push({ label, value, row: r, col: c });
|
|
19306
19338
|
}
|
|
@@ -19382,7 +19414,7 @@ function extractFormSchema(blocks) {
|
|
|
19382
19414
|
}
|
|
19383
19415
|
|
|
19384
19416
|
// src/form/filler.ts
|
|
19385
|
-
function fillFormFields(blocks, values) {
|
|
19417
|
+
function fillFormFields(blocks, values, blockedLabels) {
|
|
19386
19418
|
const cloned = structuredClone(blocks);
|
|
19387
19419
|
const filled = [];
|
|
19388
19420
|
const matchedLabels = /* @__PURE__ */ new Set();
|
|
@@ -19393,9 +19425,9 @@ function fillFormFields(blocks, values) {
|
|
|
19393
19425
|
for (const table of allTables) {
|
|
19394
19426
|
for (let r = 0; r < table.rows; r++) {
|
|
19395
19427
|
for (let c = 0; c < table.cols; c++) {
|
|
19396
|
-
const cell = _optionalChain([table, 'access',
|
|
19428
|
+
const cell = _optionalChain([table, 'access', _143 => _143.cells, 'access', _144 => _144[r], 'optionalAccess', _145 => _145[c]]);
|
|
19397
19429
|
if (!cell) continue;
|
|
19398
|
-
const result = fillInCellPatterns(cell.text, cursor, matchedLabels);
|
|
19430
|
+
const result = fillInCellPatterns(cell.text, cursor, matchedLabels, blockedLabels);
|
|
19399
19431
|
if (result) {
|
|
19400
19432
|
cell.text = result.text;
|
|
19401
19433
|
patternFilledCells.add(cell);
|
|
@@ -19407,11 +19439,11 @@ function fillFormFields(blocks, values) {
|
|
|
19407
19439
|
}
|
|
19408
19440
|
}
|
|
19409
19441
|
for (const table of allTables) {
|
|
19410
|
-
fillTable(table, cursor, filled, matchedLabels, patternFilledCells);
|
|
19442
|
+
fillTable(table, cursor, filled, matchedLabels, patternFilledCells, blockedLabels);
|
|
19411
19443
|
}
|
|
19412
19444
|
for (const block of cloned) {
|
|
19413
19445
|
if (block.type !== "paragraph" || !block.text) continue;
|
|
19414
|
-
const newText = fillInlineFields(block.text, cursor, filled, matchedLabels);
|
|
19446
|
+
const newText = fillInlineFields(block.text, cursor, filled, matchedLabels, blockedLabels);
|
|
19415
19447
|
if (newText !== block.text) block.text = newText;
|
|
19416
19448
|
}
|
|
19417
19449
|
const unmatched = resolveUnmatched(normalizedValues, matchedLabels, values);
|
|
@@ -19425,7 +19457,7 @@ function collectIRTables(blocks, depth) {
|
|
|
19425
19457
|
out.push(block.table);
|
|
19426
19458
|
for (const row of block.table.cells) {
|
|
19427
19459
|
for (const cell of row) {
|
|
19428
|
-
if (_optionalChain([cell, 'optionalAccess',
|
|
19460
|
+
if (_optionalChain([cell, 'optionalAccess', _146 => _146.blocks, 'optionalAccess', _147 => _147.length])) out.push(...collectIRTables(cell.blocks, depth + 1));
|
|
19429
19461
|
}
|
|
19430
19462
|
}
|
|
19431
19463
|
}
|
|
@@ -19436,7 +19468,7 @@ function coveredPositions(table) {
|
|
|
19436
19468
|
for (let r = 0; r < table.rows; r++) {
|
|
19437
19469
|
for (let c = 0; c < table.cols; c++) {
|
|
19438
19470
|
if (covered.has(`${r},${c}`)) continue;
|
|
19439
|
-
const cell = _optionalChain([table, 'access',
|
|
19471
|
+
const cell = _optionalChain([table, 'access', _148 => _148.cells, 'access', _149 => _149[r], 'optionalAccess', _150 => _150[c]]);
|
|
19440
19472
|
if (!cell) continue;
|
|
19441
19473
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
19442
19474
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -19449,7 +19481,7 @@ function coveredPositions(table) {
|
|
|
19449
19481
|
}
|
|
19450
19482
|
return covered;
|
|
19451
19483
|
}
|
|
19452
|
-
function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
19484
|
+
function fillTable(table, values, filled, matchedLabels, patternFilledCells, blockedLabels) {
|
|
19453
19485
|
if (table.cols < 2) return;
|
|
19454
19486
|
const covered = coveredPositions(table);
|
|
19455
19487
|
for (let r = 0; r < table.rows; r++) {
|
|
@@ -19466,11 +19498,12 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19466
19498
|
if (isKeywordLabel(valueCell.text)) continue;
|
|
19467
19499
|
const normalizedCellLabel = normalizeLabel(labelCell.text);
|
|
19468
19500
|
if (!normalizedCellLabel) continue;
|
|
19501
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _151 => _151.has, 'call', _152 => _152(normalizedCellLabel)])) continue;
|
|
19469
19502
|
const matchKey = findMatchingKey(normalizedCellLabel, values);
|
|
19470
19503
|
if (matchKey === void 0) continue;
|
|
19471
19504
|
const newValue = values.consume(matchKey);
|
|
19472
19505
|
if (newValue === void 0) continue;
|
|
19473
|
-
if (_optionalChain([patternFilledCells, 'optionalAccess',
|
|
19506
|
+
if (_optionalChain([patternFilledCells, 'optionalAccess', _153 => _153.has, 'call', _154 => _154(valueCell)])) {
|
|
19474
19507
|
valueCell.text = newValue + " " + valueCell.text;
|
|
19475
19508
|
} else {
|
|
19476
19509
|
valueCell.text = newValue;
|
|
@@ -19496,9 +19529,10 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19496
19529
|
for (let c = 0; c < table.cols; c++) {
|
|
19497
19530
|
if (covered.has(`${r},${c}`)) continue;
|
|
19498
19531
|
const headerCell = headerRow[c];
|
|
19499
|
-
const valueCell = _optionalChain([table, 'access',
|
|
19532
|
+
const valueCell = _optionalChain([table, 'access', _155 => _155.cells, 'access', _156 => _156[r], 'optionalAccess', _157 => _157[c]]);
|
|
19500
19533
|
if (!headerCell || !valueCell) continue;
|
|
19501
19534
|
const headerLabel = normalizeLabel(headerCell.text);
|
|
19535
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _158 => _158.has, 'call', _159 => _159(headerLabel)])) continue;
|
|
19502
19536
|
const matchKey = findMatchingKey(headerLabel, values);
|
|
19503
19537
|
if (matchKey === void 0) continue;
|
|
19504
19538
|
if (!values.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -19517,13 +19551,15 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
|
|
|
19517
19551
|
}
|
|
19518
19552
|
}
|
|
19519
19553
|
}
|
|
19520
|
-
function fillInlineFields(text, values, filled, matchedLabels) {
|
|
19554
|
+
function fillInlineFields(text, values, filled, matchedLabels, blockedLabels) {
|
|
19521
19555
|
const segments = scanInlineSegments(text);
|
|
19522
19556
|
if (segments.length === 0) return text;
|
|
19523
19557
|
let out = "";
|
|
19524
19558
|
let pos = 0;
|
|
19525
19559
|
for (const seg of segments) {
|
|
19526
|
-
const
|
|
19560
|
+
const nlabel = normalizeLabel(seg.label);
|
|
19561
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _160 => _160.has, 'call', _161 => _161(nlabel)])) continue;
|
|
19562
|
+
const matchKey = findMatchingKey(nlabel, values);
|
|
19527
19563
|
if (matchKey === void 0) continue;
|
|
19528
19564
|
const newValue = values.consume(matchKey);
|
|
19529
19565
|
if (newValue === void 0) continue;
|
|
@@ -20090,19 +20126,19 @@ function parseCentralDirectory(buf) {
|
|
|
20090
20126
|
}
|
|
20091
20127
|
}
|
|
20092
20128
|
}
|
|
20093
|
-
if (eocdOffset < 0) throw new (0,
|
|
20129
|
+
if (eocdOffset < 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20094
20130
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20095
20131
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20096
20132
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20097
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20133
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20098
20134
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20099
|
-
throw new (0,
|
|
20135
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20100
20136
|
}
|
|
20101
20137
|
const decoder = new TextDecoder("utf-8");
|
|
20102
20138
|
const entries = [];
|
|
20103
20139
|
let pos = cdOffset;
|
|
20104
20140
|
for (let i = 0; i < totalEntries; i++) {
|
|
20105
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20141
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20106
20142
|
const flags = view.getUint16(pos + 8, true);
|
|
20107
20143
|
const method = view.getUint16(pos + 10, true);
|
|
20108
20144
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20113,7 +20149,7 @@ function parseCentralDirectory(buf) {
|
|
|
20113
20149
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20114
20150
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20115
20151
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20116
|
-
throw new (0,
|
|
20152
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20117
20153
|
}
|
|
20118
20154
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20119
20155
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20142,11 +20178,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20142
20178
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20143
20179
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20144
20180
|
for (const name of replacements.keys()) {
|
|
20145
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20181
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkVNIQK4ALcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20146
20182
|
}
|
|
20147
20183
|
if (additions) {
|
|
20148
20184
|
for (const name of additions.keys()) {
|
|
20149
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20185
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkVNIQK4ALcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20150
20186
|
}
|
|
20151
20187
|
}
|
|
20152
20188
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20165,7 +20201,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20165
20201
|
offset += seg.length;
|
|
20166
20202
|
continue;
|
|
20167
20203
|
}
|
|
20168
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20204
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkVNIQK4ALcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20169
20205
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20170
20206
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20171
20207
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20266,12 +20302,12 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20266
20302
|
}
|
|
20267
20303
|
|
|
20268
20304
|
// src/form/filler-hwpx.ts
|
|
20269
|
-
async function fillHwpx(hwpxBuffer, values) {
|
|
20305
|
+
async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
20270
20306
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
20271
20307
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20272
20308
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20273
20309
|
if (sectionPaths.length === 0) {
|
|
20274
|
-
throw new (0,
|
|
20310
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20275
20311
|
}
|
|
20276
20312
|
const normalizedValues = normalizeValues(values);
|
|
20277
20313
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20310,7 +20346,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20310
20346
|
for (const cell of row) {
|
|
20311
20347
|
for (const para of cell.paragraphs) {
|
|
20312
20348
|
const text = matchText(para);
|
|
20313
|
-
const result = fillInCellPatterns(text, cursor, matchedLabels);
|
|
20349
|
+
const result = fillInCellPatterns(text, cursor, matchedLabels, blockedLabels);
|
|
20314
20350
|
if (!result) continue;
|
|
20315
20351
|
const l = led(para);
|
|
20316
20352
|
if (l.fullText !== void 0) continue;
|
|
@@ -20328,7 +20364,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20328
20364
|
for (const m of result.matches) {
|
|
20329
20365
|
l.filledIdx.push(filled.length);
|
|
20330
20366
|
l.matchKeys.push(m.key);
|
|
20331
|
-
filled.push({ label: m.label, value: m.value, row: -1, col: -1 });
|
|
20367
|
+
filled.push({ label: m.label, value: m.value, row: -1, col: -1, key: m.key });
|
|
20332
20368
|
}
|
|
20333
20369
|
}
|
|
20334
20370
|
}
|
|
@@ -20344,6 +20380,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20344
20380
|
if (isKeywordLabel(cellLabelText(valueCell))) continue;
|
|
20345
20381
|
const normalizedCellLabel = normalizeLabel(labelText);
|
|
20346
20382
|
if (!normalizedCellLabel) continue;
|
|
20383
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _162 => _162.has, 'call', _163 => _163(normalizedCellLabel)])) continue;
|
|
20347
20384
|
const matchKey = findMatchingKey(normalizedCellLabel, cursor);
|
|
20348
20385
|
if (matchKey === void 0) continue;
|
|
20349
20386
|
if (patternApplied.has(valueCell)) {
|
|
@@ -20361,7 +20398,8 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20361
20398
|
label: labelText.trim().replace(/[::]\s*$/, ""),
|
|
20362
20399
|
value: newValue,
|
|
20363
20400
|
row: rowIdx,
|
|
20364
|
-
col: colIdx
|
|
20401
|
+
col: colIdx,
|
|
20402
|
+
key: matchKey
|
|
20365
20403
|
});
|
|
20366
20404
|
} else {
|
|
20367
20405
|
const paras = valueCell.paragraphs;
|
|
@@ -20383,7 +20421,8 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20383
20421
|
label: labelText.trim().replace(/[::]\s*$/, ""),
|
|
20384
20422
|
value: newValue,
|
|
20385
20423
|
row: rowIdx,
|
|
20386
|
-
col: colIdx
|
|
20424
|
+
col: colIdx,
|
|
20425
|
+
key: matchKey
|
|
20387
20426
|
});
|
|
20388
20427
|
}
|
|
20389
20428
|
}
|
|
@@ -20399,6 +20438,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20399
20438
|
const dataCells = table.rows[rowIdx];
|
|
20400
20439
|
for (let colIdx = 0; colIdx < Math.min(headerCells.length, dataCells.length); colIdx++) {
|
|
20401
20440
|
const headerLabel = normalizeLabel(cellLabelText(headerCells[colIdx]));
|
|
20441
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _164 => _164.has, 'call', _165 => _165(headerLabel)])) continue;
|
|
20402
20442
|
const matchKey = findMatchingKey(headerLabel, cursor);
|
|
20403
20443
|
if (matchKey === void 0) continue;
|
|
20404
20444
|
if (!cursor.isArray(matchKey) && matchedLabels.has(matchKey)) continue;
|
|
@@ -20431,10 +20471,12 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20431
20471
|
}
|
|
20432
20472
|
for (const para of [...scan.bodyParagraphs, ...scan.excludedParagraphs]) {
|
|
20433
20473
|
const existing = ledger.get(para);
|
|
20434
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
20474
|
+
if (_optionalChain([existing, 'optionalAccess', _166 => _166.fullText]) !== void 0) continue;
|
|
20435
20475
|
const text = matchText(para);
|
|
20436
20476
|
for (const seg of scanInlineSegments(text)) {
|
|
20437
|
-
const
|
|
20477
|
+
const nlabel = normalizeLabel(seg.label);
|
|
20478
|
+
if (_optionalChain([blockedLabels, 'optionalAccess', _167 => _167.has, 'call', _168 => _168(nlabel)])) continue;
|
|
20479
|
+
const matchKey = findMatchingKey(nlabel, cursor);
|
|
20438
20480
|
if (matchKey === void 0) continue;
|
|
20439
20481
|
const newValue = cursor.consume(matchKey);
|
|
20440
20482
|
if (newValue === void 0) continue;
|
|
@@ -20444,7 +20486,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
20444
20486
|
matchedLabels.add(matchKey);
|
|
20445
20487
|
l.filledIdx.push(filled.length);
|
|
20446
20488
|
l.matchKeys.push(matchKey);
|
|
20447
|
-
filled.push({ label: seg.label.trim(), value: newValue, row: -1, col: -1 });
|
|
20489
|
+
filled.push({ label: seg.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
|
|
20448
20490
|
}
|
|
20449
20491
|
}
|
|
20450
20492
|
const splices = [];
|
|
@@ -20670,8 +20712,8 @@ function charWidthEm1000(cp) {
|
|
|
20670
20712
|
var SPACE_EM_FIXED = 500;
|
|
20671
20713
|
var SPACE_EM_FONT = 300;
|
|
20672
20714
|
function measureTextWidth(text, height, ratioPct, opts) {
|
|
20673
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20674
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20715
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _169 => _169.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20716
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _170 => _170.spacingPct]), () => ( 0));
|
|
20675
20717
|
let em = 0;
|
|
20676
20718
|
for (const ch of text) {
|
|
20677
20719
|
const cp = ch.codePointAt(0);
|
|
@@ -20684,8 +20726,8 @@ var FORBID_START = /* @__PURE__ */ new Set([..."!%),.:;?]}\xA2\xB0\u2032\u2033\u
|
|
|
20684
20726
|
var FORBID_END = /* @__PURE__ */ new Set([..."$([{\xA3\xA5\u3008\u300A\u300C\u300E\u3010\u3014$([{\u20A9"]);
|
|
20685
20727
|
function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "keep", opts) {
|
|
20686
20728
|
const EPS = 0.5;
|
|
20687
|
-
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20688
|
-
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
20729
|
+
const spaceEm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _171 => _171.spaceEm]), () => ( SPACE_EM_FIXED));
|
|
20730
|
+
const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _172 => _172.spacingPct]), () => ( 0));
|
|
20689
20731
|
const k = height * ratioPct / 100 / 1e3;
|
|
20690
20732
|
const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
|
|
20691
20733
|
const charW2 = (ch) => cwCp(ch.codePointAt(0));
|
|
@@ -20911,16 +20953,16 @@ var PARA_LIST = 7;
|
|
|
20911
20953
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
20912
20954
|
function resolveTheme(theme) {
|
|
20913
20955
|
return {
|
|
20914
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20915
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20916
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20917
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20918
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20919
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20956
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _173 => _173.headingColors, 'optionalAccess', _174 => _174[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20957
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _175 => _175.headingColors, 'optionalAccess', _176 => _176[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20958
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _177 => _177.headingColors, 'optionalAccess', _178 => _178[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20959
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _179 => _179.headingColors, 'optionalAccess', _180 => _180[4]]), () => ( _optionalChain([theme, 'optionalAccess', _181 => _181.headingColors, 'optionalAccess', _182 => _182[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20960
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _183 => _183.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20961
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _184 => _184.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
20920
20962
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
20921
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
20922
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
20923
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
20963
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _185 => _185.quoteColor]) !== void 0,
|
|
20964
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _186 => _186.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _187 => _187.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
20965
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _188 => _188.tableHeaderBold])
|
|
20924
20966
|
};
|
|
20925
20967
|
}
|
|
20926
20968
|
function escapeXml(text) {
|
|
@@ -20977,7 +21019,8 @@ function buildPrvText(blocks) {
|
|
|
20977
21019
|
let bytes = 0;
|
|
20978
21020
|
for (const b of blocks) {
|
|
20979
21021
|
let text = b.text || (b.rows ? b.rows.map((r) => r.join(" ")).join("\n") : "");
|
|
20980
|
-
if (b.type === "
|
|
21022
|
+
if (b.type === "code_block" && (b.lang || "").toLowerCase() === "chart") text = "[\uCC28\uD2B8]";
|
|
21023
|
+
else if (b.type === "html_table") text = text.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
20981
21024
|
if (!text) continue;
|
|
20982
21025
|
lines.push(text);
|
|
20983
21026
|
bytes += text.length * 3;
|
|
@@ -20996,7 +21039,7 @@ function findMathDelim(s, from) {
|
|
|
20996
21039
|
return i;
|
|
20997
21040
|
}
|
|
20998
21041
|
function parseMarkdownToBlocks(md2) {
|
|
20999
|
-
const lines = md2.split("\n");
|
|
21042
|
+
const lines = md2.replace(/\r\n?/g, "\n").split("\n");
|
|
21000
21043
|
const blocks = [];
|
|
21001
21044
|
let i = 0;
|
|
21002
21045
|
while (i < lines.length) {
|
|
@@ -21044,13 +21087,13 @@ function parseMarkdownToBlocks(md2) {
|
|
|
21044
21087
|
continue;
|
|
21045
21088
|
}
|
|
21046
21089
|
}
|
|
21047
|
-
const fenceMatch = line.match(/^(`{3,}|~{3,})(.*)$/);
|
|
21090
|
+
const fenceMatch = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
21048
21091
|
if (fenceMatch) {
|
|
21049
21092
|
const fence = fenceMatch[1];
|
|
21050
21093
|
const lang = fenceMatch[2].trim();
|
|
21051
21094
|
const codeLines = [];
|
|
21052
21095
|
i++;
|
|
21053
|
-
while (i < lines.length && !lines[i].startsWith(fence)) {
|
|
21096
|
+
while (i < lines.length && !lines[i].replace(/^ {0,3}/, "").startsWith(fence)) {
|
|
21054
21097
|
codeLines.push(lines[i]);
|
|
21055
21098
|
i++;
|
|
21056
21099
|
}
|
|
@@ -21299,7 +21342,7 @@ ${heads}
|
|
|
21299
21342
|
</hh:numberings>`;
|
|
21300
21343
|
}
|
|
21301
21344
|
function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
21302
|
-
const bodyFace = _optionalChain([gongmun, 'optionalAccess',
|
|
21345
|
+
const bodyFace = _optionalChain([gongmun, 'optionalAccess', _189 => _189.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5";
|
|
21303
21346
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants);
|
|
21304
21347
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21305
21348
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -21386,6 +21429,219 @@ function generateHeaderXml(theme, gongmun, ratioVariants = []) {
|
|
|
21386
21429
|
</hh:head>`;
|
|
21387
21430
|
}
|
|
21388
21431
|
|
|
21432
|
+
// src/hwpx/chart-gen.ts
|
|
21433
|
+
var XML_ESC = { "&": "&", "<": "<", ">": ">" };
|
|
21434
|
+
var xmlEscape = (s) => s.replace(/[&<>]/g, (c) => XML_ESC[c]);
|
|
21435
|
+
var CHART_TYPES = {
|
|
21436
|
+
0: { el: "barChart", dir: "col", grp: "clustered" },
|
|
21437
|
+
1: { el: "barChart", dir: "col", grp: "stacked", overlap: 100 },
|
|
21438
|
+
2: { el: "lineChart", grp: "standard", marker: true },
|
|
21439
|
+
3: { el: "barChart", dir: "bar", grp: "clustered" },
|
|
21440
|
+
4: { el: "barChart", dir: "bar", grp: "stacked", overlap: 100 },
|
|
21441
|
+
5: { el: "scatterChart", scatter: true },
|
|
21442
|
+
6: { el: "pieChart", pie: true },
|
|
21443
|
+
7: { el: "pieChart", pie: true, explode: true },
|
|
21444
|
+
8: { el: "doughnutChart", pie: true, hole: 50 },
|
|
21445
|
+
9: { el: "areaChart", grp: "standard" },
|
|
21446
|
+
10: { el: "areaChart", grp: "stacked" },
|
|
21447
|
+
11: { el: "radarChart", radar: true },
|
|
21448
|
+
12: { el: "bar3DChart", dir: "col", grp: "clustered" },
|
|
21449
|
+
13: { el: "bar3DChart", dir: "col", grp: "stacked", overlap: 100 },
|
|
21450
|
+
14: { el: "bar3DChart", dir: "bar", grp: "clustered" },
|
|
21451
|
+
15: { el: "bar3DChart", dir: "bar", grp: "stacked", overlap: 100 },
|
|
21452
|
+
16: { el: "pie3DChart", pie: true },
|
|
21453
|
+
17: { el: "pie3DChart", pie: true, explode: true },
|
|
21454
|
+
18: { el: "area3DChart", grp: "standard" },
|
|
21455
|
+
19: { el: "area3DChart", grp: "stacked" }
|
|
21456
|
+
};
|
|
21457
|
+
var CHART_ALIAS = {
|
|
21458
|
+
column: 0,
|
|
21459
|
+
col: 0,
|
|
21460
|
+
\uC138\uB85C\uB9C9\uB300: 0,
|
|
21461
|
+
\uB9C9\uB300: 0,
|
|
21462
|
+
column_stacked: 1,
|
|
21463
|
+
\uC138\uB85C\uB9C9\uB300_\uB204\uC801: 1,
|
|
21464
|
+
line: 2,
|
|
21465
|
+
\uC120: 2,
|
|
21466
|
+
\uAEBE\uC740\uC120: 2,
|
|
21467
|
+
bar: 3,
|
|
21468
|
+
\uAC00\uB85C\uB9C9\uB300: 3,
|
|
21469
|
+
bar_stacked: 4,
|
|
21470
|
+
scatter: 5,
|
|
21471
|
+
\uBD84\uC0B0: 5,
|
|
21472
|
+
pie: 6,
|
|
21473
|
+
\uC6D0: 6,
|
|
21474
|
+
\uD30C\uC774: 6,
|
|
21475
|
+
pie_explode: 7,
|
|
21476
|
+
doughnut: 8,
|
|
21477
|
+
donut: 8,
|
|
21478
|
+
\uB3C4\uB11B: 8,
|
|
21479
|
+
area: 9,
|
|
21480
|
+
\uC601\uC5ED: 9,
|
|
21481
|
+
area_stacked: 10,
|
|
21482
|
+
radar: 11,
|
|
21483
|
+
\uBC29\uC0AC\uD615: 11,
|
|
21484
|
+
bar3d: 12,
|
|
21485
|
+
column3d: 12,
|
|
21486
|
+
pie3d: 16
|
|
21487
|
+
};
|
|
21488
|
+
function chartSpec(t) {
|
|
21489
|
+
if (!t) return CHART_TYPES[0];
|
|
21490
|
+
const key = _nullishCoalesce(CHART_ALIAS[t.toLowerCase()], () => ( Number(t)));
|
|
21491
|
+
return _nullishCoalesce(CHART_TYPES[key], () => ( CHART_TYPES[0]));
|
|
21492
|
+
}
|
|
21493
|
+
var HU_PER_MM = 7200 / 25.4;
|
|
21494
|
+
var RESERVED_KEYS = /* @__PURE__ */ new Set(["type", "cat", "size", "colors", "point_colors", "title"]);
|
|
21495
|
+
function parseChartFence(text) {
|
|
21496
|
+
let type;
|
|
21497
|
+
let cat = null;
|
|
21498
|
+
let widthMm = 32250 / HU_PER_MM;
|
|
21499
|
+
let heightMm = 18750 / HU_PER_MM;
|
|
21500
|
+
let colors = null;
|
|
21501
|
+
let pointColors = null;
|
|
21502
|
+
const series = [];
|
|
21503
|
+
for (const rawLine of text.split("\n")) {
|
|
21504
|
+
const line = rawLine.trim();
|
|
21505
|
+
if (!line || line.startsWith("#")) continue;
|
|
21506
|
+
const colon = line.search(/[::]/);
|
|
21507
|
+
if (colon <= 0) continue;
|
|
21508
|
+
const key = line.slice(0, colon).trim();
|
|
21509
|
+
const value = line.slice(colon + 1).trim();
|
|
21510
|
+
const keyLower = key.toLowerCase();
|
|
21511
|
+
if (keyLower === "type") {
|
|
21512
|
+
type = value;
|
|
21513
|
+
} else if (keyLower === "cat") {
|
|
21514
|
+
cat = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
21515
|
+
} else if (keyLower === "size") {
|
|
21516
|
+
const m = value.match(/^(\d+(?:\.\d+)?)\s*[x×]\s*(\d+(?:\.\d+)?)$/i);
|
|
21517
|
+
if (m) {
|
|
21518
|
+
const clamp = (n) => Math.min(500, Math.max(10, n));
|
|
21519
|
+
widthMm = clamp(Number(m[1]));
|
|
21520
|
+
heightMm = clamp(Number(m[2]));
|
|
21521
|
+
}
|
|
21522
|
+
} else if (keyLower === "colors") {
|
|
21523
|
+
colors = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
21524
|
+
} else if (keyLower === "point_colors") {
|
|
21525
|
+
pointColors = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
21526
|
+
} else if (keyLower === "title") {
|
|
21527
|
+
} else if (!RESERVED_KEYS.has(keyLower)) {
|
|
21528
|
+
const segs = value.replace(/(\d),(?=\d{3}(?:\D|$))/g, "$1").split(",").map((s) => s.trim()).filter(Boolean);
|
|
21529
|
+
if (segs.length === 0) continue;
|
|
21530
|
+
const nums = segs.map(Number);
|
|
21531
|
+
if (nums.every((n) => Number.isFinite(n))) {
|
|
21532
|
+
series.push({ name: key, values: nums });
|
|
21533
|
+
} else {
|
|
21534
|
+
return null;
|
|
21535
|
+
}
|
|
21536
|
+
}
|
|
21537
|
+
}
|
|
21538
|
+
if (series.length === 0) return null;
|
|
21539
|
+
const spec = chartSpec(type);
|
|
21540
|
+
let finalSeries = spec.pie ? [series[0]] : series;
|
|
21541
|
+
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
21542
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _190 => _190.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
21543
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _191 => _191[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
21544
|
+
if (!spec.scatter) {
|
|
21545
|
+
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
21546
|
+
}
|
|
21547
|
+
if (spec.pie) {
|
|
21548
|
+
const slice = _nullishCoalesce(colors, () => ( pointColors));
|
|
21549
|
+
if (slice) finalSeries[0].pointColors = slice;
|
|
21550
|
+
} else {
|
|
21551
|
+
if (colors) finalSeries.forEach((s, i) => {
|
|
21552
|
+
s.color = colors[i % colors.length];
|
|
21553
|
+
});
|
|
21554
|
+
if (pointColors && finalSeries[0]) finalSeries[0].pointColors = pointColors;
|
|
21555
|
+
}
|
|
21556
|
+
return {
|
|
21557
|
+
spec,
|
|
21558
|
+
cat: catFinal,
|
|
21559
|
+
series: finalSeries,
|
|
21560
|
+
widthHu: Math.round(widthMm * HU_PER_MM),
|
|
21561
|
+
heightHu: Math.round(heightMm * HU_PER_MM)
|
|
21562
|
+
};
|
|
21563
|
+
}
|
|
21564
|
+
var colLetter = (i) => String.fromCharCode(66 + i);
|
|
21565
|
+
function strCachePts(vals) {
|
|
21566
|
+
return `<c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${xmlEscape(v)}</c:v></c:pt>`).join("");
|
|
21567
|
+
}
|
|
21568
|
+
function numCachePts(vals) {
|
|
21569
|
+
return `<c:formatCode>General</c:formatCode><c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${Number(v) || 0}</c:v></c:pt>`).join("");
|
|
21570
|
+
}
|
|
21571
|
+
function chartColorFill(color) {
|
|
21572
|
+
if (color == null) return null;
|
|
21573
|
+
const c = color.trim();
|
|
21574
|
+
if (/^accent[1-6]$/i.test(c)) return `<a:solidFill><a:schemeClr val="${c.toLowerCase()}"/></a:solidFill>`;
|
|
21575
|
+
const hex = c.replace(/^#/, "").toUpperCase();
|
|
21576
|
+
if (/^[0-9A-F]{6}$/.test(hex)) return `<a:solidFill><a:srgbClr val="${hex}"/></a:solidFill>`;
|
|
21577
|
+
return null;
|
|
21578
|
+
}
|
|
21579
|
+
function serSpPr(color, stroke) {
|
|
21580
|
+
const f = chartColorFill(color);
|
|
21581
|
+
if (!f) return "<c:spPr/>";
|
|
21582
|
+
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
|
+
}
|
|
21584
|
+
function dPtXml(pointColors, pie) {
|
|
21585
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _192 => _192.length])) return "";
|
|
21586
|
+
return pointColors.map((col, i) => {
|
|
21587
|
+
const f = chartColorFill(col);
|
|
21588
|
+
if (!f) return "";
|
|
21589
|
+
const mid = pie ? '<c:invertIfNegative val="0"/><c:bubble3D val="0"/><c:explosion val="0"/>' : '<c:bubble3D val="0"/>';
|
|
21590
|
+
return `<c:dPt><c:idx val="${i}"/>${mid}<c:spPr>${f}</c:spPr></c:dPt>`;
|
|
21591
|
+
}).join("");
|
|
21592
|
+
}
|
|
21593
|
+
function stdSer(idx, name, cat, values, explode, color, pointColors, stroke, pie) {
|
|
21594
|
+
const cl = colLetter(idx);
|
|
21595
|
+
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx>${serSpPr(color, stroke)}<c:invertIfNegative val="0"/>` + (explode ? `<c:explosion val="25"/>` : "") + dPtXml(pointColors, pie) + `<c:cat><c:strRef><c:f>Sheet1!$A$2:$A$${cat.length + 1}</c:f><c:strCache>${strCachePts(cat)}</c:strCache></c:strRef></c:cat><c:val><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${values.length + 1}</c:f><c:numCache>${numCachePts(values)}</c:numCache></c:numRef></c:val></c:ser>`;
|
|
21596
|
+
}
|
|
21597
|
+
function scatterSer(idx, name, xvals, yvals) {
|
|
21598
|
+
const cl = colLetter(idx);
|
|
21599
|
+
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx><c:spPr><a:ln w="28575"><a:noFill/></a:ln></c:spPr><c:marker><c:symbol val="circle"/><c:size val="7"/></c:marker><c:xVal><c:numRef><c:f>Sheet1!$A$2:$A$${xvals.length + 1}</c:f><c:numCache>${numCachePts(xvals)}</c:numCache></c:numRef></c:xVal><c:yVal><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${yvals.length + 1}</c:f><c:numCache>${numCachePts(yvals)}</c:numCache></c:numRef></c:yVal></c:ser>`;
|
|
21600
|
+
}
|
|
21601
|
+
function catAxXml(id, pos, cross) {
|
|
21602
|
+
return `<c:catAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
|
|
21603
|
+
}
|
|
21604
|
+
function valAxXml(id, pos, cross) {
|
|
21605
|
+
return `<c:valAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:majorGridlines/><c:numFmt formatCode="General" sourceLinked="1"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>`;
|
|
21606
|
+
}
|
|
21607
|
+
function buildChartSpaceXml(fence) {
|
|
21608
|
+
const { spec, cat, series } = fence;
|
|
21609
|
+
const NS = 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"';
|
|
21610
|
+
const ax1 = "111111111";
|
|
21611
|
+
const ax2 = "222222222";
|
|
21612
|
+
let plot;
|
|
21613
|
+
if (spec.scatter) {
|
|
21614
|
+
const n = Math.max(0, ...series.map((s) => s.values.length));
|
|
21615
|
+
const xs = Array.from({ length: n }, (_, i) => {
|
|
21616
|
+
const c = cat[i];
|
|
21617
|
+
const v = Number(c);
|
|
21618
|
+
return c !== void 0 && c !== "" && Number.isFinite(v) ? v : i + 1;
|
|
21619
|
+
});
|
|
21620
|
+
const sers = series.map((s, i) => scatterSer(i, s.name, xs, s.values)).join("");
|
|
21621
|
+
plot = `<c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>${sers}<c:axId val="${ax1}"/><c:axId val="${ax2}"/></c:scatterChart>` + valAxXml(ax1, "b", ax2) + valAxXml(ax2, "l", ax1);
|
|
21622
|
+
} else if (spec.pie) {
|
|
21623
|
+
const s0 = series[0];
|
|
21624
|
+
plot = `<c:${spec.el}><c:varyColors val="1"/>${stdSer(0, s0.name, cat, s0.values, !!spec.explode, s0.color, s0.pointColors, false, true)}<c:firstSliceAng val="0"/>` + (spec.hole != null ? `<c:holeSize val="${spec.hole}"/>` : "") + `</c:${spec.el}>`;
|
|
21625
|
+
} else {
|
|
21626
|
+
const stroke = spec.el === "lineChart" || spec.el === "radarChart" || !!spec.radar;
|
|
21627
|
+
const sers = series.map((s, i) => stdSer(i, s.name, cat, s.values, false, s.color, s.pointColors, stroke, false)).join("");
|
|
21628
|
+
const horiz = spec.dir === "bar";
|
|
21629
|
+
let inner = "";
|
|
21630
|
+
if (spec.dir) inner += `<c:barDir val="${spec.dir}"/>`;
|
|
21631
|
+
if (spec.grp) inner += `<c:grouping val="${spec.grp}"/>`;
|
|
21632
|
+
if (spec.radar) inner += `<c:radarStyle val="standard"/>`;
|
|
21633
|
+
inner += `<c:varyColors val="0"/>${sers}`;
|
|
21634
|
+
if (spec.marker) inner += `<c:marker val="1"/>`;
|
|
21635
|
+
if (spec.el.startsWith("bar")) inner += `<c:gapWidth val="150"/><c:overlap val="${_nullishCoalesce(spec.overlap, () => ( 0))}"/>`;
|
|
21636
|
+
inner += `<c:axId val="${ax1}"/><c:axId val="${ax2}"/>`;
|
|
21637
|
+
plot = `<c:${spec.el}>${inner}</c:${spec.el}>` + catAxXml(ax1, horiz ? "l" : "b", ax2) + valAxXml(ax2, horiz ? "b" : "l", ax1);
|
|
21638
|
+
}
|
|
21639
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><c:chartSpace ${NS}><c:date1904 val="0"/><c:roundedCorners val="0"/><c:chart><c:autoTitleDeleted val="0"/><c:plotArea><c:layout/>${plot}</c:plotArea><c:legend><c:legendPos val="r"/><c:overlay val="0"/></c:legend><c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/></c:chart></c:chartSpace>`;
|
|
21640
|
+
}
|
|
21641
|
+
function buildChartElementXml(partName, widthHu, heightHu, id) {
|
|
21642
|
+
return `<hp:chart id="${id}" zOrder="0" numberingType="PICTURE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" chartIDRef="${partName}"><hp:sz width="${widthHu}" widthRelTo="ABSOLUTE" height="${heightHu}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="709" right="709" top="709" bottom="709"/></hp:chart>`;
|
|
21643
|
+
}
|
|
21644
|
+
|
|
21389
21645
|
// src/hwpx/gen-gongmun-fit.ts
|
|
21390
21646
|
function plainRenderText(text) {
|
|
21391
21647
|
return parseInlineMarkdown(text).map((s) => s.text).join("");
|
|
@@ -21438,18 +21694,18 @@ function precomputeGongmunList(blocks, gongmun) {
|
|
|
21438
21694
|
i++;
|
|
21439
21695
|
continue;
|
|
21440
21696
|
}
|
|
21441
|
-
const passThrough = (
|
|
21697
|
+
const passThrough = (b) => b.type === "table" || b.type === "html_table" || b.type === "equation" || b.type === "code_block" && (b.lang || "").toLowerCase() === "chart" && parseChartFence(b.text || "") !== null;
|
|
21442
21698
|
const run = [];
|
|
21443
21699
|
while (i < blocks.length) {
|
|
21444
|
-
const
|
|
21445
|
-
if (
|
|
21700
|
+
const b = blocks[i];
|
|
21701
|
+
if (b.type === "list_item") {
|
|
21446
21702
|
run.push(i);
|
|
21447
21703
|
i++;
|
|
21448
21704
|
continue;
|
|
21449
21705
|
}
|
|
21450
|
-
if (passThrough(
|
|
21706
|
+
if (passThrough(b)) {
|
|
21451
21707
|
let j = i + 1;
|
|
21452
|
-
while (j < blocks.length && passThrough(blocks[j]
|
|
21708
|
+
while (j < blocks.length && passThrough(blocks[j])) j++;
|
|
21453
21709
|
if (j < blocks.length && blocks[j].type === "list_item") {
|
|
21454
21710
|
i = j;
|
|
21455
21711
|
continue;
|
|
@@ -21645,7 +21901,7 @@ function escapeGfm(text) {
|
|
|
21645
21901
|
}
|
|
21646
21902
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
21647
21903
|
function sanitizeText(text) {
|
|
21648
|
-
let result =
|
|
21904
|
+
let result = _chunkVNIQK4ALcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
21649
21905
|
if (result.length <= 30 && result.includes(" ")) {
|
|
21650
21906
|
const tokens = result.split(" ");
|
|
21651
21907
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21675,7 +21931,7 @@ function replicateGfmTable(table) {
|
|
|
21675
21931
|
for (let r = 0; r < numRows; r++) {
|
|
21676
21932
|
for (let c = 0; c < numCols; c++) {
|
|
21677
21933
|
if (skip.has(`${r},${c}`)) continue;
|
|
21678
|
-
const cell = _optionalChain([cells, 'access',
|
|
21934
|
+
const cell = _optionalChain([cells, 'access', _193 => _193[r], 'optionalAccess', _194 => _194[c]]);
|
|
21679
21935
|
if (!cell) continue;
|
|
21680
21936
|
display[r][c] = {
|
|
21681
21937
|
text: escapeGfm(sanitizeText(cell.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -21729,7 +21985,7 @@ function unescapeGfmCell(text) {
|
|
|
21729
21985
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
21730
21986
|
}
|
|
21731
21987
|
function replicateCellInnerHtml(cell) {
|
|
21732
|
-
if (_optionalChain([cell, 'access',
|
|
21988
|
+
if (_optionalChain([cell, 'access', _195 => _195.blocks, 'optionalAccess', _196 => _196.length])) {
|
|
21733
21989
|
return cell.blocks.map((b) => {
|
|
21734
21990
|
if (b.type === "table" && b.table) {
|
|
21735
21991
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -21768,7 +22024,7 @@ function replicateHtmlTable(table) {
|
|
|
21768
22024
|
const rowCells = [];
|
|
21769
22025
|
for (let c = 0; c < numCols; c++) {
|
|
21770
22026
|
if (skip.has(`${r},${c}`)) continue;
|
|
21771
|
-
const cell = _optionalChain([cells, 'access',
|
|
22027
|
+
const cell = _optionalChain([cells, 'access', _197 => _197[r], 'optionalAccess', _198 => _198[c]]);
|
|
21772
22028
|
if (!cell) continue;
|
|
21773
22029
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
21774
22030
|
for (let dc = 0; dc < cell.colSpan; dc++) {
|
|
@@ -21814,8 +22070,8 @@ function parseHtmlTable(raw) {
|
|
|
21814
22070
|
}
|
|
21815
22071
|
} else {
|
|
21816
22072
|
if (!isClose) {
|
|
21817
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
21818
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
22073
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _199 => _199.match, 'call', _200 => _200(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _201 => _201[1]]) || "1", 10);
|
|
22074
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _202 => _202.match, 'call', _203 => _203(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _204 => _204[1]]) || "1", 10);
|
|
21819
22075
|
cellStart = m.index + m[0].length;
|
|
21820
22076
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
21821
22077
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -22252,210 +22508,6 @@ function generateEquationParagraph(input, zOrder = 0) {
|
|
|
22252
22508
|
return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${generateEquationXml(script, zOrder)}</hp:run></hp:p>`;
|
|
22253
22509
|
}
|
|
22254
22510
|
|
|
22255
|
-
// src/hwpx/chart-gen.ts
|
|
22256
|
-
var XML_ESC = { "&": "&", "<": "<", ">": ">" };
|
|
22257
|
-
var xmlEscape = (s) => s.replace(/[&<>]/g, (c) => XML_ESC[c]);
|
|
22258
|
-
var CHART_TYPES = {
|
|
22259
|
-
0: { el: "barChart", dir: "col", grp: "clustered" },
|
|
22260
|
-
1: { el: "barChart", dir: "col", grp: "stacked", overlap: 100 },
|
|
22261
|
-
2: { el: "lineChart", grp: "standard", marker: true },
|
|
22262
|
-
3: { el: "barChart", dir: "bar", grp: "clustered" },
|
|
22263
|
-
4: { el: "barChart", dir: "bar", grp: "stacked", overlap: 100 },
|
|
22264
|
-
5: { el: "scatterChart", scatter: true },
|
|
22265
|
-
6: { el: "pieChart", pie: true },
|
|
22266
|
-
7: { el: "pieChart", pie: true, explode: true },
|
|
22267
|
-
8: { el: "doughnutChart", pie: true, hole: 50 },
|
|
22268
|
-
9: { el: "areaChart", grp: "standard" },
|
|
22269
|
-
10: { el: "areaChart", grp: "stacked" },
|
|
22270
|
-
11: { el: "radarChart", radar: true },
|
|
22271
|
-
12: { el: "bar3DChart", dir: "col", grp: "clustered" },
|
|
22272
|
-
13: { el: "bar3DChart", dir: "col", grp: "stacked", overlap: 100 },
|
|
22273
|
-
14: { el: "bar3DChart", dir: "bar", grp: "clustered" },
|
|
22274
|
-
15: { el: "bar3DChart", dir: "bar", grp: "stacked", overlap: 100 },
|
|
22275
|
-
16: { el: "pie3DChart", pie: true },
|
|
22276
|
-
17: { el: "pie3DChart", pie: true, explode: true },
|
|
22277
|
-
18: { el: "area3DChart", grp: "standard" },
|
|
22278
|
-
19: { el: "area3DChart", grp: "stacked" }
|
|
22279
|
-
};
|
|
22280
|
-
var CHART_ALIAS = {
|
|
22281
|
-
column: 0,
|
|
22282
|
-
col: 0,
|
|
22283
|
-
\uC138\uB85C\uB9C9\uB300: 0,
|
|
22284
|
-
\uB9C9\uB300: 0,
|
|
22285
|
-
column_stacked: 1,
|
|
22286
|
-
\uC138\uB85C\uB9C9\uB300_\uB204\uC801: 1,
|
|
22287
|
-
line: 2,
|
|
22288
|
-
\uC120: 2,
|
|
22289
|
-
\uAEBE\uC740\uC120: 2,
|
|
22290
|
-
bar: 3,
|
|
22291
|
-
\uAC00\uB85C\uB9C9\uB300: 3,
|
|
22292
|
-
bar_stacked: 4,
|
|
22293
|
-
scatter: 5,
|
|
22294
|
-
\uBD84\uC0B0: 5,
|
|
22295
|
-
pie: 6,
|
|
22296
|
-
\uC6D0: 6,
|
|
22297
|
-
\uD30C\uC774: 6,
|
|
22298
|
-
pie_explode: 7,
|
|
22299
|
-
doughnut: 8,
|
|
22300
|
-
donut: 8,
|
|
22301
|
-
\uB3C4\uB11B: 8,
|
|
22302
|
-
area: 9,
|
|
22303
|
-
\uC601\uC5ED: 9,
|
|
22304
|
-
area_stacked: 10,
|
|
22305
|
-
radar: 11,
|
|
22306
|
-
\uBC29\uC0AC\uD615: 11,
|
|
22307
|
-
bar3d: 12,
|
|
22308
|
-
column3d: 12,
|
|
22309
|
-
pie3d: 16
|
|
22310
|
-
};
|
|
22311
|
-
function chartSpec(t) {
|
|
22312
|
-
if (!t) return CHART_TYPES[0];
|
|
22313
|
-
const key = _nullishCoalesce(CHART_ALIAS[t.toLowerCase()], () => ( Number(t)));
|
|
22314
|
-
return _nullishCoalesce(CHART_TYPES[key], () => ( CHART_TYPES[0]));
|
|
22315
|
-
}
|
|
22316
|
-
var HU_PER_MM = 7200 / 25.4;
|
|
22317
|
-
var RESERVED_KEYS = /* @__PURE__ */ new Set(["type", "cat", "size", "colors", "point_colors", "title"]);
|
|
22318
|
-
function parseChartFence(text) {
|
|
22319
|
-
let type;
|
|
22320
|
-
let cat = null;
|
|
22321
|
-
let widthMm = 32250 / HU_PER_MM;
|
|
22322
|
-
let heightMm = 18750 / HU_PER_MM;
|
|
22323
|
-
let colors = null;
|
|
22324
|
-
let pointColors = null;
|
|
22325
|
-
const series = [];
|
|
22326
|
-
for (const rawLine of text.split("\n")) {
|
|
22327
|
-
const line = rawLine.trim();
|
|
22328
|
-
if (!line || line.startsWith("#")) continue;
|
|
22329
|
-
const colon = line.search(/[::]/);
|
|
22330
|
-
if (colon <= 0) continue;
|
|
22331
|
-
const key = line.slice(0, colon).trim();
|
|
22332
|
-
const value = line.slice(colon + 1).trim();
|
|
22333
|
-
const keyLower = key.toLowerCase();
|
|
22334
|
-
if (keyLower === "type") {
|
|
22335
|
-
type = value;
|
|
22336
|
-
} else if (keyLower === "cat") {
|
|
22337
|
-
cat = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
22338
|
-
} else if (keyLower === "size") {
|
|
22339
|
-
const m = value.match(/^(\d+(?:\.\d+)?)\s*[x×]\s*(\d+(?:\.\d+)?)$/i);
|
|
22340
|
-
if (m) {
|
|
22341
|
-
widthMm = Number(m[1]);
|
|
22342
|
-
heightMm = Number(m[2]);
|
|
22343
|
-
}
|
|
22344
|
-
} else if (keyLower === "colors") {
|
|
22345
|
-
colors = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
22346
|
-
} else if (keyLower === "point_colors") {
|
|
22347
|
-
pointColors = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
22348
|
-
} else if (keyLower === "title") {
|
|
22349
|
-
} else if (!RESERVED_KEYS.has(keyLower)) {
|
|
22350
|
-
const nums = value.split(",").map((s) => Number(s.trim()));
|
|
22351
|
-
if (nums.length > 0 && nums.every((n) => Number.isFinite(n))) {
|
|
22352
|
-
series.push({ name: key, values: nums });
|
|
22353
|
-
}
|
|
22354
|
-
}
|
|
22355
|
-
}
|
|
22356
|
-
if (series.length === 0) return null;
|
|
22357
|
-
const spec = chartSpec(type);
|
|
22358
|
-
const catFinal = _nullishCoalesce(cat, () => ( series[0].values.map((_, i) => `\uD56D\uBAA9 ${i + 1}`)));
|
|
22359
|
-
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22360
|
-
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22361
|
-
if (spec.pie) {
|
|
22362
|
-
const slice = _nullishCoalesce(colors, () => ( pointColors));
|
|
22363
|
-
if (slice) finalSeries[0].pointColors = slice;
|
|
22364
|
-
} else {
|
|
22365
|
-
if (colors) finalSeries.forEach((s, i) => {
|
|
22366
|
-
s.color = colors[i % colors.length];
|
|
22367
|
-
});
|
|
22368
|
-
if (pointColors && finalSeries[0]) finalSeries[0].pointColors = pointColors;
|
|
22369
|
-
}
|
|
22370
|
-
return {
|
|
22371
|
-
spec,
|
|
22372
|
-
cat: catFinal,
|
|
22373
|
-
series: finalSeries,
|
|
22374
|
-
widthHu: Math.round(widthMm * HU_PER_MM),
|
|
22375
|
-
heightHu: Math.round(heightMm * HU_PER_MM)
|
|
22376
|
-
};
|
|
22377
|
-
}
|
|
22378
|
-
var colLetter = (i) => String.fromCharCode(66 + i);
|
|
22379
|
-
function strCachePts(vals) {
|
|
22380
|
-
return `<c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${xmlEscape(v)}</c:v></c:pt>`).join("");
|
|
22381
|
-
}
|
|
22382
|
-
function numCachePts(vals) {
|
|
22383
|
-
return `<c:formatCode>General</c:formatCode><c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${Number(v) || 0}</c:v></c:pt>`).join("");
|
|
22384
|
-
}
|
|
22385
|
-
function chartColorFill(color) {
|
|
22386
|
-
if (color == null) return null;
|
|
22387
|
-
const c = color.trim();
|
|
22388
|
-
if (/^accent[1-6]$/i.test(c)) return `<a:solidFill><a:schemeClr val="${c.toLowerCase()}"/></a:solidFill>`;
|
|
22389
|
-
const hex = c.replace(/^#/, "").toUpperCase();
|
|
22390
|
-
if (/^[0-9A-F]{6}$/.test(hex)) return `<a:solidFill><a:srgbClr val="${hex}"/></a:solidFill>`;
|
|
22391
|
-
return null;
|
|
22392
|
-
}
|
|
22393
|
-
function serSpPr(color, stroke) {
|
|
22394
|
-
const f = chartColorFill(color);
|
|
22395
|
-
if (!f) return "<c:spPr/>";
|
|
22396
|
-
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>`;
|
|
22397
|
-
}
|
|
22398
|
-
function dPtXml(pointColors, pie) {
|
|
22399
|
-
if (!_optionalChain([pointColors, 'optionalAccess', _188 => _188.length])) return "";
|
|
22400
|
-
return pointColors.map((col, i) => {
|
|
22401
|
-
const f = chartColorFill(col);
|
|
22402
|
-
if (!f) return "";
|
|
22403
|
-
const mid = pie ? '<c:invertIfNegative val="0"/><c:bubble3D val="0"/><c:explosion val="0"/>' : '<c:bubble3D val="0"/>';
|
|
22404
|
-
return `<c:dPt><c:idx val="${i}"/>${mid}<c:spPr>${f}</c:spPr></c:dPt>`;
|
|
22405
|
-
}).join("");
|
|
22406
|
-
}
|
|
22407
|
-
function stdSer(idx, name, cat, values, explode, color, pointColors, stroke, pie) {
|
|
22408
|
-
const cl = colLetter(idx);
|
|
22409
|
-
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx>${serSpPr(color, stroke)}<c:invertIfNegative val="0"/>` + (explode ? `<c:explosion val="25"/>` : "") + dPtXml(pointColors, pie) + `<c:cat><c:strRef><c:f>Sheet1!$A$2:$A$${cat.length + 1}</c:f><c:strCache>${strCachePts(cat)}</c:strCache></c:strRef></c:cat><c:val><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${values.length + 1}</c:f><c:numCache>${numCachePts(values)}</c:numCache></c:numRef></c:val></c:ser>`;
|
|
22410
|
-
}
|
|
22411
|
-
function scatterSer(idx, name, xvals, yvals) {
|
|
22412
|
-
const cl = colLetter(idx);
|
|
22413
|
-
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx><c:spPr><a:ln w="28575"><a:noFill/></a:ln></c:spPr><c:marker><c:symbol val="circle"/><c:size val="7"/></c:marker><c:xVal><c:numRef><c:f>Sheet1!$A$2:$A$${xvals.length + 1}</c:f><c:numCache>${numCachePts(xvals)}</c:numCache></c:numRef></c:xVal><c:yVal><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${yvals.length + 1}</c:f><c:numCache>${numCachePts(yvals)}</c:numCache></c:numRef></c:yVal></c:ser>`;
|
|
22414
|
-
}
|
|
22415
|
-
function catAxXml(id, pos, cross) {
|
|
22416
|
-
return `<c:catAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
|
|
22417
|
-
}
|
|
22418
|
-
function valAxXml(id, pos, cross) {
|
|
22419
|
-
return `<c:valAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:majorGridlines/><c:numFmt formatCode="General" sourceLinked="1"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>`;
|
|
22420
|
-
}
|
|
22421
|
-
function buildChartSpaceXml(fence) {
|
|
22422
|
-
const { spec, cat, series } = fence;
|
|
22423
|
-
const NS = 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"';
|
|
22424
|
-
const ax1 = "111111111";
|
|
22425
|
-
const ax2 = "222222222";
|
|
22426
|
-
let plot;
|
|
22427
|
-
if (spec.scatter) {
|
|
22428
|
-
const n = Math.max(0, ...series.map((s) => s.values.length));
|
|
22429
|
-
const xs = Array.from({ length: n }, (_, i) => {
|
|
22430
|
-
const c = cat[i];
|
|
22431
|
-
const v = Number(c);
|
|
22432
|
-
return c !== void 0 && c !== "" && Number.isFinite(v) ? v : i + 1;
|
|
22433
|
-
});
|
|
22434
|
-
const sers = series.map((s, i) => scatterSer(i, s.name, xs, s.values)).join("");
|
|
22435
|
-
plot = `<c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>${sers}<c:axId val="${ax1}"/><c:axId val="${ax2}"/></c:scatterChart>` + valAxXml(ax1, "b", ax2) + valAxXml(ax2, "l", ax1);
|
|
22436
|
-
} else if (spec.pie) {
|
|
22437
|
-
const s0 = series[0];
|
|
22438
|
-
plot = `<c:${spec.el}><c:varyColors val="1"/>${stdSer(0, s0.name, cat, s0.values, !!spec.explode, s0.color, s0.pointColors, false, true)}<c:firstSliceAng val="0"/>` + (spec.hole != null ? `<c:holeSize val="${spec.hole}"/>` : "") + `</c:${spec.el}>`;
|
|
22439
|
-
} else {
|
|
22440
|
-
const stroke = spec.el === "lineChart" || spec.el === "radarChart" || !!spec.radar;
|
|
22441
|
-
const sers = series.map((s, i) => stdSer(i, s.name, cat, s.values, false, s.color, s.pointColors, stroke, false)).join("");
|
|
22442
|
-
const horiz = spec.dir === "bar";
|
|
22443
|
-
let inner = "";
|
|
22444
|
-
if (spec.dir) inner += `<c:barDir val="${spec.dir}"/>`;
|
|
22445
|
-
if (spec.grp) inner += `<c:grouping val="${spec.grp}"/>`;
|
|
22446
|
-
if (spec.radar) inner += `<c:radarStyle val="standard"/>`;
|
|
22447
|
-
inner += `<c:varyColors val="0"/>${sers}`;
|
|
22448
|
-
if (spec.marker) inner += `<c:marker val="1"/>`;
|
|
22449
|
-
if (spec.el.startsWith("bar")) inner += `<c:gapWidth val="150"/><c:overlap val="${_nullishCoalesce(spec.overlap, () => ( 0))}"/>`;
|
|
22450
|
-
inner += `<c:axId val="${ax1}"/><c:axId val="${ax2}"/>`;
|
|
22451
|
-
plot = `<c:${spec.el}>${inner}</c:${spec.el}>` + catAxXml(ax1, horiz ? "l" : "b", ax2) + valAxXml(ax2, horiz ? "b" : "l", ax1);
|
|
22452
|
-
}
|
|
22453
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><c:chartSpace ${NS}><c:date1904 val="0"/><c:roundedCorners val="0"/><c:chart><c:autoTitleDeleted val="0"/><c:plotArea><c:layout/>${plot}</c:plotArea><c:legend><c:legendPos val="r"/><c:overlay val="0"/></c:legend><c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/></c:chart></c:chartSpace>`;
|
|
22454
|
-
}
|
|
22455
|
-
function buildChartElementXml(partName, widthHu, heightHu, id) {
|
|
22456
|
-
return `<hp:chart id="${id}" zOrder="0" numberingType="PICTURE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" chartIDRef="${partName}"><hp:sz width="${widthHu}" widthRelTo="ABSOLUTE" height="${heightHu}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="709" right="709" top="709" bottom="709"/></hp:chart>`;
|
|
22457
|
-
}
|
|
22458
|
-
|
|
22459
22511
|
// src/hwpx/gen-section.ts
|
|
22460
22512
|
function generateSecPr(gongmun) {
|
|
22461
22513
|
const m = gongmun ? {
|
|
@@ -22537,8 +22589,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22537
22589
|
case "list_item": {
|
|
22538
22590
|
if (gongmun && gongmunList) {
|
|
22539
22591
|
const info = gongmunList.get(blockIdx);
|
|
22540
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22541
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22592
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _205 => _205.depth]), () => ( 0));
|
|
22593
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _206 => _206.marker]), () => ( ""));
|
|
22542
22594
|
const content = block.text || "";
|
|
22543
22595
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
22544
22596
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -22618,8 +22670,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22618
22670
|
|
|
22619
22671
|
// src/hwpx/generator.ts
|
|
22620
22672
|
async function markdownToHwpx(markdown, options) {
|
|
22621
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
22622
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
22673
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _207 => _207.theme]));
|
|
22674
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _208 => _208.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
22623
22675
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
22624
22676
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
22625
22677
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
@@ -22629,7 +22681,7 @@ async function markdownToHwpx(markdown, options) {
|
|
|
22629
22681
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
22630
22682
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
22631
22683
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
22632
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
22684
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _209 => _209.variants]), () => ( []))));
|
|
22633
22685
|
zip.file("Contents/section0.xml", sectionXml);
|
|
22634
22686
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
22635
22687
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -22850,15 +22902,15 @@ function parseRenderStyles(headXml) {
|
|
|
22850
22902
|
italic: findChildByLocalName(el, "italic") != null,
|
|
22851
22903
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
22852
22904
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
22853
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
22854
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
22905
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _210 => _210.getAttribute, 'call', _211 => _211("hangul")])) || 100,
|
|
22906
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _212 => _212.getAttribute, 'call', _213 => _213("hangul")])) || 0
|
|
22855
22907
|
});
|
|
22856
22908
|
}
|
|
22857
22909
|
} else if (tag === "paraPr") {
|
|
22858
22910
|
const id = el.getAttribute("id");
|
|
22859
22911
|
if (id != null) {
|
|
22860
22912
|
const align = findChildByLocalName(el, "align");
|
|
22861
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
22913
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _214 => _214.getAttribute, 'call', _215 => _215("horizontal")]) || "JUSTIFY");
|
|
22862
22914
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
22863
22915
|
}
|
|
22864
22916
|
} else if (tag === "borderFill") {
|
|
@@ -22872,7 +22924,7 @@ function parseRenderStyles(headXml) {
|
|
|
22872
22924
|
};
|
|
22873
22925
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
22874
22926
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
22875
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
22927
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _216 => _216.getAttribute, 'call', _217 => _217("faceColor")]);
|
|
22876
22928
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
22877
22929
|
styles.borderFill.set(id, bf);
|
|
22878
22930
|
}
|
|
@@ -22897,6 +22949,21 @@ var MIME = {
|
|
|
22897
22949
|
bmp: "image/bmp",
|
|
22898
22950
|
gif: "image/gif"
|
|
22899
22951
|
};
|
|
22952
|
+
function imageMagicMatches(buf, ext) {
|
|
22953
|
+
switch (ext) {
|
|
22954
|
+
case "png":
|
|
22955
|
+
return buf.length >= 8 && buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71;
|
|
22956
|
+
case "jpg":
|
|
22957
|
+
case "jpeg":
|
|
22958
|
+
return buf.length >= 3 && buf[0] === 255 && buf[1] === 216 && buf[2] === 255;
|
|
22959
|
+
case "bmp":
|
|
22960
|
+
return buf.length >= 2 && buf[0] === 66 && buf[1] === 77;
|
|
22961
|
+
case "gif":
|
|
22962
|
+
return buf.length >= 6 && buf[0] === 71 && buf[1] === 73 && buf[2] === 70;
|
|
22963
|
+
default:
|
|
22964
|
+
return false;
|
|
22965
|
+
}
|
|
22966
|
+
}
|
|
22900
22967
|
function glyphEm(code) {
|
|
22901
22968
|
if (code < 32) return 0;
|
|
22902
22969
|
if (code <= 126) return 0.5;
|
|
@@ -22911,25 +22978,25 @@ function measureMm(text, emMm) {
|
|
|
22911
22978
|
function collectSites(scan) {
|
|
22912
22979
|
const sites = [];
|
|
22913
22980
|
for (const p of scan.bodyParagraphs) sites.push({ para: p });
|
|
22914
|
-
const walkTables = (tables, depth) => {
|
|
22981
|
+
const walkTables = (tables, depth, outer) => {
|
|
22915
22982
|
if (depth > 16) return;
|
|
22916
22983
|
for (const t of tables) {
|
|
22917
22984
|
for (const row of t.rows) {
|
|
22918
22985
|
for (const cell of row) {
|
|
22919
|
-
for (const p of cell.paragraphs) sites.push({ para: p, cell, table: t });
|
|
22920
|
-
walkTables(cell.tables, depth + 1);
|
|
22986
|
+
for (const p of cell.paragraphs) sites.push({ para: p, cell, table: t, nested: depth > 0, outer: outer.length ? outer : void 0 });
|
|
22987
|
+
walkTables(cell.tables, depth + 1, [...outer, { cell, table: t }]);
|
|
22921
22988
|
}
|
|
22922
22989
|
}
|
|
22923
22990
|
}
|
|
22924
22991
|
};
|
|
22925
|
-
walkTables(scan.tables, 0);
|
|
22926
|
-
walkTables(scan.orphanTables, 0);
|
|
22992
|
+
walkTables(scan.tables, 0, []);
|
|
22993
|
+
walkTables(scan.orphanTables, 0, []);
|
|
22927
22994
|
sites.sort((a, b) => a.para.start - b.para.start);
|
|
22928
22995
|
return sites;
|
|
22929
22996
|
}
|
|
22930
22997
|
function attrOf(openTag, name) {
|
|
22931
22998
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
22932
|
-
return _optionalChain([m, 'optionalAccess',
|
|
22999
|
+
return _optionalChain([m, 'optionalAccess', _218 => _218[1]]);
|
|
22933
23000
|
}
|
|
22934
23001
|
function paraOpenTag(xml, para) {
|
|
22935
23002
|
const end = xml.indexOf(">", para.start);
|
|
@@ -22937,11 +23004,14 @@ function paraOpenTag(xml, para) {
|
|
|
22937
23004
|
}
|
|
22938
23005
|
function anchorRunInfo(xml, para, anchor) {
|
|
22939
23006
|
let tr = para.tRanges.find((r) => !r.selfClosing && xml.slice(r.contentStart, r.contentEnd).includes(anchor));
|
|
22940
|
-
if (!tr)
|
|
23007
|
+
if (!tr) {
|
|
23008
|
+
const head = anchor[0];
|
|
23009
|
+
tr = _nullishCoalesce(para.tRanges.find((r) => !r.selfClosing && xml.slice(r.contentStart, r.contentEnd).includes(head)), () => ( para.tRanges[para.tRanges.length - 1]));
|
|
23010
|
+
}
|
|
22941
23011
|
if (!tr) return null;
|
|
22942
23012
|
const before = xml.slice(Math.max(0, para.start), tr.contentStart);
|
|
22943
23013
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
22944
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
23014
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _219 => _219[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
22945
23015
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
22946
23016
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
22947
23017
|
if (close === -1) return null;
|
|
@@ -22968,7 +23038,7 @@ function cellContentWidthMm(xml, cell) {
|
|
|
22968
23038
|
if (width === null) return null;
|
|
22969
23039
|
let content = width;
|
|
22970
23040
|
const win = cellAddrWindow(xml, cell);
|
|
22971
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
23041
|
+
const mg = _optionalChain([win, 'optionalAccess', _220 => _220.match, 'call', _221 => _221(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
22972
23042
|
if (mg) {
|
|
22973
23043
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
22974
23044
|
}
|
|
@@ -22976,14 +23046,17 @@ function cellContentWidthMm(xml, cell) {
|
|
|
22976
23046
|
}
|
|
22977
23047
|
function cellLeftOffsetMm(xml, table, cell) {
|
|
22978
23048
|
if (cell.colAddr === void 0) return 0;
|
|
22979
|
-
const
|
|
22980
|
-
|
|
22981
|
-
|
|
22982
|
-
|
|
22983
|
-
|
|
22984
|
-
|
|
22985
|
-
|
|
23049
|
+
const colW = /* @__PURE__ */ new Map();
|
|
23050
|
+
for (const row of table.rows) {
|
|
23051
|
+
for (const c of row) {
|
|
23052
|
+
if (c.colAddr === void 0 || colW.has(c.colAddr)) continue;
|
|
23053
|
+
if (c.colSpan > 1) continue;
|
|
23054
|
+
const w = cellSzWidthHu(xml, c);
|
|
23055
|
+
if (w) colW.set(c.colAddr, w);
|
|
23056
|
+
}
|
|
22986
23057
|
}
|
|
23058
|
+
let sum = 0;
|
|
23059
|
+
for (let col = 0; col < cell.colAddr; col++) sum += _nullishCoalesce(colW.get(col), () => ( 0));
|
|
22987
23060
|
return sum / HU_PER_MM2;
|
|
22988
23061
|
}
|
|
22989
23062
|
function bodyColumnWidthMm(xml) {
|
|
@@ -22999,11 +23072,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
22999
23072
|
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>`;
|
|
23000
23073
|
}
|
|
23001
23074
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
23002
|
-
if (ops.length === 0) throw new (0,
|
|
23075
|
+
if (ops.length === 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23003
23076
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
23004
23077
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
23005
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
23006
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
23078
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _222 => _222.match, 'call', _223 => _223(/(\d+)\.xml$/i), 'optionalAccess', _224 => _224[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _225 => _225.match, 'call', _226 => _226(/(\d+)\.xml$/i), 'optionalAccess', _227 => _227[1]]), () => ( 0))));
|
|
23079
|
+
if (sectionPaths.length === 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23007
23080
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
23008
23081
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
23009
23082
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -23044,10 +23117,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23044
23117
|
const manifestItems = [];
|
|
23045
23118
|
const placed = [];
|
|
23046
23119
|
for (const op of ops) {
|
|
23047
|
-
if (!op.anchor) throw new (0,
|
|
23048
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
23120
|
+
if (!op.anchor) throw new (0, _chunkVNIQK4ALcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23121
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkVNIQK4ALcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23049
23122
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
23050
|
-
if (!MIME[ext]) throw new (0,
|
|
23123
|
+
if (!MIME[ext]) throw new (0, _chunkVNIQK4ALcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
23124
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkVNIQK4ALcjs.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)`);
|
|
23051
23125
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
23052
23126
|
let found = null;
|
|
23053
23127
|
let total = 0;
|
|
@@ -23080,7 +23154,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23080
23154
|
}
|
|
23081
23155
|
}
|
|
23082
23156
|
}
|
|
23083
|
-
throw new (0,
|
|
23157
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)(
|
|
23084
23158
|
`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)})`
|
|
23085
23159
|
);
|
|
23086
23160
|
}
|
|
@@ -23088,18 +23162,18 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23088
23162
|
const xml = sectionXmls[si];
|
|
23089
23163
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
23090
23164
|
if (!run) {
|
|
23091
|
-
throw new (0,
|
|
23165
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
23092
23166
|
}
|
|
23093
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
23167
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _228 => _228.charPr, 'access', _229 => _229.get, 'call', _230 => _230(run.charPr), 'optionalAccess', _231 => _231.height]), () => ( 1e3));
|
|
23094
23168
|
const fontPt = charPrHeight / 100;
|
|
23095
23169
|
const emMm = fontPt * 25.4 / 72;
|
|
23096
23170
|
const lineHMm = emMm;
|
|
23097
23171
|
const startXMm = measureMm(site.para.text.slice(0, idxInText), emMm);
|
|
23098
23172
|
const anchorWMm = measureMm(op.anchor, emMm);
|
|
23099
|
-
const sizeMm =
|
|
23173
|
+
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
23100
23174
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
23101
23175
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
23102
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
23176
|
+
const align = _optionalChain([styles, 'optionalAccess', _232 => _232.paraAlign, 'access', _233 => _233.get, 'call', _234 => _234(paraPrId)]);
|
|
23103
23177
|
let alignShiftMm = 0;
|
|
23104
23178
|
if (align === "CENTER" || align === "RIGHT") {
|
|
23105
23179
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -23110,7 +23184,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23110
23184
|
if (mode === "auto") {
|
|
23111
23185
|
mode = availMm - (alignShiftMm + startXMm + anchorWMm) >= sizeMm + 2 ? "right" : "overlap";
|
|
23112
23186
|
}
|
|
23113
|
-
const cellShiftMm = site.cell && site.table ? cellLeftOffsetMm(xml, site.table, site.cell) : 0;
|
|
23187
|
+
const cellShiftMm = site.cell && site.table ? cellLeftOffsetMm(xml, site.table, site.cell) + (_nullishCoalesce(site.outer, () => ( []))).reduce((s, o) => s + cellLeftOffsetMm(xml, o.table, o.cell), 0) : 0;
|
|
23114
23188
|
const posXMm = (mode === "right" ? startXMm + anchorWMm + 2 : startXMm + anchorWMm / 2 - sizeMm / 2) + alignShiftMm + cellShiftMm + (_nullishCoalesce(op.dxMm, () => ( 0)));
|
|
23115
23189
|
const posYMm = -(sizeMm - lineHMm) / 2 + (_nullishCoalesce(op.dyMm, () => ( 0)));
|
|
23116
23190
|
const n = nextImageNum();
|
|
@@ -23128,6 +23202,12 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23128
23202
|
end: run.insertAt,
|
|
23129
23203
|
replacement: `<${run.prefix}:run charPrIDRef="${run.charPr}">${pic}</${run.prefix}:run>`
|
|
23130
23204
|
});
|
|
23205
|
+
const warnings = [];
|
|
23206
|
+
const paraSeg = xml.slice(site.para.start, run.insertAt);
|
|
23207
|
+
if (/<[A-Za-z0-9]+:tab\b/.test(paraSeg)) warnings.push("\uD0ED\uC774 \uB4E0 \uBB38\uB2E8 \u2014 \uB3C4\uC7A5 \uAC00\uB85C \uC704\uCE58\uAC00 \uADFC\uC0AC\uAC12\uC785\uB2C8\uB2E4 (dx \uB85C \uBCF4\uC815)");
|
|
23208
|
+
if (/<[A-Za-z0-9]+:(lineBreak|br)\b/.test(paraSeg)) warnings.push("\uC904\uBC14\uAFC8\uC774 \uB4E0 \uBB38\uB2E8 \u2014 \uC575\uCEE4\uAC00 2\uBC88\uC9F8 \uC904 \uC774\uD558\uBA74 \uC138\uB85C \uC704\uCE58\uAC00 \uC5B4\uAE0B\uB0A0 \uC218 \uC788\uC2B5\uB2C8\uB2E4 (dy \uB85C \uBCF4\uC815)");
|
|
23209
|
+
if (site.nested) warnings.push("\uC911\uCCA9\uD45C(\uD45C \uC548 \uD45C) \uC140 \uC575\uCEE4 \u2014 \uBC14\uAE65 \uC140 \uC624\uD504\uC14B\uC744 \uCCB4\uC778\uC73C\uB85C \uAC00\uC0B0\uD558\uB098 \uC140 \uC5EC\uBC31\xB7\uC815\uB82C\uC740 \uADFC\uC0AC\uC785\uB2C8\uB2E4 (\uD544\uC694 \uC2DC dx \uB85C \uBCF4\uC815)");
|
|
23210
|
+
if (site.para.inTextbox) warnings.push("\uAE00\uC0C1\uC790 \uC575\uCEE4 \u2014 \uAE00\uC0C1\uC790 \uAE30\uD558\uB97C \uBC18\uC601\uD558\uC9C0 \uC54A\uC544 \uC815\uB82C \uBCF4\uC815\uC774 \uADFC\uC0AC\uC785\uB2C8\uB2E4 (dx/dy \uB85C \uBCF4\uC815)");
|
|
23131
23211
|
placed.push({
|
|
23132
23212
|
anchor: op.anchor,
|
|
23133
23213
|
occurrence: wantOcc,
|
|
@@ -23136,7 +23216,8 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23136
23216
|
posXMm: Math.round(posXMm * 100) / 100,
|
|
23137
23217
|
posYMm: Math.round(posYMm * 100) / 100,
|
|
23138
23218
|
sizeMm: Math.round(sizeMm * 100) / 100,
|
|
23139
|
-
entry
|
|
23219
|
+
entry,
|
|
23220
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
23140
23221
|
});
|
|
23141
23222
|
}
|
|
23142
23223
|
const encoder = new TextEncoder();
|
|
@@ -23164,7 +23245,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
23164
23245
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
23165
23246
|
function patchTableRows(input) {
|
|
23166
23247
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
23167
|
-
const xml = _optionalChain([ctx, 'access',
|
|
23248
|
+
const xml = _optionalChain([ctx, 'access', _235 => _235.scans, 'access', _236 => _236[scanTable.sectionIndex], 'optionalAccess', _237 => _237.xml]);
|
|
23168
23249
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
23169
23250
|
const numRows = table.rows;
|
|
23170
23251
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -23331,7 +23412,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
23331
23412
|
const rr = scanTable.rowRanges[template];
|
|
23332
23413
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
23333
23414
|
const scan = scanSectionXml(wrapped, 0);
|
|
23334
|
-
const row = _optionalChain([scan, 'access',
|
|
23415
|
+
const row = _optionalChain([scan, 'access', _238 => _238.tables, 'access', _239 => _239[0], 'optionalAccess', _240 => _240.rows, 'access', _241 => _241[0]]);
|
|
23335
23416
|
if (!row || row.length !== cells.length) return null;
|
|
23336
23417
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
23337
23418
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -23374,7 +23455,7 @@ function rowHeightOf(fragment) {
|
|
|
23374
23455
|
}
|
|
23375
23456
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
23376
23457
|
const from = scanTable.start + tblOpenLen;
|
|
23377
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
23458
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _242 => _242.rowRanges, 'access', _243 => _243[0], 'optionalAccess', _244 => _244.start]), () => ( from));
|
|
23378
23459
|
const slice = xml.slice(from, to);
|
|
23379
23460
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
23380
23461
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -23563,9 +23644,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
23563
23644
|
});
|
|
23564
23645
|
}
|
|
23565
23646
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
23566
|
-
const irCell = _optionalChain([table, 'access',
|
|
23647
|
+
const irCell = _optionalChain([table, 'access', _245 => _245.cells, 'access', _246 => _246[oc.gridR], 'optionalAccess', _247 => _247[oc.gridC]]);
|
|
23567
23648
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
23568
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
23649
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _248 => _248.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
23569
23650
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
23570
23651
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
23571
23652
|
}
|
|
@@ -23633,7 +23714,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23633
23714
|
};
|
|
23634
23715
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
23635
23716
|
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)");
|
|
23636
|
-
const irCell = _optionalChain([table, 'access',
|
|
23717
|
+
const irCell = _optionalChain([table, 'access', _249 => _249.cells, 'access', _250 => _250[gridR], 'optionalAccess', _251 => _251[gridC]]);
|
|
23637
23718
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
23638
23719
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
23639
23720
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -23656,7 +23737,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23656
23737
|
if (newLines.length === 0) return 0;
|
|
23657
23738
|
const target = cell.paragraphs[0];
|
|
23658
23739
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
23659
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
23740
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _252 => _252.scans, 'access', _253 => _253[target.sectionIndex], 'optionalAccess', _254 => _254.xml]));
|
|
23660
23741
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23661
23742
|
splices.push(...sp);
|
|
23662
23743
|
sectionIndex = target.sectionIndex;
|
|
@@ -23679,7 +23760,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
23679
23760
|
}
|
|
23680
23761
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
23681
23762
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
23682
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
23763
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _255 => _255.scans, 'access', _256 => _256[nonEmpty[i].sectionIndex], 'optionalAccess', _257 => _257.xml]));
|
|
23683
23764
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23684
23765
|
splices.push(...sp);
|
|
23685
23766
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -23760,7 +23841,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
23760
23841
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
23761
23842
|
if (paths.length > 0) return paths;
|
|
23762
23843
|
}
|
|
23763
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
23844
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkVNIQK4ALcjs.compareSectionPaths);
|
|
23764
23845
|
}
|
|
23765
23846
|
function sectionPathsFromManifest(xml) {
|
|
23766
23847
|
const attr = (tag, name) => {
|
|
@@ -23770,7 +23851,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23770
23851
|
const idToHref = /* @__PURE__ */ new Map();
|
|
23771
23852
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
23772
23853
|
const id = attr(m[1], "id");
|
|
23773
|
-
const href =
|
|
23854
|
+
const href = _chunkVNIQK4ALcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
23774
23855
|
if (id && href) idToHref.set(id, href);
|
|
23775
23856
|
}
|
|
23776
23857
|
const ordered = [];
|
|
@@ -23779,7 +23860,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
23779
23860
|
if (href) ordered.push(href);
|
|
23780
23861
|
}
|
|
23781
23862
|
if (ordered.length > 0) return ordered;
|
|
23782
|
-
return Array.from(idToHref.values()).sort(
|
|
23863
|
+
return Array.from(idToHref.values()).sort(_chunkVNIQK4ALcjs.compareSectionPaths);
|
|
23783
23864
|
}
|
|
23784
23865
|
|
|
23785
23866
|
// src/roundtrip/patcher.ts
|
|
@@ -23871,7 +23952,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
23871
23952
|
}
|
|
23872
23953
|
}
|
|
23873
23954
|
let verification;
|
|
23874
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23955
|
+
if (_optionalChain([options, 'optionalAccess', _258 => _258.verify]) !== false) {
|
|
23875
23956
|
try {
|
|
23876
23957
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
23877
23958
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -23889,17 +23970,17 @@ function buildOrigUnits(blocks) {
|
|
|
23889
23970
|
let chunk;
|
|
23890
23971
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
23891
23972
|
const next = blocks[i + 1];
|
|
23892
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
23893
|
-
chunk =
|
|
23973
|
+
if (_optionalChain([next, 'optionalAccess', _259 => _259.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
23974
|
+
chunk = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
23894
23975
|
} else {
|
|
23895
|
-
chunk =
|
|
23976
|
+
chunk = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, [block]);
|
|
23896
23977
|
}
|
|
23897
23978
|
if (chunk) {
|
|
23898
23979
|
const subUnits = splitMarkdownUnits(chunk);
|
|
23899
23980
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
23900
23981
|
for (let s = 0; s < subUnits.length; s++) {
|
|
23901
23982
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
23902
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
23983
|
+
if (block.type === "table" && _optionalChain([block, 'access', _260 => _260.table, 'optionalAccess', _261 => _261.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
23903
23984
|
u.role = "caption";
|
|
23904
23985
|
}
|
|
23905
23986
|
units.push(u);
|
|
@@ -24010,7 +24091,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24010
24091
|
const ti = ctx.tableInsert;
|
|
24011
24092
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
24012
24093
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24013
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24094
|
+
if (!_optionalChain([mapping, 'optionalAccess', _262 => _262.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");
|
|
24014
24095
|
const para = mapping.para;
|
|
24015
24096
|
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");
|
|
24016
24097
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -24038,7 +24119,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24038
24119
|
}
|
|
24039
24120
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
24040
24121
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24041
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24122
|
+
if (!_optionalChain([mapping, 'optionalAccess', _263 => _263.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)");
|
|
24042
24123
|
if (block.text && block.text.includes("\n")) {
|
|
24043
24124
|
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)");
|
|
24044
24125
|
}
|
|
@@ -24069,7 +24150,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
24069
24150
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24070
24151
|
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");
|
|
24071
24152
|
}
|
|
24072
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
24153
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _264 => _264.scans, 'access', _265 => _265[mapping.para.sectionIndex], 'optionalAccess', _266 => _266.xml]));
|
|
24073
24154
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24074
24155
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24075
24156
|
return 1;
|
|
@@ -24255,7 +24336,7 @@ var Surgeon = (_class4 = class {
|
|
|
24255
24336
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
24256
24337
|
findEntry(path) {
|
|
24257
24338
|
const parts = path.replace(/^\//, "").split("/");
|
|
24258
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
24339
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _267 => _267.entries, 'access', _268 => _268[0], 'optionalAccess', _269 => _269.child]), () => ( -1));
|
|
24259
24340
|
let current;
|
|
24260
24341
|
for (const part of parts) {
|
|
24261
24342
|
const search = (idx) => {
|
|
@@ -24468,8 +24549,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
24468
24549
|
parts.push(header, data);
|
|
24469
24550
|
};
|
|
24470
24551
|
for (let i = 0; i < recs.length; i++) {
|
|
24471
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
24472
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
24552
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _270 => _270.get, 'call', _271 => _271(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
24553
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _272 => _272.get, 'call', _273 => _273(i)]), () => ( recs[i].data)));
|
|
24473
24554
|
}
|
|
24474
24555
|
return Buffer.concat(parts);
|
|
24475
24556
|
}
|
|
@@ -24587,7 +24668,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24587
24668
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
24588
24669
|
}
|
|
24589
24670
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
24590
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
24671
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _274 => _274.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
24591
24672
|
let flags;
|
|
24592
24673
|
try {
|
|
24593
24674
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -24609,7 +24690,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24609
24690
|
const scans = [];
|
|
24610
24691
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
24611
24692
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
24612
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
24693
|
+
if (!_optionalChain([entry, 'optionalAccess', _275 => _275.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
24613
24694
|
let stream;
|
|
24614
24695
|
try {
|
|
24615
24696
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -24660,10 +24741,11 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
24660
24741
|
}
|
|
24661
24742
|
}
|
|
24662
24743
|
let verification;
|
|
24663
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24744
|
+
if (_optionalChain([options, 'optionalAccess', _276 => _276.verify]) !== false) {
|
|
24664
24745
|
try {
|
|
24665
24746
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
24666
|
-
|
|
24747
|
+
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
24748
|
+
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown).map(normBr), editedUnits.map(normBr));
|
|
24667
24749
|
} catch (err) {
|
|
24668
24750
|
return { success: false, applied, skipped, error: `\uD328\uCE58\uBCF8 \uC7AC\uD30C\uC2F1 \uC2E4\uD328 \u2014 \uD328\uCE58 \uC911\uB2E8: ${msg(err)}` };
|
|
24669
24751
|
}
|
|
@@ -24749,7 +24831,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
24749
24831
|
for (const [key, scanCell] of scanTable.cells) {
|
|
24750
24832
|
const comma = key.indexOf(",");
|
|
24751
24833
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
24752
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
24834
|
+
const irCell = _optionalChain([irTable, 'access', _277 => _277.cells, 'access', _278 => _278[r], 'optionalAccess', _279 => _279[c]]);
|
|
24753
24835
|
if (!irCell) continue;
|
|
24754
24836
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
24755
24837
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -24785,8 +24867,8 @@ function handleModified(orig, edited, ctx) {
|
|
|
24785
24867
|
}
|
|
24786
24868
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
24787
24869
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24788
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24789
|
-
const restoreBr = (s) => s.replace(
|
|
24870
|
+
if (!_optionalChain([mapping, 'optionalAccess', _280 => _280.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
24871
|
+
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
24790
24872
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
24791
24873
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
24792
24874
|
return skip("\uB2E4\uC911\uC904 \uBB38\uB2E8 \uC218\uC815\uC5D0 <br> \uC5C6\uC74C \u2014 \uC904\uBC14\uAFC8 \uC704\uCE58 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (\uC904\uBC14\uAFC8\uC740 <br>\uB85C \uD45C\uAE30)");
|
|
@@ -24812,7 +24894,7 @@ function patchParagraph(block, orig, edited, ctx, skip) {
|
|
|
24812
24894
|
ctx.skipped.push({ reason: "\uC790\uB3D9\uBC88\uD638 \uC811\uB450 \uC2DD\uBCC4 \uC2E4\uD328 \u2014 \uBC88\uD638 \uD3EC\uD568 \uD14D\uC2A4\uD2B8\uB85C \uC801\uC6A9 (\uBDF0\uC5B4\uC5D0\uC11C \uC911\uBCF5 \uD45C\uC2DC \uAC00\uB2A5)", after: summarize(newPlain) });
|
|
24813
24895
|
}
|
|
24814
24896
|
}
|
|
24815
|
-
const origPlain = restoreBr(textUnitToPlain(orig.raw, block));
|
|
24897
|
+
const origPlain = block.text != null ? block.text : restoreBr(textUnitToPlain(orig.raw, block));
|
|
24816
24898
|
if (newPlain === origPlain) return skip("\uD14D\uC2A4\uD2B8 \uC678 \uBCC0\uACBD(\uD5E4\uB529 \uB808\uBCA8/\uC11C\uC2DD)\uB9CC \uAC10\uC9C0 \u2014 \uC2A4\uD0C0\uC77C \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0");
|
|
24817
24899
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24818
24900
|
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");
|
|
@@ -24984,7 +25066,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
24984
25066
|
};
|
|
24985
25067
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
24986
25068
|
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)");
|
|
24987
|
-
const irCell = _optionalChain([table, 'access',
|
|
25069
|
+
const irCell = _optionalChain([table, 'access', _281 => _281.cells, 'access', _282 => _282[gridR], 'optionalAccess', _283 => _283[gridC]]);
|
|
24988
25070
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
24989
25071
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
24990
25072
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25376,7 +25458,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25376
25458
|
const block = st.blocks[blockIndex];
|
|
25377
25459
|
if (!block) return void 0;
|
|
25378
25460
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
25379
|
-
const para = _optionalChain([st, 'access',
|
|
25461
|
+
const para = _optionalChain([st, 'access', _284 => _284.paraMap, 'access', _285 => _285.get, 'call', _286 => _286(blockIndex), 'optionalAccess', _287 => _287.para]);
|
|
25380
25462
|
if (!para) return void 0;
|
|
25381
25463
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
25382
25464
|
}
|
|
@@ -25401,7 +25483,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25401
25483
|
if (block.text && block.text.includes("\n")) {
|
|
25402
25484
|
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)" };
|
|
25403
25485
|
}
|
|
25404
|
-
if (!_optionalChain([st, 'access',
|
|
25486
|
+
if (!_optionalChain([st, 'access', _288 => _288.paraMap, 'access', _289 => _289.get, 'call', _290 => _290(blockIndex), 'optionalAccess', _291 => _291.para])) {
|
|
25405
25487
|
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)" };
|
|
25406
25488
|
}
|
|
25407
25489
|
return { capability: "text" };
|
|
@@ -25467,7 +25549,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25467
25549
|
continue;
|
|
25468
25550
|
}
|
|
25469
25551
|
if (block.type === "table" && block.table) {
|
|
25470
|
-
if (!_optionalChain([edit, 'access',
|
|
25552
|
+
if (!_optionalChain([edit, 'access', _292 => _292.cells, 'optionalAccess', _293 => _293.length])) {
|
|
25471
25553
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
25472
25554
|
continue;
|
|
25473
25555
|
}
|
|
@@ -25487,7 +25569,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25487
25569
|
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) });
|
|
25488
25570
|
continue;
|
|
25489
25571
|
}
|
|
25490
|
-
const irCell = _optionalChain([block, 'access',
|
|
25572
|
+
const irCell = _optionalChain([block, 'access', _294 => _294.table, 'access', _295 => _295.cells, 'access', _296 => _296[cellEdit.row], 'optionalAccess', _297 => _297[cellEdit.col]]);
|
|
25491
25573
|
if (!irCell) {
|
|
25492
25574
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
25493
25575
|
continue;
|
|
@@ -25543,7 +25625,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25543
25625
|
}
|
|
25544
25626
|
if (replacements.size === 0) {
|
|
25545
25627
|
let changes2;
|
|
25546
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25628
|
+
if (_optionalChain([options, 'optionalAccess', _298 => _298.verify]) !== false) {
|
|
25547
25629
|
const units = splitMarkdownUnits(st.markdown);
|
|
25548
25630
|
changes2 = diffUnitLists(units, units);
|
|
25549
25631
|
}
|
|
@@ -25564,7 +25646,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25564
25646
|
}
|
|
25565
25647
|
this.state = newState;
|
|
25566
25648
|
let changes;
|
|
25567
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25649
|
+
if (_optionalChain([options, 'optionalAccess', _299 => _299.verify]) !== false) {
|
|
25568
25650
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
25569
25651
|
}
|
|
25570
25652
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -25584,7 +25666,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25584
25666
|
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)");
|
|
25585
25667
|
}
|
|
25586
25668
|
const mapping = st.paraMap.get(blockIndex);
|
|
25587
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25669
|
+
if (!_optionalChain([mapping, 'optionalAccess', _300 => _300.para])) {
|
|
25588
25670
|
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)");
|
|
25589
25671
|
}
|
|
25590
25672
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -25604,14 +25686,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25604
25686
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25605
25687
|
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");
|
|
25606
25688
|
}
|
|
25607
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
25689
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _301 => _301.scans, 'access', _302 => _302[mapping.para.sectionIndex], 'optionalAccess', _303 => _303.xml]));
|
|
25608
25690
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25609
25691
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25610
25692
|
return 1;
|
|
25611
25693
|
}
|
|
25612
25694
|
}, _class5);
|
|
25613
25695
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
25614
|
-
const irCell = _optionalChain([table, 'access',
|
|
25696
|
+
const irCell = _optionalChain([table, 'access', _304 => _304.cells, 'access', _305 => _305[r], 'optionalAccess', _306 => _306[c]]);
|
|
25615
25697
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
25616
25698
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
25617
25699
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -25695,11 +25777,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
25695
25777
|
breaks: false
|
|
25696
25778
|
});
|
|
25697
25779
|
function renderHtml(markdown, options) {
|
|
25698
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25699
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25780
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _307 => _307.preset]), () => ( "default"));
|
|
25781
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _308 => _308.extraCss]), () => ( "")));
|
|
25700
25782
|
const body = md.render(markdown);
|
|
25701
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
25702
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
25783
|
+
const watermark = _optionalChain([options, 'optionalAccess', _309 => _309.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
25784
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _310 => _310.watermark]) ? `
|
|
25703
25785
|
.watermark {
|
|
25704
25786
|
position: fixed;
|
|
25705
25787
|
top: 50%; left: 50%;
|
|
@@ -25730,13 +25812,13 @@ async function htmlToPdf(html, options) {
|
|
|
25730
25812
|
try {
|
|
25731
25813
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
25732
25814
|
} catch (e30) {
|
|
25733
|
-
throw new (0,
|
|
25815
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)(
|
|
25734
25816
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
25735
25817
|
);
|
|
25736
25818
|
}
|
|
25737
25819
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
25738
25820
|
if (!executablePath) {
|
|
25739
|
-
throw new (0,
|
|
25821
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)(
|
|
25740
25822
|
"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."
|
|
25741
25823
|
);
|
|
25742
25824
|
}
|
|
@@ -25748,10 +25830,10 @@ async function htmlToPdf(html, options) {
|
|
|
25748
25830
|
try {
|
|
25749
25831
|
const page = await browser.newPage();
|
|
25750
25832
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
25751
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
25833
|
+
const margin = _optionalChain([options, 'optionalAccess', _311 => _311.margin]);
|
|
25752
25834
|
const pdf = await page.pdf({
|
|
25753
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25754
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
25835
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _312 => _312.pageSize]), () => ( "A4")),
|
|
25836
|
+
landscape: _optionalChain([options, 'optionalAccess', _313 => _313.orientation]) === "landscape",
|
|
25755
25837
|
printBackground: true,
|
|
25756
25838
|
margin: margin ? {
|
|
25757
25839
|
top: toCss(margin.top),
|
|
@@ -25759,9 +25841,9 @@ async function htmlToPdf(html, options) {
|
|
|
25759
25841
|
bottom: toCss(margin.bottom),
|
|
25760
25842
|
left: toCss(margin.left)
|
|
25761
25843
|
} : void 0,
|
|
25762
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
25763
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25764
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
25844
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _314 => _314.header]) || _optionalChain([options, 'optionalAccess', _315 => _315.footer])),
|
|
25845
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _316 => _316.header]), () => ( "<div></div>")),
|
|
25846
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
25765
25847
|
});
|
|
25766
25848
|
return Buffer.from(pdf);
|
|
25767
25849
|
} finally {
|
|
@@ -25795,7 +25877,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
25795
25877
|
return htmlToPdf(html, options);
|
|
25796
25878
|
}
|
|
25797
25879
|
async function blocksToPdf(blocks, options) {
|
|
25798
|
-
const markdown =
|
|
25880
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, blocks);
|
|
25799
25881
|
return markdownToPdf(markdown, options);
|
|
25800
25882
|
}
|
|
25801
25883
|
|
|
@@ -26005,7 +26087,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
26005
26087
|
if (ln(p) !== "p") continue;
|
|
26006
26088
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
26007
26089
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
26008
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
26090
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _318 => _318.spaceBefore]), () => ( 0)));
|
|
26009
26091
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
26010
26092
|
if (res) {
|
|
26011
26093
|
const paraH = res.paraBottom - startV;
|
|
@@ -26114,7 +26196,7 @@ function buildPara(p) {
|
|
|
26114
26196
|
el: ch,
|
|
26115
26197
|
tag: cn,
|
|
26116
26198
|
index: chars.length,
|
|
26117
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
26199
|
+
inline: _optionalChain([pos, 'optionalAccess', _319 => _319.getAttribute, 'call', _320 => _320("treatAsChar")]) === "1",
|
|
26118
26200
|
width: w,
|
|
26119
26201
|
height: h
|
|
26120
26202
|
});
|
|
@@ -26365,15 +26447,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26365
26447
|
const sx = ow > 0 ? w / ow : 1;
|
|
26366
26448
|
const sy = oh > 0 ? h / oh : 1;
|
|
26367
26449
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
26368
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
26369
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
26450
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _321 => _321.getAttribute, 'call', _322 => _322("style")]), () => ( "SOLID"));
|
|
26451
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _323 => _323.getAttribute, 'call', _324 => _324("color")]) || "#000000";
|
|
26370
26452
|
const hasStroke = lstyle !== "NONE";
|
|
26371
26453
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num2(lineShape, "width") : 33) : 0;
|
|
26372
26454
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
26373
26455
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
26374
26456
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26375
26457
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26376
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
26458
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _325 => _325.getAttribute, 'call', _326 => _326("faceColor")]);
|
|
26377
26459
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
26378
26460
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
26379
26461
|
if (o.tag === "rect") {
|
|
@@ -26405,11 +26487,11 @@ function cellContentExtent(cell) {
|
|
|
26405
26487
|
if (ln2(p) !== "p") continue;
|
|
26406
26488
|
const m = buildPara(p);
|
|
26407
26489
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
26408
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
26490
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _327 => _327.segs, 'access', _328 => _328[0], 'optionalAccess', _329 => _329.vertpos]), () => ( 0));
|
|
26409
26491
|
for (const o of m.objs) {
|
|
26410
26492
|
if (o.inline) continue;
|
|
26411
26493
|
const pos = findChildByLocalName(o.el, "pos");
|
|
26412
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
26494
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _330 => _330.getAttribute, 'call', _331 => _331("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
26413
26495
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
26414
26496
|
const pushed = baseV - (num2(om, "top") + o.height + num2(om, "bottom"));
|
|
26415
26497
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
@@ -26495,7 +26577,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
26495
26577
|
}));
|
|
26496
26578
|
for (const g of geom) {
|
|
26497
26579
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
26498
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
26580
|
+
if (_optionalChain([bf, 'optionalAccess', _332 => _332.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
26499
26581
|
}
|
|
26500
26582
|
for (const g of geom) {
|
|
26501
26583
|
const { c } = g;
|
|
@@ -26533,7 +26615,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
26533
26615
|
const sz = findChildByLocalName(pic, "sz");
|
|
26534
26616
|
const w = num2(sz, "width", 5669), h = num2(sz, "height", 5669);
|
|
26535
26617
|
const img = findFirst(pic, "img");
|
|
26536
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
26618
|
+
const ref = _optionalChain([img, 'optionalAccess', _333 => _333.getAttribute, 'call', _334 => _334("binaryItemIDRef")]);
|
|
26537
26619
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
26538
26620
|
if (!loaded) {
|
|
26539
26621
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -26569,20 +26651,22 @@ function sniffMime(name, bytes) {
|
|
|
26569
26651
|
return "image/jpeg";
|
|
26570
26652
|
}
|
|
26571
26653
|
async function renderHwpxToSvg(input, options) {
|
|
26572
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26654
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _335 => _335.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
26655
|
+
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
26656
|
+
_chunkVNIQK4ALcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
26573
26657
|
let zip;
|
|
26574
26658
|
try {
|
|
26575
26659
|
zip = await _jszip2.default.loadAsync(input);
|
|
26576
26660
|
} catch (e31) {
|
|
26577
|
-
throw new (0,
|
|
26661
|
+
throw new (0, _chunkVNIQK4ALcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
26578
26662
|
}
|
|
26579
26663
|
const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
|
|
26580
|
-
if (!secFile) throw new (0,
|
|
26664
|
+
if (!secFile) throw new (0, _chunkVNIQK4ALcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
26581
26665
|
const secXml = await secFile.async("string");
|
|
26582
|
-
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
26666
|
+
if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
26583
26667
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
26584
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
26585
|
-
throw new (0,
|
|
26668
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _336 => _336.reflow])) {
|
|
26669
|
+
throw new (0, _chunkVNIQK4ALcjs.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)");
|
|
26586
26670
|
}
|
|
26587
26671
|
const warnings = [];
|
|
26588
26672
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
@@ -26609,7 +26693,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26609
26693
|
let href = binmap.get(ref);
|
|
26610
26694
|
if (!href) {
|
|
26611
26695
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
26612
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
26696
|
+
href = _optionalChain([cand, 'optionalAccess', _337 => _337.name]);
|
|
26613
26697
|
}
|
|
26614
26698
|
if (!href) continue;
|
|
26615
26699
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -26628,7 +26712,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26628
26712
|
}
|
|
26629
26713
|
const doc = createXmlParser().parseFromString(secXml, "text/xml");
|
|
26630
26714
|
const root = doc.documentElement;
|
|
26631
|
-
if (!root) throw new (0,
|
|
26715
|
+
if (!root) throw new (0, _chunkVNIQK4ALcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
|
|
26632
26716
|
const pagePr = findFirst(root, "pagePr");
|
|
26633
26717
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
26634
26718
|
const PW = num2(pagePr, "width", 59528), PH = num2(pagePr, "height", 84188);
|
|
@@ -26636,7 +26720,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26636
26720
|
const MT = num2(margin, "top", 5668) + num2(margin, "header", 0);
|
|
26637
26721
|
const BODY_H = PH - MT - num2(margin, "bottom", 4252) - num2(margin, "footer", 0);
|
|
26638
26722
|
const BODY_W = PW - ML - num2(margin, "right", 8504);
|
|
26639
|
-
if (!hasCache) reflowSection(root, styles, { BODY_W, BODY_H }, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26723
|
+
if (!hasCache) reflowSection(root, styles, { BODY_W, BODY_H }, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _338 => _338.reflowMode]), () => ( "keep")));
|
|
26640
26724
|
const colPr = findFirst(root, "colPr");
|
|
26641
26725
|
const multiCol = num2(colPr, "colCount", 1) > 1;
|
|
26642
26726
|
const paraSegPages = /* @__PURE__ */ new Map();
|
|
@@ -26671,7 +26755,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
26671
26755
|
styles,
|
|
26672
26756
|
images,
|
|
26673
26757
|
defs: [],
|
|
26674
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26758
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _339 => _339.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
26675
26759
|
warnings,
|
|
26676
26760
|
warned: /* @__PURE__ */ new Set(),
|
|
26677
26761
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -26698,17 +26782,17 @@ ${pagesSvg}
|
|
|
26698
26782
|
// src/index.ts
|
|
26699
26783
|
async function parse(input, options) {
|
|
26700
26784
|
let buffer;
|
|
26701
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
26785
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _340 => _340.filePath]) ? { ...options, filePath: input } : options;
|
|
26702
26786
|
if (typeof input === "string") {
|
|
26703
26787
|
try {
|
|
26704
26788
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26705
|
-
buffer =
|
|
26789
|
+
buffer = _chunkVNIQK4ALcjs.toArrayBuffer.call(void 0, buf);
|
|
26706
26790
|
} catch (err) {
|
|
26707
26791
|
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}`;
|
|
26708
26792
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
26709
26793
|
}
|
|
26710
26794
|
} else if (Buffer.isBuffer(input)) {
|
|
26711
|
-
buffer =
|
|
26795
|
+
buffer = _chunkVNIQK4ALcjs.toArrayBuffer.call(void 0, input);
|
|
26712
26796
|
} else {
|
|
26713
26797
|
buffer = input;
|
|
26714
26798
|
}
|
|
@@ -26743,21 +26827,21 @@ async function parseHwp3(buffer, options) {
|
|
|
26743
26827
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
26744
26828
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
26745
26829
|
} catch (err) {
|
|
26746
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26830
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26747
26831
|
}
|
|
26748
26832
|
}
|
|
26749
26833
|
async function parseHwpx(buffer, options) {
|
|
26750
26834
|
try {
|
|
26751
26835
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
26752
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
26836
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _341 => _341.length]) ? images : void 0 };
|
|
26753
26837
|
} catch (err) {
|
|
26754
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26838
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26755
26839
|
}
|
|
26756
26840
|
}
|
|
26757
26841
|
async function parseHwp(buffer, options) {
|
|
26758
26842
|
try {
|
|
26759
26843
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
26760
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
26844
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _342 => _342.filePath])) {
|
|
26761
26845
|
try {
|
|
26762
26846
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
26763
26847
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -26774,15 +26858,15 @@ async function parseHwp(buffer, options) {
|
|
|
26774
26858
|
} catch (e32) {
|
|
26775
26859
|
}
|
|
26776
26860
|
}
|
|
26777
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
26861
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _343 => _343.length]) ? images : void 0 };
|
|
26778
26862
|
} catch (err) {
|
|
26779
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26863
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26780
26864
|
}
|
|
26781
26865
|
}
|
|
26782
26866
|
async function parsePdf(buffer, options) {
|
|
26783
26867
|
let parsePdfDocument;
|
|
26784
26868
|
try {
|
|
26785
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
26869
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-3O2UF6VO.cjs")));
|
|
26786
26870
|
parsePdfDocument = mod.parsePdfDocument;
|
|
26787
26871
|
} catch (e33) {
|
|
26788
26872
|
return {
|
|
@@ -26797,7 +26881,7 @@ async function parsePdf(buffer, options) {
|
|
|
26797
26881
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
26798
26882
|
} catch (err) {
|
|
26799
26883
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
26800
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26884
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err), isImageBased };
|
|
26801
26885
|
}
|
|
26802
26886
|
}
|
|
26803
26887
|
async function parseXlsx(buffer, options) {
|
|
@@ -26805,7 +26889,7 @@ async function parseXlsx(buffer, options) {
|
|
|
26805
26889
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
26806
26890
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
26807
26891
|
} catch (err) {
|
|
26808
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26892
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26809
26893
|
}
|
|
26810
26894
|
}
|
|
26811
26895
|
async function parseXls(buffer, options) {
|
|
@@ -26813,15 +26897,15 @@ async function parseXls(buffer, options) {
|
|
|
26813
26897
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
26814
26898
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
26815
26899
|
} catch (err) {
|
|
26816
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26900
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26817
26901
|
}
|
|
26818
26902
|
}
|
|
26819
26903
|
async function parseDocx(buffer, options) {
|
|
26820
26904
|
try {
|
|
26821
26905
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
26822
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
26906
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _344 => _344.length]) ? images : void 0 };
|
|
26823
26907
|
} catch (err) {
|
|
26824
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26908
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26825
26909
|
}
|
|
26826
26910
|
}
|
|
26827
26911
|
async function parseHwpml(buffer, options) {
|
|
@@ -26829,16 +26913,16 @@ async function parseHwpml(buffer, options) {
|
|
|
26829
26913
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
26830
26914
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
26831
26915
|
} catch (err) {
|
|
26832
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
26916
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVNIQK4ALcjs.classifyError.call(void 0, err) };
|
|
26833
26917
|
}
|
|
26834
26918
|
}
|
|
26835
26919
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
26836
26920
|
let buffer;
|
|
26837
26921
|
if (typeof input === "string") {
|
|
26838
26922
|
const buf = await _promises.readFile.call(void 0, input);
|
|
26839
|
-
buffer =
|
|
26923
|
+
buffer = _chunkVNIQK4ALcjs.toArrayBuffer.call(void 0, buf);
|
|
26840
26924
|
} else if (Buffer.isBuffer(input)) {
|
|
26841
|
-
buffer =
|
|
26925
|
+
buffer = _chunkVNIQK4ALcjs.toArrayBuffer.call(void 0, input);
|
|
26842
26926
|
} else {
|
|
26843
26927
|
buffer = input;
|
|
26844
26928
|
}
|
|
@@ -26864,7 +26948,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
26864
26948
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
26865
26949
|
}
|
|
26866
26950
|
const fill = fillFormFields(parsed.blocks, values);
|
|
26867
|
-
const markdown =
|
|
26951
|
+
const markdown = _chunkVNIQK4ALcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
26868
26952
|
if (outputFormat === "hwpx") {
|
|
26869
26953
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
26870
26954
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -26927,5 +27011,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
26927
27011
|
|
|
26928
27012
|
|
|
26929
27013
|
|
|
26930
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
27014
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkVNIQK4ALcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkVNIQK4ALcjs.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.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;
|
|
26931
27015
|
//# sourceMappingURL=index.cjs.map
|