kordoc 4.16.1 → 4.16.3

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 (140) hide show
  1. package/README.md +8 -12
  2. package/dist/{-3DURLXSO.js → -5XQIJN3D.js} +11 -11
  3. package/dist/{chunk-3WIQSM3Z.js → chunk-2EJ5YSFZ.js} +4 -4
  4. package/dist/chunk-3IB7LBHC.js +57 -0
  5. package/dist/chunk-3IB7LBHC.js.map +1 -0
  6. package/dist/{chunk-BTO7ZEE4.js → chunk-3ZVZPYSA.js} +37 -7
  7. package/dist/chunk-3ZVZPYSA.js.map +1 -0
  8. package/dist/{chunk-7FKPPIDZ.js → chunk-46H2PPG7.js} +166 -14
  9. package/dist/chunk-46H2PPG7.js.map +1 -0
  10. package/dist/{chunk-ANZTLTKU.js → chunk-4O5XQSCT.js} +4 -4
  11. package/dist/chunk-4O5XQSCT.js.map +1 -0
  12. package/dist/chunk-62W7QCEX.cjs +57 -0
  13. package/dist/chunk-62W7QCEX.cjs.map +1 -0
  14. package/dist/{chunk-NUPXPKIQ.js → chunk-7NYRZI2Z.js} +2 -2
  15. package/dist/{chunk-VCRBR72A.js → chunk-7USPM2VT.js} +2 -2
  16. package/dist/{chunk-D2QCXK2X.cjs → chunk-7WV3WETF.cjs} +7 -7
  17. package/dist/chunk-7WV3WETF.cjs.map +1 -0
  18. package/dist/{chunk-7XAGIPOX.js → chunk-AL2WM6ZZ.js} +2 -2
  19. package/dist/{chunk-N65ZXWNQ.js → chunk-AWWFGIBA.js} +2 -2
  20. package/dist/{chunk-OBRPYCIS.js → chunk-D2UGAEXY.js} +58 -23
  21. package/dist/chunk-D2UGAEXY.js.map +1 -0
  22. package/dist/{chunk-3VLVNKJV.js → chunk-ENF34XNH.js} +2 -2
  23. package/dist/{chunk-NCXRSQNE.js → chunk-GGGO3OH2.js} +2 -2
  24. package/dist/{chunk-CXWWX6BQ.js → chunk-GH2JGKWP.js} +2 -2
  25. package/dist/{chunk-24N4IJ5I.js → chunk-IE6QX3T3.js} +2 -2
  26. package/dist/chunk-J3IF6KGW.js +59 -0
  27. package/dist/chunk-J3IF6KGW.js.map +1 -0
  28. package/dist/{chunk-UZHT3LBF.js → chunk-JIFG35UT.js} +4 -4
  29. package/dist/chunk-JIFG35UT.js.map +1 -0
  30. package/dist/{chunk-BIHS4VWR.js → chunk-LQAKDKSF.js} +2 -2
  31. package/dist/{chunk-PVMROO3A.js → chunk-MC2SRJXO.js} +86 -94
  32. package/dist/chunk-MC2SRJXO.js.map +1 -0
  33. package/dist/{chunk-YRRBA4HW.cjs → chunk-PMULUMUF.cjs} +2 -2
  34. package/dist/{chunk-YRRBA4HW.cjs.map → chunk-PMULUMUF.cjs.map} +1 -1
  35. package/dist/{chunk-FSDJLAOW.js → chunk-QPJXYJIK.js} +55 -1
  36. package/dist/chunk-QPJXYJIK.js.map +1 -0
  37. package/dist/{chunk-DJ2BBQ5P.js → chunk-T2QHY3S5.js} +3 -3
  38. package/dist/{chunk-EEVAPRPD.js → chunk-UCGGVNTD.js} +3 -3
  39. package/dist/{chunk-63YGGAQW.js → chunk-XPYK7Z73.js} +2 -2
  40. package/dist/{chunk-NV37CQFN.cjs → chunk-YJECRT5Q.cjs} +12 -12
  41. package/dist/{chunk-NV37CQFN.cjs.map → chunk-YJECRT5Q.cjs.map} +1 -1
  42. package/dist/{chunk-7IRHSRPU.cjs → chunk-YOCFY44Z.cjs} +97 -25
  43. package/dist/chunk-YOCFY44Z.cjs.map +1 -0
  44. package/dist/{chunk-VNOQTDTE.js → chunk-YUZZNS6E.js} +2 -2
  45. package/dist/{chunk-2BZFKIRB.cjs → chunk-Z3RFAVZ2.cjs} +3 -3
  46. package/dist/{chunk-2BZFKIRB.cjs.map → chunk-Z3RFAVZ2.cjs.map} +1 -1
  47. package/dist/chunks-GBPAQ6JM.js +10 -0
  48. package/dist/cli.js +34 -52
  49. package/dist/cli.js.map +1 -1
  50. package/dist/{formula-IPLFHEBD.js → formula-EUX2AHXG.js} +3 -3
  51. package/dist/{formula-U4BTEZ6I.js → formula-IMEE5OJR.js} +4 -4
  52. package/dist/{formula-TRTONZMA.cjs → formula-NPOU4BSO.cjs} +9 -9
  53. package/dist/{formula-TRTONZMA.cjs.map → formula-NPOU4BSO.cjs.map} +1 -1
  54. package/dist/{image-ocr-3IJ25PS4.js → image-ocr-CCIE3SPX.js} +8 -8
  55. package/dist/{image-ocr-THFLQ3DC.cjs → image-ocr-LTSQRHCN.cjs} +15 -15
  56. package/dist/{image-ocr-THFLQ3DC.cjs.map → image-ocr-LTSQRHCN.cjs.map} +1 -1
  57. package/dist/{image-ocr-GTDG4SAJ.js → image-ocr-QLW5VL4M.js} +6 -6
  58. package/dist/index.cjs +723 -659
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +7 -1
  61. package/dist/index.d.ts +7 -1
  62. package/dist/index.js +82 -18
  63. package/dist/index.js.map +1 -1
  64. package/dist/mcp.js +34 -39
  65. package/dist/mcp.js.map +1 -1
  66. package/dist/{model-bundle-PVWIAVEX.js → model-bundle-VRKRVD6Z.js} +5 -5
  67. package/dist/{models-VCRF3JMT.js → models-GSZIPSV2.js} +5 -5
  68. package/dist/{parser-T4RITZDP.js → parser-64C45UPQ.js} +15 -12
  69. package/dist/{parser-UEROAPYZ.js.map → parser-64C45UPQ.js.map} +1 -1
  70. package/dist/{parser-UEROAPYZ.js → parser-NARS2CF7.js} +12 -9
  71. package/dist/{parser-T4RITZDP.js.map → parser-NARS2CF7.js.map} +1 -1
  72. package/dist/{parser-2CN2DIPV.cjs → parser-U52HRNOY.cjs} +86 -83
  73. package/dist/parser-U52HRNOY.cjs.map +1 -0
  74. package/dist/pdf-ocr-4QWLMFJQ.js +18 -0
  75. package/dist/pdf-ocr-C7RXT5YU.cjs +16 -0
  76. package/dist/{pdf-ocr-NARV2AQI.cjs.map → pdf-ocr-C7RXT5YU.cjs.map} +1 -1
  77. package/dist/pdf-ocr-ZYRJLOWQ.js +15 -0
  78. package/dist/{profile-io-YD54CDXY.js → profile-io-PZBOSV5X.js} +3 -3
  79. package/dist/{rasterize-3THYOOUN.js → rasterize-DXBWM6T2.js} +3 -3
  80. package/dist/{redact-doc-65L2YJN6.js → redact-doc-FLMBZ53F.js} +11 -11
  81. package/dist/{render-YU7QJVZ7.js → render-QNWUOQXJ.js} +7 -7
  82. package/dist/seal-NNZUQPDJ.js +10 -0
  83. package/dist/{setup-CFHKXDY4.js → setup-3OR4QZFF.js} +3 -3
  84. package/dist/visual-RDGSACGE.js +20 -0
  85. package/dist/{watch-D6FCAYKJ.js → watch-5A52FP6G.js} +12 -12
  86. package/package.json +1 -1
  87. package/dist/chunk-7FKPPIDZ.js.map +0 -1
  88. package/dist/chunk-7IRHSRPU.cjs.map +0 -1
  89. package/dist/chunk-ANZTLTKU.js.map +0 -1
  90. package/dist/chunk-BTO7ZEE4.js.map +0 -1
  91. package/dist/chunk-D2QCXK2X.cjs.map +0 -1
  92. package/dist/chunk-DO74GYSM.cjs +0 -11
  93. package/dist/chunk-DO74GYSM.cjs.map +0 -1
  94. package/dist/chunk-FSDJLAOW.js.map +0 -1
  95. package/dist/chunk-KBAQLAEL.js +0 -11
  96. package/dist/chunk-KBAQLAEL.js.map +0 -1
  97. package/dist/chunk-OBRPYCIS.js.map +0 -1
  98. package/dist/chunk-PVMROO3A.js.map +0 -1
  99. package/dist/chunk-T77M2QP7.js +0 -13
  100. package/dist/chunk-T77M2QP7.js.map +0 -1
  101. package/dist/chunk-UZHT3LBF.js.map +0 -1
  102. package/dist/chunks-PYYQURNO.js +0 -10
  103. package/dist/parser-2CN2DIPV.cjs.map +0 -1
  104. package/dist/pdf-ocr-NARV2AQI.cjs +0 -16
  105. package/dist/pdf-ocr-SYLMM727.js +0 -18
  106. package/dist/pdf-ocr-YMQZDJBO.js +0 -15
  107. package/dist/seal-6CQGFTML.js +0 -10
  108. package/dist/visual-ED2H75Q5.js +0 -20
  109. /package/dist/{-3DURLXSO.js.map → -5XQIJN3D.js.map} +0 -0
  110. /package/dist/{chunk-3WIQSM3Z.js.map → chunk-2EJ5YSFZ.js.map} +0 -0
  111. /package/dist/{chunk-NUPXPKIQ.js.map → chunk-7NYRZI2Z.js.map} +0 -0
  112. /package/dist/{chunk-VCRBR72A.js.map → chunk-7USPM2VT.js.map} +0 -0
  113. /package/dist/{chunk-7XAGIPOX.js.map → chunk-AL2WM6ZZ.js.map} +0 -0
  114. /package/dist/{chunk-N65ZXWNQ.js.map → chunk-AWWFGIBA.js.map} +0 -0
  115. /package/dist/{chunk-3VLVNKJV.js.map → chunk-ENF34XNH.js.map} +0 -0
  116. /package/dist/{chunk-NCXRSQNE.js.map → chunk-GGGO3OH2.js.map} +0 -0
  117. /package/dist/{chunk-CXWWX6BQ.js.map → chunk-GH2JGKWP.js.map} +0 -0
  118. /package/dist/{chunk-24N4IJ5I.js.map → chunk-IE6QX3T3.js.map} +0 -0
  119. /package/dist/{chunk-BIHS4VWR.js.map → chunk-LQAKDKSF.js.map} +0 -0
  120. /package/dist/{chunk-DJ2BBQ5P.js.map → chunk-T2QHY3S5.js.map} +0 -0
  121. /package/dist/{chunk-EEVAPRPD.js.map → chunk-UCGGVNTD.js.map} +0 -0
  122. /package/dist/{chunk-63YGGAQW.js.map → chunk-XPYK7Z73.js.map} +0 -0
  123. /package/dist/{chunk-VNOQTDTE.js.map → chunk-YUZZNS6E.js.map} +0 -0
  124. /package/dist/{chunks-PYYQURNO.js.map → chunks-GBPAQ6JM.js.map} +0 -0
  125. /package/dist/{formula-IPLFHEBD.js.map → formula-EUX2AHXG.js.map} +0 -0
  126. /package/dist/{formula-U4BTEZ6I.js.map → formula-IMEE5OJR.js.map} +0 -0
  127. /package/dist/{image-ocr-3IJ25PS4.js.map → image-ocr-CCIE3SPX.js.map} +0 -0
  128. /package/dist/{image-ocr-GTDG4SAJ.js.map → image-ocr-QLW5VL4M.js.map} +0 -0
  129. /package/dist/{model-bundle-PVWIAVEX.js.map → model-bundle-VRKRVD6Z.js.map} +0 -0
  130. /package/dist/{models-VCRF3JMT.js.map → models-GSZIPSV2.js.map} +0 -0
  131. /package/dist/{pdf-ocr-SYLMM727.js.map → pdf-ocr-4QWLMFJQ.js.map} +0 -0
  132. /package/dist/{pdf-ocr-YMQZDJBO.js.map → pdf-ocr-ZYRJLOWQ.js.map} +0 -0
  133. /package/dist/{profile-io-YD54CDXY.js.map → profile-io-PZBOSV5X.js.map} +0 -0
  134. /package/dist/{rasterize-3THYOOUN.js.map → rasterize-DXBWM6T2.js.map} +0 -0
  135. /package/dist/{redact-doc-65L2YJN6.js.map → redact-doc-FLMBZ53F.js.map} +0 -0
  136. /package/dist/{render-YU7QJVZ7.js.map → render-QNWUOQXJ.js.map} +0 -0
  137. /package/dist/{seal-6CQGFTML.js.map → seal-NNZUQPDJ.js.map} +0 -0
  138. /package/dist/{setup-CFHKXDY4.js.map → setup-3OR4QZFF.js.map} +0 -0
  139. /package/dist/{visual-ED2H75Q5.js.map → visual-RDGSACGE.js.map} +0 -0
  140. /package/dist/{watch-D6FCAYKJ.js.map → watch-5A52FP6G.js.map} +0 -0
@@ -1,13 +1,87 @@
1
- #!/usr/bin/env node
2
1
  import {
3
2
  HEADING_RATIO_H1,
4
3
  HEADING_RATIO_H2,
5
- HEADING_RATIO_H3
6
- } from "./chunk-T77M2QP7.js";
4
+ HEADING_RATIO_H3,
5
+ tidyScriptTags
6
+ } from "./chunk-3IB7LBHC.js";
7
+ import {
8
+ ensureModelsIn,
9
+ getModelsDir
10
+ } from "./chunk-AWWFGIBA.js";
7
11
  import {
8
12
  safeMax,
9
13
  safeMin
10
- } from "./chunk-3VLVNKJV.js";
14
+ } from "./chunk-7NYRZI2Z.js";
15
+
16
+ // src/ocr/models.ts
17
+ import { join } from "path";
18
+ import { stat } from "fs/promises";
19
+ var OCR_DET_MODEL = {
20
+ name: "PP-OCRv5 mobile det",
21
+ filename: "det.onnx",
22
+ url: "https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det_onnx/resolve/main/inference.onnx",
23
+ sha256: "a431985659dc921974177a95adcfbb90fd9e51989a5e04d70d0b75f597b6e61d",
24
+ sizeMb: 5
25
+ };
26
+ var OCR_REC_MODEL = {
27
+ name: "PP-OCRv5 korean rec",
28
+ filename: "rec_korean.onnx",
29
+ url: "https://huggingface.co/PaddlePaddle/korean_PP-OCRv5_mobile_rec_onnx/resolve/main/inference.onnx",
30
+ sha256: "92f0b7785e64fc9090106a241cf4c1eb97472824558272751b88a2a4476d3a08",
31
+ sizeMb: 13
32
+ };
33
+ var OCR_REC_DICT = {
34
+ name: "PP-OCRv5 korean dict",
35
+ filename: "rec_korean.yml",
36
+ url: "https://huggingface.co/PaddlePaddle/korean_PP-OCRv5_mobile_rec_onnx/resolve/main/inference.yml",
37
+ sha256: "f757fa1c40e99edcf27e9cce879b93eb2a51fa46f5ef39095689b8c37dd75998",
38
+ sizeMb: 1
39
+ };
40
+ var ALL_OCR_MODELS = [OCR_DET_MODEL, OCR_REC_MODEL, OCR_REC_DICT];
41
+ function getOcrModelsDir() {
42
+ return getModelsDir("ppocr");
43
+ }
44
+ async function ensureOcrModels(onProgress) {
45
+ return ensureModelsIn(getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
46
+ }
47
+ async function ocrModelsCached() {
48
+ const dir = getOcrModelsDir();
49
+ for (const spec of ALL_OCR_MODELS) {
50
+ try {
51
+ if (!(await stat(join(dir, spec.filename))).size) return false;
52
+ } catch {
53
+ return false;
54
+ }
55
+ }
56
+ return true;
57
+ }
58
+ function parseCharacterDict(yml) {
59
+ const lines = yml.split("\n");
60
+ const chars = [];
61
+ let inDict = false;
62
+ let dictIndent = -1;
63
+ for (const line of lines) {
64
+ if (!inDict) {
65
+ const m2 = /^(\s*)character_dict:\s*$/.exec(line);
66
+ if (m2) {
67
+ inDict = true;
68
+ dictIndent = m2[1].length;
69
+ }
70
+ continue;
71
+ }
72
+ const m = /^(\s*)- (.*)$/.exec(line);
73
+ if (m && m[1].length >= dictIndent) {
74
+ let v = m[2];
75
+ if (v.length >= 2 && (v.startsWith("'") && v.endsWith("'") || v.startsWith('"') && v.endsWith('"'))) {
76
+ v = v.slice(1, -1).replace(/''/g, "'");
77
+ }
78
+ chars.push(v);
79
+ continue;
80
+ }
81
+ if (line.trim() !== "") break;
82
+ }
83
+ return chars;
84
+ }
11
85
 
12
86
  // src/pdf/line-extract.ts
13
87
  import { OPS } from "pdfjs-dist/legacy/build/pdf.mjs";
@@ -1854,6 +1928,60 @@ function hasHorizontalLine(horizontals, y, leftX, rightX, vertexRadius) {
1854
1928
  return false;
1855
1929
  }
1856
1930
 
1931
+ // src/pdf/script-items.ts
1932
+ function scriptKindsOfLine(sorted) {
1933
+ const kinds = sorted.map(() => null);
1934
+ if (sorted.length < 2) return kinds;
1935
+ const weight = /* @__PURE__ */ new Map();
1936
+ for (const it of sorted) {
1937
+ const k = Math.round(it.fontSize * 2) / 2;
1938
+ weight.set(k, (weight.get(k) ?? 0) + it.text.trim().length);
1939
+ }
1940
+ let bodyFs = 0, best = -1;
1941
+ for (const [fs, n] of weight) if (n > best || n === best && fs > bodyFs) {
1942
+ best = n;
1943
+ bodyFs = fs;
1944
+ }
1945
+ if (bodyFs <= 0) return kinds;
1946
+ const ys = sorted.filter((it) => Math.abs(it.fontSize - bodyFs) <= bodyFs * 0.12).map((it) => it.y).sort((a, b) => a - b);
1947
+ const bodyY = ys[ys.length >> 1];
1948
+ const isBody = (it) => it.fontSize > bodyFs * 0.85;
1949
+ for (let i = 1; i < sorted.length; i++) {
1950
+ const it = sorted[i], prev = sorted[i - 1];
1951
+ const t = it.text.trim();
1952
+ if (!t || t.length > 16 || isBody(it)) continue;
1953
+ if (!isBody(prev) && !kinds[i - 1]) continue;
1954
+ const gap = it.x - (prev.x + prev.w);
1955
+ if (gap > bodyFs * 0.35 || gap < -bodyFs * 0.5) continue;
1956
+ const dy = it.y - bodyY;
1957
+ if (dy >= bodyFs * 0.15) kinds[i] = "sup";
1958
+ else if (dy <= -bodyFs * 0.08) kinds[i] = "sub";
1959
+ }
1960
+ return kinds;
1961
+ }
1962
+ function tagScripts(text, lines) {
1963
+ const marks = [];
1964
+ let cursor = 0;
1965
+ for (const line of lines) {
1966
+ const kinds = scriptKindsOfLine(line);
1967
+ for (let k = 0; k < line.length; k++) {
1968
+ const t = line[k].text;
1969
+ if (!t) continue;
1970
+ const at = text.indexOf(t, cursor);
1971
+ if (at < 0 || /\S/.test(text.slice(cursor, at))) return text;
1972
+ if (kinds[k]) marks.push([at, at + t.length, kinds[k]]);
1973
+ cursor = at + t.length;
1974
+ }
1975
+ }
1976
+ if (!marks.length) return text;
1977
+ let out = text;
1978
+ for (let m = marks.length - 1; m >= 0; m--) {
1979
+ const [s, e, kind] = marks[m];
1980
+ out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
1981
+ }
1982
+ return tidyScriptTags(out);
1983
+ }
1984
+
1857
1985
  // src/pdf/line-wrap.ts
1858
1986
  var MARKUP = /<\/?u>|~~/g;
1859
1987
  var bump = (m, k) => {
@@ -2185,7 +2313,8 @@ function cellTextToString(items, wrap) {
2185
2313
  }
2186
2314
  return result;
2187
2315
  });
2188
- if (!wrap) return mergeCellTextLines(textLines);
2316
+ const scripted = (s) => tagScripts(s, merged.map((l) => sortLineByX([...l])));
2317
+ if (!wrap) return scripted(mergeCellTextLines(textLines));
2189
2318
  let contentLeft = Infinity;
2190
2319
  for (const it of items) if (it.x < contentLeft) contentLeft = it.x;
2191
2320
  const lineEnds = merged.map((line) => {
@@ -2198,7 +2327,7 @@ function cellTextToString(items, wrap) {
2198
2327
  let cellRight = -Infinity;
2199
2328
  for (const e of lineEnds) if (e.right > cellRight) cellRight = e.right;
2200
2329
  const wraps = lineEnds.slice(0, -1).map((a, i) => cellLineWraps(wrap.box, contentLeft, a.right, a.fontSize, lineEnds[i + 1].firstCharW) || lineEnds.length >= 3 && !textLines[i + 1].startsWith("(") && cellLineFills(wrap.box, contentLeft, cellRight, a.right, a.fontSize));
2201
- return mergeCellTextLines(textLines, { wraps, lex: wrap.lex });
2330
+ return scripted(mergeCellTextLines(textLines, { wraps, lex: wrap.lex }));
2202
2331
  }
2203
2332
  function mergeSuperscriptRows(lines) {
2204
2333
  if (lines.length <= 1) return lines;
@@ -2749,6 +2878,13 @@ function mergeSuperscriptLines(lines) {
2749
2878
  for (const i of line) total += i.text.trim().length;
2750
2879
  return total > 0 && total <= 10;
2751
2880
  };
2881
+ const isMarkers = (line, host) => line.length > 1 && line.length <= 16 && line.every((i) => {
2882
+ if (i.text.trim().length > 3 || !i.text.trim()) return false;
2883
+ return host.some((h) => {
2884
+ const g = i.x - (h.x + h.w);
2885
+ return g <= h.fontSize * 0.35 && g >= -h.fontSize * 0.1;
2886
+ });
2887
+ });
2752
2888
  const result = [lines[0]];
2753
2889
  for (let i = 1; i < lines.length; i++) {
2754
2890
  const prev = result[result.length - 1];
@@ -2756,8 +2892,8 @@ function mergeSuperscriptLines(lines) {
2756
2892
  const a = band(prev);
2757
2893
  const b = band(curr);
2758
2894
  const overlap2 = Math.min(a.top, b.top) - Math.max(a.bottom, b.bottom);
2759
- const prevIsFrag = isFrag(prev) && a.height <= b.height * 0.8 && overlap2 >= a.height * 0.5;
2760
- const currIsFrag = isFrag(curr) && b.height <= a.height * 0.8 && overlap2 >= b.height * 0.5;
2895
+ const prevIsFrag = (isFrag(prev) || isMarkers(prev, curr)) && a.height <= b.height * 0.8 && overlap2 >= a.height * 0.5;
2896
+ const currIsFrag = (isFrag(curr) || isMarkers(curr, prev)) && b.height <= a.height * 0.8 && overlap2 >= b.height * 0.5;
2761
2897
  if (prevIsFrag || currIsFrag) {
2762
2898
  result[result.length - 1] = [...prev, ...curr];
2763
2899
  } else {
@@ -2955,10 +3091,13 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
2955
3091
  for (let i = 0; i < lines.length; ) {
2956
3092
  let text = lines[i].text;
2957
3093
  const items = [...lines[i].items];
3094
+ const srcLines = [lines[i].items];
2958
3095
  for (; i + 1 < lines.length && joins[i] !== "\n"; i++) {
2959
3096
  text += joins[i] + lines[i + 1].text;
2960
3097
  items.push(...lines[i + 1].items);
3098
+ srcLines.push(lines[i + 1].items);
2961
3099
  }
3100
+ text = tagScripts(text, srcLines.map((l) => sortLineByX([...l])));
2962
3101
  const block = { type: "paragraph", text, pageNumber: pageNum, bbox: computeBBox(items, pageNum), style: dominantStyle(items) };
2963
3102
  const faces = /* @__PURE__ */ new Map();
2964
3103
  for (const it of items) faces.set(it.fontName, (faces.get(it.fontName) ?? 0) + it.text.length);
@@ -5820,17 +5959,23 @@ function splitTwoColumnProse(items, cutX) {
5820
5959
  if (last && Math.abs(last[0].y - c.y) <= 3) last.push(c);
5821
5960
  else crossLines.push([c]);
5822
5961
  }
5823
- const bandItem = (arr) => arr.filter((i) => {
5962
+ const scriptOf = (i, cl) => {
5963
+ const fs = cl[0].fontSize, dy = i.y - cl[0].y;
5964
+ if (i.fontSize > fs * 0.85 || dy > fs * 0.6 || dy < -fs * 0.35) return false;
5965
+ return cl.some((c) => c !== i && c.fontSize > fs * 0.85 && i.x - (c.x + c.w) <= fs * 0.35 && i.x - (c.x + c.w) >= -fs * 0.1);
5966
+ };
5967
+ const bandItem = (arr, fits) => arr.filter((i) => {
5824
5968
  for (const cl of crossLines) {
5825
- if (Math.abs(cl[0].y - i.y) <= 3) {
5969
+ if (fits(i, cl)) {
5826
5970
  cl.push(i);
5827
5971
  return false;
5828
5972
  }
5829
5973
  }
5830
5974
  return true;
5831
5975
  });
5832
- const leftRest = bandItem(left);
5833
- const rightRest = bandItem(right);
5976
+ const sameY = (i, cl) => Math.abs(cl[0].y - i.y) <= 3;
5977
+ const leftRest = bandItem(bandItem(left, sameY), scriptOf);
5978
+ const rightRest = bandItem(bandItem(right, sameY), scriptOf);
5834
5979
  const boundYs = crossLines.map((cl) => cl[0].y);
5835
5980
  const bandOf = (y) => {
5836
5981
  let k = 0;
@@ -5842,7 +5987,7 @@ function splitTwoColumnProse(items, cutX) {
5842
5987
  const L = leftRest.filter((i) => bandOf(i.y) === k);
5843
5988
  const R = rightRest.filter((i) => bandOf(i.y) === k);
5844
5989
  groups.push(...columnPair(L, R));
5845
- if (k < crossLines.length) groups.push(crossLines[k]);
5990
+ if (k < crossLines.length) groups.push(crossLines[k].sort((a, b) => b.y - a.y || a.x - b.x));
5846
5991
  }
5847
5992
  return groups;
5848
5993
  }
@@ -6973,6 +7118,13 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
6973
7118
  }
6974
7119
 
6975
7120
  export {
7121
+ OCR_DET_MODEL,
7122
+ OCR_REC_MODEL,
7123
+ OCR_REC_DICT,
7124
+ getOcrModelsDir,
7125
+ ensureOcrModels,
7126
+ ocrModelsCached,
7127
+ parseCharacterDict,
6976
7128
  extractLines,
6977
7129
  extractImageRegions,
6978
7130
  filterHiddenText,
@@ -7007,4 +7159,4 @@ export {
7007
7159
  trimTrailingEmptyTableCols,
7008
7160
  extractPageBlocksWithLines
7009
7161
  };
7010
- //# sourceMappingURL=chunk-7FKPPIDZ.js.map
7162
+ //# sourceMappingURL=chunk-46H2PPG7.js.map