kordoc 4.0.2 → 4.0.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 +800 -768
- package/dist/{-XMKVL3NX.js → -Q4ZCVQFI.js} +10 -8
- package/dist/chunk-2RIOXYGA.js +92 -0
- package/dist/chunk-2RIOXYGA.js.map +1 -0
- package/dist/chunk-5RPYBC2Q.js +88 -0
- package/dist/chunk-5RPYBC2Q.js.map +1 -0
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-IKBIIEVJ.js → chunk-DKMKJMR6.js} +5 -4
- package/dist/chunk-DKMKJMR6.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-STMLZDKR.js → chunk-KA5AN73R.js} +2 -2
- package/dist/chunk-KA5AN73R.js.map +1 -0
- package/dist/{chunk-3IYQYBUF.js → chunk-KSVLQ5BC.js} +33 -4
- package/dist/chunk-KSVLQ5BC.js.map +1 -0
- package/dist/{chunk-5CJGKKMZ.js → chunk-MEPHGCPQ.js} +1 -1
- package/dist/chunk-MEPHGCPQ.js.map +1 -0
- package/dist/{chunk-AHWRAGXN.js → chunk-MLNHZN32.js} +1876 -965
- package/dist/chunk-MLNHZN32.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-WN7LZHII.cjs → chunk-NIW7CZYX.cjs} +37 -8
- package/dist/chunk-NIW7CZYX.cjs.map +1 -0
- package/dist/{chunk-6SD4X5PT.js → chunk-S3KGEEBQ.js} +76 -25
- package/dist/chunk-S3KGEEBQ.js.map +1 -0
- package/dist/{chunk-67RANGFQ.js → chunk-TXNRIVWA.js} +3 -3
- package/dist/chunk-TXNRIVWA.js.map +1 -0
- package/dist/{chunk-6YIYFWO2.js → chunk-ZJXR4PWY.js} +33 -4
- package/dist/chunk-ZJXR4PWY.js.map +1 -0
- package/dist/cli.js +120 -73
- package/dist/cli.js.map +1 -1
- package/dist/{detect-PJZMUL2Z.js → detect-RI2MQ33K.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +21139 -20176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -5
- package/dist/index.d.ts +52 -5
- package/dist/index.js +20969 -20006
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +113 -90
- 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-6AYYGX6J.cjs → parser-2ZUTCU2G.cjs} +108 -19
- package/dist/parser-2ZUTCU2G.cjs.map +1 -0
- package/dist/{parser-3HM2VYKK.js → parser-46JGSTPR.js} +97 -8
- package/dist/parser-46JGSTPR.js.map +1 -0
- package/dist/{parser-2Q2YKEJG.js → parser-TLCC67W6.js} +96 -7
- package/dist/parser-TLCC67W6.js.map +1 -0
- package/dist/profile-io-MRVIJ5T4.js +11 -0
- package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/provider-4ZJKV3DC.js.map +1 -0
- package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
- package/dist/provider-AKROB7WQ.js.map +1 -0
- package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/render-TTOG6CHW.js +10 -0
- package/dist/seal-NMLZ3M3K.js +10 -0
- package/dist/seal-NMLZ3M3K.js.map +1 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-6OHF727O.js → watch-NZNVJ4YD.js} +8 -8
- package/dist/watch-NZNVJ4YD.js.map +1 -0
- package/package.json +4 -4
- package/dist/chunk-3IYQYBUF.js.map +0 -1
- package/dist/chunk-5CJGKKMZ.js.map +0 -1
- package/dist/chunk-67RANGFQ.js.map +0 -1
- package/dist/chunk-6SD4X5PT.js.map +0 -1
- package/dist/chunk-6YIYFWO2.js.map +0 -1
- package/dist/chunk-AHWRAGXN.js.map +0 -1
- package/dist/chunk-IKBIIEVJ.js.map +0 -1
- package/dist/chunk-STMLZDKR.js.map +0 -1
- package/dist/chunk-WN7LZHII.cjs.map +0 -1
- package/dist/parser-2Q2YKEJG.js.map +0 -1
- package/dist/parser-3HM2VYKK.js.map +0 -1
- package/dist/parser-6AYYGX6J.cjs.map +0 -1
- package/dist/provider-5K7O3Z2O.cjs.map +0 -1
- package/dist/provider-7H4CPZYS.js.map +0 -1
- package/dist/provider-H4WWSPOV.js.map +0 -1
- package/dist/render-W4VCJE6N.js +0 -10
- package/dist/seal-DRPTNHOP.js +0 -10
- package/dist/watch-6OHF727O.js.map +0 -1
- /package/dist/{-XMKVL3NX.js.map → -Q4ZCVQFI.js.map} +0 -0
- /package/dist/{detect-PJZMUL2Z.js.map → detect-RI2MQ33K.js.map} +0 -0
- /package/dist/{render-W4VCJE6N.js.map → profile-io-MRVIJ5T4.js.map} +0 -0
- /package/dist/{seal-DRPTNHOP.js.map → render-TTOG6CHW.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
blocksToMarkdown,
|
|
7
7
|
safeMax,
|
|
8
8
|
safeMin
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KSVLQ5BC.js";
|
|
10
10
|
import {
|
|
11
11
|
parsePageRange
|
|
12
12
|
} from "./chunk-GE43BE46.js";
|
|
@@ -487,6 +487,14 @@ var CONNECT_TOL = 5;
|
|
|
487
487
|
var MIN_COL_WIDTH = 15;
|
|
488
488
|
var MIN_ROW_HEIGHT = 6;
|
|
489
489
|
var MIN_COORD_MERGE_TOL = 8;
|
|
490
|
+
var CUT_FULLWIDTH_RATIO = 0.9;
|
|
491
|
+
var CUT_CROSS_EPS = 2;
|
|
492
|
+
var CUT_MIN_SIDE_VERTICALS = 2;
|
|
493
|
+
var CUT_EDGE_MARGIN = 12;
|
|
494
|
+
var CUT_INTERIOR_MATCH_TOL = 8;
|
|
495
|
+
var CUT_MAX_INTERIOR_OVERLAP = 0.5;
|
|
496
|
+
var CUT_VCHAIN_X_TOL = 1.5;
|
|
497
|
+
var CUT_VCHAIN_GAP = 1;
|
|
490
498
|
function buildVertices(horizontals, verticals) {
|
|
491
499
|
const vertices = [];
|
|
492
500
|
const tol = CONNECT_TOL;
|
|
@@ -534,9 +542,13 @@ function buildTableGrids(horizontals, verticals) {
|
|
|
534
542
|
...horizontals.map((l, i) => ({ ...l, type: "h", id: i })),
|
|
535
543
|
...verticals.map((l, i) => ({ ...l, type: "v", id: i + horizontals.length }))
|
|
536
544
|
];
|
|
537
|
-
const groups =
|
|
545
|
+
const groups = [];
|
|
546
|
+
for (const g2 of groupConnectedLines(allLines)) {
|
|
547
|
+
const bands = splitStackedGroup(g2);
|
|
548
|
+
for (const b of bands) groups.push({ lines: b, fromSplit: bands.length > 1 });
|
|
549
|
+
}
|
|
538
550
|
const grids = [];
|
|
539
|
-
for (const group of groups) {
|
|
551
|
+
for (const { lines: group, fromSplit } of groups) {
|
|
540
552
|
const hLines = group.filter((l) => l.type === "h");
|
|
541
553
|
const vLines = group.filter((l) => l.type === "v");
|
|
542
554
|
if (hLines.length < 2 || vLines.length < 2) continue;
|
|
@@ -555,7 +567,7 @@ function buildTableGrids(horizontals, verticals) {
|
|
|
555
567
|
x2: gx2 + CONNECT_TOL,
|
|
556
568
|
y2: gy2 + CONNECT_TOL
|
|
557
569
|
};
|
|
558
|
-
const groupVertices = vertices.filter(
|
|
570
|
+
const groupVertices = fromSplit ? mergeVertices(buildVertices(hLines, vLines)) : vertices.filter(
|
|
559
571
|
(v) => v.x >= groupBbox.x1 && v.x <= groupBbox.x2 && v.y >= groupBbox.y1 && v.y <= groupBbox.y2
|
|
560
572
|
);
|
|
561
573
|
const groupRadius = groupVertices.length > 0 ? groupVertices.reduce((max, v) => Math.max(max, v.radius), 1) : globalRadius;
|
|
@@ -655,6 +667,83 @@ function clusterCoordinates(values, tolerance) {
|
|
|
655
667
|
}
|
|
656
668
|
return clusters.map((c) => c.sum / c.count);
|
|
657
669
|
}
|
|
670
|
+
function chainVerticals(vs) {
|
|
671
|
+
if (vs.length <= 1) return vs.map((v) => ({ y1: v.y1, y2: v.y2 }));
|
|
672
|
+
const sorted = [...vs].sort((a, b) => a.x1 - b.x1 || a.y1 - b.y1);
|
|
673
|
+
const rules = [];
|
|
674
|
+
let bandStart = 0;
|
|
675
|
+
const flushBand = (end) => {
|
|
676
|
+
const band = sorted.slice(bandStart, end).sort((a, b) => a.y1 - b.y1);
|
|
677
|
+
let cur = { y1: band[0].y1, y2: band[0].y2 };
|
|
678
|
+
for (let i = 1; i < band.length; i++) {
|
|
679
|
+
const seg = band[i];
|
|
680
|
+
if (seg.y1 - cur.y2 <= CUT_VCHAIN_GAP) {
|
|
681
|
+
if (seg.y2 > cur.y2) cur.y2 = seg.y2;
|
|
682
|
+
} else {
|
|
683
|
+
rules.push(cur);
|
|
684
|
+
cur = { y1: seg.y1, y2: seg.y2 };
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
rules.push(cur);
|
|
688
|
+
};
|
|
689
|
+
for (let i = 1; i <= sorted.length; i++) {
|
|
690
|
+
if (i === sorted.length || sorted[i].x1 - sorted[bandStart].x1 > CUT_VCHAIN_X_TOL) {
|
|
691
|
+
flushBand(i);
|
|
692
|
+
bandStart = i;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return rules;
|
|
696
|
+
}
|
|
697
|
+
function splitStackedGroup(group) {
|
|
698
|
+
const hs = group.filter((l) => l.type === "h");
|
|
699
|
+
const vs = group.filter((l) => l.type === "v");
|
|
700
|
+
if (hs.length < 3 || vs.length < 4) return [group];
|
|
701
|
+
let gx1 = Infinity, gx2 = -Infinity;
|
|
702
|
+
for (const l of group) {
|
|
703
|
+
if (l.x1 < gx1) gx1 = l.x1;
|
|
704
|
+
if (l.x2 > gx2) gx2 = l.x2;
|
|
705
|
+
}
|
|
706
|
+
const groupW = gx2 - gx1;
|
|
707
|
+
if (groupW <= 0) return [group];
|
|
708
|
+
const isInterior = (v) => v.x1 > gx1 + CUT_EDGE_MARGIN && v.x1 < gx2 - CUT_EDGE_MARGIN;
|
|
709
|
+
const chained = chainVerticals(vs);
|
|
710
|
+
const cuts = [];
|
|
711
|
+
for (const h of hs) {
|
|
712
|
+
const y = h.y1;
|
|
713
|
+
if (h.x2 - h.x1 < groupW * CUT_FULLWIDTH_RATIO) continue;
|
|
714
|
+
if (cuts.some((c) => Math.abs(c - y) <= CUT_CROSS_EPS)) continue;
|
|
715
|
+
if (chained.some((v) => v.y1 < y - CUT_CROSS_EPS && v.y2 > y + CUT_CROSS_EPS)) continue;
|
|
716
|
+
const above = vs.filter((v) => v.y1 >= y - CUT_CROSS_EPS);
|
|
717
|
+
const below = vs.filter((v) => v.y2 <= y + CUT_CROSS_EPS);
|
|
718
|
+
if (above.length < CUT_MIN_SIDE_VERTICALS || below.length < CUT_MIN_SIDE_VERTICALS) continue;
|
|
719
|
+
const ia = above.filter(isInterior);
|
|
720
|
+
const ib = below.filter(isInterior);
|
|
721
|
+
if (ia.length === 0 || ib.length === 0) continue;
|
|
722
|
+
let matched = 0;
|
|
723
|
+
for (const a of ia) if (ib.some((b) => Math.abs(a.x1 - b.x1) <= CUT_INTERIOR_MATCH_TOL)) matched++;
|
|
724
|
+
if (matched / Math.min(ia.length, ib.length) > CUT_MAX_INTERIOR_OVERLAP) continue;
|
|
725
|
+
cuts.push(y);
|
|
726
|
+
}
|
|
727
|
+
if (cuts.length === 0) return [group];
|
|
728
|
+
cuts.sort((a, b) => b - a);
|
|
729
|
+
const bandOf = (y) => {
|
|
730
|
+
let k = 0;
|
|
731
|
+
while (k < cuts.length && y < cuts[k]) k++;
|
|
732
|
+
return k;
|
|
733
|
+
};
|
|
734
|
+
const bands = Array.from({ length: cuts.length + 1 }, () => []);
|
|
735
|
+
for (const v of vs) bands[bandOf((v.y1 + v.y2) / 2)].push(v);
|
|
736
|
+
for (const h of hs) {
|
|
737
|
+
const atCut = cuts.findIndex((c) => Math.abs(h.y1 - c) <= CUT_CROSS_EPS);
|
|
738
|
+
if (atCut >= 0) {
|
|
739
|
+
bands[atCut].push(h);
|
|
740
|
+
bands[atCut + 1].push(h);
|
|
741
|
+
} else {
|
|
742
|
+
bands[bandOf(h.y1)].push(h);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return bands.filter((b) => b.length > 0);
|
|
746
|
+
}
|
|
658
747
|
function groupConnectedLines(lines) {
|
|
659
748
|
const parent = lines.map((_, i) => i);
|
|
660
749
|
function find(x) {
|
|
@@ -1233,7 +1322,7 @@ function dominantStyle(items) {
|
|
|
1233
1322
|
}
|
|
1234
1323
|
if (dominantSize === 0) return void 0;
|
|
1235
1324
|
const fontName = items.find((i) => i.fontSize === dominantSize)?.fontName || void 0;
|
|
1236
|
-
return { fontSize: dominantSize, fontName };
|
|
1325
|
+
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
1237
1326
|
}
|
|
1238
1327
|
function normalizeItems(rawItems) {
|
|
1239
1328
|
const items = [];
|
|
@@ -3466,7 +3555,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3466
3555
|
if (totalChars / Math.max(parsedPageCount, 1) < 10) {
|
|
3467
3556
|
if (options?.ocr) {
|
|
3468
3557
|
try {
|
|
3469
|
-
const { ocrPages } = await import("./provider-
|
|
3558
|
+
const { ocrPages } = await import("./provider-4ZJKV3DC.js");
|
|
3470
3559
|
const ocrBlocks = await ocrPages(doc, options.ocr, pageFilter, effectivePageCount);
|
|
3471
3560
|
if (ocrBlocks.length > 0) {
|
|
3472
3561
|
const ocrMarkdown = ocrBlocks.map((b) => b.text || "").filter(Boolean).join("\n\n");
|
|
@@ -3584,4 +3673,4 @@ export {
|
|
|
3584
3673
|
parsePdfDocument,
|
|
3585
3674
|
removeHeaderFooterBlocks
|
|
3586
3675
|
};
|
|
3587
|
-
//# sourceMappingURL=parser-
|
|
3676
|
+
//# sourceMappingURL=parser-TLCC67W6.js.map
|