kordoc 4.22.1 → 4.22.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.
- package/README.md +12 -5
- package/dist/{-FYKHW5G6.js → -AOWV7MNY.js} +11 -11
- package/dist/{chunk-QH4B3PL7.js → chunk-24YLYR6Q.js} +4 -4
- package/dist/{chunk-OSFB5SQS.cjs → chunk-2BCQVQO2.cjs} +3 -3
- package/dist/{chunk-OSFB5SQS.cjs.map → chunk-2BCQVQO2.cjs.map} +1 -1
- package/dist/{chunk-5VBAHUGC.js → chunk-3ANXRVI2.js} +3 -3
- package/dist/{chunk-IB5TO2CO.js → chunk-3H2IEU4V.js} +2 -2
- package/dist/{chunk-MDS3GH43.js → chunk-4NQ4EZEE.js} +14 -4
- package/dist/chunk-4NQ4EZEE.js.map +1 -0
- package/dist/{chunk-7FASIFQP.js → chunk-6LIBF2ZB.js} +2 -2
- package/dist/{chunk-5SVJU22Z.js → chunk-6QBBGZST.js} +2 -2
- package/dist/{chunk-YE4IN3D7.js → chunk-7XITVUAK.js} +11 -11
- package/dist/{chunk-M4JC7TXG.js → chunk-AXX5AQT4.js} +4 -4
- package/dist/{chunk-AIAIBNIB.js → chunk-BS2XWGT5.js} +2 -2
- package/dist/{chunk-TSZQ4LMV.js → chunk-DKJ2RNDG.js} +2 -2
- package/dist/{chunk-7RND4SNB.js → chunk-FDFXL7VJ.js} +3 -3
- package/dist/{chunk-3SPOIAST.js → chunk-IRNWAHHZ.js} +2 -2
- package/dist/{chunk-SMPK5TUQ.js → chunk-J5PYESLX.js} +14 -4
- package/dist/chunk-J5PYESLX.js.map +1 -0
- package/dist/{chunk-5FD3LAKC.js → chunk-KBGNPGVY.js} +2 -2
- package/dist/{chunk-DOBJ7BW5.js → chunk-M2X766AY.js} +2 -2
- package/dist/{chunk-ME4NQSLE.js → chunk-MEIQ476H.js} +2 -2
- package/dist/{chunk-M2CBEXHN.cjs → chunk-MI655NV5.cjs} +2 -2
- package/dist/{chunk-M2CBEXHN.cjs.map → chunk-MI655NV5.cjs.map} +1 -1
- package/dist/{chunk-EXVTF6XE.cjs → chunk-NJEMRAIF.cjs} +24 -24
- package/dist/{chunk-EXVTF6XE.cjs.map → chunk-NJEMRAIF.cjs.map} +1 -1
- package/dist/{chunk-ZECSXHYP.cjs → chunk-NLGOMLGU.cjs} +188 -166
- package/dist/{chunk-ZECSXHYP.cjs.map → chunk-NLGOMLGU.cjs.map} +1 -1
- package/dist/{chunk-B35C5HJK.cjs → chunk-O3OS6FAW.cjs} +3 -3
- package/dist/{chunk-B35C5HJK.cjs.map → chunk-O3OS6FAW.cjs.map} +1 -1
- package/dist/{chunk-3H5QG6I2.js → chunk-O5E25RHU.js} +2 -2
- package/dist/{chunk-MGJYVNDX.js → chunk-OIF5HRVP.js} +29 -7
- package/dist/{chunk-JHHXTNZQ.js.map → chunk-OIF5HRVP.js.map} +1 -1
- package/dist/{chunk-RO7AORMO.cjs → chunk-SJ5OZXEL.cjs} +23 -13
- package/dist/chunk-SJ5OZXEL.cjs.map +1 -0
- package/dist/{chunk-JHHXTNZQ.js → chunk-SKRWKVVW.js} +28 -6
- package/dist/chunk-SKRWKVVW.js.map +1 -0
- package/dist/{chunk-LHO7E3RW.js → chunk-UCLDUUBX.js} +2 -2
- package/dist/{chunk-IK4W2M4P.js → chunk-VJCQOSMT.js} +2 -2
- package/dist/{chunk-ATODI25J.js → chunk-X45Q7EAC.js} +2 -2
- package/dist/{chunk-R37TFXMP.js → chunk-YOGMCRM7.js} +108 -29
- package/dist/chunk-YOGMCRM7.js.map +1 -0
- package/dist/chunks-7KXTS7IV.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-PYDSQGLS.cjs → formula-5V2WG4BH.cjs} +9 -9
- package/dist/{formula-PYDSQGLS.cjs.map → formula-5V2WG4BH.cjs.map} +1 -1
- package/dist/{formula-RUS4SF3O.js → formula-C26FMMGO.js} +3 -3
- package/dist/{formula-JBTYYSKB.js → formula-W4OL33YQ.js} +4 -4
- package/dist/{image-ocr-PLNNCEOR.cjs → image-ocr-BELHEWPX.cjs} +17 -17
- package/dist/{image-ocr-PLNNCEOR.cjs.map → image-ocr-BELHEWPX.cjs.map} +1 -1
- package/dist/{image-ocr-QJT4EIQU.js → image-ocr-NSQ34Y6T.js} +9 -9
- package/dist/{image-ocr-VA6WV6E4.js → image-ocr-T72HMX2W.js} +6 -6
- package/dist/index.cjs +507 -428
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -29
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-U2YY7ATC.js → model-bundle-34T2LJB4.js} +5 -5
- package/dist/{models-BOJ2SFCR.js → models-TQH5EM6V.js} +5 -5
- package/dist/{parse-worker-v2-ZHMFK3U3.js → parse-worker-v2-YEYLILGJ.js} +12 -12
- package/dist/{parser-A2EWLK2J.js → parser-E6BG3ECD.js} +133 -27
- package/dist/parser-E6BG3ECD.js.map +1 -0
- package/dist/{parser-6337Z4U2.cjs → parser-OAXCXVQ4.cjs} +383 -277
- package/dist/parser-OAXCXVQ4.cjs.map +1 -0
- package/dist/{parser-HM6N7J4R.js → parser-SJHCBL7T.js} +136 -30
- package/dist/parser-SJHCBL7T.js.map +1 -0
- package/dist/{pdf-ocr-JDER5BHI.js → pdf-ocr-LGPSJM22.js} +6 -6
- package/dist/pdf-ocr-RKXDY3ZA.cjs +31 -0
- package/dist/{pdf-ocr-PGXNUFU7.cjs.map → pdf-ocr-RKXDY3ZA.cjs.map} +1 -1
- package/dist/{pdf-ocr-MEVC6HXG.js → pdf-ocr-T5ASSUKK.js} +9 -9
- package/dist/{profile-io-OJ23SPYO.js → profile-io-KMCAFTMG.js} +3 -3
- package/dist/{rasterize-76CWCLSU.js → rasterize-M52AKY7R.js} +3 -3
- package/dist/{redact-doc-EZQIHRVT.js → redact-doc-SWJC27LL.js} +11 -11
- package/dist/{render-JZFJPFWK.js → render-45AB5YZR.js} +7 -7
- package/dist/seal-7KWG6VHS.js +10 -0
- package/dist/{setup-RIVS74JN.js → setup-5PBMUI6M.js} +3 -3
- package/dist/visual-OMJNXLNZ.js +21 -0
- package/dist/{watch-WMH222E5.js → watch-QOGKV52T.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-MDS3GH43.js.map +0 -1
- package/dist/chunk-MGJYVNDX.js.map +0 -1
- package/dist/chunk-R37TFXMP.js.map +0 -1
- package/dist/chunk-RO7AORMO.cjs.map +0 -1
- package/dist/chunk-SMPK5TUQ.js.map +0 -1
- package/dist/chunks-4XIAEJEX.js +0 -10
- package/dist/parser-6337Z4U2.cjs.map +0 -1
- package/dist/parser-A2EWLK2J.js.map +0 -1
- package/dist/parser-HM6N7J4R.js.map +0 -1
- package/dist/pdf-ocr-PGXNUFU7.cjs +0 -31
- package/dist/seal-P2NOP4LC.js +0 -10
- package/dist/visual-R5GGZBTU.js +0 -21
- /package/dist/{-FYKHW5G6.js.map → -AOWV7MNY.js.map} +0 -0
- /package/dist/{chunk-QH4B3PL7.js.map → chunk-24YLYR6Q.js.map} +0 -0
- /package/dist/{chunk-5VBAHUGC.js.map → chunk-3ANXRVI2.js.map} +0 -0
- /package/dist/{chunk-IB5TO2CO.js.map → chunk-3H2IEU4V.js.map} +0 -0
- /package/dist/{chunk-7FASIFQP.js.map → chunk-6LIBF2ZB.js.map} +0 -0
- /package/dist/{chunk-5SVJU22Z.js.map → chunk-6QBBGZST.js.map} +0 -0
- /package/dist/{chunk-YE4IN3D7.js.map → chunk-7XITVUAK.js.map} +0 -0
- /package/dist/{chunk-M4JC7TXG.js.map → chunk-AXX5AQT4.js.map} +0 -0
- /package/dist/{chunk-AIAIBNIB.js.map → chunk-BS2XWGT5.js.map} +0 -0
- /package/dist/{chunk-TSZQ4LMV.js.map → chunk-DKJ2RNDG.js.map} +0 -0
- /package/dist/{chunk-7RND4SNB.js.map → chunk-FDFXL7VJ.js.map} +0 -0
- /package/dist/{chunk-3SPOIAST.js.map → chunk-IRNWAHHZ.js.map} +0 -0
- /package/dist/{chunk-5FD3LAKC.js.map → chunk-KBGNPGVY.js.map} +0 -0
- /package/dist/{chunk-DOBJ7BW5.js.map → chunk-M2X766AY.js.map} +0 -0
- /package/dist/{chunk-ME4NQSLE.js.map → chunk-MEIQ476H.js.map} +0 -0
- /package/dist/{chunk-3H5QG6I2.js.map → chunk-O5E25RHU.js.map} +0 -0
- /package/dist/{chunk-LHO7E3RW.js.map → chunk-UCLDUUBX.js.map} +0 -0
- /package/dist/{chunk-IK4W2M4P.js.map → chunk-VJCQOSMT.js.map} +0 -0
- /package/dist/{chunk-ATODI25J.js.map → chunk-X45Q7EAC.js.map} +0 -0
- /package/dist/{chunks-4XIAEJEX.js.map → chunks-7KXTS7IV.js.map} +0 -0
- /package/dist/{formula-RUS4SF3O.js.map → formula-C26FMMGO.js.map} +0 -0
- /package/dist/{formula-JBTYYSKB.js.map → formula-W4OL33YQ.js.map} +0 -0
- /package/dist/{image-ocr-QJT4EIQU.js.map → image-ocr-NSQ34Y6T.js.map} +0 -0
- /package/dist/{image-ocr-VA6WV6E4.js.map → image-ocr-T72HMX2W.js.map} +0 -0
- /package/dist/{model-bundle-U2YY7ATC.js.map → model-bundle-34T2LJB4.js.map} +0 -0
- /package/dist/{models-BOJ2SFCR.js.map → models-TQH5EM6V.js.map} +0 -0
- /package/dist/{parse-worker-v2-ZHMFK3U3.js.map → parse-worker-v2-YEYLILGJ.js.map} +0 -0
- /package/dist/{pdf-ocr-JDER5BHI.js.map → pdf-ocr-LGPSJM22.js.map} +0 -0
- /package/dist/{pdf-ocr-MEVC6HXG.js.map → pdf-ocr-T5ASSUKK.js.map} +0 -0
- /package/dist/{profile-io-OJ23SPYO.js.map → profile-io-KMCAFTMG.js.map} +0 -0
- /package/dist/{rasterize-76CWCLSU.js.map → rasterize-M52AKY7R.js.map} +0 -0
- /package/dist/{redact-doc-EZQIHRVT.js.map → redact-doc-SWJC27LL.js.map} +0 -0
- /package/dist/{render-JZFJPFWK.js.map → render-45AB5YZR.js.map} +0 -0
- /package/dist/{seal-P2NOP4LC.js.map → seal-7KWG6VHS.js.map} +0 -0
- /package/dist/{setup-RIVS74JN.js.map → setup-5PBMUI6M.js.map} +0 -0
- /package/dist/{visual-R5GGZBTU.js.map → visual-OMJNXLNZ.js.map} +0 -0
- /package/dist/{watch-WMH222E5.js.map → watch-QOGKV52T.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
blocksToPages
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KBGNPGVY.js";
|
|
5
5
|
import {
|
|
6
6
|
encodePng
|
|
7
7
|
} from "./chunk-VKVDMH7X.js";
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
stripAbsorbedRunningLines,
|
|
63
63
|
trimTrailingEmptyTableCols,
|
|
64
64
|
wrapJoiner
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-SKRWKVVW.js";
|
|
66
66
|
import {
|
|
67
67
|
validateOcrOptions
|
|
68
68
|
} from "./chunk-BHVOY6V4.js";
|
|
@@ -74,23 +74,23 @@ import {
|
|
|
74
74
|
escapeLiteralTags,
|
|
75
75
|
stripScriptTags,
|
|
76
76
|
unframeLayoutTables
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-4NQ4EZEE.js";
|
|
78
78
|
import {
|
|
79
79
|
WINGDINGS,
|
|
80
80
|
assignTableIds,
|
|
81
81
|
blocksToMarkdown,
|
|
82
82
|
escapeLiteralDollar
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-BS2XWGT5.js";
|
|
84
84
|
import {
|
|
85
85
|
ocrModelsCached,
|
|
86
86
|
resolveOcrModels
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import "./chunk-
|
|
89
|
-
import "./chunk-
|
|
87
|
+
} from "./chunk-VJCQOSMT.js";
|
|
88
|
+
import "./chunk-M2X766AY.js";
|
|
89
|
+
import "./chunk-3H2IEU4V.js";
|
|
90
90
|
import {
|
|
91
91
|
KordocError,
|
|
92
92
|
sanitizeHref
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-DKJ2RNDG.js";
|
|
94
94
|
|
|
95
95
|
// src/pdf/image-extract.ts
|
|
96
96
|
import { createHash } from "crypto";
|
|
@@ -621,6 +621,61 @@ function ocrVectorOps(opList, paths) {
|
|
|
621
621
|
// src/pdf/split-row-pattern.ts
|
|
622
622
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
623
623
|
var plain = (cell) => !cell.blocks?.length && !IMAGE_CELLS.has(cell);
|
|
624
|
+
function matchesIndependentRowPair(table, owner, first) {
|
|
625
|
+
const norm = (cell) => textOf(cell).replace(/\s+/g, "");
|
|
626
|
+
const pairs = [];
|
|
627
|
+
for (let c = 0; c < table.cols; ) {
|
|
628
|
+
const u = owner[first - 1]?.[c], d = owner[first]?.[c];
|
|
629
|
+
if (u && u === d) {
|
|
630
|
+
c = u.c + u.cs;
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
634
|
+
if (!upper?.text.trim() && !lower?.text.trim()) {
|
|
635
|
+
c++;
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !norm(upper) || !norm(lower)) return false;
|
|
639
|
+
pairs.push({ c, cs: u.cs, upper: norm(upper), lower: norm(lower) });
|
|
640
|
+
c += u.cs;
|
|
641
|
+
}
|
|
642
|
+
if (pairs.length < 2 || pairs.every((p) => p.upper === p.lower)) return false;
|
|
643
|
+
return table.cells.some((_, r) => {
|
|
644
|
+
if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
|
|
645
|
+
return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
|
|
646
|
+
const a = owner[r + i]?.[p.c], cell = table.cells[r + i]?.[p.c];
|
|
647
|
+
return a?.r === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
|
|
648
|
+
}));
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
function matchesCompleteContextRow(table, owner, first) {
|
|
652
|
+
const norm = (s) => s.replace(/\s+/g, "");
|
|
653
|
+
const context = [];
|
|
654
|
+
let value;
|
|
655
|
+
for (let c = 0; c < table.cols; ) {
|
|
656
|
+
const u = owner[first - 1]?.[c], d = owner[first]?.[c];
|
|
657
|
+
if (u && u === d) {
|
|
658
|
+
const cell = table.cells[u.r][u.c];
|
|
659
|
+
if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
|
|
660
|
+
c = u.c + u.cs;
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
664
|
+
if (!upper?.text.trim() && !lower?.text.trim()) {
|
|
665
|
+
c++;
|
|
666
|
+
continue;
|
|
667
|
+
}
|
|
668
|
+
if (value || !u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !textOf(upper) || !textOf(lower)) return false;
|
|
669
|
+
value = { c, cs: u.cs, text: norm(textOf(upper) + textOf(lower)) };
|
|
670
|
+
c += u.cs;
|
|
671
|
+
}
|
|
672
|
+
if (!value || !context.length) return false;
|
|
673
|
+
const proof = [...context, value];
|
|
674
|
+
return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
|
|
675
|
+
const a = owner[r]?.[p.c], cell = row[p.c];
|
|
676
|
+
return a?.r === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
|
|
677
|
+
}));
|
|
678
|
+
}
|
|
624
679
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
625
680
|
const pairs = [];
|
|
626
681
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -686,6 +741,41 @@ function matchesCompleteRubricRow(table, owner, first) {
|
|
|
686
741
|
return peerMarks.length === marks.length && peerMarks.every((m, i) => m.n === marks[i].n) && values(row[score.c]).join("|") === scores.join("|") && norm(peer.slice(peerMarks[peerMarks.length - 1].at)) === tail;
|
|
687
742
|
});
|
|
688
743
|
}
|
|
744
|
+
var KO_ORDER = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558";
|
|
745
|
+
function itemMark(line) {
|
|
746
|
+
line = line.replace(/<\/?u>|~~/g, "").trim();
|
|
747
|
+
let m = /^(\d{1,2})([.)])(?!\d)/.exec(line);
|
|
748
|
+
if (m) return { style: "1" + m[2], n: +m[1] };
|
|
749
|
+
if (m = /^\((\d{1,2})\)/.exec(line)) return { style: "(1)", n: +m[1] };
|
|
750
|
+
if ((m = /^([가-하])([.)])/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "\uAC00" + m[2], n: KO_ORDER.indexOf(m[1]) };
|
|
751
|
+
if ((m = /^\(([가-하])\)/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "(\uAC00)", n: KO_ORDER.indexOf(m[1]) };
|
|
752
|
+
if (m = /^[①-⑳]/.exec(line)) return { style: "\u2460", n: m[0].charCodeAt(0) };
|
|
753
|
+
if (m = /^([A-Z])\.\s/.exec(line)) return { style: "A.", n: m[1].charCodeAt(0) };
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
function hasNumberedRowSequence(table, owner, first) {
|
|
757
|
+
if (first < 3) return false;
|
|
758
|
+
const rows = [first - 3, first - 2, first - 1, first];
|
|
759
|
+
const separate = (c, cs) => rows.every((r) => {
|
|
760
|
+
const a = owner[r]?.[c], cell = table.cells[r]?.[c];
|
|
761
|
+
return a?.r === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
|
|
762
|
+
});
|
|
763
|
+
for (let c = 0; c < table.cols; c++) {
|
|
764
|
+
const a = owner[first]?.[c];
|
|
765
|
+
if (!a || !separate(c, a.cs)) continue;
|
|
766
|
+
const marks = rows.map((r) => {
|
|
767
|
+
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
768
|
+
return firstMark && lines.slice(1).every((l) => !itemMark(l)) ? firstMark : null;
|
|
769
|
+
});
|
|
770
|
+
const head = marks[0];
|
|
771
|
+
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
772
|
+
for (let d = 0; d < table.cols; d++) {
|
|
773
|
+
const side = owner[first]?.[d];
|
|
774
|
+
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return false;
|
|
778
|
+
}
|
|
689
779
|
|
|
690
780
|
// src/pdf/contact-table.ts
|
|
691
781
|
var CONTACT_HEAD = /^(?:담당\s*부서|<[^<>]+>)$/;
|
|
@@ -704,8 +794,25 @@ function splitContactTables(blocks) {
|
|
|
704
794
|
const whole = PERSON.exec(r[3].text.replace(/\s+/g, " ").trim());
|
|
705
795
|
return whole ? [whole] : null;
|
|
706
796
|
});
|
|
707
|
-
if (people.some((p) => !p) || rows.some((r) =>
|
|
797
|
+
if (people.some((p) => !p) || rows.some((r) => r[3].rowSpan !== 1 || r[3].colSpan !== 1)) continue;
|
|
798
|
+
let roleEnd = 0;
|
|
799
|
+
const validRoles = rows.every((r, i) => {
|
|
800
|
+
const role = r[2];
|
|
801
|
+
if (role.colSpan !== 1) return false;
|
|
802
|
+
if (i < roleEnd) return !role.text.trim() && role.rowSpan === 1;
|
|
803
|
+
if (!CONTACT_ROLE.test(role.text.replace(/\s+/g, "")) || role.rowSpan < 1 || i + role.rowSpan > t.rows) return false;
|
|
804
|
+
roleEnd = i + role.rowSpan;
|
|
805
|
+
return true;
|
|
806
|
+
});
|
|
807
|
+
if (!validRoles) continue;
|
|
708
808
|
if (!people.some((p) => p.some(spaced))) continue;
|
|
809
|
+
const one = (text) => ({ text, colSpan: 1, rowSpan: 1 });
|
|
810
|
+
const part = (i, k) => one(people[i].map((p) => p[k]).join("\n"));
|
|
811
|
+
if (rows.some((r) => r[2].rowSpan > 1)) {
|
|
812
|
+
t.cells = rows.map((r, i) => [...r.slice(0, 3), part(i, 1), part(i, 2), part(i, 3)]);
|
|
813
|
+
t.cols = 6;
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
709
816
|
const lead = [];
|
|
710
817
|
let ok = true;
|
|
711
818
|
for (const c of [0, 1]) {
|
|
@@ -726,8 +833,6 @@ function splitContactTables(blocks) {
|
|
|
726
833
|
lead.push(col);
|
|
727
834
|
}
|
|
728
835
|
if (!ok) continue;
|
|
729
|
-
const one = (text) => ({ text, colSpan: 1, rowSpan: 1 });
|
|
730
|
-
const part = (i, k) => one(people[i].map((p) => p[k]).join("\n"));
|
|
731
836
|
t.cells = rows.map((r, i) => [one(lead[0][i]), one(lead[1][i]), one(r[2].text), part(i, 1), part(i, 2), part(i, 3)]);
|
|
732
837
|
t.cols = 6;
|
|
733
838
|
}
|
|
@@ -1240,18 +1345,6 @@ function wordOverflows(u, d, x1, x2) {
|
|
|
1240
1345
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1241
1346
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1242
1347
|
}
|
|
1243
|
-
var KO_ORDER = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558";
|
|
1244
|
-
function itemMark(line) {
|
|
1245
|
-
line = flowText(line).trim();
|
|
1246
|
-
let m = /^(\d{1,2})([.)])(?!\d)/.exec(line);
|
|
1247
|
-
if (m) return { style: "1" + m[2], n: +m[1] };
|
|
1248
|
-
if (m = /^\((\d{1,2})\)/.exec(line)) return { style: "(1)", n: +m[1] };
|
|
1249
|
-
if ((m = /^([가-하])([.)])/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "\uAC00" + m[2], n: KO_ORDER.indexOf(m[1]) };
|
|
1250
|
-
if ((m = /^\(([가-하])\)/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "(\uAC00)", n: KO_ORDER.indexOf(m[1]) };
|
|
1251
|
-
if (m = /^[①-⑳]/.exec(line)) return { style: "\u2460", n: m[0].charCodeAt(0) };
|
|
1252
|
-
if (m = /^([A-Z])\.\s/.exec(line)) return { style: "A.", n: m[1].charCodeAt(0) };
|
|
1253
|
-
return null;
|
|
1254
|
-
}
|
|
1255
1348
|
function listContinues(u, d, multi = false) {
|
|
1256
1349
|
const head = itemMark(d.text.trim());
|
|
1257
1350
|
if (!head) return false;
|
|
@@ -1299,6 +1392,8 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1299
1392
|
const a = serial(cell(u)), b = serial(cell(d));
|
|
1300
1393
|
return a !== null && b === a + 1;
|
|
1301
1394
|
})) return false;
|
|
1395
|
+
if (cut.ruled && hasNumberedRowSequence(table, owner, first)) return false;
|
|
1396
|
+
if (cut.ruled && matchesIndependentRowPair(table, owner, first)) return false;
|
|
1302
1397
|
const contentPairs = pairs.filter(([u, d]) => hasContent(u.cell) && hasContent(d.cell));
|
|
1303
1398
|
const carriedSplit = !textOnly && carried && !newCell && (contentPairs.length <= 1 || contentPairs.every(([, d]) => d.rs > 1) || !cut.ruled && contentPairs.some(([u, d]) => wordOverflows(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs])));
|
|
1304
1399
|
if (!carriedSplit) {
|
|
@@ -1310,7 +1405,7 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1310
1405
|
if (!(cut.open && !newCell)) {
|
|
1311
1406
|
if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
|
|
1312
1407
|
const one = pairs.filter(([, d]) => d.rs === 1);
|
|
1313
|
-
if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
|
|
1408
|
+
if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !(cut.ruled && matchesCompleteContextRow(table, owner, first)) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
|
|
1314
1409
|
}
|
|
1315
1410
|
}
|
|
1316
1411
|
for (const [u, d] of pairs) {
|
|
@@ -1371,6 +1466,12 @@ function sameHeadShape(a, b) {
|
|
|
1371
1466
|
}
|
|
1372
1467
|
return tall;
|
|
1373
1468
|
}
|
|
1469
|
+
function hasBoxTitle(t) {
|
|
1470
|
+
const titles = t.cells[0]?.filter((c) => c.text.trim()) ?? [];
|
|
1471
|
+
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
1472
|
+
const body = t.cells[titles[0].rowSpan];
|
|
1473
|
+
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
1474
|
+
}
|
|
1374
1475
|
function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
1375
1476
|
mergeColumnFlow(blocks, pageHeights, lex);
|
|
1376
1477
|
for (let i = blocks.length - 2; i >= 0; i--) {
|
|
@@ -1384,6 +1485,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1384
1485
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1385
1486
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1386
1487
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
1488
|
+
if (hasBoxTitle(prev.table) && hasBoxTitle(curr.table) && !rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1387
1489
|
const joined = j === i + 1 || blocks.slice(i + 1, j).every((b) => besideOwn(b, prev, curr) || insideTable(b, prev) || insideTable(b, curr) || pageNumberBetween(b, prev, curr, pageHeights)) ? looksContinued(prev, curr, pageHeights) && !restartsTable(blocks, i, curr.table, pageHeights) ? joinClipParts(prev, curr, pageHeights, lex) ?? false : null : null;
|
|
1388
1490
|
if (joined) {
|
|
1389
1491
|
placeJoined(blocks, i, j, joined);
|
|
@@ -1691,7 +1793,10 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1691
1793
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1692
1794
|
const part = blocks[j];
|
|
1693
1795
|
const from = part.table ? CONT_PARTS.get(part.table) : void 0;
|
|
1694
|
-
if (!from || !part.table)
|
|
1796
|
+
if (!from || !part.table) {
|
|
1797
|
+
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1695
1800
|
let i = j - 1;
|
|
1696
1801
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
1697
1802
|
const prev = blocks[i];
|
|
@@ -1718,7 +1823,7 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1718
1823
|
if (cell.blocks) mergeCrossPageTables(cell.blocks, pageHeights);
|
|
1719
1824
|
}
|
|
1720
1825
|
}
|
|
1721
|
-
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1826
|
+
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1722
1827
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1723
1828
|
if (!prev?.table || !frame?.table || frame.table.rows !== 1 || frame.table.cols !== 1 || !CLIP_TABLES.has(frame.table)) return;
|
|
1724
1829
|
const inner = frame.table.cells[0]?.[0]?.blocks;
|
|
@@ -1728,6 +1833,7 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1728
1833
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1729
1834
|
const ph = pageHeights?.get(prev.pageNumber), nh = pageHeights?.get(next.pageNumber);
|
|
1730
1835
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
1836
|
+
if (splitOnly && (inner.length !== 1 || !joinSplitParts(prev.table, px, next.table, nx, 0, prev.bbox.y)?.split)) return;
|
|
1731
1837
|
blocks.splice(at, 1, ...inner);
|
|
1732
1838
|
}
|
|
1733
1839
|
function fillNestedContinuation(blocks, at) {
|
|
@@ -3327,7 +3433,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3327
3433
|
|
|
3328
3434
|
// src/pdf/formula-ocr.ts
|
|
3329
3435
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3330
|
-
const formulaMod = await import("./formula-
|
|
3436
|
+
const formulaMod = await import("./formula-W4OL33YQ.js");
|
|
3331
3437
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3332
3438
|
await ensureFormulaModels((p) => {
|
|
3333
3439
|
if (p.phase === "download" && p.total) {
|
|
@@ -3753,10 +3859,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3753
3859
|
}
|
|
3754
3860
|
if (targets.size > 0) {
|
|
3755
3861
|
try {
|
|
3756
|
-
const { runPdfOcr } = await import("./pdf-ocr-
|
|
3862
|
+
const { runPdfOcr } = await import("./pdf-ocr-T5ASSUKK.js");
|
|
3757
3863
|
const mode = typeof options?.ocr === "function" ? options.ocr : "builtin";
|
|
3758
3864
|
const regionPages = new Map([...ocrRegions].filter(([p]) => options?.ocr !== "force" && !isImageBased && !pageQuality.find((q) => q.page === p)?.needsOcr));
|
|
3759
|
-
const { builtinOcrConfig } = await import("./pdf-ocr-
|
|
3865
|
+
const { builtinOcrConfig } = await import("./pdf-ocr-T5ASSUKK.js");
|
|
3760
3866
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options?.onProgress, options?.tables !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
3761
3867
|
for (const obs of ocrPageBlocks.values()) stripScriptTags({ blocks: obs });
|
|
3762
3868
|
if (ocrPageBlocks.size > 0) {
|
|
@@ -4001,4 +4107,4 @@ export {
|
|
|
4001
4107
|
parsePdfDocument,
|
|
4002
4108
|
removeHeaderFooterBlocks
|
|
4003
4109
|
};
|
|
4004
|
-
//# sourceMappingURL=parser-
|
|
4110
|
+
//# sourceMappingURL=parser-SJHCBL7T.js.map
|