kordoc 3.10.0 → 3.11.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 +6 -0
- package/dist/{-3B5FDXW2.js → -QMW2GDWP.js} +5 -5
- package/dist/{chunk-PNXOUDS7.js → chunk-D4JKKSSI.js} +2 -2
- package/dist/{chunk-FU25KFFZ.js → chunk-GETZFABK.js} +3 -3
- package/dist/chunk-GETZFABK.js.map +1 -0
- package/dist/{chunk-5DL6VCIJ.js → chunk-O27B5IRL.js} +2 -2
- package/dist/{chunk-ZQOGTAT5.cjs → chunk-RCSDSN5Y.cjs} +2 -2
- package/dist/{chunk-ZQOGTAT5.cjs.map → chunk-RCSDSN5Y.cjs.map} +1 -1
- package/dist/{chunk-MZA7AXHN.js → chunk-SNSAZ7FA.js} +2 -2
- package/dist/{chunk-5TK4X4JQ.js → chunk-TUBD3EEF.js} +5 -5
- package/dist/cli.js +7 -7
- package/dist/index.cjs +119 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +5 -5
- package/dist/{parser-VCJTQVAH.js → parser-3EARWV2H.js} +84 -3
- package/dist/parser-3EARWV2H.js.map +1 -0
- package/dist/{parser-DKIA66MN.js → parser-STGI5I5K.js} +83 -2
- package/dist/parser-STGI5I5K.js.map +1 -0
- package/dist/{parser-6B7BUSX3.cjs → parser-X34HD2KQ.cjs} +95 -14
- package/dist/parser-X34HD2KQ.cjs.map +1 -0
- package/dist/render-FPWZ6YNZ.js +9 -0
- package/dist/{watch-MQTMNUSB.js → watch-KVYJ46S6.js} +5 -5
- package/package.json +1 -1
- package/dist/chunk-FU25KFFZ.js.map +0 -1
- package/dist/parser-6B7BUSX3.cjs.map +0 -1
- package/dist/parser-DKIA66MN.js.map +0 -1
- package/dist/parser-VCJTQVAH.js.map +0 -1
- package/dist/render-4I72JOAR.js +0 -9
- /package/dist/{-3B5FDXW2.js.map → -QMW2GDWP.js.map} +0 -0
- /package/dist/{chunk-PNXOUDS7.js.map → chunk-D4JKKSSI.js.map} +0 -0
- /package/dist/{chunk-5DL6VCIJ.js.map → chunk-O27B5IRL.js.map} +0 -0
- /package/dist/{chunk-MZA7AXHN.js.map → chunk-SNSAZ7FA.js.map} +0 -0
- /package/dist/{chunk-5TK4X4JQ.js.map → chunk-TUBD3EEF.js.map} +0 -0
- /package/dist/{render-4I72JOAR.js.map → render-FPWZ6YNZ.js.map} +0 -0
- /package/dist/{watch-MQTMNUSB.js.map → watch-KVYJ46S6.js.map} +0 -0
package/dist/mcp.js
CHANGED
|
@@ -10,22 +10,22 @@ import {
|
|
|
10
10
|
parse,
|
|
11
11
|
patchHwp,
|
|
12
12
|
patchHwpx
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TUBD3EEF.js";
|
|
14
14
|
import {
|
|
15
15
|
detectFormat,
|
|
16
16
|
detectZipFormat
|
|
17
17
|
} from "./chunk-MEPHGCPQ.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-GETZFABK.js";
|
|
19
19
|
import {
|
|
20
20
|
blocksToMarkdown
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-O27B5IRL.js";
|
|
22
22
|
import "./chunk-MOL7MDBG.js";
|
|
23
23
|
import {
|
|
24
24
|
KordocError,
|
|
25
25
|
VERSION,
|
|
26
26
|
sanitizeError,
|
|
27
27
|
toArrayBuffer
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-SNSAZ7FA.js";
|
|
29
29
|
|
|
30
30
|
// src/mcp.ts
|
|
31
31
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -196,7 +196,7 @@ server.tool(
|
|
|
196
196
|
break;
|
|
197
197
|
case "pdf":
|
|
198
198
|
try {
|
|
199
|
-
const { extractPdfMetadataOnly } = await import("./parser-
|
|
199
|
+
const { extractPdfMetadataOnly } = await import("./parser-3EARWV2H.js");
|
|
200
200
|
metadata = await extractPdfMetadataOnly(buffer);
|
|
201
201
|
} catch {
|
|
202
202
|
metadata = void 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-O27B5IRL.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-SNSAZ7FA.js";
|
|
16
16
|
|
|
17
17
|
// src/pdf/line-extract.ts
|
|
18
18
|
import { OPS } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
@@ -201,10 +201,90 @@ function classifyAndAdd(seg, lineWidth, horizontals, verticals) {
|
|
|
201
201
|
function preprocessLines(horizontals, verticals) {
|
|
202
202
|
let h = horizontals.filter((l) => l.lineWidth <= MAX_LINE_WIDTH);
|
|
203
203
|
let v = verticals.filter((l) => l.lineWidth <= MAX_LINE_WIDTH);
|
|
204
|
+
h = dropShadingStacks(h, "h");
|
|
205
|
+
v = dropShadingStacks(v, "v");
|
|
204
206
|
h = mergeParallelLines(h, "h");
|
|
205
207
|
v = mergeParallelLines(v, "v");
|
|
206
208
|
return { horizontals: h, verticals: v };
|
|
207
209
|
}
|
|
210
|
+
var STACK_GAP = 2;
|
|
211
|
+
var STACK_MIN_LINES = 6;
|
|
212
|
+
function dropShadingStacks(lines, dir) {
|
|
213
|
+
if (lines.length < STACK_MIN_LINES) return lines;
|
|
214
|
+
const groups = /* @__PURE__ */ new Map();
|
|
215
|
+
for (const l of lines) {
|
|
216
|
+
const key = dir === "h" ? `${Math.round(l.x1)}:${Math.round(l.x2)}` : `${Math.round(l.y1)}:${Math.round(l.y2)}`;
|
|
217
|
+
const arr = groups.get(key);
|
|
218
|
+
if (arr) arr.push(l);
|
|
219
|
+
else groups.set(key, [l]);
|
|
220
|
+
}
|
|
221
|
+
const dropped = /* @__PURE__ */ new Set();
|
|
222
|
+
for (const group of groups.values()) {
|
|
223
|
+
if (group.length < STACK_MIN_LINES) continue;
|
|
224
|
+
group.sort((a, b) => dir === "h" ? a.y1 - b.y1 : a.x1 - b.x1);
|
|
225
|
+
let runStart = 0;
|
|
226
|
+
for (let i = 1; i <= group.length; i++) {
|
|
227
|
+
const gap = i < group.length ? dir === "h" ? group[i].y1 - group[i - 1].y1 : group[i].x1 - group[i - 1].x1 : Infinity;
|
|
228
|
+
if (gap < STACK_GAP) continue;
|
|
229
|
+
if (i - runStart >= STACK_MIN_LINES) {
|
|
230
|
+
for (let j = runStart; j < i; j++) dropped.add(group[j]);
|
|
231
|
+
}
|
|
232
|
+
runStart = i;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return dropped.size ? lines.filter((l) => !dropped.has(l)) : lines;
|
|
236
|
+
}
|
|
237
|
+
var EDGE_ALIGN_TOL = 3;
|
|
238
|
+
var EDGE_MIN_RULES = 3;
|
|
239
|
+
var EDGE_MIN_SPAN = 12;
|
|
240
|
+
var EDGE_INSET = 15;
|
|
241
|
+
var EDGE_NEAR = 10;
|
|
242
|
+
var EDGE_CONNECT_TOL = 5;
|
|
243
|
+
function closeOpenTableEdges(horizontals, verticals) {
|
|
244
|
+
if (horizontals.length < EDGE_MIN_RULES) return verticals;
|
|
245
|
+
const groups = [];
|
|
246
|
+
for (const hl of horizontals) {
|
|
247
|
+
let placed = false;
|
|
248
|
+
for (const g2 of groups) {
|
|
249
|
+
if (Math.abs(g2[0].x1 - hl.x1) <= EDGE_ALIGN_TOL && Math.abs(g2[0].x2 - hl.x2) <= EDGE_ALIGN_TOL) {
|
|
250
|
+
g2.push(hl);
|
|
251
|
+
placed = true;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (!placed) groups.push([hl]);
|
|
256
|
+
}
|
|
257
|
+
const synthesized = [];
|
|
258
|
+
for (const g2 of groups) {
|
|
259
|
+
if (g2.length < EDGE_MIN_RULES) continue;
|
|
260
|
+
let yMin = Infinity, yMax = -Infinity, x1 = 0, x2 = 0;
|
|
261
|
+
for (const hl of g2) {
|
|
262
|
+
if (hl.y1 < yMin) yMin = hl.y1;
|
|
263
|
+
if (hl.y1 > yMax) yMax = hl.y1;
|
|
264
|
+
x1 += hl.x1;
|
|
265
|
+
x2 += hl.x2;
|
|
266
|
+
}
|
|
267
|
+
x1 /= g2.length;
|
|
268
|
+
x2 /= g2.length;
|
|
269
|
+
if (yMax - yMin < EDGE_MIN_SPAN) continue;
|
|
270
|
+
const crossCount = (v) => {
|
|
271
|
+
let n = 0;
|
|
272
|
+
for (const hl of g2) {
|
|
273
|
+
if (v.x1 >= hl.x1 - EDGE_CONNECT_TOL && v.x1 <= hl.x2 + EDGE_CONNECT_TOL && hl.y1 >= v.y1 - EDGE_CONNECT_TOL && hl.y1 <= v.y2 + EDGE_CONNECT_TOL) n++;
|
|
274
|
+
}
|
|
275
|
+
return n;
|
|
276
|
+
};
|
|
277
|
+
const hasInterior = verticals.some((v) => v.x1 > x1 + EDGE_INSET && v.x1 < x2 - EDGE_INSET && crossCount(v) >= 2);
|
|
278
|
+
if (!hasInterior) continue;
|
|
279
|
+
for (const edgeX of [x1, x2]) {
|
|
280
|
+
const closed = verticals.some((v) => Math.abs(v.x1 - edgeX) <= EDGE_NEAR && v.y1 <= yMax + EDGE_CONNECT_TOL && v.y2 >= yMin - EDGE_CONNECT_TOL);
|
|
281
|
+
if (!closed) {
|
|
282
|
+
synthesized.push({ x1: edgeX, y1: yMin, x2: edgeX, y2: yMax, lineWidth: 0.5 });
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return synthesized.length ? [...verticals, ...synthesized] : verticals;
|
|
287
|
+
}
|
|
208
288
|
function mergeParallelLines(lines, dir) {
|
|
209
289
|
if (lines.length <= 1) return lines;
|
|
210
290
|
const sorted = [...lines].sort((a, b) => {
|
|
@@ -2555,6 +2635,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
2555
2635
|
let { horizontals, verticals } = extractLines(opList.fnArray, opList.argsArray);
|
|
2556
2636
|
({ horizontals, verticals } = filterPageBorderLines(horizontals, verticals, pageWidth, pageHeight));
|
|
2557
2637
|
({ horizontals, verticals } = preprocessLines(horizontals, verticals));
|
|
2638
|
+
verticals = closeOpenTableEdges(horizontals, verticals);
|
|
2558
2639
|
markStrikethroughItems(items, horizontals);
|
|
2559
2640
|
wrapStrikethroughRuns(items);
|
|
2560
2641
|
const grids = buildTableGrids(horizontals, verticals);
|
|
@@ -3359,4 +3440,4 @@ export {
|
|
|
3359
3440
|
parsePdfDocument,
|
|
3360
3441
|
removeHeaderFooterBlocks
|
|
3361
3442
|
};
|
|
3362
|
-
//# sourceMappingURL=parser-
|
|
3443
|
+
//# sourceMappingURL=parser-3EARWV2H.js.map
|