kordoc 3.18.0 → 3.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-OUCPI6B3.js → -V66QW3WA.js} +7 -7
- package/dist/{chunk-YWIYGXLI.js → chunk-2IBFK5ZO.js} +2 -2
- package/dist/{chunk-4YEZTZAR.js → chunk-4RGDFDQ2.js} +2 -2
- package/dist/{chunk-PWHM3KAA.js → chunk-7K5P4RNT.js} +156 -120
- package/dist/chunk-7K5P4RNT.js.map +1 -0
- package/dist/{chunk-VP34RO24.js → chunk-NZJAXMN7.js} +3 -3
- package/dist/{chunk-ZTUQYITH.js → chunk-QMJJI6TD.js} +3 -3
- package/dist/{chunk-5HDBLRVP.cjs → chunk-R2H34FY5.cjs} +2 -2
- package/dist/{chunk-5HDBLRVP.cjs.map → chunk-R2H34FY5.cjs.map} +1 -1
- package/dist/{chunk-GIXXV52X.js → chunk-UHYPUIRH.js} +2 -2
- package/dist/{chunk-6Y4KKPC3.js → chunk-UNV7F3FK.js} +2 -2
- package/dist/cli.js +14 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +377 -340
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +151 -114
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +10 -21
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-NZAE7PBE.js → parser-DOBK652H.js} +3 -3
- package/dist/{parser-5D6BQYTX.js → parser-JBBA5A5E.js} +2 -2
- package/dist/{parser-S34YR2SH.cjs → parser-XEY5MRGV.cjs} +14 -14
- package/dist/{parser-S34YR2SH.cjs.map → parser-XEY5MRGV.cjs.map} +1 -1
- package/dist/render-VX4H2S4F.js +10 -0
- package/dist/seal-6Z6H4YXN.js +10 -0
- package/dist/{watch-2EFXBRYK.js → watch-2MNRQWGV.js} +7 -7
- package/package.json +1 -1
- package/dist/chunk-PWHM3KAA.js.map +0 -1
- package/dist/render-HRAW7ASR.js +0 -10
- package/dist/seal-CK64CXWO.js +0 -10
- /package/dist/{-OUCPI6B3.js.map → -V66QW3WA.js.map} +0 -0
- /package/dist/{chunk-YWIYGXLI.js.map → chunk-2IBFK5ZO.js.map} +0 -0
- /package/dist/{chunk-4YEZTZAR.js.map → chunk-4RGDFDQ2.js.map} +0 -0
- /package/dist/{chunk-VP34RO24.js.map → chunk-NZJAXMN7.js.map} +0 -0
- /package/dist/{chunk-ZTUQYITH.js.map → chunk-QMJJI6TD.js.map} +0 -0
- /package/dist/{chunk-GIXXV52X.js.map → chunk-UHYPUIRH.js.map} +0 -0
- /package/dist/{chunk-6Y4KKPC3.js.map → chunk-UNV7F3FK.js.map} +0 -0
- /package/dist/{parser-NZAE7PBE.js.map → parser-DOBK652H.js.map} +0 -0
- /package/dist/{parser-5D6BQYTX.js.map → parser-JBBA5A5E.js.map} +0 -0
- /package/dist/{render-HRAW7ASR.js.map → render-VX4H2S4F.js.map} +0 -0
- /package/dist/{seal-CK64CXWO.js.map → seal-6Z6H4YXN.js.map} +0 -0
- /package/dist/{watch-2EFXBRYK.js.map → watch-2MNRQWGV.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkR2H34FY5cjs = require('./chunk-R2H34FY5.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -406,7 +406,7 @@ function createSectionShared() {
|
|
|
406
406
|
function createXmlParser(warnings) {
|
|
407
407
|
return new (0, _xmldom.DOMParser)({
|
|
408
408
|
onError(level, msg2) {
|
|
409
|
-
if (level === "fatalError") throw new (0,
|
|
409
|
+
if (level === "fatalError") throw new (0, _chunkR2H34FY5cjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
410
410
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
411
411
|
}
|
|
412
412
|
});
|
|
@@ -461,10 +461,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
461
461
|
const xml = await file.async("text");
|
|
462
462
|
if (decompressed) {
|
|
463
463
|
decompressed.total += xml.length * 2;
|
|
464
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
464
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
465
465
|
}
|
|
466
466
|
const parser = createXmlParser();
|
|
467
|
-
const doc = parser.parseFromString(
|
|
467
|
+
const doc = parser.parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
468
468
|
if (!doc.documentElement) continue;
|
|
469
469
|
parseCharProperties(doc, result.charProperties);
|
|
470
470
|
parseStyleElements(doc, result.styles);
|
|
@@ -616,9 +616,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
616
616
|
let level = 0;
|
|
617
617
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
|
|
618
618
|
const ratio = block.style.fontSize / baseFontSize;
|
|
619
|
-
if (ratio >=
|
|
620
|
-
else if (ratio >=
|
|
621
|
-
else if (ratio >=
|
|
619
|
+
if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H1) level = 1;
|
|
620
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H2) level = 2;
|
|
621
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H3) level = 3;
|
|
622
622
|
}
|
|
623
623
|
const compactText = text.replace(/\s+/g, "");
|
|
624
624
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1195,7 +1195,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1195
1195
|
|
|
1196
1196
|
// src/hwpx/table-build.ts
|
|
1197
1197
|
function buildTableWithCellMeta(state) {
|
|
1198
|
-
const table =
|
|
1198
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, state.rows);
|
|
1199
1199
|
if (state.caption) table.caption = state.caption;
|
|
1200
1200
|
const anchors = [];
|
|
1201
1201
|
{
|
|
@@ -1265,7 +1265,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1265
1265
|
const cell = parentTable.cell;
|
|
1266
1266
|
(cell.blocks ??= []).push(block);
|
|
1267
1267
|
cell.hasStructure = true;
|
|
1268
|
-
let flat =
|
|
1268
|
+
let flat = _chunkR2H34FY5cjs.convertTableToText.call(void 0, newTable.rows);
|
|
1269
1269
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1270
1270
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1271
1271
|
} else {
|
|
@@ -1277,7 +1277,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1277
1277
|
// src/hwpx/section-walker.ts
|
|
1278
1278
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1279
1279
|
const parser = createXmlParser(warnings);
|
|
1280
|
-
const doc = parser.parseFromString(
|
|
1280
|
+
const doc = parser.parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1281
1281
|
if (!doc.documentElement) return [];
|
|
1282
1282
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1283
1283
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1368,8 +1368,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1368
1368
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1369
1369
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1370
1370
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1371
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1372
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1371
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkR2H34FY5cjs.MAX_COLS);
|
|
1372
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkR2H34FY5cjs.MAX_ROWS);
|
|
1373
1373
|
}
|
|
1374
1374
|
break;
|
|
1375
1375
|
case "p": {
|
|
@@ -1591,7 +1591,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1591
1591
|
let url = (ch.textContent || "").trim();
|
|
1592
1592
|
if (!url) continue;
|
|
1593
1593
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1594
|
-
const safe =
|
|
1594
|
+
const safe = _chunkR2H34FY5cjs.sanitizeHref.call(void 0, url);
|
|
1595
1595
|
if (safe) return safe;
|
|
1596
1596
|
}
|
|
1597
1597
|
return void 0;
|
|
@@ -1726,7 +1726,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1726
1726
|
case "hyperlink": {
|
|
1727
1727
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1728
1728
|
if (url) {
|
|
1729
|
-
const safe =
|
|
1729
|
+
const safe = _chunkR2H34FY5cjs.sanitizeHref.call(void 0, url);
|
|
1730
1730
|
if (safe) href = safe;
|
|
1731
1731
|
}
|
|
1732
1732
|
walk(child);
|
|
@@ -1912,13 +1912,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1912
1912
|
}
|
|
1913
1913
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1914
1914
|
for (const path of allCandidates) {
|
|
1915
|
-
if (
|
|
1915
|
+
if (_chunkR2H34FY5cjs.isPathTraversal.call(void 0, path)) continue;
|
|
1916
1916
|
const file = zip.file(path);
|
|
1917
1917
|
if (!file) continue;
|
|
1918
1918
|
try {
|
|
1919
1919
|
const data = await file.async("uint8array");
|
|
1920
1920
|
decompressed.total += data.length;
|
|
1921
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1921
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1922
1922
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1923
1923
|
const mimeType = imageExtToMime(ext);
|
|
1924
1924
|
imageIndex++;
|
|
@@ -1927,7 +1927,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1927
1927
|
images.push(img);
|
|
1928
1928
|
break;
|
|
1929
1929
|
} catch (err) {
|
|
1930
|
-
if (err instanceof
|
|
1930
|
+
if (err instanceof _chunkR2H34FY5cjs.KordocError) throw err;
|
|
1931
1931
|
}
|
|
1932
1932
|
}
|
|
1933
1933
|
if (!img) _optionalChain([warnings, 'optionalAccess', _38 => _38.push, 'call', _39 => _39({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -1989,7 +1989,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1989
1989
|
}
|
|
1990
1990
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1991
1991
|
const name = new TextDecoder().decode(nameBytes);
|
|
1992
|
-
if (
|
|
1992
|
+
if (_chunkR2H34FY5cjs.isPathTraversal.call(void 0, name)) {
|
|
1993
1993
|
pos = fileStart + compSize;
|
|
1994
1994
|
continue;
|
|
1995
1995
|
}
|
|
@@ -2007,16 +2007,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2007
2007
|
continue;
|
|
2008
2008
|
}
|
|
2009
2009
|
totalDecompressed += content.length * 2;
|
|
2010
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2010
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2011
2011
|
sectionNum++;
|
|
2012
2012
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2013
2013
|
} catch (e13) {
|
|
2014
2014
|
continue;
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
|
-
if (blocks.length === 0) throw new (0,
|
|
2017
|
+
if (blocks.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2018
2018
|
applyPageText(blocks, shared);
|
|
2019
|
-
const markdown =
|
|
2019
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
2020
2020
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2021
2021
|
}
|
|
2022
2022
|
async function resolveSectionPaths(zip) {
|
|
@@ -2030,18 +2030,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2030
2030
|
if (paths.length > 0) return paths;
|
|
2031
2031
|
}
|
|
2032
2032
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2033
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2033
|
+
return sectionFiles.map((f) => f.name).sort(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
2034
2034
|
}
|
|
2035
2035
|
function parseSectionPathsFromManifest(xml) {
|
|
2036
2036
|
const parser = createXmlParser();
|
|
2037
|
-
const doc = parser.parseFromString(
|
|
2037
|
+
const doc = parser.parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2038
2038
|
const items = doc.getElementsByTagName("opf:item");
|
|
2039
2039
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2040
2040
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2041
2041
|
for (let i = 0; i < items.length; i++) {
|
|
2042
2042
|
const item = items[i];
|
|
2043
2043
|
const id = item.getAttribute("id") || "";
|
|
2044
|
-
const href =
|
|
2044
|
+
const href = _chunkR2H34FY5cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2045
2045
|
if (id && href) idToHref.set(id, href);
|
|
2046
2046
|
}
|
|
2047
2047
|
if (spine.length > 0) {
|
|
@@ -2052,7 +2052,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2052
2052
|
}
|
|
2053
2053
|
if (ordered.length > 0) return ordered;
|
|
2054
2054
|
}
|
|
2055
|
-
return Array.from(idToHref.values()).sort(
|
|
2055
|
+
return Array.from(idToHref.values()).sort(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
2056
2056
|
}
|
|
2057
2057
|
|
|
2058
2058
|
// src/hwpx/metadata.ts
|
|
@@ -2065,7 +2065,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2065
2065
|
const xml = await file.async("text");
|
|
2066
2066
|
if (decompressed) {
|
|
2067
2067
|
decompressed.total += xml.length * 2;
|
|
2068
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2068
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2069
2069
|
}
|
|
2070
2070
|
parseDublinCoreMetadata(xml, metadata);
|
|
2071
2071
|
if (metadata.title || metadata.author) return;
|
|
@@ -2075,7 +2075,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2075
2075
|
}
|
|
2076
2076
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2077
2077
|
const parser = createXmlParser();
|
|
2078
|
-
const doc = parser.parseFromString(
|
|
2078
|
+
const doc = parser.parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2079
2079
|
if (!doc.documentElement) return;
|
|
2080
2080
|
const getText = (tagNames) => {
|
|
2081
2081
|
for (const tag of tagNames) {
|
|
@@ -2100,7 +2100,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2100
2100
|
|
|
2101
2101
|
// src/hwpx/parser.ts
|
|
2102
2102
|
async function parseHwpxDocument(buffer, options) {
|
|
2103
|
-
|
|
2103
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2104
2104
|
let zip;
|
|
2105
2105
|
try {
|
|
2106
2106
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2109,7 +2109,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2109
2109
|
}
|
|
2110
2110
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2111
2111
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2112
|
-
throw new (0,
|
|
2112
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2113
2113
|
}
|
|
2114
2114
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2115
2115
|
if (manifestFile) {
|
|
@@ -2121,7 +2121,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2121
2121
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2122
2122
|
}
|
|
2123
2123
|
}
|
|
2124
|
-
throw new (0,
|
|
2124
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
2125
2125
|
}
|
|
2126
2126
|
}
|
|
2127
2127
|
const decompressed = { total: 0 };
|
|
@@ -2130,7 +2130,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2130
2130
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2131
2131
|
const warnings = [];
|
|
2132
2132
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2133
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2133
|
+
if (sectionPaths.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2134
2134
|
metadata.pageCount = sectionPaths.length;
|
|
2135
2135
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2136
2136
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2144,12 +2144,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2144
2144
|
try {
|
|
2145
2145
|
const xml = await file.async("text");
|
|
2146
2146
|
decompressed.total += xml.length * 2;
|
|
2147
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2147
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2148
2148
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2149
2149
|
parsedSections++;
|
|
2150
2150
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2151
2151
|
} catch (secErr) {
|
|
2152
|
-
if (secErr instanceof
|
|
2152
|
+
if (secErr instanceof _chunkR2H34FY5cjs.KordocError) throw secErr;
|
|
2153
2153
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
2154
2154
|
}
|
|
2155
2155
|
}
|
|
@@ -2157,7 +2157,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2157
2157
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2158
2158
|
detectHwpxHeadings(blocks, styleMap);
|
|
2159
2159
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2160
|
-
const markdown =
|
|
2160
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
2161
2161
|
return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
2162
2162
|
}
|
|
2163
2163
|
|
|
@@ -2224,7 +2224,7 @@ function decompressStream(data) {
|
|
|
2224
2224
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2225
2225
|
}
|
|
2226
2226
|
function parseFileHeader(data) {
|
|
2227
|
-
if (data.length < 40) throw new (0,
|
|
2227
|
+
if (data.length < 40) throw new (0, _chunkR2H34FY5cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2228
2228
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2229
2229
|
return {
|
|
2230
2230
|
signature: sig,
|
|
@@ -2782,7 +2782,7 @@ function crc32(bytes) {
|
|
|
2782
2782
|
}
|
|
2783
2783
|
var BI_RGB = 0;
|
|
2784
2784
|
var MAX_DIM = 32767;
|
|
2785
|
-
var MAX_PIXELS =
|
|
2785
|
+
var MAX_PIXELS = 36e6;
|
|
2786
2786
|
function bmpToPng(bmp) {
|
|
2787
2787
|
if (bmp.length < 54) return null;
|
|
2788
2788
|
if (bmp[0] !== 66 || bmp[1] !== 77) return null;
|
|
@@ -2870,7 +2870,6 @@ function encodePng(width, height, rgba) {
|
|
|
2870
2870
|
out.set(iendChunk, o);
|
|
2871
2871
|
return out;
|
|
2872
2872
|
}
|
|
2873
|
-
var MAX_INLINE_MD_BYTES = 4 * 1024 * 1024;
|
|
2874
2873
|
function escapeRegExp(s) {
|
|
2875
2874
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2876
2875
|
}
|
|
@@ -2889,8 +2888,11 @@ function inlineImagesIntoMarkdown(markdown, images, opts) {
|
|
|
2889
2888
|
}
|
|
2890
2889
|
const base64 = Buffer.from(bytes).toString("base64");
|
|
2891
2890
|
const dataUri = `data:${mime};base64,${base64}`;
|
|
2892
|
-
const
|
|
2893
|
-
|
|
2891
|
+
const name = escapeRegExp(img.filename);
|
|
2892
|
+
const mdRe = new RegExp(`!\\[image\\]\\((?:images/)?${name}\\)`, "g");
|
|
2893
|
+
out = out.replace(mdRe, () => ``);
|
|
2894
|
+
const imgTagRe = new RegExp(`(<img\\b[^>]*\\bsrc=")(?:images/)?${name}(")`, "g");
|
|
2895
|
+
out = out.replace(imgTagRe, (_m, pre, post) => `${pre}${dataUri}${post}`);
|
|
2894
2896
|
}
|
|
2895
2897
|
return out;
|
|
2896
2898
|
}
|
|
@@ -3892,7 +3894,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3892
3894
|
lenientCfb = parseLenientCfb(buffer);
|
|
3893
3895
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3894
3896
|
} catch (e21) {
|
|
3895
|
-
throw new (0,
|
|
3897
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3896
3898
|
}
|
|
3897
3899
|
}
|
|
3898
3900
|
const findStream = (path) => {
|
|
@@ -3903,11 +3905,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3903
3905
|
return lenientCfb.findStream(path);
|
|
3904
3906
|
};
|
|
3905
3907
|
const headerData = findStream("/FileHeader");
|
|
3906
|
-
if (!headerData) throw new (0,
|
|
3908
|
+
if (!headerData) throw new (0, _chunkR2H34FY5cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3907
3909
|
const header = parseFileHeader(headerData);
|
|
3908
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3909
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3910
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3910
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkR2H34FY5cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3911
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3912
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkR2H34FY5cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3911
3913
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3912
3914
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3913
3915
|
const metadata = {
|
|
@@ -3916,7 +3918,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3916
3918
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3917
3919
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3918
3920
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3919
|
-
if (sections.length === 0) throw new (0,
|
|
3921
|
+
if (sections.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3920
3922
|
metadata.pageCount = sections.length;
|
|
3921
3923
|
const pageFilter = _optionalChain([options, 'optionalAccess', _52 => _52.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3922
3924
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3930,22 +3932,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3930
3932
|
const sectionData = sections[si];
|
|
3931
3933
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3932
3934
|
totalDecompressed += data.length;
|
|
3933
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3935
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3934
3936
|
const records = readRecords(data);
|
|
3935
3937
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3936
3938
|
bodyBlocks.push(...sectionBlocks);
|
|
3937
3939
|
parsedSections++;
|
|
3938
3940
|
_optionalChain([options, 'optionalAccess', _53 => _53.onProgress, 'optionalCall', _54 => _54(parsedSections, totalTarget)]);
|
|
3939
3941
|
} catch (secErr) {
|
|
3940
|
-
if (secErr instanceof
|
|
3942
|
+
if (secErr instanceof _chunkR2H34FY5cjs.KordocError) throw secErr;
|
|
3941
3943
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3942
3944
|
}
|
|
3943
3945
|
}
|
|
3944
3946
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3945
3947
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3946
|
-
let flatBlocks =
|
|
3948
|
+
let flatBlocks = _chunkR2H34FY5cjs.flattenLayoutTables.call(void 0, blocks);
|
|
3947
3949
|
if (_optionalChain([options, 'optionalAccess', _55 => _55.dedupeRunningHeaders])) {
|
|
3948
|
-
const deduped =
|
|
3950
|
+
const deduped = _chunkR2H34FY5cjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
3949
3951
|
const removed = flatBlocks.length - deduped.length;
|
|
3950
3952
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
3951
3953
|
flatBlocks = deduped;
|
|
@@ -3954,7 +3956,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3954
3956
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3955
3957
|
}
|
|
3956
3958
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3957
|
-
let markdown =
|
|
3959
|
+
let markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3958
3960
|
if (_optionalChain([options, 'optionalAccess', _56 => _56.inlineImages]) && images.length > 0) {
|
|
3959
3961
|
try {
|
|
3960
3962
|
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
@@ -4021,9 +4023,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4021
4023
|
let level = 0;
|
|
4022
4024
|
if (_optionalChain([block, 'access', _61 => _61.style, 'optionalAccess', _62 => _62.fontSize]) && baseFontSize > 0) {
|
|
4023
4025
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4024
|
-
if (ratio >=
|
|
4025
|
-
else if (ratio >=
|
|
4026
|
-
else if (ratio >=
|
|
4026
|
+
if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H1) level = 1;
|
|
4027
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H2) level = 2;
|
|
4028
|
+
else if (ratio >= _chunkR2H34FY5cjs.HEADING_RATIO_H3) level = 3;
|
|
4027
4029
|
}
|
|
4028
4030
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4029
4031
|
if (level === 0) level = 2;
|
|
@@ -4108,7 +4110,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4108
4110
|
if (!raw) break;
|
|
4109
4111
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4110
4112
|
totalDecompressed += content.length;
|
|
4111
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4113
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4112
4114
|
sections.push({ idx: i, content });
|
|
4113
4115
|
}
|
|
4114
4116
|
if (sections.length === 0) {
|
|
@@ -4120,7 +4122,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4120
4122
|
if (raw) {
|
|
4121
4123
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4122
4124
|
totalDecompressed += content.length;
|
|
4123
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4125
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4124
4126
|
sections.push({ idx, content });
|
|
4125
4127
|
}
|
|
4126
4128
|
}
|
|
@@ -4137,7 +4139,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4137
4139
|
try {
|
|
4138
4140
|
const content = decryptViewText(raw, compressed);
|
|
4139
4141
|
totalDecompressed += content.length;
|
|
4140
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4142
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4141
4143
|
sections.push({ idx: i, content });
|
|
4142
4144
|
} catch (e26) {
|
|
4143
4145
|
break;
|
|
@@ -4240,7 +4242,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4240
4242
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4241
4243
|
if (!_optionalChain([ctrl, 'optionalAccess', _69 => _69.href]) || r.end <= r.start) continue;
|
|
4242
4244
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4243
|
-
const href =
|
|
4245
|
+
const href = _chunkR2H34FY5cjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4244
4246
|
if (!href) continue;
|
|
4245
4247
|
const anchor = text.slice(r.start, r.end);
|
|
4246
4248
|
if (!anchor.trim()) continue;
|
|
@@ -4473,8 +4475,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4473
4475
|
let tableIdx = -1;
|
|
4474
4476
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4475
4477
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4476
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4477
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4478
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkR2H34FY5cjs.MAX_ROWS);
|
|
4479
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkR2H34FY5cjs.MAX_COLS);
|
|
4478
4480
|
tableIdx = i2;
|
|
4479
4481
|
break;
|
|
4480
4482
|
}
|
|
@@ -4523,7 +4525,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4523
4525
|
return table2;
|
|
4524
4526
|
}
|
|
4525
4527
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4526
|
-
const table =
|
|
4528
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
4527
4529
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4528
4530
|
return table.rows > 0 ? table : null;
|
|
4529
4531
|
}
|
|
@@ -4540,8 +4542,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4540
4542
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4541
4543
|
const cs = rec.data.readUInt16LE(12);
|
|
4542
4544
|
const rs = rec.data.readUInt16LE(14);
|
|
4543
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4544
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4545
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkR2H34FY5cjs.MAX_COLS);
|
|
4546
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkR2H34FY5cjs.MAX_ROWS);
|
|
4545
4547
|
}
|
|
4546
4548
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4547
4549
|
const parts = [];
|
|
@@ -4551,7 +4553,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4551
4553
|
parts.push(``);
|
|
4552
4554
|
hasStructure = true;
|
|
4553
4555
|
} else if (b.type === "table" && b.table) {
|
|
4554
|
-
const flat =
|
|
4556
|
+
const flat = _chunkR2H34FY5cjs.convertTableToText.call(void 0, b.table.cells);
|
|
4555
4557
|
if (flat) parts.push(flat);
|
|
4556
4558
|
hasStructure = true;
|
|
4557
4559
|
} else if (b.text) {
|
|
@@ -16988,7 +16990,7 @@ function getTextContent(el) {
|
|
|
16988
16990
|
return _nullishCoalesce(_optionalChain([el, 'access', _84 => _84.textContent, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()]), () => ( ""));
|
|
16989
16991
|
}
|
|
16990
16992
|
function parseXml(text) {
|
|
16991
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16993
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
16992
16994
|
}
|
|
16993
16995
|
function parseSharedStrings(xml) {
|
|
16994
16996
|
const doc = parseXml(xml);
|
|
@@ -17132,7 +17134,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17132
17134
|
cellRows.push(row);
|
|
17133
17135
|
}
|
|
17134
17136
|
if (cellRows.length > 0) {
|
|
17135
|
-
const table =
|
|
17137
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
17136
17138
|
if (table.rows > 0) {
|
|
17137
17139
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17138
17140
|
}
|
|
@@ -17140,12 +17142,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17140
17142
|
return blocks;
|
|
17141
17143
|
}
|
|
17142
17144
|
async function parseXlsxDocument(buffer, options) {
|
|
17143
|
-
|
|
17145
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
17144
17146
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
17145
17147
|
const warnings = [];
|
|
17146
17148
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
17147
17149
|
if (!workbookFile) {
|
|
17148
|
-
throw new (0,
|
|
17150
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17149
17151
|
}
|
|
17150
17152
|
let sharedStrings = [];
|
|
17151
17153
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17154,7 +17156,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17154
17156
|
}
|
|
17155
17157
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
17156
17158
|
if (sheets.length === 0) {
|
|
17157
|
-
throw new (0,
|
|
17159
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17158
17160
|
}
|
|
17159
17161
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17160
17162
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17226,7 +17228,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17226
17228
|
} catch (e27) {
|
|
17227
17229
|
}
|
|
17228
17230
|
}
|
|
17229
|
-
const markdown =
|
|
17231
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
17230
17232
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17231
17233
|
}
|
|
17232
17234
|
|
|
@@ -17633,11 +17635,11 @@ function processGlobals(records) {
|
|
|
17633
17635
|
let encrypted = false;
|
|
17634
17636
|
const firstBof = records[0];
|
|
17635
17637
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17636
|
-
throw new (0,
|
|
17638
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17637
17639
|
}
|
|
17638
17640
|
const bof = decodeBof(firstBof.data);
|
|
17639
17641
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17640
|
-
throw new (0,
|
|
17642
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17641
17643
|
}
|
|
17642
17644
|
let i = 1;
|
|
17643
17645
|
while (i < records.length) {
|
|
@@ -17752,7 +17754,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17752
17754
|
cellRows.push(row);
|
|
17753
17755
|
}
|
|
17754
17756
|
if (cellRows.length > 0) {
|
|
17755
|
-
const table =
|
|
17757
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
17756
17758
|
if (table.rows > 0) {
|
|
17757
17759
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17758
17760
|
}
|
|
@@ -17765,21 +17767,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17765
17767
|
try {
|
|
17766
17768
|
cfb = parseLenientCfb(buf);
|
|
17767
17769
|
} catch (e) {
|
|
17768
|
-
throw new (0,
|
|
17770
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
17769
17771
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17770
17772
|
);
|
|
17771
17773
|
}
|
|
17772
17774
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17773
17775
|
if (!wb) {
|
|
17774
|
-
throw new (0,
|
|
17776
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17775
17777
|
}
|
|
17776
17778
|
const records = readRecords2(wb);
|
|
17777
17779
|
if (records.length === 0) {
|
|
17778
|
-
throw new (0,
|
|
17780
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17779
17781
|
}
|
|
17780
17782
|
const firstBof = decodeBof(records[0].data);
|
|
17781
17783
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17782
|
-
throw new (0,
|
|
17784
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
17783
17785
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17784
17786
|
);
|
|
17785
17787
|
}
|
|
@@ -17839,7 +17841,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17839
17841
|
pageCount: totalSheets
|
|
17840
17842
|
};
|
|
17841
17843
|
return {
|
|
17842
|
-
markdown:
|
|
17844
|
+
markdown: _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17843
17845
|
blocks: allBlocks,
|
|
17844
17846
|
metadata,
|
|
17845
17847
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18277,7 +18279,7 @@ function getAttr(el, localName2) {
|
|
|
18277
18279
|
return null;
|
|
18278
18280
|
}
|
|
18279
18281
|
function parseXml2(text) {
|
|
18280
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18282
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkR2H34FY5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
18281
18283
|
}
|
|
18282
18284
|
function parseStyles(xml) {
|
|
18283
18285
|
const doc = parseXml2(xml);
|
|
@@ -18562,7 +18564,7 @@ ${cell.text}` : cell.text;
|
|
|
18562
18564
|
return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
|
|
18563
18565
|
})
|
|
18564
18566
|
);
|
|
18565
|
-
const table =
|
|
18567
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
18566
18568
|
if (table.rows === 0 || table.cols === 0) return null;
|
|
18567
18569
|
return { type: "table", table };
|
|
18568
18570
|
}
|
|
@@ -18629,12 +18631,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18629
18631
|
return { blocks, images };
|
|
18630
18632
|
}
|
|
18631
18633
|
async function parseDocxDocument(buffer, options) {
|
|
18632
|
-
|
|
18634
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18633
18635
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18634
18636
|
const warnings = [];
|
|
18635
18637
|
const docFile = zip.file("word/document.xml");
|
|
18636
18638
|
if (!docFile) {
|
|
18637
|
-
throw new (0,
|
|
18639
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18638
18640
|
}
|
|
18639
18641
|
let rels = /* @__PURE__ */ new Map();
|
|
18640
18642
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18681,7 +18683,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18681
18683
|
const doc = parseXml2(docXml);
|
|
18682
18684
|
const body = findElements(doc, "body");
|
|
18683
18685
|
if (body.length === 0) {
|
|
18684
|
-
throw new (0,
|
|
18686
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18685
18687
|
}
|
|
18686
18688
|
const blocks = [];
|
|
18687
18689
|
const bodyEl = body[0];
|
|
@@ -18726,7 +18728,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18726
18728
|
}
|
|
18727
18729
|
}
|
|
18728
18730
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18729
|
-
const markdown =
|
|
18731
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18730
18732
|
return {
|
|
18731
18733
|
markdown,
|
|
18732
18734
|
blocks,
|
|
@@ -18749,7 +18751,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18749
18751
|
}
|
|
18750
18752
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18751
18753
|
const normalized = text.replace(/ /g, " ");
|
|
18752
|
-
const xml =
|
|
18754
|
+
const xml = _chunkR2H34FY5cjs.stripDtd.call(void 0, normalized);
|
|
18753
18755
|
const warnings = [];
|
|
18754
18756
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18755
18757
|
onError: (_level, msg2) => {
|
|
@@ -18789,7 +18791,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18789
18791
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18790
18792
|
}
|
|
18791
18793
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18792
|
-
const markdown =
|
|
18794
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
18793
18795
|
return {
|
|
18794
18796
|
markdown,
|
|
18795
18797
|
blocks,
|
|
@@ -18947,7 +18949,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18947
18949
|
const cellRows = grid.map(
|
|
18948
18950
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18949
18951
|
);
|
|
18950
|
-
const table =
|
|
18952
|
+
const table = _chunkR2H34FY5cjs.buildTable.call(void 0, cellRows);
|
|
18951
18953
|
const caption = extractShapeCaption(el);
|
|
18952
18954
|
if (caption.text && caption.before) {
|
|
18953
18955
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20275,19 +20277,19 @@ function parseCentralDirectory(buf) {
|
|
|
20275
20277
|
}
|
|
20276
20278
|
}
|
|
20277
20279
|
}
|
|
20278
|
-
if (eocdOffset < 0) throw new (0,
|
|
20280
|
+
if (eocdOffset < 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20279
20281
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20280
20282
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20281
20283
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20282
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20284
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20283
20285
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20284
|
-
throw new (0,
|
|
20286
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20285
20287
|
}
|
|
20286
20288
|
const decoder = new TextDecoder("utf-8");
|
|
20287
20289
|
const entries = [];
|
|
20288
20290
|
let pos = cdOffset;
|
|
20289
20291
|
for (let i = 0; i < totalEntries; i++) {
|
|
20290
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20292
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20291
20293
|
const flags = view.getUint16(pos + 8, true);
|
|
20292
20294
|
const method = view.getUint16(pos + 10, true);
|
|
20293
20295
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20298,7 +20300,7 @@ function parseCentralDirectory(buf) {
|
|
|
20298
20300
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20299
20301
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20300
20302
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20301
|
-
throw new (0,
|
|
20303
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20302
20304
|
}
|
|
20303
20305
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20304
20306
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20327,11 +20329,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20327
20329
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20328
20330
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20329
20331
|
for (const name of replacements.keys()) {
|
|
20330
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20332
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkR2H34FY5cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20331
20333
|
}
|
|
20332
20334
|
if (additions) {
|
|
20333
20335
|
for (const name of additions.keys()) {
|
|
20334
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20336
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkR2H34FY5cjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20335
20337
|
}
|
|
20336
20338
|
}
|
|
20337
20339
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20350,7 +20352,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20350
20352
|
offset += seg.length;
|
|
20351
20353
|
continue;
|
|
20352
20354
|
}
|
|
20353
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20355
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkR2H34FY5cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20354
20356
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20355
20357
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20356
20358
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20456,7 +20458,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20456
20458
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20457
20459
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20458
20460
|
if (sectionPaths.length === 0) {
|
|
20459
|
-
throw new (0,
|
|
20461
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20460
20462
|
}
|
|
20461
20463
|
const normalizedValues = normalizeValues(values);
|
|
20462
20464
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -22051,7 +22053,7 @@ function escapeGfm(text) {
|
|
|
22051
22053
|
}
|
|
22052
22054
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
22053
22055
|
function sanitizeText(text) {
|
|
22054
|
-
let result =
|
|
22056
|
+
let result = _chunkR2H34FY5cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
22055
22057
|
if (result.length <= 30 && result.includes(" ")) {
|
|
22056
22058
|
const tokens = result.split(" ");
|
|
22057
22059
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -22290,37 +22292,141 @@ function removeNestedTables(html) {
|
|
|
22290
22292
|
return result;
|
|
22291
22293
|
}
|
|
22292
22294
|
|
|
22295
|
+
// src/hwpx/gen-profile.ts
|
|
22296
|
+
function normalizeAnchor(s) {
|
|
22297
|
+
return s.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "").slice(0, 24);
|
|
22298
|
+
}
|
|
22299
|
+
function takeProfile(remap, rows, cols, anchor, seq) {
|
|
22300
|
+
if (!remap) return null;
|
|
22301
|
+
for (const t of remap.tables) {
|
|
22302
|
+
if (t.used) continue;
|
|
22303
|
+
if (t.rows !== rows || t.cols !== cols) continue;
|
|
22304
|
+
if (t.anchor && anchor) {
|
|
22305
|
+
if (t.anchor !== anchor) continue;
|
|
22306
|
+
} else if (t.index !== seq) {
|
|
22307
|
+
continue;
|
|
22308
|
+
}
|
|
22309
|
+
t.used = true;
|
|
22310
|
+
return t;
|
|
22311
|
+
}
|
|
22312
|
+
return null;
|
|
22313
|
+
}
|
|
22314
|
+
function parseHu(s) {
|
|
22315
|
+
if (s == null) return void 0;
|
|
22316
|
+
const n = parseInt(String(s).trim(), 10);
|
|
22317
|
+
return Number.isFinite(n) ? n : void 0;
|
|
22318
|
+
}
|
|
22319
|
+
function edgeXml(tag, d) {
|
|
22320
|
+
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22321
|
+
}
|
|
22322
|
+
function borderFillDefToXml(id, def) {
|
|
22323
|
+
const fill = _optionalChain([def, 'access', _211 => _211.fill, 'optionalAccess', _212 => _212.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22324
|
+
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22325
|
+
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22326
|
+
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
22327
|
+
${edgeXml("leftBorder", def.leftBorder)}
|
|
22328
|
+
${edgeXml("rightBorder", def.rightBorder)}
|
|
22329
|
+
${edgeXml("topBorder", def.topBorder)}
|
|
22330
|
+
${edgeXml("bottomBorder", def.bottomBorder)}${fill ? `
|
|
22331
|
+
${fill}` : ""}
|
|
22332
|
+
</hh:borderFill>`;
|
|
22333
|
+
}
|
|
22334
|
+
var PROFILE_FONT_MAX = 2;
|
|
22335
|
+
function profileCharPrXml(id, def) {
|
|
22336
|
+
const height = _nullishCoalesce(parseHu(def.height_hwpunit), () => ( 1e3));
|
|
22337
|
+
const color = _nullishCoalesce(def.textColor, () => ( "#000000"));
|
|
22338
|
+
const rawFont = def.fontRef_hangul != null ? parseInt(def.fontRef_hangul, 10) || 0 : 0;
|
|
22339
|
+
const font = rawFont >= 0 && rawFont <= PROFILE_FONT_MAX ? rawFont : 0;
|
|
22340
|
+
const boldAttr = def.bold ? ` bold="1"` : "";
|
|
22341
|
+
const italicAttr = def.italic ? ` italic="1"` : "";
|
|
22342
|
+
const underline = def.underline ? `
|
|
22343
|
+
<hh:underline type="BOTTOM" shape="SOLID" color="${color}"/>` : "";
|
|
22344
|
+
return ` <hh:charPr id="${id}" height="${height}" textColor="${color}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="1"${boldAttr}${italicAttr}>
|
|
22345
|
+
<hh:fontRef hangul="${font}" latin="${font}" hanja="${font}" japanese="${font}" other="${font}" symbol="${font}" user="${font}"/>
|
|
22346
|
+
<hh:ratio hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22347
|
+
<hh:spacing hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
22348
|
+
<hh:relSz hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22349
|
+
<hh:offset hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>${underline}
|
|
22350
|
+
</hh:charPr>`;
|
|
22351
|
+
}
|
|
22352
|
+
function buildProfileRemap(profile, charPrBase, borderFillBase = 3) {
|
|
22353
|
+
const remap = { borderFillXmls: [], charPrXmls: [], tables: [] };
|
|
22354
|
+
let bfNext = borderFillBase;
|
|
22355
|
+
let charNext = charPrBase;
|
|
22356
|
+
for (const t of profile.tables) {
|
|
22357
|
+
const localBf = {};
|
|
22358
|
+
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_border_fills, () => ( {})))) {
|
|
22359
|
+
const gid = bfNext++;
|
|
22360
|
+
remap.borderFillXmls.push(borderFillDefToXml(gid, def));
|
|
22361
|
+
localBf[key] = gid;
|
|
22362
|
+
}
|
|
22363
|
+
const localChar = {};
|
|
22364
|
+
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_char_prs, () => ( {})))) {
|
|
22365
|
+
const gid = charNext++;
|
|
22366
|
+
remap.charPrXmls.push(profileCharPrXml(gid, def));
|
|
22367
|
+
localChar[key] = gid;
|
|
22368
|
+
}
|
|
22369
|
+
let colWidths;
|
|
22370
|
+
if (t.col_widths_hwpunit && t.col_widths_hwpunit.length === t.cols) {
|
|
22371
|
+
const parsed = t.col_widths_hwpunit.map(parseHu);
|
|
22372
|
+
if (parsed.every((n) => n != null)) colWidths = parsed;
|
|
22373
|
+
}
|
|
22374
|
+
const tr = {
|
|
22375
|
+
index: t.table_index,
|
|
22376
|
+
rows: t.rows,
|
|
22377
|
+
cols: t.cols,
|
|
22378
|
+
// 재정규화 — 추출기는 정규화해 담지만 손편집된 프로필 JSON도 같은 키 공간으로
|
|
22379
|
+
anchor: t.anchor_text ? normalizeAnchor(t.anchor_text) : void 0,
|
|
22380
|
+
width: parseHu(t.width_hwpunit),
|
|
22381
|
+
colWidths,
|
|
22382
|
+
cellBf: /* @__PURE__ */ new Map(),
|
|
22383
|
+
cellChar: /* @__PURE__ */ new Map(),
|
|
22384
|
+
cellH: /* @__PURE__ */ new Map()
|
|
22385
|
+
};
|
|
22386
|
+
for (const cell of t.cells) {
|
|
22387
|
+
const k = `${cell.row},${cell.col}`;
|
|
22388
|
+
if (cell.borderFillIDRef != null && cell.borderFillIDRef in localBf) {
|
|
22389
|
+
tr.cellBf.set(k, localBf[cell.borderFillIDRef]);
|
|
22390
|
+
}
|
|
22391
|
+
if (cell.charPrIDRef != null && cell.charPrIDRef in localChar) {
|
|
22392
|
+
tr.cellChar.set(k, localChar[cell.charPrIDRef]);
|
|
22393
|
+
}
|
|
22394
|
+
const h = parseHu(cell.height_hwpunit);
|
|
22395
|
+
if (h != null) tr.cellH.set(k, h);
|
|
22396
|
+
}
|
|
22397
|
+
remap.tables.push(tr);
|
|
22398
|
+
}
|
|
22399
|
+
return remap;
|
|
22400
|
+
}
|
|
22401
|
+
function profileCharPrBase(ratioVariantCount) {
|
|
22402
|
+
return CHAR_VARIANT_BASE + ratioVariantCount * 4;
|
|
22403
|
+
}
|
|
22404
|
+
|
|
22293
22405
|
// src/hwpx/gen-table.ts
|
|
22294
22406
|
var TABLE_ID_BASE = 1e3;
|
|
22295
22407
|
var tableIdCounter = TABLE_ID_BASE;
|
|
22296
22408
|
function nextTableId() {
|
|
22297
22409
|
return ++tableIdCounter;
|
|
22298
22410
|
}
|
|
22299
|
-
|
|
22300
|
-
|
|
22301
|
-
if (warnedTables.has(tblId)) return;
|
|
22302
|
-
warnedTables.add(tblId);
|
|
22303
|
-
console.warn(`[kordoc] format profile: table ${tp.rows}x${tp.cols} vs document ${rowCnt}x${colCnt} \u2014 \uD504\uB85C\uD544 \uBB34\uC2DC`);
|
|
22411
|
+
function anchorOfMarkdownCell(cell) {
|
|
22412
|
+
return normalizeAnchor(cell.replace(/!\[[^\]]*\]\([^)]*\)/g, ""));
|
|
22304
22413
|
}
|
|
22305
|
-
function
|
|
22306
|
-
|
|
22307
|
-
|
|
22308
|
-
|
|
22309
|
-
return null;
|
|
22310
|
-
}
|
|
22311
|
-
return tp;
|
|
22414
|
+
function anchorOfHtmlCell(inner) {
|
|
22415
|
+
const noNested = inner.replace(/<table[\s\S]*?<\/table>/gi, "");
|
|
22416
|
+
const { lines } = htmlCellInnerToLines(noNested);
|
|
22417
|
+
return normalizeAnchor(lines.join(""));
|
|
22312
22418
|
}
|
|
22313
22419
|
function resolveColWidths(tp, colCnt, fallbackTotal) {
|
|
22314
|
-
if (_optionalChain([tp, 'optionalAccess',
|
|
22315
|
-
const w = _optionalChain([tp, 'optionalAccess',
|
|
22420
|
+
if (_optionalChain([tp, 'optionalAccess', _213 => _213.colWidths]) && tp.colWidths.length === colCnt) return tp.colWidths;
|
|
22421
|
+
const w = _optionalChain([tp, 'optionalAccess', _214 => _214.width]) ? Math.floor(tp.width / colCnt) : Math.floor(fallbackTotal / colCnt);
|
|
22316
22422
|
return Array(colCnt).fill(w);
|
|
22317
22423
|
}
|
|
22318
|
-
function generateTable(rows, theme,
|
|
22424
|
+
function generateTable(rows, theme, remap = null, seq = 0) {
|
|
22319
22425
|
const rowCnt = rows.length;
|
|
22320
22426
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
22321
22427
|
const cellH = 1500;
|
|
22322
22428
|
const tblId = nextTableId();
|
|
22323
|
-
const prof =
|
|
22429
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _215 => _215[0], 'optionalAccess', _216 => _216[0]]), () => ( ""))), seq);
|
|
22324
22430
|
const colW = resolveColWidths(prof, colCnt, 44e3);
|
|
22325
22431
|
const tblW = colW.reduce((a, b) => a + b, 0);
|
|
22326
22432
|
const tblH = cellH * rowCnt;
|
|
@@ -22331,9 +22437,9 @@ function generateTable(rows, theme, tp = null) {
|
|
|
22331
22437
|
const headerCharPr = isHeaderRow && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
22332
22438
|
const tdElements = cells.map((cell, colIdx) => {
|
|
22333
22439
|
const k = `${rowIdx},${colIdx}`;
|
|
22334
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22335
|
-
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22336
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22440
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _217 => _217.cellBf, 'access', _218 => _218.get, 'call', _219 => _219(k)]), () => ( 2));
|
|
22441
|
+
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _220 => _220.cellChar, 'access', _221 => _221.get, 'call', _222 => _222(k)]), () => ( headerCharPr));
|
|
22442
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _223 => _223.cellH, 'access', _224 => _224.get, 'call', _225 => _225(k)]), () => ( cellH));
|
|
22337
22443
|
const runs = generateRuns(cell, ch);
|
|
22338
22444
|
const p = `<hp:p paraPrIDRef="0" styleIDRef="0">${runs}</hp:p>`;
|
|
22339
22445
|
return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${p}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${colW[colIdx]}" height="${h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
@@ -22367,23 +22473,24 @@ function layoutHtmlRows(rows) {
|
|
|
22367
22473
|
function unescapeHtml(s) {
|
|
22368
22474
|
return s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
22369
22475
|
}
|
|
22370
|
-
function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3,
|
|
22476
|
+
function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, remap = null, seq = 0) {
|
|
22371
22477
|
const rows = parseHtmlTable(rawHtml);
|
|
22372
22478
|
if (!rows || rows.length === 0) return null;
|
|
22373
22479
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
22374
22480
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
22375
22481
|
const cellH = 1500;
|
|
22376
22482
|
const tblId = nextTableId();
|
|
22377
|
-
const
|
|
22483
|
+
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
22484
|
+
const prof = takeProfile(remap, rowCnt, colCnt, first ? anchorOfHtmlCell(first.inner) : "", seq);
|
|
22378
22485
|
const colW = resolveColWidths(prof, colCnt, totalWidth);
|
|
22379
22486
|
const tblW = colW.reduce((a, b) => a + b, 0);
|
|
22380
22487
|
const useHeaderStyle = theme.tableHeader !== theme.body || theme.tableHeaderBold;
|
|
22381
22488
|
const spanW = (c, colSpan) => colW.slice(c, c + colSpan).reduce((a, b) => a + b, 0);
|
|
22382
22489
|
const tcXmls = placed.map((cell) => {
|
|
22383
22490
|
const k = `${cell.r},${cell.c}`;
|
|
22384
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22491
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _226 => _226.cellBf, 'access', _227 => _227.get, 'call', _228 => _228(k)]), () => ( 2));
|
|
22385
22492
|
const headerCharPr = cell.isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : CHAR_NORMAL;
|
|
22386
|
-
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22493
|
+
const ch = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _229 => _229.cellChar, 'access', _230 => _230.get, 'call', _231 => _231(k)]), () => ( headerCharPr));
|
|
22387
22494
|
const { lines } = htmlCellInnerToLines(cell.inner);
|
|
22388
22495
|
const paras = lines.map(
|
|
22389
22496
|
(line) => `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${ch}"><hp:t>${escapeXml(unescapeHtml(line))}</hp:t></hp:run></hp:p>`
|
|
@@ -22401,7 +22508,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, tp = null) {
|
|
|
22401
22508
|
paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="${ch}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
22402
22509
|
}
|
|
22403
22510
|
const contentH = Math.max(cellH * cell.rowSpan, Math.max(lines.length, 1) * 800 + nestedH);
|
|
22404
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22511
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _232 => _232.cellH, 'access', _233 => _233.get, 'call', _234 => _234(k)]), () => ( 0)), contentH);
|
|
22405
22512
|
return `<hp:tc name="" header="${cell.isHeader ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${paras.join("")}</hp:subList><hp:cellAddr colAddr="${cell.c}" rowAddr="${cell.r}"/><hp:cellSpan colSpan="${cell.colSpan}" rowSpan="${cell.rowSpan}"/><hp:cellSz width="${cellW}" height="${cellHeight}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22406
22513
|
});
|
|
22407
22514
|
const trXmls = [];
|
|
@@ -22771,8 +22878,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22771
22878
|
case "list_item": {
|
|
22772
22879
|
if (gongmun && gongmunList) {
|
|
22773
22880
|
const info = gongmunList.get(blockIdx);
|
|
22774
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22775
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
22881
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _235 => _235.depth]), () => ( 0));
|
|
22882
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _236 => _236.marker]), () => ( ""));
|
|
22776
22883
|
const content = block.text || "";
|
|
22777
22884
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
22778
22885
|
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
@@ -22812,12 +22919,11 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22812
22919
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
|
|
22813
22920
|
isFirst = false;
|
|
22814
22921
|
}
|
|
22815
|
-
xml = generateTable(block.rows, theme,
|
|
22816
|
-
tableSeq++;
|
|
22922
|
+
xml = generateTable(block.rows, theme, remap, tableSeq++);
|
|
22817
22923
|
}
|
|
22818
22924
|
break;
|
|
22819
22925
|
case "html_table": {
|
|
22820
|
-
const tbl = generateHtmlTableXml(block.text || "", theme, 44e3,
|
|
22926
|
+
const tbl = generateHtmlTableXml(block.text || "", theme, 44e3, remap, tableSeq++);
|
|
22821
22927
|
if (tbl) {
|
|
22822
22928
|
if (isFirst) {
|
|
22823
22929
|
const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
|
|
@@ -22825,7 +22931,6 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22825
22931
|
isFirst = false;
|
|
22826
22932
|
}
|
|
22827
22933
|
xml = `<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${tbl}</hp:run></hp:p>`;
|
|
22828
|
-
tableSeq++;
|
|
22829
22934
|
} else {
|
|
22830
22935
|
const plain = (block.text || "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
22831
22936
|
xml = plain ? generateParagraph(plain) : "";
|
|
@@ -22852,108 +22957,27 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
22852
22957
|
</hs:sec>`;
|
|
22853
22958
|
}
|
|
22854
22959
|
|
|
22855
|
-
// src/hwpx/gen-profile.ts
|
|
22856
|
-
function parseHu(s) {
|
|
22857
|
-
if (s == null) return void 0;
|
|
22858
|
-
const n = parseInt(String(s).trim(), 10);
|
|
22859
|
-
return Number.isFinite(n) ? n : void 0;
|
|
22860
|
-
}
|
|
22861
|
-
function edgeXml(tag, d) {
|
|
22862
|
-
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22863
|
-
}
|
|
22864
|
-
function borderFillDefToXml(id, def) {
|
|
22865
|
-
const fill = _optionalChain([def, 'access', _239 => _239.fill, 'optionalAccess', _240 => _240.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22866
|
-
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22867
|
-
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22868
|
-
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
22869
|
-
${edgeXml("leftBorder", def.leftBorder)}
|
|
22870
|
-
${edgeXml("rightBorder", def.rightBorder)}
|
|
22871
|
-
${edgeXml("topBorder", def.topBorder)}
|
|
22872
|
-
${edgeXml("bottomBorder", def.bottomBorder)}${fill ? `
|
|
22873
|
-
${fill}` : ""}
|
|
22874
|
-
</hh:borderFill>`;
|
|
22875
|
-
}
|
|
22876
|
-
function profileCharPrXml(id, def) {
|
|
22877
|
-
const height = _nullishCoalesce(parseHu(def.height_hwpunit), () => ( 1e3));
|
|
22878
|
-
const color = _nullishCoalesce(def.textColor, () => ( "#000000"));
|
|
22879
|
-
const font = def.fontRef_hangul != null ? parseInt(def.fontRef_hangul, 10) || 0 : 0;
|
|
22880
|
-
const boldAttr = def.bold ? ` bold="1"` : "";
|
|
22881
|
-
const italicAttr = def.italic ? ` italic="1"` : "";
|
|
22882
|
-
const underline = def.underline ? `
|
|
22883
|
-
<hh:underline type="BOTTOM" shape="SOLID" color="${color}"/>` : "";
|
|
22884
|
-
return ` <hh:charPr id="${id}" height="${height}" textColor="${color}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="1"${boldAttr}${italicAttr}>
|
|
22885
|
-
<hh:fontRef hangul="${font}" latin="${font}" hanja="${font}" japanese="${font}" other="${font}" symbol="${font}" user="${font}"/>
|
|
22886
|
-
<hh:ratio hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22887
|
-
<hh:spacing hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>
|
|
22888
|
-
<hh:relSz hangul="100" latin="100" hanja="100" japanese="100" other="100" symbol="100" user="100"/>
|
|
22889
|
-
<hh:offset hangul="0" latin="0" hanja="0" japanese="0" other="0" symbol="0" user="0"/>${underline}
|
|
22890
|
-
</hh:charPr>`;
|
|
22891
|
-
}
|
|
22892
|
-
function buildProfileRemap(profile, charPrBase, borderFillBase = 3) {
|
|
22893
|
-
const remap = { borderFillXmls: [], charPrXmls: [], tables: /* @__PURE__ */ new Map() };
|
|
22894
|
-
let bfNext = borderFillBase;
|
|
22895
|
-
let charNext = charPrBase;
|
|
22896
|
-
for (const t of profile.tables) {
|
|
22897
|
-
const localBf = {};
|
|
22898
|
-
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_border_fills, () => ( {})))) {
|
|
22899
|
-
const gid = bfNext++;
|
|
22900
|
-
remap.borderFillXmls.push(borderFillDefToXml(gid, def));
|
|
22901
|
-
localBf[key] = gid;
|
|
22902
|
-
}
|
|
22903
|
-
const localChar = {};
|
|
22904
|
-
for (const [key, def] of Object.entries(_nullishCoalesce(t.used_char_prs, () => ( {})))) {
|
|
22905
|
-
const gid = charNext++;
|
|
22906
|
-
remap.charPrXmls.push(profileCharPrXml(gid, def));
|
|
22907
|
-
localChar[key] = gid;
|
|
22908
|
-
}
|
|
22909
|
-
let colWidths;
|
|
22910
|
-
if (t.col_widths_hwpunit && t.col_widths_hwpunit.length === t.cols) {
|
|
22911
|
-
const parsed = t.col_widths_hwpunit.map(parseHu);
|
|
22912
|
-
if (parsed.every((n) => n != null)) colWidths = parsed;
|
|
22913
|
-
}
|
|
22914
|
-
const tr = {
|
|
22915
|
-
rows: t.rows,
|
|
22916
|
-
cols: t.cols,
|
|
22917
|
-
width: parseHu(t.width_hwpunit),
|
|
22918
|
-
colWidths,
|
|
22919
|
-
cellBf: /* @__PURE__ */ new Map(),
|
|
22920
|
-
cellChar: /* @__PURE__ */ new Map(),
|
|
22921
|
-
cellH: /* @__PURE__ */ new Map()
|
|
22922
|
-
};
|
|
22923
|
-
for (const cell of t.cells) {
|
|
22924
|
-
const k = `${cell.row},${cell.col}`;
|
|
22925
|
-
if (cell.borderFillIDRef != null && cell.borderFillIDRef in localBf) {
|
|
22926
|
-
tr.cellBf.set(k, localBf[cell.borderFillIDRef]);
|
|
22927
|
-
}
|
|
22928
|
-
if (cell.charPrIDRef != null && cell.charPrIDRef in localChar) {
|
|
22929
|
-
tr.cellChar.set(k, localChar[cell.charPrIDRef]);
|
|
22930
|
-
}
|
|
22931
|
-
const h = parseHu(cell.height_hwpunit);
|
|
22932
|
-
if (h != null) tr.cellH.set(k, h);
|
|
22933
|
-
}
|
|
22934
|
-
remap.tables.set(t.table_index, tr);
|
|
22935
|
-
}
|
|
22936
|
-
return remap;
|
|
22937
|
-
}
|
|
22938
|
-
function profileCharPrBase(ratioVariantCount) {
|
|
22939
|
-
return CHAR_VARIANT_BASE + ratioVariantCount * 4;
|
|
22940
|
-
}
|
|
22941
|
-
|
|
22942
22960
|
// src/hwpx/generator.ts
|
|
22943
22961
|
async function markdownToHwpx(markdown, options) {
|
|
22944
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
22945
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
22962
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _237 => _237.theme]));
|
|
22963
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _238 => _238.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
22946
22964
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
22947
22965
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
22948
22966
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
22949
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
22967
|
+
const remap = _optionalChain([options, 'optionalAccess', _239 => _239.profile]) ? buildProfileRemap(options.profile, profileCharPrBase(_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _240 => _240.variants, 'optionalAccess', _241 => _241.length]), () => ( 0)))) : null;
|
|
22950
22968
|
const chartParts = [];
|
|
22951
22969
|
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, remap);
|
|
22970
|
+
if (remap && remap.tables.length > 0) {
|
|
22971
|
+
const unused = remap.tables.filter((t) => !t.used).length;
|
|
22972
|
+
if (unused === remap.tables.length) {
|
|
22973
|
+
console.warn(`[kordoc] format profile: \uD504\uB85C\uD544 \uD45C ${unused}\uAC1C\uAC00 \uBB38\uC11C \uD45C\uC640 \uB9E4\uCE6D\uB418\uC9C0 \uC54A\uC544 \uBBF8\uC801\uC6A9 (\uD589\xB7\uC5F4/\uCCAB \uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
22974
|
+
}
|
|
22975
|
+
}
|
|
22952
22976
|
const zip = new (0, _jszip2.default)();
|
|
22953
22977
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
22954
22978
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
22955
22979
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
22956
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
22980
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _242 => _242.variants]), () => ( [])), remap));
|
|
22957
22981
|
zip.file("Contents/section0.xml", sectionXml);
|
|
22958
22982
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
22959
22983
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -23241,7 +23265,7 @@ function parseRenderStyles(headXml) {
|
|
|
23241
23265
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
23242
23266
|
const textColor = el.getAttribute("textColor");
|
|
23243
23267
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
23244
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
23268
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _243 => _243.getAttribute, 'call', _244 => _244("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _245 => _245.getAttribute, 'call', _246 => _246("latin")])));
|
|
23245
23269
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
23246
23270
|
styles.charPr.set(id, {
|
|
23247
23271
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -23249,8 +23273,8 @@ function parseRenderStyles(headXml) {
|
|
|
23249
23273
|
italic: findChildByLocalName(el, "italic") != null,
|
|
23250
23274
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
23251
23275
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
23252
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
23253
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
23276
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _247 => _247.getAttribute, 'call', _248 => _248("hangul")])) || 100,
|
|
23277
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _249 => _249.getAttribute, 'call', _250 => _250("hangul")])) || 0,
|
|
23254
23278
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
23255
23279
|
});
|
|
23256
23280
|
}
|
|
@@ -23258,7 +23282,7 @@ function parseRenderStyles(headXml) {
|
|
|
23258
23282
|
const id = el.getAttribute("id");
|
|
23259
23283
|
if (id != null) {
|
|
23260
23284
|
const align = findChildByLocalName(el, "align");
|
|
23261
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
23285
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _251 => _251.getAttribute, 'call', _252 => _252("horizontal")]) || "JUSTIFY");
|
|
23262
23286
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
23263
23287
|
}
|
|
23264
23288
|
} else if (tag === "borderFill") {
|
|
@@ -23272,7 +23296,7 @@ function parseRenderStyles(headXml) {
|
|
|
23272
23296
|
};
|
|
23273
23297
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
23274
23298
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
23275
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
23299
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _253 => _253.getAttribute, 'call', _254 => _254("faceColor")]);
|
|
23276
23300
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
23277
23301
|
styles.borderFill.set(id, bf);
|
|
23278
23302
|
}
|
|
@@ -23344,7 +23368,7 @@ function collectSites(scan) {
|
|
|
23344
23368
|
}
|
|
23345
23369
|
function attrOf(openTag, name) {
|
|
23346
23370
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
23347
|
-
return _optionalChain([m, 'optionalAccess',
|
|
23371
|
+
return _optionalChain([m, 'optionalAccess', _255 => _255[1]]);
|
|
23348
23372
|
}
|
|
23349
23373
|
function paraOpenTag(xml, para) {
|
|
23350
23374
|
const end = xml.indexOf(">", para.start);
|
|
@@ -23359,7 +23383,7 @@ function anchorRunInfo(xml, para, anchor) {
|
|
|
23359
23383
|
if (!tr) return null;
|
|
23360
23384
|
const before = xml.slice(Math.max(0, para.start), tr.contentStart);
|
|
23361
23385
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
23362
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
23386
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _256 => _256[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
23363
23387
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
23364
23388
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
23365
23389
|
if (close === -1) return null;
|
|
@@ -23386,7 +23410,7 @@ function cellContentWidthMm(xml, cell) {
|
|
|
23386
23410
|
if (width === null) return null;
|
|
23387
23411
|
let content = width;
|
|
23388
23412
|
const win = cellAddrWindow(xml, cell);
|
|
23389
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
23413
|
+
const mg = _optionalChain([win, 'optionalAccess', _257 => _257.match, 'call', _258 => _258(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
23390
23414
|
if (mg) {
|
|
23391
23415
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
23392
23416
|
}
|
|
@@ -23420,11 +23444,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
23420
23444
|
return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
|
|
23421
23445
|
}
|
|
23422
23446
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
23423
|
-
if (ops.length === 0) throw new (0,
|
|
23447
|
+
if (ops.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23424
23448
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
23425
23449
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
23426
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
23427
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
23450
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _259 => _259.match, 'call', _260 => _260(/(\d+)\.xml$/i), 'optionalAccess', _261 => _261[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _262 => _262.match, 'call', _263 => _263(/(\d+)\.xml$/i), 'optionalAccess', _264 => _264[1]]), () => ( 0))));
|
|
23451
|
+
if (sectionPaths.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
23428
23452
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
23429
23453
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
23430
23454
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -23465,11 +23489,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23465
23489
|
const manifestItems = [];
|
|
23466
23490
|
const placed = [];
|
|
23467
23491
|
for (const op of ops) {
|
|
23468
|
-
if (!op.anchor) throw new (0,
|
|
23469
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
23492
|
+
if (!op.anchor) throw new (0, _chunkR2H34FY5cjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23493
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
23470
23494
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
23471
|
-
if (!MIME[ext]) throw new (0,
|
|
23472
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
23495
|
+
if (!MIME[ext]) throw new (0, _chunkR2H34FY5cjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
23496
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkR2H34FY5cjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
23473
23497
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
23474
23498
|
let found = null;
|
|
23475
23499
|
let total = 0;
|
|
@@ -23502,7 +23526,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23502
23526
|
}
|
|
23503
23527
|
}
|
|
23504
23528
|
}
|
|
23505
|
-
throw new (0,
|
|
23529
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
23506
23530
|
`place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
|
|
23507
23531
|
);
|
|
23508
23532
|
}
|
|
@@ -23510,9 +23534,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23510
23534
|
const xml = sectionXmls[si];
|
|
23511
23535
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
23512
23536
|
if (!run) {
|
|
23513
|
-
throw new (0,
|
|
23537
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
23514
23538
|
}
|
|
23515
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
23539
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _265 => _265.charPr, 'access', _266 => _266.get, 'call', _267 => _267(run.charPr), 'optionalAccess', _268 => _268.height]), () => ( 1e3));
|
|
23516
23540
|
const fontPt = charPrHeight / 100;
|
|
23517
23541
|
const emMm = fontPt * 25.4 / 72;
|
|
23518
23542
|
const lineHMm = emMm;
|
|
@@ -23521,7 +23545,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
23521
23545
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
23522
23546
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
23523
23547
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
23524
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
23548
|
+
const align = _optionalChain([styles, 'optionalAccess', _269 => _269.paraAlign, 'access', _270 => _270.get, 'call', _271 => _271(paraPrId)]);
|
|
23525
23549
|
let alignShiftMm = 0;
|
|
23526
23550
|
if (align === "CENTER" || align === "RIGHT") {
|
|
23527
23551
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -23617,7 +23641,7 @@ function parseBorderFills(headerDoc) {
|
|
|
23617
23641
|
};
|
|
23618
23642
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
23619
23643
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
23620
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
23644
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _272 => _272.getAttribute, 'call', _273 => _273("faceColor")]);
|
|
23621
23645
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
23622
23646
|
map.set(id, def);
|
|
23623
23647
|
}
|
|
@@ -23637,7 +23661,7 @@ function parseCharPrs(headerDoc) {
|
|
|
23637
23661
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
23638
23662
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
23639
23663
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
23640
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
23664
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _274 => _274.getAttribute, 'call', _275 => _275("hangul")]);
|
|
23641
23665
|
if (hangul) def.fontRef_hangul = hangul;
|
|
23642
23666
|
map.set(id, def);
|
|
23643
23667
|
}
|
|
@@ -23661,25 +23685,27 @@ function parseTable3(tbl, tableIndex, borderFills, charPrs) {
|
|
|
23661
23685
|
const rows = _nullishCoalesce(num(tbl.getAttribute("rowCnt")), () => ( 0));
|
|
23662
23686
|
const cols = _nullishCoalesce(num(tbl.getAttribute("colCnt")), () => ( 0));
|
|
23663
23687
|
const sz = findChildByLocalName(tbl, "sz");
|
|
23664
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
23688
|
+
const width = _optionalChain([sz, 'optionalAccess', _276 => _276.getAttribute, 'call', _277 => _277("width")]) || void 0;
|
|
23665
23689
|
const cells = [];
|
|
23666
23690
|
const usedBf = /* @__PURE__ */ new Set();
|
|
23667
23691
|
const usedCp = /* @__PURE__ */ new Set();
|
|
23668
23692
|
const colWidths = new Array(cols).fill(void 0);
|
|
23693
|
+
let anchorText = "";
|
|
23669
23694
|
for (const tc of elemsByLocal(tbl, "tc")) {
|
|
23670
23695
|
if (nearestTable(tc) !== tbl) continue;
|
|
23671
23696
|
const addr = findChildByLocalName(tc, "cellAddr");
|
|
23672
23697
|
const span = findChildByLocalName(tc, "cellSpan");
|
|
23673
23698
|
const csz = findChildByLocalName(tc, "cellSz");
|
|
23674
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
23675
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
23676
|
-
|
|
23677
|
-
const
|
|
23699
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _278 => _278.getAttribute, 'call', _279 => _279("rowAddr")])), () => ( 0));
|
|
23700
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _280 => _280.getAttribute, 'call', _281 => _281("colAddr")])), () => ( 0));
|
|
23701
|
+
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc);
|
|
23702
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _282 => _282.getAttribute, 'call', _283 => _283("colSpan")])), () => ( 1));
|
|
23703
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _284 => _284.getAttribute, 'call', _285 => _285("rowSpan")])), () => ( 1));
|
|
23678
23704
|
const bfId = tc.getAttribute("borderFillIDRef") || void 0;
|
|
23679
23705
|
const cpId = firstRunCharPr(tc);
|
|
23680
23706
|
const cell = { row, col, rowSpan, colSpan };
|
|
23681
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
23682
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
23707
|
+
const w = _optionalChain([csz, 'optionalAccess', _286 => _286.getAttribute, 'call', _287 => _287("width")]);
|
|
23708
|
+
const hh = _optionalChain([csz, 'optionalAccess', _288 => _288.getAttribute, 'call', _289 => _289("height")]);
|
|
23683
23709
|
if (w) cell.width_hwpunit = w;
|
|
23684
23710
|
if (hh) cell.height_hwpunit = hh;
|
|
23685
23711
|
if (bfId) {
|
|
@@ -23700,6 +23726,8 @@ function parseTable3(tbl, tableIndex, borderFills, charPrs) {
|
|
|
23700
23726
|
cells,
|
|
23701
23727
|
used_border_fills: pick(borderFills, usedBf)
|
|
23702
23728
|
};
|
|
23729
|
+
const anchor = normalizeAnchor(anchorText);
|
|
23730
|
+
if (anchor) table.anchor_text = anchor;
|
|
23703
23731
|
if (width) table.width_hwpunit = width;
|
|
23704
23732
|
if (colWidths.every((w) => w != null)) table.col_widths_hwpunit = colWidths;
|
|
23705
23733
|
const cp = pick(charPrs, usedCp);
|
|
@@ -23732,6 +23760,15 @@ function nearestCell(el) {
|
|
|
23732
23760
|
}
|
|
23733
23761
|
return null;
|
|
23734
23762
|
}
|
|
23763
|
+
function directCellText(tc) {
|
|
23764
|
+
let out = "";
|
|
23765
|
+
for (const t of elemsByLocal(tc, "t")) {
|
|
23766
|
+
if (nearestCell(t) !== tc) continue;
|
|
23767
|
+
out += _nullishCoalesce(t.textContent, () => ( ""));
|
|
23768
|
+
if (out.length >= 64) break;
|
|
23769
|
+
}
|
|
23770
|
+
return out;
|
|
23771
|
+
}
|
|
23735
23772
|
function pick(map, keys) {
|
|
23736
23773
|
const out = {};
|
|
23737
23774
|
for (const k of keys) {
|
|
@@ -23741,16 +23778,16 @@ function pick(map, keys) {
|
|
|
23741
23778
|
return out;
|
|
23742
23779
|
}
|
|
23743
23780
|
async function hwpxToProfile(input) {
|
|
23744
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
23781
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, input);
|
|
23745
23782
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
23746
23783
|
const parser = createXmlParser();
|
|
23747
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
23784
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _290 => _290.file, 'call', _291 => _291(/[Hh]eader\.xml$/), 'optionalAccess', _292 => _292[0]])));
|
|
23748
23785
|
let headerXml = "<root/>";
|
|
23749
23786
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
23750
23787
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
23751
23788
|
const borderFills = parseBorderFills(headerDoc);
|
|
23752
23789
|
const charPrs = parseCharPrs(headerDoc);
|
|
23753
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
23790
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _293 => _293.name, 'access', _294 => _294.match, 'call', _295 => _295(/(\d+)\.xml$/), 'optionalAccess', _296 => _296[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _297 => _297.name, 'access', _298 => _298.match, 'call', _299 => _299(/(\d+)\.xml$/), 'optionalAccess', _300 => _300[1]]), () => ( null))), () => ( 0))));
|
|
23754
23791
|
const tables = [];
|
|
23755
23792
|
let tableIndex = 0;
|
|
23756
23793
|
for (const f of sectionFiles) {
|
|
@@ -23760,7 +23797,7 @@ async function hwpxToProfile(input) {
|
|
|
23760
23797
|
tables.push(parseTable3(tbl, tableIndex++, borderFills, charPrs));
|
|
23761
23798
|
}
|
|
23762
23799
|
}
|
|
23763
|
-
return { schema_version: "0.
|
|
23800
|
+
return { schema_version: "0.2.0", tables };
|
|
23764
23801
|
}
|
|
23765
23802
|
|
|
23766
23803
|
// src/roundtrip/patcher.ts
|
|
@@ -23771,7 +23808,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
23771
23808
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
23772
23809
|
function patchTableRows(input) {
|
|
23773
23810
|
const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
23774
|
-
const xml = _optionalChain([ctx, 'access',
|
|
23811
|
+
const xml = _optionalChain([ctx, 'access', _301 => _301.scans, 'access', _302 => _302[scanTable.sectionIndex], 'optionalAccess', _303 => _303.xml]);
|
|
23775
23812
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
23776
23813
|
const numRows = table.rows;
|
|
23777
23814
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -23938,7 +23975,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
23938
23975
|
const rr = scanTable.rowRanges[template];
|
|
23939
23976
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
23940
23977
|
const scan = scanSectionXml(wrapped, 0);
|
|
23941
|
-
const row = _optionalChain([scan, 'access',
|
|
23978
|
+
const row = _optionalChain([scan, 'access', _304 => _304.tables, 'access', _305 => _305[0], 'optionalAccess', _306 => _306.rows, 'access', _307 => _307[0]]);
|
|
23942
23979
|
if (!row || row.length !== cells.length) return null;
|
|
23943
23980
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
23944
23981
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -23981,7 +24018,7 @@ function rowHeightOf(fragment) {
|
|
|
23981
24018
|
}
|
|
23982
24019
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
23983
24020
|
const from = scanTable.start + tblOpenLen;
|
|
23984
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
24021
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _308 => _308.rowRanges, 'access', _309 => _309[0], 'optionalAccess', _310 => _310.start]), () => ( from));
|
|
23985
24022
|
const slice = xml.slice(from, to);
|
|
23986
24023
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
23987
24024
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -24170,9 +24207,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
|
|
|
24170
24207
|
});
|
|
24171
24208
|
}
|
|
24172
24209
|
function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
24173
|
-
const irCell = _optionalChain([table, 'access',
|
|
24210
|
+
const irCell = _optionalChain([table, 'access', _311 => _311.cells, 'access', _312 => _312[oc.gridR], 'optionalAccess', _313 => _313[oc.gridC]]);
|
|
24174
24211
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
24175
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
24212
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _314 => _314.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
24176
24213
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
24177
24214
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
24178
24215
|
}
|
|
@@ -24240,7 +24277,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
24240
24277
|
};
|
|
24241
24278
|
const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
24242
24279
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
24243
|
-
const irCell = _optionalChain([table, 'access',
|
|
24280
|
+
const irCell = _optionalChain([table, 'access', _315 => _315.cells, 'access', _316 => _316[gridR], 'optionalAccess', _317 => _317[gridC]]);
|
|
24244
24281
|
const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
24245
24282
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
24246
24283
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -24263,7 +24300,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
24263
24300
|
if (newLines.length === 0) return 0;
|
|
24264
24301
|
const target = cell.paragraphs[0];
|
|
24265
24302
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
24266
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
24303
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _318 => _318.scans, 'access', _319 => _319[target.sectionIndex], 'optionalAccess', _320 => _320.xml]));
|
|
24267
24304
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24268
24305
|
splices.push(...sp);
|
|
24269
24306
|
sectionIndex = target.sectionIndex;
|
|
@@ -24286,7 +24323,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
24286
24323
|
}
|
|
24287
24324
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
24288
24325
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
24289
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
24326
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _321 => _321.scans, 'access', _322 => _322[nonEmpty[i].sectionIndex], 'optionalAccess', _323 => _323.xml]));
|
|
24290
24327
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24291
24328
|
splices.push(...sp);
|
|
24292
24329
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -24367,7 +24404,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
24367
24404
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
24368
24405
|
if (paths.length > 0) return paths;
|
|
24369
24406
|
}
|
|
24370
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
24407
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
24371
24408
|
}
|
|
24372
24409
|
function sectionPathsFromManifest(xml) {
|
|
24373
24410
|
const attr = (tag, name) => {
|
|
@@ -24377,7 +24414,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
24377
24414
|
const idToHref = /* @__PURE__ */ new Map();
|
|
24378
24415
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
24379
24416
|
const id = attr(m[1], "id");
|
|
24380
|
-
const href =
|
|
24417
|
+
const href = _chunkR2H34FY5cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
24381
24418
|
if (id && href) idToHref.set(id, href);
|
|
24382
24419
|
}
|
|
24383
24420
|
const ordered = [];
|
|
@@ -24386,7 +24423,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
24386
24423
|
if (href) ordered.push(href);
|
|
24387
24424
|
}
|
|
24388
24425
|
if (ordered.length > 0) return ordered;
|
|
24389
|
-
return Array.from(idToHref.values()).sort(
|
|
24426
|
+
return Array.from(idToHref.values()).sort(_chunkR2H34FY5cjs.compareSectionPaths);
|
|
24390
24427
|
}
|
|
24391
24428
|
|
|
24392
24429
|
// src/roundtrip/patcher.ts
|
|
@@ -24478,7 +24515,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
24478
24515
|
}
|
|
24479
24516
|
}
|
|
24480
24517
|
let verification;
|
|
24481
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
24518
|
+
if (_optionalChain([options, 'optionalAccess', _324 => _324.verify]) !== false) {
|
|
24482
24519
|
try {
|
|
24483
24520
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
24484
24521
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -24496,17 +24533,17 @@ function buildOrigUnits(blocks) {
|
|
|
24496
24533
|
let chunk2;
|
|
24497
24534
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
24498
24535
|
const next = blocks[i + 1];
|
|
24499
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
24500
|
-
chunk2 =
|
|
24536
|
+
if (_optionalChain([next, 'optionalAccess', _325 => _325.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
24537
|
+
chunk2 = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
24501
24538
|
} else {
|
|
24502
|
-
chunk2 =
|
|
24539
|
+
chunk2 = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, [block]);
|
|
24503
24540
|
}
|
|
24504
24541
|
if (chunk2) {
|
|
24505
24542
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
24506
24543
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
24507
24544
|
for (let s = 0; s < subUnits.length; s++) {
|
|
24508
24545
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
24509
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
24546
|
+
if (block.type === "table" && _optionalChain([block, 'access', _326 => _326.table, 'optionalAccess', _327 => _327.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
24510
24547
|
u.role = "caption";
|
|
24511
24548
|
}
|
|
24512
24549
|
units.push(u);
|
|
@@ -24617,7 +24654,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24617
24654
|
const ti = ctx.tableInsert;
|
|
24618
24655
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
24619
24656
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24620
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24657
|
+
if (!_optionalChain([mapping, 'optionalAccess', _328 => _328.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
|
|
24621
24658
|
const para = mapping.para;
|
|
24622
24659
|
if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
|
|
24623
24660
|
const scan = ctx.scans[para.sectionIndex];
|
|
@@ -24645,7 +24682,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
24645
24682
|
}
|
|
24646
24683
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
24647
24684
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
24648
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
24685
|
+
if (!_optionalChain([mapping, 'optionalAccess', _329 => _329.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
24649
24686
|
if (block.text && block.text.includes("\n")) {
|
|
24650
24687
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
24651
24688
|
}
|
|
@@ -24676,7 +24713,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
24676
24713
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
24677
24714
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
24678
24715
|
}
|
|
24679
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
24716
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _330 => _330.scans, 'access', _331 => _331[mapping.para.sectionIndex], 'optionalAccess', _332 => _332.xml]));
|
|
24680
24717
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
24681
24718
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
24682
24719
|
return 1;
|
|
@@ -24862,7 +24899,7 @@ var Surgeon = (_class4 = class {
|
|
|
24862
24899
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
24863
24900
|
findEntry(path) {
|
|
24864
24901
|
const parts = path.replace(/^\//, "").split("/");
|
|
24865
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
24902
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _333 => _333.entries, 'access', _334 => _334[0], 'optionalAccess', _335 => _335.child]), () => ( -1));
|
|
24866
24903
|
let current;
|
|
24867
24904
|
for (const part of parts) {
|
|
24868
24905
|
const search = (idx) => {
|
|
@@ -25075,8 +25112,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
25075
25112
|
parts.push(header, data);
|
|
25076
25113
|
};
|
|
25077
25114
|
for (let i = 0; i < recs.length; i++) {
|
|
25078
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
25079
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
25115
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _336 => _336.get, 'call', _337 => _337(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
25116
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _338 => _338.get, 'call', _339 => _339(i)]), () => ( recs[i].data)));
|
|
25080
25117
|
}
|
|
25081
25118
|
return Buffer.concat(parts);
|
|
25082
25119
|
}
|
|
@@ -25194,7 +25231,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
25194
25231
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
25195
25232
|
}
|
|
25196
25233
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
25197
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
25234
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _340 => _340.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
25198
25235
|
let flags;
|
|
25199
25236
|
try {
|
|
25200
25237
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -25216,7 +25253,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
25216
25253
|
const scans = [];
|
|
25217
25254
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
25218
25255
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
25219
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
25256
|
+
if (!_optionalChain([entry, 'optionalAccess', _341 => _341.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
25220
25257
|
let stream;
|
|
25221
25258
|
try {
|
|
25222
25259
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -25267,7 +25304,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
25267
25304
|
}
|
|
25268
25305
|
}
|
|
25269
25306
|
let verification;
|
|
25270
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25307
|
+
if (_optionalChain([options, 'optionalAccess', _342 => _342.verify]) !== false) {
|
|
25271
25308
|
try {
|
|
25272
25309
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
25273
25310
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -25357,7 +25394,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
25357
25394
|
for (const [key, scanCell] of scanTable.cells) {
|
|
25358
25395
|
const comma = key.indexOf(",");
|
|
25359
25396
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
25360
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
25397
|
+
const irCell = _optionalChain([irTable, 'access', _343 => _343.cells, 'access', _344 => _344[r], 'optionalAccess', _345 => _345[c]]);
|
|
25361
25398
|
if (!irCell) continue;
|
|
25362
25399
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
25363
25400
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -25393,7 +25430,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
25393
25430
|
}
|
|
25394
25431
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
25395
25432
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25396
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25433
|
+
if (!_optionalChain([mapping, 'optionalAccess', _346 => _346.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
25397
25434
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
25398
25435
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
25399
25436
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -25592,7 +25629,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25592
25629
|
};
|
|
25593
25630
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
25594
25631
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
25595
|
-
const irCell = _optionalChain([table, 'access',
|
|
25632
|
+
const irCell = _optionalChain([table, 'access', _347 => _347.cells, 'access', _348 => _348[gridR], 'optionalAccess', _349 => _349[gridC]]);
|
|
25596
25633
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
25597
25634
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25598
25635
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25984,7 +26021,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
25984
26021
|
const block = st.blocks[blockIndex];
|
|
25985
26022
|
if (!block) return void 0;
|
|
25986
26023
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
25987
|
-
const para = _optionalChain([st, 'access',
|
|
26024
|
+
const para = _optionalChain([st, 'access', _350 => _350.paraMap, 'access', _351 => _351.get, 'call', _352 => _352(blockIndex), 'optionalAccess', _353 => _353.para]);
|
|
25988
26025
|
if (!para) return void 0;
|
|
25989
26026
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
25990
26027
|
}
|
|
@@ -26009,7 +26046,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26009
26046
|
if (block.text && block.text.includes("\n")) {
|
|
26010
26047
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
|
|
26011
26048
|
}
|
|
26012
|
-
if (!_optionalChain([st, 'access',
|
|
26049
|
+
if (!_optionalChain([st, 'access', _354 => _354.paraMap, 'access', _355 => _355.get, 'call', _356 => _356(blockIndex), 'optionalAccess', _357 => _357.para])) {
|
|
26013
26050
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
|
|
26014
26051
|
}
|
|
26015
26052
|
return { capability: "text" };
|
|
@@ -26075,7 +26112,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26075
26112
|
continue;
|
|
26076
26113
|
}
|
|
26077
26114
|
if (block.type === "table" && block.table) {
|
|
26078
|
-
if (!_optionalChain([edit, 'access',
|
|
26115
|
+
if (!_optionalChain([edit, 'access', _358 => _358.cells, 'optionalAccess', _359 => _359.length])) {
|
|
26079
26116
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
26080
26117
|
continue;
|
|
26081
26118
|
}
|
|
@@ -26095,7 +26132,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26095
26132
|
skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
|
|
26096
26133
|
continue;
|
|
26097
26134
|
}
|
|
26098
|
-
const irCell = _optionalChain([block, 'access',
|
|
26135
|
+
const irCell = _optionalChain([block, 'access', _360 => _360.table, 'access', _361 => _361.cells, 'access', _362 => _362[cellEdit.row], 'optionalAccess', _363 => _363[cellEdit.col]]);
|
|
26099
26136
|
if (!irCell) {
|
|
26100
26137
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
26101
26138
|
continue;
|
|
@@ -26151,7 +26188,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26151
26188
|
}
|
|
26152
26189
|
if (replacements.size === 0) {
|
|
26153
26190
|
let changes2;
|
|
26154
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26191
|
+
if (_optionalChain([options, 'optionalAccess', _364 => _364.verify]) !== false) {
|
|
26155
26192
|
const units = splitMarkdownUnits(st.markdown);
|
|
26156
26193
|
changes2 = diffUnitLists(units, units);
|
|
26157
26194
|
}
|
|
@@ -26172,7 +26209,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26172
26209
|
}
|
|
26173
26210
|
this.state = newState;
|
|
26174
26211
|
let changes;
|
|
26175
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26212
|
+
if (_optionalChain([options, 'optionalAccess', _365 => _365.verify]) !== false) {
|
|
26176
26213
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
26177
26214
|
}
|
|
26178
26215
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -26192,7 +26229,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26192
26229
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
26193
26230
|
}
|
|
26194
26231
|
const mapping = st.paraMap.get(blockIndex);
|
|
26195
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26232
|
+
if (!_optionalChain([mapping, 'optionalAccess', _366 => _366.para])) {
|
|
26196
26233
|
return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
26197
26234
|
}
|
|
26198
26235
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -26212,14 +26249,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
|
|
|
26212
26249
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
26213
26250
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
26214
26251
|
}
|
|
26215
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
26252
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _367 => _367.scans, 'access', _368 => _368[mapping.para.sectionIndex], 'optionalAccess', _369 => _369.xml]));
|
|
26216
26253
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
26217
26254
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
26218
26255
|
return 1;
|
|
26219
26256
|
}
|
|
26220
26257
|
}, _class5);
|
|
26221
26258
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
26222
|
-
const irCell = _optionalChain([table, 'access',
|
|
26259
|
+
const irCell = _optionalChain([table, 'access', _370 => _370.cells, 'access', _371 => _371[r], 'optionalAccess', _372 => _372[c]]);
|
|
26223
26260
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
26224
26261
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
26225
26262
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -26303,11 +26340,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
26303
26340
|
breaks: false
|
|
26304
26341
|
});
|
|
26305
26342
|
function renderHtml(markdown, options) {
|
|
26306
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26307
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26343
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _373 => _373.preset]), () => ( "default"));
|
|
26344
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _374 => _374.extraCss]), () => ( "")));
|
|
26308
26345
|
const body = md.render(markdown);
|
|
26309
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
26310
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
26346
|
+
const watermark = _optionalChain([options, 'optionalAccess', _375 => _375.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
26347
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _376 => _376.watermark]) ? `
|
|
26311
26348
|
.watermark {
|
|
26312
26349
|
position: fixed;
|
|
26313
26350
|
top: 50%; left: 50%;
|
|
@@ -26338,13 +26375,13 @@ async function htmlToPdf(html, options) {
|
|
|
26338
26375
|
try {
|
|
26339
26376
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
26340
26377
|
} catch (e30) {
|
|
26341
|
-
throw new (0,
|
|
26378
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
26342
26379
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
26343
26380
|
);
|
|
26344
26381
|
}
|
|
26345
26382
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
26346
26383
|
if (!executablePath) {
|
|
26347
|
-
throw new (0,
|
|
26384
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)(
|
|
26348
26385
|
"Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
|
|
26349
26386
|
);
|
|
26350
26387
|
}
|
|
@@ -26356,10 +26393,10 @@ async function htmlToPdf(html, options) {
|
|
|
26356
26393
|
try {
|
|
26357
26394
|
const page = await browser.newPage();
|
|
26358
26395
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
26359
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
26396
|
+
const margin = _optionalChain([options, 'optionalAccess', _377 => _377.margin]);
|
|
26360
26397
|
const pdf = await page.pdf({
|
|
26361
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26362
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
26398
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _378 => _378.pageSize]), () => ( "A4")),
|
|
26399
|
+
landscape: _optionalChain([options, 'optionalAccess', _379 => _379.orientation]) === "landscape",
|
|
26363
26400
|
printBackground: true,
|
|
26364
26401
|
margin: margin ? {
|
|
26365
26402
|
top: toCss(margin.top),
|
|
@@ -26367,9 +26404,9 @@ async function htmlToPdf(html, options) {
|
|
|
26367
26404
|
bottom: toCss(margin.bottom),
|
|
26368
26405
|
left: toCss(margin.left)
|
|
26369
26406
|
} : void 0,
|
|
26370
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
26371
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26372
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
26407
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _380 => _380.header]) || _optionalChain([options, 'optionalAccess', _381 => _381.footer])),
|
|
26408
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _382 => _382.header]), () => ( "<div></div>")),
|
|
26409
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _383 => _383.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
26373
26410
|
});
|
|
26374
26411
|
return Buffer.from(pdf);
|
|
26375
26412
|
} finally {
|
|
@@ -26403,7 +26440,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
26403
26440
|
return htmlToPdf(html, options);
|
|
26404
26441
|
}
|
|
26405
26442
|
async function blocksToPdf(blocks, options) {
|
|
26406
|
-
const markdown =
|
|
26443
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, blocks);
|
|
26407
26444
|
return markdownToPdf(markdown, options);
|
|
26408
26445
|
}
|
|
26409
26446
|
|
|
@@ -26613,7 +26650,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
26613
26650
|
if (ln(p) !== "p") continue;
|
|
26614
26651
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
26615
26652
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
26616
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
26653
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _384 => _384.spaceBefore]), () => ( 0)));
|
|
26617
26654
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
26618
26655
|
if (res) {
|
|
26619
26656
|
const paraH = res.paraBottom - startV;
|
|
@@ -26722,7 +26759,7 @@ function buildPara(p) {
|
|
|
26722
26759
|
el: ch,
|
|
26723
26760
|
tag: cn,
|
|
26724
26761
|
index: chars.length,
|
|
26725
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
26762
|
+
inline: _optionalChain([pos, 'optionalAccess', _385 => _385.getAttribute, 'call', _386 => _386("treatAsChar")]) === "1",
|
|
26726
26763
|
width: w,
|
|
26727
26764
|
height: h
|
|
26728
26765
|
});
|
|
@@ -26974,15 +27011,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
26974
27011
|
const sx = ow > 0 ? w / ow : 1;
|
|
26975
27012
|
const sy = oh > 0 ? h / oh : 1;
|
|
26976
27013
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
26977
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
26978
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
27014
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _387 => _387.getAttribute, 'call', _388 => _388("style")]), () => ( "SOLID"));
|
|
27015
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _389 => _389.getAttribute, 'call', _390 => _390("color")]) || "#000000";
|
|
26979
27016
|
const hasStroke = lstyle !== "NONE";
|
|
26980
27017
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
26981
27018
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
26982
27019
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
26983
27020
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
26984
27021
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
26985
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
27022
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _391 => _391.getAttribute, 'call', _392 => _392("faceColor")]);
|
|
26986
27023
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
26987
27024
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
26988
27025
|
if (o.tag === "rect") {
|
|
@@ -27014,7 +27051,7 @@ function cellContentExtent(cell) {
|
|
|
27014
27051
|
if (ln2(p) !== "p") continue;
|
|
27015
27052
|
const m = buildPara(p);
|
|
27016
27053
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
27017
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
27054
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _393 => _393.segs, 'access', _394 => _394[0], 'optionalAccess', _395 => _395.vertpos]), () => ( 0));
|
|
27018
27055
|
for (const o of m.objs) {
|
|
27019
27056
|
if (o.inline) {
|
|
27020
27057
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -27022,7 +27059,7 @@ function cellContentExtent(cell) {
|
|
|
27022
27059
|
continue;
|
|
27023
27060
|
}
|
|
27024
27061
|
const pos = findChildByLocalName(o.el, "pos");
|
|
27025
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
27062
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _396 => _396.getAttribute, 'call', _397 => _397("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
27026
27063
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
27027
27064
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
27028
27065
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
@@ -27108,7 +27145,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
27108
27145
|
}));
|
|
27109
27146
|
for (const g of geom) {
|
|
27110
27147
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
27111
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
27148
|
+
if (_optionalChain([bf, 'optionalAccess', _398 => _398.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
27112
27149
|
}
|
|
27113
27150
|
for (const g of geom) {
|
|
27114
27151
|
const { c } = g;
|
|
@@ -27146,7 +27183,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
27146
27183
|
const sz = findChildByLocalName(pic, "sz");
|
|
27147
27184
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
27148
27185
|
const img = findFirst(pic, "img");
|
|
27149
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
27186
|
+
const ref = _optionalChain([img, 'optionalAccess', _399 => _399.getAttribute, 'call', _400 => _400("binaryItemIDRef")]);
|
|
27150
27187
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
27151
27188
|
if (!loaded) {
|
|
27152
27189
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -27185,7 +27222,7 @@ function readSectionGeom(root) {
|
|
|
27185
27222
|
const pagePr = findFirst(root, "pagePr");
|
|
27186
27223
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
27187
27224
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
27188
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
27225
|
+
if (_optionalChain([pagePr, 'optionalAccess', _401 => _401.getAttribute, 'call', _402 => _402("landscape")]) === "NARROWLY" && PW < PH) {
|
|
27189
27226
|
const t = PW;
|
|
27190
27227
|
PW = PH;
|
|
27191
27228
|
PH = t;
|
|
@@ -27243,17 +27280,17 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
27243
27280
|
return { pages: ctx.pages, pageH };
|
|
27244
27281
|
}
|
|
27245
27282
|
async function renderHwpxToSvg(input, options) {
|
|
27246
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27283
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _403 => _403.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
27247
27284
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
27248
|
-
|
|
27285
|
+
_chunkR2H34FY5cjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
27249
27286
|
let zip;
|
|
27250
27287
|
try {
|
|
27251
27288
|
zip = await _jszip2.default.loadAsync(input);
|
|
27252
27289
|
} catch (e31) {
|
|
27253
|
-
throw new (0,
|
|
27290
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
27254
27291
|
}
|
|
27255
27292
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
27256
|
-
if (secFiles.length === 0) throw new (0,
|
|
27293
|
+
if (secFiles.length === 0) throw new (0, _chunkR2H34FY5cjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
27257
27294
|
const warnings = [];
|
|
27258
27295
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
27259
27296
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -27261,7 +27298,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
27261
27298
|
const secXmls = [];
|
|
27262
27299
|
for (const f of secFiles) {
|
|
27263
27300
|
const xml = await f.async("string");
|
|
27264
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
27301
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
27265
27302
|
secXmls.push(xml);
|
|
27266
27303
|
}
|
|
27267
27304
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -27285,7 +27322,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
27285
27322
|
let href = binmap.get(ref);
|
|
27286
27323
|
if (!href) {
|
|
27287
27324
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
27288
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
27325
|
+
href = _optionalChain([cand, 'optionalAccess', _404 => _404.name]);
|
|
27289
27326
|
}
|
|
27290
27327
|
if (!href) continue;
|
|
27291
27328
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -27306,7 +27343,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
27306
27343
|
styles,
|
|
27307
27344
|
images,
|
|
27308
27345
|
defs: [],
|
|
27309
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27346
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _405 => _405.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
27310
27347
|
warnings,
|
|
27311
27348
|
warned: /* @__PURE__ */ new Set(),
|
|
27312
27349
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -27316,7 +27353,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
27316
27353
|
for (let si = 0; si < secXmls.length; si++) {
|
|
27317
27354
|
const secXml = secXmls[si];
|
|
27318
27355
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
27319
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
27356
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _406 => _406.reflow])) {
|
|
27320
27357
|
noCacheSkipped = true;
|
|
27321
27358
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
27322
27359
|
continue;
|
|
@@ -27328,14 +27365,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
27328
27365
|
continue;
|
|
27329
27366
|
}
|
|
27330
27367
|
const geom = readSectionGeom(root);
|
|
27331
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27368
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _407 => _407.reflowMode]), () => ( "keep")));
|
|
27332
27369
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
27333
27370
|
}
|
|
27334
27371
|
if (rendered.length === 0) {
|
|
27335
27372
|
if (noCacheSkipped) {
|
|
27336
|
-
throw new (0,
|
|
27373
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
|
|
27337
27374
|
}
|
|
27338
|
-
throw new (0,
|
|
27375
|
+
throw new (0, _chunkR2H34FY5cjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
27339
27376
|
}
|
|
27340
27377
|
const GAP = 2400;
|
|
27341
27378
|
const clipDefs = [];
|
|
@@ -27367,17 +27404,17 @@ ${groups.join("\n")}
|
|
|
27367
27404
|
// src/index.ts
|
|
27368
27405
|
async function parse(input, options) {
|
|
27369
27406
|
let buffer;
|
|
27370
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
27407
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _408 => _408.filePath]) ? { ...options, filePath: input } : options;
|
|
27371
27408
|
if (typeof input === "string") {
|
|
27372
27409
|
try {
|
|
27373
27410
|
const buf = await _promises.readFile.call(void 0, input);
|
|
27374
|
-
buffer =
|
|
27411
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, buf);
|
|
27375
27412
|
} catch (err) {
|
|
27376
27413
|
const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
|
|
27377
27414
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
27378
27415
|
}
|
|
27379
27416
|
} else if (Buffer.isBuffer(input)) {
|
|
27380
|
-
buffer =
|
|
27417
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, input);
|
|
27381
27418
|
} else {
|
|
27382
27419
|
buffer = input;
|
|
27383
27420
|
}
|
|
@@ -27412,21 +27449,21 @@ async function parseHwp3(buffer, options) {
|
|
|
27412
27449
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
27413
27450
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
27414
27451
|
} catch (err) {
|
|
27415
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27452
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27416
27453
|
}
|
|
27417
27454
|
}
|
|
27418
27455
|
async function parseHwpx(buffer, options) {
|
|
27419
27456
|
try {
|
|
27420
27457
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
27421
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27458
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _409 => _409.length]) ? images : void 0 };
|
|
27422
27459
|
} catch (err) {
|
|
27423
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27460
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27424
27461
|
}
|
|
27425
27462
|
}
|
|
27426
27463
|
async function parseHwp(buffer, options) {
|
|
27427
27464
|
try {
|
|
27428
27465
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
27429
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
27466
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _410 => _410.filePath])) {
|
|
27430
27467
|
try {
|
|
27431
27468
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
27432
27469
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -27443,15 +27480,15 @@ async function parseHwp(buffer, options) {
|
|
|
27443
27480
|
} catch (e32) {
|
|
27444
27481
|
}
|
|
27445
27482
|
}
|
|
27446
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27483
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _411 => _411.length]) ? images : void 0 };
|
|
27447
27484
|
} catch (err) {
|
|
27448
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27485
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27449
27486
|
}
|
|
27450
27487
|
}
|
|
27451
27488
|
async function parsePdf(buffer, options) {
|
|
27452
27489
|
let parsePdfDocument;
|
|
27453
27490
|
try {
|
|
27454
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
27491
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-XEY5MRGV.cjs")));
|
|
27455
27492
|
parsePdfDocument = mod.parsePdfDocument;
|
|
27456
27493
|
} catch (e33) {
|
|
27457
27494
|
return {
|
|
@@ -27466,7 +27503,7 @@ async function parsePdf(buffer, options) {
|
|
|
27466
27503
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
27467
27504
|
} catch (err) {
|
|
27468
27505
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
27469
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27506
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err), isImageBased };
|
|
27470
27507
|
}
|
|
27471
27508
|
}
|
|
27472
27509
|
async function parseXlsx(buffer, options) {
|
|
@@ -27474,7 +27511,7 @@ async function parseXlsx(buffer, options) {
|
|
|
27474
27511
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
27475
27512
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
27476
27513
|
} catch (err) {
|
|
27477
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27514
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27478
27515
|
}
|
|
27479
27516
|
}
|
|
27480
27517
|
async function parseXls(buffer, options) {
|
|
@@ -27482,15 +27519,15 @@ async function parseXls(buffer, options) {
|
|
|
27482
27519
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
27483
27520
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
27484
27521
|
} catch (err) {
|
|
27485
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27522
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27486
27523
|
}
|
|
27487
27524
|
}
|
|
27488
27525
|
async function parseDocx(buffer, options) {
|
|
27489
27526
|
try {
|
|
27490
27527
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
27491
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
27528
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _412 => _412.length]) ? images : void 0 };
|
|
27492
27529
|
} catch (err) {
|
|
27493
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27530
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27494
27531
|
}
|
|
27495
27532
|
}
|
|
27496
27533
|
async function parseHwpml(buffer, options) {
|
|
@@ -27498,16 +27535,16 @@ async function parseHwpml(buffer, options) {
|
|
|
27498
27535
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
27499
27536
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
27500
27537
|
} catch (err) {
|
|
27501
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
27538
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkR2H34FY5cjs.classifyError.call(void 0, err) };
|
|
27502
27539
|
}
|
|
27503
27540
|
}
|
|
27504
27541
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
27505
27542
|
let buffer;
|
|
27506
27543
|
if (typeof input === "string") {
|
|
27507
27544
|
const buf = await _promises.readFile.call(void 0, input);
|
|
27508
|
-
buffer =
|
|
27545
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, buf);
|
|
27509
27546
|
} else if (Buffer.isBuffer(input)) {
|
|
27510
|
-
buffer =
|
|
27547
|
+
buffer = _chunkR2H34FY5cjs.toArrayBuffer.call(void 0, input);
|
|
27511
27548
|
} else {
|
|
27512
27549
|
buffer = input;
|
|
27513
27550
|
}
|
|
@@ -27533,7 +27570,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27533
27570
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
27534
27571
|
}
|
|
27535
27572
|
const fill = fillFormFields(parsed.blocks, values);
|
|
27536
|
-
const markdown =
|
|
27573
|
+
const markdown = _chunkR2H34FY5cjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
27537
27574
|
if (outputFormat === "hwpx") {
|
|
27538
27575
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
27539
27576
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -27597,5 +27634,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
27597
27634
|
|
|
27598
27635
|
|
|
27599
27636
|
|
|
27600
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
27637
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkR2H34FY5cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkR2H34FY5cjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.hwpxToProfile = hwpxToProfile; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.validateHwpx = validateHwpx;
|
|
27601
27638
|
//# sourceMappingURL=index.cjs.map
|