kordoc 4.0.1 → 4.0.2
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/{-O3AWNVPH.js → -XMKVL3NX.js} +7 -7
- package/dist/{chunk-3H3CVOZ3.js → chunk-3IYQYBUF.js} +2 -2
- package/dist/{chunk-JMLK6NTW.js → chunk-67RANGFQ.js} +3 -3
- package/dist/{chunk-C5ABJ7PB.js → chunk-6SD4X5PT.js} +3 -3
- package/dist/{chunk-33OUI7HC.js → chunk-6YIYFWO2.js} +2 -2
- package/dist/{chunk-SHVV3BD6.js → chunk-AHWRAGXN.js} +299 -71
- package/dist/chunk-AHWRAGXN.js.map +1 -0
- package/dist/{chunk-YEC7VG6O.js → chunk-IKBIIEVJ.js} +2 -2
- package/dist/{chunk-EH2KYFFO.js → chunk-STMLZDKR.js} +2 -2
- package/dist/{chunk-NIZXIVEI.cjs → chunk-WN7LZHII.cjs} +2 -2
- package/dist/{chunk-NIZXIVEI.cjs.map → chunk-WN7LZHII.cjs.map} +1 -1
- package/dist/cli.js +36 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +552 -324
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/index.js +294 -66
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +53 -11
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-G433UZMX.js → parser-2Q2YKEJG.js} +2 -2
- package/dist/{parser-ZOMDHCA7.js → parser-3HM2VYKK.js} +3 -3
- package/dist/{parser-44OPXZMP.cjs → parser-6AYYGX6J.cjs} +14 -14
- package/dist/{parser-44OPXZMP.cjs.map → parser-6AYYGX6J.cjs.map} +1 -1
- package/dist/render-W4VCJE6N.js +10 -0
- package/dist/seal-DRPTNHOP.js +10 -0
- package/dist/{watch-UYT3ZCBM.js → watch-6OHF727O.js} +7 -7
- package/package.json +1 -1
- package/dist/chunk-SHVV3BD6.js.map +0 -1
- package/dist/render-SQVQBORJ.js +0 -10
- package/dist/seal-6E26L45Z.js +0 -10
- /package/dist/{-O3AWNVPH.js.map → -XMKVL3NX.js.map} +0 -0
- /package/dist/{chunk-3H3CVOZ3.js.map → chunk-3IYQYBUF.js.map} +0 -0
- /package/dist/{chunk-JMLK6NTW.js.map → chunk-67RANGFQ.js.map} +0 -0
- /package/dist/{chunk-C5ABJ7PB.js.map → chunk-6SD4X5PT.js.map} +0 -0
- /package/dist/{chunk-33OUI7HC.js.map → chunk-6YIYFWO2.js.map} +0 -0
- /package/dist/{chunk-YEC7VG6O.js.map → chunk-IKBIIEVJ.js.map} +0 -0
- /package/dist/{chunk-EH2KYFFO.js.map → chunk-STMLZDKR.js.map} +0 -0
- /package/dist/{parser-G433UZMX.js.map → parser-2Q2YKEJG.js.map} +0 -0
- /package/dist/{parser-ZOMDHCA7.js.map → parser-3HM2VYKK.js.map} +0 -0
- /package/dist/{render-SQVQBORJ.js.map → render-W4VCJE6N.js.map} +0 -0
- /package/dist/{seal-6E26L45Z.js.map → seal-DRPTNHOP.js.map} +0 -0
- /package/dist/{watch-UYT3ZCBM.js.map → watch-6OHF727O.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkWN7LZHIIcjs = require('./chunk-WN7LZHII.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, _chunkWN7LZHIIcjs.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, _chunkWN7LZHIIcjs.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(_chunkWN7LZHIIcjs.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 >= _chunkWN7LZHIIcjs.HEADING_RATIO_H1) level = 1;
|
|
620
|
+
else if (ratio >= _chunkWN7LZHIIcjs.HEADING_RATIO_H2) level = 2;
|
|
621
|
+
else if (ratio >= _chunkWN7LZHIIcjs.HEADING_RATIO_H3) level = 3;
|
|
622
622
|
}
|
|
623
623
|
const compactText = text.replace(/\s+/g, "");
|
|
624
624
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1202,7 +1202,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1202
1202
|
|
|
1203
1203
|
// src/hwpx/table-build.ts
|
|
1204
1204
|
function buildTableWithCellMeta(state) {
|
|
1205
|
-
const table2 =
|
|
1205
|
+
const table2 = _chunkWN7LZHIIcjs.buildTable.call(void 0, state.rows);
|
|
1206
1206
|
if (state.caption) table2.caption = state.caption;
|
|
1207
1207
|
const anchors = [];
|
|
1208
1208
|
{
|
|
@@ -1272,7 +1272,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1272
1272
|
const cell2 = parentTable.cell;
|
|
1273
1273
|
(cell2.blocks ??= []).push(block);
|
|
1274
1274
|
cell2.hasStructure = true;
|
|
1275
|
-
let flat =
|
|
1275
|
+
let flat = _chunkWN7LZHIIcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1276
1276
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1277
1277
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1278
1278
|
} else {
|
|
@@ -1284,7 +1284,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1284
1284
|
// src/hwpx/section-walker.ts
|
|
1285
1285
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1286
1286
|
const parser = createXmlParser(warnings);
|
|
1287
|
-
const doc = parser.parseFromString(
|
|
1287
|
+
const doc = parser.parseFromString(_chunkWN7LZHIIcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1288
1288
|
if (!doc.documentElement) return [];
|
|
1289
1289
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1290
1290
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1375,8 +1375,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1375
1375
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1376
1376
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1377
1377
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1378
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1379
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1378
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkWN7LZHIIcjs.MAX_COLS);
|
|
1379
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkWN7LZHIIcjs.MAX_ROWS);
|
|
1380
1380
|
}
|
|
1381
1381
|
break;
|
|
1382
1382
|
case "p": {
|
|
@@ -1598,7 +1598,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1598
1598
|
let url = (ch.textContent || "").trim();
|
|
1599
1599
|
if (!url) continue;
|
|
1600
1600
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1601
|
-
const safe =
|
|
1601
|
+
const safe = _chunkWN7LZHIIcjs.sanitizeHref.call(void 0, url);
|
|
1602
1602
|
if (safe) return safe;
|
|
1603
1603
|
}
|
|
1604
1604
|
return void 0;
|
|
@@ -1733,7 +1733,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
1733
1733
|
case "hyperlink": {
|
|
1734
1734
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1735
1735
|
if (url) {
|
|
1736
|
-
const safe =
|
|
1736
|
+
const safe = _chunkWN7LZHIIcjs.sanitizeHref.call(void 0, url);
|
|
1737
1737
|
if (safe) href = safe;
|
|
1738
1738
|
}
|
|
1739
1739
|
walk(child);
|
|
@@ -1919,13 +1919,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1919
1919
|
}
|
|
1920
1920
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1921
1921
|
for (const path of allCandidates) {
|
|
1922
|
-
if (
|
|
1922
|
+
if (_chunkWN7LZHIIcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1923
1923
|
const file = zip.file(path);
|
|
1924
1924
|
if (!file) continue;
|
|
1925
1925
|
try {
|
|
1926
1926
|
const data = await file.async("uint8array");
|
|
1927
1927
|
decompressed.total += data.length;
|
|
1928
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1928
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1929
1929
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
1930
1930
|
const mimeType = imageExtToMime(ext);
|
|
1931
1931
|
imageIndex++;
|
|
@@ -1934,7 +1934,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1934
1934
|
images.push(img);
|
|
1935
1935
|
break;
|
|
1936
1936
|
} catch (err) {
|
|
1937
|
-
if (err instanceof
|
|
1937
|
+
if (err instanceof _chunkWN7LZHIIcjs.KordocError) throw err;
|
|
1938
1938
|
}
|
|
1939
1939
|
}
|
|
1940
1940
|
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" })]);
|
|
@@ -1996,7 +1996,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1996
1996
|
}
|
|
1997
1997
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1998
1998
|
const name = new TextDecoder().decode(nameBytes);
|
|
1999
|
-
if (
|
|
1999
|
+
if (_chunkWN7LZHIIcjs.isPathTraversal.call(void 0, name)) {
|
|
2000
2000
|
pos = fileStart + compSize;
|
|
2001
2001
|
continue;
|
|
2002
2002
|
}
|
|
@@ -2014,16 +2014,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
2014
2014
|
continue;
|
|
2015
2015
|
}
|
|
2016
2016
|
totalDecompressed += content.length * 2;
|
|
2017
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2017
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
2018
2018
|
sectionNum++;
|
|
2019
2019
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
2020
2020
|
} catch (e13) {
|
|
2021
2021
|
continue;
|
|
2022
2022
|
}
|
|
2023
2023
|
}
|
|
2024
|
-
if (blocks.length === 0) throw new (0,
|
|
2024
|
+
if (blocks.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2025
2025
|
applyPageText(blocks, shared);
|
|
2026
|
-
const markdown =
|
|
2026
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2027
2027
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
2028
2028
|
}
|
|
2029
2029
|
async function resolveSectionPaths(zip) {
|
|
@@ -2037,18 +2037,18 @@ async function resolveSectionPaths(zip) {
|
|
|
2037
2037
|
if (paths.length > 0) return paths;
|
|
2038
2038
|
}
|
|
2039
2039
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
2040
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
2040
|
+
return sectionFiles.map((f) => f.name).sort(_chunkWN7LZHIIcjs.compareSectionPaths);
|
|
2041
2041
|
}
|
|
2042
2042
|
function parseSectionPathsFromManifest(xml) {
|
|
2043
2043
|
const parser = createXmlParser();
|
|
2044
|
-
const doc = parser.parseFromString(
|
|
2044
|
+
const doc = parser.parseFromString(_chunkWN7LZHIIcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2045
2045
|
const items = doc.getElementsByTagName("opf:item");
|
|
2046
2046
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
2047
2047
|
const idToHref = /* @__PURE__ */ new Map();
|
|
2048
2048
|
for (let i = 0; i < items.length; i++) {
|
|
2049
2049
|
const item = items[i];
|
|
2050
2050
|
const id = item.getAttribute("id") || "";
|
|
2051
|
-
const href =
|
|
2051
|
+
const href = _chunkWN7LZHIIcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
2052
2052
|
if (id && href) idToHref.set(id, href);
|
|
2053
2053
|
}
|
|
2054
2054
|
if (spine.length > 0) {
|
|
@@ -2059,7 +2059,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
if (ordered.length > 0) return ordered;
|
|
2061
2061
|
}
|
|
2062
|
-
return Array.from(idToHref.values()).sort(
|
|
2062
|
+
return Array.from(idToHref.values()).sort(_chunkWN7LZHIIcjs.compareSectionPaths);
|
|
2063
2063
|
}
|
|
2064
2064
|
|
|
2065
2065
|
// src/hwpx/metadata.ts
|
|
@@ -2072,7 +2072,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2072
2072
|
const xml = await file.async("text");
|
|
2073
2073
|
if (decompressed) {
|
|
2074
2074
|
decompressed.total += xml.length * 2;
|
|
2075
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2075
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2076
2076
|
}
|
|
2077
2077
|
parseDublinCoreMetadata(xml, metadata);
|
|
2078
2078
|
if (metadata.title || metadata.author) return;
|
|
@@ -2082,7 +2082,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
2082
2082
|
}
|
|
2083
2083
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
2084
2084
|
const parser = createXmlParser();
|
|
2085
|
-
const doc = parser.parseFromString(
|
|
2085
|
+
const doc = parser.parseFromString(_chunkWN7LZHIIcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2086
2086
|
if (!doc.documentElement) return;
|
|
2087
2087
|
const getText = (tagNames) => {
|
|
2088
2088
|
for (const tag of tagNames) {
|
|
@@ -2107,7 +2107,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
2107
2107
|
|
|
2108
2108
|
// src/hwpx/parser.ts
|
|
2109
2109
|
async function parseHwpxDocument(buffer, options) {
|
|
2110
|
-
|
|
2110
|
+
_chunkWN7LZHIIcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
2111
2111
|
let zip;
|
|
2112
2112
|
try {
|
|
2113
2113
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -2116,7 +2116,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2116
2116
|
}
|
|
2117
2117
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
2118
2118
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
2119
|
-
throw new (0,
|
|
2119
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2120
2120
|
}
|
|
2121
2121
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
2122
2122
|
if (manifestFile) {
|
|
@@ -2128,7 +2128,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2128
2128
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
throw new (0,
|
|
2131
|
+
throw new (0, _chunkWN7LZHIIcjs.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.");
|
|
2132
2132
|
}
|
|
2133
2133
|
}
|
|
2134
2134
|
const decompressed = { total: 0 };
|
|
@@ -2137,7 +2137,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2137
2137
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
2138
2138
|
const warnings = [];
|
|
2139
2139
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
2140
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
2140
|
+
if (sectionPaths.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
2141
2141
|
metadata.pageCount = sectionPaths.length;
|
|
2142
2142
|
const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
2143
2143
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -2151,12 +2151,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2151
2151
|
try {
|
|
2152
2152
|
const xml = await file.async("text");
|
|
2153
2153
|
decompressed.total += xml.length * 2;
|
|
2154
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2154
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2155
2155
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
2156
2156
|
parsedSections++;
|
|
2157
2157
|
_optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
|
|
2158
2158
|
} catch (secErr) {
|
|
2159
|
-
if (secErr instanceof
|
|
2159
|
+
if (secErr instanceof _chunkWN7LZHIIcjs.KordocError) throw secErr;
|
|
2160
2160
|
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" });
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
@@ -2164,7 +2164,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
2164
2164
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
2165
2165
|
detectHwpxHeadings(blocks, styleMap);
|
|
2166
2166
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
2167
|
-
const markdown =
|
|
2167
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
2168
2168
|
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 };
|
|
2169
2169
|
}
|
|
2170
2170
|
|
|
@@ -2231,7 +2231,7 @@ function decompressStream(data) {
|
|
|
2231
2231
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2232
2232
|
}
|
|
2233
2233
|
function parseFileHeader(data) {
|
|
2234
|
-
if (data.length < 40) throw new (0,
|
|
2234
|
+
if (data.length < 40) throw new (0, _chunkWN7LZHIIcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2235
2235
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2236
2236
|
return {
|
|
2237
2237
|
signature: sig,
|
|
@@ -3901,7 +3901,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3901
3901
|
lenientCfb = parseLenientCfb(buffer);
|
|
3902
3902
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3903
3903
|
} catch (e21) {
|
|
3904
|
-
throw new (0,
|
|
3904
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3905
3905
|
}
|
|
3906
3906
|
}
|
|
3907
3907
|
const findStream = (path) => {
|
|
@@ -3912,11 +3912,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3912
3912
|
return lenientCfb.findStream(path);
|
|
3913
3913
|
};
|
|
3914
3914
|
const headerData = findStream("/FileHeader");
|
|
3915
|
-
if (!headerData) throw new (0,
|
|
3915
|
+
if (!headerData) throw new (0, _chunkWN7LZHIIcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3916
3916
|
const header = parseFileHeader(headerData);
|
|
3917
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3918
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3919
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3917
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkWN7LZHIIcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3918
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3919
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkWN7LZHIIcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3920
3920
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3921
3921
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3922
3922
|
const metadata = {
|
|
@@ -3925,7 +3925,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3925
3925
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3926
3926
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3927
3927
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3928
|
-
if (sections.length === 0) throw new (0,
|
|
3928
|
+
if (sections.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3929
3929
|
metadata.pageCount = sections.length;
|
|
3930
3930
|
const pageFilter = _optionalChain([options, 'optionalAccess', _52 => _52.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3931
3931
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -3939,22 +3939,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
3939
3939
|
const sectionData = sections[si];
|
|
3940
3940
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3941
3941
|
totalDecompressed += data.length;
|
|
3942
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3942
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3943
3943
|
const records = readRecords(data);
|
|
3944
3944
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3945
3945
|
bodyBlocks.push(...sectionBlocks);
|
|
3946
3946
|
parsedSections++;
|
|
3947
3947
|
_optionalChain([options, 'optionalAccess', _53 => _53.onProgress, 'optionalCall', _54 => _54(parsedSections, totalTarget)]);
|
|
3948
3948
|
} catch (secErr) {
|
|
3949
|
-
if (secErr instanceof
|
|
3949
|
+
if (secErr instanceof _chunkWN7LZHIIcjs.KordocError) throw secErr;
|
|
3950
3950
|
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" });
|
|
3951
3951
|
}
|
|
3952
3952
|
}
|
|
3953
3953
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3954
3954
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3955
|
-
let flatBlocks =
|
|
3955
|
+
let flatBlocks = _chunkWN7LZHIIcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3956
3956
|
if (_optionalChain([options, 'optionalAccess', _55 => _55.dedupeRunningHeaders])) {
|
|
3957
|
-
const deduped =
|
|
3957
|
+
const deduped = _chunkWN7LZHIIcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
3958
3958
|
const removed = flatBlocks.length - deduped.length;
|
|
3959
3959
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
3960
3960
|
flatBlocks = deduped;
|
|
@@ -3963,7 +3963,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
3963
3963
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3964
3964
|
}
|
|
3965
3965
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3966
|
-
let markdown =
|
|
3966
|
+
let markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3967
3967
|
if (_optionalChain([options, 'optionalAccess', _56 => _56.inlineImages]) && images.length > 0) {
|
|
3968
3968
|
try {
|
|
3969
3969
|
markdown = inlineImagesIntoMarkdown(markdown, images, { compress: true });
|
|
@@ -4030,9 +4030,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4030
4030
|
let level = 0;
|
|
4031
4031
|
if (_optionalChain([block, 'access', _61 => _61.style, 'optionalAccess', _62 => _62.fontSize]) && baseFontSize > 0) {
|
|
4032
4032
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4033
|
-
if (ratio >=
|
|
4034
|
-
else if (ratio >=
|
|
4035
|
-
else if (ratio >=
|
|
4033
|
+
if (ratio >= _chunkWN7LZHIIcjs.HEADING_RATIO_H1) level = 1;
|
|
4034
|
+
else if (ratio >= _chunkWN7LZHIIcjs.HEADING_RATIO_H2) level = 2;
|
|
4035
|
+
else if (ratio >= _chunkWN7LZHIIcjs.HEADING_RATIO_H3) level = 3;
|
|
4036
4036
|
}
|
|
4037
4037
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4038
4038
|
if (level === 0) level = 2;
|
|
@@ -4117,7 +4117,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4117
4117
|
if (!raw) break;
|
|
4118
4118
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4119
4119
|
totalDecompressed += content.length;
|
|
4120
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4120
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4121
4121
|
sections.push({ idx: i, content });
|
|
4122
4122
|
}
|
|
4123
4123
|
if (sections.length === 0) {
|
|
@@ -4129,7 +4129,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4129
4129
|
if (raw) {
|
|
4130
4130
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4131
4131
|
totalDecompressed += content.length;
|
|
4132
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4132
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4133
4133
|
sections.push({ idx, content });
|
|
4134
4134
|
}
|
|
4135
4135
|
}
|
|
@@ -4146,7 +4146,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4146
4146
|
try {
|
|
4147
4147
|
const content = decryptViewText(raw, compressed);
|
|
4148
4148
|
totalDecompressed += content.length;
|
|
4149
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4149
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4150
4150
|
sections.push({ idx: i, content });
|
|
4151
4151
|
} catch (e26) {
|
|
4152
4152
|
break;
|
|
@@ -4249,7 +4249,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4249
4249
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4250
4250
|
if (!_optionalChain([ctrl, 'optionalAccess', _69 => _69.href]) || r.end <= r.start) continue;
|
|
4251
4251
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4252
|
-
const href =
|
|
4252
|
+
const href = _chunkWN7LZHIIcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4253
4253
|
if (!href) continue;
|
|
4254
4254
|
const anchor = text.slice(r.start, r.end);
|
|
4255
4255
|
if (!anchor.trim()) continue;
|
|
@@ -4482,8 +4482,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4482
4482
|
let tableIdx = -1;
|
|
4483
4483
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4484
4484
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4485
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4486
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4485
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkWN7LZHIIcjs.MAX_ROWS);
|
|
4486
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkWN7LZHIIcjs.MAX_COLS);
|
|
4487
4487
|
tableIdx = i2;
|
|
4488
4488
|
break;
|
|
4489
4489
|
}
|
|
@@ -4532,7 +4532,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4532
4532
|
return table3;
|
|
4533
4533
|
}
|
|
4534
4534
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4535
|
-
const table2 =
|
|
4535
|
+
const table2 = _chunkWN7LZHIIcjs.buildTable.call(void 0, cellRows);
|
|
4536
4536
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
4537
4537
|
return table2.rows > 0 ? table2 : null;
|
|
4538
4538
|
}
|
|
@@ -4549,8 +4549,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4549
4549
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4550
4550
|
const cs = rec.data.readUInt16LE(12);
|
|
4551
4551
|
const rs = rec.data.readUInt16LE(14);
|
|
4552
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4553
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4552
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkWN7LZHIIcjs.MAX_COLS);
|
|
4553
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkWN7LZHIIcjs.MAX_ROWS);
|
|
4554
4554
|
}
|
|
4555
4555
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4556
4556
|
const parts = [];
|
|
@@ -4560,7 +4560,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4560
4560
|
parts.push(``);
|
|
4561
4561
|
hasStructure = true;
|
|
4562
4562
|
} else if (b.type === "table" && b.table) {
|
|
4563
|
-
const flat =
|
|
4563
|
+
const flat = _chunkWN7LZHIIcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4564
4564
|
if (flat) parts.push(flat);
|
|
4565
4565
|
hasStructure = true;
|
|
4566
4566
|
} else if (b.text) {
|
|
@@ -16997,7 +16997,7 @@ function getTextContent(el) {
|
|
|
16997
16997
|
return _nullishCoalesce(_optionalChain([el, 'access', _84 => _84.textContent, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()]), () => ( ""));
|
|
16998
16998
|
}
|
|
16999
16999
|
function parseXml(text) {
|
|
17000
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17000
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkWN7LZHIIcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17001
17001
|
}
|
|
17002
17002
|
function parseSharedStrings(xml) {
|
|
17003
17003
|
const doc = parseXml(xml);
|
|
@@ -17141,7 +17141,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17141
17141
|
cellRows.push(row);
|
|
17142
17142
|
}
|
|
17143
17143
|
if (cellRows.length > 0) {
|
|
17144
|
-
const table2 =
|
|
17144
|
+
const table2 = _chunkWN7LZHIIcjs.buildTable.call(void 0, cellRows);
|
|
17145
17145
|
if (table2.rows > 0) {
|
|
17146
17146
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17147
17147
|
}
|
|
@@ -17149,12 +17149,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
17149
17149
|
return blocks;
|
|
17150
17150
|
}
|
|
17151
17151
|
async function parseXlsxDocument(buffer, options) {
|
|
17152
|
-
|
|
17152
|
+
_chunkWN7LZHIIcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
17153
17153
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
17154
17154
|
const warnings = [];
|
|
17155
17155
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
17156
17156
|
if (!workbookFile) {
|
|
17157
|
-
throw new (0,
|
|
17157
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17158
17158
|
}
|
|
17159
17159
|
let sharedStrings = [];
|
|
17160
17160
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17163,7 +17163,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17163
17163
|
}
|
|
17164
17164
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
17165
17165
|
if (sheets.length === 0) {
|
|
17166
|
-
throw new (0,
|
|
17166
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17167
17167
|
}
|
|
17168
17168
|
let relsMap = /* @__PURE__ */ new Map();
|
|
17169
17169
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -17235,7 +17235,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17235
17235
|
} catch (e27) {
|
|
17236
17236
|
}
|
|
17237
17237
|
}
|
|
17238
|
-
const markdown =
|
|
17238
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17239
17239
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17240
17240
|
}
|
|
17241
17241
|
|
|
@@ -17642,11 +17642,11 @@ function processGlobals(records) {
|
|
|
17642
17642
|
let encrypted = false;
|
|
17643
17643
|
const firstBof = records[0];
|
|
17644
17644
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17645
|
-
throw new (0,
|
|
17645
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17646
17646
|
}
|
|
17647
17647
|
const bof = decodeBof(firstBof.data);
|
|
17648
17648
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17649
|
-
throw new (0,
|
|
17649
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17650
17650
|
}
|
|
17651
17651
|
let i = 1;
|
|
17652
17652
|
while (i < records.length) {
|
|
@@ -17761,7 +17761,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17761
17761
|
cellRows.push(row);
|
|
17762
17762
|
}
|
|
17763
17763
|
if (cellRows.length > 0) {
|
|
17764
|
-
const table2 =
|
|
17764
|
+
const table2 = _chunkWN7LZHIIcjs.buildTable.call(void 0, cellRows);
|
|
17765
17765
|
if (table2.rows > 0) {
|
|
17766
17766
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17767
17767
|
}
|
|
@@ -17774,21 +17774,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17774
17774
|
try {
|
|
17775
17775
|
cfb = parseLenientCfb(buf);
|
|
17776
17776
|
} catch (e) {
|
|
17777
|
-
throw new (0,
|
|
17777
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)(
|
|
17778
17778
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17779
17779
|
);
|
|
17780
17780
|
}
|
|
17781
17781
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17782
17782
|
if (!wb) {
|
|
17783
|
-
throw new (0,
|
|
17783
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17784
17784
|
}
|
|
17785
17785
|
const records = readRecords2(wb);
|
|
17786
17786
|
if (records.length === 0) {
|
|
17787
|
-
throw new (0,
|
|
17787
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17788
17788
|
}
|
|
17789
17789
|
const firstBof = decodeBof(records[0].data);
|
|
17790
17790
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17791
|
-
throw new (0,
|
|
17791
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)(
|
|
17792
17792
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17793
17793
|
);
|
|
17794
17794
|
}
|
|
@@ -17848,7 +17848,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17848
17848
|
pageCount: totalSheets
|
|
17849
17849
|
};
|
|
17850
17850
|
return {
|
|
17851
|
-
markdown:
|
|
17851
|
+
markdown: _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17852
17852
|
blocks: allBlocks,
|
|
17853
17853
|
metadata,
|
|
17854
17854
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18286,7 +18286,7 @@ function getAttr(el, localName2) {
|
|
|
18286
18286
|
return null;
|
|
18287
18287
|
}
|
|
18288
18288
|
function parseXml2(text) {
|
|
18289
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18289
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkWN7LZHIIcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18290
18290
|
}
|
|
18291
18291
|
function parseStyles(xml) {
|
|
18292
18292
|
const doc = parseXml2(xml);
|
|
@@ -18571,7 +18571,7 @@ ${cell2.text}` : cell2.text;
|
|
|
18571
18571
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
18572
18572
|
})
|
|
18573
18573
|
);
|
|
18574
|
-
const table2 =
|
|
18574
|
+
const table2 = _chunkWN7LZHIIcjs.buildTable.call(void 0, cellRows);
|
|
18575
18575
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
18576
18576
|
return { type: "table", table: table2 };
|
|
18577
18577
|
}
|
|
@@ -18638,12 +18638,12 @@ async function extractImages(zip, rels, doc, warnings) {
|
|
|
18638
18638
|
return { blocks, images };
|
|
18639
18639
|
}
|
|
18640
18640
|
async function parseDocxDocument(buffer, options) {
|
|
18641
|
-
|
|
18641
|
+
_chunkWN7LZHIIcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18642
18642
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18643
18643
|
const warnings = [];
|
|
18644
18644
|
const docFile = zip.file("word/document.xml");
|
|
18645
18645
|
if (!docFile) {
|
|
18646
|
-
throw new (0,
|
|
18646
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18647
18647
|
}
|
|
18648
18648
|
let rels = /* @__PURE__ */ new Map();
|
|
18649
18649
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18690,7 +18690,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18690
18690
|
const doc = parseXml2(docXml);
|
|
18691
18691
|
const body = findElements(doc, "body");
|
|
18692
18692
|
if (body.length === 0) {
|
|
18693
|
-
throw new (0,
|
|
18693
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18694
18694
|
}
|
|
18695
18695
|
const blocks = [];
|
|
18696
18696
|
const bodyEl = body[0];
|
|
@@ -18735,7 +18735,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18735
18735
|
}
|
|
18736
18736
|
}
|
|
18737
18737
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18738
|
-
const markdown =
|
|
18738
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18739
18739
|
return {
|
|
18740
18740
|
markdown,
|
|
18741
18741
|
blocks,
|
|
@@ -18758,7 +18758,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18758
18758
|
}
|
|
18759
18759
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18760
18760
|
const normalized = text.replace(/ /g, " ");
|
|
18761
|
-
const xml =
|
|
18761
|
+
const xml = _chunkWN7LZHIIcjs.stripDtd.call(void 0, normalized);
|
|
18762
18762
|
const warnings = [];
|
|
18763
18763
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18764
18764
|
onError: (_level, msg2) => {
|
|
@@ -18798,7 +18798,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18798
18798
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18799
18799
|
}
|
|
18800
18800
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18801
|
-
const markdown =
|
|
18801
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18802
18802
|
return {
|
|
18803
18803
|
markdown,
|
|
18804
18804
|
blocks,
|
|
@@ -18956,7 +18956,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18956
18956
|
const cellRows = grid.map(
|
|
18957
18957
|
(row) => row.map((cell2) => _nullishCoalesce(cell2, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18958
18958
|
);
|
|
18959
|
-
const table2 =
|
|
18959
|
+
const table2 = _chunkWN7LZHIIcjs.buildTable.call(void 0, cellRows);
|
|
18960
18960
|
const caption = extractShapeCaption(el);
|
|
18961
18961
|
if (caption.text && caption.before) {
|
|
18962
18962
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -20284,19 +20284,19 @@ function parseCentralDirectory(buf) {
|
|
|
20284
20284
|
}
|
|
20285
20285
|
}
|
|
20286
20286
|
}
|
|
20287
|
-
if (eocdOffset < 0) throw new (0,
|
|
20287
|
+
if (eocdOffset < 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20288
20288
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
20289
20289
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
20290
20290
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
20291
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
20291
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20292
20292
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
20293
|
-
throw new (0,
|
|
20293
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20294
20294
|
}
|
|
20295
20295
|
const decoder = new TextDecoder("utf-8");
|
|
20296
20296
|
const entries = [];
|
|
20297
20297
|
let pos = cdOffset;
|
|
20298
20298
|
for (let i = 0; i < totalEntries; i++) {
|
|
20299
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
20299
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
20300
20300
|
const flags = view.getUint16(pos + 8, true);
|
|
20301
20301
|
const method = view.getUint16(pos + 10, true);
|
|
20302
20302
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -20307,7 +20307,7 @@ function parseCentralDirectory(buf) {
|
|
|
20307
20307
|
const commentLen = view.getUint16(pos + 32, true);
|
|
20308
20308
|
const localOffset = view.getUint32(pos + 42, true);
|
|
20309
20309
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
20310
|
-
throw new (0,
|
|
20310
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
20311
20311
|
}
|
|
20312
20312
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
20313
20313
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -20336,11 +20336,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20336
20336
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
20337
20337
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
20338
20338
|
for (const name of replacements.keys()) {
|
|
20339
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
20339
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkWN7LZHIIcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20340
20340
|
}
|
|
20341
20341
|
if (additions) {
|
|
20342
20342
|
for (const name of additions.keys()) {
|
|
20343
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
20343
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkWN7LZHIIcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
20344
20344
|
}
|
|
20345
20345
|
}
|
|
20346
20346
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -20359,7 +20359,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
20359
20359
|
offset += seg.length;
|
|
20360
20360
|
continue;
|
|
20361
20361
|
}
|
|
20362
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
20362
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkWN7LZHIIcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
20363
20363
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
20364
20364
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
20365
20365
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -20465,7 +20465,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
20465
20465
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
20466
20466
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
20467
20467
|
if (sectionPaths.length === 0) {
|
|
20468
|
-
throw new (0,
|
|
20468
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
20469
20469
|
}
|
|
20470
20470
|
const normalizedValues = normalizeValues(values);
|
|
20471
20471
|
const cursor = new ValueCursor(normalizedValues);
|
|
@@ -20954,7 +20954,8 @@ function fitRatioForFewerLines(text, firstWidth, contWidth, height, baseRatio, m
|
|
|
20954
20954
|
|
|
20955
20955
|
// src/hwpx/gaejosik.ts
|
|
20956
20956
|
var GAEJOSIK_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
20957
|
-
function gaejosikMarker(depth) {
|
|
20957
|
+
function gaejosikMarker(depth, bullet2 = "\u25CB") {
|
|
20958
|
+
if (depth === 1) return bullet2;
|
|
20958
20959
|
return GAEJOSIK_BULLETS[Math.min(depth, GAEJOSIK_BULLETS.length - 1)];
|
|
20959
20960
|
}
|
|
20960
20961
|
function gaejosikSizes(bodyHeight, ov = {}) {
|
|
@@ -20990,11 +20991,11 @@ function gaejosikSpaceBefore(depth, bodyHeight) {
|
|
|
20990
20991
|
const ui = [3e3, 2e3, 1200, 600][Math.min(depth, 3)];
|
|
20991
20992
|
return Math.round(ui * s);
|
|
20992
20993
|
}
|
|
20993
|
-
function gaejosikLevelIndent(depth, bodyHeight, sizes = {}) {
|
|
20994
|
+
function gaejosikLevelIndent(depth, bodyHeight, sizes = {}, bullet2 = "\u25CB") {
|
|
20994
20995
|
const lefts = [0, 1, 1.5, 2];
|
|
20995
20996
|
const left = depth <= 3 ? Math.round(lefts[depth] * bodyHeight) : Math.round((2 + (depth - 3) * 0.5) * bodyHeight);
|
|
20996
20997
|
const h = depth === 0 ? gaejosikSizes(bodyHeight, sizes).dae : bodyHeight;
|
|
20997
|
-
return { left, indent: -markerWidth(gaejosikMarker(depth), h) };
|
|
20998
|
+
return { left, indent: -markerWidth(gaejosikMarker(depth, bullet2), h) };
|
|
20998
20999
|
}
|
|
20999
21000
|
function gaejosikChamIndent(bodyHeight, sizes = {}) {
|
|
21000
21001
|
const cham = gaejosikSizes(bodyHeight, sizes).cham;
|
|
@@ -21062,7 +21063,7 @@ function bodyTitleGeom(bodyHeight, ov = {}) {
|
|
|
21062
21063
|
}
|
|
21063
21064
|
|
|
21064
21065
|
// src/hwpx/gongmun.ts
|
|
21065
|
-
var OFFICIAL_MARGINS = { top: 20, bottom:
|
|
21066
|
+
var OFFICIAL_MARGINS = { top: 20, bottom: 15, left: 20, right: 15 };
|
|
21066
21067
|
var GAEJOSIK_MARGINS = { top: 15, bottom: 15, left: 20, right: 20 };
|
|
21067
21068
|
var GAEJOSIK_HEADER_FOOTER = 4251;
|
|
21068
21069
|
var PRESET_DEFAULTS = {
|
|
@@ -21071,7 +21072,9 @@ var PRESET_DEFAULTS = {
|
|
|
21071
21072
|
plan: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
21072
21073
|
notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
21073
21074
|
minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" },
|
|
21074
|
-
gaejosik: { bodyPt: 15, lineSpacing: 160, numbering: "gaejosik" }
|
|
21075
|
+
gaejosik: { bodyPt: 15, lineSpacing: 160, numbering: "gaejosik" },
|
|
21076
|
+
// 보도자료 — 실측(국토부 실물): 본문 바탕 14pt 160%, □→ㅇ→*(각주) 부호
|
|
21077
|
+
press: { bodyPt: 14, lineSpacing: 160, numbering: "report" }
|
|
21075
21078
|
};
|
|
21076
21079
|
var PRESET_ALIAS = {
|
|
21077
21080
|
official: "official",
|
|
@@ -21094,7 +21097,9 @@ var PRESET_ALIAS = {
|
|
|
21094
21097
|
\uAC1C\uC870\uC2DD: "gaejosik",
|
|
21095
21098
|
\uAC1C\uC870\uC2DD\uBCF4\uACE0\uC11C: "gaejosik",
|
|
21096
21099
|
\uC815\uBD80\uBCF4\uACE0\uC11C: "gaejosik",
|
|
21097
|
-
\uC815\uBD80\uD45C\uC900\uAC1C\uC870\uC2DD\uBCF4\uACE0\uC11C: "gaejosik"
|
|
21100
|
+
\uC815\uBD80\uD45C\uC900\uAC1C\uC870\uC2DD\uBCF4\uACE0\uC11C: "gaejosik",
|
|
21101
|
+
press: "press",
|
|
21102
|
+
\uBCF4\uB3C4\uC790\uB8CC: "press"
|
|
21098
21103
|
};
|
|
21099
21104
|
function normalizeGongmunPreset(preset) {
|
|
21100
21105
|
if (!preset) return "official";
|
|
@@ -21111,13 +21116,14 @@ function resolveGongmun(opts) {
|
|
|
21111
21116
|
const coverOn = opts.cover !== void 0 ? opts.cover !== false : preset === "gaejosik";
|
|
21112
21117
|
const coverOpts = typeof opts.cover === "object" ? opts.cover : {};
|
|
21113
21118
|
const gaejosik = preset === "gaejosik";
|
|
21119
|
+
const reportFamily = gaejosik || preset === "report" || preset === "plan" || preset === "notice" || preset === "press";
|
|
21114
21120
|
return {
|
|
21115
21121
|
preset,
|
|
21116
21122
|
bodyFont: _nullishCoalesce(opts.bodyFont, () => ( "myeongjo")),
|
|
21117
21123
|
bodyHeight: Math.round(bodyPt * 100),
|
|
21118
21124
|
lineSpacing: _nullishCoalesce(opts.lineSpacing, () => ( d.lineSpacing)),
|
|
21119
21125
|
numbering: _nullishCoalesce(opts.numbering, () => ( d.numbering)),
|
|
21120
|
-
margins: _nullishCoalesce(opts.margins, () => ( (
|
|
21126
|
+
margins: _nullishCoalesce(opts.margins, () => ( (reportFamily ? GAEJOSIK_MARGINS : OFFICIAL_MARGINS))),
|
|
21121
21127
|
centerTitle: _nullishCoalesce(opts.centerTitle, () => ( true)),
|
|
21122
21128
|
autoFitMinRatio,
|
|
21123
21129
|
cover: coverOn ? { date: _nullishCoalesce(coverOpts.date, () => ( null)), org: _nullishCoalesce(coverOpts.org, () => ( "")) } : null,
|
|
@@ -21126,14 +21132,26 @@ function resolveGongmun(opts) {
|
|
|
21126
21132
|
sizes: _nullishCoalesce(opts.sizes, () => ( {})),
|
|
21127
21133
|
// 쪽번호 — 보고서 계열 관행(실측: 2_보고서 양식·추진계획·공고문 전부 하단 중앙)
|
|
21128
21134
|
pageNumbers: _nullishCoalesce(opts.pageNumbers, () => ( (gaejosik || preset === "report" || preset === "plan"))),
|
|
21129
|
-
|
|
21135
|
+
// 머리말·꼬리말 — 실측: 보고서 계열 15mm(GT3·t2·춘천·브라더), 공고·보도 10mm,
|
|
21136
|
+
// 기안문 0(실결재 41/60건 h0/f0)
|
|
21137
|
+
headerFooter: usesReportFonts(preset) ? GAEJOSIK_HEADER_FOOTER : preset === "notice" || preset === "press" ? 2835 : 0,
|
|
21130
21138
|
// "끝." — 기안문 규정(본문 끝 2타+"끝."). 그 외는 opt-in
|
|
21131
21139
|
endMark: _nullishCoalesce(opts.endMark, () => ( preset === "official")),
|
|
21132
21140
|
approval: opts.approval && opts.approval.length > 0 ? opts.approval : null,
|
|
21133
21141
|
// 본문 제목박스 — 실측(GT3·GT12): 목차 뒤 본문 시작에 제목 반복. 표지 켜진 개조식 기본
|
|
21134
21142
|
bodyTitleBox: _nullishCoalesce(opts.bodyTitleBox, () => ( (gaejosik && coverOn))),
|
|
21135
|
-
// h2 말머리 —
|
|
21136
|
-
h2Marker: _nullishCoalesce(opts.h2Marker, () => ( (preset === "report" || preset === "plan" ? "box" : "none")))
|
|
21143
|
+
// h2 말머리 — 실측: 보고서 양식 □ 대항목(QA-2), 공고문 아라비아("1. 사업개요", 바이오헬스 실측)
|
|
21144
|
+
h2Marker: _nullishCoalesce(opts.h2Marker, () => ( (preset === "report" || preset === "plan" ? "box" : preset === "notice" ? "number" : "none"))),
|
|
21145
|
+
// 2단계 부호 — 실결재 기안문·공고문 ㅇ 지배(60건 중 ㅇ134:○5), 보고서 양식 계열 ○
|
|
21146
|
+
bullet2: _nullishCoalesce(opts.bullet2, () => ( (preset === "notice" || preset === "press" ? "\u3147" : "\u25CB"))),
|
|
21147
|
+
// 단일 형제 부호 생략 — 규정이지만 부호 없는 계단이 실무 눈에 어색 (실무자 QA)
|
|
21148
|
+
suppressSingle: _nullishCoalesce(opts.suppressSingle, () => ( false)),
|
|
21149
|
+
docHead: preset === "official" && opts.docHead ? opts.docHead : null,
|
|
21150
|
+
docFoot: preset === "official" && opts.docFoot ? opts.docFoot : null,
|
|
21151
|
+
reportInfo: _optionalChain([opts, 'access', _176 => _176.reportInfo, 'optionalAccess', _177 => _177.trim, 'call', _178 => _178()]) || null,
|
|
21152
|
+
noticeHead: preset === "notice" && opts.noticeHead ? opts.noticeHead : null,
|
|
21153
|
+
// 보도자료 머리박스는 프리셋 자체가 요구 — 옵션 미지정이어도 빈 객체
|
|
21154
|
+
press: preset === "press" ? _nullishCoalesce(opts.press, () => ( {})) : null
|
|
21137
21155
|
};
|
|
21138
21156
|
}
|
|
21139
21157
|
var HANGUL_INITIALS = [0, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18];
|
|
@@ -21151,6 +21169,7 @@ function circledHangul(n) {
|
|
|
21151
21169
|
return String.fromCodePoint(12910 + n % 14);
|
|
21152
21170
|
}
|
|
21153
21171
|
var REPORT_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
21172
|
+
var PRESS_BULLETS = ["\u25A1", "\u3147", "*", "\u318D"];
|
|
21154
21173
|
function standardMarker(depth, n) {
|
|
21155
21174
|
switch (depth) {
|
|
21156
21175
|
case 0:
|
|
@@ -21173,17 +21192,19 @@ function standardMarker(depth, n) {
|
|
|
21173
21192
|
return circledHangul(n);
|
|
21174
21193
|
}
|
|
21175
21194
|
}
|
|
21176
|
-
function reportMarker(depth) {
|
|
21177
|
-
|
|
21195
|
+
function reportMarker(depth, bullet2 = "\u25CB", press = false) {
|
|
21196
|
+
const bullets = press ? PRESS_BULLETS : REPORT_BULLETS;
|
|
21197
|
+
const m = bullets[Math.min(depth, bullets.length - 1)];
|
|
21198
|
+
return depth === 1 && !press ? bullet2 : m;
|
|
21178
21199
|
}
|
|
21179
21200
|
function markerWidth(marker, bodyHeight) {
|
|
21180
21201
|
let em = SPACE_EM_FIXED;
|
|
21181
21202
|
for (const c of marker) em += charWidthEm1000(c.codePointAt(0));
|
|
21182
21203
|
return Math.round(em / 1e3 * bodyHeight);
|
|
21183
21204
|
}
|
|
21184
|
-
function levelIndent(depth, bodyHeight, numbering, sizes = {}) {
|
|
21185
|
-
if (numbering === "gaejosik") return gaejosikLevelIndent(depth, bodyHeight, sizes);
|
|
21186
|
-
const marker = numbering === "report" ? reportMarker(depth) : standardMarker(depth, 0);
|
|
21205
|
+
function levelIndent(depth, bodyHeight, numbering, sizes = {}, bullet2 = "\u25CB", press = false) {
|
|
21206
|
+
if (numbering === "gaejosik") return gaejosikLevelIndent(depth, bodyHeight, sizes, bullet2);
|
|
21207
|
+
const marker = numbering === "report" ? reportMarker(depth, bullet2, press) : standardMarker(depth, 0);
|
|
21187
21208
|
return { left: Math.round(depth * bodyHeight), indent: -markerWidth(marker, bodyHeight) };
|
|
21188
21209
|
}
|
|
21189
21210
|
function computeSuppression(depths) {
|
|
@@ -21200,8 +21221,10 @@ function computeSuppression(depths) {
|
|
|
21200
21221
|
return keys.map((k) => (_nullishCoalesce(counts.get(k), () => ( 0))) <= 1);
|
|
21201
21222
|
}
|
|
21202
21223
|
var GongmunNumberer = (_class3 = class {
|
|
21203
|
-
constructor(numbering) {;_class3.prototype.__init5.call(this);
|
|
21224
|
+
constructor(numbering, bullet2 = "\u25CB", press = false) {;_class3.prototype.__init5.call(this);
|
|
21204
21225
|
this.numbering = numbering;
|
|
21226
|
+
this.bullet2 = bullet2;
|
|
21227
|
+
this.press = press;
|
|
21205
21228
|
}
|
|
21206
21229
|
__init5() {this.counts = []}
|
|
21207
21230
|
/** depth 항목 하나에 대한 마커. suppress=true면 빈 문자열(부호 없음) */
|
|
@@ -21210,8 +21233,8 @@ var GongmunNumberer = (_class3 = class {
|
|
|
21210
21233
|
const n = _nullishCoalesce(this.counts[depth], () => ( 0));
|
|
21211
21234
|
this.counts[depth] = n + 1;
|
|
21212
21235
|
if (suppress) return "";
|
|
21213
|
-
if (this.numbering === "gaejosik") return gaejosikMarker(depth);
|
|
21214
|
-
return this.numbering === "report" ? reportMarker(depth) : standardMarker(depth, n);
|
|
21236
|
+
if (this.numbering === "gaejosik") return gaejosikMarker(depth, this.bullet2);
|
|
21237
|
+
return this.numbering === "report" ? reportMarker(depth, this.bullet2, this.press) : standardMarker(depth, n);
|
|
21215
21238
|
}
|
|
21216
21239
|
reset() {
|
|
21217
21240
|
this.counts = [];
|
|
@@ -21251,16 +21274,16 @@ var PARA_LIST = 7;
|
|
|
21251
21274
|
var DEFAULT_TEXT_COLOR = "#000000";
|
|
21252
21275
|
function resolveTheme(theme) {
|
|
21253
21276
|
return {
|
|
21254
|
-
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21255
|
-
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21256
|
-
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21257
|
-
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21258
|
-
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21259
|
-
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21277
|
+
h1: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _179 => _179.headingColors, 'optionalAccess', _180 => _180[1]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21278
|
+
h2: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _181 => _181.headingColors, 'optionalAccess', _182 => _182[2]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21279
|
+
h3: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _183 => _183.headingColors, 'optionalAccess', _184 => _184[3]]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21280
|
+
h4: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _185 => _185.headingColors, 'optionalAccess', _186 => _186[4]]), () => ( _optionalChain([theme, 'optionalAccess', _187 => _187.headingColors, 'optionalAccess', _188 => _188[3]]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21281
|
+
body: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _189 => _189.bodyColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21282
|
+
quote: _nullishCoalesce(_optionalChain([theme, 'optionalAccess', _190 => _190.quoteColor]), () => ( DEFAULT_TEXT_COLOR)),
|
|
21260
21283
|
/** quoteColor가 명시되었는지 — blockquote charPr 분기에 사용 (baseline 호환) */
|
|
21261
|
-
hasQuoteOption: _optionalChain([theme, 'optionalAccess',
|
|
21262
|
-
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess',
|
|
21263
|
-
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess',
|
|
21284
|
+
hasQuoteOption: _optionalChain([theme, 'optionalAccess', _191 => _191.quoteColor]) !== void 0,
|
|
21285
|
+
tableHeader: _nullishCoalesce(_nullishCoalesce(_optionalChain([theme, 'optionalAccess', _192 => _192.tableHeaderColor]), () => ( _optionalChain([theme, 'optionalAccess', _193 => _193.bodyColor]))), () => ( DEFAULT_TEXT_COLOR)),
|
|
21286
|
+
tableHeaderBold: !!_optionalChain([theme, 'optionalAccess', _194 => _194.tableHeaderBold])
|
|
21264
21287
|
};
|
|
21265
21288
|
}
|
|
21266
21289
|
function escapeXml(text) {
|
|
@@ -21333,6 +21356,7 @@ var GJ_PARA_COVER = 21;
|
|
|
21333
21356
|
var GJ_PARA_TOC_ITEM = 22;
|
|
21334
21357
|
var GJ_PARA_CHAPTER = 23;
|
|
21335
21358
|
var GJ_PARA_BAR = 24;
|
|
21359
|
+
var GONGMUN_LIST_PLAIN_BASE = 25;
|
|
21336
21360
|
var GJ_BF_CHAPTER_NUM = 3;
|
|
21337
21361
|
var GJ_BF_CHAPTER_GAP = 4;
|
|
21338
21362
|
var GJ_BF_CHAPTER_TITLE = 5;
|
|
@@ -21371,9 +21395,13 @@ function newPageNumCtrl(num4 = 1) {
|
|
|
21371
21395
|
function pageHidingCtrl(hideHeader = false) {
|
|
21372
21396
|
return `<hp:ctrl><hp:pageHiding hideHeader="${hideHeader ? 1 : 0}" hideFooter="0" hideMasterPage="0" hideBorder="0" hideFill="0" hidePageNum="1"/></hp:ctrl>`;
|
|
21373
21397
|
}
|
|
21398
|
+
var GONGMUN_TBL_CHAR = 11;
|
|
21399
|
+
var GONGMUN_TBL_CHAR_BOLD = 12;
|
|
21400
|
+
var GONGMUN_TBL_PT = 1200;
|
|
21374
21401
|
var CHAR_VARIANT_BASE = 11;
|
|
21375
|
-
function charVariantBase(measured) {
|
|
21376
|
-
|
|
21402
|
+
function charVariantBase(measured, isGongmun = true) {
|
|
21403
|
+
if (!isGongmun) return CHAR_VARIANT_BASE;
|
|
21404
|
+
return measured ? 11 + GJ_CHAR_COUNT : 11 + 2;
|
|
21377
21405
|
}
|
|
21378
21406
|
var GONGMUN_BODY_RATIO = 95;
|
|
21379
21407
|
|
|
@@ -21648,6 +21676,12 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21648
21676
|
charPr(CHAR_TABLE_HEADER, body, theme.tableHeaderBold, false, bodyFont, theme.tableHeader),
|
|
21649
21677
|
charPr(CHAR_QUOTE, body, false, true, bodyFont, theme.quote)
|
|
21650
21678
|
];
|
|
21679
|
+
if (gongmun && !measured) {
|
|
21680
|
+
rows.push(
|
|
21681
|
+
charPr(11, GONGMUN_TBL_PT, false, false, bodyFont, theme.body),
|
|
21682
|
+
charPr(12, GONGMUN_TBL_PT, true, false, bodyFont, theme.body)
|
|
21683
|
+
);
|
|
21684
|
+
}
|
|
21651
21685
|
if (measured) {
|
|
21652
21686
|
const sz = gaejosikSizes(body, gongmun.sizes);
|
|
21653
21687
|
rows.push(
|
|
@@ -21726,16 +21760,16 @@ ${base2.join("\n")}
|
|
|
21726
21760
|
paraPr(7, { align: "LEFT", lineSpacing: ls, indent: 600, keepWord: true })
|
|
21727
21761
|
];
|
|
21728
21762
|
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
21729
|
-
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes);
|
|
21730
|
-
const sectionGap = gongmun.numbering === "gaejosik"
|
|
21731
|
-
const keepNext = gongmun.numbering === "gaejosik" && d === 0;
|
|
21763
|
+
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes, gongmun.bullet2, gongmun.preset === "press");
|
|
21764
|
+
const sectionGap = gongmun.numbering === "gaejosik" || gongmun.numbering === "report" ? gaejosikSpaceBefore(d, gongmun.bodyHeight) : 0;
|
|
21765
|
+
const keepNext = (gongmun.numbering === "gaejosik" || gongmun.numbering === "report") && d === 0;
|
|
21732
21766
|
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent, spaceBefore: sectionGap, keepWord: true, keepWithNext: keepNext }));
|
|
21733
21767
|
}
|
|
21734
21768
|
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls, keepWord: true }));
|
|
21735
21769
|
base.push(paraPr(GONGMUN_RIGHT, { align: "RIGHT", lineSpacing: ls, keepWord: true }));
|
|
21736
21770
|
base.push(paraPr(GONGMUN_TBL_CENTER, { align: "CENTER", lineSpacing: 130, keepWord: true }));
|
|
21737
21771
|
base.push(paraPr(GONGMUN_TBL_LEFT, { align: "LEFT", lineSpacing: 130, keepWord: true }));
|
|
21738
|
-
|
|
21772
|
+
{
|
|
21739
21773
|
const cham = gaejosikChamIndent(gongmun.bodyHeight, gongmun.sizes);
|
|
21740
21774
|
const toc = gaejosikTocItemIndent(gongmun.bodyHeight, gongmun.sizes);
|
|
21741
21775
|
base.push(
|
|
@@ -21747,11 +21781,11 @@ ${base2.join("\n")}
|
|
|
21747
21781
|
// 표지 장식 바 셀 빈 문단 — 저줄간격(실측 71%)으로 바 높이 818 안에 수납
|
|
21748
21782
|
paraPr(GJ_PARA_BAR, { align: "CENTER", lineSpacing: 70, keepWord: true })
|
|
21749
21783
|
);
|
|
21750
|
-
}
|
|
21751
|
-
|
|
21752
|
-
|
|
21753
|
-
|
|
21754
|
-
);
|
|
21784
|
+
}
|
|
21785
|
+
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
21786
|
+
const { left } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes, gongmun.bullet2, gongmun.preset === "press");
|
|
21787
|
+
const sectionGap = gongmun.numbering === "gaejosik" || gongmun.numbering === "report" ? gaejosikSpaceBefore(d, gongmun.bodyHeight) : 0;
|
|
21788
|
+
base.push(paraPr(GONGMUN_LIST_PLAIN_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent: 0, spaceBefore: sectionGap, keepWord: true }));
|
|
21755
21789
|
}
|
|
21756
21790
|
return `<hh:paraProperties itemCnt="${base.length}">
|
|
21757
21791
|
${base.join("\n")}
|
|
@@ -21835,7 +21869,7 @@ function buildBorderFills(gongmun, extra = []) {
|
|
|
21835
21869
|
borderFillEntry(1, {}),
|
|
21836
21870
|
borderFillEntry(2, { l: thin, r: thin, t: thin, b: thin })
|
|
21837
21871
|
];
|
|
21838
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
21872
|
+
if (_optionalChain([gongmun, 'optionalAccess', _195 => _195.preset]) === "gaejosik") {
|
|
21839
21873
|
const c = GAEJOSIK_COLORS;
|
|
21840
21874
|
const edge = ["0.12 mm", c.border];
|
|
21841
21875
|
const grayLine = ["0.1 mm", c.titleLine];
|
|
@@ -21879,7 +21913,7 @@ function buildStyles(gongmun) {
|
|
|
21879
21913
|
</hh:styles>`;
|
|
21880
21914
|
}
|
|
21881
21915
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = []) {
|
|
21882
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
21916
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _196 => _196.fonts, 'access', _197 => _197.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _198 => _198.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
21883
21917
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
21884
21918
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21885
21919
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -22009,8 +22043,8 @@ function parseChartFence(text) {
|
|
|
22009
22043
|
const spec = chartSpec(type);
|
|
22010
22044
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
22011
22045
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
22012
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22013
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22046
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _199 => _199.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
22047
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _200 => _200[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22014
22048
|
if (!spec.scatter) {
|
|
22015
22049
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22016
22050
|
}
|
|
@@ -22052,7 +22086,7 @@ function serSpPr(color, stroke) {
|
|
|
22052
22086
|
return stroke ? `<c:spPr><a:ln w="28575" cap="flat" cmpd="sng" algn="ctr">${f}<a:prstDash val="solid"/><a:round/></a:ln></c:spPr>` : `<c:spPr>${f}</c:spPr>`;
|
|
22053
22087
|
}
|
|
22054
22088
|
function dPtXml(pointColors, pie) {
|
|
22055
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
22089
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _201 => _201.length])) return "";
|
|
22056
22090
|
return pointColors.map((col, i) => {
|
|
22057
22091
|
const f = chartColorFill(col);
|
|
22058
22092
|
if (!f) return "";
|
|
@@ -22132,7 +22166,9 @@ function computeGongmunFitPlan(blocks, gongmun, gongmunList) {
|
|
|
22132
22166
|
if (gongmun.numbering === "gaejosik" && (depth === 0 || (block.text || "").trimStart().startsWith("\u203B"))) continue;
|
|
22133
22167
|
const content = plainRenderText(block.text || "");
|
|
22134
22168
|
text = marker ? `${marker} ${content}` : content;
|
|
22135
|
-
const
|
|
22169
|
+
const li = levelIndent(depth, gongmun.bodyHeight, gongmun.numbering, gongmun.sizes, gongmun.bullet2, gongmun.preset === "press");
|
|
22170
|
+
const left = li.left;
|
|
22171
|
+
const indent = marker ? li.indent : 0;
|
|
22136
22172
|
firstW = pageW - left - Math.max(indent, 0);
|
|
22137
22173
|
contW = pageW - left - Math.max(-indent, 0);
|
|
22138
22174
|
} else if (block.type === "paragraph") {
|
|
@@ -22160,7 +22196,7 @@ function variantMapper(fit, blockIdx, base = CHAR_VARIANT_BASE) {
|
|
|
22160
22196
|
}
|
|
22161
22197
|
function precomputeGongmunList(blocks, gongmun) {
|
|
22162
22198
|
const result = /* @__PURE__ */ new Map();
|
|
22163
|
-
const depthOffset = gongmun.numbering === "gaejosik" && blocks.some((b) => b.type === "heading" && b.level === 3) ? 1 : 0;
|
|
22199
|
+
const depthOffset = gongmun.numbering === "gaejosik" && blocks.some((b) => b.type === "heading" && b.level === 3) || gongmun.numbering === "standard" && gongmun.h2Marker === "number" && blocks.some((b) => b.type === "heading" && b.level === 2) ? 1 : 0;
|
|
22164
22200
|
let i = 0;
|
|
22165
22201
|
while (i < blocks.length) {
|
|
22166
22202
|
if (blocks[i].type !== "list_item") {
|
|
@@ -22187,8 +22223,8 @@ function precomputeGongmunList(blocks, gongmun) {
|
|
|
22187
22223
|
break;
|
|
22188
22224
|
}
|
|
22189
22225
|
const depths = run.map((bi) => Math.min(Math.max((blocks[bi].indent || 0) + depthOffset, 0), GONGMUN_LIST_LEVELS - 1));
|
|
22190
|
-
const suppress = gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
|
|
22191
|
-
const numberer = new GongmunNumberer(gongmun.numbering);
|
|
22226
|
+
const suppress = gongmun.suppressSingle && gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
|
|
22227
|
+
const numberer = new GongmunNumberer(gongmun.numbering, gongmun.bullet2, gongmun.preset === "press");
|
|
22192
22228
|
run.forEach((bi, k) => {
|
|
22193
22229
|
const marker = numberer.next(depths[k], suppress[k]);
|
|
22194
22230
|
result.set(bi, { marker, depth: depths[k] });
|
|
@@ -22218,7 +22254,8 @@ function cell(opts) {
|
|
|
22218
22254
|
return `<hp:tc name="" header="0" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${opts.bf}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="${_nullishCoalesce(opts.vertAlign, () => ( "CENTER"))}" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${paras}</hp:subList><hp:cellAddr colAddr="${opts.col}" rowAddr="${_nullishCoalesce(opts.row, () => ( 0))}"/><hp:cellSpan colSpan="${_nullishCoalesce(opts.colSpan, () => ( 1))}" rowSpan="1"/><hp:cellSz width="${opts.w}" height="${opts.h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22219
22255
|
}
|
|
22220
22256
|
function table(rows, w, h, cols, tblBf = 1) {
|
|
22221
|
-
|
|
22257
|
+
const outLR = w + 566 > 48e3 ? 0 : 283;
|
|
22258
|
+
return `<hp:tbl id="${++gjTableId}" zOrder="0" numberingType="TABLE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" pageBreak="CELL" repeatHeader="0" rowCnt="${rows.length}" colCnt="${cols}" cellSpacing="0" borderFillIDRef="${tblBf}" noAdjust="1"><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="${outLR}" right="${outLR}" top="283" bottom="283"/><hp:inMargin left="141" right="141" top="141" bottom="141"/>` + rows.map((r) => `<hp:tr>${r}</hp:tr>`).join("") + `</hp:tbl>`;
|
|
22222
22259
|
}
|
|
22223
22260
|
function buildGaejosikCover(title, gongmun) {
|
|
22224
22261
|
const g = coverGeom(gongmun.bodyHeight, gongmun.sizes);
|
|
@@ -22232,8 +22269,8 @@ function buildGaejosikCover(title, gongmun) {
|
|
|
22232
22269
|
const botRow = cell({ bf: GJ_BF_BAR_DARK, col: 0, row: 2, w: g.botDarkW, h: g.botBarH, paras: barEmpty }) + cell({ bf: GJ_BF_BAR_LIGHT, col: 1, colSpan: 2, row: 2, w: g.botLightW, h: g.botBarH, paras: barEmpty });
|
|
22233
22270
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3);
|
|
22234
22271
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
22235
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22236
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22272
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _202 => _202.cover, 'optionalAccess', _203 => _203.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
22273
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _204 => _204.cover, 'optionalAccess', _205 => _205.org]), () => ( ""));
|
|
22237
22274
|
const sub = (t) => `<hp:p paraPrIDRef="${GJ_PARA_COVER}" styleIDRef="0"><hp:run charPrIDRef="${GJ_CHAR_COVER_SUB}"><hp:t>${escapeXml(t)}</hp:t></hp:run></hp:p>`;
|
|
22238
22275
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
22239
22276
|
return [
|
|
@@ -22466,7 +22503,7 @@ function escapeGfm(text) {
|
|
|
22466
22503
|
}
|
|
22467
22504
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
22468
22505
|
function sanitizeText(text) {
|
|
22469
|
-
let result =
|
|
22506
|
+
let result = _chunkWN7LZHIIcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
22470
22507
|
if (result.length <= 30 && result.includes(" ")) {
|
|
22471
22508
|
const tokens = result.split(" ");
|
|
22472
22509
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -22496,7 +22533,7 @@ function replicateGfmTable(table2) {
|
|
|
22496
22533
|
for (let r = 0; r < numRows; r++) {
|
|
22497
22534
|
for (let c = 0; c < numCols; c++) {
|
|
22498
22535
|
if (skip.has(`${r},${c}`)) continue;
|
|
22499
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
22536
|
+
const cell2 = _optionalChain([cells, 'access', _206 => _206[r], 'optionalAccess', _207 => _207[c]]);
|
|
22500
22537
|
if (!cell2) continue;
|
|
22501
22538
|
display[r][c] = {
|
|
22502
22539
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -22550,7 +22587,7 @@ function unescapeGfmCell(text) {
|
|
|
22550
22587
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
22551
22588
|
}
|
|
22552
22589
|
function replicateCellInnerHtml(cell2) {
|
|
22553
|
-
if (_optionalChain([cell2, 'access',
|
|
22590
|
+
if (_optionalChain([cell2, 'access', _208 => _208.blocks, 'optionalAccess', _209 => _209.length])) {
|
|
22554
22591
|
return cell2.blocks.map((b) => {
|
|
22555
22592
|
if (b.type === "table" && b.table) {
|
|
22556
22593
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -22589,7 +22626,7 @@ function replicateHtmlTable(table2) {
|
|
|
22589
22626
|
const rowCells = [];
|
|
22590
22627
|
for (let c = 0; c < numCols; c++) {
|
|
22591
22628
|
if (skip.has(`${r},${c}`)) continue;
|
|
22592
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
22629
|
+
const cell2 = _optionalChain([cells, 'access', _210 => _210[r], 'optionalAccess', _211 => _211[c]]);
|
|
22593
22630
|
if (!cell2) continue;
|
|
22594
22631
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
22595
22632
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -22635,8 +22672,8 @@ function parseHtmlTable(raw) {
|
|
|
22635
22672
|
}
|
|
22636
22673
|
} else {
|
|
22637
22674
|
if (!isClose) {
|
|
22638
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
22639
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
22675
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _212 => _212.match, 'call', _213 => _213(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _214 => _214[1]]) || "1", 10);
|
|
22676
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _215 => _215.match, 'call', _216 => _216(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _217 => _217[1]]) || "1", 10);
|
|
22640
22677
|
cellStart = m.index + m[0].length;
|
|
22641
22678
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
22642
22679
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -22781,7 +22818,7 @@ function edgeXml(tag, d) {
|
|
|
22781
22818
|
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22782
22819
|
}
|
|
22783
22820
|
function borderFillDefToXml(id, def) {
|
|
22784
|
-
const fill = _optionalChain([def, 'access',
|
|
22821
|
+
const fill = _optionalChain([def, 'access', _218 => _218.fill, 'optionalAccess', _219 => _219.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22785
22822
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22786
22823
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22787
22824
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -22881,7 +22918,7 @@ function profileColWidths(tp, colCnt) {
|
|
|
22881
22918
|
if (tp.width) return Array(colCnt).fill(Math.floor(tp.width / colCnt));
|
|
22882
22919
|
return null;
|
|
22883
22920
|
}
|
|
22884
|
-
var CELL_PAD =
|
|
22921
|
+
var CELL_PAD = 1200;
|
|
22885
22922
|
function cellContentWidth(text, charHeight) {
|
|
22886
22923
|
let max = 0;
|
|
22887
22924
|
for (const seg of text.replace(/\*\*|__|`/g, "").split(/<br\s*\/?>/i)) {
|
|
@@ -22890,35 +22927,51 @@ function cellContentWidth(text, charHeight) {
|
|
|
22890
22927
|
}
|
|
22891
22928
|
return max;
|
|
22892
22929
|
}
|
|
22893
|
-
function
|
|
22930
|
+
function cellMinWordWidth(text, charHeight) {
|
|
22931
|
+
let max = 0;
|
|
22932
|
+
for (const seg of text.replace(/\*\*|__|`/g, "").split(/<br\s*\/?>/i)) {
|
|
22933
|
+
for (const word of seg.trim().split(/\s+/)) {
|
|
22934
|
+
const w = measureTextWidth(word, charHeight, 100);
|
|
22935
|
+
if (w > max) max = w;
|
|
22936
|
+
}
|
|
22937
|
+
}
|
|
22938
|
+
return max;
|
|
22939
|
+
}
|
|
22940
|
+
function computeColWidths(colMax, totalWidth, colMinWord = []) {
|
|
22894
22941
|
const colCnt = colMax.length;
|
|
22895
22942
|
const minW = Math.min(Math.max(2e3, Math.round(totalWidth * 0.06)), Math.floor(totalWidth / colCnt));
|
|
22896
22943
|
const cap = Math.round(totalWidth * 0.8);
|
|
22897
22944
|
const raw = colMax.map((w) => Math.min(Math.max(w + CELL_PAD, minW), cap));
|
|
22945
|
+
const floor = raw.map((r, i) => Math.min(Math.max(minW, (_nullishCoalesce(colMinWord[i], () => ( 0))) + CELL_PAD), r, cap));
|
|
22898
22946
|
const widths = Array(colCnt).fill(0);
|
|
22899
22947
|
const free = new Set(raw.map((_, i) => i));
|
|
22900
22948
|
let budget = totalWidth;
|
|
22901
|
-
|
|
22902
|
-
for (
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22949
|
+
let sumFloorFree = floor.reduce((a, b) => a + b, 0);
|
|
22950
|
+
for (const i of [...raw.keys()].sort((a, b) => raw[a] - raw[b])) {
|
|
22951
|
+
if (free.size <= 1) break;
|
|
22952
|
+
const fixed = Math.round(raw[i] * 1.12);
|
|
22953
|
+
if (budget - fixed < sumFloorFree - floor[i]) break;
|
|
22954
|
+
widths[i] = fixed;
|
|
22955
|
+
free.delete(i);
|
|
22956
|
+
budget -= fixed;
|
|
22957
|
+
sumFloorFree -= floor[i];
|
|
22958
|
+
}
|
|
22959
|
+
const sumFreeRaw = [...free].reduce((a, i) => a + raw[i], 0);
|
|
22960
|
+
if (budget > sumFreeRaw * 1.6) {
|
|
22911
22961
|
const sumRaw = raw.reduce((a, b) => a + b, 0);
|
|
22912
|
-
for (let i = 0; i < colCnt; i++) widths[i]
|
|
22962
|
+
for (let i = 0; i < colCnt; i++) widths[i] = raw[i] + Math.floor(raw[i] / sumRaw * (totalWidth - sumRaw));
|
|
22963
|
+
free.clear();
|
|
22913
22964
|
} else {
|
|
22914
22965
|
for (; ; ) {
|
|
22915
22966
|
const sum2 = [...free].reduce((a, i) => a + raw[i], 0);
|
|
22916
|
-
const short = [...free].filter((i) => raw[i] / sum2 * budget <
|
|
22967
|
+
const short = [...free].filter((i) => raw[i] / sum2 * budget < floor[i]);
|
|
22917
22968
|
if (short.length === 0) break;
|
|
22969
|
+
const shortSum = short.reduce((a, i) => a + floor[i], 0);
|
|
22970
|
+
const scale = Math.min(1, (budget - (free.size - short.length) * minW) / shortSum);
|
|
22918
22971
|
for (const i of short) {
|
|
22919
|
-
widths[i] = minW;
|
|
22972
|
+
widths[i] = Math.max(minW, Math.floor(floor[i] * scale));
|
|
22920
22973
|
free.delete(i);
|
|
22921
|
-
budget -=
|
|
22974
|
+
budget -= widths[i];
|
|
22922
22975
|
}
|
|
22923
22976
|
if (free.size === 0) break;
|
|
22924
22977
|
}
|
|
@@ -22945,18 +22998,21 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
22945
22998
|
function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
22946
22999
|
const rowCnt = rows.length;
|
|
22947
23000
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
22948
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23001
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _220 => _220.bfRegistry]), () => ( null));
|
|
22949
23002
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
22950
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
22951
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
23003
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _221 => _221.charHeight]), () => ( 1e3));
|
|
23004
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _222 => _222[0], 'optionalAccess', _223 => _223[0]]), () => ( ""))), seq);
|
|
22952
23005
|
const colMax = Array(colCnt).fill(0);
|
|
22953
23006
|
const colMaxBody = Array(colCnt).fill(0);
|
|
23007
|
+
const colMinWord = Array(colCnt).fill(0);
|
|
22954
23008
|
rows.forEach((row, r) => row.forEach((cell2, c) => {
|
|
22955
23009
|
const w = cellContentWidth(cell2, measureH);
|
|
22956
23010
|
if (w > colMax[c]) colMax[c] = w;
|
|
22957
23011
|
if (r > 0 && w > colMaxBody[c]) colMaxBody[c] = w;
|
|
23012
|
+
const mw = cellMinWordWidth(cell2, measureH);
|
|
23013
|
+
if (mw > colMinWord[c]) colMinWord[c] = mw;
|
|
22958
23014
|
}));
|
|
22959
|
-
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalW)));
|
|
23015
|
+
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalW, colMinWord)));
|
|
22960
23016
|
const colCentered = colWidths.map((w, c) => colMaxBody[c] + CELL_PAD <= w);
|
|
22961
23017
|
const labelCol0 = !!reg && colCnt === 2 && colCentered[0] && rows.every((r) => (_nullishCoalesce(r[0], () => ( ""))).replace(/\*\*|__|`/g, "").length <= 12);
|
|
22962
23018
|
const tblId = nextTableId();
|
|
@@ -22973,14 +23029,14 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22973
23029
|
const k = `${rowIdx},${colIdx}`;
|
|
22974
23030
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
22975
23031
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
22976
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23032
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _224 => _224.cellChar, 'access', _225 => _225.get, 'call', _226 => _226(k)]), () => ( defaultCharPr));
|
|
22977
23033
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
22978
23034
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
22979
23035
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
22980
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
23036
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _227 => _227.cellChar, 'access', _228 => _228.has, 'call', _229 => _229(k)]) ? void 0 : mapId);
|
|
22981
23037
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${runs || `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`}</hp:p>`;
|
|
22982
23038
|
}).join("");
|
|
22983
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23039
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _230 => _230.cellBf, 'access', _231 => _231.get, 'call', _232 => _232(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
22984
23040
|
row: rowIdx,
|
|
22985
23041
|
rowEnd: rowIdx,
|
|
22986
23042
|
col: colIdx,
|
|
@@ -22990,7 +23046,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22990
23046
|
headerRows: 1,
|
|
22991
23047
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
22992
23048
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
22993
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23049
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _233 => _233.cellH, 'access', _234 => _234.get, 'call', _235 => _235(k)]), () => ( cellH));
|
|
22994
23050
|
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="${style ? "CENTER" : "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="${colWidths[colIdx]}" height="${h}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
22995
23051
|
}).join("");
|
|
22996
23052
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -22999,7 +23055,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22999
23055
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
23000
23056
|
const tblInner = `<hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${tblH}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trElements;
|
|
23001
23057
|
const tbl2 = `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="${style ? 1 : 0}" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="2" noShading="0">${tblInner}</hp:tbl>`;
|
|
23002
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
23058
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _236 => _236.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
23003
23059
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
23004
23060
|
}
|
|
23005
23061
|
function layoutHtmlRows(rows) {
|
|
@@ -23030,28 +23086,31 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23030
23086
|
if (!rows || rows.length === 0) return null;
|
|
23031
23087
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
23032
23088
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
23033
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23089
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _237 => _237.charHeight]), () => ( 1e3));
|
|
23034
23090
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
23035
23091
|
const prof = takeProfile(remap, rowCnt, colCnt, first ? anchorOfHtmlCell(first.inner) : "", seq);
|
|
23036
23092
|
const colMax = Array(colCnt).fill(0);
|
|
23037
23093
|
const colMaxBody = Array(colCnt).fill(0);
|
|
23094
|
+
const colMinWord = Array(colCnt).fill(0);
|
|
23038
23095
|
const cellLines = placed.map((cell2) => htmlCellInnerToLines(cell2.inner).lines);
|
|
23039
23096
|
placed.forEach((cell2, i) => {
|
|
23040
23097
|
const w = Math.max(...cellLines[i].map((l) => measureTextWidth(unescapeHtml(l).trim(), measureH, 100)), 0) / cell2.colSpan;
|
|
23098
|
+
const mw = cell2.colSpan === 1 ? Math.max(...cellLines[i].map((l) => cellMinWordWidth(unescapeHtml(l), measureH)), 0) : 0;
|
|
23041
23099
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
23042
23100
|
const c = cell2.c + dc;
|
|
23043
23101
|
if (w > colMax[c]) colMax[c] = w;
|
|
23044
23102
|
if (!cell2.isHeader && w > colMaxBody[c]) colMaxBody[c] = w;
|
|
23103
|
+
if (dc === 0 && mw > colMinWord[c]) colMinWord[c] = mw;
|
|
23045
23104
|
}
|
|
23046
23105
|
});
|
|
23047
|
-
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalWidth)));
|
|
23106
|
+
const colWidths = _nullishCoalesce(profileColWidths(prof, colCnt), () => ( computeColWidths(colMax, totalWidth, colMinWord)));
|
|
23048
23107
|
const colCentered = colWidths.map((w, c) => colMaxBody[c] + CELL_PAD <= w);
|
|
23049
23108
|
const cellH = style ? Math.round(measureH * 1.6) + 282 : 1500;
|
|
23050
23109
|
const tblW = colWidths.reduce((a, b) => a + b, 0);
|
|
23051
23110
|
const tblId = nextTableId();
|
|
23052
23111
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
23053
23112
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
23054
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23113
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _238 => _238.bfRegistry]), () => ( null));
|
|
23055
23114
|
let htmlHeaderRows = 0;
|
|
23056
23115
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
23057
23116
|
const tcXmls = placed.map((cell2, i) => {
|
|
@@ -23060,7 +23119,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23060
23119
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
23061
23120
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
23062
23121
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
23063
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23122
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _239 => _239.cellChar, 'access', _240 => _240.get, 'call', _241 => _241(k)]), () => ( defaultCharPr));
|
|
23064
23123
|
const centered = isHeader || colCentered[cell2.c];
|
|
23065
23124
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
23066
23125
|
const lines = cellLines[i];
|
|
@@ -23080,8 +23139,8 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23080
23139
|
paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
23081
23140
|
}
|
|
23082
23141
|
const contentH = Math.max(cellH * cell2.rowSpan, Math.max(lines.length, 1) * (style ? Math.round(measureH * 1.6) : 800) + nestedH);
|
|
23083
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23084
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23142
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _242 => _242.cellH, 'access', _243 => _243.get, 'call', _244 => _244(k)]), () => ( 0)), contentH);
|
|
23143
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _245 => _245.cellBf, 'access', _246 => _246.get, 'call', _247 => _247(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
23085
23144
|
row: cell2.r,
|
|
23086
23145
|
rowEnd: cell2.r + cell2.rowSpan - 1,
|
|
23087
23146
|
col: cell2.c,
|
|
@@ -23156,6 +23215,118 @@ function buildTitleBox(title, titleCharPr, bodyWidth, reg) {
|
|
|
23156
23215
|
return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`;
|
|
23157
23216
|
}
|
|
23158
23217
|
|
|
23218
|
+
// src/hwpx/gen-docframe.ts
|
|
23219
|
+
function docframeIds(base) {
|
|
23220
|
+
return { org: base, sender: base + 1, foot: base + 2, small: base + 3, pressLabel: base + 4, pressHead: base + 5, pressTitle: base + 6, pressSub: base + 7, pressContact: base + 8 };
|
|
23221
|
+
}
|
|
23222
|
+
function docframeActive(g) {
|
|
23223
|
+
return !!(g.docHead || g.docFoot || g.reportInfo || g.noticeHead || g.press);
|
|
23224
|
+
}
|
|
23225
|
+
function docframeCharPrXmls(base, measured) {
|
|
23226
|
+
const body = measured ? 4 : 0;
|
|
23227
|
+
const ids = docframeIds(base);
|
|
23228
|
+
return [
|
|
23229
|
+
charPr(ids.org, 1800, true, false, body),
|
|
23230
|
+
charPr(ids.sender, 2200, true, false, body),
|
|
23231
|
+
charPr(ids.foot, 900, false, false, body),
|
|
23232
|
+
charPr(ids.small, 1200, false, false, body),
|
|
23233
|
+
charPr(ids.pressLabel, 2e3, true, false, body),
|
|
23234
|
+
charPr(ids.pressHead, 1e3, true, false, body),
|
|
23235
|
+
charPr(ids.pressTitle, 2500, true, false, body),
|
|
23236
|
+
charPr(ids.pressSub, 1500, true, false, body),
|
|
23237
|
+
charPr(ids.pressContact, 1e3, false, false, body)
|
|
23238
|
+
];
|
|
23239
|
+
}
|
|
23240
|
+
function labeled(label, value, paraPrId) {
|
|
23241
|
+
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_BOLD}"><hp:t>${escapeXml(label)}</hp:t></hp:run><hp:run charPrIDRef="${CHAR_NORMAL}"><hp:t>${escapeXml(value)}</hp:t></hp:run></hp:p>`;
|
|
23242
|
+
}
|
|
23243
|
+
function blank() {
|
|
23244
|
+
return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}"><hp:t></hp:t></hp:run></hp:p>`;
|
|
23245
|
+
}
|
|
23246
|
+
function buildDocHead(g, ids) {
|
|
23247
|
+
const h = g.docHead;
|
|
23248
|
+
const out = [];
|
|
23249
|
+
if (h.org) {
|
|
23250
|
+
out.push(para(h.org, GONGMUN_CENTER, ids.org), blank());
|
|
23251
|
+
}
|
|
23252
|
+
if (h.to !== void 0) out.push(labeled("\uC218\uC2E0 ", h.to, PARA_NORMAL));
|
|
23253
|
+
out.push(para(h.via ? `(\uACBD\uC720) ${h.via}` : "(\uACBD\uC720)", PARA_NORMAL, CHAR_NORMAL));
|
|
23254
|
+
if (h.title !== void 0) out.push(labeled("\uC81C\uBAA9 ", h.title, PARA_NORMAL));
|
|
23255
|
+
out.push(blank());
|
|
23256
|
+
return out;
|
|
23257
|
+
}
|
|
23258
|
+
var FOOT_SEP = "\u2500".repeat(46);
|
|
23259
|
+
function buildDocFoot(g, ids) {
|
|
23260
|
+
const f = g.docFoot;
|
|
23261
|
+
const out = [blank()];
|
|
23262
|
+
if (f.sender) {
|
|
23263
|
+
out.push(para(f.sender, GONGMUN_CENTER, ids.sender), blank());
|
|
23264
|
+
}
|
|
23265
|
+
const foot = (text) => para(text, GONGMUN_TBL_LEFT, ids.foot);
|
|
23266
|
+
out.push(foot(FOOT_SEP));
|
|
23267
|
+
if (f.drafter || f.reviewer || f.approver)
|
|
23268
|
+
out.push(foot(`\uAE30\uC548\uC790 ${_nullishCoalesce(f.drafter, () => ( ""))} \uAC80\uD1A0\uC790 ${_nullishCoalesce(f.reviewer, () => ( ""))} \uACB0\uC7AC\uAD8C\uC790 ${_nullishCoalesce(f.approver, () => ( ""))}`));
|
|
23269
|
+
if (f.cooperator) out.push(foot(`\uD611\uC870\uC790 ${f.cooperator}`));
|
|
23270
|
+
if (f.docNum || f.receive) out.push(foot(`\uC2DC\uD589 ${_nullishCoalesce(f.docNum, () => ( ""))} \uC811\uC218 ${_nullishCoalesce(f.receive, () => ( ""))}`));
|
|
23271
|
+
if (f.address || f.site) out.push(foot(`${_nullishCoalesce(f.address, () => ( ""))} / ${_nullishCoalesce(f.site, () => ( ""))}`));
|
|
23272
|
+
if (f.phone || f.fax || f.email || f.disclosure)
|
|
23273
|
+
out.push(foot(`\uC804\uD654 ${_nullishCoalesce(f.phone, () => ( ""))} \uC804\uC1A1 ${_nullishCoalesce(f.fax, () => ( ""))} / ${_nullishCoalesce(f.email, () => ( ""))} / ${_nullishCoalesce(f.disclosure, () => ( ""))}`));
|
|
23274
|
+
return out;
|
|
23275
|
+
}
|
|
23276
|
+
function buildReportInfo(g, ids) {
|
|
23277
|
+
return para(g.reportInfo, GONGMUN_RIGHT, ids.small);
|
|
23278
|
+
}
|
|
23279
|
+
function buildNoticeHead(g) {
|
|
23280
|
+
const n = g.noticeHead;
|
|
23281
|
+
return n.no ? [para(n.no, PARA_NORMAL, CHAR_BOLD), blank()] : [];
|
|
23282
|
+
}
|
|
23283
|
+
function buildNoticeFoot(g) {
|
|
23284
|
+
const n = g.noticeHead;
|
|
23285
|
+
const out = [];
|
|
23286
|
+
if (n.date) out.push(blank(), para(n.date, GONGMUN_RIGHT, CHAR_NORMAL));
|
|
23287
|
+
if (n.sender) out.push(blank(), para(n.sender, GONGMUN_RIGHT, CHAR_BOLD));
|
|
23288
|
+
return out;
|
|
23289
|
+
}
|
|
23290
|
+
var PRESS_LABEL_H = 3200;
|
|
23291
|
+
var PRESS_HEAD_H = 900;
|
|
23292
|
+
function buildPressHead(g, ids, bodyWidth, reg) {
|
|
23293
|
+
const p = g.press;
|
|
23294
|
+
const w = bodyWidth - 280;
|
|
23295
|
+
const thick = { t: "thick", b: "thick", l: "thick", r: "thick" };
|
|
23296
|
+
const rows = [tc({ bf: reg.get({ ...thick, b: "thin" }), row: 0, col: 0, w, h: PRESS_LABEL_H, paras: para("\uBCF4\uB3C4\uC790\uB8CC", GONGMUN_TBL_CENTER, ids.pressLabel) })];
|
|
23297
|
+
const headLine = [
|
|
23298
|
+
p.release ? `\uBCF4\uB3C4\uC2DC\uC810 : ${p.release}` : "",
|
|
23299
|
+
p.distribute ? `\uBC30\uD3EC : ${p.distribute}` : ""
|
|
23300
|
+
].filter(Boolean).join(" / ");
|
|
23301
|
+
if (headLine) rows.push(tc({ bf: reg.get({ ...thick, t: "thin" }), row: 1, col: 0, w, h: PRESS_HEAD_H, paras: para(headLine, GONGMUN_TBL_CENTER, ids.pressHead) }));
|
|
23302
|
+
const table2 = tbl(rows, w, PRESS_LABEL_H + (headLine ? PRESS_HEAD_H : 0), 1);
|
|
23303
|
+
return [`<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`, blank()];
|
|
23304
|
+
}
|
|
23305
|
+
function buildPressContact(g, ids, bodyWidth, reg) {
|
|
23306
|
+
const c = _optionalChain([g, 'access', _248 => _248.press, 'optionalAccess', _249 => _249.contact]);
|
|
23307
|
+
if (!c || !c.dept && !c.manager && !c.phone) return [];
|
|
23308
|
+
const w = bodyWidth - 280;
|
|
23309
|
+
const cells = [["\uB2F4\uB2F9 \uBD80\uC11C", _nullishCoalesce(c.dept, () => ( ""))], ["\uB2F4\uB2F9\uC790", _nullishCoalesce(c.manager, () => ( ""))], ["\uC5F0\uB77D\uCC98", _nullishCoalesce(c.phone, () => ( ""))]];
|
|
23310
|
+
const labelW = Math.round(w * 0.14);
|
|
23311
|
+
const valueW = Math.round(w / 3) - labelW;
|
|
23312
|
+
let col = 0;
|
|
23313
|
+
const row = cells.flatMap(([label, value], i) => {
|
|
23314
|
+
const bf = (first) => reg.get({
|
|
23315
|
+
t: "thick",
|
|
23316
|
+
b: "thick",
|
|
23317
|
+
l: first && i === 0 ? "thick" : "thin",
|
|
23318
|
+
r: !first && i === cells.length - 1 ? "thick" : "thin",
|
|
23319
|
+
fill: first ? "#E6E6E6" : void 0
|
|
23320
|
+
});
|
|
23321
|
+
return [
|
|
23322
|
+
tc({ bf: bf(true), row: 0, col: col++, w: labelW, h: 1100, paras: para(label, GONGMUN_TBL_CENTER, ids.pressHead) }),
|
|
23323
|
+
tc({ bf: bf(false), row: 0, col: col++, w: valueW, h: 1100, paras: para(value, GONGMUN_TBL_CENTER, ids.pressContact) })
|
|
23324
|
+
];
|
|
23325
|
+
});
|
|
23326
|
+
const table2 = tbl([row.join("")], w, 1100, cells.length * 2);
|
|
23327
|
+
return [blank(), `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${table2}</hp:run></hp:p>`];
|
|
23328
|
+
}
|
|
23329
|
+
|
|
23159
23330
|
// src/hwpx/equation-generate.ts
|
|
23160
23331
|
var MAX_EQUATION_SOURCE = 1e4;
|
|
23161
23332
|
var MAX_GROUP_DEPTH = 64;
|
|
@@ -23448,22 +23619,25 @@ function generateSecPr(gongmun) {
|
|
|
23448
23619
|
m.footer = gongmun.headerFooter;
|
|
23449
23620
|
}
|
|
23450
23621
|
const secPr = `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
|
|
23451
|
-
|
|
23622
|
+
const colPr = `<hp:ctrl><hp:colPr id="" type="NEWSPAPER" layout="LEFT" colCount="1" sameSz="1" sameGap="0"/></hp:ctrl>`;
|
|
23623
|
+
return secPr + colPr + (_optionalChain([gongmun, 'optionalAccess', _250 => _250.pageNumbers]) ? pageNumCtrl() : "");
|
|
23452
23624
|
}
|
|
23453
|
-
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null) {
|
|
23625
|
+
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null, dfIds = null) {
|
|
23454
23626
|
const paraXmls = [];
|
|
23455
23627
|
let isFirst = true;
|
|
23456
23628
|
let tableSeq = 0;
|
|
23457
23629
|
const orderedCounters = {};
|
|
23458
23630
|
let prevWasOrdered = false;
|
|
23459
|
-
const gaejosik = _optionalChain([gongmun, 'optionalAccess',
|
|
23631
|
+
const gaejosik = _optionalChain([gongmun, 'optionalAccess', _251 => _251.preset]) === "gaejosik";
|
|
23460
23632
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
23461
|
-
const vBase = charVariantBase(measured);
|
|
23633
|
+
const vBase = charVariantBase(measured, !!gongmun);
|
|
23462
23634
|
const tableStyle = gongmun ? {
|
|
23463
23635
|
totalWidth: mmToHwpunit(210 - gongmun.margins.left - gongmun.margins.right),
|
|
23464
|
-
|
|
23465
|
-
|
|
23466
|
-
|
|
23636
|
+
// 표 셀 크기 — 실측: 실측 프리셋 맑은 고딕 12pt(22·23), 비실측도 12pt(11·12,
|
|
23637
|
+
// 실결재 지배값 — 본문 크기 셀은 열폭 부족으로 서술 열 세로 신장, v4.0.2 QA)
|
|
23638
|
+
charPr: measured ? GJ_CHAR_TABLE : GONGMUN_TBL_CHAR,
|
|
23639
|
+
boldCharPr: measured ? GJ_CHAR_TABLE_BOLD : GONGMUN_TBL_CHAR_BOLD,
|
|
23640
|
+
charHeight: measured ? gaejosikSizes(gongmun.bodyHeight, gongmun.sizes).table : GONGMUN_TBL_PT,
|
|
23467
23641
|
headerBf: gongmunTableHeaderBf(gaejosik),
|
|
23468
23642
|
centerParaPr: GONGMUN_CENTER,
|
|
23469
23643
|
tblCenterParaPr: GONGMUN_TBL_CENTER,
|
|
@@ -23478,11 +23652,24 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23478
23652
|
let pendingPageBreak = false;
|
|
23479
23653
|
let pendingNewNum = false;
|
|
23480
23654
|
let titleBoxH1Idx = -1;
|
|
23655
|
+
let pressH1Idx = -1;
|
|
23481
23656
|
let hasFrontPages = false;
|
|
23482
23657
|
const preamble = [];
|
|
23483
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
23658
|
+
if (_optionalChain([gongmun, 'optionalAccess', _252 => _252.reportInfo]) && dfIds) {
|
|
23659
|
+
preamble.push(buildReportInfo(gongmun, dfIds));
|
|
23660
|
+
}
|
|
23661
|
+
if (_optionalChain([gongmun, 'optionalAccess', _253 => _253.approval]) && bfReg) {
|
|
23484
23662
|
preamble.push(buildApprovalTable(gongmun.approval, gongmun, bfReg));
|
|
23485
23663
|
}
|
|
23664
|
+
if (_optionalChain([gongmun, 'optionalAccess', _254 => _254.docHead]) && dfIds) {
|
|
23665
|
+
preamble.push(...buildDocHead(gongmun, dfIds));
|
|
23666
|
+
}
|
|
23667
|
+
if (_optionalChain([gongmun, 'optionalAccess', _255 => _255.noticeHead]) && dfIds) {
|
|
23668
|
+
preamble.push(...buildNoticeHead(gongmun));
|
|
23669
|
+
}
|
|
23670
|
+
if (_optionalChain([gongmun, 'optionalAccess', _256 => _256.press]) && dfIds && bfReg && tableStyle) {
|
|
23671
|
+
preamble.push(...buildPressHead(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
23672
|
+
}
|
|
23486
23673
|
if (gaejosik && gongmun) {
|
|
23487
23674
|
const h1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
23488
23675
|
const chapters = blocks.filter((b) => b.type === "heading" && b.level === 2).map((b) => stripChapterNumber(b.text || ""));
|
|
@@ -23507,6 +23694,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23507
23694
|
}
|
|
23508
23695
|
} else if (gongmun && !gaejosik && bfReg && (gongmun.preset === "report" || gongmun.preset === "plan" || gongmun.preset === "notice")) {
|
|
23509
23696
|
titleBoxH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
23697
|
+
} else if (_optionalChain([gongmun, 'optionalAccess', _257 => _257.press]) && dfIds) {
|
|
23698
|
+
pressH1Idx = blocks.findIndex((b) => b.type === "heading" && (_nullishCoalesce(b.level, () => ( 1))) === 1);
|
|
23510
23699
|
}
|
|
23511
23700
|
if (preamble.length > 0) {
|
|
23512
23701
|
preamble[0] = preamble[0].replace(` pageBreak="1"`, "").replace(/<hp:run charPrIDRef="(\d+)">/, `<hp:run charPrIDRef="$1">${generateSecPr(gongmun)}`);
|
|
@@ -23526,6 +23715,14 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23526
23715
|
}
|
|
23527
23716
|
switch (block.type) {
|
|
23528
23717
|
case "heading": {
|
|
23718
|
+
if (gongmun && blockIdx === pressH1Idx && dfIds) {
|
|
23719
|
+
const parts = [generateParagraph((block.text || "").trim(), GONGMUN_CENTER, dfIds.pressTitle)];
|
|
23720
|
+
for (const s of _nullishCoalesce(_optionalChain([gongmun, 'access', _258 => _258.press, 'optionalAccess', _259 => _259.sub]), () => ( []))) {
|
|
23721
|
+
parts.push(generateParagraph(`- ${s} -`, GONGMUN_CENTER, dfIds.pressSub));
|
|
23722
|
+
}
|
|
23723
|
+
xml = parts.join("\n ");
|
|
23724
|
+
break;
|
|
23725
|
+
}
|
|
23529
23726
|
if (gongmun && blockIdx === titleBoxH1Idx && tableStyle && bfReg) {
|
|
23530
23727
|
xml = buildTitleBox((block.text || "").trim(), measured ? GJ_CHAR_BODY_TITLE : CHAR_H1, tableStyle.totalWidth, bfReg);
|
|
23531
23728
|
break;
|
|
@@ -23544,7 +23741,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23544
23741
|
(id) => id === CHAR_BOLD ? GJ_CHAR_DAE_BOLD : id
|
|
23545
23742
|
);
|
|
23546
23743
|
} else {
|
|
23547
|
-
xml = generateParagraph(
|
|
23744
|
+
xml = generateParagraph(`${gongmun.bullet2} ${block.text || ""}`, GONGMUN_LIST_BASE + 1, CHAR_NORMAL);
|
|
23548
23745
|
}
|
|
23549
23746
|
break;
|
|
23550
23747
|
}
|
|
@@ -23560,7 +23757,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23560
23757
|
break;
|
|
23561
23758
|
}
|
|
23562
23759
|
case "paragraph": {
|
|
23563
|
-
|
|
23760
|
+
const pTrim = (block.text || "").trimStart();
|
|
23761
|
+
if (measured && (pTrim.startsWith("\u203B") || /^\*\s/.test(pTrim))) {
|
|
23564
23762
|
xml = generateParagraph((block.text || "").trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23565
23763
|
break;
|
|
23566
23764
|
}
|
|
@@ -23620,21 +23818,33 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23620
23818
|
case "list_item": {
|
|
23621
23819
|
if (gongmun && gongmunList) {
|
|
23622
23820
|
const info = gongmunList.get(blockIdx);
|
|
23623
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
23624
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
23821
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _260 => _260.depth]), () => ( 0));
|
|
23822
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _261 => _261.marker]), () => ( ""));
|
|
23625
23823
|
const content = block.text || "";
|
|
23626
23824
|
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
23627
23825
|
xml = generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23628
23826
|
break;
|
|
23629
23827
|
}
|
|
23828
|
+
if (measured && block.marker === "*") {
|
|
23829
|
+
xml = generateParagraph(`* ${content.trim()}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23830
|
+
break;
|
|
23831
|
+
}
|
|
23630
23832
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
23833
|
+
const listParaPr = marker2 ? GONGMUN_LIST_BASE + depth : GONGMUN_LIST_PLAIN_BASE + depth;
|
|
23631
23834
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
23632
23835
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
23633
23836
|
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
23634
23837
|
listCharPr = GJ_CHAR_DAE;
|
|
23635
23838
|
mapId = (id) => id === CHAR_BOLD ? GJ_CHAR_DAE_BOLD : id;
|
|
23636
23839
|
}
|
|
23637
|
-
|
|
23840
|
+
if (gongmun.preset === "press") {
|
|
23841
|
+
if (depth === 0) listCharPr = CHAR_NORMAL;
|
|
23842
|
+
if (depth >= 2 && dfIds) {
|
|
23843
|
+
listCharPr = dfIds.small;
|
|
23844
|
+
mapId = void 0;
|
|
23845
|
+
}
|
|
23846
|
+
}
|
|
23847
|
+
xml = generateParagraph(text, listParaPr, listCharPr, mapId);
|
|
23638
23848
|
break;
|
|
23639
23849
|
}
|
|
23640
23850
|
const indent = block.indent || 0;
|
|
@@ -23708,10 +23918,19 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23708
23918
|
}
|
|
23709
23919
|
paraXmls.push(xml);
|
|
23710
23920
|
}
|
|
23711
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
23712
|
-
|
|
23921
|
+
if (_optionalChain([gongmun, 'optionalAccess', _262 => _262.noticeHead]) && dfIds) {
|
|
23922
|
+
paraXmls.push(...buildNoticeFoot(gongmun));
|
|
23923
|
+
}
|
|
23924
|
+
if (_optionalChain([gongmun, 'optionalAccess', _263 => _263.endMark]) && paraXmls.length > 0) {
|
|
23925
|
+
const lastText = _nullishCoalesce(_optionalChain([[...blocks], 'access', _264 => _264.reverse, 'call', _265 => _265(), 'access', _266 => _266.find, 'call', _267 => _267((b) => (b.type === "paragraph" || b.type === "list_item") && (b.text || "").trim()), 'optionalAccess', _268 => _268.text]), () => ( ""));
|
|
23713
23926
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
23714
23927
|
}
|
|
23928
|
+
if (_optionalChain([gongmun, 'optionalAccess', _269 => _269.docFoot]) && dfIds) {
|
|
23929
|
+
paraXmls.push(...buildDocFoot(gongmun, dfIds));
|
|
23930
|
+
}
|
|
23931
|
+
if (_optionalChain([gongmun, 'optionalAccess', _270 => _270.press]) && dfIds && bfReg && tableStyle) {
|
|
23932
|
+
paraXmls.push(...buildPressContact(gongmun, dfIds, tableStyle.totalWidth, bfReg));
|
|
23933
|
+
}
|
|
23715
23934
|
if (paraXmls.length === 0) {
|
|
23716
23935
|
paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run></hp:p>`);
|
|
23717
23936
|
}
|
|
@@ -23723,30 +23942,39 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23723
23942
|
|
|
23724
23943
|
// src/hwpx/generator.ts
|
|
23725
23944
|
async function markdownToHwpx(markdown, options) {
|
|
23726
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
23727
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
23728
|
-
const gaejosik = _optionalChain([gongmun, 'optionalAccess',
|
|
23945
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _271 => _271.theme]));
|
|
23946
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _272 => _272.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
23947
|
+
const gaejosik = _optionalChain([gongmun, 'optionalAccess', _273 => _273.preset]) === "gaejosik";
|
|
23729
23948
|
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
23730
23949
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
23731
23950
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
23732
23951
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
23733
23952
|
const staticBfEnd = gongmun ? gaejosik ? 11 : 4 : 3;
|
|
23734
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
23735
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
23953
|
+
const remap = _optionalChain([options, 'optionalAccess', _274 => _274.profile]) ? buildProfileRemap(options.profile, charVariantBase(measured, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _275 => _275.variants, 'optionalAccess', _276 => _276.length]), () => ( 0))) * 4, staticBfEnd) : null;
|
|
23954
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _277 => _277.borderFillXmls, 'access', _278 => _278.length]), () => ( 0)))) : null;
|
|
23955
|
+
const dfActive = !!gongmun && docframeActive(gongmun);
|
|
23956
|
+
const dfBase = charVariantBase(measured, !!gongmun) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _279 => _279.variants, 'optionalAccess', _280 => _280.length]), () => ( 0))) * 4 + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _281 => _281.charPrXmls, 'access', _282 => _282.length]), () => ( 0)));
|
|
23957
|
+
const dfIds = dfActive ? docframeIds(dfBase) : null;
|
|
23736
23958
|
const chartParts = [];
|
|
23737
|
-
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap);
|
|
23959
|
+
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap, dfIds);
|
|
23738
23960
|
if (remap && remap.tables.length > 0) {
|
|
23739
23961
|
const unused = remap.tables.filter((t) => !t.used).length;
|
|
23740
23962
|
if (unused === remap.tables.length) {
|
|
23741
23963
|
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)`);
|
|
23742
23964
|
}
|
|
23743
23965
|
}
|
|
23744
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
23966
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _283 => _283.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _284 => _284.emit, 'call', _285 => _285()]), () => ( []))];
|
|
23745
23967
|
const zip = new (0, _jszip2.default)();
|
|
23746
23968
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
23747
23969
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
23748
23970
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
23749
|
-
zip.file("Contents/header.xml", generateHeaderXml(
|
|
23971
|
+
zip.file("Contents/header.xml", generateHeaderXml(
|
|
23972
|
+
theme,
|
|
23973
|
+
gongmun,
|
|
23974
|
+
_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _286 => _286.variants]), () => ( [])),
|
|
23975
|
+
extraBorderFills,
|
|
23976
|
+
[..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _287 => _287.charPrXmls]), () => ( [])), ...dfActive ? docframeCharPrXmls(dfBase, measured) : []]
|
|
23977
|
+
));
|
|
23750
23978
|
zip.file("Contents/section0.xml", sectionXml);
|
|
23751
23979
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
23752
23980
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -24040,7 +24268,7 @@ function parseRenderStyles(headXml) {
|
|
|
24040
24268
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
24041
24269
|
const textColor = el.getAttribute("textColor");
|
|
24042
24270
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
24043
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
24271
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _288 => _288.getAttribute, 'call', _289 => _289("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _290 => _290.getAttribute, 'call', _291 => _291("latin")])));
|
|
24044
24272
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
24045
24273
|
styles.charPr.set(id, {
|
|
24046
24274
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -24048,8 +24276,8 @@ function parseRenderStyles(headXml) {
|
|
|
24048
24276
|
italic: findChildByLocalName(el, "italic") != null,
|
|
24049
24277
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
24050
24278
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
24051
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
24052
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
24279
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _292 => _292.getAttribute, 'call', _293 => _293("hangul")])) || 100,
|
|
24280
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _294 => _294.getAttribute, 'call', _295 => _295("hangul")])) || 0,
|
|
24053
24281
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
24054
24282
|
});
|
|
24055
24283
|
}
|
|
@@ -24057,7 +24285,7 @@ function parseRenderStyles(headXml) {
|
|
|
24057
24285
|
const id = el.getAttribute("id");
|
|
24058
24286
|
if (id != null) {
|
|
24059
24287
|
const align = findChildByLocalName(el, "align");
|
|
24060
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
24288
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _296 => _296.getAttribute, 'call', _297 => _297("horizontal")]) || "JUSTIFY");
|
|
24061
24289
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
24062
24290
|
}
|
|
24063
24291
|
} else if (tag === "borderFill") {
|
|
@@ -24071,7 +24299,7 @@ function parseRenderStyles(headXml) {
|
|
|
24071
24299
|
};
|
|
24072
24300
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
24073
24301
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
24074
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
24302
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _298 => _298.getAttribute, 'call', _299 => _299("faceColor")]);
|
|
24075
24303
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
24076
24304
|
styles.borderFill.set(id, bf);
|
|
24077
24305
|
}
|
|
@@ -24143,7 +24371,7 @@ function collectSites(scan) {
|
|
|
24143
24371
|
}
|
|
24144
24372
|
function attrOf(openTag, name) {
|
|
24145
24373
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
24146
|
-
return _optionalChain([m, 'optionalAccess',
|
|
24374
|
+
return _optionalChain([m, 'optionalAccess', _300 => _300[1]]);
|
|
24147
24375
|
}
|
|
24148
24376
|
function paraOpenTag(xml, para2) {
|
|
24149
24377
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -24158,7 +24386,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
24158
24386
|
if (!tr) return null;
|
|
24159
24387
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
24160
24388
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
24161
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
24389
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _301 => _301[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
24162
24390
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
24163
24391
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
24164
24392
|
if (close === -1) return null;
|
|
@@ -24185,7 +24413,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
24185
24413
|
if (width === null) return null;
|
|
24186
24414
|
let content = width;
|
|
24187
24415
|
const win = cellAddrWindow(xml, cell2);
|
|
24188
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
24416
|
+
const mg = _optionalChain([win, 'optionalAccess', _302 => _302.match, 'call', _303 => _303(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
24189
24417
|
if (mg) {
|
|
24190
24418
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
24191
24419
|
}
|
|
@@ -24219,11 +24447,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
24219
24447
|
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>`;
|
|
24220
24448
|
}
|
|
24221
24449
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
24222
|
-
if (ops.length === 0) throw new (0,
|
|
24450
|
+
if (ops.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
24223
24451
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
24224
24452
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
24225
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
24226
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
24453
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _304 => _304.match, 'call', _305 => _305(/(\d+)\.xml$/i), 'optionalAccess', _306 => _306[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _307 => _307.match, 'call', _308 => _308(/(\d+)\.xml$/i), 'optionalAccess', _309 => _309[1]]), () => ( 0))));
|
|
24454
|
+
if (sectionPaths.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
24227
24455
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
24228
24456
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
24229
24457
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -24264,11 +24492,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24264
24492
|
const manifestItems = [];
|
|
24265
24493
|
const placed = [];
|
|
24266
24494
|
for (const op of ops) {
|
|
24267
|
-
if (!op.anchor) throw new (0,
|
|
24268
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
24495
|
+
if (!op.anchor) throw new (0, _chunkWN7LZHIIcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
24496
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
24269
24497
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
24270
|
-
if (!MIME[ext]) throw new (0,
|
|
24271
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
24498
|
+
if (!MIME[ext]) throw new (0, _chunkWN7LZHIIcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
24499
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkWN7LZHIIcjs.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)`);
|
|
24272
24500
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
24273
24501
|
let found = null;
|
|
24274
24502
|
let total = 0;
|
|
@@ -24301,7 +24529,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24301
24529
|
}
|
|
24302
24530
|
}
|
|
24303
24531
|
}
|
|
24304
|
-
throw new (0,
|
|
24532
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)(
|
|
24305
24533
|
`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)})`
|
|
24306
24534
|
);
|
|
24307
24535
|
}
|
|
@@ -24309,9 +24537,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24309
24537
|
const xml = sectionXmls[si];
|
|
24310
24538
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
24311
24539
|
if (!run) {
|
|
24312
|
-
throw new (0,
|
|
24540
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
24313
24541
|
}
|
|
24314
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
24542
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _310 => _310.charPr, 'access', _311 => _311.get, 'call', _312 => _312(run.charPr), 'optionalAccess', _313 => _313.height]), () => ( 1e3));
|
|
24315
24543
|
const fontPt = charPrHeight / 100;
|
|
24316
24544
|
const emMm = fontPt * 25.4 / 72;
|
|
24317
24545
|
const lineHMm = emMm;
|
|
@@ -24320,7 +24548,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24320
24548
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
24321
24549
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
24322
24550
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
24323
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
24551
|
+
const align = _optionalChain([styles, 'optionalAccess', _314 => _314.paraAlign, 'access', _315 => _315.get, 'call', _316 => _316(paraPrId)]);
|
|
24324
24552
|
let alignShiftMm = 0;
|
|
24325
24553
|
if (align === "CENTER" || align === "RIGHT") {
|
|
24326
24554
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -24416,7 +24644,7 @@ function parseBorderFills(headerDoc) {
|
|
|
24416
24644
|
};
|
|
24417
24645
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
24418
24646
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
24419
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
24647
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _317 => _317.getAttribute, 'call', _318 => _318("faceColor")]);
|
|
24420
24648
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
24421
24649
|
map.set(id, def);
|
|
24422
24650
|
}
|
|
@@ -24436,7 +24664,7 @@ function parseCharPrs(headerDoc) {
|
|
|
24436
24664
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
24437
24665
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
24438
24666
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
24439
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
24667
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _319 => _319.getAttribute, 'call', _320 => _320("hangul")]);
|
|
24440
24668
|
if (hangul) def.fontRef_hangul = hangul;
|
|
24441
24669
|
map.set(id, def);
|
|
24442
24670
|
}
|
|
@@ -24460,7 +24688,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
24460
24688
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
24461
24689
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
24462
24690
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
24463
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
24691
|
+
const width = _optionalChain([sz, 'optionalAccess', _321 => _321.getAttribute, 'call', _322 => _322("width")]) || void 0;
|
|
24464
24692
|
const cells = [];
|
|
24465
24693
|
const usedBf = /* @__PURE__ */ new Set();
|
|
24466
24694
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -24471,16 +24699,16 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
24471
24699
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
24472
24700
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
24473
24701
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
24474
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
24475
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
24702
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _323 => _323.getAttribute, 'call', _324 => _324("rowAddr")])), () => ( 0));
|
|
24703
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _325 => _325.getAttribute, 'call', _326 => _326("colAddr")])), () => ( 0));
|
|
24476
24704
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
24477
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
24478
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
24705
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _327 => _327.getAttribute, 'call', _328 => _328("colSpan")])), () => ( 1));
|
|
24706
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _329 => _329.getAttribute, 'call', _330 => _330("rowSpan")])), () => ( 1));
|
|
24479
24707
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
24480
24708
|
const cpId = firstRunCharPr(tc2);
|
|
24481
24709
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
24482
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
24483
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
24710
|
+
const w = _optionalChain([csz, 'optionalAccess', _331 => _331.getAttribute, 'call', _332 => _332("width")]);
|
|
24711
|
+
const hh = _optionalChain([csz, 'optionalAccess', _333 => _333.getAttribute, 'call', _334 => _334("height")]);
|
|
24484
24712
|
if (w) cell2.width_hwpunit = w;
|
|
24485
24713
|
if (hh) cell2.height_hwpunit = hh;
|
|
24486
24714
|
if (bfId) {
|
|
@@ -24553,16 +24781,16 @@ function pick(map, keys) {
|
|
|
24553
24781
|
return out;
|
|
24554
24782
|
}
|
|
24555
24783
|
async function hwpxToProfile(input) {
|
|
24556
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
24784
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkWN7LZHIIcjs.toArrayBuffer.call(void 0, input);
|
|
24557
24785
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
24558
24786
|
const parser = createXmlParser();
|
|
24559
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
24787
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _335 => _335.file, 'call', _336 => _336(/[Hh]eader\.xml$/), 'optionalAccess', _337 => _337[0]])));
|
|
24560
24788
|
let headerXml = "<root/>";
|
|
24561
24789
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
24562
24790
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
24563
24791
|
const borderFills = parseBorderFills(headerDoc);
|
|
24564
24792
|
const charPrs = parseCharPrs(headerDoc);
|
|
24565
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
24793
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _338 => _338.name, 'access', _339 => _339.match, 'call', _340 => _340(/(\d+)\.xml$/), 'optionalAccess', _341 => _341[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _342 => _342.name, 'access', _343 => _343.match, 'call', _344 => _344(/(\d+)\.xml$/), 'optionalAccess', _345 => _345[1]]), () => ( null))), () => ( 0))));
|
|
24566
24794
|
const tables = [];
|
|
24567
24795
|
let tableIndex = 0;
|
|
24568
24796
|
for (const f of sectionFiles) {
|
|
@@ -24873,7 +25101,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
24873
25101
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
24874
25102
|
function patchTableRows(input) {
|
|
24875
25103
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
24876
|
-
const xml = _optionalChain([ctx, 'access',
|
|
25104
|
+
const xml = _optionalChain([ctx, 'access', _346 => _346.scans, 'access', _347 => _347[scanTable.sectionIndex], 'optionalAccess', _348 => _348.xml]);
|
|
24877
25105
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
24878
25106
|
const numRows = table2.rows;
|
|
24879
25107
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -25040,7 +25268,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
25040
25268
|
const rr = scanTable.rowRanges[template];
|
|
25041
25269
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
25042
25270
|
const scan = scanSectionXml(wrapped, 0);
|
|
25043
|
-
const row = _optionalChain([scan, 'access',
|
|
25271
|
+
const row = _optionalChain([scan, 'access', _349 => _349.tables, 'access', _350 => _350[0], 'optionalAccess', _351 => _351.rows, 'access', _352 => _352[0]]);
|
|
25044
25272
|
if (!row || row.length !== cells.length) return null;
|
|
25045
25273
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
25046
25274
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -25083,7 +25311,7 @@ function rowHeightOf(fragment) {
|
|
|
25083
25311
|
}
|
|
25084
25312
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
25085
25313
|
const from = scanTable.start + tblOpenLen;
|
|
25086
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
25314
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _353 => _353.rowRanges, 'access', _354 => _354[0], 'optionalAccess', _355 => _355.start]), () => ( from));
|
|
25087
25315
|
const slice = xml.slice(from, to);
|
|
25088
25316
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
25089
25317
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -25272,9 +25500,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
25272
25500
|
});
|
|
25273
25501
|
}
|
|
25274
25502
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
25275
|
-
const irCell = _optionalChain([table2, 'access',
|
|
25503
|
+
const irCell = _optionalChain([table2, 'access', _356 => _356.cells, 'access', _357 => _357[oc.gridR], 'optionalAccess', _358 => _358[oc.gridC]]);
|
|
25276
25504
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
25277
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
25505
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _359 => _359.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
25278
25506
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
25279
25507
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
25280
25508
|
}
|
|
@@ -25342,7 +25570,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25342
25570
|
};
|
|
25343
25571
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
25344
25572
|
if (!cell2) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
25345
|
-
const irCell = _optionalChain([table2, 'access',
|
|
25573
|
+
const irCell = _optionalChain([table2, 'access', _360 => _360.cells, 'access', _361 => _361[gridR], 'optionalAccess', _362 => _362[gridC]]);
|
|
25346
25574
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
25347
25575
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25348
25576
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25365,7 +25593,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25365
25593
|
if (newLines.length === 0) return 0;
|
|
25366
25594
|
const target = cell2.paragraphs[0];
|
|
25367
25595
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
25368
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
25596
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _363 => _363.scans, 'access', _364 => _364[target.sectionIndex], 'optionalAccess', _365 => _365.xml]));
|
|
25369
25597
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25370
25598
|
splices.push(...sp);
|
|
25371
25599
|
sectionIndex = target.sectionIndex;
|
|
@@ -25388,7 +25616,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25388
25616
|
}
|
|
25389
25617
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
25390
25618
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
25391
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
25619
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _366 => _366.scans, 'access', _367 => _367[nonEmpty[i].sectionIndex], 'optionalAccess', _368 => _368.xml]));
|
|
25392
25620
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25393
25621
|
splices.push(...sp);
|
|
25394
25622
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -25469,7 +25697,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
25469
25697
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
25470
25698
|
if (paths.length > 0) return paths;
|
|
25471
25699
|
}
|
|
25472
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
25700
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkWN7LZHIIcjs.compareSectionPaths);
|
|
25473
25701
|
}
|
|
25474
25702
|
function sectionPathsFromManifest(xml) {
|
|
25475
25703
|
const attr = (tag, name) => {
|
|
@@ -25479,7 +25707,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
25479
25707
|
const idToHref = /* @__PURE__ */ new Map();
|
|
25480
25708
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
25481
25709
|
const id = attr(m[1], "id");
|
|
25482
|
-
const href =
|
|
25710
|
+
const href = _chunkWN7LZHIIcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
25483
25711
|
if (id && href) idToHref.set(id, href);
|
|
25484
25712
|
}
|
|
25485
25713
|
const ordered = [];
|
|
@@ -25488,7 +25716,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
25488
25716
|
if (href) ordered.push(href);
|
|
25489
25717
|
}
|
|
25490
25718
|
if (ordered.length > 0) return ordered;
|
|
25491
|
-
return Array.from(idToHref.values()).sort(
|
|
25719
|
+
return Array.from(idToHref.values()).sort(_chunkWN7LZHIIcjs.compareSectionPaths);
|
|
25492
25720
|
}
|
|
25493
25721
|
|
|
25494
25722
|
// src/roundtrip/patcher.ts
|
|
@@ -25580,7 +25808,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
25580
25808
|
}
|
|
25581
25809
|
}
|
|
25582
25810
|
let verification;
|
|
25583
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25811
|
+
if (_optionalChain([options, 'optionalAccess', _369 => _369.verify]) !== false) {
|
|
25584
25812
|
try {
|
|
25585
25813
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
25586
25814
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -25598,17 +25826,17 @@ function buildOrigUnits(blocks) {
|
|
|
25598
25826
|
let chunk2;
|
|
25599
25827
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
25600
25828
|
const next = blocks[i + 1];
|
|
25601
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
25602
|
-
chunk2 =
|
|
25829
|
+
if (_optionalChain([next, 'optionalAccess', _370 => _370.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
25830
|
+
chunk2 = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
25603
25831
|
} else {
|
|
25604
|
-
chunk2 =
|
|
25832
|
+
chunk2 = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, [block]);
|
|
25605
25833
|
}
|
|
25606
25834
|
if (chunk2) {
|
|
25607
25835
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
25608
25836
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
25609
25837
|
for (let s = 0; s < subUnits.length; s++) {
|
|
25610
25838
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
25611
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
25839
|
+
if (block.type === "table" && _optionalChain([block, 'access', _371 => _371.table, 'optionalAccess', _372 => _372.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
25612
25840
|
u.role = "caption";
|
|
25613
25841
|
}
|
|
25614
25842
|
units.push(u);
|
|
@@ -25719,7 +25947,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
25719
25947
|
const ti = ctx.tableInsert;
|
|
25720
25948
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
25721
25949
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25722
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25950
|
+
if (!_optionalChain([mapping, 'optionalAccess', _373 => _373.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");
|
|
25723
25951
|
const para2 = mapping.para;
|
|
25724
25952
|
if (para2.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
|
|
25725
25953
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -25747,7 +25975,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
25747
25975
|
}
|
|
25748
25976
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
25749
25977
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25750
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25978
|
+
if (!_optionalChain([mapping, 'optionalAccess', _374 => _374.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)");
|
|
25751
25979
|
if (block.text && block.text.includes("\n")) {
|
|
25752
25980
|
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)");
|
|
25753
25981
|
}
|
|
@@ -25778,7 +26006,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
25778
26006
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25779
26007
|
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");
|
|
25780
26008
|
}
|
|
25781
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
26009
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _375 => _375.scans, 'access', _376 => _376[mapping.para.sectionIndex], 'optionalAccess', _377 => _377.xml]));
|
|
25782
26010
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25783
26011
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25784
26012
|
return 1;
|
|
@@ -25964,7 +26192,7 @@ var Surgeon = (_class5 = class {
|
|
|
25964
26192
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
25965
26193
|
findEntry(path) {
|
|
25966
26194
|
const parts = path.replace(/^\//, "").split("/");
|
|
25967
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
26195
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _378 => _378.entries, 'access', _379 => _379[0], 'optionalAccess', _380 => _380.child]), () => ( -1));
|
|
25968
26196
|
let current;
|
|
25969
26197
|
for (const part of parts) {
|
|
25970
26198
|
const search = (idx) => {
|
|
@@ -26177,8 +26405,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
26177
26405
|
parts.push(header, data);
|
|
26178
26406
|
};
|
|
26179
26407
|
for (let i = 0; i < recs.length; i++) {
|
|
26180
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
26181
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
26408
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _381 => _381.get, 'call', _382 => _382(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
26409
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _383 => _383.get, 'call', _384 => _384(i)]), () => ( recs[i].data)));
|
|
26182
26410
|
}
|
|
26183
26411
|
return Buffer.concat(parts);
|
|
26184
26412
|
}
|
|
@@ -26296,7 +26524,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26296
26524
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
26297
26525
|
}
|
|
26298
26526
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
26299
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
26527
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _385 => _385.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
26300
26528
|
let flags;
|
|
26301
26529
|
try {
|
|
26302
26530
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -26318,7 +26546,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26318
26546
|
const scans = [];
|
|
26319
26547
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
26320
26548
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
26321
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
26549
|
+
if (!_optionalChain([entry, 'optionalAccess', _386 => _386.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
26322
26550
|
let stream;
|
|
26323
26551
|
try {
|
|
26324
26552
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -26369,7 +26597,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26369
26597
|
}
|
|
26370
26598
|
}
|
|
26371
26599
|
let verification;
|
|
26372
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26600
|
+
if (_optionalChain([options, 'optionalAccess', _387 => _387.verify]) !== false) {
|
|
26373
26601
|
try {
|
|
26374
26602
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
26375
26603
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -26459,7 +26687,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
26459
26687
|
for (const [key, scanCell] of scanTable.cells) {
|
|
26460
26688
|
const comma = key.indexOf(",");
|
|
26461
26689
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
26462
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
26690
|
+
const irCell = _optionalChain([irTable, 'access', _388 => _388.cells, 'access', _389 => _389[r], 'optionalAccess', _390 => _390[c]]);
|
|
26463
26691
|
if (!irCell) continue;
|
|
26464
26692
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
26465
26693
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -26495,7 +26723,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
26495
26723
|
}
|
|
26496
26724
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
26497
26725
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
26498
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26726
|
+
if (!_optionalChain([mapping, 'optionalAccess', _391 => _391.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)");
|
|
26499
26727
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
26500
26728
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
26501
26729
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -26694,7 +26922,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
26694
26922
|
};
|
|
26695
26923
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
26696
26924
|
if (!cell2) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
26697
|
-
const irCell = _optionalChain([table2, 'access',
|
|
26925
|
+
const irCell = _optionalChain([table2, 'access', _392 => _392.cells, 'access', _393 => _393[gridR], 'optionalAccess', _394 => _394[gridC]]);
|
|
26698
26926
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
26699
26927
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
26700
26928
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -27086,7 +27314,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27086
27314
|
const block = st.blocks[blockIndex];
|
|
27087
27315
|
if (!block) return void 0;
|
|
27088
27316
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
27089
|
-
const para2 = _optionalChain([st, 'access',
|
|
27317
|
+
const para2 = _optionalChain([st, 'access', _395 => _395.paraMap, 'access', _396 => _396.get, 'call', _397 => _397(blockIndex), 'optionalAccess', _398 => _398.para]);
|
|
27090
27318
|
if (!para2) return void 0;
|
|
27091
27319
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
27092
27320
|
}
|
|
@@ -27111,7 +27339,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27111
27339
|
if (block.text && block.text.includes("\n")) {
|
|
27112
27340
|
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)" };
|
|
27113
27341
|
}
|
|
27114
|
-
if (!_optionalChain([st, 'access',
|
|
27342
|
+
if (!_optionalChain([st, 'access', _399 => _399.paraMap, 'access', _400 => _400.get, 'call', _401 => _401(blockIndex), 'optionalAccess', _402 => _402.para])) {
|
|
27115
27343
|
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)" };
|
|
27116
27344
|
}
|
|
27117
27345
|
return { capability: "text" };
|
|
@@ -27177,7 +27405,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27177
27405
|
continue;
|
|
27178
27406
|
}
|
|
27179
27407
|
if (block.type === "table" && block.table) {
|
|
27180
|
-
if (!_optionalChain([edit, 'access',
|
|
27408
|
+
if (!_optionalChain([edit, 'access', _403 => _403.cells, 'optionalAccess', _404 => _404.length])) {
|
|
27181
27409
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
27182
27410
|
continue;
|
|
27183
27411
|
}
|
|
@@ -27197,7 +27425,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27197
27425
|
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) });
|
|
27198
27426
|
continue;
|
|
27199
27427
|
}
|
|
27200
|
-
const irCell = _optionalChain([block, 'access',
|
|
27428
|
+
const irCell = _optionalChain([block, 'access', _405 => _405.table, 'access', _406 => _406.cells, 'access', _407 => _407[cellEdit.row], 'optionalAccess', _408 => _408[cellEdit.col]]);
|
|
27201
27429
|
if (!irCell) {
|
|
27202
27430
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
27203
27431
|
continue;
|
|
@@ -27253,7 +27481,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27253
27481
|
}
|
|
27254
27482
|
if (replacements.size === 0) {
|
|
27255
27483
|
let changes2;
|
|
27256
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27484
|
+
if (_optionalChain([options, 'optionalAccess', _409 => _409.verify]) !== false) {
|
|
27257
27485
|
const units = splitMarkdownUnits(st.markdown);
|
|
27258
27486
|
changes2 = diffUnitLists(units, units);
|
|
27259
27487
|
}
|
|
@@ -27274,7 +27502,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27274
27502
|
}
|
|
27275
27503
|
this.state = newState;
|
|
27276
27504
|
let changes;
|
|
27277
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27505
|
+
if (_optionalChain([options, 'optionalAccess', _410 => _410.verify]) !== false) {
|
|
27278
27506
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
27279
27507
|
}
|
|
27280
27508
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -27294,7 +27522,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27294
27522
|
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)");
|
|
27295
27523
|
}
|
|
27296
27524
|
const mapping = st.paraMap.get(blockIndex);
|
|
27297
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27525
|
+
if (!_optionalChain([mapping, 'optionalAccess', _411 => _411.para])) {
|
|
27298
27526
|
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)");
|
|
27299
27527
|
}
|
|
27300
27528
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -27314,14 +27542,14 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27314
27542
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27315
27543
|
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");
|
|
27316
27544
|
}
|
|
27317
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
27545
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _412 => _412.scans, 'access', _413 => _413[mapping.para.sectionIndex], 'optionalAccess', _414 => _414.xml]));
|
|
27318
27546
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27319
27547
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27320
27548
|
return 1;
|
|
27321
27549
|
}
|
|
27322
27550
|
}, _class6);
|
|
27323
27551
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
27324
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27552
|
+
const irCell = _optionalChain([table2, 'access', _415 => _415.cells, 'access', _416 => _416[r], 'optionalAccess', _417 => _417[c]]);
|
|
27325
27553
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
27326
27554
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
27327
27555
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -27405,11 +27633,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
27405
27633
|
breaks: false
|
|
27406
27634
|
});
|
|
27407
27635
|
function renderHtml(markdown, options) {
|
|
27408
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27409
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27636
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _418 => _418.preset]), () => ( "default"));
|
|
27637
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _419 => _419.extraCss]), () => ( "")));
|
|
27410
27638
|
const body = md.render(markdown);
|
|
27411
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
27412
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
27639
|
+
const watermark = _optionalChain([options, 'optionalAccess', _420 => _420.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
27640
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _421 => _421.watermark]) ? `
|
|
27413
27641
|
.watermark {
|
|
27414
27642
|
position: fixed;
|
|
27415
27643
|
top: 50%; left: 50%;
|
|
@@ -27440,13 +27668,13 @@ async function htmlToPdf(html, options) {
|
|
|
27440
27668
|
try {
|
|
27441
27669
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
27442
27670
|
} catch (e30) {
|
|
27443
|
-
throw new (0,
|
|
27671
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)(
|
|
27444
27672
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
27445
27673
|
);
|
|
27446
27674
|
}
|
|
27447
27675
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
27448
27676
|
if (!executablePath) {
|
|
27449
|
-
throw new (0,
|
|
27677
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)(
|
|
27450
27678
|
"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."
|
|
27451
27679
|
);
|
|
27452
27680
|
}
|
|
@@ -27458,10 +27686,10 @@ async function htmlToPdf(html, options) {
|
|
|
27458
27686
|
try {
|
|
27459
27687
|
const page = await browser.newPage();
|
|
27460
27688
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
27461
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
27689
|
+
const margin = _optionalChain([options, 'optionalAccess', _422 => _422.margin]);
|
|
27462
27690
|
const pdf = await page.pdf({
|
|
27463
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27464
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
27691
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _423 => _423.pageSize]), () => ( "A4")),
|
|
27692
|
+
landscape: _optionalChain([options, 'optionalAccess', _424 => _424.orientation]) === "landscape",
|
|
27465
27693
|
printBackground: true,
|
|
27466
27694
|
margin: margin ? {
|
|
27467
27695
|
top: toCss(margin.top),
|
|
@@ -27469,9 +27697,9 @@ async function htmlToPdf(html, options) {
|
|
|
27469
27697
|
bottom: toCss(margin.bottom),
|
|
27470
27698
|
left: toCss(margin.left)
|
|
27471
27699
|
} : void 0,
|
|
27472
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
27473
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27474
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27700
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _425 => _425.header]) || _optionalChain([options, 'optionalAccess', _426 => _426.footer])),
|
|
27701
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _427 => _427.header]), () => ( "<div></div>")),
|
|
27702
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _428 => _428.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
27475
27703
|
});
|
|
27476
27704
|
return Buffer.from(pdf);
|
|
27477
27705
|
} finally {
|
|
@@ -27505,7 +27733,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
27505
27733
|
return htmlToPdf(html, options);
|
|
27506
27734
|
}
|
|
27507
27735
|
async function blocksToPdf(blocks, options) {
|
|
27508
|
-
const markdown =
|
|
27736
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
27509
27737
|
return markdownToPdf(markdown, options);
|
|
27510
27738
|
}
|
|
27511
27739
|
|
|
@@ -27716,7 +27944,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
27716
27944
|
if (ln(p) !== "p") continue;
|
|
27717
27945
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
27718
27946
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
27719
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
27947
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _429 => _429.spaceBefore]), () => ( 0)));
|
|
27720
27948
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
27721
27949
|
if (res) {
|
|
27722
27950
|
const paraH = res.paraBottom - startV;
|
|
@@ -27825,7 +28053,7 @@ function buildPara(p) {
|
|
|
27825
28053
|
el: ch,
|
|
27826
28054
|
tag: cn,
|
|
27827
28055
|
index: chars.length,
|
|
27828
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
28056
|
+
inline: _optionalChain([pos, 'optionalAccess', _430 => _430.getAttribute, 'call', _431 => _431("treatAsChar")]) === "1",
|
|
27829
28057
|
width: w,
|
|
27830
28058
|
height: h
|
|
27831
28059
|
});
|
|
@@ -28077,15 +28305,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
28077
28305
|
const sx = ow > 0 ? w / ow : 1;
|
|
28078
28306
|
const sy = oh > 0 ? h / oh : 1;
|
|
28079
28307
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
28080
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
28081
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
28308
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _432 => _432.getAttribute, 'call', _433 => _433("style")]), () => ( "SOLID"));
|
|
28309
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _434 => _434.getAttribute, 'call', _435 => _435("color")]) || "#000000";
|
|
28082
28310
|
const hasStroke = lstyle !== "NONE";
|
|
28083
28311
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
28084
28312
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
28085
28313
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
28086
28314
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
28087
28315
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
28088
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
28316
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _436 => _436.getAttribute, 'call', _437 => _437("faceColor")]);
|
|
28089
28317
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
28090
28318
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
28091
28319
|
if (o.tag === "rect") {
|
|
@@ -28117,7 +28345,7 @@ function cellContentExtent(cell2) {
|
|
|
28117
28345
|
if (ln2(p) !== "p") continue;
|
|
28118
28346
|
const m = buildPara(p);
|
|
28119
28347
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
28120
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
28348
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _438 => _438.segs, 'access', _439 => _439[0], 'optionalAccess', _440 => _440.vertpos]), () => ( 0));
|
|
28121
28349
|
for (const o of m.objs) {
|
|
28122
28350
|
if (o.inline) {
|
|
28123
28351
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -28125,7 +28353,7 @@ function cellContentExtent(cell2) {
|
|
|
28125
28353
|
continue;
|
|
28126
28354
|
}
|
|
28127
28355
|
const pos = findChildByLocalName(o.el, "pos");
|
|
28128
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
28356
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _441 => _441.getAttribute, 'call', _442 => _442("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
28129
28357
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
28130
28358
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
28131
28359
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
@@ -28211,7 +28439,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
28211
28439
|
}));
|
|
28212
28440
|
for (const g of geom) {
|
|
28213
28441
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
28214
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
28442
|
+
if (_optionalChain([bf, 'optionalAccess', _443 => _443.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
28215
28443
|
}
|
|
28216
28444
|
for (const g of geom) {
|
|
28217
28445
|
const { c } = g;
|
|
@@ -28249,7 +28477,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
28249
28477
|
const sz = findChildByLocalName(pic, "sz");
|
|
28250
28478
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
28251
28479
|
const img = findFirst(pic, "img");
|
|
28252
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
28480
|
+
const ref = _optionalChain([img, 'optionalAccess', _444 => _444.getAttribute, 'call', _445 => _445("binaryItemIDRef")]);
|
|
28253
28481
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
28254
28482
|
if (!loaded) {
|
|
28255
28483
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -28288,7 +28516,7 @@ function readSectionGeom(root) {
|
|
|
28288
28516
|
const pagePr = findFirst(root, "pagePr");
|
|
28289
28517
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
28290
28518
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
28291
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
28519
|
+
if (_optionalChain([pagePr, 'optionalAccess', _446 => _446.getAttribute, 'call', _447 => _447("landscape")]) === "NARROWLY" && PW < PH) {
|
|
28292
28520
|
const t = PW;
|
|
28293
28521
|
PW = PH;
|
|
28294
28522
|
PH = t;
|
|
@@ -28346,17 +28574,17 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
28346
28574
|
return { pages: ctx.pages, pageH };
|
|
28347
28575
|
}
|
|
28348
28576
|
async function renderHwpxToSvg(input, options) {
|
|
28349
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28577
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _448 => _448.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
28350
28578
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
28351
|
-
|
|
28579
|
+
_chunkWN7LZHIIcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
28352
28580
|
let zip;
|
|
28353
28581
|
try {
|
|
28354
28582
|
zip = await _jszip2.default.loadAsync(input);
|
|
28355
28583
|
} catch (e31) {
|
|
28356
|
-
throw new (0,
|
|
28584
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
28357
28585
|
}
|
|
28358
28586
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
28359
|
-
if (secFiles.length === 0) throw new (0,
|
|
28587
|
+
if (secFiles.length === 0) throw new (0, _chunkWN7LZHIIcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
28360
28588
|
const warnings = [];
|
|
28361
28589
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
28362
28590
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -28364,7 +28592,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28364
28592
|
const secXmls = [];
|
|
28365
28593
|
for (const f of secFiles) {
|
|
28366
28594
|
const xml = await f.async("string");
|
|
28367
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
28595
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
28368
28596
|
secXmls.push(xml);
|
|
28369
28597
|
}
|
|
28370
28598
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -28388,7 +28616,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28388
28616
|
let href = binmap.get(ref);
|
|
28389
28617
|
if (!href) {
|
|
28390
28618
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
28391
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
28619
|
+
href = _optionalChain([cand, 'optionalAccess', _449 => _449.name]);
|
|
28392
28620
|
}
|
|
28393
28621
|
if (!href) continue;
|
|
28394
28622
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -28409,7 +28637,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28409
28637
|
styles,
|
|
28410
28638
|
images,
|
|
28411
28639
|
defs: [],
|
|
28412
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28640
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _450 => _450.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
28413
28641
|
warnings,
|
|
28414
28642
|
warned: /* @__PURE__ */ new Set(),
|
|
28415
28643
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -28419,7 +28647,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28419
28647
|
for (let si = 0; si < secXmls.length; si++) {
|
|
28420
28648
|
const secXml = secXmls[si];
|
|
28421
28649
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
28422
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
28650
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _451 => _451.reflow])) {
|
|
28423
28651
|
noCacheSkipped = true;
|
|
28424
28652
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
28425
28653
|
continue;
|
|
@@ -28431,14 +28659,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28431
28659
|
continue;
|
|
28432
28660
|
}
|
|
28433
28661
|
const geom = readSectionGeom(root);
|
|
28434
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28662
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _452 => _452.reflowMode]), () => ( "keep")));
|
|
28435
28663
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
28436
28664
|
}
|
|
28437
28665
|
if (rendered.length === 0) {
|
|
28438
28666
|
if (noCacheSkipped) {
|
|
28439
|
-
throw new (0,
|
|
28667
|
+
throw new (0, _chunkWN7LZHIIcjs.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)");
|
|
28440
28668
|
}
|
|
28441
|
-
throw new (0,
|
|
28669
|
+
throw new (0, _chunkWN7LZHIIcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
28442
28670
|
}
|
|
28443
28671
|
const GAP = 2400;
|
|
28444
28672
|
const clipDefs = [];
|
|
@@ -28470,17 +28698,17 @@ ${groups.join("\n")}
|
|
|
28470
28698
|
// src/index.ts
|
|
28471
28699
|
async function parse(input, options) {
|
|
28472
28700
|
let buffer;
|
|
28473
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
28701
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _453 => _453.filePath]) ? { ...options, filePath: input } : options;
|
|
28474
28702
|
if (typeof input === "string") {
|
|
28475
28703
|
try {
|
|
28476
28704
|
const buf = await _promises.readFile.call(void 0, input);
|
|
28477
|
-
buffer =
|
|
28705
|
+
buffer = _chunkWN7LZHIIcjs.toArrayBuffer.call(void 0, buf);
|
|
28478
28706
|
} catch (err) {
|
|
28479
28707
|
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}`;
|
|
28480
28708
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
28481
28709
|
}
|
|
28482
28710
|
} else if (Buffer.isBuffer(input)) {
|
|
28483
|
-
buffer =
|
|
28711
|
+
buffer = _chunkWN7LZHIIcjs.toArrayBuffer.call(void 0, input);
|
|
28484
28712
|
} else {
|
|
28485
28713
|
buffer = input;
|
|
28486
28714
|
}
|
|
@@ -28515,21 +28743,21 @@ async function parseHwp3(buffer, options) {
|
|
|
28515
28743
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
28516
28744
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
28517
28745
|
} catch (err) {
|
|
28518
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28746
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28519
28747
|
}
|
|
28520
28748
|
}
|
|
28521
28749
|
async function parseHwpx(buffer, options) {
|
|
28522
28750
|
try {
|
|
28523
28751
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
28524
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28752
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _454 => _454.length]) ? images : void 0 };
|
|
28525
28753
|
} catch (err) {
|
|
28526
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28754
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28527
28755
|
}
|
|
28528
28756
|
}
|
|
28529
28757
|
async function parseHwp(buffer, options) {
|
|
28530
28758
|
try {
|
|
28531
28759
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
28532
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
28760
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _455 => _455.filePath])) {
|
|
28533
28761
|
try {
|
|
28534
28762
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
28535
28763
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -28546,15 +28774,15 @@ async function parseHwp(buffer, options) {
|
|
|
28546
28774
|
} catch (e32) {
|
|
28547
28775
|
}
|
|
28548
28776
|
}
|
|
28549
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28777
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _456 => _456.length]) ? images : void 0 };
|
|
28550
28778
|
} catch (err) {
|
|
28551
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28779
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28552
28780
|
}
|
|
28553
28781
|
}
|
|
28554
28782
|
async function parsePdf(buffer, options) {
|
|
28555
28783
|
let parsePdfDocument;
|
|
28556
28784
|
try {
|
|
28557
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
28785
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-6AYYGX6J.cjs")));
|
|
28558
28786
|
parsePdfDocument = mod.parsePdfDocument;
|
|
28559
28787
|
} catch (e33) {
|
|
28560
28788
|
return {
|
|
@@ -28569,7 +28797,7 @@ async function parsePdf(buffer, options) {
|
|
|
28569
28797
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
28570
28798
|
} catch (err) {
|
|
28571
28799
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
28572
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28800
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err), isImageBased };
|
|
28573
28801
|
}
|
|
28574
28802
|
}
|
|
28575
28803
|
async function parseXlsx(buffer, options) {
|
|
@@ -28577,7 +28805,7 @@ async function parseXlsx(buffer, options) {
|
|
|
28577
28805
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
28578
28806
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
28579
28807
|
} catch (err) {
|
|
28580
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28808
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28581
28809
|
}
|
|
28582
28810
|
}
|
|
28583
28811
|
async function parseXls(buffer, options) {
|
|
@@ -28585,15 +28813,15 @@ async function parseXls(buffer, options) {
|
|
|
28585
28813
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
28586
28814
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
28587
28815
|
} catch (err) {
|
|
28588
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28816
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28589
28817
|
}
|
|
28590
28818
|
}
|
|
28591
28819
|
async function parseDocx(buffer, options) {
|
|
28592
28820
|
try {
|
|
28593
28821
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
28594
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28822
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _457 => _457.length]) ? images : void 0 };
|
|
28595
28823
|
} catch (err) {
|
|
28596
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28824
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28597
28825
|
}
|
|
28598
28826
|
}
|
|
28599
28827
|
async function parseHwpml(buffer, options) {
|
|
@@ -28601,16 +28829,16 @@ async function parseHwpml(buffer, options) {
|
|
|
28601
28829
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
28602
28830
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
28603
28831
|
} catch (err) {
|
|
28604
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28832
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkWN7LZHIIcjs.classifyError.call(void 0, err) };
|
|
28605
28833
|
}
|
|
28606
28834
|
}
|
|
28607
28835
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
28608
28836
|
let buffer;
|
|
28609
28837
|
if (typeof input === "string") {
|
|
28610
28838
|
const buf = await _promises.readFile.call(void 0, input);
|
|
28611
|
-
buffer =
|
|
28839
|
+
buffer = _chunkWN7LZHIIcjs.toArrayBuffer.call(void 0, buf);
|
|
28612
28840
|
} else if (Buffer.isBuffer(input)) {
|
|
28613
|
-
buffer =
|
|
28841
|
+
buffer = _chunkWN7LZHIIcjs.toArrayBuffer.call(void 0, input);
|
|
28614
28842
|
} else {
|
|
28615
28843
|
buffer = input;
|
|
28616
28844
|
}
|
|
@@ -28636,7 +28864,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
28636
28864
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
28637
28865
|
}
|
|
28638
28866
|
const fill = fillFormFields(parsed.blocks, values);
|
|
28639
|
-
const markdown =
|
|
28867
|
+
const markdown = _chunkWN7LZHIIcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
28640
28868
|
if (outputFormat === "hwpx") {
|
|
28641
28869
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
28642
28870
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -28704,5 +28932,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
28704
28932
|
|
|
28705
28933
|
|
|
28706
28934
|
|
|
28707
|
-
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
28935
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkWN7LZHIIcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkWN7LZHIIcjs.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.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; 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.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
28708
28936
|
//# sourceMappingURL=index.cjs.map
|