kordoc 4.0.5 → 4.0.6
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 +806 -800
- package/dist/{-QVHGOOCR.js → -NDU7YGSS.js} +8 -8
- package/dist/{chunk-QK2G34WE.js → chunk-4C7SBZNW.js} +2 -2
- package/dist/chunk-4C7SBZNW.js.map +1 -0
- package/dist/{chunk-MEPHGCPQ.js → chunk-5CJGKKMZ.js} +1 -1
- package/dist/chunk-5CJGKKMZ.js.map +1 -0
- package/dist/{chunk-OMERK4AW.js → chunk-5SOZXPQY.js} +3 -3
- package/dist/chunk-5SOZXPQY.js.map +1 -0
- package/dist/{chunk-6WDPB4SN.js → chunk-63ASYC4N.js} +3 -3
- package/dist/chunk-63ASYC4N.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-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-6R5FY47W.cjs → chunk-DQJTNXVS.cjs} +2 -2
- package/dist/chunk-DQJTNXVS.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-Z6Q3YG22.js → chunk-HC2SEH6I.js} +39 -9
- package/dist/chunk-HC2SEH6I.js.map +1 -0
- package/dist/{chunk-FKK4K53F.js → chunk-HOGJ5ALY.js} +2 -2
- package/dist/chunk-HOGJ5ALY.js.map +1 -0
- package/dist/{chunk-ZGMMLYAL.js → chunk-KA4FEBS2.js} +2 -2
- package/dist/chunk-KA4FEBS2.js.map +1 -0
- package/dist/{chunk-6BABRVOJ.js → chunk-L3I4TIRP.js} +2 -2
- package/dist/chunk-L3I4TIRP.js.map +1 -0
- package/dist/chunk-MOL7MDBG.js +0 -0
- package/dist/{chunk-6PED5OOG.js → chunk-UVSOSFER.js} +2 -2
- package/dist/chunk-UVSOSFER.js.map +1 -0
- package/dist/cli.js +15 -15
- package/dist/cli.js.map +1 -1
- package/dist/{detect-RI2MQ33K.js → detect-PJZMUL2Z.js} +2 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -1
- package/dist/formula-JCNF43NE.js +0 -0
- package/dist/index.cjs +167 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +13 -13
- 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-3MAYZUJX.js → parser-C636QIOB.js} +72 -4
- package/dist/parser-C636QIOB.js.map +1 -0
- package/dist/{parser-YSHZC5FQ.js → parser-DMKHIV4E.js} +71 -3
- package/dist/parser-DMKHIV4E.js.map +1 -0
- package/dist/{parser-2V5SPTU7.cjs → parser-VEY4B5CJ.cjs} +83 -15
- package/dist/parser-VEY4B5CJ.cjs.map +1 -0
- package/dist/{profile-io-3EECPDHG.js → profile-io-JYGCC6XQ.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-ISOEOMTM.js +10 -0
- package/dist/seal-676ZIAZZ.js +10 -0
- package/dist/setup-57FB3LSP.js +0 -0
- package/dist/{watch-7MHSCKEQ.js → watch-ZQUFJBFR.js} +8 -8
- package/dist/watch-ZQUFJBFR.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-FKK4K53F.js.map +0 -1
- package/dist/chunk-MEPHGCPQ.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/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/watch-7MHSCKEQ.js.map +0 -1
- /package/dist/{-QVHGOOCR.js.map → -NDU7YGSS.js.map} +0 -0
- /package/dist/{detect-RI2MQ33K.js.map → detect-PJZMUL2Z.js.map} +0 -0
- /package/dist/{profile-io-3EECPDHG.js.map → profile-io-JYGCC6XQ.js.map} +0 -0
- /package/dist/{render-MJSQ4TG2.js.map → render-ISOEOMTM.js.map} +0 -0
- /package/dist/{seal-R3POFNOU.js.map → seal-676ZIAZZ.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
blocksToMarkdown,
|
|
7
7
|
safeMax,
|
|
8
8
|
safeMin
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HOGJ5ALY.js";
|
|
10
10
|
import {
|
|
11
11
|
parsePageRange
|
|
12
12
|
} from "./chunk-GE43BE46.js";
|
|
@@ -427,6 +427,73 @@ function filterPageBorderLines(horizontals, verticals, pageWidth, pageHeight) {
|
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
+
// src/pdf/vertical-bridge.ts
|
|
431
|
+
var BRIDGE_X_TOL = 1.5;
|
|
432
|
+
var BRIDGE_MIN_GAP = 5;
|
|
433
|
+
var BRIDGE_MAX_GAP = 120;
|
|
434
|
+
var BRIDGE_BAND_TOL = 6;
|
|
435
|
+
var BRIDGE_MIN_COLUMNS = 3;
|
|
436
|
+
var BRIDGE_ENDPOINT_TOL = 2;
|
|
437
|
+
var BRIDGE_EDGE_EPS = 2;
|
|
438
|
+
function bridgeSplitColumnVerticals(horizontals, verticals) {
|
|
439
|
+
if (verticals.length < 4 || horizontals.length === 0) return verticals;
|
|
440
|
+
const sorted = [...verticals].sort((a, b) => a.x1 - b.x1 || a.y1 - b.y1);
|
|
441
|
+
const candidates = [];
|
|
442
|
+
let bandStart = 0;
|
|
443
|
+
const collectBand = (end) => {
|
|
444
|
+
const band = sorted.slice(bandStart, end).sort((a, b) => a.y1 - b.y1);
|
|
445
|
+
for (let i = 1; i < band.length; i++) {
|
|
446
|
+
const lower = band[i - 1], upper = band[i];
|
|
447
|
+
const gap = upper.y1 - lower.y2;
|
|
448
|
+
if (gap <= BRIDGE_MIN_GAP || gap > BRIDGE_MAX_GAP) continue;
|
|
449
|
+
const x = (lower.x1 + upper.x1) / 2;
|
|
450
|
+
const hasInteriorH = horizontals.some((h) => h.y1 > lower.y2 + BRIDGE_EDGE_EPS && h.y1 < upper.y1 - BRIDGE_EDGE_EPS && h.x1 <= x + BRIDGE_ENDPOINT_TOL && h.x2 >= x - BRIDGE_ENDPOINT_TOL);
|
|
451
|
+
if (!hasInteriorH) continue;
|
|
452
|
+
candidates.push({
|
|
453
|
+
x,
|
|
454
|
+
lo: lower.y2,
|
|
455
|
+
hi: upper.y1,
|
|
456
|
+
spanLo: lower.y1,
|
|
457
|
+
spanHi: upper.y2,
|
|
458
|
+
lineWidth: Math.min(lower.lineWidth, upper.lineWidth)
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
for (let i = 1; i <= sorted.length; i++) {
|
|
463
|
+
if (i === sorted.length || sorted[i].x1 - sorted[bandStart].x1 > BRIDGE_X_TOL) {
|
|
464
|
+
collectBand(i);
|
|
465
|
+
bandStart = i;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (candidates.length < BRIDGE_MIN_COLUMNS) return verticals;
|
|
469
|
+
const clusters = [];
|
|
470
|
+
for (const c of candidates) {
|
|
471
|
+
let placed = false;
|
|
472
|
+
for (const cl of clusters) {
|
|
473
|
+
if (Math.abs(cl[0].lo - c.lo) <= BRIDGE_BAND_TOL && Math.abs(cl[0].hi - c.hi) <= BRIDGE_BAND_TOL) {
|
|
474
|
+
cl.push(c);
|
|
475
|
+
placed = true;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (!placed) clusters.push([c]);
|
|
480
|
+
}
|
|
481
|
+
const synthesized = [];
|
|
482
|
+
for (const cl of clusters) {
|
|
483
|
+
if (cl.length < BRIDGE_MIN_COLUMNS) continue;
|
|
484
|
+
const xs = cl.map((c) => c.x).sort((a, b) => a - b);
|
|
485
|
+
const interiorXs = xs.slice(1, -1);
|
|
486
|
+
const bandLo = Math.min(...cl.map((c) => c.lo));
|
|
487
|
+
const bandHi = Math.max(...cl.map((c) => c.hi));
|
|
488
|
+
const segmented = horizontals.some((h) => h.y1 > bandLo + BRIDGE_EDGE_EPS && h.y1 < bandHi - BRIDGE_EDGE_EPS && interiorXs.some((ix) => Math.abs(h.x1 - ix) <= BRIDGE_ENDPOINT_TOL || Math.abs(h.x2 - ix) <= BRIDGE_ENDPOINT_TOL));
|
|
489
|
+
if (!segmented) continue;
|
|
490
|
+
for (const c of cl) {
|
|
491
|
+
synthesized.push({ x1: c.x, y1: c.spanLo, x2: c.x, y2: c.spanHi, lineWidth: c.lineWidth });
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return synthesized.length ? [...verticals, ...synthesized] : verticals;
|
|
495
|
+
}
|
|
496
|
+
|
|
430
497
|
// src/pdf/image-regions.ts
|
|
431
498
|
import { OPS as OPS2 } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
432
499
|
function multiplyTransform(m, t) {
|
|
@@ -2817,6 +2884,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
2817
2884
|
({ horizontals, verticals } = filterPageBorderLines(horizontals, verticals, pageWidth, pageHeight));
|
|
2818
2885
|
({ horizontals, verticals } = preprocessLines(horizontals, verticals));
|
|
2819
2886
|
verticals = closeOpenTableEdges(horizontals, verticals);
|
|
2887
|
+
verticals = bridgeSplitColumnVerticals(horizontals, verticals);
|
|
2820
2888
|
markStrikethroughItems(items, horizontals);
|
|
2821
2889
|
wrapStrikethroughRuns(items);
|
|
2822
2890
|
const grids = buildTableGrids(horizontals, verticals);
|
|
@@ -3555,7 +3623,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3555
3623
|
if (totalChars / Math.max(parsedPageCount, 1) < 10) {
|
|
3556
3624
|
if (options?.ocr) {
|
|
3557
3625
|
try {
|
|
3558
|
-
const { ocrPages } = await import("./provider-
|
|
3626
|
+
const { ocrPages } = await import("./provider-H4WWSPOV.js");
|
|
3559
3627
|
const ocrBlocks = await ocrPages(doc, options.ocr, pageFilter, effectivePageCount);
|
|
3560
3628
|
if (ocrBlocks.length > 0) {
|
|
3561
3629
|
const ocrMarkdown = ocrBlocks.map((b) => b.text || "").filter(Boolean).join("\n\n");
|
|
@@ -3673,4 +3741,4 @@ export {
|
|
|
3673
3741
|
parsePdfDocument,
|
|
3674
3742
|
removeHeaderFooterBlocks
|
|
3675
3743
|
};
|
|
3676
|
-
//# sourceMappingURL=parser-
|
|
3744
|
+
//# sourceMappingURL=parser-DMKHIV4E.js.map
|