kordoc 4.22.2 → 4.22.4
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 +11 -6
- package/dist/{-C437ZARA.js → -HAK3YFWW.js} +11 -11
- package/dist/{chunk-UV2G6XFA.js → chunk-36DK6AOX.js} +2 -2
- package/dist/{chunk-CNMUT5YW.js → chunk-3TUJ34V7.js} +2 -2
- package/dist/{chunk-I4BS4BXE.cjs → chunk-4X7AR4EH.cjs} +34 -28
- package/dist/chunk-4X7AR4EH.cjs.map +1 -0
- package/dist/{chunk-4BJZGXNM.js → chunk-5ARHF54C.js} +2 -2
- package/dist/{chunk-56GBOIOE.js → chunk-A3SKXHAN.js} +2 -2
- package/dist/{chunk-GVBQVXXB.js → chunk-AYV5VRHL.js} +14 -4
- package/dist/chunk-AYV5VRHL.js.map +1 -0
- package/dist/{chunk-3LJ6QO53.js → chunk-C5J5LDWM.js} +14 -8
- package/dist/{chunk-3LJ6QO53.js.map → chunk-C5J5LDWM.js.map} +1 -1
- package/dist/{chunk-IRP6QS3K.js → chunk-CWBH66IQ.js} +3 -3
- package/dist/{chunk-YTEMFVZB.js → chunk-DEFT7Z3B.js} +2 -2
- package/dist/{chunk-L6N4OMKR.js → chunk-EVL6HZQL.js} +128 -70
- package/dist/chunk-EVL6HZQL.js.map +1 -0
- package/dist/{chunk-ZLFUZM7H.cjs → chunk-EYQLJ57Y.cjs} +3 -3
- package/dist/{chunk-ZLFUZM7H.cjs.map → chunk-EYQLJ57Y.cjs.map} +1 -1
- package/dist/{chunk-GFQIKYBV.js → chunk-F3AWNFMO.js} +3 -3
- package/dist/{chunk-S4KQUVBV.js → chunk-FAFSBCU2.js} +4 -4
- package/dist/{chunk-AXR7OKQY.js → chunk-G2325K2F.js} +2 -2
- package/dist/{chunk-FPUBEM3F.js → chunk-G4KNI7EO.js} +11 -11
- package/dist/{chunk-NGDMJICC.js → chunk-HN3QMHTT.js} +15 -9
- package/dist/{chunk-NGDMJICC.js.map → chunk-HN3QMHTT.js.map} +1 -1
- package/dist/{chunk-MED2MR6O.cjs → chunk-K2NWHLCD.cjs} +23 -13
- package/dist/chunk-K2NWHLCD.cjs.map +1 -0
- package/dist/{chunk-UMNKY2EZ.js → chunk-LVVSMYG4.js} +4 -4
- package/dist/{chunk-AUWO57ED.cjs → chunk-MJSHXESK.cjs} +2 -2
- package/dist/{chunk-AUWO57ED.cjs.map → chunk-MJSHXESK.cjs.map} +1 -1
- package/dist/{chunk-L6PFPBTK.js → chunk-MYTMZSQO.js} +2 -2
- package/dist/{chunk-DQXP3ELP.js → chunk-Q65HT2BL.js} +2 -2
- package/dist/{chunk-U3TZVR7A.js → chunk-Q6SVCBMK.js} +2 -2
- package/dist/{chunk-2X64TI7I.js → chunk-RPSILMQY.js} +2 -2
- package/dist/{chunk-ENV25MPM.cjs → chunk-S45M7IQH.cjs} +24 -24
- package/dist/{chunk-ENV25MPM.cjs.map → chunk-S45M7IQH.cjs.map} +1 -1
- package/dist/{chunk-4GCS7WJJ.js → chunk-SSL3TKJY.js} +2 -2
- package/dist/{chunk-QFJCEHY7.js → chunk-UJVVL6BI.js} +14 -4
- package/dist/chunk-UJVVL6BI.js.map +1 -0
- package/dist/{chunk-EKKZNKJD.cjs → chunk-VXQWAPC6.cjs} +3 -3
- package/dist/{chunk-EKKZNKJD.cjs.map → chunk-VXQWAPC6.cjs.map} +1 -1
- package/dist/{chunk-VUC4JJUM.js → chunk-WCTC3LSV.js} +2 -2
- package/dist/{chunk-YOFKJ7IM.js → chunk-WNW77CAY.js} +2 -2
- package/dist/chunks-3N7OFSA4.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-3TVRNJ66.cjs → formula-JGFYGFYX.cjs} +9 -9
- package/dist/{formula-3TVRNJ66.cjs.map → formula-JGFYGFYX.cjs.map} +1 -1
- package/dist/{formula-HUENRCPJ.js → formula-KSTY73DQ.js} +3 -3
- package/dist/{formula-43QBPAL5.js → formula-PWAUR5PF.js} +4 -4
- package/dist/{image-ocr-BAHDLDV5.js → image-ocr-RASJHOAK.js} +6 -6
- package/dist/{image-ocr-HYAKWJGE.js → image-ocr-RPBPO3VT.js} +9 -9
- package/dist/{image-ocr-OC3TCXMV.cjs → image-ocr-UULNAC5Y.cjs} +17 -17
- package/dist/{image-ocr-OC3TCXMV.cjs.map → image-ocr-UULNAC5Y.cjs.map} +1 -1
- package/dist/index.cjs +536 -478
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +128 -70
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-23WBSECG.js → model-bundle-ZPQ4IFT7.js} +5 -5
- package/dist/{models-NRZQY45P.js → models-YJQ5VHOR.js} +5 -5
- package/dist/{parse-worker-v2-DPNXGJ73.js → parse-worker-v2-7PNZYASF.js} +12 -12
- package/dist/{parser-XNOLC3MZ.js → parser-DR6ZHYEB.js} +121 -12
- package/dist/parser-DR6ZHYEB.js.map +1 -0
- package/dist/{parser-FNUQW2F3.js → parser-ER3VLB37.js} +124 -15
- package/dist/parser-ER3VLB37.js.map +1 -0
- package/dist/{parser-OKAQRZKM.cjs → parser-ZFXVZZKQ.cjs} +376 -267
- package/dist/parser-ZFXVZZKQ.cjs.map +1 -0
- package/dist/{pdf-ocr-FAGA3O6B.js → pdf-ocr-BYT7XVID.js} +6 -6
- package/dist/{pdf-ocr-N5LYC5LA.js → pdf-ocr-DRQN5BXA.js} +9 -9
- package/dist/pdf-ocr-QWTGWYQT.cjs +31 -0
- package/dist/{pdf-ocr-6UXBIQE6.cjs.map → pdf-ocr-QWTGWYQT.cjs.map} +1 -1
- package/dist/{profile-io-HC6FMYX4.js → profile-io-3QYTSPNH.js} +3 -3
- package/dist/{rasterize-QLTROEV2.js → rasterize-LPLWCBXV.js} +3 -3
- package/dist/{redact-doc-V4KMM2QV.js → redact-doc-HDA6ZG3N.js} +11 -11
- package/dist/{render-V4S3QLTR.js → render-MYZGD3SB.js} +7 -7
- package/dist/seal-XA5V6A6V.js +10 -0
- package/dist/{setup-HU7ZOQNM.js → setup-EF5TQVAI.js} +3 -3
- package/dist/visual-DB7NJOID.js +21 -0
- package/dist/{watch-NPIZ6DSJ.js → watch-PM5PRSFW.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-GVBQVXXB.js.map +0 -1
- package/dist/chunk-I4BS4BXE.cjs.map +0 -1
- package/dist/chunk-L6N4OMKR.js.map +0 -1
- package/dist/chunk-MED2MR6O.cjs.map +0 -1
- package/dist/chunk-QFJCEHY7.js.map +0 -1
- package/dist/chunks-MPOOHZVO.js +0 -10
- package/dist/parser-FNUQW2F3.js.map +0 -1
- package/dist/parser-OKAQRZKM.cjs.map +0 -1
- package/dist/parser-XNOLC3MZ.js.map +0 -1
- package/dist/pdf-ocr-6UXBIQE6.cjs +0 -31
- package/dist/seal-MQ5TB5YZ.js +0 -10
- package/dist/visual-RLIFC4XC.js +0 -21
- /package/dist/{-C437ZARA.js.map → -HAK3YFWW.js.map} +0 -0
- /package/dist/{chunk-UV2G6XFA.js.map → chunk-36DK6AOX.js.map} +0 -0
- /package/dist/{chunk-CNMUT5YW.js.map → chunk-3TUJ34V7.js.map} +0 -0
- /package/dist/{chunk-4BJZGXNM.js.map → chunk-5ARHF54C.js.map} +0 -0
- /package/dist/{chunk-56GBOIOE.js.map → chunk-A3SKXHAN.js.map} +0 -0
- /package/dist/{chunk-IRP6QS3K.js.map → chunk-CWBH66IQ.js.map} +0 -0
- /package/dist/{chunk-YTEMFVZB.js.map → chunk-DEFT7Z3B.js.map} +0 -0
- /package/dist/{chunk-GFQIKYBV.js.map → chunk-F3AWNFMO.js.map} +0 -0
- /package/dist/{chunk-S4KQUVBV.js.map → chunk-FAFSBCU2.js.map} +0 -0
- /package/dist/{chunk-AXR7OKQY.js.map → chunk-G2325K2F.js.map} +0 -0
- /package/dist/{chunk-FPUBEM3F.js.map → chunk-G4KNI7EO.js.map} +0 -0
- /package/dist/{chunk-UMNKY2EZ.js.map → chunk-LVVSMYG4.js.map} +0 -0
- /package/dist/{chunk-L6PFPBTK.js.map → chunk-MYTMZSQO.js.map} +0 -0
- /package/dist/{chunk-DQXP3ELP.js.map → chunk-Q65HT2BL.js.map} +0 -0
- /package/dist/{chunk-U3TZVR7A.js.map → chunk-Q6SVCBMK.js.map} +0 -0
- /package/dist/{chunk-2X64TI7I.js.map → chunk-RPSILMQY.js.map} +0 -0
- /package/dist/{chunk-4GCS7WJJ.js.map → chunk-SSL3TKJY.js.map} +0 -0
- /package/dist/{chunk-VUC4JJUM.js.map → chunk-WCTC3LSV.js.map} +0 -0
- /package/dist/{chunk-YOFKJ7IM.js.map → chunk-WNW77CAY.js.map} +0 -0
- /package/dist/{chunks-MPOOHZVO.js.map → chunks-3N7OFSA4.js.map} +0 -0
- /package/dist/{formula-HUENRCPJ.js.map → formula-KSTY73DQ.js.map} +0 -0
- /package/dist/{formula-43QBPAL5.js.map → formula-PWAUR5PF.js.map} +0 -0
- /package/dist/{image-ocr-BAHDLDV5.js.map → image-ocr-RASJHOAK.js.map} +0 -0
- /package/dist/{image-ocr-HYAKWJGE.js.map → image-ocr-RPBPO3VT.js.map} +0 -0
- /package/dist/{model-bundle-23WBSECG.js.map → model-bundle-ZPQ4IFT7.js.map} +0 -0
- /package/dist/{models-NRZQY45P.js.map → models-YJQ5VHOR.js.map} +0 -0
- /package/dist/{parse-worker-v2-DPNXGJ73.js.map → parse-worker-v2-7PNZYASF.js.map} +0 -0
- /package/dist/{pdf-ocr-FAGA3O6B.js.map → pdf-ocr-BYT7XVID.js.map} +0 -0
- /package/dist/{pdf-ocr-N5LYC5LA.js.map → pdf-ocr-DRQN5BXA.js.map} +0 -0
- /package/dist/{profile-io-HC6FMYX4.js.map → profile-io-3QYTSPNH.js.map} +0 -0
- /package/dist/{rasterize-QLTROEV2.js.map → rasterize-LPLWCBXV.js.map} +0 -0
- /package/dist/{redact-doc-V4KMM2QV.js.map → redact-doc-HDA6ZG3N.js.map} +0 -0
- /package/dist/{render-V4S3QLTR.js.map → render-MYZGD3SB.js.map} +0 -0
- /package/dist/{seal-MQ5TB5YZ.js.map → seal-XA5V6A6V.js.map} +0 -0
- /package/dist/{setup-HU7ZOQNM.js.map → setup-EF5TQVAI.js.map} +0 -0
- /package/dist/{visual-RLIFC4XC.js.map → visual-DB7NJOID.js.map} +0 -0
- /package/dist/{watch-NPIZ6DSJ.js.map → watch-PM5PRSFW.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
blocksToPages
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-G2325K2F.js";
|
|
5
5
|
import {
|
|
6
6
|
encodePng
|
|
7
7
|
} from "./chunk-VKVDMH7X.js";
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
stripAbsorbedRunningLines,
|
|
63
63
|
trimTrailingEmptyTableCols,
|
|
64
64
|
wrapJoiner
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-C5J5LDWM.js";
|
|
66
66
|
import {
|
|
67
67
|
validateOcrOptions
|
|
68
68
|
} from "./chunk-BHVOY6V4.js";
|
|
@@ -74,23 +74,23 @@ import {
|
|
|
74
74
|
escapeLiteralTags,
|
|
75
75
|
stripScriptTags,
|
|
76
76
|
unframeLayoutTables
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-AYV5VRHL.js";
|
|
78
78
|
import {
|
|
79
79
|
WINGDINGS,
|
|
80
80
|
assignTableIds,
|
|
81
81
|
blocksToMarkdown,
|
|
82
82
|
escapeLiteralDollar
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-Q6SVCBMK.js";
|
|
84
84
|
import {
|
|
85
85
|
ocrModelsCached,
|
|
86
86
|
resolveOcrModels
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import "./chunk-
|
|
89
|
-
import "./chunk-
|
|
87
|
+
} from "./chunk-MYTMZSQO.js";
|
|
88
|
+
import "./chunk-36DK6AOX.js";
|
|
89
|
+
import "./chunk-3TUJ34V7.js";
|
|
90
90
|
import {
|
|
91
91
|
KordocError,
|
|
92
92
|
sanitizeHref
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-5ARHF54C.js";
|
|
94
94
|
|
|
95
95
|
// src/pdf/image-extract.ts
|
|
96
96
|
import { createHash } from "crypto";
|
|
@@ -621,6 +621,110 @@ function ocrVectorOps(opList, paths) {
|
|
|
621
621
|
// src/pdf/split-row-pattern.ts
|
|
622
622
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
623
623
|
var plain = (cell) => !cell.blocks?.length && !IMAGE_CELLS.has(cell);
|
|
624
|
+
var labelsOf = (cell) => {
|
|
625
|
+
const labels = textOf(cell).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
626
|
+
return labels.length && labels.every((s) => /^\p{L}[\p{L}\p{N} ]{0,15}[::]$/u.test(s)) ? labels.map((s) => s.replace(/\s+/g, "").replace(/:/g, ":")) : void 0;
|
|
627
|
+
};
|
|
628
|
+
var alignedLabels = (label, value, count) => {
|
|
629
|
+
const L = CELL_LINES.get(label), V = CELL_LINES.get(value);
|
|
630
|
+
let next = 0;
|
|
631
|
+
return !!L && !!V && L.length === count && V.length >= count && Math.abs(L[0].y - V[0].y) <= 1 && L.every((l) => {
|
|
632
|
+
while (next < V.length && Math.abs(l.y - V[next].y) > 1) next++;
|
|
633
|
+
return next++ < V.length;
|
|
634
|
+
});
|
|
635
|
+
};
|
|
636
|
+
function matchesCompleteAlignedLabelListRow(table, owner, first) {
|
|
637
|
+
const pairs = [];
|
|
638
|
+
let carried = false;
|
|
639
|
+
for (let c = 0; c < table.cols; ) {
|
|
640
|
+
const u = owner[first - 1]?.[c], d = owner[first]?.[c];
|
|
641
|
+
if (u && u === d) {
|
|
642
|
+
carried = true;
|
|
643
|
+
c = u.c + u.cs;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
647
|
+
if (!upper?.text.trim() && !lower?.text.trim()) {
|
|
648
|
+
c++;
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower)) return false;
|
|
652
|
+
pairs.push({ c, cs: u.cs, upper, lower });
|
|
653
|
+
c += u.cs;
|
|
654
|
+
}
|
|
655
|
+
const filled = pairs.filter((p) => textOf(p.upper) && textOf(p.lower));
|
|
656
|
+
if (!carried || filled.length !== 2) return false;
|
|
657
|
+
const keyed = filled.filter((p) => labelsOf(p.upper) && labelsOf(p.lower));
|
|
658
|
+
if (keyed.length !== 1) return false;
|
|
659
|
+
const label = keyed[0], value = filled.find((p) => p !== label);
|
|
660
|
+
const U = labelsOf(label.upper), D = labelsOf(label.lower), sequence = [...U, ...D];
|
|
661
|
+
if (D.length < 2 || sequence.length < 3 || new Set(sequence).size !== sequence.length || value.c !== label.c + label.cs || pairs.some((p) => p !== label && p !== value && textOf(p.lower)) || !pairs.some((p) => p.c < label.c && textOf(p.upper) && !textOf(p.lower)) || !alignedLabels(label.upper, value.upper, U.length) || !alignedLabels(label.lower, value.lower, D.length)) return false;
|
|
662
|
+
let peers = 0;
|
|
663
|
+
for (let r = 0; r < table.rows; r++) {
|
|
664
|
+
if (r === first - 1 || r === first) continue;
|
|
665
|
+
const L = owner[r]?.[label.c], V = owner[r]?.[value.c];
|
|
666
|
+
if (L?.r !== r || V?.r !== r || L.c !== label.c || V.c !== value.c || L.rs !== 1 || V.rs !== 1 || L.cs !== label.cs || V.cs !== value.cs) continue;
|
|
667
|
+
const l = table.cells[r][label.c], v = table.cells[r][value.c];
|
|
668
|
+
if (!plain(l) || !plain(v) || !textOf(v) || labelsOf(l)?.join("|") !== sequence.join("|") || !alignedLabels(l, v, sequence.length)) continue;
|
|
669
|
+
if (++peers >= 2) return true;
|
|
670
|
+
}
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
function matchesIndependentRowPair(table, owner, first) {
|
|
674
|
+
const norm = (cell) => textOf(cell).replace(/\s+/g, "");
|
|
675
|
+
const pairs = [];
|
|
676
|
+
for (let c = 0; c < table.cols; ) {
|
|
677
|
+
const u = owner[first - 1]?.[c], d = owner[first]?.[c];
|
|
678
|
+
if (u && u === d) {
|
|
679
|
+
c = u.c + u.cs;
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
683
|
+
if (!upper?.text.trim() && !lower?.text.trim()) {
|
|
684
|
+
c++;
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !norm(upper) || !norm(lower)) return false;
|
|
688
|
+
pairs.push({ c, cs: u.cs, upper: norm(upper), lower: norm(lower) });
|
|
689
|
+
c += u.cs;
|
|
690
|
+
}
|
|
691
|
+
if (pairs.length < 2 || pairs.every((p) => p.upper === p.lower)) return false;
|
|
692
|
+
return table.cells.some((_, r) => {
|
|
693
|
+
if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
|
|
694
|
+
return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
|
|
695
|
+
const a = owner[r + i]?.[p.c], cell = table.cells[r + i]?.[p.c];
|
|
696
|
+
return a?.r === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
|
|
697
|
+
}));
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
function matchesCompleteContextRow(table, owner, first) {
|
|
701
|
+
const norm = (s) => s.replace(/\s+/g, "");
|
|
702
|
+
const context = [];
|
|
703
|
+
let value;
|
|
704
|
+
for (let c = 0; c < table.cols; ) {
|
|
705
|
+
const u = owner[first - 1]?.[c], d = owner[first]?.[c];
|
|
706
|
+
if (u && u === d) {
|
|
707
|
+
const cell = table.cells[u.r][u.c];
|
|
708
|
+
if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
|
|
709
|
+
c = u.c + u.cs;
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
713
|
+
if (!upper?.text.trim() && !lower?.text.trim()) {
|
|
714
|
+
c++;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
if (value || !u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !textOf(upper) || !textOf(lower)) return false;
|
|
718
|
+
value = { c, cs: u.cs, text: norm(textOf(upper) + textOf(lower)) };
|
|
719
|
+
c += u.cs;
|
|
720
|
+
}
|
|
721
|
+
if (!value || !context.length) return false;
|
|
722
|
+
const proof = [...context, value];
|
|
723
|
+
return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
|
|
724
|
+
const a = owner[r]?.[p.c], cell = row[p.c];
|
|
725
|
+
return a?.r === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
|
|
726
|
+
}));
|
|
727
|
+
}
|
|
624
728
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
625
729
|
const pairs = [];
|
|
626
730
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -1338,6 +1442,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1338
1442
|
return a !== null && b === a + 1;
|
|
1339
1443
|
})) return false;
|
|
1340
1444
|
if (cut.ruled && hasNumberedRowSequence(table, owner, first)) return false;
|
|
1445
|
+
if (cut.ruled && matchesIndependentRowPair(table, owner, first)) return false;
|
|
1341
1446
|
const contentPairs = pairs.filter(([u, d]) => hasContent(u.cell) && hasContent(d.cell));
|
|
1342
1447
|
const carriedSplit = !textOnly && carried && !newCell && (contentPairs.length <= 1 || contentPairs.every(([, d]) => d.rs > 1) || !cut.ruled && contentPairs.some(([u, d]) => wordOverflows(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs])));
|
|
1343
1448
|
if (!carriedSplit) {
|
|
@@ -1349,7 +1454,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1349
1454
|
if (!(cut.open && !newCell)) {
|
|
1350
1455
|
if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
|
|
1351
1456
|
const one = pairs.filter(([, d]) => d.rs === 1);
|
|
1352
|
-
if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
|
|
1457
|
+
if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !(cut.ruled && (matchesCompleteContextRow(table, owner, first) || matchesCompleteAlignedLabelListRow(table, owner, first))) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
|
|
1353
1458
|
}
|
|
1354
1459
|
}
|
|
1355
1460
|
for (const [u, d] of pairs) {
|
|
@@ -1737,7 +1842,10 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1737
1842
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1738
1843
|
const part = blocks[j];
|
|
1739
1844
|
const from = part.table ? CONT_PARTS.get(part.table) : void 0;
|
|
1740
|
-
if (!from || !part.table)
|
|
1845
|
+
if (!from || !part.table) {
|
|
1846
|
+
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1741
1849
|
let i = j - 1;
|
|
1742
1850
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
1743
1851
|
const prev = blocks[i];
|
|
@@ -1764,7 +1872,7 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1764
1872
|
if (cell.blocks) mergeCrossPageTables(cell.blocks, pageHeights);
|
|
1765
1873
|
}
|
|
1766
1874
|
}
|
|
1767
|
-
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1875
|
+
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1768
1876
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1769
1877
|
if (!prev?.table || !frame?.table || frame.table.rows !== 1 || frame.table.cols !== 1 || !CLIP_TABLES.has(frame.table)) return;
|
|
1770
1878
|
const inner = frame.table.cells[0]?.[0]?.blocks;
|
|
@@ -1774,6 +1882,7 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1774
1882
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1775
1883
|
const ph = pageHeights?.get(prev.pageNumber), nh = pageHeights?.get(next.pageNumber);
|
|
1776
1884
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
1885
|
+
if (splitOnly && (inner.length !== 1 || !joinSplitParts(prev.table, px, next.table, nx, 0, prev.bbox.y)?.split)) return;
|
|
1777
1886
|
blocks.splice(at, 1, ...inner);
|
|
1778
1887
|
}
|
|
1779
1888
|
function fillNestedContinuation(blocks, at) {
|
|
@@ -3373,7 +3482,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3373
3482
|
|
|
3374
3483
|
// src/pdf/formula-ocr.ts
|
|
3375
3484
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3376
|
-
const formulaMod = await import("./formula-
|
|
3485
|
+
const formulaMod = await import("./formula-PWAUR5PF.js");
|
|
3377
3486
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3378
3487
|
await ensureFormulaModels((p) => {
|
|
3379
3488
|
if (p.phase === "download" && p.total) {
|
|
@@ -3799,10 +3908,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3799
3908
|
}
|
|
3800
3909
|
if (targets.size > 0) {
|
|
3801
3910
|
try {
|
|
3802
|
-
const { runPdfOcr } = await import("./pdf-ocr-
|
|
3911
|
+
const { runPdfOcr } = await import("./pdf-ocr-DRQN5BXA.js");
|
|
3803
3912
|
const mode = typeof options?.ocr === "function" ? options.ocr : "builtin";
|
|
3804
3913
|
const regionPages = new Map([...ocrRegions].filter(([p]) => options?.ocr !== "force" && !isImageBased && !pageQuality.find((q) => q.page === p)?.needsOcr));
|
|
3805
|
-
const { builtinOcrConfig } = await import("./pdf-ocr-
|
|
3914
|
+
const { builtinOcrConfig } = await import("./pdf-ocr-DRQN5BXA.js");
|
|
3806
3915
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options?.onProgress, options?.tables !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
3807
3916
|
for (const obs of ocrPageBlocks.values()) stripScriptTags({ blocks: obs });
|
|
3808
3917
|
if (ocrPageBlocks.size > 0) {
|
|
@@ -4047,4 +4156,4 @@ export {
|
|
|
4047
4156
|
parsePdfDocument,
|
|
4048
4157
|
removeHeaderFooterBlocks
|
|
4049
4158
|
};
|
|
4050
|
-
//# sourceMappingURL=parser-
|
|
4159
|
+
//# sourceMappingURL=parser-ER3VLB37.js.map
|