kordoc 3.12.0 → 3.13.0
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 +7 -0
- package/dist/{-OPZIF3QT.js → -MRPDPE2X.js} +5 -5
- package/dist/{chunk-ILR7GF3W.js → chunk-33CIKNL4.js} +2 -2
- package/dist/{chunk-2C5GCXPJ.cjs → chunk-MEXUFQVC.cjs} +2 -2
- package/dist/{chunk-2C5GCXPJ.cjs.map → chunk-MEXUFQVC.cjs.map} +1 -1
- package/dist/{chunk-NGKIAZ6G.js → chunk-O4WFPOFN.js} +2 -2
- package/dist/{chunk-7Z43WEML.js → chunk-Q6UXVJXI.js} +2 -2
- package/dist/{chunk-RUYSNNYZ.js → chunk-TWACKS3K.js} +21 -5
- package/dist/{chunk-RUYSNNYZ.js.map → chunk-TWACKS3K.js.map} +1 -1
- package/dist/{chunk-BUDM6ULT.js → chunk-YXOT7P5B.js} +2 -2
- package/dist/cli.js +7 -7
- package/dist/index.cjs +134 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +5 -5
- package/dist/{parser-PCTX7LGN.cjs → parser-DZBI3EA2.cjs} +66 -14
- package/dist/parser-DZBI3EA2.cjs.map +1 -0
- package/dist/{parser-5FSEFR3R.js → parser-XUNGOH76.js} +55 -3
- package/dist/{parser-AWEGMHHV.js.map → parser-XUNGOH76.js.map} +1 -1
- package/dist/{parser-AWEGMHHV.js → parser-Z3IL2ESY.js} +54 -2
- package/dist/{parser-5FSEFR3R.js.map → parser-Z3IL2ESY.js.map} +1 -1
- package/dist/render-VZ4OGHZU.js +9 -0
- package/dist/{watch-Y7BAYXJE.js → watch-G5NFIT5L.js} +5 -5
- package/package.json +1 -1
- package/dist/parser-PCTX7LGN.cjs.map +0 -1
- package/dist/render-ATQNKOT2.js +0 -9
- /package/dist/{-OPZIF3QT.js.map → -MRPDPE2X.js.map} +0 -0
- /package/dist/{chunk-ILR7GF3W.js.map → chunk-33CIKNL4.js.map} +0 -0
- /package/dist/{chunk-NGKIAZ6G.js.map → chunk-O4WFPOFN.js.map} +0 -0
- /package/dist/{chunk-7Z43WEML.js.map → chunk-Q6UXVJXI.js.map} +0 -0
- /package/dist/{chunk-BUDM6ULT.js.map → chunk-YXOT7P5B.js.map} +0 -0
- /package/dist/{render-ATQNKOT2.js.map → render-VZ4OGHZU.js.map} +0 -0
- /package/dist/{watch-Y7BAYXJE.js.map → watch-G5NFIT5L.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
HEADING_RATIO_H2,
|
|
5
5
|
HEADING_RATIO_H3,
|
|
6
6
|
blocksToMarkdown
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YXOT7P5B.js";
|
|
8
8
|
import {
|
|
9
9
|
parsePageRange
|
|
10
10
|
} from "./chunk-MOL7MDBG.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
KordocError,
|
|
13
13
|
safeMax,
|
|
14
14
|
safeMin
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Q6UXVJXI.js";
|
|
16
16
|
|
|
17
17
|
// src/pdf/line-extract.ts
|
|
18
18
|
import { OPS } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
@@ -2721,6 +2721,54 @@ function wrapStrikethroughRuns(items) {
|
|
|
2721
2721
|
arr[arr.length - 1].text = arr[arr.length - 1].text + "~~";
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
|
+
var PROSEBOX_FULLWIDTH_MIN = 0.6;
|
|
2725
|
+
var PROSEBOX_LONG_CELL_CHARS = 80;
|
|
2726
|
+
var PROSEBOX_LONG_CELL_MIN = 3;
|
|
2727
|
+
var PROSEBOX_LONG_CELL_RATIO = 0.4;
|
|
2728
|
+
var PROSEBOX_X_TOL = 8;
|
|
2729
|
+
function verticalCoverageAt(verticals, x, yMin, yMax) {
|
|
2730
|
+
const tol = PROSEBOX_X_TOL;
|
|
2731
|
+
const spans = [];
|
|
2732
|
+
for (const v of verticals) {
|
|
2733
|
+
if (Math.abs(v.x1 - x) > tol) continue;
|
|
2734
|
+
const lo = Math.max(v.y1, yMin), hi = Math.min(v.y2, yMax);
|
|
2735
|
+
if (hi > lo) spans.push([lo, hi]);
|
|
2736
|
+
}
|
|
2737
|
+
if (spans.length === 0) return 0;
|
|
2738
|
+
spans.sort((a, b) => a[0] - b[0]);
|
|
2739
|
+
let total = 0, s = spans[0][0], e = spans[0][1];
|
|
2740
|
+
for (let i = 1; i < spans.length; i++) {
|
|
2741
|
+
if (spans[i][0] <= e) {
|
|
2742
|
+
if (spans[i][1] > e) e = spans[i][1];
|
|
2743
|
+
} else {
|
|
2744
|
+
total += e - s;
|
|
2745
|
+
s = spans[i][0];
|
|
2746
|
+
e = spans[i][1];
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
return total + (e - s);
|
|
2750
|
+
}
|
|
2751
|
+
function isProseBoxGrid(grid, verticals, table) {
|
|
2752
|
+
const numCols = grid.colXs.length - 1;
|
|
2753
|
+
if (numCols < 2 || grid.rowYs.length < 3) return false;
|
|
2754
|
+
const gyMax = grid.rowYs[0], gyMin = grid.rowYs[grid.rowYs.length - 1];
|
|
2755
|
+
const span = gyMax - gyMin;
|
|
2756
|
+
if (span <= 0) return false;
|
|
2757
|
+
const interior = grid.colXs.slice(1, -1);
|
|
2758
|
+
let fullWidthHeight = 0;
|
|
2759
|
+
for (let r = 0; r < grid.rowYs.length - 1; r++) {
|
|
2760
|
+
const top = grid.rowYs[r], bot = grid.rowYs[r + 1];
|
|
2761
|
+
const h = top - bot;
|
|
2762
|
+
if (h <= 0) continue;
|
|
2763
|
+
const hasDivider = interior.some((cx) => verticalCoverageAt(verticals, cx, bot, top) >= h * 0.5);
|
|
2764
|
+
if (!hasDivider) fullWidthHeight += h;
|
|
2765
|
+
}
|
|
2766
|
+
if (fullWidthHeight < span * PROSEBOX_FULLWIDTH_MIN) return false;
|
|
2767
|
+
const texts = table.cells.flat().map((c) => c.text.trim()).filter(Boolean);
|
|
2768
|
+
const longCells = texts.filter((s) => s.length > PROSEBOX_LONG_CELL_CHARS).length;
|
|
2769
|
+
if (longCells < PROSEBOX_LONG_CELL_MIN || longCells < texts.length * PROSEBOX_LONG_CELL_RATIO) return false;
|
|
2770
|
+
return true;
|
|
2771
|
+
}
|
|
2724
2772
|
function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
2725
2773
|
const blocks = [];
|
|
2726
2774
|
const usedItems = /* @__PURE__ */ new Set();
|
|
@@ -2795,6 +2843,10 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
|
2795
2843
|
};
|
|
2796
2844
|
const hasContent = finalGrid.some((row) => row.some((cell) => cell.text.trim() !== ""));
|
|
2797
2845
|
if (!hasContent) continue;
|
|
2846
|
+
if (isProseBoxGrid(grid, verticals, irTable)) {
|
|
2847
|
+
for (const it of tableItems) usedItems.delete(it);
|
|
2848
|
+
continue;
|
|
2849
|
+
}
|
|
2798
2850
|
const tableBbox = {
|
|
2799
2851
|
page: pageNum,
|
|
2800
2852
|
x: grid.bbox.x1,
|
|
@@ -3474,4 +3526,4 @@ export {
|
|
|
3474
3526
|
parsePdfDocument,
|
|
3475
3527
|
removeHeaderFooterBlocks
|
|
3476
3528
|
};
|
|
3477
|
-
//# sourceMappingURL=parser-
|
|
3529
|
+
//# sourceMappingURL=parser-XUNGOH76.js.map
|