kordoc 4.19.0 → 4.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/{-I3DEUQUC.js → -3JIHF2AL.js} +11 -11
- package/dist/{chunk-CR4RXHXO.js → chunk-4CS7XE2Q.js} +2 -2
- package/dist/{chunk-UCTD3BXH.js → chunk-56ZWAREM.js} +2 -2
- package/dist/{chunk-YV4PWWRW.cjs → chunk-5PGOZBEQ.cjs} +22 -22
- package/dist/{chunk-YV4PWWRW.cjs.map → chunk-5PGOZBEQ.cjs.map} +1 -1
- package/dist/{chunk-OMJWAJBD.js → chunk-6ZBORHFB.js} +2 -2
- package/dist/{chunk-DH75ZUYF.js → chunk-AKSCTGKG.js} +10 -4
- package/dist/chunk-AKSCTGKG.js.map +1 -0
- package/dist/{chunk-L5KNWOGR.js → chunk-AOVMOCTK.js} +10 -4
- package/dist/chunk-AOVMOCTK.js.map +1 -0
- package/dist/{chunk-XXUXQHUC.js → chunk-B4R443MV.js} +2 -2
- package/dist/{chunk-RYKNAYKC.js → chunk-EUCBMW6C.js} +3 -3
- package/dist/{chunk-XIWGPC3V.js → chunk-GNUGD4RO.js} +2 -2
- package/dist/{chunk-AMDDV4CI.js → chunk-I2TBI7PN.js} +2 -2
- package/dist/{chunk-5B55S4JU.js → chunk-J75TVRJB.js} +2 -2
- package/dist/{chunk-VZSOPECZ.js → chunk-JK7N4R4K.js} +2 -2
- package/dist/{chunk-DEYCTP2S.js → chunk-JXJDXDOU.js} +3 -3
- package/dist/{chunk-34RIECIF.cjs → chunk-MZ6XNFZL.cjs} +2 -2
- package/dist/{chunk-34RIECIF.cjs.map → chunk-MZ6XNFZL.cjs.map} +1 -1
- package/dist/{chunk-C4JHZNRL.js → chunk-NV46IWKF.js} +27 -21
- package/dist/chunk-NV46IWKF.js.map +1 -0
- package/dist/{chunk-UTVNSCEI.js → chunk-OKHKEYTL.js} +2 -2
- package/dist/{chunk-LNU54ZKV.cjs → chunk-ORGWGR4K.cjs} +15 -9
- package/dist/chunk-ORGWGR4K.cjs.map +1 -0
- package/dist/{chunk-AAE765MK.js → chunk-PWQ2BVAT.js} +3 -3
- package/dist/{chunk-FJE3TMZ7.js → chunk-QYJPU4FZ.js} +30 -2
- package/dist/chunk-QYJPU4FZ.js.map +1 -0
- package/dist/{chunk-DGXGVC4Z.js → chunk-QZ63HXEG.js} +51 -20
- package/dist/chunk-QZ63HXEG.js.map +1 -0
- package/dist/{chunk-GCYLNOTJ.js → chunk-R2JM2HOJ.js} +4 -4
- package/dist/{chunk-LLVF6X5W.cjs → chunk-RVBQT2PD.cjs} +3 -3
- package/dist/{chunk-LLVF6X5W.cjs.map → chunk-RVBQT2PD.cjs.map} +1 -1
- package/dist/{chunk-7TVRQJXI.cjs → chunk-T2DZTOGG.cjs} +12 -12
- package/dist/{chunk-7TVRQJXI.cjs.map → chunk-T2DZTOGG.cjs.map} +1 -1
- package/dist/{chunk-GYQVQF2J.js → chunk-TM4T4NYJ.js} +2 -2
- package/dist/{chunk-W5XX2GKO.js → chunk-U6AJU2VD.js} +2 -2
- package/dist/{chunk-QHN7N2QA.js → chunk-VO22VAR3.js} +2 -2
- package/dist/{chunk-5ZSQ2ZIH.cjs → chunk-WQAGDJIP.cjs} +3 -3
- package/dist/{chunk-5ZSQ2ZIH.cjs.map → chunk-WQAGDJIP.cjs.map} +1 -1
- package/dist/{chunk-HFMIAMEO.js → chunk-XPM7WC54.js} +4 -4
- package/dist/chunks-2EC2R7PY.js +10 -0
- package/dist/cli.js +26 -26
- package/dist/{formula-L2BKGA4J.cjs → formula-RNATQ3FQ.cjs} +9 -9
- package/dist/{formula-L2BKGA4J.cjs.map → formula-RNATQ3FQ.cjs.map} +1 -1
- package/dist/{formula-DUEAYGIG.js → formula-RSTTP626.js} +4 -4
- package/dist/{formula-I4MAHCTZ.js → formula-STIFIS57.js} +3 -3
- package/dist/{image-ocr-ZWRJZKYR.cjs → image-ocr-7L5TBBPA.cjs} +15 -15
- package/dist/{image-ocr-ZWRJZKYR.cjs.map → image-ocr-7L5TBBPA.cjs.map} +1 -1
- package/dist/{image-ocr-B32G24XW.js → image-ocr-R6ZDFBAN.js} +6 -6
- package/dist/{image-ocr-NUL3JKXM.js → image-ocr-XKSAEEXP.js} +9 -9
- package/dist/index.cjs +824 -761
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +94 -31
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-OBIKG4K5.js → model-bundle-NGTKULP7.js} +5 -5
- package/dist/{models-2OZHOPPM.js → models-QOSU5SYL.js} +5 -5
- package/dist/{parser-FDE6GQST.js → parser-3G4G6SST.js} +176 -12
- package/dist/parser-3G4G6SST.js.map +1 -0
- package/dist/{parser-YW3NMSJE.js → parser-5GUEP6EK.js} +173 -9
- package/dist/parser-5GUEP6EK.js.map +1 -0
- package/dist/{parser-DMWCXX7A.cjs → parser-AIQBU7FS.cjs} +392 -228
- package/dist/parser-AIQBU7FS.cjs.map +1 -0
- package/dist/pdf-ocr-7OAFUDM4.cjs +17 -0
- package/dist/{pdf-ocr-K2OK7FNQ.cjs.map → pdf-ocr-7OAFUDM4.cjs.map} +1 -1
- package/dist/pdf-ocr-DAXS5RX4.js +16 -0
- package/dist/pdf-ocr-R3VGX6F2.js +20 -0
- package/dist/{profile-io-6WCU4KHY.js → profile-io-ZVNMDLLS.js} +3 -3
- package/dist/{rasterize-X3I7SWXF.js → rasterize-Y2RLMVCL.js} +3 -3
- package/dist/{redact-doc-6H7WPUQD.js → redact-doc-PNRDDBI3.js} +11 -11
- package/dist/{render-PBQJGZT3.js → render-S3ALARVO.js} +7 -7
- package/dist/seal-EJWPS5VK.js +10 -0
- package/dist/{setup-UORJSR3M.js → setup-JH66VSFZ.js} +3 -3
- package/dist/visual-GDXMKDVY.js +20 -0
- package/dist/{watch-S2ZMDDZU.js → watch-KMB2FTOD.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-C4JHZNRL.js.map +0 -1
- package/dist/chunk-DGXGVC4Z.js.map +0 -1
- package/dist/chunk-DH75ZUYF.js.map +0 -1
- package/dist/chunk-FJE3TMZ7.js.map +0 -1
- package/dist/chunk-L5KNWOGR.js.map +0 -1
- package/dist/chunk-LNU54ZKV.cjs.map +0 -1
- package/dist/chunks-JPNLQOVD.js +0 -10
- package/dist/parser-DMWCXX7A.cjs.map +0 -1
- package/dist/parser-FDE6GQST.js.map +0 -1
- package/dist/parser-YW3NMSJE.js.map +0 -1
- package/dist/pdf-ocr-7MR56U4P.js +0 -16
- package/dist/pdf-ocr-K2OK7FNQ.cjs +0 -17
- package/dist/pdf-ocr-YHC4X67W.js +0 -20
- package/dist/seal-E2E7CFZJ.js +0 -10
- package/dist/visual-4GDT5BRH.js +0 -20
- /package/dist/{-I3DEUQUC.js.map → -3JIHF2AL.js.map} +0 -0
- /package/dist/{chunk-CR4RXHXO.js.map → chunk-4CS7XE2Q.js.map} +0 -0
- /package/dist/{chunk-UCTD3BXH.js.map → chunk-56ZWAREM.js.map} +0 -0
- /package/dist/{chunk-OMJWAJBD.js.map → chunk-6ZBORHFB.js.map} +0 -0
- /package/dist/{chunk-XXUXQHUC.js.map → chunk-B4R443MV.js.map} +0 -0
- /package/dist/{chunk-RYKNAYKC.js.map → chunk-EUCBMW6C.js.map} +0 -0
- /package/dist/{chunk-XIWGPC3V.js.map → chunk-GNUGD4RO.js.map} +0 -0
- /package/dist/{chunk-AMDDV4CI.js.map → chunk-I2TBI7PN.js.map} +0 -0
- /package/dist/{chunk-5B55S4JU.js.map → chunk-J75TVRJB.js.map} +0 -0
- /package/dist/{chunk-VZSOPECZ.js.map → chunk-JK7N4R4K.js.map} +0 -0
- /package/dist/{chunk-DEYCTP2S.js.map → chunk-JXJDXDOU.js.map} +0 -0
- /package/dist/{chunk-UTVNSCEI.js.map → chunk-OKHKEYTL.js.map} +0 -0
- /package/dist/{chunk-AAE765MK.js.map → chunk-PWQ2BVAT.js.map} +0 -0
- /package/dist/{chunk-GCYLNOTJ.js.map → chunk-R2JM2HOJ.js.map} +0 -0
- /package/dist/{chunk-GYQVQF2J.js.map → chunk-TM4T4NYJ.js.map} +0 -0
- /package/dist/{chunk-W5XX2GKO.js.map → chunk-U6AJU2VD.js.map} +0 -0
- /package/dist/{chunk-QHN7N2QA.js.map → chunk-VO22VAR3.js.map} +0 -0
- /package/dist/{chunk-HFMIAMEO.js.map → chunk-XPM7WC54.js.map} +0 -0
- /package/dist/{chunks-JPNLQOVD.js.map → chunks-2EC2R7PY.js.map} +0 -0
- /package/dist/{formula-DUEAYGIG.js.map → formula-RSTTP626.js.map} +0 -0
- /package/dist/{formula-I4MAHCTZ.js.map → formula-STIFIS57.js.map} +0 -0
- /package/dist/{image-ocr-B32G24XW.js.map → image-ocr-R6ZDFBAN.js.map} +0 -0
- /package/dist/{image-ocr-NUL3JKXM.js.map → image-ocr-XKSAEEXP.js.map} +0 -0
- /package/dist/{model-bundle-OBIKG4K5.js.map → model-bundle-NGTKULP7.js.map} +0 -0
- /package/dist/{models-2OZHOPPM.js.map → models-QOSU5SYL.js.map} +0 -0
- /package/dist/{pdf-ocr-7MR56U4P.js.map → pdf-ocr-DAXS5RX4.js.map} +0 -0
- /package/dist/{pdf-ocr-YHC4X67W.js.map → pdf-ocr-R3VGX6F2.js.map} +0 -0
- /package/dist/{profile-io-6WCU4KHY.js.map → profile-io-ZVNMDLLS.js.map} +0 -0
- /package/dist/{rasterize-X3I7SWXF.js.map → rasterize-Y2RLMVCL.js.map} +0 -0
- /package/dist/{redact-doc-6H7WPUQD.js.map → redact-doc-PNRDDBI3.js.map} +0 -0
- /package/dist/{render-PBQJGZT3.js.map → render-S3ALARVO.js.map} +0 -0
- /package/dist/{seal-E2E7CFZJ.js.map → seal-EJWPS5VK.js.map} +0 -0
- /package/dist/{setup-UORJSR3M.js.map → setup-JH66VSFZ.js.map} +0 -0
- /package/dist/{visual-4GDT5BRH.js.map → visual-GDXMKDVY.js.map} +0 -0
- /package/dist/{watch-S2ZMDDZU.js.map → watch-KMB2FTOD.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
blocksToPages,
|
|
3
3
|
encodePng
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U6AJU2VD.js";
|
|
5
5
|
import {
|
|
6
6
|
hasRequestedPagesAfter,
|
|
7
7
|
parsePageRange
|
|
@@ -58,9 +58,10 @@ import {
|
|
|
58
58
|
startsNewItem,
|
|
59
59
|
trimTrailingEmptyTableCols,
|
|
60
60
|
wrapJoiner
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-R2JM2HOJ.js";
|
|
62
62
|
import {
|
|
63
63
|
CELL_EDGES,
|
|
64
|
+
CELL_PAGES,
|
|
64
65
|
CONTENT_CELLS,
|
|
65
66
|
WINGDINGS,
|
|
66
67
|
assignTableIds,
|
|
@@ -69,12 +70,12 @@ import {
|
|
|
69
70
|
escapeLiteralTags,
|
|
70
71
|
stripScriptTags,
|
|
71
72
|
unframeLayoutTables
|
|
72
|
-
} from "./chunk-
|
|
73
|
-
import "./chunk-
|
|
73
|
+
} from "./chunk-AKSCTGKG.js";
|
|
74
|
+
import "./chunk-GNUGD4RO.js";
|
|
74
75
|
import {
|
|
75
76
|
KordocError,
|
|
76
77
|
sanitizeHref
|
|
77
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-J75TVRJB.js";
|
|
78
79
|
|
|
79
80
|
// src/pdf/ocr-region-merge.ts
|
|
80
81
|
function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
@@ -755,6 +756,167 @@ function splitContactTables(blocks) {
|
|
|
755
756
|
}
|
|
756
757
|
}
|
|
757
758
|
|
|
759
|
+
// src/pdf/table-pages.ts
|
|
760
|
+
var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
761
|
+
function relocate(src, dst, from = 0) {
|
|
762
|
+
const out = [];
|
|
763
|
+
for (const s of CELL_SPLITS.get(src) ?? []) {
|
|
764
|
+
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, out.at(-1)?.at ?? 0));
|
|
765
|
+
if (at >= 0) out.push({ at, page: s.page });
|
|
766
|
+
}
|
|
767
|
+
return out;
|
|
768
|
+
}
|
|
769
|
+
var setSplits = (cell, splits) => {
|
|
770
|
+
if (splits.length) CELL_SPLITS.set(cell, splits.sort((a, b) => a.at - b.at));
|
|
771
|
+
};
|
|
772
|
+
function markContinuedText(cell, add, page) {
|
|
773
|
+
if (!add.text.trim()) return;
|
|
774
|
+
const base = cell.text.trim() ? cell.text.length + 1 : 0;
|
|
775
|
+
setSplits(cell, [
|
|
776
|
+
...CELL_SPLITS.get(cell) ?? [],
|
|
777
|
+
{ at: base, page },
|
|
778
|
+
...(CELL_SPLITS.get(add) ?? []).map((s) => ({ at: base + s.at, page: s.page }))
|
|
779
|
+
]);
|
|
780
|
+
}
|
|
781
|
+
function rowStarts(t) {
|
|
782
|
+
const covered = /* @__PURE__ */ new Set();
|
|
783
|
+
const rows = [];
|
|
784
|
+
for (let r = 0; r < t.rows; r++) {
|
|
785
|
+
const starts = [];
|
|
786
|
+
for (let c = 0; c < t.cols; c++) {
|
|
787
|
+
if (covered.has(r * 1e5 + c)) continue;
|
|
788
|
+
const cell = t.cells[r]?.[c];
|
|
789
|
+
if (!cell) continue;
|
|
790
|
+
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
|
|
791
|
+
starts.push({ cell, c });
|
|
792
|
+
}
|
|
793
|
+
rows.push(starts);
|
|
794
|
+
}
|
|
795
|
+
return rows;
|
|
796
|
+
}
|
|
797
|
+
var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
|
|
798
|
+
function cellPage(cell) {
|
|
799
|
+
const p = CELL_PAGES.get(cell);
|
|
800
|
+
if (p !== void 0 || !cell.blocks?.length || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
801
|
+
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
802
|
+
}
|
|
803
|
+
function tableRowPages(t, pageNumber) {
|
|
804
|
+
const pages = [];
|
|
805
|
+
let prev = pageNumber;
|
|
806
|
+
for (const starts of rowStarts(t)) {
|
|
807
|
+
let mark, text = false;
|
|
808
|
+
for (const { cell } of starts) {
|
|
809
|
+
const p = cellPage(cell);
|
|
810
|
+
if (p !== void 0) mark = Math.max(mark ?? p, p);
|
|
811
|
+
else if (cell.text.trim() || cell.blocks?.length) text = true;
|
|
812
|
+
}
|
|
813
|
+
const page = mark ?? (text ? pageNumber : prev);
|
|
814
|
+
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : page ?? prev;
|
|
815
|
+
pages.push(prev);
|
|
816
|
+
}
|
|
817
|
+
return pages;
|
|
818
|
+
}
|
|
819
|
+
function markJoinedPages(table, prev, curr) {
|
|
820
|
+
const pt = prev.table, ct = curr.table;
|
|
821
|
+
if (!curr.pageNumber || table.rows < pt.rows) return;
|
|
822
|
+
const pp = tableRowPages(pt, prev.pageNumber), cp = tableRowPages(ct, curr.pageNumber);
|
|
823
|
+
const off = table.rows - ct.rows;
|
|
824
|
+
const rows = rowStarts(table), ptRows = rowStarts(pt), ctRows = rowStarts(ct);
|
|
825
|
+
rows.forEach((starts, r) => {
|
|
826
|
+
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
827
|
+
for (const { cell } of starts) {
|
|
828
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) CELL_PAGES.set(cell, page2);
|
|
829
|
+
const src = (r < pt.rows ? ptRows[r] : ctRows[r - off])?.find((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell));
|
|
830
|
+
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
const cr = pt.rows - 1 - off, page = cp[cr];
|
|
834
|
+
if (cr < 0 || page === void 0 || page === prev.pageNumber) return;
|
|
835
|
+
const tails = ctRows[cr].filter((s) => s.cell.text.trim());
|
|
836
|
+
for (const { cell } of ctRows[cr]) for (const b of cell.blocks ?? []) b.pageNumber ??= page;
|
|
837
|
+
const heads = covering(pt, pt.rows - 1);
|
|
838
|
+
for (const cell of covering(table, pt.rows - 1)) {
|
|
839
|
+
if (cell.blocks?.length) continue;
|
|
840
|
+
const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
|
|
841
|
+
if (!head) continue;
|
|
842
|
+
const from = head.text.trimEnd().length;
|
|
843
|
+
const hit = tails.map((t) => ({ t: t.cell, at: cell.text.indexOf(t.cell.text.trim().slice(0, 20), from) })).filter((h) => h.at >= from).sort((a, b) => a.at - b.at)[0];
|
|
844
|
+
if (!hit) continue;
|
|
845
|
+
setSplits(cell, [...relocate(head, cell), { at: hit.at, page }, ...relocate(hit.t, cell, hit.at)]);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
function splitCell(cell, page) {
|
|
849
|
+
if (page === void 0) return null;
|
|
850
|
+
if (cell.blocks?.length) {
|
|
851
|
+
const k2 = cell.blocks.findIndex((b) => (b.pageNumber ?? page) > page);
|
|
852
|
+
if (k2 <= 0) return null;
|
|
853
|
+
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
854
|
+
const text = (bs) => bs.map((b) => b.text ?? "").filter(Boolean).join("\n");
|
|
855
|
+
return { head: { text: text(head), blocks: head }, tail: { text: text(tail), blocks: tail }, page: tail[0].pageNumber, rest: [] };
|
|
856
|
+
}
|
|
857
|
+
const splits = CELL_SPLITS.get(cell) ?? [];
|
|
858
|
+
const k = splits.findIndex((s2) => s2.page > page && s2.at < cell.text.length);
|
|
859
|
+
if (k < 0) return null;
|
|
860
|
+
const s = splits[k];
|
|
861
|
+
const rest = cell.text.slice(s.at), lead = rest.length - rest.trimStart().length;
|
|
862
|
+
return {
|
|
863
|
+
head: { text: cell.text.slice(0, s.at).trimEnd() },
|
|
864
|
+
tail: { text: rest.trim() },
|
|
865
|
+
page: s.page,
|
|
866
|
+
rest: splits.slice(k + 1).map((x) => ({ at: x.at - s.at - lead, page: x.page })).filter((x) => x.at > 0)
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
function splitCrossPageRows(t, pageNumber) {
|
|
870
|
+
const pages = tableRowPages(t, pageNumber);
|
|
871
|
+
const rows = rowStarts(t);
|
|
872
|
+
for (let r = 0; r < t.rows; r++) {
|
|
873
|
+
const splits = rows[r].map((s) => ({ ...s, split: splitCell(s.cell, pages[r]) })).filter((s) => s.split);
|
|
874
|
+
if (!splits.length) continue;
|
|
875
|
+
const clone = (cell, patch) => {
|
|
876
|
+
const out = { ...cell, ...patch };
|
|
877
|
+
const p = CELL_PAGES.get(cell);
|
|
878
|
+
if (p !== void 0) CELL_PAGES.set(out, p);
|
|
879
|
+
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
880
|
+
return out;
|
|
881
|
+
};
|
|
882
|
+
const e = Math.max(...splits.map((s) => r + s.cell.rowSpan - 1));
|
|
883
|
+
const cells = t.cells.map((row2) => row2.slice());
|
|
884
|
+
const row = Array.from({ length: t.cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }));
|
|
885
|
+
for (const { cell, c, split } of splits) {
|
|
886
|
+
cells[r][c] = clone(cell, split.head);
|
|
887
|
+
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
888
|
+
CELL_PAGES.set(tail, split.page);
|
|
889
|
+
setSplits(tail, split.rest);
|
|
890
|
+
row[c] = tail;
|
|
891
|
+
}
|
|
892
|
+
rows.forEach((starts, rr) => {
|
|
893
|
+
for (const { cell, c } of starts) {
|
|
894
|
+
if (splits.some((s) => s.cell === cell) || rr > e || rr + cell.rowSpan - 1 <= e) continue;
|
|
895
|
+
cells[rr][c] = clone(cells[rr][c], { rowSpan: cell.rowSpan + 1 });
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
cells.splice(e + 1, 0, row);
|
|
899
|
+
return splitCrossPageRows({ ...t, rows: t.rows + 1, cells }, pageNumber);
|
|
900
|
+
}
|
|
901
|
+
return t;
|
|
902
|
+
}
|
|
903
|
+
function splitPageTables(blocks) {
|
|
904
|
+
return blocks.flatMap((b) => {
|
|
905
|
+
if (b.type !== "table" || !b.table) return [b];
|
|
906
|
+
const t = splitCrossPageRows(b.table, b.pageNumber);
|
|
907
|
+
const pages = tableRowPages(t, b.pageNumber);
|
|
908
|
+
const cuts = [0];
|
|
909
|
+
for (let r = 1; r < t.rows; r++) if (pages[r] !== pages[r - 1]) cuts.push(r);
|
|
910
|
+
if (cuts.length === 1) return t === b.table ? [b] : [{ ...b, table: t }];
|
|
911
|
+
return cuts.map((from, k) => {
|
|
912
|
+
const end = cuts[k + 1] ?? t.rows;
|
|
913
|
+
const cells = t.cells.slice(from, end).map((row, dr) => row.map((cell) => cell && from + dr + cell.rowSpan > end ? { ...cell, rowSpan: end - from - dr } : cell));
|
|
914
|
+
const table = { ...t, rows: end - from, cells, ...k ? { caption: void 0, captionBlocks: void 0 } : {} };
|
|
915
|
+
return { ...b, table, pageNumber: pages[from] };
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
758
920
|
// src/pdf/table-parts.ts
|
|
759
921
|
var flowText = (text) => text.replace(/<\/?u>|~~/g, "");
|
|
760
922
|
var PART_COL_TOL = 1;
|
|
@@ -1174,6 +1336,7 @@ function leftColumnOf(b, t) {
|
|
|
1174
1336
|
}
|
|
1175
1337
|
function placeJoined(blocks, i, j, table) {
|
|
1176
1338
|
const prev = blocks[i];
|
|
1339
|
+
markJoinedPages(table, prev, blocks[j]);
|
|
1177
1340
|
blocks[i] = { ...prev, table };
|
|
1178
1341
|
blocks.splice(j, 1);
|
|
1179
1342
|
let k = j - 1;
|
|
@@ -1527,6 +1690,7 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1527
1690
|
if (!cell || !add) continue;
|
|
1528
1691
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1529
1692
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1693
|
+
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1530
1694
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1531
1695
|
joinCellEdges(cell, add);
|
|
1532
1696
|
const lines = CELL_LINES.get(add);
|
|
@@ -2875,7 +3039,7 @@ function mergeLinkRuns(markdown) {
|
|
|
2875
3039
|
|
|
2876
3040
|
// src/pdf/formula-ocr.ts
|
|
2877
3041
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
2878
|
-
const formulaMod = await import("./formula-
|
|
3042
|
+
const formulaMod = await import("./formula-STIFIS57.js");
|
|
2879
3043
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
2880
3044
|
await ensureFormulaModels((p) => {
|
|
2881
3045
|
if (p.phase === "download" && p.total) {
|
|
@@ -3296,7 +3460,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3296
3460
|
}
|
|
3297
3461
|
if (targets.size > 0) {
|
|
3298
3462
|
try {
|
|
3299
|
-
const { runPdfOcr } = await import("./pdf-ocr-
|
|
3463
|
+
const { runPdfOcr } = await import("./pdf-ocr-DAXS5RX4.js");
|
|
3300
3464
|
const mode = typeof options?.ocr === "function" ? options.ocr : "builtin";
|
|
3301
3465
|
const regionPages = new Map([...ocrRegions].filter(([p]) => options?.ocr !== "force" && !isImageBased && !pageQuality.find((q) => q.page === p)?.needsOcr));
|
|
3302
3466
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options?.onProgress, options?.tables !== false, vectorPageOps, regionPages);
|
|
@@ -3454,7 +3618,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3454
3618
|
let markdown = finishMarkdown(outBlocks);
|
|
3455
3619
|
return {
|
|
3456
3620
|
markdown,
|
|
3457
|
-
pages: blocksToPages(splitPageBreakWraps(outBlocks), finishMarkdown),
|
|
3621
|
+
pages: blocksToPages(splitPageTables(splitPageBreakWraps(outBlocks)), finishMarkdown),
|
|
3458
3622
|
blocks,
|
|
3459
3623
|
metadata,
|
|
3460
3624
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3534,4 +3698,4 @@ export {
|
|
|
3534
3698
|
parsePdfDocument,
|
|
3535
3699
|
removeHeaderFooterBlocks
|
|
3536
3700
|
};
|
|
3537
|
-
//# sourceMappingURL=parser-
|
|
3701
|
+
//# sourceMappingURL=parser-5GUEP6EK.js.map
|