kordoc 4.16.1 → 4.16.2
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 -7
- package/dist/{-3DURLXSO.js → -4G6MA4X6.js} +11 -11
- package/dist/chunk-3IB7LBHC.js +57 -0
- package/dist/chunk-3IB7LBHC.js.map +1 -0
- package/dist/{chunk-EEVAPRPD.js → chunk-4VODJKFL.js} +3 -3
- package/dist/{chunk-NCXRSQNE.js → chunk-5KS5PWJR.js} +2 -2
- package/dist/chunk-62W7QCEX.cjs +57 -0
- package/dist/chunk-62W7QCEX.cjs.map +1 -0
- package/dist/{chunk-ANZTLTKU.js → chunk-7KNGSQU7.js} +4 -4
- package/dist/chunk-7KNGSQU7.js.map +1 -0
- package/dist/{chunk-63YGGAQW.js → chunk-AUWGDP4G.js} +2 -2
- package/dist/{chunk-2BZFKIRB.cjs → chunk-CEIATRDW.cjs} +3 -3
- package/dist/{chunk-2BZFKIRB.cjs.map → chunk-CEIATRDW.cjs.map} +1 -1
- package/dist/{chunk-BIHS4VWR.js → chunk-DES2LGFZ.js} +2 -2
- package/dist/{chunk-N65ZXWNQ.js → chunk-F4NRLLY4.js} +2 -2
- package/dist/{chunk-NV37CQFN.cjs → chunk-FKUDAIJI.cjs} +12 -12
- package/dist/{chunk-NV37CQFN.cjs.map → chunk-FKUDAIJI.cjs.map} +1 -1
- package/dist/{chunk-VCRBR72A.js → chunk-GO5IFOUF.js} +2 -2
- package/dist/{chunk-BTO7ZEE4.js → chunk-IQGIT2VX.js} +37 -7
- package/dist/chunk-IQGIT2VX.js.map +1 -0
- package/dist/chunk-J3IF6KGW.js +59 -0
- package/dist/chunk-J3IF6KGW.js.map +1 -0
- package/dist/{chunk-VNOQTDTE.js → chunk-JELRWAZC.js} +2 -2
- package/dist/{chunk-CXWWX6BQ.js → chunk-JFLAM3MM.js} +2 -2
- package/dist/{chunk-7XAGIPOX.js → chunk-KIOQ4N37.js} +2 -2
- package/dist/{chunk-UZHT3LBF.js → chunk-LEIAEWZ7.js} +4 -4
- package/dist/chunk-LEIAEWZ7.js.map +1 -0
- package/dist/{chunk-NUPXPKIQ.js → chunk-MLIS253L.js} +2 -2
- package/dist/{chunk-DJ2BBQ5P.js → chunk-OXLPVQYK.js} +3 -3
- package/dist/{chunk-3VLVNKJV.js → chunk-P6ZDXTV6.js} +2 -2
- package/dist/{chunk-OBRPYCIS.js → chunk-QOCS7W7R.js} +58 -23
- package/dist/chunk-QOCS7W7R.js.map +1 -0
- package/dist/{chunk-24N4IJ5I.js → chunk-S2PL227Q.js} +2 -2
- package/dist/{chunk-PVMROO3A.js → chunk-SFEQYKYJ.js} +86 -94
- package/dist/chunk-SFEQYKYJ.js.map +1 -0
- package/dist/{chunk-YRRBA4HW.cjs → chunk-STM3ORY7.cjs} +2 -2
- package/dist/{chunk-YRRBA4HW.cjs.map → chunk-STM3ORY7.cjs.map} +1 -1
- package/dist/{chunk-7FKPPIDZ.js → chunk-TXUKTOG2.js} +166 -14
- package/dist/chunk-TXUKTOG2.js.map +1 -0
- package/dist/{chunk-3WIQSM3Z.js → chunk-UTP2WCHS.js} +4 -4
- package/dist/{chunk-7IRHSRPU.cjs → chunk-WDQTFAXY.cjs} +97 -25
- package/dist/chunk-WDQTFAXY.cjs.map +1 -0
- package/dist/{chunk-D2QCXK2X.cjs → chunk-XTFN5WKS.cjs} +7 -7
- package/dist/chunk-XTFN5WKS.cjs.map +1 -0
- package/dist/chunks-NUNIKS2J.js +10 -0
- package/dist/cli.js +28 -27
- package/dist/cli.js.map +1 -1
- package/dist/{formula-IPLFHEBD.js → formula-EPKLPDU7.js} +3 -3
- package/dist/{formula-U4BTEZ6I.js → formula-NARUOXRX.js} +4 -4
- package/dist/{formula-TRTONZMA.cjs → formula-WIMV5TUX.cjs} +9 -9
- package/dist/{formula-TRTONZMA.cjs.map → formula-WIMV5TUX.cjs.map} +1 -1
- package/dist/{image-ocr-3IJ25PS4.js → image-ocr-3WJ4QH3T.js} +8 -8
- package/dist/{image-ocr-GTDG4SAJ.js → image-ocr-5BUJQ4TK.js} +6 -6
- package/dist/{image-ocr-THFLQ3DC.cjs → image-ocr-AXWXR6JV.cjs} +15 -15
- package/dist/{image-ocr-THFLQ3DC.cjs.map → image-ocr-AXWXR6JV.cjs.map} +1 -1
- package/dist/index.cjs +723 -659
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +82 -18
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +25 -23
- package/dist/mcp.js.map +1 -1
- package/dist/{model-bundle-PVWIAVEX.js → model-bundle-IMBW7D2Z.js} +5 -5
- package/dist/{models-VCRF3JMT.js → models-SY75IBOE.js} +5 -5
- package/dist/{parser-2CN2DIPV.cjs → parser-2LU4EVU3.cjs} +86 -83
- package/dist/parser-2LU4EVU3.cjs.map +1 -0
- package/dist/{parser-T4RITZDP.js → parser-N6476XAC.js} +15 -12
- package/dist/{parser-UEROAPYZ.js.map → parser-N6476XAC.js.map} +1 -1
- package/dist/{parser-UEROAPYZ.js → parser-ZQM3664Z.js} +12 -9
- package/dist/{parser-T4RITZDP.js.map → parser-ZQM3664Z.js.map} +1 -1
- package/dist/pdf-ocr-6DEE23IP.js +15 -0
- package/dist/pdf-ocr-GHEJVPX2.cjs +16 -0
- package/dist/{pdf-ocr-NARV2AQI.cjs.map → pdf-ocr-GHEJVPX2.cjs.map} +1 -1
- package/dist/pdf-ocr-MQTWODVU.js +18 -0
- package/dist/{profile-io-YD54CDXY.js → profile-io-GJPKCYPT.js} +3 -3
- package/dist/{rasterize-3THYOOUN.js → rasterize-UOALJQDS.js} +3 -3
- package/dist/{redact-doc-65L2YJN6.js → redact-doc-22SYW3KH.js} +11 -11
- package/dist/{render-YU7QJVZ7.js → render-MJ4H3R23.js} +7 -7
- package/dist/seal-XWMRUTI4.js +10 -0
- package/dist/{setup-CFHKXDY4.js → setup-2URYVUEO.js} +3 -3
- package/dist/visual-USPS4QRC.js +20 -0
- package/dist/{watch-D6FCAYKJ.js → watch-ALXZGTOB.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-7FKPPIDZ.js.map +0 -1
- package/dist/chunk-7IRHSRPU.cjs.map +0 -1
- package/dist/chunk-ANZTLTKU.js.map +0 -1
- package/dist/chunk-BTO7ZEE4.js.map +0 -1
- package/dist/chunk-D2QCXK2X.cjs.map +0 -1
- package/dist/chunk-DO74GYSM.cjs +0 -11
- package/dist/chunk-DO74GYSM.cjs.map +0 -1
- package/dist/chunk-KBAQLAEL.js +0 -11
- package/dist/chunk-KBAQLAEL.js.map +0 -1
- package/dist/chunk-OBRPYCIS.js.map +0 -1
- package/dist/chunk-PVMROO3A.js.map +0 -1
- package/dist/chunk-T77M2QP7.js +0 -13
- package/dist/chunk-T77M2QP7.js.map +0 -1
- package/dist/chunk-UZHT3LBF.js.map +0 -1
- package/dist/chunks-PYYQURNO.js +0 -10
- package/dist/parser-2CN2DIPV.cjs.map +0 -1
- package/dist/pdf-ocr-NARV2AQI.cjs +0 -16
- package/dist/pdf-ocr-SYLMM727.js +0 -18
- package/dist/pdf-ocr-YMQZDJBO.js +0 -15
- package/dist/seal-6CQGFTML.js +0 -10
- package/dist/visual-ED2H75Q5.js +0 -20
- /package/dist/{-3DURLXSO.js.map → -4G6MA4X6.js.map} +0 -0
- /package/dist/{chunk-EEVAPRPD.js.map → chunk-4VODJKFL.js.map} +0 -0
- /package/dist/{chunk-NCXRSQNE.js.map → chunk-5KS5PWJR.js.map} +0 -0
- /package/dist/{chunk-63YGGAQW.js.map → chunk-AUWGDP4G.js.map} +0 -0
- /package/dist/{chunk-BIHS4VWR.js.map → chunk-DES2LGFZ.js.map} +0 -0
- /package/dist/{chunk-N65ZXWNQ.js.map → chunk-F4NRLLY4.js.map} +0 -0
- /package/dist/{chunk-VCRBR72A.js.map → chunk-GO5IFOUF.js.map} +0 -0
- /package/dist/{chunk-VNOQTDTE.js.map → chunk-JELRWAZC.js.map} +0 -0
- /package/dist/{chunk-CXWWX6BQ.js.map → chunk-JFLAM3MM.js.map} +0 -0
- /package/dist/{chunk-7XAGIPOX.js.map → chunk-KIOQ4N37.js.map} +0 -0
- /package/dist/{chunk-NUPXPKIQ.js.map → chunk-MLIS253L.js.map} +0 -0
- /package/dist/{chunk-DJ2BBQ5P.js.map → chunk-OXLPVQYK.js.map} +0 -0
- /package/dist/{chunk-3VLVNKJV.js.map → chunk-P6ZDXTV6.js.map} +0 -0
- /package/dist/{chunk-24N4IJ5I.js.map → chunk-S2PL227Q.js.map} +0 -0
- /package/dist/{chunk-3WIQSM3Z.js.map → chunk-UTP2WCHS.js.map} +0 -0
- /package/dist/{chunks-PYYQURNO.js.map → chunks-NUNIKS2J.js.map} +0 -0
- /package/dist/{formula-IPLFHEBD.js.map → formula-EPKLPDU7.js.map} +0 -0
- /package/dist/{formula-U4BTEZ6I.js.map → formula-NARUOXRX.js.map} +0 -0
- /package/dist/{image-ocr-3IJ25PS4.js.map → image-ocr-3WJ4QH3T.js.map} +0 -0
- /package/dist/{image-ocr-GTDG4SAJ.js.map → image-ocr-5BUJQ4TK.js.map} +0 -0
- /package/dist/{model-bundle-PVWIAVEX.js.map → model-bundle-IMBW7D2Z.js.map} +0 -0
- /package/dist/{models-VCRF3JMT.js.map → models-SY75IBOE.js.map} +0 -0
- /package/dist/{pdf-ocr-SYLMM727.js.map → pdf-ocr-6DEE23IP.js.map} +0 -0
- /package/dist/{pdf-ocr-YMQZDJBO.js.map → pdf-ocr-MQTWODVU.js.map} +0 -0
- /package/dist/{profile-io-YD54CDXY.js.map → profile-io-GJPKCYPT.js.map} +0 -0
- /package/dist/{rasterize-3THYOOUN.js.map → rasterize-UOALJQDS.js.map} +0 -0
- /package/dist/{redact-doc-65L2YJN6.js.map → redact-doc-22SYW3KH.js.map} +0 -0
- /package/dist/{render-YU7QJVZ7.js.map → render-MJ4H3R23.js.map} +0 -0
- /package/dist/{seal-6CQGFTML.js.map → seal-XWMRUTI4.js.map} +0 -0
- /package/dist/{setup-CFHKXDY4.js.map → setup-2URYVUEO.js.map} +0 -0
- /package/dist/{visual-ED2H75Q5.js.map → visual-USPS4QRC.js.map} +0 -0
- /package/dist/{watch-D6FCAYKJ.js.map → watch-ALXZGTOB.js.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ALL_OCR_MODELS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DES2LGFZ.js";
|
|
5
5
|
import {
|
|
6
6
|
ALL_FORMULA_MODELS,
|
|
7
7
|
getModelStatusIn,
|
|
8
8
|
getModelsDir
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-KIOQ4N37.js";
|
|
10
|
+
import "./chunk-JELRWAZC.js";
|
|
11
|
+
import "./chunk-P6ZDXTV6.js";
|
|
12
12
|
|
|
13
13
|
// src/shared/model-bundle.ts
|
|
14
14
|
import { copyFile, mkdir } from "fs/promises";
|
|
@@ -101,4 +101,4 @@ export {
|
|
|
101
101
|
importModels,
|
|
102
102
|
modelCacheStatus
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=model-bundle-
|
|
104
|
+
//# sourceMappingURL=model-bundle-IMBW7D2Z.js.map
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
ocrModelPath,
|
|
11
11
|
ocrModelsCached,
|
|
12
12
|
parseCharacterDict
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-DES2LGFZ.js";
|
|
14
|
+
import "./chunk-KIOQ4N37.js";
|
|
15
|
+
import "./chunk-JELRWAZC.js";
|
|
16
|
+
import "./chunk-P6ZDXTV6.js";
|
|
17
17
|
export {
|
|
18
18
|
ALL_OCR_MODELS,
|
|
19
19
|
OCR_DET_MODEL,
|
|
@@ -26,4 +26,4 @@ export {
|
|
|
26
26
|
ocrModelsCached,
|
|
27
27
|
parseCharacterDict
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=models-
|
|
29
|
+
//# sourceMappingURL=models-SY75IBOE.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkXTFN5WKScjs = require('./chunk-XTFN5WKS.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -44,13 +44,15 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
var
|
|
48
|
-
require('./chunk-DO74GYSM.cjs');
|
|
49
|
-
require('./chunk-2BZFKIRB.cjs');
|
|
47
|
+
var _chunkWDQTFAXYcjs = require('./chunk-WDQTFAXY.cjs');
|
|
50
48
|
|
|
51
49
|
|
|
50
|
+
var _chunk62W7QCEXcjs = require('./chunk-62W7QCEX.cjs');
|
|
51
|
+
require('./chunk-CEIATRDW.cjs');
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
var _chunkSTM3ORY7cjs = require('./chunk-STM3ORY7.cjs');
|
|
54
56
|
|
|
55
57
|
|
|
56
58
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -244,7 +246,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
244
246
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
245
247
|
state.seen.set(hash, filename);
|
|
246
248
|
if (withBytes) {
|
|
247
|
-
const png =
|
|
249
|
+
const png = _chunkXTFN5WKScjs.encodePng.call(void 0, w, h, rgba);
|
|
248
250
|
state.totalBytes += png.length;
|
|
249
251
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
250
252
|
}
|
|
@@ -731,14 +733,14 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
731
733
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
732
734
|
}
|
|
733
735
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
734
|
-
const lines =
|
|
735
|
-
if (lines)
|
|
736
|
-
if (
|
|
736
|
+
const lines = _chunkWDQTFAXYcjs.CELL_LINES.get(a.cell);
|
|
737
|
+
if (lines) _chunkWDQTFAXYcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
738
|
+
if (_chunkWDQTFAXYcjs.IMAGE_CELLS.has(a.cell)) _chunkWDQTFAXYcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
737
739
|
return true;
|
|
738
740
|
};
|
|
739
|
-
for (const a of pa) if (!
|
|
741
|
+
for (const a of pa) if (!_chunkWDQTFAXYcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
740
742
|
for (const a of ca) {
|
|
741
|
-
if (a.r < skip ||
|
|
743
|
+
if (a.r < skip || _chunkWDQTFAXYcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
742
744
|
if (!place(a, ccx, prev.rows - skip, dx)) return null;
|
|
743
745
|
}
|
|
744
746
|
const first = prev.rows;
|
|
@@ -762,7 +764,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
762
764
|
const grown = { ...above, rs: newRs };
|
|
763
765
|
for (let rr = above.r; rr < above.r + newRs; rr++) for (let dc = above.c; dc < above.c + above.cs; dc++) owner[rr][dc] = grown;
|
|
764
766
|
}
|
|
765
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
767
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkWDQTFAXYcjs.FILLER_CELLS.add(grid[r][c]);
|
|
766
768
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
767
769
|
let split = rows > prev.rows && mergeSplitRow(table, owner, prev.rows, U);
|
|
768
770
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex)) split = mergeSplitRow(table, owner, prev.rows, U, true);
|
|
@@ -805,7 +807,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex) {
|
|
|
805
807
|
if (!(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
806
808
|
if (!straddles && !midWord) continue;
|
|
807
809
|
if (u.r >= last && d.rs < 2) continue;
|
|
808
|
-
const U =
|
|
810
|
+
const U = _chunkWDQTFAXYcjs.CELL_LINES.get(a);
|
|
809
811
|
if (!_optionalChain([U, 'optionalAccess', _33 => _33.length]) || U.length > STRADDLE_MAX_LINES || !hasContent(b)) continue;
|
|
810
812
|
const lu = U[U.length - 1];
|
|
811
813
|
if (!midWord && lu.y - prevBottom > (u.r >= last ? STRADDLE_BOTTOM_ONE_ROW : STRADDLE_BOTTOM) * (lu.h || 10)) continue;
|
|
@@ -832,7 +834,7 @@ var LABEL_ROOM = 1.5;
|
|
|
832
834
|
var HANGING_MIN = 0.5;
|
|
833
835
|
var HANGING_TOL = 1;
|
|
834
836
|
function continuesAcross(u, d, x1, x2) {
|
|
835
|
-
const U =
|
|
837
|
+
const U = _chunkWDQTFAXYcjs.CELL_LINES.get(u), D = _chunkWDQTFAXYcjs.CELL_LINES.get(d);
|
|
836
838
|
if (!_optionalChain([U, 'optionalAccess', _34 => _34.length]) || !_optionalChain([D, 'optionalAccess', _35 => _35.length])) return false;
|
|
837
839
|
const last = U[U.length - 1];
|
|
838
840
|
const fs = last.h || 10;
|
|
@@ -861,7 +863,7 @@ function outlineContinues(u, d) {
|
|
|
861
863
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
862
864
|
}
|
|
863
865
|
function lineEnded(c, x1, x2, next = "") {
|
|
864
|
-
const L =
|
|
866
|
+
const L = _chunkWDQTFAXYcjs.CELL_LINES.get(c);
|
|
865
867
|
if (!L || L.length !== 1) return false;
|
|
866
868
|
const l = L[0], h = l.h || 10;
|
|
867
869
|
const word = _nullishCoalesce(next.trim().split(/\s+/)[0], () => ( ""));
|
|
@@ -876,7 +878,7 @@ function appendCell(a, b) {
|
|
|
876
878
|
}
|
|
877
879
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
878
880
|
}
|
|
879
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _42 => _42.blocks, 'optionalAccess', _43 => _43.length]) ||
|
|
881
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _42 => _42.blocks, 'optionalAccess', _43 => _43.length]) || _chunkWDQTFAXYcjs.IMAGE_CELLS.has(cell);
|
|
880
882
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
881
883
|
var batchim = (ch) => {
|
|
882
884
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -884,7 +886,7 @@ var batchim = (ch) => {
|
|
|
884
886
|
};
|
|
885
887
|
function clauseContinues(u, d) {
|
|
886
888
|
const tail = _nullishCoalesce(u.text.trim().split(/\s+/).pop(), () => ( "")), head = d.text.trim();
|
|
887
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
889
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkWDQTFAXYcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
888
890
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
889
891
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
890
892
|
}
|
|
@@ -977,19 +979,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
977
979
|
placeJoined(blocks, i, j, joined);
|
|
978
980
|
continue;
|
|
979
981
|
}
|
|
980
|
-
if (
|
|
982
|
+
if (_chunkWDQTFAXYcjs.EMPTY_PARTS.has(curr.table)) {
|
|
981
983
|
blocks.splice(j, 1);
|
|
982
984
|
i++;
|
|
983
985
|
continue;
|
|
984
986
|
}
|
|
985
987
|
if (joined === null) continue;
|
|
986
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
988
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkWDQTFAXYcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
987
989
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
988
990
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
989
991
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
990
992
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
991
|
-
const px =
|
|
992
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
993
|
+
const px = _chunkWDQTFAXYcjs.TABLE_COLXS.get(prev.table), cx = _chunkWDQTFAXYcjs.TABLE_COLXS.get(curr.table);
|
|
994
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkWDQTFAXYcjs.CLIP_TABLES.has(prev.table) && !_chunkWDQTFAXYcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
993
995
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
994
996
|
let currCells = curr.table.cells;
|
|
995
997
|
if (currCells.length > 1 && prev.table.cells.length > 0 && rowTextsEqual(prev.table.cells[0], currCells[0])) {
|
|
@@ -1007,20 +1009,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1007
1009
|
caption: prev.table.caption,
|
|
1008
1010
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1009
1011
|
};
|
|
1010
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1011
|
-
if (
|
|
1012
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkWDQTFAXYcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1013
|
+
if (_chunkWDQTFAXYcjs.CLIP_TABLES.has(prev.table) || _chunkWDQTFAXYcjs.CLIP_TABLES.has(curr.table)) _chunkWDQTFAXYcjs.CLIP_TABLES.add(merged);
|
|
1012
1014
|
placeJoined(blocks, i, j, merged);
|
|
1013
1015
|
}
|
|
1014
1016
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1015
1017
|
const t = blocks[i].table;
|
|
1016
|
-
if (blocks[i].type === "table" && t &&
|
|
1018
|
+
if (blocks[i].type === "table" && t && _chunkWDQTFAXYcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1017
1019
|
}
|
|
1018
1020
|
}
|
|
1019
1021
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1020
1022
|
if (!pageHeights) return;
|
|
1021
1023
|
for (let i = 0; i < blocks.length; i++) {
|
|
1022
1024
|
const L = blocks[i];
|
|
1023
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1025
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(L.table) || _chunkWDQTFAXYcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1024
1026
|
const ph = pageHeights.get(L.pageNumber);
|
|
1025
1027
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1026
1028
|
let s0 = i, s1 = i;
|
|
@@ -1049,8 +1051,8 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1049
1051
|
}
|
|
1050
1052
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1051
1053
|
const pt = prev.table, ct = curr.table;
|
|
1052
|
-
if (!
|
|
1053
|
-
const px =
|
|
1054
|
+
if (!_chunkWDQTFAXYcjs.CLIP_TABLES.has(pt) || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(ct)) return null;
|
|
1055
|
+
const px = _chunkWDQTFAXYcjs.TABLE_COLXS.get(pt), cx = _chunkWDQTFAXYcjs.TABLE_COLXS.get(ct);
|
|
1054
1056
|
if (!px || !cx) return null;
|
|
1055
1057
|
let xs = cx, shifted = false, dx = 0, foreign = false;
|
|
1056
1058
|
if (!shiftedSame(px, cx, false)) {
|
|
@@ -1066,8 +1068,8 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1066
1068
|
}
|
|
1067
1069
|
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _58 => _58.bbox, 'optionalAccess', _59 => _59.y]), lex);
|
|
1068
1070
|
if (!res || (shifted || foreign) && !res.split && !res.header) return null;
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
+
_chunkWDQTFAXYcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1072
|
+
_chunkWDQTFAXYcjs.CLIP_TABLES.add(res.table);
|
|
1071
1073
|
return res.table;
|
|
1072
1074
|
}
|
|
1073
1075
|
function headingRow(row) {
|
|
@@ -1086,7 +1088,7 @@ function looksContinued(prev, curr, pageHeights) {
|
|
|
1086
1088
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1087
1089
|
}
|
|
1088
1090
|
function firstRowSig(t) {
|
|
1089
|
-
const x =
|
|
1091
|
+
const x = _chunkWDQTFAXYcjs.TABLE_COLXS.get(t);
|
|
1090
1092
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1091
1093
|
return anchorsOf(t).filter((a) => a.r === 0).map((a) => ({ x1: x[a.c], x2: x[a.c + a.cs], t: a.cell.text.replace(/\s+/g, "") }));
|
|
1092
1094
|
}
|
|
@@ -1139,7 +1141,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1139
1141
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1140
1142
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb))) break;
|
|
1141
1143
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1142
|
-
const px =
|
|
1144
|
+
const px = _chunkWDQTFAXYcjs.TABLE_COLXS.get(pb.table), cx = _chunkWDQTFAXYcjs.TABLE_COLXS.get(cur.table);
|
|
1143
1145
|
if (!px || !cx) break;
|
|
1144
1146
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1145
1147
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL)) break;
|
|
@@ -1170,7 +1172,7 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1170
1172
|
var COL_MATCH_TOL = 0.5;
|
|
1171
1173
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1172
1174
|
function lastRowCell(t, x1, x2) {
|
|
1173
|
-
const xs =
|
|
1175
|
+
const xs = _chunkWDQTFAXYcjs.TABLE_COLXS.get(t);
|
|
1174
1176
|
const covered = /* @__PURE__ */ new Set();
|
|
1175
1177
|
for (let r = 0; r < t.rows; r++) {
|
|
1176
1178
|
for (let c = 0; c < t.cols; c++) {
|
|
@@ -1188,7 +1190,7 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1188
1190
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1189
1191
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1190
1192
|
const part = blocks[j];
|
|
1191
|
-
const from = part.table ?
|
|
1193
|
+
const from = part.table ? _chunkWDQTFAXYcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1192
1194
|
if (!from || !part.table) continue;
|
|
1193
1195
|
let i = j - 1;
|
|
1194
1196
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
@@ -1200,7 +1202,7 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1200
1202
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1201
1203
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1202
1204
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1203
|
-
if (cell.text.trim() || _optionalChain([cell, 'access', _79 => _79.blocks, 'optionalAccess', _80 => _80.length]))
|
|
1205
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _79 => _79.blocks, 'optionalAccess', _80 => _80.length])) _chunkWDQTFAXYcjs.EMPTY_PARTS.delete(prev.table);
|
|
1204
1206
|
blocks.splice(j, 1);
|
|
1205
1207
|
if (cell.blocks && at > 0) {
|
|
1206
1208
|
const nextAt = cell.blocks[at];
|
|
@@ -1212,11 +1214,11 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1212
1214
|
}
|
|
1213
1215
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1214
1216
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1215
|
-
if (!_optionalChain([prev, 'optionalAccess', _81 => _81.table]) || !_optionalChain([frame, 'optionalAccess', _82 => _82.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !
|
|
1217
|
+
if (!_optionalChain([prev, 'optionalAccess', _81 => _81.table]) || !_optionalChain([frame, 'optionalAccess', _82 => _82.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1216
1218
|
const inner = _optionalChain([frame, 'access', _83 => _83.table, 'access', _84 => _84.cells, 'access', _85 => _85[0], 'optionalAccess', _86 => _86[0], 'optionalAccess', _87 => _87.blocks]);
|
|
1217
1219
|
const next = _optionalChain([inner, 'optionalAccess', _88 => _88[0]]);
|
|
1218
|
-
if (!inner || !_optionalChain([next, 'optionalAccess', _89 => _89.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !
|
|
1219
|
-
const px =
|
|
1220
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _89 => _89.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(prev.table) || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1221
|
+
const px = _chunkWDQTFAXYcjs.TABLE_COLXS.get(prev.table), nx = _chunkWDQTFAXYcjs.TABLE_COLXS.get(next.table);
|
|
1220
1222
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1221
1223
|
const ph = _optionalChain([pageHeights, 'optionalAccess', _90 => _90.get, 'call', _91 => _91(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _92 => _92.get, 'call', _93 => _93(next.pageNumber)]);
|
|
1222
1224
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
@@ -1225,8 +1227,8 @@ function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
|
1225
1227
|
function fillNestedContinuation(blocks, at) {
|
|
1226
1228
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1227
1229
|
const t = _optionalChain([prev, 'optionalAccess', _94 => _94.table]), u = _optionalChain([next, 'optionalAccess', _95 => _95.table]);
|
|
1228
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1229
|
-
const xs =
|
|
1230
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(t) || !_chunkWDQTFAXYcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1231
|
+
const xs = _chunkWDQTFAXYcjs.TABLE_COLXS.get(u);
|
|
1230
1232
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1231
1233
|
const add = _optionalChain([u, 'access', _96 => _96.cells, 'access', _97 => _97[0], 'optionalAccess', _98 => _98[0]]);
|
|
1232
1234
|
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _99 => _99.blocks, 'optionalAccess', _100 => _100.length])) return;
|
|
@@ -1267,7 +1269,7 @@ var WINANSI_REVERSE = {
|
|
|
1267
1269
|
};
|
|
1268
1270
|
function symbolFontTable(fontName) {
|
|
1269
1271
|
if (!fontName) return void 0;
|
|
1270
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
1272
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkXTFN5WKScjs.WINGDINGS;
|
|
1271
1273
|
return void 0;
|
|
1272
1274
|
}
|
|
1273
1275
|
function remapSymbolText(text, table) {
|
|
@@ -2287,7 +2289,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2287
2289
|
if (block.type !== "heading" || !block.text) continue;
|
|
2288
2290
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
2289
2291
|
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _133 => _133.style, 'optionalAccess', _134 => _134.fontSize]), () => ( 0));
|
|
2290
|
-
const tocEntry = i > 0 &&
|
|
2292
|
+
const tocEntry = i > 0 && _chunkWDQTFAXYcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkWDQTFAXYcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
2291
2293
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
2292
2294
|
const proseStyle = _optionalChain([block, 'access', _135 => _135.style, 'optionalAccess', _136 => _136.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
2293
2295
|
const next = blocks[i + 1];
|
|
@@ -2396,7 +2398,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
2396
2398
|
const lines = cell.text.split("\n");
|
|
2397
2399
|
const out = [lines[0]];
|
|
2398
2400
|
for (const line of lines.slice(1)) {
|
|
2399
|
-
if (
|
|
2401
|
+
if (_chunkWDQTFAXYcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
2400
2402
|
else out.push(line);
|
|
2401
2403
|
}
|
|
2402
2404
|
cell.text = out.join("\n");
|
|
@@ -2416,11 +2418,11 @@ function cleanPdfText(text, opts) {
|
|
|
2416
2418
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
2417
2419
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
2418
2420
|
if (line.startsWith("|")) {
|
|
2419
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
2421
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkWDQTFAXYcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
2420
2422
|
}
|
|
2421
2423
|
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _208 => _208.exec, 'call', _209 => _209(line), 'optionalAccess', _210 => _210[0]]), () => ( ""));
|
|
2422
|
-
return mark +
|
|
2423
|
-
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
2424
|
+
return mark + _chunkWDQTFAXYcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
2425
|
+
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
2424
2426
|
}
|
|
2425
2427
|
function startsWithMarker(line) {
|
|
2426
2428
|
const t = line.trimStart();
|
|
@@ -2451,7 +2453,7 @@ function mergeKoreanLines(text) {
|
|
|
2451
2453
|
continue;
|
|
2452
2454
|
}
|
|
2453
2455
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
2454
|
-
result[result.length - 1] = prev +
|
|
2456
|
+
result[result.length - 1] = prev + _chunkWDQTFAXYcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
2455
2457
|
} else {
|
|
2456
2458
|
result.push(curr);
|
|
2457
2459
|
}
|
|
@@ -2467,7 +2469,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
2467
2469
|
const wrapped = /* @__PURE__ */ new Set();
|
|
2468
2470
|
for (const a of annots) {
|
|
2469
2471
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
2470
|
-
const url =
|
|
2472
|
+
const url = _chunkSTM3ORY7cjs.sanitizeHref.call(void 0, a.url);
|
|
2471
2473
|
if (!url) continue;
|
|
2472
2474
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
2473
2475
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -2508,7 +2510,7 @@ function mergeLinkRuns(markdown) {
|
|
|
2508
2510
|
|
|
2509
2511
|
// src/pdf/formula-ocr.ts
|
|
2510
2512
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
2511
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
2513
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-WIMV5TUX.cjs")));
|
|
2512
2514
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
2513
2515
|
await ensureFormulaModels((p) => {
|
|
2514
2516
|
if (p.phase === "download" && p.total) {
|
|
@@ -2687,13 +2689,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
2687
2689
|
try {
|
|
2688
2690
|
return await Promise.race([
|
|
2689
2691
|
loadingTask.promise.catch((e) => {
|
|
2690
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
2692
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkSTM3ORY7cjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
|
|
2691
2693
|
throw e;
|
|
2692
2694
|
}),
|
|
2693
2695
|
new Promise((_, reject) => {
|
|
2694
2696
|
timer = setTimeout(() => {
|
|
2695
2697
|
loadingTask.destroy();
|
|
2696
|
-
reject(new (0,
|
|
2698
|
+
reject(new (0, _chunkSTM3ORY7cjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
2697
2699
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
2698
2700
|
})
|
|
2699
2701
|
]);
|
|
@@ -2703,12 +2705,12 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
2703
2705
|
}
|
|
2704
2706
|
async function parsePdfDocument(buffer, options) {
|
|
2705
2707
|
const formulaBuffer = _optionalChain([options, 'optionalAccess', _211 => _211.formulaOcr]) ? buffer : null;
|
|
2706
|
-
const autoOcr = _optionalChain([options, 'optionalAccess', _212 => _212.ocr]) === void 0 && await
|
|
2708
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _212 => _212.ocr]) === void 0 && await _chunkWDQTFAXYcjs.ocrModelsCached.call(void 0, );
|
|
2707
2709
|
const ocrBuffer = _optionalChain([options, 'optionalAccess', _213 => _213.ocr]) || autoOcr ? buffer : null;
|
|
2708
2710
|
const doc = await loadPdfWithTimeout(buffer);
|
|
2709
2711
|
try {
|
|
2710
2712
|
const pageCount = doc.numPages;
|
|
2711
|
-
if (pageCount === 0) throw new (0,
|
|
2713
|
+
if (pageCount === 0) throw new (0, _chunkSTM3ORY7cjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
2712
2714
|
const metadata = { pageCount, pageMode: "layout" };
|
|
2713
2715
|
await extractPdfMetadata(doc, metadata);
|
|
2714
2716
|
const blocks = [];
|
|
@@ -2735,7 +2737,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2735
2737
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
2736
2738
|
const carry = {};
|
|
2737
2739
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
2738
|
-
const wrapLexicon = new (0,
|
|
2740
|
+
const wrapLexicon = new (0, _chunkWDQTFAXYcjs.WrapLexicon)();
|
|
2739
2741
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
2740
2742
|
let parsedPages = 0;
|
|
2741
2743
|
for (let i = 1; i <= effectivePageCount; i++) {
|
|
@@ -2763,8 +2765,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2763
2765
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
2764
2766
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
2765
2767
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
2766
|
-
const items =
|
|
2767
|
-
const filtered =
|
|
2768
|
+
const items = _chunkWDQTFAXYcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
2769
|
+
const filtered = _chunkWDQTFAXYcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
2768
2770
|
const joined = joinVerticalColumns(filtered.visible);
|
|
2769
2771
|
const visible = dropTabLeaderDots(joined);
|
|
2770
2772
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -2802,11 +2804,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2802
2804
|
it.fontName = face;
|
|
2803
2805
|
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _223 => _223(face), 'optionalAccess', _224 => _224.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
2804
2806
|
}
|
|
2805
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
2807
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkXTFN5WKScjs.escapeLiteralDollar.call(void 0, it.text);
|
|
2806
2808
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
2807
2809
|
const pageArea = pageW * pageH;
|
|
2808
2810
|
if (pageArea > 0) {
|
|
2809
|
-
const imageRegions =
|
|
2811
|
+
const imageRegions = _chunkWDQTFAXYcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
2810
2812
|
let uncovered = 0;
|
|
2811
2813
|
for (const r of imageRegions) {
|
|
2812
2814
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -2832,10 +2834,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2832
2834
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
2833
2835
|
}
|
|
2834
2836
|
const marks = superscriptNoteMarks(visible);
|
|
2835
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
2837
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkWDQTFAXYcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
2836
2838
|
const stamp = marginStamp(visible);
|
|
2837
2839
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
2838
|
-
const pageBlocks = orderTwoUpPage(
|
|
2840
|
+
const pageBlocks = orderTwoUpPage(_chunkWDQTFAXYcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _225 => _225.tables]) !== false, carry, wrapLexicon), pageW, pageH);
|
|
2839
2841
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
2840
2842
|
for (const b of pageBlocks) blocks.push(b);
|
|
2841
2843
|
try {
|
|
@@ -2861,11 +2863,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2861
2863
|
if (_optionalChain([options, 'optionalAccess', _227 => _227.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
2862
2864
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
2863
2865
|
}
|
|
2864
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
2866
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkSTM3ORY7cjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
2865
2867
|
parsedPages++;
|
|
2866
2868
|
_optionalChain([options, 'optionalAccess', _228 => _228.onProgress, 'optionalCall', _229 => _229(parsedPages, totalTarget)]);
|
|
2867
2869
|
} catch (pageErr) {
|
|
2868
|
-
if (pageErr instanceof
|
|
2870
|
+
if (pageErr instanceof _chunkSTM3ORY7cjs.KordocError) throw pageErr;
|
|
2869
2871
|
warnings.push({ page: i, message: `\uD398\uC774\uC9C0 ${i} \uD30C\uC2F1 \uC2E4\uD328: ${pageErr instanceof Error ? pageErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
2870
2872
|
} finally {
|
|
2871
2873
|
_optionalChain([loadedPage, 'optionalAccess', _230 => _230.cleanup, 'call', _231 => _231()]);
|
|
@@ -2891,10 +2893,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2891
2893
|
}
|
|
2892
2894
|
if (targets.size > 0) {
|
|
2893
2895
|
try {
|
|
2894
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
2896
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-GHEJVPX2.cjs")));
|
|
2895
2897
|
const mode = typeof _optionalChain([options, 'optionalAccess', _236 => _236.ocr]) === "function" ? options.ocr : "builtin";
|
|
2896
2898
|
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _237 => _237.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _238 => _238.find, 'call', _239 => _239((q) => q.page === p), 'optionalAccess', _240 => _240.needsOcr])));
|
|
2897
2899
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _241 => _241.onProgress]), _optionalChain([options, 'optionalAccess', _242 => _242.tables]) !== false, vectorPageOps, regionPages);
|
|
2900
|
+
for (const obs of ocrPageBlocks.values()) _chunk62W7QCEXcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
2898
2901
|
if (ocrPageBlocks.size > 0) {
|
|
2899
2902
|
const replacePages = /* @__PURE__ */ new Set();
|
|
2900
2903
|
for (const [p, obs] of ocrPageBlocks) {
|
|
@@ -2958,7 +2961,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2958
2961
|
}
|
|
2959
2962
|
}
|
|
2960
2963
|
if (_optionalChain([options, 'optionalAccess', _250 => _250.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
2961
|
-
const removed =
|
|
2964
|
+
const removed = _chunkWDQTFAXYcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks);
|
|
2962
2965
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
2963
2966
|
blocks.splice(removed[ri], 1);
|
|
2964
2967
|
}
|
|
@@ -2971,12 +2974,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2971
2974
|
mergeContinuedCells(blocks, pageHeights);
|
|
2972
2975
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
2973
2976
|
if (_optionalChain([options, 'optionalAccess', _251 => _251.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
2974
|
-
const boxes =
|
|
2977
|
+
const boxes = _chunkWDQTFAXYcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
2975
2978
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
2976
2979
|
}
|
|
2977
2980
|
splitContactTables(blocks);
|
|
2978
|
-
if (!_optionalChain([options, 'optionalAccess', _252 => _252.keepTrailingEmptyCols]))
|
|
2979
|
-
|
|
2981
|
+
if (!_optionalChain([options, 'optionalAccess', _252 => _252.keepTrailingEmptyCols])) _chunkWDQTFAXYcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
2982
|
+
_chunkWDQTFAXYcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
2980
2983
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
2981
2984
|
if (_optionalChain([options, 'optionalAccess', _253 => _253.formulaOcr]) && formulaBuffer) {
|
|
2982
2985
|
try {
|
|
@@ -2988,21 +2991,21 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2988
2991
|
});
|
|
2989
2992
|
}
|
|
2990
2993
|
}
|
|
2991
|
-
const medianFontSize =
|
|
2994
|
+
const medianFontSize = _chunkWDQTFAXYcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
2992
2995
|
if (medianFontSize > 0) {
|
|
2993
|
-
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
2996
|
+
_chunkWDQTFAXYcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
2997
|
+
}
|
|
2998
|
+
_chunkWDQTFAXYcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
2999
|
+
_chunkWDQTFAXYcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3000
|
+
_chunkWDQTFAXYcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3001
|
+
_chunkWDQTFAXYcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3002
|
+
_chunkWDQTFAXYcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3003
|
+
_chunkWDQTFAXYcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3004
|
+
_chunkWDQTFAXYcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3005
|
+
_chunkWDQTFAXYcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3003
3006
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3004
|
-
|
|
3005
|
-
|
|
3007
|
+
_chunkWDQTFAXYcjs.detectTableCaptions.call(void 0, blocks);
|
|
3008
|
+
_chunkWDQTFAXYcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3006
3009
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3007
3010
|
sanitizeBlockControlChars(blocks);
|
|
3008
3011
|
let outBlocks = splitSingleCellTables(blocks);
|
|
@@ -3015,11 +3018,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3015
3018
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
3016
3019
|
});
|
|
3017
3020
|
joinLatinCellWraps(outBlocks);
|
|
3018
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3021
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkXTFN5WKScjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
|
|
3019
3022
|
let markdown = finishMarkdown(outBlocks);
|
|
3020
3023
|
return {
|
|
3021
3024
|
markdown,
|
|
3022
|
-
pages:
|
|
3025
|
+
pages: _chunkXTFN5WKScjs.blocksToPages.call(void 0, outBlocks, finishMarkdown),
|
|
3023
3026
|
blocks,
|
|
3024
3027
|
metadata,
|
|
3025
3028
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3089,5 +3092,5 @@ function marginStamp(items) {
|
|
|
3089
3092
|
|
|
3090
3093
|
|
|
3091
3094
|
|
|
3092
|
-
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3093
|
-
//# sourceMappingURL=parser-
|
|
3095
|
+
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkWDQTFAXYcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkWDQTFAXYcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkWDQTFAXYcjs.removeHeaderFooterBlocks;
|
|
3096
|
+
//# sourceMappingURL=parser-2LU4EVU3.cjs.map
|