kordoc 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-URVKBXYK.js → -O3AWNVPH.js} +11 -7
- package/dist/{chunk-7ETIIYGI.js → chunk-33OUI7HC.js} +2 -2
- package/dist/{chunk-IA5UZZKV.js → chunk-3H3CVOZ3.js} +2 -2
- package/dist/{chunk-JUJEKFUF.js → chunk-C5ABJ7PB.js} +3 -3
- package/dist/{chunk-ZKG6SBHV.js → chunk-EH2KYFFO.js} +2 -2
- package/dist/{chunk-THZVBYHE.js → chunk-JMLK6NTW.js} +3 -3
- package/dist/{chunk-EBSCV3JC.cjs → chunk-NIZXIVEI.cjs} +2 -2
- package/dist/{chunk-EBSCV3JC.cjs.map → chunk-NIZXIVEI.cjs.map} +1 -1
- package/dist/{chunk-PGWAF755.js → chunk-SHVV3BD6.js} +200 -40
- package/dist/chunk-SHVV3BD6.js.map +1 -0
- package/dist/{chunk-DVUNWK6W.js → chunk-YEC7VG6O.js} +2 -2
- package/dist/cli.js +49 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +446 -286
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -4
- package/dist/index.d.ts +38 -4
- package/dist/index.js +195 -35
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +17 -13
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-6TV6JKHF.cjs → parser-44OPXZMP.cjs} +14 -14
- package/dist/{parser-6TV6JKHF.cjs.map → parser-44OPXZMP.cjs.map} +1 -1
- package/dist/{parser-NXHY37WH.js → parser-G433UZMX.js} +2 -2
- package/dist/{parser-LHUO6UUA.js → parser-ZOMDHCA7.js} +3 -3
- package/dist/render-SQVQBORJ.js +10 -0
- package/dist/seal-6E26L45Z.js +10 -0
- package/dist/{watch-PNXTAWDR.js → watch-UYT3ZCBM.js} +7 -7
- package/package.json +1 -1
- package/dist/chunk-PGWAF755.js.map +0 -1
- package/dist/render-T5O6QHBJ.js +0 -10
- package/dist/seal-7KNR5WFH.js +0 -10
- /package/dist/{-URVKBXYK.js.map → -O3AWNVPH.js.map} +0 -0
- /package/dist/{chunk-7ETIIYGI.js.map → chunk-33OUI7HC.js.map} +0 -0
- /package/dist/{chunk-IA5UZZKV.js.map → chunk-3H3CVOZ3.js.map} +0 -0
- /package/dist/{chunk-JUJEKFUF.js.map → chunk-C5ABJ7PB.js.map} +0 -0
- /package/dist/{chunk-ZKG6SBHV.js.map → chunk-EH2KYFFO.js.map} +0 -0
- /package/dist/{chunk-THZVBYHE.js.map → chunk-JMLK6NTW.js.map} +0 -0
- /package/dist/{chunk-DVUNWK6W.js.map → chunk-YEC7VG6O.js.map} +0 -0
- /package/dist/{parser-NXHY37WH.js.map → parser-G433UZMX.js.map} +0 -0
- /package/dist/{parser-LHUO6UUA.js.map → parser-ZOMDHCA7.js.map} +0 -0
- /package/dist/{render-T5O6QHBJ.js.map → render-SQVQBORJ.js.map} +0 -0
- /package/dist/{seal-7KNR5WFH.js.map → seal-6E26L45Z.js.map} +0 -0
- /package/dist/{watch-PNXTAWDR.js.map → watch-UYT3ZCBM.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkNIZXIVEIcjs = require('./chunk-NIZXIVEI.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.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 >= _chunkNIZXIVEIcjs.HEADING_RATIO_H1) level = 1;
|
|
620
|
+
else if (ratio >= _chunkNIZXIVEIcjs.HEADING_RATIO_H2) level = 2;
|
|
621
|
+
else if (ratio >= _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.MAX_COLS);
|
|
1379
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 (_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 _chunkNIZXIVEIcjs.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 (_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.compareSectionPaths);
|
|
2041
2041
|
}
|
|
2042
2042
|
function parseSectionPathsFromManifest(xml) {
|
|
2043
2043
|
const parser = createXmlParser();
|
|
2044
|
-
const doc = parser.parseFromString(
|
|
2044
|
+
const doc = parser.parseFromString(_chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.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
|
+
_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3918
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkNIZXIVEIcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3919
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3956
3956
|
if (_optionalChain([options, 'optionalAccess', _55 => _55.dedupeRunningHeaders])) {
|
|
3957
|
-
const deduped =
|
|
3957
|
+
const deduped = _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 >= _chunkNIZXIVEIcjs.HEADING_RATIO_H1) level = 1;
|
|
4034
|
+
else if (ratio >= _chunkNIZXIVEIcjs.HEADING_RATIO_H2) level = 2;
|
|
4035
|
+
else if (ratio >= _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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), _chunkNIZXIVEIcjs.MAX_ROWS);
|
|
4486
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.MAX_COLS);
|
|
4553
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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
|
+
_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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: _chunkNIZXIVEIcjs.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(_chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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
|
+
_chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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 = _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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, _chunkNIZXIVEIcjs.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);
|
|
@@ -20953,7 +20953,7 @@ function fitRatioForFewerLines(text, firstWidth, contWidth, height, baseRatio, m
|
|
|
20953
20953
|
}
|
|
20954
20954
|
|
|
20955
20955
|
// src/hwpx/gaejosik.ts
|
|
20956
|
-
var GAEJOSIK_BULLETS = ["\u25A1", "\u25CB", "
|
|
20956
|
+
var GAEJOSIK_BULLETS = ["\u25A1", "\u25CB", "-", "\u318D"];
|
|
20957
20957
|
function gaejosikMarker(depth) {
|
|
20958
20958
|
return GAEJOSIK_BULLETS[Math.min(depth, GAEJOSIK_BULLETS.length - 1)];
|
|
20959
20959
|
}
|
|
@@ -21100,6 +21100,9 @@ function normalizeGongmunPreset(preset) {
|
|
|
21100
21100
|
if (!preset) return "official";
|
|
21101
21101
|
return _nullishCoalesce(PRESET_ALIAS[preset.trim()], () => ( "official"));
|
|
21102
21102
|
}
|
|
21103
|
+
function usesReportFonts(preset) {
|
|
21104
|
+
return preset === "gaejosik" || preset === "report" || preset === "plan";
|
|
21105
|
+
}
|
|
21103
21106
|
function resolveGongmun(opts) {
|
|
21104
21107
|
const preset = normalizeGongmunPreset(opts.preset);
|
|
21105
21108
|
const d = PRESET_DEFAULTS[preset];
|
|
@@ -21128,7 +21131,9 @@ function resolveGongmun(opts) {
|
|
|
21128
21131
|
endMark: _nullishCoalesce(opts.endMark, () => ( preset === "official")),
|
|
21129
21132
|
approval: opts.approval && opts.approval.length > 0 ? opts.approval : null,
|
|
21130
21133
|
// 본문 제목박스 — 실측(GT3·GT12): 목차 뒤 본문 시작에 제목 반복. 표지 켜진 개조식 기본
|
|
21131
|
-
bodyTitleBox: _nullishCoalesce(opts.bodyTitleBox, () => ( (gaejosik && coverOn)))
|
|
21134
|
+
bodyTitleBox: _nullishCoalesce(opts.bodyTitleBox, () => ( (gaejosik && coverOn))),
|
|
21135
|
+
// h2 말머리 — 실측 보고서 양식(부처별 3종)의 섹션 제목이 곧 □ 대항목 (QA-2)
|
|
21136
|
+
h2Marker: _nullishCoalesce(opts.h2Marker, () => ( (preset === "report" || preset === "plan" ? "box" : "none")))
|
|
21132
21137
|
};
|
|
21133
21138
|
}
|
|
21134
21139
|
var HANGUL_INITIALS = [0, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18];
|
|
@@ -21273,10 +21278,10 @@ function headingCharPrId(level) {
|
|
|
21273
21278
|
if (level === 3) return CHAR_H3;
|
|
21274
21279
|
return CHAR_H4;
|
|
21275
21280
|
}
|
|
21276
|
-
function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_COLOR, ratioPct = 100
|
|
21281
|
+
function charPr(id, height, bold, italic, fontId = 0, textColor = DEFAULT_TEXT_COLOR, ratioPct = 100) {
|
|
21277
21282
|
const boldAttr = bold ? ` bold="1"` : "";
|
|
21278
21283
|
const italicAttr = italic ? ` italic="1"` : "";
|
|
21279
|
-
const effFont =
|
|
21284
|
+
const effFont = fontId;
|
|
21280
21285
|
const boldEl = bold ? `<hh:bold/>` : "";
|
|
21281
21286
|
return ` <hh:charPr id="${id}" height="${height}" textColor="${textColor}" shadeColor="none" useFontSpace="0" useKerning="0" symMark="NONE" borderFillIDRef="1"${boldAttr}${italicAttr}>
|
|
21282
21287
|
<hh:fontRef hangul="${effFont}" latin="${effFont}" hanja="${effFont}" japanese="${effFont}" other="${effFont}" symbol="${effFont}" user="${effFont}"/>
|
|
@@ -21367,8 +21372,8 @@ function pageHidingCtrl(hideHeader = false) {
|
|
|
21367
21372
|
return `<hp:ctrl><hp:pageHiding hideHeader="${hideHeader ? 1 : 0}" hideFooter="0" hideMasterPage="0" hideBorder="0" hideFill="0" hidePageNum="1"/></hp:ctrl>`;
|
|
21368
21373
|
}
|
|
21369
21374
|
var CHAR_VARIANT_BASE = 11;
|
|
21370
|
-
function charVariantBase(
|
|
21371
|
-
return
|
|
21375
|
+
function charVariantBase(measured) {
|
|
21376
|
+
return measured ? CHAR_VARIANT_BASE + GJ_CHAR_COUNT : CHAR_VARIANT_BASE;
|
|
21372
21377
|
}
|
|
21373
21378
|
var GONGMUN_BODY_RATIO = 95;
|
|
21374
21379
|
|
|
@@ -21616,7 +21621,7 @@ function generateManifest(chartParts = []) {
|
|
|
21616
21621
|
</opf:package>`;
|
|
21617
21622
|
}
|
|
21618
21623
|
function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls = []) {
|
|
21619
|
-
const
|
|
21624
|
+
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
21620
21625
|
let body = 1e3, code = 900, h1 = 1800, h2 = 1400, h3 = 1200, h4 = 1100;
|
|
21621
21626
|
if (gongmun) {
|
|
21622
21627
|
body = gongmun.bodyHeight;
|
|
@@ -21626,7 +21631,9 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21626
21631
|
h3 = body;
|
|
21627
21632
|
h4 = Math.max(body - 100, 1300);
|
|
21628
21633
|
}
|
|
21629
|
-
const bodyFont =
|
|
21634
|
+
const bodyFont = measured ? 4 : 0;
|
|
21635
|
+
const hFont = measured ? 3 : 1;
|
|
21636
|
+
const hBold = !measured;
|
|
21630
21637
|
const bodyRatio = gongmun ? GONGMUN_BODY_RATIO : 100;
|
|
21631
21638
|
const rows = [
|
|
21632
21639
|
charPr(0, body, false, false, bodyFont, theme.body, bodyRatio),
|
|
@@ -21634,25 +21641,25 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21634
21641
|
charPr(2, body, false, true, bodyFont, theme.body, bodyRatio),
|
|
21635
21642
|
charPr(3, body, true, true, bodyFont, theme.body, bodyRatio),
|
|
21636
21643
|
charPr(4, code, false, false, 1),
|
|
21637
|
-
charPr(5, h1,
|
|
21638
|
-
charPr(6, h2,
|
|
21639
|
-
charPr(7, h3,
|
|
21640
|
-
charPr(8, h4,
|
|
21644
|
+
charPr(5, h1, hBold, false, hFont, theme.h1),
|
|
21645
|
+
charPr(6, h2, hBold, false, hFont, theme.h2),
|
|
21646
|
+
charPr(7, h3, hBold, false, hFont, theme.h3),
|
|
21647
|
+
charPr(8, h4, hBold, false, hFont, theme.h4),
|
|
21641
21648
|
charPr(CHAR_TABLE_HEADER, body, theme.tableHeaderBold, false, bodyFont, theme.tableHeader),
|
|
21642
21649
|
charPr(CHAR_QUOTE, body, false, true, bodyFont, theme.quote)
|
|
21643
21650
|
];
|
|
21644
|
-
if (
|
|
21651
|
+
if (measured) {
|
|
21645
21652
|
const sz = gaejosikSizes(body, gongmun.sizes);
|
|
21646
21653
|
rows.push(
|
|
21647
21654
|
charPr(11, sz.dae, false, false, 3),
|
|
21648
21655
|
// □ HY헤드라인M
|
|
21649
|
-
charPr(12, sz.dae, true, false, 3
|
|
21656
|
+
charPr(12, sz.dae, true, false, 3),
|
|
21650
21657
|
// □ bold
|
|
21651
21658
|
charPr(13, sz.cham, false, false, 5),
|
|
21652
21659
|
// ※ 한양중고딕
|
|
21653
|
-
charPr(14, sz.cham, true, false, 5
|
|
21660
|
+
charPr(14, sz.cham, true, false, 5),
|
|
21654
21661
|
// ※ bold
|
|
21655
|
-
charPr(15, sz.chapter, true, false, 4, "#FFFFFF"
|
|
21662
|
+
charPr(15, sz.chapter, true, false, 4, "#FFFFFF"),
|
|
21656
21663
|
// 장 로마숫자(흰)
|
|
21657
21664
|
charPr(16, sz.chapter, false, false, 3),
|
|
21658
21665
|
// 장 제목
|
|
@@ -21660,15 +21667,15 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
21660
21667
|
// 표지 제목
|
|
21661
21668
|
charPr(18, sz.coverSub, false, false, 3),
|
|
21662
21669
|
// 표지 날짜·기관명
|
|
21663
|
-
charPr(19, sz.tocLabel, true, false, 3
|
|
21670
|
+
charPr(19, sz.tocLabel, true, false, 3),
|
|
21664
21671
|
// 목 차
|
|
21665
|
-
charPr(20, sz.tocRoman, true, false, 6
|
|
21672
|
+
charPr(20, sz.tocRoman, true, false, 6),
|
|
21666
21673
|
// 목차 로마숫자(한양신명조)
|
|
21667
21674
|
charPr(21, sz.tocItem, false, false, 3),
|
|
21668
21675
|
// 목차 항목
|
|
21669
21676
|
charPr(22, sz.table, false, false, 7),
|
|
21670
21677
|
// 표 셀(맑은 고딕 12pt)
|
|
21671
|
-
charPr(23, sz.table, true, false, 7
|
|
21678
|
+
charPr(23, sz.table, true, false, 7),
|
|
21672
21679
|
// 표 셀 bold
|
|
21673
21680
|
charPr(24, sz.bar, false, false, 4),
|
|
21674
21681
|
// 표지 바 셀 빈 문단(6pt)
|
|
@@ -21707,10 +21714,11 @@ ${base2.join("\n")}
|
|
|
21707
21714
|
}
|
|
21708
21715
|
const ls = gongmun.lineSpacing;
|
|
21709
21716
|
const titleAlign = gongmun.centerTitle ? "CENTER" : "LEFT";
|
|
21717
|
+
const h2Geom = gongmun.h2Marker !== "none" ? { spaceBefore: Math.round(gongmun.bodyHeight * 2), spaceAfter: 0, indent: -markerWidth(gongmun.h2Marker === "box" ? "\u25A1" : "1.", 1600) } : { spaceBefore: 600, spaceAfter: 150 };
|
|
21710
21718
|
const base = [
|
|
21711
21719
|
paraPr(0, { lineSpacing: ls, keepWord: true }),
|
|
21712
21720
|
paraPr(1, { align: titleAlign, spaceBefore: 400, spaceAfter: 400, lineSpacing: ls, keepWord: true }),
|
|
21713
|
-
paraPr(2, { align: "LEFT",
|
|
21721
|
+
paraPr(2, { align: "LEFT", ...h2Geom, lineSpacing: ls, keepWord: true }),
|
|
21714
21722
|
paraPr(3, { align: "LEFT", spaceBefore: 400, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
21715
21723
|
paraPr(4, { align: "LEFT", spaceBefore: 300, spaceAfter: 100, lineSpacing: ls, keepWord: true }),
|
|
21716
21724
|
paraPr(5, { align: "LEFT", lineSpacing: 130, indent: 400, keepWord: true }),
|
|
@@ -21739,6 +21747,11 @@ ${base2.join("\n")}
|
|
|
21739
21747
|
// 표지 장식 바 셀 빈 문단 — 저줄간격(실측 71%)으로 바 높이 818 안에 수납
|
|
21740
21748
|
paraPr(GJ_PARA_BAR, { align: "CENTER", lineSpacing: 70, keepWord: true })
|
|
21741
21749
|
);
|
|
21750
|
+
} else if (usesReportFonts(gongmun.preset)) {
|
|
21751
|
+
const cham = gaejosikChamIndent(gongmun.bodyHeight, gongmun.sizes);
|
|
21752
|
+
base.push(
|
|
21753
|
+
paraPr(GJ_PARA_CHAM, { align: "JUSTIFY", lineSpacing: ls, left: cham.left, indent: cham.indent, spaceBefore: gaejosikSpaceBefore(3, gongmun.bodyHeight), keepWord: true })
|
|
21754
|
+
);
|
|
21742
21755
|
}
|
|
21743
21756
|
return `<hh:paraProperties itemCnt="${base.length}">
|
|
21744
21757
|
${base.join("\n")}
|
|
@@ -21761,14 +21774,15 @@ function fontEntry(id, face, weight = 6) {
|
|
|
21761
21774
|
</hh:font>`;
|
|
21762
21775
|
}
|
|
21763
21776
|
function buildFontFaces(gongmun, bodyFace) {
|
|
21764
|
-
if (
|
|
21777
|
+
if (gongmun && usesReportFonts(gongmun.preset)) {
|
|
21765
21778
|
const ov = gongmun.fonts;
|
|
21779
|
+
const bodyDefault = gongmun.preset !== "gaejosik" && gongmun.bodyFont === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD734\uBA3C\uBA85\uC870";
|
|
21766
21780
|
const faces = [
|
|
21767
21781
|
"\uD568\uCD08\uB86C\uBC14\uD0D5",
|
|
21768
21782
|
"\uD568\uCD08\uB86C\uB3CB\uC6C0",
|
|
21769
21783
|
"HY\uACAC\uACE0\uB515",
|
|
21770
21784
|
_nullishCoalesce(ov.heading, () => ( "HY\uD5E4\uB4DC\uB77C\uC778M")),
|
|
21771
|
-
_nullishCoalesce(ov.body, () => (
|
|
21785
|
+
_nullishCoalesce(ov.body, () => ( bodyDefault)),
|
|
21772
21786
|
_nullishCoalesce(ov.ref, () => ( "\uD55C\uC591\uC911\uACE0\uB515")),
|
|
21773
21787
|
"\uD55C\uC591\uC2E0\uBA85\uC870",
|
|
21774
21788
|
_nullishCoalesce(ov.table, () => ( "\uB9D1\uC740 \uACE0\uB515"))
|
|
@@ -21821,7 +21835,7 @@ function buildBorderFills(gongmun, extra = []) {
|
|
|
21821
21835
|
borderFillEntry(1, {}),
|
|
21822
21836
|
borderFillEntry(2, { l: thin, r: thin, t: thin, b: thin })
|
|
21823
21837
|
];
|
|
21824
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
21838
|
+
if (_optionalChain([gongmun, 'optionalAccess', _192 => _192.preset]) === "gaejosik") {
|
|
21825
21839
|
const c = GAEJOSIK_COLORS;
|
|
21826
21840
|
const edge = ["0.12 mm", c.border];
|
|
21827
21841
|
const grayLine = ["0.1 mm", c.titleLine];
|
|
@@ -21865,7 +21879,7 @@ function buildStyles(gongmun) {
|
|
|
21865
21879
|
</hh:styles>`;
|
|
21866
21880
|
}
|
|
21867
21881
|
function generateHeaderXml(theme, gongmun, ratioVariants = [], extraBorderFills = [], extraCharPrXmls = []) {
|
|
21868
|
-
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess',
|
|
21882
|
+
const bodyFace = _nullishCoalesce(_optionalChain([gongmun, 'optionalAccess', _193 => _193.fonts, 'access', _194 => _194.body]), () => ( (_optionalChain([gongmun, 'optionalAccess', _195 => _195.bodyFont]) === "gothic" ? "\uB9D1\uC740 \uACE0\uB515" : "\uD568\uCD08\uB86C\uBC14\uD0D5")));
|
|
21869
21883
|
const charPropsXml = buildCharProperties(theme, gongmun, ratioVariants, extraCharPrXmls);
|
|
21870
21884
|
const paraPropsXml = buildParaProperties(gongmun);
|
|
21871
21885
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
@@ -21995,8 +22009,8 @@ function parseChartFence(text) {
|
|
|
21995
22009
|
const spec = chartSpec(type);
|
|
21996
22010
|
let finalSeries = spec.pie ? [series[0]] : series;
|
|
21997
22011
|
finalSeries = finalSeries.map((s) => ({ ...s }));
|
|
21998
|
-
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
21999
|
-
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess',
|
|
22012
|
+
const ptLen = Math.max(_nullishCoalesce(_optionalChain([cat, 'optionalAccess', _196 => _196.length]), () => ( 0)), ...finalSeries.map((s) => s.values.length));
|
|
22013
|
+
const catFinal = Array.from({ length: ptLen }, (_, i) => _nullishCoalesce(_optionalChain([cat, 'optionalAccess', _197 => _197[i]]), () => ( `\uD56D\uBAA9 ${i + 1}`)));
|
|
22000
22014
|
if (!spec.scatter) {
|
|
22001
22015
|
finalSeries = finalSeries.map((s) => ({ ...s, values: catFinal.map((_, i) => _nullishCoalesce(s.values[i], () => ( 0))) }));
|
|
22002
22016
|
}
|
|
@@ -22038,7 +22052,7 @@ function serSpPr(color, stroke) {
|
|
|
22038
22052
|
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>`;
|
|
22039
22053
|
}
|
|
22040
22054
|
function dPtXml(pointColors, pie) {
|
|
22041
|
-
if (!_optionalChain([pointColors, 'optionalAccess',
|
|
22055
|
+
if (!_optionalChain([pointColors, 'optionalAccess', _198 => _198.length])) return "";
|
|
22042
22056
|
return pointColors.map((col, i) => {
|
|
22043
22057
|
const f = chartColorFill(col);
|
|
22044
22058
|
if (!f) return "";
|
|
@@ -22218,8 +22232,8 @@ function buildGaejosikCover(title, gongmun) {
|
|
|
22218
22232
|
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 });
|
|
22219
22233
|
const tbl2 = table([topRow, titleRow, botRow], g.totalW, g.barH + g.titleH + g.botBarH, 3);
|
|
22220
22234
|
const host = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${tbl2}</hp:run></hp:p>`;
|
|
22221
|
-
const date = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22222
|
-
const org = _nullishCoalesce(_optionalChain([gongmun, 'access',
|
|
22235
|
+
const date = _nullishCoalesce(_optionalChain([gongmun, 'access', _199 => _199.cover, 'optionalAccess', _200 => _200.date]), () => ( formatGaejosikDate(/* @__PURE__ */ new Date())));
|
|
22236
|
+
const org = _nullishCoalesce(_optionalChain([gongmun, 'access', _201 => _201.cover, 'optionalAccess', _202 => _202.org]), () => ( ""));
|
|
22223
22237
|
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>`;
|
|
22224
22238
|
const subEmpty = emptyPara(GJ_PARA_COVER, false, GJ_CHAR_COVER_SUB);
|
|
22225
22239
|
return [
|
|
@@ -22452,7 +22466,7 @@ function escapeGfm(text) {
|
|
|
22452
22466
|
}
|
|
22453
22467
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
22454
22468
|
function sanitizeText(text) {
|
|
22455
|
-
let result =
|
|
22469
|
+
let result = _chunkNIZXIVEIcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
22456
22470
|
if (result.length <= 30 && result.includes(" ")) {
|
|
22457
22471
|
const tokens = result.split(" ");
|
|
22458
22472
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -22482,7 +22496,7 @@ function replicateGfmTable(table2) {
|
|
|
22482
22496
|
for (let r = 0; r < numRows; r++) {
|
|
22483
22497
|
for (let c = 0; c < numCols; c++) {
|
|
22484
22498
|
if (skip.has(`${r},${c}`)) continue;
|
|
22485
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
22499
|
+
const cell2 = _optionalChain([cells, 'access', _203 => _203[r], 'optionalAccess', _204 => _204[c]]);
|
|
22486
22500
|
if (!cell2) continue;
|
|
22487
22501
|
display[r][c] = {
|
|
22488
22502
|
text: escapeGfm(sanitizeText(cell2.text)).replace(/\|/g, "\\|").replace(/\n/g, "<br>"),
|
|
@@ -22536,7 +22550,7 @@ function unescapeGfmCell(text) {
|
|
|
22536
22550
|
return text.replace(/<br\s*\/?>/gi, "\n").replace(/\\\|/g, "|").replace(/\\([~*])/g, "$1");
|
|
22537
22551
|
}
|
|
22538
22552
|
function replicateCellInnerHtml(cell2) {
|
|
22539
|
-
if (_optionalChain([cell2, 'access',
|
|
22553
|
+
if (_optionalChain([cell2, 'access', _205 => _205.blocks, 'optionalAccess', _206 => _206.length])) {
|
|
22540
22554
|
return cell2.blocks.map((b) => {
|
|
22541
22555
|
if (b.type === "table" && b.table) {
|
|
22542
22556
|
const cap = b.table.caption ? sanitizeText(b.table.caption) : "";
|
|
@@ -22575,7 +22589,7 @@ function replicateHtmlTable(table2) {
|
|
|
22575
22589
|
const rowCells = [];
|
|
22576
22590
|
for (let c = 0; c < numCols; c++) {
|
|
22577
22591
|
if (skip.has(`${r},${c}`)) continue;
|
|
22578
|
-
const cell2 = _optionalChain([cells, 'access',
|
|
22592
|
+
const cell2 = _optionalChain([cells, 'access', _207 => _207[r], 'optionalAccess', _208 => _208[c]]);
|
|
22579
22593
|
if (!cell2) continue;
|
|
22580
22594
|
for (let dr = 0; dr < cell2.rowSpan; dr++) {
|
|
22581
22595
|
for (let dc = 0; dc < cell2.colSpan; dc++) {
|
|
@@ -22621,8 +22635,8 @@ function parseHtmlTable(raw) {
|
|
|
22621
22635
|
}
|
|
22622
22636
|
} else {
|
|
22623
22637
|
if (!isClose) {
|
|
22624
|
-
const cs = parseInt(_optionalChain([attrs, 'access',
|
|
22625
|
-
const rs = parseInt(_optionalChain([attrs, 'access',
|
|
22638
|
+
const cs = parseInt(_optionalChain([attrs, 'access', _209 => _209.match, 'call', _210 => _210(/colspan\s*=\s*"(\d+)"/i), 'optionalAccess', _211 => _211[1]]) || "1", 10);
|
|
22639
|
+
const rs = parseInt(_optionalChain([attrs, 'access', _212 => _212.match, 'call', _213 => _213(/rowspan\s*=\s*"(\d+)"/i), 'optionalAccess', _214 => _214[1]]) || "1", 10);
|
|
22626
22640
|
cellStart = m.index + m[0].length;
|
|
22627
22641
|
cellInfo = { colSpan: isNaN(cs) ? 1 : cs, rowSpan: isNaN(rs) ? 1 : rs };
|
|
22628
22642
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
@@ -22767,7 +22781,7 @@ function edgeXml(tag, d) {
|
|
|
22767
22781
|
return d ? `<hh:${tag} type="${d.type}" width="${d.width}" color="${d.color}"/>` : `<hh:${tag} type="NONE" width="0.1 mm" color="#000000"/>`;
|
|
22768
22782
|
}
|
|
22769
22783
|
function borderFillDefToXml(id, def) {
|
|
22770
|
-
const fill = _optionalChain([def, 'access',
|
|
22784
|
+
const fill = _optionalChain([def, 'access', _215 => _215.fill, 'optionalAccess', _216 => _216.faceColor]) ? `<hh:fillBrush><hh:winBrush faceColor="${def.fill.faceColor}" hatchColor="#000000" alpha="0"/></hh:fillBrush>` : "";
|
|
22771
22785
|
return ` <hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="NONE" breakCellSeparateLine="0">
|
|
22772
22786
|
<hh:slash type="NONE" Crooked="0" isCounter="0"/>
|
|
22773
22787
|
<hh:backSlash type="NONE" Crooked="0" isCounter="0"/>
|
|
@@ -22931,10 +22945,10 @@ function estimateRowHeight(cells, widths, charHeight) {
|
|
|
22931
22945
|
function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
22932
22946
|
const rowCnt = rows.length;
|
|
22933
22947
|
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
22934
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
22948
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _217 => _217.bfRegistry]), () => ( null));
|
|
22935
22949
|
const totalW = style ? reg ? style.totalWidth - DATA_TABLE_INSET : style.totalWidth : 44e3;
|
|
22936
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
22937
|
-
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access',
|
|
22950
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _218 => _218.charHeight]), () => ( 1e3));
|
|
22951
|
+
const prof = takeProfile(remap, rowCnt, colCnt, anchorOfMarkdownCell(_nullishCoalesce(_optionalChain([rows, 'access', _219 => _219[0], 'optionalAccess', _220 => _220[0]]), () => ( ""))), seq);
|
|
22938
22952
|
const colMax = Array(colCnt).fill(0);
|
|
22939
22953
|
const colMaxBody = Array(colCnt).fill(0);
|
|
22940
22954
|
rows.forEach((row, r) => row.forEach((cell2, c) => {
|
|
@@ -22959,14 +22973,14 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22959
22973
|
const k = `${rowIdx},${colIdx}`;
|
|
22960
22974
|
const isLabelCell2 = labelCol0 && colIdx === 0;
|
|
22961
22975
|
const defaultCharPr = style ? reg && (isHeaderRow || isLabelCell2) ? style.boldCharPr : style.charPr : isHeaderRow ? headerCharPr : baseCharPr;
|
|
22962
|
-
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22976
|
+
const cellCharPr = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _221 => _221.cellChar, 'access', _222 => _222.get, 'call', _223 => _223(k)]), () => ( defaultCharPr));
|
|
22963
22977
|
const centered = isHeaderRow || colCentered[colIdx];
|
|
22964
22978
|
const paraPrId = style ? centered ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
22965
22979
|
const p = cell2.split(/<br\s*\/?>/i).map((seg) => {
|
|
22966
|
-
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess',
|
|
22980
|
+
const runs = generateRuns(seg, cellCharPr, _optionalChain([prof, 'optionalAccess', _224 => _224.cellChar, 'access', _225 => _225.has, 'call', _226 => _226(k)]) ? void 0 : mapId);
|
|
22967
22981
|
return `<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0">${runs || `<hp:run charPrIDRef="${cellCharPr}"><hp:t></hp:t></hp:run>`}</hp:p>`;
|
|
22968
22982
|
}).join("");
|
|
22969
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22983
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _227 => _227.cellBf, 'access', _228 => _228.get, 'call', _229 => _229(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
22970
22984
|
row: rowIdx,
|
|
22971
22985
|
rowEnd: rowIdx,
|
|
22972
22986
|
col: colIdx,
|
|
@@ -22976,7 +22990,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22976
22990
|
headerRows: 1,
|
|
22977
22991
|
fill: isHeaderRow ? _nullishCoalesce(style.headerFill, () => ( "#E6E6E6")) : isLabelCell2 ? _nullishCoalesce(style.labelFill, () => ( "#E7E7E7")) : void 0
|
|
22978
22992
|
})) : style && isHeaderRow ? style.headerBf : 2)));
|
|
22979
|
-
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
22993
|
+
const h = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _230 => _230.cellH, 'access', _231 => _231.get, 'call', _232 => _232(k)]), () => ( cellH));
|
|
22980
22994
|
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>`;
|
|
22981
22995
|
}).join("");
|
|
22982
22996
|
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
@@ -22985,7 +22999,7 @@ function generateTable(rows, theme, style = null, remap = null, seq = 0) {
|
|
|
22985
22999
|
const tblH = rowHeights.reduce((a, b) => a + b, 0);
|
|
22986
23000
|
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;
|
|
22987
23001
|
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>`;
|
|
22988
|
-
const hostPr = reg && _optionalChain([style, 'optionalAccess',
|
|
23002
|
+
const hostPr = reg && _optionalChain([style, 'optionalAccess', _233 => _233.rightParaPr]) !== void 0 ? style.rightParaPr : 0;
|
|
22989
23003
|
return `<hp:p paraPrIDRef="${hostPr}" styleIDRef="0"><hp:run charPrIDRef="0">${tbl2}</hp:run></hp:p>`;
|
|
22990
23004
|
}
|
|
22991
23005
|
function layoutHtmlRows(rows) {
|
|
@@ -23016,7 +23030,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23016
23030
|
if (!rows || rows.length === 0) return null;
|
|
23017
23031
|
const { placed, rowCnt, colCnt } = layoutHtmlRows(rows);
|
|
23018
23032
|
if (rowCnt === 0 || colCnt === 0) return null;
|
|
23019
|
-
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23033
|
+
const measureH = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _234 => _234.charHeight]), () => ( 1e3));
|
|
23020
23034
|
const first = _nullishCoalesce(placed.find((p) => p.r === 0 && p.c === 0), () => ( placed[0]));
|
|
23021
23035
|
const prof = takeProfile(remap, rowCnt, colCnt, first ? anchorOfHtmlCell(first.inner) : "", seq);
|
|
23022
23036
|
const colMax = Array(colCnt).fill(0);
|
|
@@ -23037,7 +23051,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23037
23051
|
const tblId = nextTableId();
|
|
23038
23052
|
const useHeaderStyle = !style && (theme.tableHeader !== theme.body || theme.tableHeaderBold);
|
|
23039
23053
|
const spanW = (cell2) => colWidths.slice(cell2.c, cell2.c + cell2.colSpan).reduce((a, b) => a + b, 0);
|
|
23040
|
-
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
23054
|
+
const reg = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _235 => _235.bfRegistry]), () => ( null));
|
|
23041
23055
|
let htmlHeaderRows = 0;
|
|
23042
23056
|
while (htmlHeaderRows < rows.length && rows[htmlHeaderRows].tag === "th") htmlHeaderRows++;
|
|
23043
23057
|
const tcXmls = placed.map((cell2, i) => {
|
|
@@ -23046,7 +23060,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23046
23060
|
const baseCharPr = style ? style.charPr : CHAR_NORMAL;
|
|
23047
23061
|
const headerCharPr = isHeader && useHeaderStyle ? CHAR_TABLE_HEADER : baseCharPr;
|
|
23048
23062
|
const defaultCharPr = style && reg && isHeader ? style.boldCharPr : isHeader ? headerCharPr : baseCharPr;
|
|
23049
|
-
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23063
|
+
const charPrId = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _236 => _236.cellChar, 'access', _237 => _237.get, 'call', _238 => _238(k)]), () => ( defaultCharPr));
|
|
23050
23064
|
const centered = isHeader || colCentered[cell2.c];
|
|
23051
23065
|
const paraPrId = style ? centered ? reg ? _nullishCoalesce(style.tblCenterParaPr, () => ( style.centerParaPr)) : style.centerParaPr : reg ? _nullishCoalesce(style.tblLeftParaPr, () => ( PARA_NORMAL)) : PARA_NORMAL : PARA_NORMAL;
|
|
23052
23066
|
const lines = cellLines[i];
|
|
@@ -23066,8 +23080,8 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
|
|
|
23066
23080
|
paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t></hp:t></hp:run></hp:p>`);
|
|
23067
23081
|
}
|
|
23068
23082
|
const contentH = Math.max(cellH * cell2.rowSpan, Math.max(lines.length, 1) * (style ? Math.round(measureH * 1.6) : 800) + nestedH);
|
|
23069
|
-
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23070
|
-
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess',
|
|
23083
|
+
const cellHeight = Math.max(_nullishCoalesce(_optionalChain([prof, 'optionalAccess', _239 => _239.cellH, 'access', _240 => _240.get, 'call', _241 => _241(k)]), () => ( 0)), contentH);
|
|
23084
|
+
const bf = _nullishCoalesce(_optionalChain([prof, 'optionalAccess', _242 => _242.cellBf, 'access', _243 => _243.get, 'call', _244 => _244(k)]), () => ( (reg ? reg.get(dataCellSpec({
|
|
23071
23085
|
row: cell2.r,
|
|
23072
23086
|
rowEnd: cell2.r + cell2.rowSpan - 1,
|
|
23073
23087
|
col: cell2.c,
|
|
@@ -23434,7 +23448,7 @@ function generateSecPr(gongmun) {
|
|
|
23434
23448
|
m.footer = gongmun.headerFooter;
|
|
23435
23449
|
}
|
|
23436
23450
|
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>`;
|
|
23437
|
-
return _optionalChain([gongmun, 'optionalAccess',
|
|
23451
|
+
return _optionalChain([gongmun, 'optionalAccess', _245 => _245.pageNumbers]) ? secPr + pageNumCtrl() : secPr;
|
|
23438
23452
|
}
|
|
23439
23453
|
function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null, bfReg = null, remap = null) {
|
|
23440
23454
|
const paraXmls = [];
|
|
@@ -23442,13 +23456,14 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23442
23456
|
let tableSeq = 0;
|
|
23443
23457
|
const orderedCounters = {};
|
|
23444
23458
|
let prevWasOrdered = false;
|
|
23445
|
-
const gaejosik = _optionalChain([gongmun, 'optionalAccess',
|
|
23446
|
-
const
|
|
23459
|
+
const gaejosik = _optionalChain([gongmun, 'optionalAccess', _246 => _246.preset]) === "gaejosik";
|
|
23460
|
+
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
23461
|
+
const vBase = charVariantBase(measured);
|
|
23447
23462
|
const tableStyle = gongmun ? {
|
|
23448
23463
|
totalWidth: mmToHwpunit(210 - gongmun.margins.left - gongmun.margins.right),
|
|
23449
|
-
charPr:
|
|
23450
|
-
boldCharPr:
|
|
23451
|
-
charHeight:
|
|
23464
|
+
charPr: measured ? GJ_CHAR_TABLE : CHAR_NORMAL,
|
|
23465
|
+
boldCharPr: measured ? GJ_CHAR_TABLE_BOLD : CHAR_BOLD,
|
|
23466
|
+
charHeight: measured ? gaejosikSizes(gongmun.bodyHeight, gongmun.sizes).table : gongmun.bodyHeight,
|
|
23452
23467
|
headerBf: gongmunTableHeaderBf(gaejosik),
|
|
23453
23468
|
centerParaPr: GONGMUN_CENTER,
|
|
23454
23469
|
tblCenterParaPr: GONGMUN_TBL_CENTER,
|
|
@@ -23458,13 +23473,14 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23458
23473
|
} : null;
|
|
23459
23474
|
const chamMap = (id) => id === CHAR_BOLD ? GJ_CHAR_CHAM_BOLD : id;
|
|
23460
23475
|
let chapterNo = 0;
|
|
23476
|
+
let h2Seq = 0;
|
|
23461
23477
|
let coverH1Idx = -1;
|
|
23462
23478
|
let pendingPageBreak = false;
|
|
23463
23479
|
let pendingNewNum = false;
|
|
23464
23480
|
let titleBoxH1Idx = -1;
|
|
23465
23481
|
let hasFrontPages = false;
|
|
23466
23482
|
const preamble = [];
|
|
23467
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
23483
|
+
if (_optionalChain([gongmun, 'optionalAccess', _247 => _247.approval]) && bfReg) {
|
|
23468
23484
|
preamble.push(buildApprovalTable(gongmun.approval, gongmun, bfReg));
|
|
23469
23485
|
}
|
|
23470
23486
|
if (gaejosik && gongmun) {
|
|
@@ -23511,7 +23527,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23511
23527
|
switch (block.type) {
|
|
23512
23528
|
case "heading": {
|
|
23513
23529
|
if (gongmun && blockIdx === titleBoxH1Idx && tableStyle && bfReg) {
|
|
23514
|
-
xml = buildTitleBox((block.text || "").trim(), CHAR_H1, tableStyle.totalWidth, bfReg);
|
|
23530
|
+
xml = buildTitleBox((block.text || "").trim(), measured ? GJ_CHAR_BODY_TITLE : CHAR_H1, tableStyle.totalWidth, bfReg);
|
|
23515
23531
|
break;
|
|
23516
23532
|
}
|
|
23517
23533
|
if (gaejosik) {
|
|
@@ -23535,11 +23551,16 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23535
23551
|
const pId = headingParaPrId(block.level || 1);
|
|
23536
23552
|
const cId = headingCharPrId(block.level || 1);
|
|
23537
23553
|
const styleId = gongmun ? Math.min(block.level || 1, 4) : 0;
|
|
23538
|
-
|
|
23554
|
+
let hText = block.text || "";
|
|
23555
|
+
if (gongmun && (block.level || 1) === 2 && gongmun.h2Marker !== "none") {
|
|
23556
|
+
const title = stripChapterNumber(hText);
|
|
23557
|
+
hText = gongmun.h2Marker === "box" ? `\u25A1 ${title}` : `${++h2Seq}. ${title}`;
|
|
23558
|
+
}
|
|
23559
|
+
xml = generateParagraph(hText, pId, cId, void 0, styleId);
|
|
23539
23560
|
break;
|
|
23540
23561
|
}
|
|
23541
23562
|
case "paragraph": {
|
|
23542
|
-
if (
|
|
23563
|
+
if (measured && (block.text || "").trimStart().startsWith("\u203B")) {
|
|
23543
23564
|
xml = generateParagraph((block.text || "").trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23544
23565
|
break;
|
|
23545
23566
|
}
|
|
@@ -23584,7 +23605,7 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23584
23605
|
break;
|
|
23585
23606
|
}
|
|
23586
23607
|
case "blockquote": {
|
|
23587
|
-
if (
|
|
23608
|
+
if (measured) {
|
|
23588
23609
|
const t = (block.text || "").trim();
|
|
23589
23610
|
if (t) xml = generateParagraph(t.startsWith("\u203B") ? t : `\u203B ${t}`, GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23590
23611
|
break;
|
|
@@ -23599,17 +23620,17 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23599
23620
|
case "list_item": {
|
|
23600
23621
|
if (gongmun && gongmunList) {
|
|
23601
23622
|
const info = gongmunList.get(blockIdx);
|
|
23602
|
-
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
23603
|
-
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
23623
|
+
const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _248 => _248.depth]), () => ( 0));
|
|
23624
|
+
const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _249 => _249.marker]), () => ( ""));
|
|
23604
23625
|
const content = block.text || "";
|
|
23605
|
-
if (
|
|
23626
|
+
if (measured && content.trimStart().startsWith("\u203B")) {
|
|
23606
23627
|
xml = generateParagraph(content.trim(), GJ_PARA_CHAM, GJ_CHAR_CHAM, chamMap);
|
|
23607
23628
|
break;
|
|
23608
23629
|
}
|
|
23609
23630
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
23610
23631
|
let listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
23611
23632
|
let mapId = fit ? variantMapper(fit, blockIdx, vBase) : void 0;
|
|
23612
|
-
if (
|
|
23633
|
+
if (measured && depth === 0 && gongmun.numbering !== "standard") {
|
|
23613
23634
|
listCharPr = GJ_CHAR_DAE;
|
|
23614
23635
|
mapId = (id) => id === CHAR_BOLD ? GJ_CHAR_DAE_BOLD : id;
|
|
23615
23636
|
}
|
|
@@ -23687,8 +23708,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23687
23708
|
}
|
|
23688
23709
|
paraXmls.push(xml);
|
|
23689
23710
|
}
|
|
23690
|
-
if (_optionalChain([gongmun, 'optionalAccess',
|
|
23691
|
-
const lastText = _nullishCoalesce(_optionalChain([[...blocks], 'access',
|
|
23711
|
+
if (_optionalChain([gongmun, 'optionalAccess', _250 => _250.endMark]) && paraXmls.length > 0) {
|
|
23712
|
+
const lastText = _nullishCoalesce(_optionalChain([[...blocks], 'access', _251 => _251.reverse, 'call', _252 => _252(), 'access', _253 => _253.find, 'call', _254 => _254((b) => (b.type === "paragraph" || b.type === "list_item") && (b.text || "").trim()), 'optionalAccess', _255 => _255.text]), () => ( ""));
|
|
23692
23713
|
if (!hasEndMark(lastText)) paraXmls.push(buildEndMark());
|
|
23693
23714
|
}
|
|
23694
23715
|
if (paraXmls.length === 0) {
|
|
@@ -23702,15 +23723,16 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
|
|
|
23702
23723
|
|
|
23703
23724
|
// src/hwpx/generator.ts
|
|
23704
23725
|
async function markdownToHwpx(markdown, options) {
|
|
23705
|
-
const theme = resolveTheme(_optionalChain([options, 'optionalAccess',
|
|
23706
|
-
const gongmun = _optionalChain([options, 'optionalAccess',
|
|
23707
|
-
const gaejosik = _optionalChain([gongmun, 'optionalAccess',
|
|
23726
|
+
const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _256 => _256.theme]));
|
|
23727
|
+
const gongmun = _optionalChain([options, 'optionalAccess', _257 => _257.gongmun]) ? resolveGongmun(options.gongmun) : null;
|
|
23728
|
+
const gaejosik = _optionalChain([gongmun, 'optionalAccess', _258 => _258.preset]) === "gaejosik";
|
|
23729
|
+
const measured = !!gongmun && usesReportFonts(gongmun.preset);
|
|
23708
23730
|
const blocks = parseMarkdownToBlocks(markdown);
|
|
23709
23731
|
const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
|
|
23710
23732
|
const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
|
|
23711
23733
|
const staticBfEnd = gongmun ? gaejosik ? 11 : 4 : 3;
|
|
23712
|
-
const remap = _optionalChain([options, 'optionalAccess',
|
|
23713
|
-
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
23734
|
+
const remap = _optionalChain([options, 'optionalAccess', _259 => _259.profile]) ? buildProfileRemap(options.profile, charVariantBase(measured) + (_nullishCoalesce(_optionalChain([fit, 'optionalAccess', _260 => _260.variants, 'optionalAccess', _261 => _261.length]), () => ( 0))) * 4, staticBfEnd) : null;
|
|
23735
|
+
const bfReg = gongmun ? new TableBfRegistry(staticBfEnd + (_nullishCoalesce(_optionalChain([remap, 'optionalAccess', _262 => _262.borderFillXmls, 'access', _263 => _263.length]), () => ( 0)))) : null;
|
|
23714
23736
|
const chartParts = [];
|
|
23715
23737
|
const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts, bfReg, remap);
|
|
23716
23738
|
if (remap && remap.tables.length > 0) {
|
|
@@ -23719,12 +23741,12 @@ async function markdownToHwpx(markdown, options) {
|
|
|
23719
23741
|
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)`);
|
|
23720
23742
|
}
|
|
23721
23743
|
}
|
|
23722
|
-
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess',
|
|
23744
|
+
const extraBorderFills = [..._nullishCoalesce(_optionalChain([remap, 'optionalAccess', _264 => _264.borderFillXmls]), () => ( [])), ..._nullishCoalesce(_optionalChain([bfReg, 'optionalAccess', _265 => _265.emit, 'call', _266 => _266()]), () => ( []))];
|
|
23723
23745
|
const zip = new (0, _jszip2.default)();
|
|
23724
23746
|
zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
|
|
23725
23747
|
zip.file("META-INF/container.xml", generateContainerXml());
|
|
23726
23748
|
zip.file("Contents/content.hpf", generateManifest(chartParts));
|
|
23727
|
-
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess',
|
|
23749
|
+
zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _267 => _267.variants]), () => ( [])), extraBorderFills, _nullishCoalesce(_optionalChain([remap, 'optionalAccess', _268 => _268.charPrXmls]), () => ( []))));
|
|
23728
23750
|
zip.file("Contents/section0.xml", sectionXml);
|
|
23729
23751
|
for (const part of chartParts) zip.file(part.name, part.xml);
|
|
23730
23752
|
zip.file("Preview/PrvText.txt", buildPrvText(blocks));
|
|
@@ -24018,7 +24040,7 @@ function parseRenderStyles(headXml) {
|
|
|
24018
24040
|
const underlineEl = findChildByLocalName(el, "underline");
|
|
24019
24041
|
const textColor = el.getAttribute("textColor");
|
|
24020
24042
|
const fontRef = findChildByLocalName(el, "fontRef");
|
|
24021
|
-
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess',
|
|
24043
|
+
const fontId = _nullishCoalesce(_optionalChain([fontRef, 'optionalAccess', _269 => _269.getAttribute, 'call', _270 => _270("hangul")]), () => ( _optionalChain([fontRef, 'optionalAccess', _271 => _271.getAttribute, 'call', _272 => _272("latin")])));
|
|
24022
24044
|
const face = fontId != null ? hangulFonts.get(fontId) : void 0;
|
|
24023
24045
|
styles.charPr.set(id, {
|
|
24024
24046
|
height: Number(el.getAttribute("height")) || 1e3,
|
|
@@ -24026,8 +24048,8 @@ function parseRenderStyles(headXml) {
|
|
|
24026
24048
|
italic: findChildByLocalName(el, "italic") != null,
|
|
24027
24049
|
underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
|
|
24028
24050
|
color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
|
|
24029
|
-
ratio: Number(_optionalChain([ratioEl, 'optionalAccess',
|
|
24030
|
-
spacing: Number(_optionalChain([spacingEl, 'optionalAccess',
|
|
24051
|
+
ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _273 => _273.getAttribute, 'call', _274 => _274("hangul")])) || 100,
|
|
24052
|
+
spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _275 => _275.getAttribute, 'call', _276 => _276("hangul")])) || 0,
|
|
24031
24053
|
fontFamily: face ? hwpFaceToCssStack(face) : void 0
|
|
24032
24054
|
});
|
|
24033
24055
|
}
|
|
@@ -24035,7 +24057,7 @@ function parseRenderStyles(headXml) {
|
|
|
24035
24057
|
const id = el.getAttribute("id");
|
|
24036
24058
|
if (id != null) {
|
|
24037
24059
|
const align = findChildByLocalName(el, "align");
|
|
24038
|
-
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess',
|
|
24060
|
+
styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _277 => _277.getAttribute, 'call', _278 => _278("horizontal")]) || "JUSTIFY");
|
|
24039
24061
|
styles.paraGeom.set(id, parseParaGeom(el));
|
|
24040
24062
|
}
|
|
24041
24063
|
} else if (tag === "borderFill") {
|
|
@@ -24049,7 +24071,7 @@ function parseRenderStyles(headXml) {
|
|
|
24049
24071
|
};
|
|
24050
24072
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
24051
24073
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
24052
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
24074
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _279 => _279.getAttribute, 'call', _280 => _280("faceColor")]);
|
|
24053
24075
|
if (face && face.toLowerCase() !== "none") bf.fill = face;
|
|
24054
24076
|
styles.borderFill.set(id, bf);
|
|
24055
24077
|
}
|
|
@@ -24121,7 +24143,7 @@ function collectSites(scan) {
|
|
|
24121
24143
|
}
|
|
24122
24144
|
function attrOf(openTag, name) {
|
|
24123
24145
|
const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
|
|
24124
|
-
return _optionalChain([m, 'optionalAccess',
|
|
24146
|
+
return _optionalChain([m, 'optionalAccess', _281 => _281[1]]);
|
|
24125
24147
|
}
|
|
24126
24148
|
function paraOpenTag(xml, para2) {
|
|
24127
24149
|
const end = xml.indexOf(">", para2.start);
|
|
@@ -24136,7 +24158,7 @@ function anchorRunInfo(xml, para2, anchor) {
|
|
|
24136
24158
|
if (!tr) return null;
|
|
24137
24159
|
const before = xml.slice(Math.max(0, para2.start), tr.contentStart);
|
|
24138
24160
|
const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
|
|
24139
|
-
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess',
|
|
24161
|
+
const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _282 => _282[1]]), () => ( tr.prefix)), () => ( "hp"));
|
|
24140
24162
|
const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
|
|
24141
24163
|
const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
|
|
24142
24164
|
if (close === -1) return null;
|
|
@@ -24163,7 +24185,7 @@ function cellContentWidthMm(xml, cell2) {
|
|
|
24163
24185
|
if (width === null) return null;
|
|
24164
24186
|
let content = width;
|
|
24165
24187
|
const win = cellAddrWindow(xml, cell2);
|
|
24166
|
-
const mg = _optionalChain([win, 'optionalAccess',
|
|
24188
|
+
const mg = _optionalChain([win, 'optionalAccess', _283 => _283.match, 'call', _284 => _284(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
|
|
24167
24189
|
if (mg) {
|
|
24168
24190
|
content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
|
|
24169
24191
|
}
|
|
@@ -24197,11 +24219,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
24197
24219
|
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>`;
|
|
24198
24220
|
}
|
|
24199
24221
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
24200
|
-
if (ops.length === 0) throw new (0,
|
|
24222
|
+
if (ops.length === 0) throw new (0, _chunkNIZXIVEIcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
24201
24223
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
24202
24224
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
24203
|
-
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access',
|
|
24204
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
24225
|
+
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _285 => _285.match, 'call', _286 => _286(/(\d+)\.xml$/i), 'optionalAccess', _287 => _287[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _288 => _288.match, 'call', _289 => _289(/(\d+)\.xml$/i), 'optionalAccess', _290 => _290[1]]), () => ( 0))));
|
|
24226
|
+
if (sectionPaths.length === 0) throw new (0, _chunkNIZXIVEIcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
24205
24227
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
24206
24228
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
24207
24229
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -24242,11 +24264,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24242
24264
|
const manifestItems = [];
|
|
24243
24265
|
const placed = [];
|
|
24244
24266
|
for (const op of ops) {
|
|
24245
|
-
if (!op.anchor) throw new (0,
|
|
24246
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
24267
|
+
if (!op.anchor) throw new (0, _chunkNIZXIVEIcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
24268
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkNIZXIVEIcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
24247
24269
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
24248
|
-
if (!MIME[ext]) throw new (0,
|
|
24249
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
24270
|
+
if (!MIME[ext]) throw new (0, _chunkNIZXIVEIcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
24271
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkNIZXIVEIcjs.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)`);
|
|
24250
24272
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
24251
24273
|
let found = null;
|
|
24252
24274
|
let total = 0;
|
|
@@ -24279,7 +24301,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24279
24301
|
}
|
|
24280
24302
|
}
|
|
24281
24303
|
}
|
|
24282
|
-
throw new (0,
|
|
24304
|
+
throw new (0, _chunkNIZXIVEIcjs.KordocError)(
|
|
24283
24305
|
`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)})`
|
|
24284
24306
|
);
|
|
24285
24307
|
}
|
|
@@ -24287,9 +24309,9 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24287
24309
|
const xml = sectionXmls[si];
|
|
24288
24310
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
24289
24311
|
if (!run) {
|
|
24290
|
-
throw new (0,
|
|
24312
|
+
throw new (0, _chunkNIZXIVEIcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
24291
24313
|
}
|
|
24292
|
-
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess',
|
|
24314
|
+
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _291 => _291.charPr, 'access', _292 => _292.get, 'call', _293 => _293(run.charPr), 'optionalAccess', _294 => _294.height]), () => ( 1e3));
|
|
24293
24315
|
const fontPt = charPrHeight / 100;
|
|
24294
24316
|
const emMm = fontPt * 25.4 / 72;
|
|
24295
24317
|
const lineHMm = emMm;
|
|
@@ -24298,7 +24320,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
24298
24320
|
const sizeMm = op.sizeMm != null && Number.isFinite(op.sizeMm) && op.sizeMm > 0 ? op.sizeMm : Math.max(7, Math.min(18, lineHMm * 1.6));
|
|
24299
24321
|
const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
|
|
24300
24322
|
const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
|
|
24301
|
-
const align = _optionalChain([styles, 'optionalAccess',
|
|
24323
|
+
const align = _optionalChain([styles, 'optionalAccess', _295 => _295.paraAlign, 'access', _296 => _296.get, 'call', _297 => _297(paraPrId)]);
|
|
24302
24324
|
let alignShiftMm = 0;
|
|
24303
24325
|
if (align === "CENTER" || align === "RIGHT") {
|
|
24304
24326
|
const paraWMm = measureMm(site.para.text, emMm);
|
|
@@ -24394,7 +24416,7 @@ function parseBorderFills(headerDoc) {
|
|
|
24394
24416
|
};
|
|
24395
24417
|
const fillBrush = findChildByLocalName(bf, "fillBrush");
|
|
24396
24418
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
24397
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
24419
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _298 => _298.getAttribute, 'call', _299 => _299("faceColor")]);
|
|
24398
24420
|
if (face && face !== "none") def.fill = { faceColor: face };
|
|
24399
24421
|
map.set(id, def);
|
|
24400
24422
|
}
|
|
@@ -24414,7 +24436,7 @@ function parseCharPrs(headerDoc) {
|
|
|
24414
24436
|
if (cp.getAttribute("italic") === "1") def.italic = true;
|
|
24415
24437
|
if (findChildByLocalName(cp, "underline")) def.underline = true;
|
|
24416
24438
|
const fontRef = findChildByLocalName(cp, "fontRef");
|
|
24417
|
-
const hangul = _optionalChain([fontRef, 'optionalAccess',
|
|
24439
|
+
const hangul = _optionalChain([fontRef, 'optionalAccess', _300 => _300.getAttribute, 'call', _301 => _301("hangul")]);
|
|
24418
24440
|
if (hangul) def.fontRef_hangul = hangul;
|
|
24419
24441
|
map.set(id, def);
|
|
24420
24442
|
}
|
|
@@ -24438,7 +24460,7 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
24438
24460
|
const rows = _nullishCoalesce(num(tbl2.getAttribute("rowCnt")), () => ( 0));
|
|
24439
24461
|
const cols = _nullishCoalesce(num(tbl2.getAttribute("colCnt")), () => ( 0));
|
|
24440
24462
|
const sz = findChildByLocalName(tbl2, "sz");
|
|
24441
|
-
const width = _optionalChain([sz, 'optionalAccess',
|
|
24463
|
+
const width = _optionalChain([sz, 'optionalAccess', _302 => _302.getAttribute, 'call', _303 => _303("width")]) || void 0;
|
|
24442
24464
|
const cells = [];
|
|
24443
24465
|
const usedBf = /* @__PURE__ */ new Set();
|
|
24444
24466
|
const usedCp = /* @__PURE__ */ new Set();
|
|
@@ -24449,16 +24471,16 @@ function parseTable3(tbl2, tableIndex, borderFills, charPrs) {
|
|
|
24449
24471
|
const addr = findChildByLocalName(tc2, "cellAddr");
|
|
24450
24472
|
const span = findChildByLocalName(tc2, "cellSpan");
|
|
24451
24473
|
const csz = findChildByLocalName(tc2, "cellSz");
|
|
24452
|
-
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
24453
|
-
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess',
|
|
24474
|
+
const row = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _304 => _304.getAttribute, 'call', _305 => _305("rowAddr")])), () => ( 0));
|
|
24475
|
+
const col = _nullishCoalesce(num(_optionalChain([addr, 'optionalAccess', _306 => _306.getAttribute, 'call', _307 => _307("colAddr")])), () => ( 0));
|
|
24454
24476
|
if (row === 0 && col === 0 && !anchorText) anchorText = directCellText(tc2);
|
|
24455
|
-
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
24456
|
-
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess',
|
|
24477
|
+
const colSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _308 => _308.getAttribute, 'call', _309 => _309("colSpan")])), () => ( 1));
|
|
24478
|
+
const rowSpan = _nullishCoalesce(num(_optionalChain([span, 'optionalAccess', _310 => _310.getAttribute, 'call', _311 => _311("rowSpan")])), () => ( 1));
|
|
24457
24479
|
const bfId = tc2.getAttribute("borderFillIDRef") || void 0;
|
|
24458
24480
|
const cpId = firstRunCharPr(tc2);
|
|
24459
24481
|
const cell2 = { row, col, rowSpan, colSpan };
|
|
24460
|
-
const w = _optionalChain([csz, 'optionalAccess',
|
|
24461
|
-
const hh = _optionalChain([csz, 'optionalAccess',
|
|
24482
|
+
const w = _optionalChain([csz, 'optionalAccess', _312 => _312.getAttribute, 'call', _313 => _313("width")]);
|
|
24483
|
+
const hh = _optionalChain([csz, 'optionalAccess', _314 => _314.getAttribute, 'call', _315 => _315("height")]);
|
|
24462
24484
|
if (w) cell2.width_hwpunit = w;
|
|
24463
24485
|
if (hh) cell2.height_hwpunit = hh;
|
|
24464
24486
|
if (bfId) {
|
|
@@ -24531,16 +24553,16 @@ function pick(map, keys) {
|
|
|
24531
24553
|
return out;
|
|
24532
24554
|
}
|
|
24533
24555
|
async function hwpxToProfile(input) {
|
|
24534
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
24556
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkNIZXIVEIcjs.toArrayBuffer.call(void 0, input);
|
|
24535
24557
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
24536
24558
|
const parser = createXmlParser();
|
|
24537
|
-
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access',
|
|
24559
|
+
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _316 => _316.file, 'call', _317 => _317(/[Hh]eader\.xml$/), 'optionalAccess', _318 => _318[0]])));
|
|
24538
24560
|
let headerXml = "<root/>";
|
|
24539
24561
|
if (headerFile) headerXml = await headerFile.async("text");
|
|
24540
24562
|
const headerDoc = parser.parseFromString(headerXml, "text/xml");
|
|
24541
24563
|
const borderFills = parseBorderFills(headerDoc);
|
|
24542
24564
|
const charPrs = parseCharPrs(headerDoc);
|
|
24543
|
-
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access',
|
|
24565
|
+
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/).sort((a, b) => (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([a, 'access', _319 => _319.name, 'access', _320 => _320.match, 'call', _321 => _321(/(\d+)\.xml$/), 'optionalAccess', _322 => _322[1]]), () => ( null))), () => ( 0))) - (_nullishCoalesce(num(_nullishCoalesce(_optionalChain([b, 'access', _323 => _323.name, 'access', _324 => _324.match, 'call', _325 => _325(/(\d+)\.xml$/), 'optionalAccess', _326 => _326[1]]), () => ( null))), () => ( 0))));
|
|
24544
24566
|
const tables = [];
|
|
24545
24567
|
let tableIndex = 0;
|
|
24546
24568
|
for (const f of sectionFiles) {
|
|
@@ -24707,6 +24729,142 @@ function unknownFontWarnings(fonts) {
|
|
|
24707
24729
|
return warnings;
|
|
24708
24730
|
}
|
|
24709
24731
|
|
|
24732
|
+
// src/hwpx/gongmun-lint.ts
|
|
24733
|
+
var RULES = [
|
|
24734
|
+
// 날짜 ─ 온점 뒤 한 칸, 0 패딩 금지, 연도 4자리, 끝 마침표
|
|
24735
|
+
{
|
|
24736
|
+
code: "DATE_NO_SPACE",
|
|
24737
|
+
severity: "error",
|
|
24738
|
+
pattern: /\b\d{4}\.\d{1,2}\.\d{1,2}\.?/g,
|
|
24739
|
+
message: "\uB0A0\uC9DC \uC628\uC810 \uB4A4\uC5D0 \uD55C \uCE78\uC529 \uB744\uC6CC\uC57C \uD568",
|
|
24740
|
+
suggest: "\uC608) 2025. 1. 6."
|
|
24741
|
+
},
|
|
24742
|
+
{
|
|
24743
|
+
code: "DATE_ZERO_PAD",
|
|
24744
|
+
severity: "error",
|
|
24745
|
+
pattern: /\b\d{4}\.\s*0\d\.|\.\s*0\d\./g,
|
|
24746
|
+
message: "\uC6D4\xB7\uC77C \uC55E\uC758 '0'\uC740 \uD45C\uAE30\uD558\uC9C0 \uC54A\uC74C",
|
|
24747
|
+
suggest: "\uC608) 2025. 1. 6. (2025. 01. 06. \u2715)"
|
|
24748
|
+
},
|
|
24749
|
+
{
|
|
24750
|
+
code: "DATE_2DIGIT_YR",
|
|
24751
|
+
severity: "error",
|
|
24752
|
+
pattern: /(?<!\d)['’]\d{2}\.\s*\d/g,
|
|
24753
|
+
message: "\uC5F0\uB3C4\uB294 \uB124 \uC790\uB9AC\uB85C \uD45C\uAE30('24 \u2715)",
|
|
24754
|
+
suggest: "\uC608) 2025. 1. 6."
|
|
24755
|
+
},
|
|
24756
|
+
{
|
|
24757
|
+
code: "DATE_NO_END_DOT",
|
|
24758
|
+
severity: "warning",
|
|
24759
|
+
pattern: /\b\d{4}\.\s\d{1,2}\.\s\d{1,2}(?!\s*[.\d(])/g,
|
|
24760
|
+
message: "\uB0A0\uC9DC\uC758 '\uC77C' \uB2E4\uC74C\uC5D0 \uB9C8\uCE68\uD45C(.)\uB97C \uCC0D\uC5B4\uC57C \uD568",
|
|
24761
|
+
suggest: "\uC608) 2025. 1. 6."
|
|
24762
|
+
},
|
|
24763
|
+
// 시간 ─ 24시각제, 쌍점 붙여쓰기
|
|
24764
|
+
{
|
|
24765
|
+
code: "TIME_AMPM",
|
|
24766
|
+
severity: "error",
|
|
24767
|
+
pattern: /(오전|오후|아침|밤|낮)\s*\d{1,2}\s*시/g,
|
|
24768
|
+
message: "24\uC2DC\uAC01\uC81C \uC22B\uC790\uB85C \uD45C\uAE30(\uC624\uC804/\uC624\uD6C4 \uC0AC\uC6A9 \uC548 \uD568)",
|
|
24769
|
+
suggest: "\uC608) 09:00, 15:30"
|
|
24770
|
+
},
|
|
24771
|
+
{
|
|
24772
|
+
code: "TIME_24H",
|
|
24773
|
+
severity: "warning",
|
|
24774
|
+
pattern: /(?<!\d)24\s*시(?!각)/g,
|
|
24775
|
+
message: "'24\uC2DC'\uBCF4\uB2E4 \uC775\uC77C 00:00 \uB610\uB294 '18:00\uAE4C\uC9C0' \uAD8C\uC7A5",
|
|
24776
|
+
suggest: "\uC608) 18:00"
|
|
24777
|
+
},
|
|
24778
|
+
{
|
|
24779
|
+
code: "TIME_COLON_SP",
|
|
24780
|
+
severity: "error",
|
|
24781
|
+
pattern: /\b\d{1,2}\s+:\s*\d{2}\b|\b\d{1,2}:\s+\d{2}\b/g,
|
|
24782
|
+
message: "\uC2DC\uC640 \uBD84 \uC0AC\uC774 \uC30D\uC810\uC740 \uC591\uCABD\uC744 \uBD99\uC5EC \uC500",
|
|
24783
|
+
suggest: "\uC608) 13:20"
|
|
24784
|
+
},
|
|
24785
|
+
// 금액 ─ '천원' 금지, 금+숫자 붙여쓰기
|
|
24786
|
+
{
|
|
24787
|
+
code: "MONEY_CHEONWON",
|
|
24788
|
+
severity: "error",
|
|
24789
|
+
pattern: /\d+\s*천\s*원/g,
|
|
24790
|
+
message: "\uAE08\uC561\uC740 '\uCC9C\uC6D0'\uC73C\uB85C \uC904\uC774\uC9C0 \uC54A\uACE0 \uC544\uB77C\uBE44\uC544 \uC22B\uC790\uB85C",
|
|
24791
|
+
suggest: "\uC608) 345,000\uC6D0"
|
|
24792
|
+
},
|
|
24793
|
+
{
|
|
24794
|
+
code: "MONEY_GEUM_SP",
|
|
24795
|
+
severity: "warning",
|
|
24796
|
+
pattern: /금\s+\d/g,
|
|
24797
|
+
message: "'\uAE08'\uACFC \uC22B\uC790 \uC0AC\uC774\uB294 \uBD99\uC5EC \uC4F0\uB294 \uAC83\uC774 \uC6D0\uCE59",
|
|
24798
|
+
suggest: "\uC608) \uAE08113,560\uC6D0"
|
|
24799
|
+
},
|
|
24800
|
+
// 붙임 ─ 쌍점 금지(2타 띄움)
|
|
24801
|
+
{
|
|
24802
|
+
code: "BUNIM_COLON",
|
|
24803
|
+
severity: "error",
|
|
24804
|
+
pattern: /붙\s*임\s*:/g,
|
|
24805
|
+
message: "'\uBD99\uC784' \uB2E4\uC74C\uC5D0 \uC30D\uC810(:)\uC744 \uBD99\uC774\uC9C0 \uC54A\uC74C(2\uD0C0 \uB744\uC6C0)",
|
|
24806
|
+
suggest: "\uC608) \uBD99\uC784 \uACC4\uD68D\uC11C 1\uBD80."
|
|
24807
|
+
},
|
|
24808
|
+
// 표기 ─ 물결표+까지 중복, 한글 먼저, 쌍점 띄어쓰기
|
|
24809
|
+
{
|
|
24810
|
+
code: "KKAJI_DUP",
|
|
24811
|
+
severity: "error",
|
|
24812
|
+
pattern: /[∼~~][^\n]{0,20}?까지/g,
|
|
24813
|
+
message: "\uBB3C\uACB0\uD45C(\u223C)\uC640 '\uAE4C\uC9C0'\uB97C \uD568\uAED8 \uC4F0\uC9C0 \uC54A\uC74C",
|
|
24814
|
+
suggest: "\uC608) 2. 20.\u223C2. 24."
|
|
24815
|
+
},
|
|
24816
|
+
{
|
|
24817
|
+
code: "FOREIGN_FIRST",
|
|
24818
|
+
severity: "warning",
|
|
24819
|
+
pattern: /\b[A-Z]{2,5}\s*\([가-힣]/g,
|
|
24820
|
+
message: "\uD55C\uAE00\uC744 \uBA3C\uC800 \uC4F0\uACE0 \uAD04\uD638 \uC548\uC5D0 \uC678\uAD6D\uC5B4\uB97C \uBCD1\uAE30",
|
|
24821
|
+
suggest: "\uC608) \uC5C5\uBB34 \uD611\uC57D(MOU)"
|
|
24822
|
+
},
|
|
24823
|
+
// 쌍점 — URL(https:// 등)·시각(13:20)은 제외
|
|
24824
|
+
{
|
|
24825
|
+
code: "COLON_SPACE",
|
|
24826
|
+
severity: "warning",
|
|
24827
|
+
pattern: /\S\s+:\S|\S:(?!\/\/)[^\s\d]/g,
|
|
24828
|
+
message: "\uC30D\uC810\uC740 \uC55E\uB9D0\uC5D0 \uBD99\uC774\uACE0 \uB4A4\uB294 \uD55C \uCE78 \uB744\uC6C0",
|
|
24829
|
+
suggest: "\uC608) \uC6D0\uC7A5: \uAE40\uAC11\uB3D9"
|
|
24830
|
+
}
|
|
24831
|
+
];
|
|
24832
|
+
function lintGongmunText(text) {
|
|
24833
|
+
const findings = [];
|
|
24834
|
+
let inFence = false;
|
|
24835
|
+
const lines = text.split(/\r?\n/);
|
|
24836
|
+
for (let i = 0; i < lines.length; i++) {
|
|
24837
|
+
const line = lines[i];
|
|
24838
|
+
if (/^\s*(```|~~~)/.test(line)) {
|
|
24839
|
+
inFence = !inFence;
|
|
24840
|
+
continue;
|
|
24841
|
+
}
|
|
24842
|
+
if (inFence) continue;
|
|
24843
|
+
for (const r of RULES) {
|
|
24844
|
+
r.pattern.lastIndex = 0;
|
|
24845
|
+
for (const m of line.matchAll(r.pattern)) {
|
|
24846
|
+
findings.push({
|
|
24847
|
+
line: i + 1,
|
|
24848
|
+
match: m[0].trim(),
|
|
24849
|
+
rule: r.code,
|
|
24850
|
+
severity: r.severity,
|
|
24851
|
+
message: r.message,
|
|
24852
|
+
suggest: r.suggest
|
|
24853
|
+
});
|
|
24854
|
+
}
|
|
24855
|
+
}
|
|
24856
|
+
}
|
|
24857
|
+
return findings;
|
|
24858
|
+
}
|
|
24859
|
+
function gongmunLintWarnings(text, limit = 10) {
|
|
24860
|
+
const findings = lintGongmunText(text);
|
|
24861
|
+
const shown = findings.slice(0, limit).map(
|
|
24862
|
+
(f) => `\uD45C\uAE30\uBC95 [${f.rule}] L${f.line} "${f.match}" \u2014 ${f.message}${f.suggest ? ` (${f.suggest})` : ""}`
|
|
24863
|
+
);
|
|
24864
|
+
if (findings.length > limit) shown.push(`\uD45C\uAE30\uBC95 \uACBD\uACE0 ${findings.length - limit}\uAC74 \uB354 \uC788\uC74C \u2014 kordoc lint\uB85C \uC804\uCCB4 \uD655\uC778`);
|
|
24865
|
+
return shown;
|
|
24866
|
+
}
|
|
24867
|
+
|
|
24710
24868
|
// src/roundtrip/patcher.ts
|
|
24711
24869
|
|
|
24712
24870
|
|
|
@@ -24715,7 +24873,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
|
|
|
24715
24873
|
var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
|
|
24716
24874
|
function patchTableRows(input) {
|
|
24717
24875
|
const { table: table2, scanTable, ctx, skip, origKeys, editedKeys } = input;
|
|
24718
|
-
const xml = _optionalChain([ctx, 'access',
|
|
24876
|
+
const xml = _optionalChain([ctx, 'access', _327 => _327.scans, 'access', _328 => _328[scanTable.sectionIndex], 'optionalAccess', _329 => _329.xml]);
|
|
24719
24877
|
if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
|
|
24720
24878
|
const numRows = table2.rows;
|
|
24721
24879
|
if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
|
|
@@ -24882,7 +25040,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
|
|
|
24882
25040
|
const rr = scanTable.rowRanges[template];
|
|
24883
25041
|
const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
|
|
24884
25042
|
const scan = scanSectionXml(wrapped, 0);
|
|
24885
|
-
const row = _optionalChain([scan, 'access',
|
|
25043
|
+
const row = _optionalChain([scan, 'access', _330 => _330.tables, 'access', _331 => _331[0], 'optionalAccess', _332 => _332.rows, 'access', _333 => _333[0]]);
|
|
24886
25044
|
if (!row || row.length !== cells.length) return null;
|
|
24887
25045
|
const splices = allLinesegRemovalSplices(wrapped);
|
|
24888
25046
|
for (let i = 0; i < cells.length; i++) {
|
|
@@ -24925,7 +25083,7 @@ function rowHeightOf(fragment) {
|
|
|
24925
25083
|
}
|
|
24926
25084
|
function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
|
|
24927
25085
|
const from = scanTable.start + tblOpenLen;
|
|
24928
|
-
const to = _nullishCoalesce(_optionalChain([scanTable, 'access',
|
|
25086
|
+
const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _334 => _334.rowRanges, 'access', _335 => _335[0], 'optionalAccess', _336 => _336.start]), () => ( from));
|
|
24929
25087
|
const slice = xml.slice(from, to);
|
|
24930
25088
|
const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
|
|
24931
25089
|
if (!szM || szM.index === void 0) return null;
|
|
@@ -25114,9 +25272,9 @@ function patchHtmlTableRows(table2, scanTable, replica, editedRows, ctx, skip, d
|
|
|
25114
25272
|
});
|
|
25115
25273
|
}
|
|
25116
25274
|
function patchNestedTables(table2, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
|
|
25117
|
-
const irCell = _optionalChain([table2, 'access',
|
|
25275
|
+
const irCell = _optionalChain([table2, 'access', _337 => _337.cells, 'access', _338 => _338[oc.gridR], 'optionalAccess', _339 => _339[oc.gridC]]);
|
|
25118
25276
|
const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
|
|
25119
|
-
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess',
|
|
25277
|
+
const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _340 => _340.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
|
|
25120
25278
|
if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
|
|
25121
25279
|
return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
|
|
25122
25280
|
}
|
|
@@ -25184,7 +25342,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25184
25342
|
};
|
|
25185
25343
|
const cell2 = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
|
|
25186
25344
|
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)");
|
|
25187
|
-
const irCell = _optionalChain([table2, 'access',
|
|
25345
|
+
const irCell = _optionalChain([table2, 'access', _341 => _341.cells, 'access', _342 => _342[gridR], 'optionalAccess', _343 => _343[gridC]]);
|
|
25188
25346
|
const scanJoined = cell2.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
|
|
25189
25347
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
25190
25348
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -25207,7 +25365,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25207
25365
|
if (newLines.length === 0) return 0;
|
|
25208
25366
|
const target = cell2.paragraphs[0];
|
|
25209
25367
|
if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
|
|
25210
|
-
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access',
|
|
25368
|
+
const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _344 => _344.scans, 'access', _345 => _345[target.sectionIndex], 'optionalAccess', _346 => _346.xml]));
|
|
25211
25369
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25212
25370
|
splices.push(...sp);
|
|
25213
25371
|
sectionIndex = target.sectionIndex;
|
|
@@ -25230,7 +25388,7 @@ function applyCellEdit(table2, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
25230
25388
|
}
|
|
25231
25389
|
for (let i = 0; i < nonEmpty.length; i++) {
|
|
25232
25390
|
if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
|
|
25233
|
-
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access',
|
|
25391
|
+
const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _347 => _347.scans, 'access', _348 => _348[nonEmpty[i].sectionIndex], 'optionalAccess', _349 => _349.xml]));
|
|
25234
25392
|
if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25235
25393
|
splices.push(...sp);
|
|
25236
25394
|
sectionIndex = nonEmpty[i].sectionIndex;
|
|
@@ -25311,7 +25469,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
25311
25469
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
25312
25470
|
if (paths.length > 0) return paths;
|
|
25313
25471
|
}
|
|
25314
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
25472
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkNIZXIVEIcjs.compareSectionPaths);
|
|
25315
25473
|
}
|
|
25316
25474
|
function sectionPathsFromManifest(xml) {
|
|
25317
25475
|
const attr = (tag, name) => {
|
|
@@ -25321,7 +25479,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
25321
25479
|
const idToHref = /* @__PURE__ */ new Map();
|
|
25322
25480
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
25323
25481
|
const id = attr(m[1], "id");
|
|
25324
|
-
const href =
|
|
25482
|
+
const href = _chunkNIZXIVEIcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
25325
25483
|
if (id && href) idToHref.set(id, href);
|
|
25326
25484
|
}
|
|
25327
25485
|
const ordered = [];
|
|
@@ -25330,7 +25488,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
25330
25488
|
if (href) ordered.push(href);
|
|
25331
25489
|
}
|
|
25332
25490
|
if (ordered.length > 0) return ordered;
|
|
25333
|
-
return Array.from(idToHref.values()).sort(
|
|
25491
|
+
return Array.from(idToHref.values()).sort(_chunkNIZXIVEIcjs.compareSectionPaths);
|
|
25334
25492
|
}
|
|
25335
25493
|
|
|
25336
25494
|
// src/roundtrip/patcher.ts
|
|
@@ -25422,7 +25580,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
25422
25580
|
}
|
|
25423
25581
|
}
|
|
25424
25582
|
let verification;
|
|
25425
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
25583
|
+
if (_optionalChain([options, 'optionalAccess', _350 => _350.verify]) !== false) {
|
|
25426
25584
|
try {
|
|
25427
25585
|
const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
|
|
25428
25586
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -25440,17 +25598,17 @@ function buildOrigUnits(blocks) {
|
|
|
25440
25598
|
let chunk2;
|
|
25441
25599
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
25442
25600
|
const next = blocks[i + 1];
|
|
25443
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
25444
|
-
chunk2 =
|
|
25601
|
+
if (_optionalChain([next, 'optionalAccess', _351 => _351.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
25602
|
+
chunk2 = _chunkNIZXIVEIcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
25445
25603
|
} else {
|
|
25446
|
-
chunk2 =
|
|
25604
|
+
chunk2 = _chunkNIZXIVEIcjs.blocksToMarkdown.call(void 0, [block]);
|
|
25447
25605
|
}
|
|
25448
25606
|
if (chunk2) {
|
|
25449
25607
|
const subUnits = splitMarkdownUnits(chunk2);
|
|
25450
25608
|
const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
|
|
25451
25609
|
for (let s = 0; s < subUnits.length; s++) {
|
|
25452
25610
|
const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
|
|
25453
|
-
if (block.type === "table" && _optionalChain([block, 'access',
|
|
25611
|
+
if (block.type === "table" && _optionalChain([block, 'access', _352 => _352.table, 'optionalAccess', _353 => _353.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
|
|
25454
25612
|
u.role = "caption";
|
|
25455
25613
|
}
|
|
25456
25614
|
units.push(u);
|
|
@@ -25561,7 +25719,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
25561
25719
|
const ti = ctx.tableInsert;
|
|
25562
25720
|
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
25563
25721
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25564
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25722
|
+
if (!_optionalChain([mapping, 'optionalAccess', _354 => _354.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");
|
|
25565
25723
|
const para2 = mapping.para;
|
|
25566
25724
|
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");
|
|
25567
25725
|
const scan = ctx.scans[para2.sectionIndex];
|
|
@@ -25589,7 +25747,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
|
25589
25747
|
}
|
|
25590
25748
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
25591
25749
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
25592
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
25750
|
+
if (!_optionalChain([mapping, 'optionalAccess', _355 => _355.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)");
|
|
25593
25751
|
if (block.text && block.text.includes("\n")) {
|
|
25594
25752
|
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)");
|
|
25595
25753
|
}
|
|
@@ -25620,7 +25778,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
25620
25778
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
25621
25779
|
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");
|
|
25622
25780
|
}
|
|
25623
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
25781
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _356 => _356.scans, 'access', _357 => _357[mapping.para.sectionIndex], 'optionalAccess', _358 => _358.xml]));
|
|
25624
25782
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
25625
25783
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
25626
25784
|
return 1;
|
|
@@ -25806,7 +25964,7 @@ var Surgeon = (_class5 = class {
|
|
|
25806
25964
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
25807
25965
|
findEntry(path) {
|
|
25808
25966
|
const parts = path.replace(/^\//, "").split("/");
|
|
25809
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
25967
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _359 => _359.entries, 'access', _360 => _360[0], 'optionalAccess', _361 => _361.child]), () => ( -1));
|
|
25810
25968
|
let current;
|
|
25811
25969
|
for (const part of parts) {
|
|
25812
25970
|
const search = (idx) => {
|
|
@@ -26019,8 +26177,8 @@ function serializeRecords(recs, repl, inserts) {
|
|
|
26019
26177
|
parts.push(header, data);
|
|
26020
26178
|
};
|
|
26021
26179
|
for (let i = 0; i < recs.length; i++) {
|
|
26022
|
-
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess',
|
|
26023
|
-
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
26180
|
+
for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _362 => _362.get, 'call', _363 => _363(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
|
|
26181
|
+
push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _364 => _364.get, 'call', _365 => _365(i)]), () => ( recs[i].data)));
|
|
26024
26182
|
}
|
|
26025
26183
|
return Buffer.concat(parts);
|
|
26026
26184
|
}
|
|
@@ -26138,7 +26296,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26138
26296
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
26139
26297
|
}
|
|
26140
26298
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
26141
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
26299
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _366 => _366.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
26142
26300
|
let flags;
|
|
26143
26301
|
try {
|
|
26144
26302
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -26160,7 +26318,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26160
26318
|
const scans = [];
|
|
26161
26319
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
26162
26320
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
26163
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
26321
|
+
if (!_optionalChain([entry, 'optionalAccess', _367 => _367.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
26164
26322
|
let stream;
|
|
26165
26323
|
try {
|
|
26166
26324
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -26211,7 +26369,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
26211
26369
|
}
|
|
26212
26370
|
}
|
|
26213
26371
|
let verification;
|
|
26214
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
26372
|
+
if (_optionalChain([options, 'optionalAccess', _368 => _368.verify]) !== false) {
|
|
26215
26373
|
try {
|
|
26216
26374
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
26217
26375
|
const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
|
|
@@ -26301,7 +26459,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
26301
26459
|
for (const [key, scanCell] of scanTable.cells) {
|
|
26302
26460
|
const comma = key.indexOf(",");
|
|
26303
26461
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
26304
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
26462
|
+
const irCell = _optionalChain([irTable, 'access', _369 => _369.cells, 'access', _370 => _370[r], 'optionalAccess', _371 => _371[c]]);
|
|
26305
26463
|
if (!irCell) continue;
|
|
26306
26464
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
26307
26465
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -26337,7 +26495,7 @@ function handleModified(orig, edited, ctx) {
|
|
|
26337
26495
|
}
|
|
26338
26496
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
26339
26497
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
26340
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
26498
|
+
if (!_optionalChain([mapping, 'optionalAccess', _372 => _372.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)");
|
|
26341
26499
|
const restoreBr = (s) => s.replace(/(?:\s*<br\s*\/?\s*>\s*)+/gi, "\n");
|
|
26342
26500
|
let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
|
|
26343
26501
|
if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
|
|
@@ -26536,7 +26694,7 @@ function applyCellEdit5(table2, scanTable, gridR, gridC, newLines, ctx, before,
|
|
|
26536
26694
|
};
|
|
26537
26695
|
const cell2 = scanTable.cells.get(`${gridR},${gridC}`);
|
|
26538
26696
|
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)");
|
|
26539
|
-
const irCell = _optionalChain([table2, 'access',
|
|
26697
|
+
const irCell = _optionalChain([table2, 'access', _373 => _373.cells, 'access', _374 => _374[gridR], 'optionalAccess', _375 => _375[gridC]]);
|
|
26540
26698
|
const scanJoined = cell2.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
26541
26699
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
26542
26700
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -26928,7 +27086,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
26928
27086
|
const block = st.blocks[blockIndex];
|
|
26929
27087
|
if (!block) return void 0;
|
|
26930
27088
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
26931
|
-
const para2 = _optionalChain([st, 'access',
|
|
27089
|
+
const para2 = _optionalChain([st, 'access', _376 => _376.paraMap, 'access', _377 => _377.get, 'call', _378 => _378(blockIndex), 'optionalAccess', _379 => _379.para]);
|
|
26932
27090
|
if (!para2) return void 0;
|
|
26933
27091
|
return { kind: "paragraph", sectionIndex: para2.sectionIndex, xmlStart: para2.start };
|
|
26934
27092
|
}
|
|
@@ -26953,7 +27111,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
26953
27111
|
if (block.text && block.text.includes("\n")) {
|
|
26954
27112
|
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)" };
|
|
26955
27113
|
}
|
|
26956
|
-
if (!_optionalChain([st, 'access',
|
|
27114
|
+
if (!_optionalChain([st, 'access', _380 => _380.paraMap, 'access', _381 => _381.get, 'call', _382 => _382(blockIndex), 'optionalAccess', _383 => _383.para])) {
|
|
26957
27115
|
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)" };
|
|
26958
27116
|
}
|
|
26959
27117
|
return { capability: "text" };
|
|
@@ -27019,7 +27177,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27019
27177
|
continue;
|
|
27020
27178
|
}
|
|
27021
27179
|
if (block.type === "table" && block.table) {
|
|
27022
|
-
if (!_optionalChain([edit, 'access',
|
|
27180
|
+
if (!_optionalChain([edit, 'access', _384 => _384.cells, 'optionalAccess', _385 => _385.length])) {
|
|
27023
27181
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
27024
27182
|
continue;
|
|
27025
27183
|
}
|
|
@@ -27039,7 +27197,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27039
27197
|
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) });
|
|
27040
27198
|
continue;
|
|
27041
27199
|
}
|
|
27042
|
-
const irCell = _optionalChain([block, 'access',
|
|
27200
|
+
const irCell = _optionalChain([block, 'access', _386 => _386.table, 'access', _387 => _387.cells, 'access', _388 => _388[cellEdit.row], 'optionalAccess', _389 => _389[cellEdit.col]]);
|
|
27043
27201
|
if (!irCell) {
|
|
27044
27202
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
27045
27203
|
continue;
|
|
@@ -27095,7 +27253,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27095
27253
|
}
|
|
27096
27254
|
if (replacements.size === 0) {
|
|
27097
27255
|
let changes2;
|
|
27098
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27256
|
+
if (_optionalChain([options, 'optionalAccess', _390 => _390.verify]) !== false) {
|
|
27099
27257
|
const units = splitMarkdownUnits(st.markdown);
|
|
27100
27258
|
changes2 = diffUnitLists(units, units);
|
|
27101
27259
|
}
|
|
@@ -27116,7 +27274,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27116
27274
|
}
|
|
27117
27275
|
this.state = newState;
|
|
27118
27276
|
let changes;
|
|
27119
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
27277
|
+
if (_optionalChain([options, 'optionalAccess', _391 => _391.verify]) !== false) {
|
|
27120
27278
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
27121
27279
|
}
|
|
27122
27280
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -27136,7 +27294,7 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27136
27294
|
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)");
|
|
27137
27295
|
}
|
|
27138
27296
|
const mapping = st.paraMap.get(blockIndex);
|
|
27139
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
27297
|
+
if (!_optionalChain([mapping, 'optionalAccess', _392 => _392.para])) {
|
|
27140
27298
|
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)");
|
|
27141
27299
|
}
|
|
27142
27300
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -27156,14 +27314,14 @@ var HwpxSession = (_class6 = class _HwpxSession {
|
|
|
27156
27314
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
27157
27315
|
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");
|
|
27158
27316
|
}
|
|
27159
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
27317
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _393 => _393.scans, 'access', _394 => _394[mapping.para.sectionIndex], 'optionalAccess', _395 => _395.xml]));
|
|
27160
27318
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
27161
27319
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
27162
27320
|
return 1;
|
|
27163
27321
|
}
|
|
27164
27322
|
}, _class6);
|
|
27165
27323
|
function cellStaticCheck(table2, scanTable, r, c) {
|
|
27166
|
-
const irCell = _optionalChain([table2, 'access',
|
|
27324
|
+
const irCell = _optionalChain([table2, 'access', _396 => _396.cells, 'access', _397 => _397[r], 'optionalAccess', _398 => _398[c]]);
|
|
27167
27325
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
27168
27326
|
const cell2 = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
27169
27327
|
if (!cell2) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -27247,11 +27405,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
27247
27405
|
breaks: false
|
|
27248
27406
|
});
|
|
27249
27407
|
function renderHtml(markdown, options) {
|
|
27250
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27251
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27408
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _399 => _399.preset]), () => ( "default"));
|
|
27409
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _400 => _400.extraCss]), () => ( "")));
|
|
27252
27410
|
const body = md.render(markdown);
|
|
27253
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
27254
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
27411
|
+
const watermark = _optionalChain([options, 'optionalAccess', _401 => _401.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
27412
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _402 => _402.watermark]) ? `
|
|
27255
27413
|
.watermark {
|
|
27256
27414
|
position: fixed;
|
|
27257
27415
|
top: 50%; left: 50%;
|
|
@@ -27282,13 +27440,13 @@ async function htmlToPdf(html, options) {
|
|
|
27282
27440
|
try {
|
|
27283
27441
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
27284
27442
|
} catch (e30) {
|
|
27285
|
-
throw new (0,
|
|
27443
|
+
throw new (0, _chunkNIZXIVEIcjs.KordocError)(
|
|
27286
27444
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
27287
27445
|
);
|
|
27288
27446
|
}
|
|
27289
27447
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
27290
27448
|
if (!executablePath) {
|
|
27291
|
-
throw new (0,
|
|
27449
|
+
throw new (0, _chunkNIZXIVEIcjs.KordocError)(
|
|
27292
27450
|
"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."
|
|
27293
27451
|
);
|
|
27294
27452
|
}
|
|
@@ -27300,10 +27458,10 @@ async function htmlToPdf(html, options) {
|
|
|
27300
27458
|
try {
|
|
27301
27459
|
const page = await browser.newPage();
|
|
27302
27460
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
27303
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
27461
|
+
const margin = _optionalChain([options, 'optionalAccess', _403 => _403.margin]);
|
|
27304
27462
|
const pdf = await page.pdf({
|
|
27305
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27306
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
27463
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _404 => _404.pageSize]), () => ( "A4")),
|
|
27464
|
+
landscape: _optionalChain([options, 'optionalAccess', _405 => _405.orientation]) === "landscape",
|
|
27307
27465
|
printBackground: true,
|
|
27308
27466
|
margin: margin ? {
|
|
27309
27467
|
top: toCss(margin.top),
|
|
@@ -27311,9 +27469,9 @@ async function htmlToPdf(html, options) {
|
|
|
27311
27469
|
bottom: toCss(margin.bottom),
|
|
27312
27470
|
left: toCss(margin.left)
|
|
27313
27471
|
} : void 0,
|
|
27314
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
27315
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27316
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
27472
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _406 => _406.header]) || _optionalChain([options, 'optionalAccess', _407 => _407.footer])),
|
|
27473
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _408 => _408.header]), () => ( "<div></div>")),
|
|
27474
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _409 => _409.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
27317
27475
|
});
|
|
27318
27476
|
return Buffer.from(pdf);
|
|
27319
27477
|
} finally {
|
|
@@ -27347,7 +27505,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
27347
27505
|
return htmlToPdf(html, options);
|
|
27348
27506
|
}
|
|
27349
27507
|
async function blocksToPdf(blocks, options) {
|
|
27350
|
-
const markdown =
|
|
27508
|
+
const markdown = _chunkNIZXIVEIcjs.blocksToMarkdown.call(void 0, blocks);
|
|
27351
27509
|
return markdownToPdf(markdown, options);
|
|
27352
27510
|
}
|
|
27353
27511
|
|
|
@@ -27558,7 +27716,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
|
|
|
27558
27716
|
if (ln(p) !== "p") continue;
|
|
27559
27717
|
reflowTablesIn(p, doc, styles, mode, counter);
|
|
27560
27718
|
const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
|
|
27561
|
-
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess',
|
|
27719
|
+
const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _410 => _410.spaceBefore]), () => ( 0)));
|
|
27562
27720
|
const res = reflowPara(p, doc, styles, areaW, startV, mode);
|
|
27563
27721
|
if (res) {
|
|
27564
27722
|
const paraH = res.paraBottom - startV;
|
|
@@ -27667,7 +27825,7 @@ function buildPara(p) {
|
|
|
27667
27825
|
el: ch,
|
|
27668
27826
|
tag: cn,
|
|
27669
27827
|
index: chars.length,
|
|
27670
|
-
inline: _optionalChain([pos, 'optionalAccess',
|
|
27828
|
+
inline: _optionalChain([pos, 'optionalAccess', _411 => _411.getAttribute, 'call', _412 => _412("treatAsChar")]) === "1",
|
|
27671
27829
|
width: w,
|
|
27672
27830
|
height: h
|
|
27673
27831
|
});
|
|
@@ -27919,15 +28077,15 @@ function drawShape(o, x, y, ctx, depth) {
|
|
|
27919
28077
|
const sx = ow > 0 ? w / ow : 1;
|
|
27920
28078
|
const sy = oh > 0 ? h / oh : 1;
|
|
27921
28079
|
const lineShape = findChildByLocalName(el, "lineShape");
|
|
27922
|
-
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess',
|
|
27923
|
-
const strokeCol = _optionalChain([lineShape, 'optionalAccess',
|
|
28080
|
+
const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _413 => _413.getAttribute, 'call', _414 => _414("style")]), () => ( "SOLID"));
|
|
28081
|
+
const strokeCol = _optionalChain([lineShape, 'optionalAccess', _415 => _415.getAttribute, 'call', _416 => _416("color")]) || "#000000";
|
|
27924
28082
|
const hasStroke = lstyle !== "NONE";
|
|
27925
28083
|
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num3(lineShape, "width") : 33) : 0;
|
|
27926
28084
|
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
27927
28085
|
const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
27928
28086
|
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
27929
28087
|
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
27930
|
-
const face = _optionalChain([winBrush, 'optionalAccess',
|
|
28088
|
+
const face = _optionalChain([winBrush, 'optionalAccess', _417 => _417.getAttribute, 'call', _418 => _418("faceColor")]);
|
|
27931
28089
|
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
27932
28090
|
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
|
|
27933
28091
|
if (o.tag === "rect") {
|
|
@@ -27959,7 +28117,7 @@ function cellContentExtent(cell2) {
|
|
|
27959
28117
|
if (ln2(p) !== "p") continue;
|
|
27960
28118
|
const m = buildPara(p);
|
|
27961
28119
|
for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
|
|
27962
|
-
const baseV = _nullishCoalesce(_optionalChain([m, 'access',
|
|
28120
|
+
const baseV = _nullishCoalesce(_optionalChain([m, 'access', _419 => _419.segs, 'access', _420 => _420[0], 'optionalAccess', _421 => _421.vertpos]), () => ( 0));
|
|
27963
28121
|
for (const o of m.objs) {
|
|
27964
28122
|
if (o.inline) {
|
|
27965
28123
|
const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
|
|
@@ -27967,7 +28125,7 @@ function cellContentExtent(cell2) {
|
|
|
27967
28125
|
continue;
|
|
27968
28126
|
}
|
|
27969
28127
|
const pos = findChildByLocalName(o.el, "pos");
|
|
27970
|
-
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess',
|
|
28128
|
+
if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _422 => _422.getAttribute, 'call', _423 => _423("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
|
|
27971
28129
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
27972
28130
|
const pushed = baseV - (num3(om, "top") + o.height + num3(om, "bottom"));
|
|
27973
28131
|
const anchor = pushed >= -100 ? pushed : baseV;
|
|
@@ -28053,7 +28211,7 @@ function drawTable(tbl2, tx, ty, ctx, depth) {
|
|
|
28053
28211
|
}));
|
|
28054
28212
|
for (const g of geom) {
|
|
28055
28213
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
28056
|
-
if (_optionalChain([bf, 'optionalAccess',
|
|
28214
|
+
if (_optionalChain([bf, 'optionalAccess', _424 => _424.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
|
|
28057
28215
|
}
|
|
28058
28216
|
for (const g of geom) {
|
|
28059
28217
|
const { c } = g;
|
|
@@ -28091,7 +28249,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
28091
28249
|
const sz = findChildByLocalName(pic, "sz");
|
|
28092
28250
|
const w = num3(sz, "width", 5669), h = num3(sz, "height", 5669);
|
|
28093
28251
|
const img = findFirst(pic, "img");
|
|
28094
|
-
const ref = _optionalChain([img, 'optionalAccess',
|
|
28252
|
+
const ref = _optionalChain([img, 'optionalAccess', _425 => _425.getAttribute, 'call', _426 => _426("binaryItemIDRef")]);
|
|
28095
28253
|
const loaded = ref != null ? ctx.images.get(ref) : void 0;
|
|
28096
28254
|
if (!loaded) {
|
|
28097
28255
|
emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
@@ -28130,7 +28288,7 @@ function readSectionGeom(root) {
|
|
|
28130
28288
|
const pagePr = findFirst(root, "pagePr");
|
|
28131
28289
|
const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
28132
28290
|
let PW = num3(pagePr, "width", 59528), PH = num3(pagePr, "height", 84188);
|
|
28133
|
-
if (_optionalChain([pagePr, 'optionalAccess',
|
|
28291
|
+
if (_optionalChain([pagePr, 'optionalAccess', _427 => _427.getAttribute, 'call', _428 => _428("landscape")]) === "NARROWLY" && PW < PH) {
|
|
28134
28292
|
const t = PW;
|
|
28135
28293
|
PW = PH;
|
|
28136
28294
|
PH = t;
|
|
@@ -28188,17 +28346,17 @@ function renderSectionToPages(root, geom, ctxBase, hasCache, reflowMode) {
|
|
|
28188
28346
|
return { pages: ctx.pages, pageH };
|
|
28189
28347
|
}
|
|
28190
28348
|
async function renderHwpxToSvg(input, options) {
|
|
28191
|
-
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28349
|
+
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _429 => _429.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
28192
28350
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
28193
|
-
|
|
28351
|
+
_chunkNIZXIVEIcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
28194
28352
|
let zip;
|
|
28195
28353
|
try {
|
|
28196
28354
|
zip = await _jszip2.default.loadAsync(input);
|
|
28197
28355
|
} catch (e31) {
|
|
28198
|
-
throw new (0,
|
|
28356
|
+
throw new (0, _chunkNIZXIVEIcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
28199
28357
|
}
|
|
28200
28358
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
28201
|
-
if (secFiles.length === 0) throw new (0,
|
|
28359
|
+
if (secFiles.length === 0) throw new (0, _chunkNIZXIVEIcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
28202
28360
|
const warnings = [];
|
|
28203
28361
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
28204
28362
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -28206,7 +28364,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28206
28364
|
const secXmls = [];
|
|
28207
28365
|
for (const f of secFiles) {
|
|
28208
28366
|
const xml = await f.async("string");
|
|
28209
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
28367
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkNIZXIVEIcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
28210
28368
|
secXmls.push(xml);
|
|
28211
28369
|
}
|
|
28212
28370
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -28230,7 +28388,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28230
28388
|
let href = binmap.get(ref);
|
|
28231
28389
|
if (!href) {
|
|
28232
28390
|
const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
|
|
28233
|
-
href = _optionalChain([cand, 'optionalAccess',
|
|
28391
|
+
href = _optionalChain([cand, 'optionalAccess', _430 => _430.name]);
|
|
28234
28392
|
}
|
|
28235
28393
|
if (!href) continue;
|
|
28236
28394
|
const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
|
|
@@ -28251,7 +28409,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28251
28409
|
styles,
|
|
28252
28410
|
images,
|
|
28253
28411
|
defs: [],
|
|
28254
|
-
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28412
|
+
highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _431 => _431.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
|
|
28255
28413
|
warnings,
|
|
28256
28414
|
warned: /* @__PURE__ */ new Set(),
|
|
28257
28415
|
stats: { texts: 0, images: 0, tables: 0 }
|
|
@@ -28261,7 +28419,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28261
28419
|
for (let si = 0; si < secXmls.length; si++) {
|
|
28262
28420
|
const secXml = secXmls[si];
|
|
28263
28421
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
28264
|
-
if (!hasCache && !_optionalChain([options, 'optionalAccess',
|
|
28422
|
+
if (!hasCache && !_optionalChain([options, 'optionalAccess', _432 => _432.reflow])) {
|
|
28265
28423
|
noCacheSkipped = true;
|
|
28266
28424
|
warnings.push(`\uAD6C\uC5ED ${si}: \uC870\uD310 \uCE90\uC2DC \uC5C6\uC74C \u2014 reflow \uC635\uC158 \uD544\uC694, \uC0DD\uB7B5`);
|
|
28267
28425
|
continue;
|
|
@@ -28273,14 +28431,14 @@ async function renderHwpxToSvg(input, options) {
|
|
|
28273
28431
|
continue;
|
|
28274
28432
|
}
|
|
28275
28433
|
const geom = readSectionGeom(root);
|
|
28276
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
28434
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, hasCache, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _433 => _433.reflowMode]), () => ( "keep")));
|
|
28277
28435
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${si}` });
|
|
28278
28436
|
}
|
|
28279
28437
|
if (rendered.length === 0) {
|
|
28280
28438
|
if (noCacheSkipped) {
|
|
28281
|
-
throw new (0,
|
|
28439
|
+
throw new (0, _chunkNIZXIVEIcjs.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)");
|
|
28282
28440
|
}
|
|
28283
|
-
throw new (0,
|
|
28441
|
+
throw new (0, _chunkNIZXIVEIcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
28284
28442
|
}
|
|
28285
28443
|
const GAP = 2400;
|
|
28286
28444
|
const clipDefs = [];
|
|
@@ -28312,17 +28470,17 @@ ${groups.join("\n")}
|
|
|
28312
28470
|
// src/index.ts
|
|
28313
28471
|
async function parse(input, options) {
|
|
28314
28472
|
let buffer;
|
|
28315
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
28473
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _434 => _434.filePath]) ? { ...options, filePath: input } : options;
|
|
28316
28474
|
if (typeof input === "string") {
|
|
28317
28475
|
try {
|
|
28318
28476
|
const buf = await _promises.readFile.call(void 0, input);
|
|
28319
|
-
buffer =
|
|
28477
|
+
buffer = _chunkNIZXIVEIcjs.toArrayBuffer.call(void 0, buf);
|
|
28320
28478
|
} catch (err) {
|
|
28321
28479
|
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}`;
|
|
28322
28480
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
28323
28481
|
}
|
|
28324
28482
|
} else if (Buffer.isBuffer(input)) {
|
|
28325
|
-
buffer =
|
|
28483
|
+
buffer = _chunkNIZXIVEIcjs.toArrayBuffer.call(void 0, input);
|
|
28326
28484
|
} else {
|
|
28327
28485
|
buffer = input;
|
|
28328
28486
|
}
|
|
@@ -28357,21 +28515,21 @@ async function parseHwp3(buffer, options) {
|
|
|
28357
28515
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
28358
28516
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
28359
28517
|
} catch (err) {
|
|
28360
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28518
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28361
28519
|
}
|
|
28362
28520
|
}
|
|
28363
28521
|
async function parseHwpx(buffer, options) {
|
|
28364
28522
|
try {
|
|
28365
28523
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
28366
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28524
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _435 => _435.length]) ? images : void 0 };
|
|
28367
28525
|
} catch (err) {
|
|
28368
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28526
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28369
28527
|
}
|
|
28370
28528
|
}
|
|
28371
28529
|
async function parseHwp(buffer, options) {
|
|
28372
28530
|
try {
|
|
28373
28531
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
28374
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
28532
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _436 => _436.filePath])) {
|
|
28375
28533
|
try {
|
|
28376
28534
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
28377
28535
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -28388,15 +28546,15 @@ async function parseHwp(buffer, options) {
|
|
|
28388
28546
|
} catch (e32) {
|
|
28389
28547
|
}
|
|
28390
28548
|
}
|
|
28391
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28549
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _437 => _437.length]) ? images : void 0 };
|
|
28392
28550
|
} catch (err) {
|
|
28393
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28551
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28394
28552
|
}
|
|
28395
28553
|
}
|
|
28396
28554
|
async function parsePdf(buffer, options) {
|
|
28397
28555
|
let parsePdfDocument;
|
|
28398
28556
|
try {
|
|
28399
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
28557
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-44OPXZMP.cjs")));
|
|
28400
28558
|
parsePdfDocument = mod.parsePdfDocument;
|
|
28401
28559
|
} catch (e33) {
|
|
28402
28560
|
return {
|
|
@@ -28411,7 +28569,7 @@ async function parsePdf(buffer, options) {
|
|
|
28411
28569
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
28412
28570
|
} catch (err) {
|
|
28413
28571
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
28414
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28572
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err), isImageBased };
|
|
28415
28573
|
}
|
|
28416
28574
|
}
|
|
28417
28575
|
async function parseXlsx(buffer, options) {
|
|
@@ -28419,7 +28577,7 @@ async function parseXlsx(buffer, options) {
|
|
|
28419
28577
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
28420
28578
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
28421
28579
|
} catch (err) {
|
|
28422
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28580
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28423
28581
|
}
|
|
28424
28582
|
}
|
|
28425
28583
|
async function parseXls(buffer, options) {
|
|
@@ -28427,15 +28585,15 @@ async function parseXls(buffer, options) {
|
|
|
28427
28585
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
28428
28586
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
28429
28587
|
} catch (err) {
|
|
28430
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28588
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28431
28589
|
}
|
|
28432
28590
|
}
|
|
28433
28591
|
async function parseDocx(buffer, options) {
|
|
28434
28592
|
try {
|
|
28435
28593
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
28436
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
28594
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _438 => _438.length]) ? images : void 0 };
|
|
28437
28595
|
} catch (err) {
|
|
28438
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28596
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28439
28597
|
}
|
|
28440
28598
|
}
|
|
28441
28599
|
async function parseHwpml(buffer, options) {
|
|
@@ -28443,16 +28601,16 @@ async function parseHwpml(buffer, options) {
|
|
|
28443
28601
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
28444
28602
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
28445
28603
|
} catch (err) {
|
|
28446
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
28604
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkNIZXIVEIcjs.classifyError.call(void 0, err) };
|
|
28447
28605
|
}
|
|
28448
28606
|
}
|
|
28449
28607
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
28450
28608
|
let buffer;
|
|
28451
28609
|
if (typeof input === "string") {
|
|
28452
28610
|
const buf = await _promises.readFile.call(void 0, input);
|
|
28453
|
-
buffer =
|
|
28611
|
+
buffer = _chunkNIZXIVEIcjs.toArrayBuffer.call(void 0, buf);
|
|
28454
28612
|
} else if (Buffer.isBuffer(input)) {
|
|
28455
|
-
buffer =
|
|
28613
|
+
buffer = _chunkNIZXIVEIcjs.toArrayBuffer.call(void 0, input);
|
|
28456
28614
|
} else {
|
|
28457
28615
|
buffer = input;
|
|
28458
28616
|
}
|
|
@@ -28478,7 +28636,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
28478
28636
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
28479
28637
|
}
|
|
28480
28638
|
const fill = fillFormFields(parsed.blocks, values);
|
|
28481
|
-
const markdown =
|
|
28639
|
+
const markdown = _chunkNIZXIVEIcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
28482
28640
|
if (outputFormat === "hwpx") {
|
|
28483
28641
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
28484
28642
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -28544,5 +28702,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
28544
28702
|
|
|
28545
28703
|
|
|
28546
28704
|
|
|
28547
|
-
|
|
28705
|
+
|
|
28706
|
+
|
|
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 = _chunkNIZXIVEIcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkNIZXIVEIcjs.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;
|
|
28548
28708
|
//# sourceMappingURL=index.cjs.map
|