kordoc 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +806 -800
- package/dist/{-Q4ZCVQFI.js → -NDU7YGSS.js} +8 -8
- package/dist/{chunk-DKMKJMR6.js → chunk-4C7SBZNW.js} +2 -2
- package/dist/chunk-4C7SBZNW.js.map +1 -0
- package/dist/{chunk-MEPHGCPQ.js → chunk-5CJGKKMZ.js} +1 -1
- package/dist/chunk-5CJGKKMZ.js.map +1 -0
- package/dist/{chunk-S3KGEEBQ.js → chunk-5SOZXPQY.js} +3 -3
- package/dist/chunk-5SOZXPQY.js.map +1 -0
- package/dist/{chunk-TXNRIVWA.js → chunk-63ASYC4N.js} +3 -3
- package/dist/chunk-63ASYC4N.js.map +1 -0
- package/dist/{chunk-5RPYBC2Q.js → chunk-6GBLFQMA.js} +1 -1
- package/dist/chunk-6GBLFQMA.js.map +1 -0
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-NIW7CZYX.cjs → chunk-DQJTNXVS.cjs} +5 -4
- package/dist/chunk-DQJTNXVS.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-MLNHZN32.js → chunk-HC2SEH6I.js} +90 -17
- package/dist/chunk-HC2SEH6I.js.map +1 -0
- package/dist/{chunk-KSVLQ5BC.js → chunk-HOGJ5ALY.js} +5 -4
- package/dist/chunk-HOGJ5ALY.js.map +1 -0
- package/dist/{chunk-2RIOXYGA.js → chunk-KA4FEBS2.js} +2 -2
- package/dist/chunk-KA4FEBS2.js.map +1 -0
- package/dist/{chunk-KA5AN73R.js → chunk-L3I4TIRP.js} +2 -2
- package/dist/chunk-L3I4TIRP.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-ZJXR4PWY.js → chunk-UVSOSFER.js} +5 -4
- package/dist/chunk-UVSOSFER.js.map +1 -0
- package/dist/cli.js +15 -15
- package/dist/cli.js.map +1 -1
- package/dist/{detect-RI2MQ33K.js → detect-PJZMUL2Z.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +437 -364
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +84 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +13 -13
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +0 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-46JGSTPR.js → parser-C636QIOB.js} +72 -4
- package/dist/parser-C636QIOB.js.map +1 -0
- package/dist/{parser-TLCC67W6.js → parser-DMKHIV4E.js} +71 -3
- package/dist/parser-DMKHIV4E.js.map +1 -0
- package/dist/{parser-2ZUTCU2G.cjs → parser-VEY4B5CJ.cjs} +83 -15
- package/dist/parser-VEY4B5CJ.cjs.map +1 -0
- package/dist/{profile-io-MRVIJ5T4.js → profile-io-JYGCC6XQ.js} +3 -3
- package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
- package/dist/provider-5K7O3Z2O.cjs.map +1 -0
- package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
- package/dist/provider-7H4CPZYS.js.map +1 -0
- package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
- package/dist/provider-H4WWSPOV.js.map +1 -0
- package/dist/render-ISOEOMTM.js +10 -0
- package/dist/seal-676ZIAZZ.js +10 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-NZNVJ4YD.js → watch-ZQUFJBFR.js} +8 -8
- package/dist/watch-ZQUFJBFR.js.map +1 -0
- package/package.json +97 -97
- package/dist/chunk-2RIOXYGA.js.map +0 -1
- package/dist/chunk-5RPYBC2Q.js.map +0 -1
- package/dist/chunk-DKMKJMR6.js.map +0 -1
- package/dist/chunk-KA5AN73R.js.map +0 -1
- package/dist/chunk-KSVLQ5BC.js.map +0 -1
- package/dist/chunk-MEPHGCPQ.js.map +0 -1
- package/dist/chunk-MLNHZN32.js.map +0 -1
- package/dist/chunk-NIW7CZYX.cjs.map +0 -1
- package/dist/chunk-S3KGEEBQ.js.map +0 -1
- package/dist/chunk-TXNRIVWA.js.map +0 -1
- package/dist/chunk-ZJXR4PWY.js.map +0 -1
- package/dist/parser-2ZUTCU2G.cjs.map +0 -1
- package/dist/parser-46JGSTPR.js.map +0 -1
- package/dist/parser-TLCC67W6.js.map +0 -1
- package/dist/provider-4ZJKV3DC.js.map +0 -1
- package/dist/provider-AKROB7WQ.js.map +0 -1
- package/dist/provider-G4C2V2PD.cjs.map +0 -1
- package/dist/render-TTOG6CHW.js +0 -10
- package/dist/seal-NMLZ3M3K.js +0 -10
- package/dist/watch-NZNVJ4YD.js.map +0 -1
- /package/dist/{-Q4ZCVQFI.js.map → -NDU7YGSS.js.map} +0 -0
- /package/dist/{detect-RI2MQ33K.js.map → detect-PJZMUL2Z.js.map} +0 -0
- /package/dist/{profile-io-MRVIJ5T4.js.map → profile-io-JYGCC6XQ.js.map} +0 -0
- /package/dist/{render-TTOG6CHW.js.map → render-ISOEOMTM.js.map} +0 -0
- /package/dist/{seal-NMLZ3M3K.js.map → seal-676ZIAZZ.js.map} +0 -0
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
dedupeRunningHeaders,
|
|
12
12
|
flattenLayoutTables,
|
|
13
13
|
mapPuaText
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UVSOSFER.js";
|
|
15
15
|
import {
|
|
16
16
|
detectFormat,
|
|
17
17
|
detectOle2Format,
|
|
18
18
|
detectZipFormat,
|
|
19
19
|
parseLenientCfb
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-5CJGKKMZ.js";
|
|
21
21
|
import {
|
|
22
22
|
parsePageRange
|
|
23
23
|
} from "./chunk-MOL7MDBG.js";
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
paraTextPureT,
|
|
33
33
|
patchZipEntries,
|
|
34
34
|
scanSectionXml
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-63ASYC4N.js";
|
|
36
36
|
import {
|
|
37
37
|
SPACE_EM_FIXED,
|
|
38
38
|
charWidthEm1000,
|
|
39
39
|
fitRatioForFewerLines,
|
|
40
40
|
measureTextWidth,
|
|
41
41
|
simulateWrap
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-5SOZXPQY.js";
|
|
43
43
|
import {
|
|
44
44
|
MAX_DECOMPRESS_SIZE,
|
|
45
45
|
MAX_XML_DEPTH,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
createXmlParser,
|
|
51
51
|
extractTextFromNode,
|
|
52
52
|
findChildByLocalName
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-4C7SBZNW.js";
|
|
54
54
|
import {
|
|
55
55
|
KordocError,
|
|
56
56
|
classifyError,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
sanitizeHref,
|
|
62
62
|
stripDtd,
|
|
63
63
|
toArrayBuffer
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-L3I4TIRP.js";
|
|
65
65
|
|
|
66
66
|
// src/index.ts
|
|
67
67
|
import { readFile } from "fs/promises";
|
|
@@ -1557,8 +1557,9 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1557
1557
|
if (footnote) text += ` (\uC8FC: ${footnote})`;
|
|
1558
1558
|
cell2.text += (cell2.text ? "\n" : "") + text;
|
|
1559
1559
|
const cellBlock = { type: "paragraph", text, pageNumber: ctx.sectionNum };
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
const cellSpanMode = spanModeOf(ctx.shared.kordocLayout);
|
|
1561
|
+
if (cellSpanMode && !ph?.prefix) {
|
|
1562
|
+
const spans = extractRunSpans(el, ctx, cellSpanMode, cellSpanMode !== "kordoc");
|
|
1562
1563
|
if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
|
|
1563
1564
|
cellBlock.spans = spans;
|
|
1564
1565
|
}
|
|
@@ -1581,14 +1582,19 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1581
1582
|
const eff = ind.left + Math.max(0, ind.intent);
|
|
1582
1583
|
if (eff > 0) block.indent = eff;
|
|
1583
1584
|
}
|
|
1584
|
-
if (
|
|
1585
|
+
if (ctx.shared.kordocLayout === "gongmun" && block.indent && /^(?:-|\d{1,3}\)) /.test(text)) {
|
|
1586
|
+
const depth2 = gongmunDepthFromIndent(el, block.indent, ctx);
|
|
1587
|
+
if (depth2) block.listDepth = depth2;
|
|
1588
|
+
}
|
|
1589
|
+
const spanMode = spanModeOf(ctx.shared.kordocLayout);
|
|
1590
|
+
if (!headingLevel && spanMode) {
|
|
1585
1591
|
if (!ph?.prefix) {
|
|
1586
|
-
const spans = extractRunSpans(el, ctx);
|
|
1592
|
+
const spans = extractRunSpans(el, ctx, spanMode, spanMode === "gongmun");
|
|
1587
1593
|
if (spans && spans.map((s) => s.text).join("").replace(/[ \t]+/g, " ").trim() === text) {
|
|
1588
1594
|
block.spans = spans;
|
|
1589
1595
|
}
|
|
1590
1596
|
}
|
|
1591
|
-
if (el.getAttribute("paraPrIDRef") === KORDOC_PARA_QUOTE) block.quote = true;
|
|
1597
|
+
if (spanMode !== "foreign" && el.getAttribute("paraPrIDRef") === KORDOC_PARA_QUOTE) block.quote = true;
|
|
1592
1598
|
}
|
|
1593
1599
|
blocks.push(block);
|
|
1594
1600
|
} else {
|
|
@@ -1711,8 +1717,15 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
1711
1717
|
if (tag === "p" || tag === "para") {
|
|
1712
1718
|
const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
|
|
1713
1719
|
if (t) parts.push(t);
|
|
1720
|
+
const tbls = [];
|
|
1721
|
+
findTopLevelTbls(ch, tbls);
|
|
1722
|
+
for (const tbl2 of tbls) {
|
|
1723
|
+
const flat = flattenSubListTable(tbl2, ctx, depth);
|
|
1724
|
+
if (flat) parts.push(flat);
|
|
1725
|
+
}
|
|
1714
1726
|
} else if (tag === "tbl") {
|
|
1715
|
-
|
|
1727
|
+
const flat = flattenSubListTable(ch, ctx, depth);
|
|
1728
|
+
if (flat) parts.push(flat);
|
|
1716
1729
|
} else {
|
|
1717
1730
|
const t = collectSubListText(ch, ctx, depth + 1);
|
|
1718
1731
|
if (t) parts.push(t);
|
|
@@ -1720,6 +1733,29 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
1720
1733
|
}
|
|
1721
1734
|
return parts.join("\n").trim();
|
|
1722
1735
|
}
|
|
1736
|
+
function flattenSubListTable(el, ctx, depth) {
|
|
1737
|
+
const sink = [];
|
|
1738
|
+
const st = { rows: [], currentRow: [], cell: null };
|
|
1739
|
+
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
1740
|
+
let flat = convertTableToText(st.rows);
|
|
1741
|
+
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
1742
|
+
return flat;
|
|
1743
|
+
}
|
|
1744
|
+
function findTopLevelTbls(el, out, depth = 0) {
|
|
1745
|
+
if (depth > MAX_XML_DEPTH) return;
|
|
1746
|
+
const kids2 = el.childNodes;
|
|
1747
|
+
if (!kids2) return;
|
|
1748
|
+
for (let i = 0; i < kids2.length; i++) {
|
|
1749
|
+
const ch = kids2[i];
|
|
1750
|
+
if (ch.nodeType !== 1) continue;
|
|
1751
|
+
const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
|
|
1752
|
+
if (tag === "tbl") {
|
|
1753
|
+
out.push(ch);
|
|
1754
|
+
continue;
|
|
1755
|
+
}
|
|
1756
|
+
findTopLevelTbls(ch, out, depth + 1);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1723
1759
|
function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
1724
1760
|
if (depth > MAX_XML_DEPTH) return tableCtx;
|
|
1725
1761
|
const children = node.childNodes;
|
|
@@ -2078,7 +2114,13 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2078
2114
|
}
|
|
2079
2115
|
var KORDOC_CHAR_CODE = "4";
|
|
2080
2116
|
var KORDOC_PARA_QUOTE = "6";
|
|
2081
|
-
function
|
|
2117
|
+
function spanModeOf(layout) {
|
|
2118
|
+
if (layout === "default") return "kordoc";
|
|
2119
|
+
if (layout === "gongmun") return "gongmun";
|
|
2120
|
+
if (!layout) return "foreign";
|
|
2121
|
+
return null;
|
|
2122
|
+
}
|
|
2123
|
+
function extractRunSpans(para2, ctx, mode, requireMixed) {
|
|
2082
2124
|
const styleMap = ctx.styleMap;
|
|
2083
2125
|
if (!styleMap) return null;
|
|
2084
2126
|
const spans = [];
|
|
@@ -2115,7 +2157,7 @@ function extractRunSpans(para2, ctx) {
|
|
|
2115
2157
|
const prId = child.getAttribute("charPrIDRef") ?? "";
|
|
2116
2158
|
const cp = styleMap.charProperties.get(prId);
|
|
2117
2159
|
const span = { text };
|
|
2118
|
-
if (prId === KORDOC_CHAR_CODE) span.code = true;
|
|
2160
|
+
if (mode !== "foreign" && prId === KORDOC_CHAR_CODE) span.code = true;
|
|
2119
2161
|
else {
|
|
2120
2162
|
if (cp?.bold) span.bold = true;
|
|
2121
2163
|
if (cp?.italic) span.italic = true;
|
|
@@ -2123,7 +2165,38 @@ function extractRunSpans(para2, ctx) {
|
|
|
2123
2165
|
if (span.bold || span.italic || span.code) styled = true;
|
|
2124
2166
|
spans.push(span);
|
|
2125
2167
|
}
|
|
2126
|
-
|
|
2168
|
+
if (!styled || spans.length === 0) return null;
|
|
2169
|
+
const merged = [];
|
|
2170
|
+
for (const s of spans) {
|
|
2171
|
+
const last = merged[merged.length - 1];
|
|
2172
|
+
if (last && !!last.bold === !!s.bold && !!last.italic === !!s.italic && !!last.code === !!s.code) {
|
|
2173
|
+
last.text += s.text;
|
|
2174
|
+
} else {
|
|
2175
|
+
merged.push(s);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
if (requireMixed && !merged.some((s) => !(s.bold || s.italic || s.code))) return null;
|
|
2179
|
+
return merged;
|
|
2180
|
+
}
|
|
2181
|
+
function gongmunDepthFromIndent(para2, left, ctx) {
|
|
2182
|
+
const styleMap = ctx.styleMap;
|
|
2183
|
+
if (!styleMap) return null;
|
|
2184
|
+
let unit = 0;
|
|
2185
|
+
const kids2 = para2.childNodes;
|
|
2186
|
+
for (let i = 0; i < (kids2?.length ?? 0); i++) {
|
|
2187
|
+
const child = kids2[i];
|
|
2188
|
+
if (child.nodeType !== 1) continue;
|
|
2189
|
+
const tag = (child.tagName || child.localName || "").replace(/^[^:]+:/, "");
|
|
2190
|
+
if (tag !== "run" && tag !== "r") continue;
|
|
2191
|
+
const size = styleMap.charProperties.get(child.getAttribute("charPrIDRef") ?? "")?.fontSize;
|
|
2192
|
+
if (size) unit = size * 100;
|
|
2193
|
+
break;
|
|
2194
|
+
}
|
|
2195
|
+
if (!unit) return null;
|
|
2196
|
+
const r = left / unit;
|
|
2197
|
+
const nearInt = Math.round(r);
|
|
2198
|
+
const depth = Math.abs(r - nearInt) < 0.2 ? nearInt : Math.round(2 * r - 1);
|
|
2199
|
+
return depth >= 1 && depth < 8 ? depth : null;
|
|
2127
2200
|
}
|
|
2128
2201
|
|
|
2129
2202
|
// src/hwpx/images.ts
|
|
@@ -27030,7 +27103,7 @@ async function parseHwp(buffer, options) {
|
|
|
27030
27103
|
async function parsePdf(buffer, options) {
|
|
27031
27104
|
let parsePdfDocument;
|
|
27032
27105
|
try {
|
|
27033
|
-
const mod = await import("./parser-
|
|
27106
|
+
const mod = await import("./parser-C636QIOB.js");
|
|
27034
27107
|
parsePdfDocument = mod.parsePdfDocument;
|
|
27035
27108
|
} catch {
|
|
27036
27109
|
return {
|
|
@@ -27163,4 +27236,4 @@ export {
|
|
|
27163
27236
|
parseHwpml,
|
|
27164
27237
|
fillForm
|
|
27165
27238
|
};
|
|
27166
|
-
//# sourceMappingURL=chunk-
|
|
27239
|
+
//# sourceMappingURL=chunk-HC2SEH6I.js.map
|