kordoc 4.0.5 → 4.0.7
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/LICENSE +21 -21
- package/README.md +806 -800
- package/dist/{-QVHGOOCR.js → -6HWEFXVV.js} +9 -9
- package/dist/{chunk-6PED5OOG.js → chunk-2SN3CKME.js} +2 -2
- package/dist/chunk-2SN3CKME.js.map +1 -0
- package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
- package/dist/chunk-3TBUDJDE.js.map +1 -0
- package/dist/{chunk-FKK4K53F.js → chunk-5OKHAJ62.js} +2 -2
- package/dist/chunk-5OKHAJ62.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-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
- package/dist/chunk-AIQ3ISQU.js.map +1 -0
- package/dist/{chunk-OMERK4AW.js → chunk-BKWHX3RC.js} +3 -3
- package/dist/chunk-BKWHX3RC.js.map +1 -0
- package/dist/{chunk-MEPHGCPQ.js → chunk-CFQLK3LM.js} +1 -1
- package/dist/chunk-CFQLK3LM.js.map +1 -0
- package/dist/{chunk-6BABRVOJ.js → chunk-CNM75ZSX.js} +2 -2
- package/dist/chunk-CNM75ZSX.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-6WDPB4SN.js → chunk-NGSHDBQR.js} +3 -3
- package/dist/chunk-NGSHDBQR.js.map +1 -0
- package/dist/{chunk-ZGMMLYAL.js → chunk-ONXVBURQ.js} +2 -2
- package/dist/chunk-ONXVBURQ.js.map +1 -0
- package/dist/{chunk-QK2G34WE.js → chunk-Q7EN4EUJ.js} +2 -2
- package/dist/chunk-Q7EN4EUJ.js.map +1 -0
- package/dist/{chunk-Z6Q3YG22.js → chunk-TJJTLM76.js} +197 -98
- package/dist/chunk-TJJTLM76.js.map +1 -0
- package/dist/{chunk-6R5FY47W.cjs → chunk-U25XGCNH.cjs} +2 -2
- package/dist/chunk-U25XGCNH.cjs.map +1 -0
- package/dist/{chunk-DCZVOIEO.cjs → chunk-X34YWRL5.cjs} +1 -1
- package/dist/chunk-X34YWRL5.cjs.map +1 -0
- package/dist/cli.js +18 -18
- package/dist/cli.js.map +1 -1
- package/dist/{detect-RI2MQ33K.js → detect-NTR2FUEG.js} +2 -2
- package/dist/{formula-JCNF43NE.js → formula-KOQV353G.js} +1 -1
- package/dist/formula-KOQV353G.js.map +1 -0
- package/dist/{formula-RXVSQPXI.js → formula-MEDGYQXS.js} +1 -1
- package/dist/formula-MEDGYQXS.js.map +1 -0
- package/dist/{formula-5NKVS2LR.cjs → formula-ZYUDQHD3.cjs} +1 -1
- package/dist/formula-ZYUDQHD3.cjs.map +1 -0
- package/dist/index.cjs +328 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +191 -92
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +14 -14
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-CIRRJPXJ.js +7 -0
- package/dist/page-range-OF5I4PQY.js +8 -0
- package/dist/page-range-TPIRSA3J.cjs +8 -0
- package/dist/page-range-TPIRSA3J.cjs.map +1 -0
- package/dist/{parser-3MAYZUJX.js → parser-5EHWYJMC.js} +93 -7
- package/dist/parser-5EHWYJMC.js.map +1 -0
- package/dist/{parser-2V5SPTU7.cjs → parser-E6U5TNAU.cjs} +105 -19
- package/dist/parser-E6U5TNAU.cjs.map +1 -0
- package/dist/{parser-YSHZC5FQ.js → parser-UGB3NIVH.js} +92 -6
- package/dist/parser-UGB3NIVH.js.map +1 -0
- package/dist/{profile-io-3EECPDHG.js → profile-io-CAKRPQRD.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-P6663O4I.js +10 -0
- package/dist/seal-7PPTXKKV.js +10 -0
- package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
- package/dist/setup-QSJ2INNS.js.map +1 -0
- package/dist/{watch-7MHSCKEQ.js → watch-RMX427YR.js} +9 -9
- package/dist/watch-RMX427YR.js.map +1 -0
- package/package.json +97 -97
- package/dist/chunk-5RPYBC2Q.js.map +0 -1
- package/dist/chunk-6BABRVOJ.js.map +0 -1
- package/dist/chunk-6PED5OOG.js.map +0 -1
- package/dist/chunk-6R5FY47W.cjs.map +0 -1
- package/dist/chunk-6WDPB4SN.js.map +0 -1
- package/dist/chunk-DCZVOIEO.cjs.map +0 -1
- package/dist/chunk-FKK4K53F.js.map +0 -1
- package/dist/chunk-GE43BE46.js.map +0 -1
- package/dist/chunk-MEPHGCPQ.js.map +0 -1
- package/dist/chunk-MOL7MDBG.js.map +0 -1
- package/dist/chunk-OMERK4AW.js.map +0 -1
- package/dist/chunk-QK2G34WE.js.map +0 -1
- package/dist/chunk-Z6Q3YG22.js.map +0 -1
- package/dist/chunk-ZGMMLYAL.js.map +0 -1
- package/dist/formula-5NKVS2LR.cjs.map +0 -1
- package/dist/formula-JCNF43NE.js.map +0 -1
- package/dist/formula-RXVSQPXI.js.map +0 -1
- package/dist/page-range-737B4EZW.js +0 -8
- package/dist/page-range-LNMXJU6W.js +0 -7
- package/dist/page-range-P7SDW6LR.cjs +0 -8
- package/dist/page-range-P7SDW6LR.cjs.map +0 -1
- package/dist/parser-2V5SPTU7.cjs.map +0 -1
- package/dist/parser-3MAYZUJX.js.map +0 -1
- package/dist/parser-YSHZC5FQ.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-MJSQ4TG2.js +0 -10
- package/dist/seal-R3POFNOU.js +0 -10
- package/dist/setup-57FB3LSP.js.map +0 -1
- package/dist/watch-7MHSCKEQ.js.map +0 -1
- /package/dist/{-QVHGOOCR.js.map → -6HWEFXVV.js.map} +0 -0
- /package/dist/{detect-RI2MQ33K.js.map → detect-NTR2FUEG.js.map} +0 -0
- /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
- /package/dist/{page-range-LNMXJU6W.js.map → page-range-OF5I4PQY.js.map} +0 -0
- /package/dist/{profile-io-3EECPDHG.js.map → profile-io-CAKRPQRD.js.map} +0 -0
- /package/dist/{render-MJSQ4TG2.js.map → render-P6663O4I.js.map} +0 -0
- /package/dist/{seal-R3POFNOU.js.map → seal-7PPTXKKV.js.map} +0 -0
|
@@ -11,16 +11,16 @@ import {
|
|
|
11
11
|
dedupeRunningHeaders,
|
|
12
12
|
flattenLayoutTables,
|
|
13
13
|
mapPuaText
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2SN3CKME.js";
|
|
15
15
|
import {
|
|
16
16
|
detectFormat,
|
|
17
17
|
detectOle2Format,
|
|
18
18
|
detectZipFormat,
|
|
19
19
|
parseLenientCfb
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-CFQLK3LM.js";
|
|
21
21
|
import {
|
|
22
22
|
parsePageRange
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-3TBUDJDE.js";
|
|
24
24
|
import {
|
|
25
25
|
allLinesegRemovalSplices,
|
|
26
26
|
applySplices,
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
paraTextPureT,
|
|
33
33
|
patchZipEntries,
|
|
34
34
|
scanSectionXml
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-NGSHDBQR.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-BKWHX3RC.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-Q7EN4EUJ.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-CNM75ZSX.js";
|
|
65
65
|
|
|
66
66
|
// src/index.ts
|
|
67
67
|
import { readFile } from "fs/promises";
|
|
@@ -1717,8 +1717,15 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
1717
1717
|
if (tag === "p" || tag === "para") {
|
|
1718
1718
|
const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
|
|
1719
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
|
+
}
|
|
1720
1726
|
} else if (tag === "tbl") {
|
|
1721
|
-
|
|
1727
|
+
const flat = flattenSubListTable(ch, ctx, depth);
|
|
1728
|
+
if (flat) parts.push(flat);
|
|
1722
1729
|
} else {
|
|
1723
1730
|
const t = collectSubListText(ch, ctx, depth + 1);
|
|
1724
1731
|
if (t) parts.push(t);
|
|
@@ -1726,6 +1733,29 @@ function collectSubListText(el, ctx, depth = 0) {
|
|
|
1726
1733
|
}
|
|
1727
1734
|
return parts.join("\n").trim();
|
|
1728
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
|
+
}
|
|
1729
1759
|
function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
1730
1760
|
if (depth > MAX_XML_DEPTH) return tableCtx;
|
|
1731
1761
|
const children = node.childNodes;
|
|
@@ -17542,7 +17572,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17542
17572
|
}
|
|
17543
17573
|
let pageFilter = null;
|
|
17544
17574
|
if (options?.pages) {
|
|
17545
|
-
const { parsePageRange: parsePageRange2 } = await import("./page-range-
|
|
17575
|
+
const { parsePageRange: parsePageRange2 } = await import("./page-range-OF5I4PQY.js");
|
|
17546
17576
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
17547
17577
|
}
|
|
17548
17578
|
const blocks = [];
|
|
@@ -18180,7 +18210,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18180
18210
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18181
18211
|
let pageFilter = null;
|
|
18182
18212
|
if (options?.pages) {
|
|
18183
|
-
const { parsePageRange: parsePageRange2 } = await import("./page-range-
|
|
18213
|
+
const { parsePageRange: parsePageRange2 } = await import("./page-range-OF5I4PQY.js");
|
|
18184
18214
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18185
18215
|
}
|
|
18186
18216
|
const allBlocks = [];
|
|
@@ -18782,6 +18812,102 @@ function extractRun(r) {
|
|
|
18782
18812
|
}
|
|
18783
18813
|
return { text, bold, italic };
|
|
18784
18814
|
}
|
|
18815
|
+
function fieldUrlFromInstr(instr) {
|
|
18816
|
+
if (!/HYPERLINK\b/i.test(instr)) return null;
|
|
18817
|
+
const urlM = instr.match(/HYPERLINK\s+"([^"]*)"/i);
|
|
18818
|
+
const anchorM = instr.match(/\\l\s+"([^"]*)"/i);
|
|
18819
|
+
if (urlM && urlM[1]) {
|
|
18820
|
+
return anchorM && anchorM[1] ? `${urlM[1]}#${anchorM[1]}` : urlM[1];
|
|
18821
|
+
}
|
|
18822
|
+
if (anchorM && anchorM[1]) return `#${anchorM[1]}`;
|
|
18823
|
+
return null;
|
|
18824
|
+
}
|
|
18825
|
+
function makeLink(text, rawHref) {
|
|
18826
|
+
if (!text) return "";
|
|
18827
|
+
if (!rawHref) return text;
|
|
18828
|
+
const href = sanitizeHref(rawHref);
|
|
18829
|
+
return href ? `[${text}](${href})` : text;
|
|
18830
|
+
}
|
|
18831
|
+
function collectInline(p, footnotes, rels) {
|
|
18832
|
+
const parts = [];
|
|
18833
|
+
let bold = false;
|
|
18834
|
+
let italic = false;
|
|
18835
|
+
let footnoteText;
|
|
18836
|
+
let fieldActive = false;
|
|
18837
|
+
let fieldStage = "instr";
|
|
18838
|
+
let fieldInstr = "";
|
|
18839
|
+
let fieldDisplay = "";
|
|
18840
|
+
const flushField = () => {
|
|
18841
|
+
if (!fieldActive) return;
|
|
18842
|
+
if (fieldDisplay) {
|
|
18843
|
+
const url = fieldUrlFromInstr(fieldInstr);
|
|
18844
|
+
parts.push(url ? makeLink(fieldDisplay, url) : fieldDisplay);
|
|
18845
|
+
}
|
|
18846
|
+
fieldActive = false;
|
|
18847
|
+
fieldStage = "instr";
|
|
18848
|
+
fieldInstr = "";
|
|
18849
|
+
fieldDisplay = "";
|
|
18850
|
+
};
|
|
18851
|
+
for (const el of effectiveChildElements(p)) {
|
|
18852
|
+
if (matchesLocal(el, "hyperlink")) {
|
|
18853
|
+
const rId = getAttr(el, "id");
|
|
18854
|
+
const anchor = getAttr(el, "anchor");
|
|
18855
|
+
const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
|
|
18856
|
+
if (!t) continue;
|
|
18857
|
+
let raw = null;
|
|
18858
|
+
if (rId && rels.has(rId)) raw = rels.get(rId);
|
|
18859
|
+
else if (anchor) raw = `#${anchor}`;
|
|
18860
|
+
if (fieldActive && fieldStage === "display") fieldDisplay += t;
|
|
18861
|
+
else parts.push(makeLink(t, raw));
|
|
18862
|
+
continue;
|
|
18863
|
+
}
|
|
18864
|
+
if (matchesLocal(el, "fldSimple")) {
|
|
18865
|
+
const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
|
|
18866
|
+
if (!t) continue;
|
|
18867
|
+
const url = fieldUrlFromInstr(getAttr(el, "instr") ?? "");
|
|
18868
|
+
parts.push(url ? makeLink(t, url) : t);
|
|
18869
|
+
continue;
|
|
18870
|
+
}
|
|
18871
|
+
if (matchesLocal(el, "r")) {
|
|
18872
|
+
for (const fc of getChildElements(el, "fldChar")) {
|
|
18873
|
+
const ty = getAttr(fc, "fldCharType");
|
|
18874
|
+
if (ty === "begin") {
|
|
18875
|
+
flushField();
|
|
18876
|
+
fieldActive = true;
|
|
18877
|
+
fieldStage = "instr";
|
|
18878
|
+
} else if (ty === "separate") {
|
|
18879
|
+
if (fieldActive) fieldStage = "display";
|
|
18880
|
+
} else if (ty === "end") flushField();
|
|
18881
|
+
}
|
|
18882
|
+
if (fieldActive && fieldStage === "instr") {
|
|
18883
|
+
for (const it of getChildElements(el, "instrText")) fieldInstr += it.textContent ?? "";
|
|
18884
|
+
}
|
|
18885
|
+
const rr = extractRun(el);
|
|
18886
|
+
if (rr.bold) bold = true;
|
|
18887
|
+
if (rr.italic) italic = true;
|
|
18888
|
+
const fnRefEls = getChildElements(el, "footnoteReference");
|
|
18889
|
+
if (fnRefEls.length > 0) {
|
|
18890
|
+
const fnId = getAttr(fnRefEls[0], "id");
|
|
18891
|
+
if (fnId && footnotes.has(fnId)) footnoteText = footnotes.get(fnId);
|
|
18892
|
+
}
|
|
18893
|
+
if (rr.text) {
|
|
18894
|
+
if (fieldActive && fieldStage === "display") fieldDisplay += rr.text;
|
|
18895
|
+
else if (fieldActive && fieldStage === "instr") {
|
|
18896
|
+
} else parts.push(rr.text);
|
|
18897
|
+
}
|
|
18898
|
+
continue;
|
|
18899
|
+
}
|
|
18900
|
+
}
|
|
18901
|
+
flushField();
|
|
18902
|
+
for (const om of collectOmmlRoots(p)) {
|
|
18903
|
+
const latex = ommlElementToLatex(om);
|
|
18904
|
+
if (!latex) continue;
|
|
18905
|
+
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
18906
|
+
else parts.push(" $" + latex + "$ ");
|
|
18907
|
+
}
|
|
18908
|
+
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18909
|
+
return { text, bold, italic, footnoteText };
|
|
18910
|
+
}
|
|
18785
18911
|
function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
18786
18912
|
const pPrEls = getChildElements(p, "pPr");
|
|
18787
18913
|
let styleId = "";
|
|
@@ -18798,54 +18924,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18798
18924
|
ilvl = ilvlEls.length > 0 ? parseInt(getAttr(ilvlEls[0], "val") ?? "0", 10) : 0;
|
|
18799
18925
|
}
|
|
18800
18926
|
}
|
|
18801
|
-
const
|
|
18802
|
-
let hasBold = false;
|
|
18803
|
-
let hasItalic = false;
|
|
18804
|
-
let href;
|
|
18805
|
-
let footnoteText;
|
|
18806
|
-
const hyperlinks = getChildElements(p, "hyperlink");
|
|
18807
|
-
const hyperlinkTexts = /* @__PURE__ */ new Set();
|
|
18808
|
-
for (const hl of hyperlinks) {
|
|
18809
|
-
const rId = getAttr(hl, "id");
|
|
18810
|
-
const hlText = [];
|
|
18811
|
-
const runs2 = findElements(hl, "r");
|
|
18812
|
-
for (const r of runs2) {
|
|
18813
|
-
const result = extractRun(r);
|
|
18814
|
-
hlText.push(result.text);
|
|
18815
|
-
}
|
|
18816
|
-
const text2 = hlText.join("");
|
|
18817
|
-
if (text2) {
|
|
18818
|
-
hyperlinkTexts.add(text2);
|
|
18819
|
-
if (rId && rels.has(rId)) {
|
|
18820
|
-
href = rels.get(rId);
|
|
18821
|
-
parts.push(text2);
|
|
18822
|
-
} else {
|
|
18823
|
-
parts.push(text2);
|
|
18824
|
-
}
|
|
18825
|
-
}
|
|
18826
|
-
}
|
|
18827
|
-
const runs = getChildElements(p, "r");
|
|
18828
|
-
for (const r of runs) {
|
|
18829
|
-
if (r.parentNode && r.parentNode.localName === "hyperlink") continue;
|
|
18830
|
-
const result = extractRun(r);
|
|
18831
|
-
if (result.bold) hasBold = true;
|
|
18832
|
-
if (result.italic) hasItalic = true;
|
|
18833
|
-
const fnRefEls = getChildElements(r, "footnoteReference");
|
|
18834
|
-
if (fnRefEls.length > 0) {
|
|
18835
|
-
const fnId = getAttr(fnRefEls[0], "id");
|
|
18836
|
-
if (fnId && footnotes.has(fnId)) {
|
|
18837
|
-
footnoteText = footnotes.get(fnId);
|
|
18838
|
-
}
|
|
18839
|
-
}
|
|
18840
|
-
if (result.text) parts.push(result.text);
|
|
18841
|
-
}
|
|
18842
|
-
for (const om of collectOmmlRoots(p)) {
|
|
18843
|
-
const latex = ommlElementToLatex(om);
|
|
18844
|
-
if (!latex) continue;
|
|
18845
|
-
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
18846
|
-
else parts.push(" $" + latex + "$ ");
|
|
18847
|
-
}
|
|
18848
|
-
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18927
|
+
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
18849
18928
|
if (!text) return null;
|
|
18850
18929
|
const style = styles.get(styleId);
|
|
18851
18930
|
if (style?.outlineLevel !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
@@ -18865,7 +18944,6 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18865
18944
|
if (hasBold || hasItalic) {
|
|
18866
18945
|
block.style = { bold: hasBold || void 0, italic: hasItalic || void 0 };
|
|
18867
18946
|
}
|
|
18868
|
-
if (href) block.href = href;
|
|
18869
18947
|
if (footnoteText) block.footnoteText = footnoteText;
|
|
18870
18948
|
return block;
|
|
18871
18949
|
}
|
|
@@ -18966,46 +19044,61 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
18966
19044
|
}
|
|
18967
19045
|
return parts;
|
|
18968
19046
|
}
|
|
18969
|
-
async function
|
|
18970
|
-
const
|
|
19047
|
+
async function buildImageMap(zip, rels, doc, warnings) {
|
|
19048
|
+
const imageMap = /* @__PURE__ */ new Map();
|
|
18971
19049
|
const images = [];
|
|
18972
|
-
const drawingElements = findElements(doc.documentElement, "drawing");
|
|
18973
19050
|
let imgIdx = 0;
|
|
18974
|
-
for (const
|
|
18975
|
-
const
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
18982
|
-
|
|
18983
|
-
|
|
18984
|
-
|
|
18985
|
-
|
|
18986
|
-
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19004
|
-
});
|
|
19005
|
-
}
|
|
19051
|
+
for (const blip of findElements(doc.documentElement, "blip")) {
|
|
19052
|
+
const embedId = getAttr(blip, "embed");
|
|
19053
|
+
if (!embedId || imageMap.has(embedId)) continue;
|
|
19054
|
+
const target = rels.get(embedId);
|
|
19055
|
+
if (!target) continue;
|
|
19056
|
+
const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
|
|
19057
|
+
const imgFile = zip.file(imgPath);
|
|
19058
|
+
if (!imgFile) continue;
|
|
19059
|
+
try {
|
|
19060
|
+
const data = await imgFile.async("uint8array");
|
|
19061
|
+
imgIdx++;
|
|
19062
|
+
const ext = imgPath.split(".").pop()?.toLowerCase() ?? "png";
|
|
19063
|
+
const mimeMap = {
|
|
19064
|
+
png: "image/png",
|
|
19065
|
+
jpg: "image/jpeg",
|
|
19066
|
+
jpeg: "image/jpeg",
|
|
19067
|
+
gif: "image/gif",
|
|
19068
|
+
bmp: "image/bmp",
|
|
19069
|
+
wmf: "image/wmf",
|
|
19070
|
+
emf: "image/emf"
|
|
19071
|
+
};
|
|
19072
|
+
const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
|
|
19073
|
+
images.push({ filename, data, mimeType: mimeMap[ext] ?? "image/png" });
|
|
19074
|
+
imageMap.set(embedId, filename);
|
|
19075
|
+
} catch (err) {
|
|
19076
|
+
warnings.push({
|
|
19077
|
+
code: "SKIPPED_IMAGE",
|
|
19078
|
+
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19079
|
+
});
|
|
19006
19080
|
}
|
|
19007
19081
|
}
|
|
19008
|
-
return {
|
|
19082
|
+
return { imageMap, images };
|
|
19083
|
+
}
|
|
19084
|
+
function collectParagraphBlips(node, out = [], depth = 0) {
|
|
19085
|
+
if (depth > 40) return out;
|
|
19086
|
+
for (const el of effectiveChildElements(node)) {
|
|
19087
|
+
if (matchesLocal(el, "txbxContent") || matchesLocal(el, "Fallback")) continue;
|
|
19088
|
+
if (matchesLocal(el, "blip")) out.push(el);
|
|
19089
|
+
else collectParagraphBlips(el, out, depth + 1);
|
|
19090
|
+
}
|
|
19091
|
+
return out;
|
|
19092
|
+
}
|
|
19093
|
+
function emitParagraphImages(p, imageMap, linked, out) {
|
|
19094
|
+
for (const blip of collectParagraphBlips(p)) {
|
|
19095
|
+
const embedId = getAttr(blip, "embed");
|
|
19096
|
+
if (!embedId) continue;
|
|
19097
|
+
const filename = imageMap.get(embedId);
|
|
19098
|
+
if (!filename) continue;
|
|
19099
|
+
linked.add(embedId);
|
|
19100
|
+
out.push({ type: "image", text: filename });
|
|
19101
|
+
}
|
|
19009
19102
|
}
|
|
19010
19103
|
async function parseDocxDocument(buffer, options) {
|
|
19011
19104
|
precheckZipSize(buffer, MAX_DECOMPRESS_SIZE4);
|
|
@@ -19062,6 +19155,8 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19062
19155
|
if (body.length === 0) {
|
|
19063
19156
|
throw new KordocError("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19064
19157
|
}
|
|
19158
|
+
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19159
|
+
const linkedImages = /* @__PURE__ */ new Set();
|
|
19065
19160
|
const blocks = [];
|
|
19066
19161
|
const bodyEl = body[0];
|
|
19067
19162
|
const topLevel = effectiveChildElements(bodyEl);
|
|
@@ -19070,16 +19165,20 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19070
19165
|
if (localName2 === "p") {
|
|
19071
19166
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19072
19167
|
if (block) blocks.push(block);
|
|
19168
|
+
if (imageMap.size > 0) emitParagraphImages(el, imageMap, linkedImages, blocks);
|
|
19073
19169
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19074
19170
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19075
19171
|
if (tb) blocks.push(tb);
|
|
19172
|
+
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19076
19173
|
}
|
|
19077
19174
|
} else if (localName2 === "tbl") {
|
|
19078
19175
|
const block = parseTable(el, styles, numbering, footnotes, rels);
|
|
19079
19176
|
if (block) blocks.push(block);
|
|
19080
19177
|
}
|
|
19081
19178
|
}
|
|
19082
|
-
const
|
|
19179
|
+
for (const [embedId, filename] of imageMap) {
|
|
19180
|
+
if (!linkedImages.has(embedId)) blocks.push({ type: "image", text: filename });
|
|
19181
|
+
}
|
|
19083
19182
|
const metadata = {};
|
|
19084
19183
|
const coreFile = zip.file("docProps/core.xml");
|
|
19085
19184
|
if (coreFile) {
|
|
@@ -27073,7 +27172,7 @@ async function parseHwp(buffer, options) {
|
|
|
27073
27172
|
async function parsePdf(buffer, options) {
|
|
27074
27173
|
let parsePdfDocument;
|
|
27075
27174
|
try {
|
|
27076
|
-
const mod = await import("./parser-
|
|
27175
|
+
const mod = await import("./parser-5EHWYJMC.js");
|
|
27077
27176
|
parsePdfDocument = mod.parsePdfDocument;
|
|
27078
27177
|
} catch {
|
|
27079
27178
|
return {
|
|
@@ -27206,4 +27305,4 @@ export {
|
|
|
27206
27305
|
parseHwpml,
|
|
27207
27306
|
fillForm
|
|
27208
27307
|
};
|
|
27209
|
-
//# sourceMappingURL=chunk-
|
|
27308
|
+
//# sourceMappingURL=chunk-TJJTLM76.js.map
|