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.
Files changed (37) hide show
  1. package/README.md +6 -0
  2. package/dist/{-3B5FDXW2.js → -QMW2GDWP.js} +5 -5
  3. package/dist/{chunk-PNXOUDS7.js → chunk-D4JKKSSI.js} +2 -2
  4. package/dist/{chunk-FU25KFFZ.js → chunk-GETZFABK.js} +3 -3
  5. package/dist/chunk-GETZFABK.js.map +1 -0
  6. package/dist/{chunk-5DL6VCIJ.js → chunk-O27B5IRL.js} +2 -2
  7. package/dist/{chunk-ZQOGTAT5.cjs → chunk-RCSDSN5Y.cjs} +2 -2
  8. package/dist/{chunk-ZQOGTAT5.cjs.map → chunk-RCSDSN5Y.cjs.map} +1 -1
  9. package/dist/{chunk-MZA7AXHN.js → chunk-SNSAZ7FA.js} +2 -2
  10. package/dist/{chunk-5TK4X4JQ.js → chunk-TUBD3EEF.js} +5 -5
  11. package/dist/cli.js +7 -7
  12. package/dist/index.cjs +119 -119
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +3 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/mcp.js +5 -5
  17. package/dist/{parser-VCJTQVAH.js → parser-3EARWV2H.js} +84 -3
  18. package/dist/parser-3EARWV2H.js.map +1 -0
  19. package/dist/{parser-DKIA66MN.js → parser-STGI5I5K.js} +83 -2
  20. package/dist/parser-STGI5I5K.js.map +1 -0
  21. package/dist/{parser-6B7BUSX3.cjs → parser-X34HD2KQ.cjs} +95 -14
  22. package/dist/parser-X34HD2KQ.cjs.map +1 -0
  23. package/dist/render-FPWZ6YNZ.js +9 -0
  24. package/dist/{watch-MQTMNUSB.js → watch-KVYJ46S6.js} +5 -5
  25. package/package.json +1 -1
  26. package/dist/chunk-FU25KFFZ.js.map +0 -1
  27. package/dist/parser-6B7BUSX3.cjs.map +0 -1
  28. package/dist/parser-DKIA66MN.js.map +0 -1
  29. package/dist/parser-VCJTQVAH.js.map +0 -1
  30. package/dist/render-4I72JOAR.js +0 -9
  31. /package/dist/{-3B5FDXW2.js.map → -QMW2GDWP.js.map} +0 -0
  32. /package/dist/{chunk-PNXOUDS7.js.map → chunk-D4JKKSSI.js.map} +0 -0
  33. /package/dist/{chunk-5DL6VCIJ.js.map → chunk-O27B5IRL.js.map} +0 -0
  34. /package/dist/{chunk-MZA7AXHN.js.map → chunk-SNSAZ7FA.js.map} +0 -0
  35. /package/dist/{chunk-5TK4X4JQ.js.map → chunk-TUBD3EEF.js.map} +0 -0
  36. /package/dist/{render-4I72JOAR.js.map → render-FPWZ6YNZ.js.map} +0 -0
  37. /package/dist/{watch-MQTMNUSB.js.map → watch-KVYJ46S6.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  blocksToMarkdown,
7
7
  safeMax,
8
8
  safeMin
9
- } from "./chunk-PNXOUDS7.js";
9
+ } from "./chunk-D4JKKSSI.js";
10
10
  import {
11
11
  parsePageRange
12
12
  } from "./chunk-GE43BE46.js";
@@ -198,10 +198,90 @@ function classifyAndAdd(seg, lineWidth, horizontals, verticals) {
198
198
  function preprocessLines(horizontals, verticals) {
199
199
  let h = horizontals.filter((l) => l.lineWidth <= MAX_LINE_WIDTH);
200
200
  let v = verticals.filter((l) => l.lineWidth <= MAX_LINE_WIDTH);
201
+ h = dropShadingStacks(h, "h");
202
+ v = dropShadingStacks(v, "v");
201
203
  h = mergeParallelLines(h, "h");
202
204
  v = mergeParallelLines(v, "v");
203
205
  return { horizontals: h, verticals: v };
204
206
  }
207
+ var STACK_GAP = 2;
208
+ var STACK_MIN_LINES = 6;
209
+ function dropShadingStacks(lines, dir) {
210
+ if (lines.length < STACK_MIN_LINES) return lines;
211
+ const groups = /* @__PURE__ */ new Map();
212
+ for (const l of lines) {
213
+ const key = dir === "h" ? `${Math.round(l.x1)}:${Math.round(l.x2)}` : `${Math.round(l.y1)}:${Math.round(l.y2)}`;
214
+ const arr = groups.get(key);
215
+ if (arr) arr.push(l);
216
+ else groups.set(key, [l]);
217
+ }
218
+ const dropped = /* @__PURE__ */ new Set();
219
+ for (const group of groups.values()) {
220
+ if (group.length < STACK_MIN_LINES) continue;
221
+ group.sort((a, b) => dir === "h" ? a.y1 - b.y1 : a.x1 - b.x1);
222
+ let runStart = 0;
223
+ for (let i = 1; i <= group.length; i++) {
224
+ const gap = i < group.length ? dir === "h" ? group[i].y1 - group[i - 1].y1 : group[i].x1 - group[i - 1].x1 : Infinity;
225
+ if (gap < STACK_GAP) continue;
226
+ if (i - runStart >= STACK_MIN_LINES) {
227
+ for (let j = runStart; j < i; j++) dropped.add(group[j]);
228
+ }
229
+ runStart = i;
230
+ }
231
+ }
232
+ return dropped.size ? lines.filter((l) => !dropped.has(l)) : lines;
233
+ }
234
+ var EDGE_ALIGN_TOL = 3;
235
+ var EDGE_MIN_RULES = 3;
236
+ var EDGE_MIN_SPAN = 12;
237
+ var EDGE_INSET = 15;
238
+ var EDGE_NEAR = 10;
239
+ var EDGE_CONNECT_TOL = 5;
240
+ function closeOpenTableEdges(horizontals, verticals) {
241
+ if (horizontals.length < EDGE_MIN_RULES) return verticals;
242
+ const groups = [];
243
+ for (const hl of horizontals) {
244
+ let placed = false;
245
+ for (const g2 of groups) {
246
+ if (Math.abs(g2[0].x1 - hl.x1) <= EDGE_ALIGN_TOL && Math.abs(g2[0].x2 - hl.x2) <= EDGE_ALIGN_TOL) {
247
+ g2.push(hl);
248
+ placed = true;
249
+ break;
250
+ }
251
+ }
252
+ if (!placed) groups.push([hl]);
253
+ }
254
+ const synthesized = [];
255
+ for (const g2 of groups) {
256
+ if (g2.length < EDGE_MIN_RULES) continue;
257
+ let yMin = Infinity, yMax = -Infinity, x1 = 0, x2 = 0;
258
+ for (const hl of g2) {
259
+ if (hl.y1 < yMin) yMin = hl.y1;
260
+ if (hl.y1 > yMax) yMax = hl.y1;
261
+ x1 += hl.x1;
262
+ x2 += hl.x2;
263
+ }
264
+ x1 /= g2.length;
265
+ x2 /= g2.length;
266
+ if (yMax - yMin < EDGE_MIN_SPAN) continue;
267
+ const crossCount = (v) => {
268
+ let n = 0;
269
+ for (const hl of g2) {
270
+ 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++;
271
+ }
272
+ return n;
273
+ };
274
+ const hasInterior = verticals.some((v) => v.x1 > x1 + EDGE_INSET && v.x1 < x2 - EDGE_INSET && crossCount(v) >= 2);
275
+ if (!hasInterior) continue;
276
+ for (const edgeX of [x1, x2]) {
277
+ const closed = verticals.some((v) => Math.abs(v.x1 - edgeX) <= EDGE_NEAR && v.y1 <= yMax + EDGE_CONNECT_TOL && v.y2 >= yMin - EDGE_CONNECT_TOL);
278
+ if (!closed) {
279
+ synthesized.push({ x1: edgeX, y1: yMin, x2: edgeX, y2: yMax, lineWidth: 0.5 });
280
+ }
281
+ }
282
+ }
283
+ return synthesized.length ? [...verticals, ...synthesized] : verticals;
284
+ }
205
285
  function mergeParallelLines(lines, dir) {
206
286
  if (lines.length <= 1) return lines;
207
287
  const sorted = [...lines].sort((a, b) => {
@@ -2552,6 +2632,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
2552
2632
  let { horizontals, verticals } = extractLines(opList.fnArray, opList.argsArray);
2553
2633
  ({ horizontals, verticals } = filterPageBorderLines(horizontals, verticals, pageWidth, pageHeight));
2554
2634
  ({ horizontals, verticals } = preprocessLines(horizontals, verticals));
2635
+ verticals = closeOpenTableEdges(horizontals, verticals);
2555
2636
  markStrikethroughItems(items, horizontals);
2556
2637
  wrapStrikethroughRuns(items);
2557
2638
  const grids = buildTableGrids(horizontals, verticals);
@@ -3356,4 +3437,4 @@ export {
3356
3437
  parsePdfDocument,
3357
3438
  removeHeaderFooterBlocks
3358
3439
  };
3359
- //# sourceMappingURL=parser-DKIA66MN.js.map
3440
+ //# sourceMappingURL=parser-STGI5I5K.js.map