kordoc 4.18.13 → 4.19.1

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 (131) hide show
  1. package/README.md +3 -1
  2. package/dist/{-DC2OO5KO.js → -LYUUVVQF.js} +11 -11
  3. package/dist/{chunk-ISC2TH24.js → chunk-4WTJS6ES.js} +2 -2
  4. package/dist/{chunk-SVIOP7PE.js → chunk-5AZQEMMG.js} +7 -7
  5. package/dist/{chunk-SVIOP7PE.js.map → chunk-5AZQEMMG.js.map} +1 -1
  6. package/dist/{chunk-GUH6HYSZ.js → chunk-6KOQPPLX.js} +25 -22
  7. package/dist/chunk-6KOQPPLX.js.map +1 -0
  8. package/dist/{chunk-PN5WWW56.js → chunk-7L5GY54Q.js} +2 -2
  9. package/dist/{chunk-PN5WWW56.js.map → chunk-7L5GY54Q.js.map} +1 -1
  10. package/dist/{chunk-PHMWSWHJ.js → chunk-7XRI4FL4.js} +2 -2
  11. package/dist/{chunk-32ZUIHSY.js → chunk-ADBES5QJ.js} +3 -3
  12. package/dist/{chunk-JWTZ3OVZ.js → chunk-BDTWXJNM.js} +2 -2
  13. package/dist/{chunk-INESPVEV.js → chunk-CL3CJ7X5.js} +3 -3
  14. package/dist/{chunk-VDEENOPW.js → chunk-DQHDI567.js} +2 -2
  15. package/dist/{chunk-ZNY5BRV6.js → chunk-FEGRQA3Q.js} +4 -4
  16. package/dist/{chunk-3FGHQWJP.cjs → chunk-FNX3ZAYB.cjs} +22 -22
  17. package/dist/{chunk-3FGHQWJP.cjs.map → chunk-FNX3ZAYB.cjs.map} +1 -1
  18. package/dist/{chunk-GGMIPTM5.cjs → chunk-GPNPYBXJ.cjs} +12 -12
  19. package/dist/{chunk-GGMIPTM5.cjs.map → chunk-GPNPYBXJ.cjs.map} +1 -1
  20. package/dist/{chunk-6CQZMVXW.cjs → chunk-HMJXB7ZE.cjs} +3 -3
  21. package/dist/{chunk-6CQZMVXW.cjs.map → chunk-HMJXB7ZE.cjs.map} +1 -1
  22. package/dist/{chunk-IRN5SDY2.js → chunk-JA5B4NPF.js} +2 -2
  23. package/dist/{chunk-GSW7W7AL.js → chunk-JNIJPP4B.js} +7 -4
  24. package/dist/chunk-JNIJPP4B.js.map +1 -0
  25. package/dist/{chunk-EZSWBHHI.js → chunk-KYFP5LDC.js} +2 -2
  26. package/dist/{chunk-XVB3PUPJ.js → chunk-L5N5UQBP.js} +10 -4
  27. package/dist/chunk-L5N5UQBP.js.map +1 -0
  28. package/dist/{chunk-6AYTYTFY.js → chunk-MSUGYK6A.js} +3 -3
  29. package/dist/{chunk-K6WSMTVU.cjs → chunk-RHMIEEAZ.cjs} +2 -2
  30. package/dist/{chunk-K6WSMTVU.cjs.map → chunk-RHMIEEAZ.cjs.map} +1 -1
  31. package/dist/{chunk-JKHU7HID.js → chunk-TRUR4RUJ.js} +95 -11
  32. package/dist/chunk-TRUR4RUJ.js.map +1 -0
  33. package/dist/{chunk-DHEUQXXR.js → chunk-UAAYIEIK.js} +2 -2
  34. package/dist/{chunk-RQEDNI4P.cjs → chunk-UOXOYZU4.cjs} +3 -3
  35. package/dist/{chunk-RQEDNI4P.cjs.map → chunk-UOXOYZU4.cjs.map} +1 -1
  36. package/dist/{chunk-6FW3AZWN.cjs → chunk-W5NXOMCD.cjs} +125 -35
  37. package/dist/chunk-W5NXOMCD.cjs.map +1 -0
  38. package/dist/{chunk-V7LKQNC4.js → chunk-X6ME7YYS.js} +2 -2
  39. package/dist/{chunk-LKA7Z2NH.js → chunk-XFZMRCGJ.js} +2 -2
  40. package/dist/{chunk-JPSLMPFI.js → chunk-YLST4S4P.js} +103 -13
  41. package/dist/chunk-YLST4S4P.js.map +1 -0
  42. package/dist/{chunk-EBXJ45VZ.js → chunk-Z2WI3E4N.js} +2 -2
  43. package/dist/{chunk-EBXJ45VZ.js.map → chunk-Z2WI3E4N.js.map} +1 -1
  44. package/dist/{chunk-7LOD4IGO.js → chunk-ZTGTFO52.js} +4 -4
  45. package/dist/chunks-T67OQGPJ.js +10 -0
  46. package/dist/cli.js +39 -28
  47. package/dist/cli.js.map +1 -1
  48. package/dist/{formula-DAMFHLQO.js → formula-G4YA7SNQ.js} +3 -3
  49. package/dist/{formula-HJNQGPRC.cjs → formula-J3UUIPCX.cjs} +9 -9
  50. package/dist/{formula-HJNQGPRC.cjs.map → formula-J3UUIPCX.cjs.map} +1 -1
  51. package/dist/{formula-YCAO5IVW.js → formula-QSZRYZ44.js} +4 -4
  52. package/dist/{image-ocr-AZ25IOC7.cjs → image-ocr-467KLV3F.cjs} +15 -15
  53. package/dist/{image-ocr-AZ25IOC7.cjs.map → image-ocr-467KLV3F.cjs.map} +1 -1
  54. package/dist/{image-ocr-VH54SDZ7.js → image-ocr-I52GBXRE.js} +6 -6
  55. package/dist/{image-ocr-PAF76DAW.js → image-ocr-ZP3F4MUY.js} +9 -9
  56. package/dist/index.cjs +669 -663
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +15 -2
  59. package/dist/index.d.ts +15 -2
  60. package/dist/index.js +26 -20
  61. package/dist/index.js.map +1 -1
  62. package/dist/mcp.js +25 -23
  63. package/dist/mcp.js.map +1 -1
  64. package/dist/{model-bundle-53CHDYCG.js → model-bundle-FEUM7XXS.js} +5 -5
  65. package/dist/{models-UVLAKK3M.js → models-6QCNX5YR.js} +5 -5
  66. package/dist/{parser-I4D3TRGU.js → parser-6EIBURDE.js} +179 -13
  67. package/dist/parser-6EIBURDE.js.map +1 -0
  68. package/dist/{parser-HWAOPQYK.cjs → parser-BIJBX2D5.cjs} +393 -227
  69. package/dist/parser-BIJBX2D5.cjs.map +1 -0
  70. package/dist/{parser-Z6PHB54O.js → parser-YX4LGKIK.js} +176 -10
  71. package/dist/parser-YX4LGKIK.js.map +1 -0
  72. package/dist/pdf-ocr-DXQIMO77.cjs +17 -0
  73. package/dist/{pdf-ocr-HR6CXGTX.cjs.map → pdf-ocr-DXQIMO77.cjs.map} +1 -1
  74. package/dist/pdf-ocr-MESGGING.js +20 -0
  75. package/dist/pdf-ocr-YSRBRIPR.js +16 -0
  76. package/dist/{profile-io-WHCWCOPW.js → profile-io-ATHFEUAP.js} +3 -3
  77. package/dist/{rasterize-5DZ3DHGH.js → rasterize-SG3CLXMQ.js} +3 -3
  78. package/dist/{redact-doc-RNJVMFGQ.js → redact-doc-K3S4HFHU.js} +11 -11
  79. package/dist/{render-NZ6RA6SW.js → render-6CQJM7VE.js} +7 -7
  80. package/dist/seal-SMO4544N.js +10 -0
  81. package/dist/{setup-U3EQNK4Z.js → setup-CZ5KHGPI.js} +3 -3
  82. package/dist/visual-UWYGQLOU.js +20 -0
  83. package/dist/{watch-GB2M7XU6.js → watch-RQRIGLFF.js} +12 -12
  84. package/package.json +3 -2
  85. package/dist/chunk-6FW3AZWN.cjs.map +0 -1
  86. package/dist/chunk-GSW7W7AL.js.map +0 -1
  87. package/dist/chunk-GUH6HYSZ.js.map +0 -1
  88. package/dist/chunk-JKHU7HID.js.map +0 -1
  89. package/dist/chunk-JPSLMPFI.js.map +0 -1
  90. package/dist/chunk-XVB3PUPJ.js.map +0 -1
  91. package/dist/chunks-JZW2TXIZ.js +0 -10
  92. package/dist/parser-HWAOPQYK.cjs.map +0 -1
  93. package/dist/parser-I4D3TRGU.js.map +0 -1
  94. package/dist/parser-Z6PHB54O.js.map +0 -1
  95. package/dist/pdf-ocr-F4ICXO7W.js +0 -20
  96. package/dist/pdf-ocr-HR6CXGTX.cjs +0 -17
  97. package/dist/pdf-ocr-JI3K7JIN.js +0 -16
  98. package/dist/seal-WHJ6O5HT.js +0 -10
  99. package/dist/visual-JDAS4R43.js +0 -20
  100. /package/dist/{-DC2OO5KO.js.map → -LYUUVVQF.js.map} +0 -0
  101. /package/dist/{chunk-ISC2TH24.js.map → chunk-4WTJS6ES.js.map} +0 -0
  102. /package/dist/{chunk-PHMWSWHJ.js.map → chunk-7XRI4FL4.js.map} +0 -0
  103. /package/dist/{chunk-32ZUIHSY.js.map → chunk-ADBES5QJ.js.map} +0 -0
  104. /package/dist/{chunk-JWTZ3OVZ.js.map → chunk-BDTWXJNM.js.map} +0 -0
  105. /package/dist/{chunk-INESPVEV.js.map → chunk-CL3CJ7X5.js.map} +0 -0
  106. /package/dist/{chunk-VDEENOPW.js.map → chunk-DQHDI567.js.map} +0 -0
  107. /package/dist/{chunk-ZNY5BRV6.js.map → chunk-FEGRQA3Q.js.map} +0 -0
  108. /package/dist/{chunk-IRN5SDY2.js.map → chunk-JA5B4NPF.js.map} +0 -0
  109. /package/dist/{chunk-EZSWBHHI.js.map → chunk-KYFP5LDC.js.map} +0 -0
  110. /package/dist/{chunk-6AYTYTFY.js.map → chunk-MSUGYK6A.js.map} +0 -0
  111. /package/dist/{chunk-DHEUQXXR.js.map → chunk-UAAYIEIK.js.map} +0 -0
  112. /package/dist/{chunk-V7LKQNC4.js.map → chunk-X6ME7YYS.js.map} +0 -0
  113. /package/dist/{chunk-LKA7Z2NH.js.map → chunk-XFZMRCGJ.js.map} +0 -0
  114. /package/dist/{chunk-7LOD4IGO.js.map → chunk-ZTGTFO52.js.map} +0 -0
  115. /package/dist/{chunks-JZW2TXIZ.js.map → chunks-T67OQGPJ.js.map} +0 -0
  116. /package/dist/{formula-DAMFHLQO.js.map → formula-G4YA7SNQ.js.map} +0 -0
  117. /package/dist/{formula-YCAO5IVW.js.map → formula-QSZRYZ44.js.map} +0 -0
  118. /package/dist/{image-ocr-VH54SDZ7.js.map → image-ocr-I52GBXRE.js.map} +0 -0
  119. /package/dist/{image-ocr-PAF76DAW.js.map → image-ocr-ZP3F4MUY.js.map} +0 -0
  120. /package/dist/{model-bundle-53CHDYCG.js.map → model-bundle-FEUM7XXS.js.map} +0 -0
  121. /package/dist/{models-UVLAKK3M.js.map → models-6QCNX5YR.js.map} +0 -0
  122. /package/dist/{pdf-ocr-F4ICXO7W.js.map → pdf-ocr-MESGGING.js.map} +0 -0
  123. /package/dist/{pdf-ocr-JI3K7JIN.js.map → pdf-ocr-YSRBRIPR.js.map} +0 -0
  124. /package/dist/{profile-io-WHCWCOPW.js.map → profile-io-ATHFEUAP.js.map} +0 -0
  125. /package/dist/{rasterize-5DZ3DHGH.js.map → rasterize-SG3CLXMQ.js.map} +0 -0
  126. /package/dist/{redact-doc-RNJVMFGQ.js.map → redact-doc-K3S4HFHU.js.map} +0 -0
  127. /package/dist/{render-NZ6RA6SW.js.map → render-6CQJM7VE.js.map} +0 -0
  128. /package/dist/{seal-WHJ6O5HT.js.map → seal-SMO4544N.js.map} +0 -0
  129. /package/dist/{setup-U3EQNK4Z.js.map → setup-CZ5KHGPI.js.map} +0 -0
  130. /package/dist/{visual-JDAS4R43.js.map → visual-UWYGQLOU.js.map} +0 -0
  131. /package/dist/{watch-GB2M7XU6.js.map → watch-RQRIGLFF.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  blocksToPages,
3
3
  encodePng
4
- } from "./chunk-VDEENOPW.js";
4
+ } from "./chunk-DQHDI567.js";
5
5
  import {
6
6
  hasRequestedPagesAfter,
7
7
  parsePageRange
@@ -58,22 +58,24 @@ import {
58
58
  startsNewItem,
59
59
  trimTrailingEmptyTableCols,
60
60
  wrapJoiner
61
- } from "./chunk-ZNY5BRV6.js";
61
+ } from "./chunk-FEGRQA3Q.js";
62
62
  import {
63
63
  CELL_EDGES,
64
+ CELL_PAGES,
64
65
  CONTENT_CELLS,
65
66
  WINGDINGS,
67
+ assignTableIds,
66
68
  blocksToMarkdown,
67
69
  escapeLiteralDollar,
68
70
  escapeLiteralTags,
69
71
  stripScriptTags,
70
72
  unframeLayoutTables
71
- } from "./chunk-JPSLMPFI.js";
72
- import "./chunk-PHMWSWHJ.js";
73
+ } from "./chunk-YLST4S4P.js";
74
+ import "./chunk-7XRI4FL4.js";
73
75
  import {
74
76
  KordocError,
75
77
  sanitizeHref
76
- } from "./chunk-EBXJ45VZ.js";
78
+ } from "./chunk-Z2WI3E4N.js";
77
79
 
78
80
  // src/pdf/ocr-region-merge.ts
79
81
  function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
@@ -754,6 +756,167 @@ function splitContactTables(blocks) {
754
756
  }
755
757
  }
756
758
 
759
+ // src/pdf/table-pages.ts
760
+ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
761
+ function relocate(src, dst, from = 0) {
762
+ const out = [];
763
+ for (const s of CELL_SPLITS.get(src) ?? []) {
764
+ const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, out.at(-1)?.at ?? 0));
765
+ if (at >= 0) out.push({ at, page: s.page });
766
+ }
767
+ return out;
768
+ }
769
+ var setSplits = (cell, splits) => {
770
+ if (splits.length) CELL_SPLITS.set(cell, splits.sort((a, b) => a.at - b.at));
771
+ };
772
+ function markContinuedText(cell, add, page) {
773
+ if (!add.text.trim()) return;
774
+ const base = cell.text.trim() ? cell.text.length + 1 : 0;
775
+ setSplits(cell, [
776
+ ...CELL_SPLITS.get(cell) ?? [],
777
+ { at: base, page },
778
+ ...(CELL_SPLITS.get(add) ?? []).map((s) => ({ at: base + s.at, page: s.page }))
779
+ ]);
780
+ }
781
+ function rowStarts(t) {
782
+ const covered = /* @__PURE__ */ new Set();
783
+ const rows = [];
784
+ for (let r = 0; r < t.rows; r++) {
785
+ const starts = [];
786
+ for (let c = 0; c < t.cols; c++) {
787
+ if (covered.has(r * 1e5 + c)) continue;
788
+ const cell = t.cells[r]?.[c];
789
+ if (!cell) continue;
790
+ for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
791
+ starts.push({ cell, c });
792
+ }
793
+ rows.push(starts);
794
+ }
795
+ return rows;
796
+ }
797
+ var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
798
+ function cellPage(cell) {
799
+ const p = CELL_PAGES.get(cell);
800
+ if (p !== void 0 || !cell.blocks?.length || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
801
+ return Math.min(...cell.blocks.map((b) => b.pageNumber));
802
+ }
803
+ function tableRowPages(t, pageNumber) {
804
+ const pages = [];
805
+ let prev = pageNumber;
806
+ for (const starts of rowStarts(t)) {
807
+ let mark, text = false;
808
+ for (const { cell } of starts) {
809
+ const p = cellPage(cell);
810
+ if (p !== void 0) mark = Math.max(mark ?? p, p);
811
+ else if (cell.text.trim() || cell.blocks?.length) text = true;
812
+ }
813
+ const page = mark ?? (text ? pageNumber : prev);
814
+ prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : page ?? prev;
815
+ pages.push(prev);
816
+ }
817
+ return pages;
818
+ }
819
+ function markJoinedPages(table, prev, curr) {
820
+ const pt = prev.table, ct = curr.table;
821
+ if (!curr.pageNumber || table.rows < pt.rows) return;
822
+ const pp = tableRowPages(pt, prev.pageNumber), cp = tableRowPages(ct, curr.pageNumber);
823
+ const off = table.rows - ct.rows;
824
+ const rows = rowStarts(table), ptRows = rowStarts(pt), ctRows = rowStarts(ct);
825
+ rows.forEach((starts, r) => {
826
+ const page2 = r < pt.rows ? pp[r] : cp[r - off];
827
+ for (const { cell } of starts) {
828
+ if (page2 !== void 0 && page2 !== prev.pageNumber) CELL_PAGES.set(cell, page2);
829
+ const src = (r < pt.rows ? ptRows[r] : ctRows[r - off])?.find((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell));
830
+ if (src) setSplits(cell, relocate(src.cell, cell));
831
+ }
832
+ });
833
+ const cr = pt.rows - 1 - off, page = cp[cr];
834
+ if (cr < 0 || page === void 0 || page === prev.pageNumber) return;
835
+ const tails = ctRows[cr].filter((s) => s.cell.text.trim());
836
+ for (const { cell } of ctRows[cr]) for (const b of cell.blocks ?? []) b.pageNumber ??= page;
837
+ const heads = covering(pt, pt.rows - 1);
838
+ for (const cell of covering(table, pt.rows - 1)) {
839
+ if (cell.blocks?.length) continue;
840
+ const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
841
+ if (!head) continue;
842
+ const from = head.text.trimEnd().length;
843
+ const hit = tails.map((t) => ({ t: t.cell, at: cell.text.indexOf(t.cell.text.trim().slice(0, 20), from) })).filter((h) => h.at >= from).sort((a, b) => a.at - b.at)[0];
844
+ if (!hit) continue;
845
+ setSplits(cell, [...relocate(head, cell), { at: hit.at, page }, ...relocate(hit.t, cell, hit.at)]);
846
+ }
847
+ }
848
+ function splitCell(cell, page) {
849
+ if (page === void 0) return null;
850
+ if (cell.blocks?.length) {
851
+ const k2 = cell.blocks.findIndex((b) => (b.pageNumber ?? page) > page);
852
+ if (k2 <= 0) return null;
853
+ const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
854
+ const text = (bs) => bs.map((b) => b.text ?? "").filter(Boolean).join("\n");
855
+ return { head: { text: text(head), blocks: head }, tail: { text: text(tail), blocks: tail }, page: tail[0].pageNumber, rest: [] };
856
+ }
857
+ const splits = CELL_SPLITS.get(cell) ?? [];
858
+ const k = splits.findIndex((s2) => s2.page > page && s2.at < cell.text.length);
859
+ if (k < 0) return null;
860
+ const s = splits[k];
861
+ const rest = cell.text.slice(s.at), lead = rest.length - rest.trimStart().length;
862
+ return {
863
+ head: { text: cell.text.slice(0, s.at).trimEnd() },
864
+ tail: { text: rest.trim() },
865
+ page: s.page,
866
+ rest: splits.slice(k + 1).map((x) => ({ at: x.at - s.at - lead, page: x.page })).filter((x) => x.at > 0)
867
+ };
868
+ }
869
+ function splitCrossPageRows(t, pageNumber) {
870
+ const pages = tableRowPages(t, pageNumber);
871
+ const rows = rowStarts(t);
872
+ for (let r = 0; r < t.rows; r++) {
873
+ const splits = rows[r].map((s) => ({ ...s, split: splitCell(s.cell, pages[r]) })).filter((s) => s.split);
874
+ if (!splits.length) continue;
875
+ const clone = (cell, patch) => {
876
+ const out = { ...cell, ...patch };
877
+ const p = CELL_PAGES.get(cell);
878
+ if (p !== void 0) CELL_PAGES.set(out, p);
879
+ if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
880
+ return out;
881
+ };
882
+ const e = Math.max(...splits.map((s) => r + s.cell.rowSpan - 1));
883
+ const cells = t.cells.map((row2) => row2.slice());
884
+ const row = Array.from({ length: t.cols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }));
885
+ for (const { cell, c, split } of splits) {
886
+ cells[r][c] = clone(cell, split.head);
887
+ const tail = { ...cell, ...split.tail, rowSpan: 1 };
888
+ CELL_PAGES.set(tail, split.page);
889
+ setSplits(tail, split.rest);
890
+ row[c] = tail;
891
+ }
892
+ rows.forEach((starts, rr) => {
893
+ for (const { cell, c } of starts) {
894
+ if (splits.some((s) => s.cell === cell) || rr > e || rr + cell.rowSpan - 1 <= e) continue;
895
+ cells[rr][c] = clone(cells[rr][c], { rowSpan: cell.rowSpan + 1 });
896
+ }
897
+ });
898
+ cells.splice(e + 1, 0, row);
899
+ return splitCrossPageRows({ ...t, rows: t.rows + 1, cells }, pageNumber);
900
+ }
901
+ return t;
902
+ }
903
+ function splitPageTables(blocks) {
904
+ return blocks.flatMap((b) => {
905
+ if (b.type !== "table" || !b.table) return [b];
906
+ const t = splitCrossPageRows(b.table, b.pageNumber);
907
+ const pages = tableRowPages(t, b.pageNumber);
908
+ const cuts = [0];
909
+ for (let r = 1; r < t.rows; r++) if (pages[r] !== pages[r - 1]) cuts.push(r);
910
+ if (cuts.length === 1) return t === b.table ? [b] : [{ ...b, table: t }];
911
+ return cuts.map((from, k) => {
912
+ const end = cuts[k + 1] ?? t.rows;
913
+ const cells = t.cells.slice(from, end).map((row, dr) => row.map((cell) => cell && from + dr + cell.rowSpan > end ? { ...cell, rowSpan: end - from - dr } : cell));
914
+ const table = { ...t, rows: end - from, cells, ...k ? { caption: void 0, captionBlocks: void 0 } : {} };
915
+ return { ...b, table, pageNumber: pages[from] };
916
+ });
917
+ });
918
+ }
919
+
757
920
  // src/pdf/table-parts.ts
758
921
  var flowText = (text) => text.replace(/<\/?u>|~~/g, "");
759
922
  var PART_COL_TOL = 1;
@@ -1173,6 +1336,7 @@ function leftColumnOf(b, t) {
1173
1336
  }
1174
1337
  function placeJoined(blocks, i, j, table) {
1175
1338
  const prev = blocks[i];
1339
+ markJoinedPages(table, prev, blocks[j]);
1176
1340
  blocks[i] = { ...prev, table };
1177
1341
  blocks.splice(j, 1);
1178
1342
  let k = j - 1;
@@ -1526,6 +1690,7 @@ function mergeContinuedCells(blocks, pageHeights) {
1526
1690
  if (!cell || !add) continue;
1527
1691
  const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
1528
1692
  if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
1693
+ else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
1529
1694
  cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
1530
1695
  joinCellEdges(cell, add);
1531
1696
  const lines = CELL_LINES.get(add);
@@ -2874,7 +3039,7 @@ function mergeLinkRuns(markdown) {
2874
3039
 
2875
3040
  // src/pdf/formula-ocr.ts
2876
3041
  async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
2877
- const formulaMod = await import("./formula-DAMFHLQO.js");
3042
+ const formulaMod = await import("./formula-G4YA7SNQ.js");
2878
3043
  const { FormulaPipeline, ensureFormulaModels } = formulaMod;
2879
3044
  await ensureFormulaModels((p) => {
2880
3045
  if (p.phase === "download" && p.total) {
@@ -3295,7 +3460,7 @@ async function parsePdfDocument(buffer, options) {
3295
3460
  }
3296
3461
  if (targets.size > 0) {
3297
3462
  try {
3298
- const { runPdfOcr } = await import("./pdf-ocr-JI3K7JIN.js");
3463
+ const { runPdfOcr } = await import("./pdf-ocr-YSRBRIPR.js");
3299
3464
  const mode = typeof options?.ocr === "function" ? options.ocr : "builtin";
3300
3465
  const regionPages = new Map([...ocrRegions].filter(([p]) => options?.ocr !== "force" && !isImageBased && !pageQuality.find((q) => q.page === p)?.needsOcr));
3301
3466
  const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options?.onProgress, options?.tables !== false, vectorPageOps, regionPages);
@@ -3448,11 +3613,12 @@ async function parsePdfDocument(buffer, options) {
3448
3613
  blocks.length = 0;
3449
3614
  for (const b of kept) blocks.push(b);
3450
3615
  }
3451
- const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(blocksToMarkdown(bs), { keepLoneNumbers: true }));
3616
+ const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(blocksToMarkdown(bs, { tableFormat: options?.tableFormat }), { keepLoneNumbers: true }));
3617
+ if (options?.tableFormat === "gfm") assignTableIds(blocks);
3452
3618
  let markdown = finishMarkdown(outBlocks);
3453
3619
  return {
3454
3620
  markdown,
3455
- pages: blocksToPages(splitPageBreakWraps(outBlocks), finishMarkdown),
3621
+ pages: blocksToPages(splitPageTables(splitPageBreakWraps(outBlocks)), finishMarkdown),
3456
3622
  blocks,
3457
3623
  metadata,
3458
3624
  outline: outline.length > 0 ? outline : void 0,
@@ -3532,4 +3698,4 @@ export {
3532
3698
  parsePdfDocument,
3533
3699
  removeHeaderFooterBlocks
3534
3700
  };
3535
- //# sourceMappingURL=parser-Z6PHB54O.js.map
3701
+ //# sourceMappingURL=parser-YX4LGKIK.js.map