kordoc 4.18.2 → 4.18.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/dist/{-I3CP33G4.js → -WOKB25R2.js} +11 -11
- package/dist/{chunk-M4P7YS2N.js → chunk-2I2RTJJ5.js} +66 -36
- package/dist/chunk-2I2RTJJ5.js.map +1 -0
- package/dist/{chunk-QGFZU3JE.cjs → chunk-2ZBLQVAS.cjs} +10 -8
- package/dist/chunk-2ZBLQVAS.cjs.map +1 -0
- package/dist/{chunk-LSOD2A6N.js → chunk-3FZGL3IL.js} +2 -2
- package/dist/{chunk-NZM2SSI4.js → chunk-5X7XWYR2.js} +2 -2
- package/dist/{chunk-GM7XIZF2.js → chunk-6GLTGOP6.js} +2 -2
- package/dist/{chunk-6OKBTY72.js → chunk-AZQWESRH.js} +2 -2
- package/dist/{chunk-O2DI4GHD.js → chunk-BGOR5GCF.js} +2 -2
- package/dist/{chunk-L64QRUMK.js → chunk-BJ6RYYXV.js} +9 -6
- package/dist/chunk-BJ6RYYXV.js.map +1 -0
- package/dist/{chunk-N5DQFA7L.js → chunk-CAN5P6N6.js} +10 -5
- package/dist/chunk-CAN5P6N6.js.map +1 -0
- package/dist/{chunk-YNLW6EGU.cjs → chunk-HZV52V2X.cjs} +3 -3
- package/dist/{chunk-YNLW6EGU.cjs.map → chunk-HZV52V2X.cjs.map} +1 -1
- package/dist/{chunk-BL7KRE6X.js → chunk-IXX3WHIE.js} +3 -3
- package/dist/{chunk-OGAYGUJF.js → chunk-J2A46VCA.js} +8 -5
- package/dist/chunk-J2A46VCA.js.map +1 -0
- package/dist/{chunk-CKUIFTXJ.js → chunk-KSJ7GKNQ.js} +2 -2
- package/dist/{chunk-L5RLJPI3.js → chunk-NES5U4JK.js} +3 -3
- package/dist/{chunk-VSY5PAJ5.js → chunk-OOX2GZZ4.js} +2 -2
- package/dist/{chunk-B2E6C2LH.js → chunk-PSJLB3SZ.js} +6 -4
- package/dist/chunk-PSJLB3SZ.js.map +1 -0
- package/dist/{chunk-4B2EXELH.js → chunk-RDBTOE5X.js} +2 -2
- package/dist/{chunk-QP7IXF7R.js → chunk-RRURZDEK.js} +2 -2
- package/dist/{chunk-LACO375L.js → chunk-RSDUH4XF.js} +4 -3
- package/dist/chunk-RSDUH4XF.js.map +1 -0
- package/dist/{chunk-UZGZRGYM.cjs → chunk-SHRRD2TD.cjs} +10 -5
- package/dist/chunk-SHRRD2TD.cjs.map +1 -0
- package/dist/{chunk-F5HING4Y.js → chunk-UVUKT3IQ.js} +5 -4
- package/dist/chunk-UVUKT3IQ.js.map +1 -0
- package/dist/{chunk-W2YYBPW5.cjs → chunk-V4BKT65D.cjs} +3 -3
- package/dist/{chunk-W2YYBPW5.cjs.map → chunk-V4BKT65D.cjs.map} +1 -1
- package/dist/{chunk-OBILAVWC.js → chunk-VGDTONTB.js} +10 -5
- package/dist/chunk-VGDTONTB.js.map +1 -0
- package/dist/{chunk-IA3UKDHA.js → chunk-W3RADOLO.js} +3 -2
- package/dist/{chunk-IA3UKDHA.js.map → chunk-W3RADOLO.js.map} +1 -1
- package/dist/{chunk-C2CVOC5K.js → chunk-W7P4GPOV.js} +4 -4
- package/dist/{chunk-KDMAYOWH.cjs → chunk-WN5YLP7H.cjs} +26 -23
- package/dist/chunk-WN5YLP7H.cjs.map +1 -0
- package/dist/{chunk-OI5ZSSIC.cjs → chunk-ZD5WNQNC.cjs} +12 -12
- package/dist/{chunk-OI5ZSSIC.cjs.map → chunk-ZD5WNQNC.cjs.map} +1 -1
- package/dist/{chunk-T4MXCSBP.js → chunk-ZN3LHNJG.js} +49 -26
- package/dist/chunk-ZN3LHNJG.js.map +1 -0
- package/dist/chunks-OQDRDICD.js +10 -0
- package/dist/cli.js +55 -34
- package/dist/cli.js.map +1 -1
- package/dist/{formula-VY4ITOMN.cjs → formula-BQ5RW5XD.cjs} +9 -9
- package/dist/{formula-VY4ITOMN.cjs.map → formula-BQ5RW5XD.cjs.map} +1 -1
- package/dist/{formula-AQZODKZF.js → formula-GPCOJJXN.js} +3 -3
- package/dist/{formula-E3N7KDDG.js → formula-QZAOKPBX.js} +4 -4
- package/dist/{image-ocr-IMYXOHHV.js → image-ocr-POCME5I4.js} +6 -6
- package/dist/{image-ocr-LN3GSQPW.js → image-ocr-TWNNVTZS.js} +9 -9
- package/dist/{image-ocr-6LYEBMVR.cjs → image-ocr-VKIUBLBX.cjs} +15 -15
- package/dist/{image-ocr-6LYEBMVR.cjs.map → image-ocr-VKIUBLBX.cjs.map} +1 -1
- package/dist/index.cjs +800 -748
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +104 -52
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +26 -26
- package/dist/mcp.js.map +1 -1
- package/dist/{model-bundle-IHKNDLOT.js → model-bundle-THYUL7GG.js} +5 -5
- package/dist/{models-YXITRAMR.js → models-U22N4RXX.js} +5 -5
- package/dist/{parser-7KECZTTP.cjs → parser-JOMFOZLH.cjs} +211 -198
- package/dist/parser-JOMFOZLH.cjs.map +1 -0
- package/dist/{parser-KB4BYQBZ.js → parser-NKP2NCSV.js} +24 -11
- package/dist/parser-NKP2NCSV.js.map +1 -0
- package/dist/{parser-M3T2EWUN.js → parser-SCXRLOW7.js} +21 -8
- package/dist/parser-SCXRLOW7.js.map +1 -0
- package/dist/pdf-ocr-NF4AY5MI.cjs +16 -0
- package/dist/{pdf-ocr-IGYCZ7G2.cjs.map → pdf-ocr-NF4AY5MI.cjs.map} +1 -1
- package/dist/pdf-ocr-OLII3WAG.js +15 -0
- package/dist/pdf-ocr-VJL7ON2Q.js +19 -0
- package/dist/{profile-io-GQWQR7YQ.js → profile-io-UI3TZBYH.js} +3 -3
- package/dist/{rasterize-Y6TVFQ3M.js → rasterize-XMBV5H2I.js} +3 -3
- package/dist/{redact-doc-TRPZ3HNW.js → redact-doc-7ZZMHDBO.js} +11 -11
- package/dist/{render-GHT5HKBO.js → render-SWRTUDAV.js} +7 -7
- package/dist/seal-UKKJZHKE.js +10 -0
- package/dist/{setup-AGSCEHDB.js → setup-43JJEEU7.js} +3 -3
- package/dist/visual-D2563HCJ.js +20 -0
- package/dist/{watch-ALSEW4GB.js → watch-NRATQ472.js} +13 -13
- package/dist/watch-NRATQ472.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-B2E6C2LH.js.map +0 -1
- package/dist/chunk-F5HING4Y.js.map +0 -1
- package/dist/chunk-KDMAYOWH.cjs.map +0 -1
- package/dist/chunk-L64QRUMK.js.map +0 -1
- package/dist/chunk-LACO375L.js.map +0 -1
- package/dist/chunk-M4P7YS2N.js.map +0 -1
- package/dist/chunk-N5DQFA7L.js.map +0 -1
- package/dist/chunk-OBILAVWC.js.map +0 -1
- package/dist/chunk-OGAYGUJF.js.map +0 -1
- package/dist/chunk-QGFZU3JE.cjs.map +0 -1
- package/dist/chunk-T4MXCSBP.js.map +0 -1
- package/dist/chunk-UZGZRGYM.cjs.map +0 -1
- package/dist/chunks-IFFRC5IQ.js +0 -10
- package/dist/parser-7KECZTTP.cjs.map +0 -1
- package/dist/parser-KB4BYQBZ.js.map +0 -1
- package/dist/parser-M3T2EWUN.js.map +0 -1
- package/dist/pdf-ocr-4S2OAHUX.js +0 -15
- package/dist/pdf-ocr-IGYCZ7G2.cjs +0 -16
- package/dist/pdf-ocr-YEBFWU2K.js +0 -19
- package/dist/seal-3YTXSABW.js +0 -10
- package/dist/visual-R3E35Q2K.js +0 -20
- package/dist/watch-ALSEW4GB.js.map +0 -1
- /package/dist/{-I3CP33G4.js.map → -WOKB25R2.js.map} +0 -0
- /package/dist/{chunk-LSOD2A6N.js.map → chunk-3FZGL3IL.js.map} +0 -0
- /package/dist/{chunk-NZM2SSI4.js.map → chunk-5X7XWYR2.js.map} +0 -0
- /package/dist/{chunk-GM7XIZF2.js.map → chunk-6GLTGOP6.js.map} +0 -0
- /package/dist/{chunk-6OKBTY72.js.map → chunk-AZQWESRH.js.map} +0 -0
- /package/dist/{chunk-O2DI4GHD.js.map → chunk-BGOR5GCF.js.map} +0 -0
- /package/dist/{chunk-BL7KRE6X.js.map → chunk-IXX3WHIE.js.map} +0 -0
- /package/dist/{chunk-CKUIFTXJ.js.map → chunk-KSJ7GKNQ.js.map} +0 -0
- /package/dist/{chunk-L5RLJPI3.js.map → chunk-NES5U4JK.js.map} +0 -0
- /package/dist/{chunk-VSY5PAJ5.js.map → chunk-OOX2GZZ4.js.map} +0 -0
- /package/dist/{chunk-4B2EXELH.js.map → chunk-RDBTOE5X.js.map} +0 -0
- /package/dist/{chunk-QP7IXF7R.js.map → chunk-RRURZDEK.js.map} +0 -0
- /package/dist/{chunk-C2CVOC5K.js.map → chunk-W7P4GPOV.js.map} +0 -0
- /package/dist/{chunks-IFFRC5IQ.js.map → chunks-OQDRDICD.js.map} +0 -0
- /package/dist/{formula-AQZODKZF.js.map → formula-GPCOJJXN.js.map} +0 -0
- /package/dist/{formula-E3N7KDDG.js.map → formula-QZAOKPBX.js.map} +0 -0
- /package/dist/{image-ocr-IMYXOHHV.js.map → image-ocr-POCME5I4.js.map} +0 -0
- /package/dist/{image-ocr-LN3GSQPW.js.map → image-ocr-TWNNVTZS.js.map} +0 -0
- /package/dist/{model-bundle-IHKNDLOT.js.map → model-bundle-THYUL7GG.js.map} +0 -0
- /package/dist/{models-YXITRAMR.js.map → models-U22N4RXX.js.map} +0 -0
- /package/dist/{pdf-ocr-4S2OAHUX.js.map → pdf-ocr-OLII3WAG.js.map} +0 -0
- /package/dist/{pdf-ocr-YEBFWU2K.js.map → pdf-ocr-VJL7ON2Q.js.map} +0 -0
- /package/dist/{profile-io-GQWQR7YQ.js.map → profile-io-UI3TZBYH.js.map} +0 -0
- /package/dist/{rasterize-Y6TVFQ3M.js.map → rasterize-XMBV5H2I.js.map} +0 -0
- /package/dist/{redact-doc-TRPZ3HNW.js.map → redact-doc-7ZZMHDBO.js.map} +0 -0
- /package/dist/{render-GHT5HKBO.js.map → render-SWRTUDAV.js.map} +0 -0
- /package/dist/{seal-3YTXSABW.js.map → seal-UKKJZHKE.js.map} +0 -0
- /package/dist/{setup-AGSCEHDB.js.map → setup-43JJEEU7.js.map} +0 -0
- /package/dist/{visual-R3E35Q2K.js.map → visual-D2563HCJ.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkV4BKT65Dcjs = require('./chunk-V4BKT65D.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -48,7 +48,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunkWN5YLP7Hcjs = require('./chunk-WN5YLP7H.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
@@ -58,12 +58,12 @@ var _chunkKDMAYOWHcjs = require('./chunk-KDMAYOWH.cjs');
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
var
|
|
62
|
-
require('./chunk-
|
|
61
|
+
var _chunk2ZBLQVAScjs = require('./chunk-2ZBLQVAS.cjs');
|
|
62
|
+
require('./chunk-HZV52V2X.cjs');
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
var
|
|
66
|
+
var _chunkSHRRD2TDcjs = require('./chunk-SHRRD2TD.cjs');
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -257,7 +257,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
257
257
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
258
258
|
state.seen.set(hash, filename);
|
|
259
259
|
if (withBytes) {
|
|
260
|
-
const png =
|
|
260
|
+
const png = _chunkV4BKT65Dcjs.encodePng.call(void 0, w, h, rgba);
|
|
261
261
|
state.totalBytes += png.length;
|
|
262
262
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
263
263
|
}
|
|
@@ -772,19 +772,19 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
772
772
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
773
773
|
}
|
|
774
774
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
775
|
-
const lines =
|
|
776
|
-
if (lines)
|
|
777
|
-
if (
|
|
778
|
-
const edges =
|
|
775
|
+
const lines = _chunkWN5YLP7Hcjs.CELL_LINES.get(a.cell);
|
|
776
|
+
if (lines) _chunkWN5YLP7Hcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
777
|
+
if (_chunkWN5YLP7Hcjs.IMAGE_CELLS.has(a.cell)) _chunkWN5YLP7Hcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
778
|
+
const edges = _chunk2ZBLQVAScjs.CELL_EDGES.get(a.cell);
|
|
779
779
|
if (edges) {
|
|
780
|
-
|
|
780
|
+
_chunk2ZBLQVAScjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
781
781
|
edged = true;
|
|
782
782
|
}
|
|
783
783
|
return true;
|
|
784
784
|
};
|
|
785
|
-
for (const a of pa) if (!
|
|
785
|
+
for (const a of pa) if (!_chunkWN5YLP7Hcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
786
786
|
for (const a of ca) {
|
|
787
|
-
if (a.r < skip ||
|
|
787
|
+
if (a.r < skip || _chunkWN5YLP7Hcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
788
788
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
789
789
|
}
|
|
790
790
|
const first = prev.rows;
|
|
@@ -808,9 +808,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
808
808
|
const grown = { ...above, rs: newRs };
|
|
809
809
|
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;
|
|
810
810
|
}
|
|
811
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
811
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkWN5YLP7Hcjs.FILLER_CELLS.add(grid[r][c]);
|
|
812
812
|
if (edged) {
|
|
813
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
813
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunk2ZBLQVAScjs.CELL_EDGES.set(grid[r][c], _chunkWN5YLP7Hcjs.NO_EDGES);
|
|
814
814
|
}
|
|
815
815
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
816
816
|
let r = prev.rows;
|
|
@@ -819,7 +819,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
819
819
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
820
820
|
}
|
|
821
821
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
822
|
-
const pr =
|
|
822
|
+
const pr = _chunkWN5YLP7Hcjs.ROW_RULES.get(prev), cr = _chunkWN5YLP7Hcjs.ROW_RULES.get(curr);
|
|
823
823
|
const shifted = dx !== 0;
|
|
824
824
|
const cut = {
|
|
825
825
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -830,7 +830,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
830
830
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
831
831
|
if (pr && cr) {
|
|
832
832
|
const cutRuled = pr.bottom || cr.top;
|
|
833
|
-
|
|
833
|
+
_chunkWN5YLP7Hcjs.ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
|
|
834
834
|
}
|
|
835
835
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
836
836
|
}
|
|
@@ -884,7 +884,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
884
884
|
if (!crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
885
885
|
if (!straddles && !midWord) continue;
|
|
886
886
|
if (u.r >= last && d.rs < 2) continue;
|
|
887
|
-
const U =
|
|
887
|
+
const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(a);
|
|
888
888
|
if (!_optionalChain([U, 'optionalAccess', _33 => _33.length]) || !hasContent(b)) continue;
|
|
889
889
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
890
890
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
@@ -919,8 +919,19 @@ var CARRIED_MIN_COL_W = 4;
|
|
|
919
919
|
var LABEL_ROOM = 1.5;
|
|
920
920
|
var HANGING_MIN = 0.5;
|
|
921
921
|
var HANGING_TOL = 1;
|
|
922
|
+
var KO_ITEMS = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558\uAC70\uB108\uB354\uB7EC\uBA38\uBC84\uC11C\uC5B4\uC800\uCC98\uCEE4\uD130\uD37C\uD5C8\uACE0\uB178\uB3C4\uB85C\uBAA8\uBCF4\uC18C\uC624\uC870\uCD08\uCF54\uD1A0\uD3EC\uD638\uAD6C\uB204\uB450\uB8E8\uBB34\uBD80\uC218\uC6B0\uC8FC\uCD94\uCFE0\uD22C\uD478\uD6C4";
|
|
923
|
+
var ITEM_MARK = /^\s*(?:([가-힣])\.|(\d{1,3})[.)]|\(([가-힣\d]{1,3})\))(?=\s)/;
|
|
924
|
+
function nextItemHead(prev, next) {
|
|
925
|
+
const a = ITEM_MARK.exec(prev), b = ITEM_MARK.exec(next);
|
|
926
|
+
if (!a || !b) return false;
|
|
927
|
+
const succ = (x, y) => /^\d+$/.test(x) ? /^\d+$/.test(y) && Number(y) === Number(x) + 1 : KO_ITEMS.indexOf(x) >= 0 && KO_ITEMS.indexOf(y) === KO_ITEMS.indexOf(x) + 1;
|
|
928
|
+
if (a[1] && b[1]) return succ(a[1], b[1]);
|
|
929
|
+
if (a[2] && b[2]) return succ(a[2], b[2]) && prev.trimStart()[a[2].length] === next.trimStart()[b[2].length];
|
|
930
|
+
if (a[3] && b[3]) return succ(a[3], b[3]);
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
922
933
|
function continuesAcross(u, d, x1, x2) {
|
|
923
|
-
const U =
|
|
934
|
+
const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(u), D = _chunkWN5YLP7Hcjs.CELL_LINES.get(d);
|
|
924
935
|
if (!_optionalChain([U, 'optionalAccess', _34 => _34.length]) || !_optionalChain([D, 'optionalAccess', _35 => _35.length])) return false;
|
|
925
936
|
const last = U[U.length - 1];
|
|
926
937
|
const fs = last.h || 10;
|
|
@@ -938,7 +949,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
938
949
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
939
950
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
940
951
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
941
|
-
const newItem =
|
|
952
|
+
const newItem = _chunkWN5YLP7Hcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
942
953
|
const all = D.length ? U.concat(D) : U;
|
|
943
954
|
const leftAligned = (l) => maxR - l.r > SHORT_LINE_GAP * fs && (l.l - minL <= fs || !newItem && all.some((o) => o !== l && Math.abs(o.l - l.l) <= HANGING_TOL && Math.abs(o.r - l.r) >= HANGING_MIN * fs));
|
|
944
955
|
const hanging = U.length >= 2 && U.every((l) => maxR - l.r <= FULL_LINE_TOL * fs) && indented && Math.abs(D[0].l - last.l) <= HANGING_TOL;
|
|
@@ -955,10 +966,10 @@ function outlineContinues(u, d) {
|
|
|
955
966
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
956
967
|
}
|
|
957
968
|
function lineEnded(c, x1, x2, next) {
|
|
958
|
-
const L =
|
|
969
|
+
const L = _chunkWN5YLP7Hcjs.CELL_LINES.get(c);
|
|
959
970
|
if (!L || L.length !== 1) return false;
|
|
960
971
|
const l = L[0], h = l.h || 10;
|
|
961
|
-
const d0 = next ? _optionalChain([
|
|
972
|
+
const d0 = next ? _optionalChain([_chunkWN5YLP7Hcjs.CELL_LINES, 'access', _36 => _36.get, 'call', _37 => _37(next), 'optionalAccess', _38 => _38[0]]) : void 0;
|
|
962
973
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
963
974
|
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _39 => _39.text]), () => ( "")))) * h;
|
|
964
975
|
}
|
|
@@ -974,9 +985,9 @@ function appendCell(a, b) {
|
|
|
974
985
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
975
986
|
}
|
|
976
987
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
977
|
-
|
|
988
|
+
_chunkWN5YLP7Hcjs.joinCellEdges.call(void 0, a, b);
|
|
978
989
|
}
|
|
979
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _46 => _46.blocks, 'optionalAccess', _47 => _47.length]) ||
|
|
990
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _46 => _46.blocks, 'optionalAccess', _47 => _47.length]) || _chunkWN5YLP7Hcjs.IMAGE_CELLS.has(cell);
|
|
980
991
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
981
992
|
var batchim = (ch) => {
|
|
982
993
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -984,13 +995,13 @@ var batchim = (ch) => {
|
|
|
984
995
|
};
|
|
985
996
|
function clauseContinues(u, d) {
|
|
986
997
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
987
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
998
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkWN5YLP7Hcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
988
999
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
989
1000
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
990
1001
|
}
|
|
991
1002
|
function wordOverflows(u, d, x1, x2) {
|
|
992
|
-
const U =
|
|
993
|
-
if (!_optionalChain([U, 'optionalAccess', _48 => _48.length]) ||
|
|
1003
|
+
const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(u);
|
|
1004
|
+
if (!_optionalChain([U, 'optionalAccess', _48 => _48.length]) || _chunkWN5YLP7Hcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
994
1005
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
995
1006
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
996
1007
|
}
|
|
@@ -1050,6 +1061,8 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1050
1061
|
if (!carriedSplit) {
|
|
1051
1062
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1052
1063
|
if (pairs.some(([u, d]) => hasContent(d.cell) && norm(cell(d)) !== norm(cell(u)) && lineEnded(cell(u), colXs[u.c], colXs[u.c + u.cs], cell(d)))) return false;
|
|
1064
|
+
const oneLine = (c) => _optionalChain([_chunkWN5YLP7Hcjs.CELL_LINES, 'access', _50 => _50.get, 'call', _51 => _51(c), 'optionalAccess', _52 => _52.length]) === 1;
|
|
1065
|
+
if (pairs.some(([u, d]) => nextItemHead(cell(u).text, cell(d).text)) && pairs.some(([u, d]) => hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
|
|
1053
1066
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d));
|
|
1054
1067
|
if (!(cut.open && !newCell)) {
|
|
1055
1068
|
if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
|
|
@@ -1079,8 +1092,8 @@ function besideOwn(b, p, c) {
|
|
|
1079
1092
|
}
|
|
1080
1093
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
1081
1094
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
1082
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1083
|
-
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess',
|
|
1095
|
+
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _53 => _53.text, 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()]), () => ( "")))) return false;
|
|
1096
|
+
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _56 => _56.get, 'call', _57 => _57(b.pageNumber)]) : void 0;
|
|
1084
1097
|
if (!h) return false;
|
|
1085
1098
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
1086
1099
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -1103,7 +1116,7 @@ function insideTable(b, t) {
|
|
|
1103
1116
|
return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
|
|
1104
1117
|
}
|
|
1105
1118
|
function startsWithUnitRow(table) {
|
|
1106
|
-
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access',
|
|
1119
|
+
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _58 => _58.cells, 'access', _59 => _59[0], 'optionalAccess', _60 => _60[0], 'optionalAccess', _61 => _61.text]), () => ( ""))) && _optionalChain([table, 'access', _62 => _62.cells, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.slice, 'call', _65 => _65(1), 'access', _66 => _66.every, 'call', _67 => _67((c) => !c.text.trim())]);
|
|
1107
1120
|
}
|
|
1108
1121
|
function sameHeadShape(a, b) {
|
|
1109
1122
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -1123,7 +1136,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1123
1136
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
1124
1137
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
1125
1138
|
const curr = blocks[j];
|
|
1126
|
-
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess',
|
|
1139
|
+
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _68 => _68.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
|
|
1127
1140
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1128
1141
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1129
1142
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
@@ -1132,19 +1145,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1132
1145
|
placeJoined(blocks, i, j, joined);
|
|
1133
1146
|
continue;
|
|
1134
1147
|
}
|
|
1135
|
-
if (
|
|
1148
|
+
if (_chunkWN5YLP7Hcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1136
1149
|
blocks.splice(j, 1);
|
|
1137
1150
|
i++;
|
|
1138
1151
|
continue;
|
|
1139
1152
|
}
|
|
1140
1153
|
if (joined === null) continue;
|
|
1141
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1154
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkWN5YLP7Hcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1142
1155
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1143
1156
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1144
1157
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1145
1158
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1146
|
-
const px =
|
|
1147
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1159
|
+
const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(prev.table), cx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(curr.table);
|
|
1160
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) && !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1148
1161
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1149
1162
|
let currCells = curr.table.cells;
|
|
1150
1163
|
if (currCells.length > 1 && prev.table.cells.length > 0 && rowTextsEqual(prev.table.cells[0], currCells[0])) {
|
|
@@ -1154,16 +1167,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1154
1167
|
blocks.splice(j, 1);
|
|
1155
1168
|
continue;
|
|
1156
1169
|
}
|
|
1157
|
-
if (px && cx && !
|
|
1170
|
+
if (px && cx && !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) && !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table) && currCells.length < curr.table.cells.length && curr.table.cells[0].filter((c) => c.text.trim()).length >= 2 && prev.table.cells.at(-1).concat(currCells[0]).every((c) => c.rowSpan === 1 && c.colSpan === 1 && _chunkWN5YLP7Hcjs.CELL_LINES.has(c))) {
|
|
1158
1171
|
const dx = px[0] - cx[0];
|
|
1159
1172
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1160
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
1173
|
+
if (_optionalChain([part, 'optionalAccess', _69 => _69.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1161
1174
|
const last = prev.table.rows - 1;
|
|
1162
1175
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1163
|
-
const U =
|
|
1164
|
-
|
|
1176
|
+
const U = _chunkWN5YLP7Hcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkWN5YLP7Hcjs.CELL_LINES.get(currCells[0][c]);
|
|
1177
|
+
_chunkWN5YLP7Hcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1165
1178
|
}
|
|
1166
|
-
|
|
1179
|
+
_chunkWN5YLP7Hcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1167
1180
|
placeJoined(blocks, i, j, part.table);
|
|
1168
1181
|
continue;
|
|
1169
1182
|
}
|
|
@@ -1176,20 +1189,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1176
1189
|
caption: prev.table.caption,
|
|
1177
1190
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1178
1191
|
};
|
|
1179
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1180
|
-
if (
|
|
1192
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkWN5YLP7Hcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1193
|
+
if (_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) || _chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table)) _chunkWN5YLP7Hcjs.CLIP_TABLES.add(merged);
|
|
1181
1194
|
placeJoined(blocks, i, j, merged);
|
|
1182
1195
|
}
|
|
1183
1196
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1184
1197
|
const t = blocks[i].table;
|
|
1185
|
-
if (blocks[i].type === "table" && t &&
|
|
1198
|
+
if (blocks[i].type === "table" && t && _chunkWN5YLP7Hcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1186
1199
|
}
|
|
1187
1200
|
}
|
|
1188
1201
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1189
1202
|
if (!pageHeights) return;
|
|
1190
1203
|
for (let i = 0; i < blocks.length; i++) {
|
|
1191
1204
|
const L = blocks[i];
|
|
1192
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1205
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(L.table) || _chunkWN5YLP7Hcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1193
1206
|
const ph = pageHeights.get(L.pageNumber);
|
|
1194
1207
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1195
1208
|
let s0 = i, s1 = i;
|
|
@@ -1218,12 +1231,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1218
1231
|
}
|
|
1219
1232
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1220
1233
|
const pt = prev.table, ct = curr.table;
|
|
1221
|
-
if (!
|
|
1222
|
-
const px =
|
|
1234
|
+
if (!_chunkWN5YLP7Hcjs.CLIP_TABLES.has(pt) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(ct)) return null;
|
|
1235
|
+
const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(pt), cx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(ct);
|
|
1223
1236
|
if (!px || !cx) return null;
|
|
1224
1237
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1225
1238
|
if (!shiftedSame(px, cx, false)) {
|
|
1226
|
-
if (!_optionalChain([pageHeights, 'optionalAccess',
|
|
1239
|
+
if (!_optionalChain([pageHeights, 'optionalAccess', _70 => _70.get, 'call', _71 => _71(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _72 => _72.get, 'call', _73 => _73(curr.pageNumber)])) return null;
|
|
1227
1240
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1228
1241
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1229
1242
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -1235,19 +1248,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1235
1248
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1236
1249
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1237
1250
|
};
|
|
1238
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1251
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkWN5YLP7Hcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
|
|
1239
1252
|
}
|
|
1240
|
-
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access',
|
|
1253
|
+
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _74 => _74.bbox, 'optionalAccess', _75 => _75.y]), lex);
|
|
1241
1254
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1242
|
-
|
|
1243
|
-
const ys =
|
|
1244
|
-
if (ys)
|
|
1245
|
-
|
|
1246
|
-
|
|
1255
|
+
_chunkWN5YLP7Hcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1256
|
+
const ys = _chunkWN5YLP7Hcjs.TABLE_ROWYS.get(pt);
|
|
1257
|
+
if (ys) _chunkWN5YLP7Hcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1258
|
+
_chunkWN5YLP7Hcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkWN5YLP7Hcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1259
|
+
_chunkWN5YLP7Hcjs.CLIP_TABLES.add(res.table);
|
|
1247
1260
|
return res.table;
|
|
1248
1261
|
}
|
|
1249
1262
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
1250
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1263
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _76 => _76.get, 'call', _77 => _77(prev.pageNumber)]);
|
|
1251
1264
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
1252
1265
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
1253
1266
|
}
|
|
@@ -1258,21 +1271,21 @@ function headingRow(row) {
|
|
|
1258
1271
|
}
|
|
1259
1272
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
1260
1273
|
function looksContinued(prev, curr, pageHeights) {
|
|
1261
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1274
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _78 => _78.get, 'call', _79 => _79(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _80 => _80.get, 'call', _81 => _81(curr.pageNumber)]);
|
|
1262
1275
|
if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
|
|
1263
1276
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
1264
|
-
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access',
|
|
1277
|
+
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _82 => _82.find, 'call', _83 => _83((c) => c.text.trim()), 'optionalAccess', _84 => _84.text]), () => ( ""));
|
|
1265
1278
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
1266
1279
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
1267
1280
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1268
1281
|
}
|
|
1269
1282
|
function pushedLead(prev, curr) {
|
|
1270
|
-
if (!
|
|
1283
|
+
if (!_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1271
1284
|
const lead = leadRows(curr.table);
|
|
1272
1285
|
return lead.image && lead.height > prev.bbox.y;
|
|
1273
1286
|
}
|
|
1274
1287
|
function leadRows(t) {
|
|
1275
|
-
const ys =
|
|
1288
|
+
const ys = _chunkWN5YLP7Hcjs.TABLE_ROWYS.get(t);
|
|
1276
1289
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1277
1290
|
const anchors = anchorsOf(t);
|
|
1278
1291
|
let end = 1, image = false;
|
|
@@ -1280,17 +1293,17 @@ function leadRows(t) {
|
|
|
1280
1293
|
for (const a of anchors) {
|
|
1281
1294
|
if (a.r !== r) continue;
|
|
1282
1295
|
end = Math.max(end, r + a.rs);
|
|
1283
|
-
if (
|
|
1296
|
+
if (_chunkWN5YLP7Hcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1284
1297
|
}
|
|
1285
1298
|
}
|
|
1286
1299
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1287
1300
|
}
|
|
1288
1301
|
function tailOf(b) {
|
|
1289
|
-
const t = b.table &&
|
|
1302
|
+
const t = b.table && _chunkWN5YLP7Hcjs.TABLE_TAIL.get(b.table);
|
|
1290
1303
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1291
1304
|
}
|
|
1292
1305
|
function firstRowSig(t) {
|
|
1293
|
-
const x =
|
|
1306
|
+
const x = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(t);
|
|
1294
1307
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1295
1308
|
return anchorsOf(t).filter((a) => a.r === 0).map((a) => ({ x1: x[a.c], x2: x[a.c + a.cs], t: flowText(a.cell.text).replace(/\s+/g, "") }));
|
|
1296
1309
|
}
|
|
@@ -1315,9 +1328,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
1315
1328
|
}
|
|
1316
1329
|
function restartsTitledForm(head, curr) {
|
|
1317
1330
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
1318
|
-
const full = (t) => _optionalChain([t, 'access',
|
|
1331
|
+
const full = (t) => _optionalChain([t, 'access', _85 => _85.cells, 'access', _86 => _86[0], 'access', _87 => _87[0], 'optionalAccess', _88 => _88.colSpan]) === t.cols;
|
|
1319
1332
|
if (!full(head) || !full(curr)) return false;
|
|
1320
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
1333
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _89 => _89.text]), () => ( ""))).replace(/\s+/g, "");
|
|
1321
1334
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
1322
1335
|
if (!ht || !ct || ht === ct) return false;
|
|
1323
1336
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -1343,7 +1356,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1343
1356
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1344
1357
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1345
1358
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1346
|
-
const px =
|
|
1359
|
+
const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(pb.table), cx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(cur.table);
|
|
1347
1360
|
if (!px || !cx) break;
|
|
1348
1361
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1349
1362
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1375,12 +1388,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1375
1388
|
var COL_MATCH_TOL = 0.5;
|
|
1376
1389
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1377
1390
|
function lastRowCell(t, x1, x2) {
|
|
1378
|
-
const xs =
|
|
1391
|
+
const xs = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(t);
|
|
1379
1392
|
const covered = /* @__PURE__ */ new Set();
|
|
1380
1393
|
for (let r = 0; r < t.rows; r++) {
|
|
1381
1394
|
for (let c = 0; c < t.cols; c++) {
|
|
1382
1395
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1383
|
-
const cell = _optionalChain([t, 'access',
|
|
1396
|
+
const cell = _optionalChain([t, 'access', _90 => _90.cells, 'access', _91 => _91[r], 'optionalAccess', _92 => _92[c]]);
|
|
1384
1397
|
if (!cell) continue;
|
|
1385
1398
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
1386
1399
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -1393,23 +1406,23 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1393
1406
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1394
1407
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1395
1408
|
const part = blocks[j];
|
|
1396
|
-
const from = part.table ?
|
|
1409
|
+
const from = part.table ? _chunkWN5YLP7Hcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1397
1410
|
if (!from || !part.table) continue;
|
|
1398
1411
|
let i = j - 1;
|
|
1399
1412
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
1400
1413
|
const prev = blocks[i];
|
|
1401
1414
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
1402
1415
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
1403
|
-
const add = _optionalChain([part, 'access',
|
|
1416
|
+
const add = _optionalChain([part, 'access', _93 => _93.table, 'access', _94 => _94.cells, 'access', _95 => _95[0], 'optionalAccess', _96 => _96[0]]);
|
|
1404
1417
|
if (!cell || !add) continue;
|
|
1405
1418
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1406
1419
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1407
1420
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1408
|
-
|
|
1409
|
-
const lines =
|
|
1410
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
1411
|
-
if (part.pageNumber && part.bbox)
|
|
1412
|
-
if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
1421
|
+
_chunkWN5YLP7Hcjs.joinCellEdges.call(void 0, cell, add);
|
|
1422
|
+
const lines = _chunkWN5YLP7Hcjs.CELL_LINES.get(add);
|
|
1423
|
+
if (_optionalChain([lines, 'optionalAccess', _97 => _97.length])) _chunkWN5YLP7Hcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkWN5YLP7Hcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1424
|
+
if (part.pageNumber && part.bbox) _chunkWN5YLP7Hcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkWN5YLP7Hcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1425
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _98 => _98.blocks, 'optionalAccess', _99 => _99.length])) _chunkWN5YLP7Hcjs.EMPTY_PARTS.delete(prev.table);
|
|
1413
1426
|
blocks.splice(j, 1);
|
|
1414
1427
|
if (cell.blocks && at > 0) {
|
|
1415
1428
|
const nextAt = cell.blocks[at];
|
|
@@ -1421,27 +1434,27 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1421
1434
|
}
|
|
1422
1435
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1423
1436
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1424
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
1425
|
-
const inner = _optionalChain([frame, 'access',
|
|
1426
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
1427
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
1428
|
-
const px =
|
|
1437
|
+
if (!_optionalChain([prev, 'optionalAccess', _100 => _100.table]) || !_optionalChain([frame, 'optionalAccess', _101 => _101.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1438
|
+
const inner = _optionalChain([frame, 'access', _102 => _102.table, 'access', _103 => _103.cells, 'access', _104 => _104[0], 'optionalAccess', _105 => _105[0], 'optionalAccess', _106 => _106.blocks]);
|
|
1439
|
+
const next = _optionalChain([inner, 'optionalAccess', _107 => _107[0]]);
|
|
1440
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _108 => _108.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(prev.table) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1441
|
+
const px = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(prev.table), nx = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(next.table);
|
|
1429
1442
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1430
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1443
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _109 => _109.get, 'call', _110 => _110(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _111 => _111.get, 'call', _112 => _112(next.pageNumber)]);
|
|
1431
1444
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
1432
1445
|
blocks.splice(at, 1, ...inner);
|
|
1433
1446
|
}
|
|
1434
1447
|
function fillNestedContinuation(blocks, at) {
|
|
1435
1448
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1436
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
1437
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1438
|
-
const xs =
|
|
1449
|
+
const t = _optionalChain([prev, 'optionalAccess', _113 => _113.table]), u = _optionalChain([next, 'optionalAccess', _114 => _114.table]);
|
|
1450
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(t) || !_chunkWN5YLP7Hcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1451
|
+
const xs = _chunkWN5YLP7Hcjs.TABLE_COLXS.get(u);
|
|
1439
1452
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1440
|
-
const add = _optionalChain([u, 'access',
|
|
1441
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access',
|
|
1453
|
+
const add = _optionalChain([u, 'access', _115 => _115.cells, 'access', _116 => _116[0], 'optionalAccess', _117 => _117[0]]);
|
|
1454
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _118 => _118.blocks, 'optionalAccess', _119 => _119.length])) return;
|
|
1442
1455
|
cell.text = add.text;
|
|
1443
1456
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1444
|
-
|
|
1457
|
+
_chunkWN5YLP7Hcjs.joinCellEdges.call(void 0, cell, add);
|
|
1445
1458
|
blocks.splice(at, 1);
|
|
1446
1459
|
}
|
|
1447
1460
|
|
|
@@ -1477,7 +1490,7 @@ var WINANSI_REVERSE = {
|
|
|
1477
1490
|
};
|
|
1478
1491
|
function symbolFontTable(fontName) {
|
|
1479
1492
|
if (!fontName) return void 0;
|
|
1480
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
1493
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunk2ZBLQVAScjs.WINGDINGS;
|
|
1481
1494
|
return void 0;
|
|
1482
1495
|
}
|
|
1483
1496
|
function remapSymbolText(text, table) {
|
|
@@ -1605,7 +1618,7 @@ function layout(toks) {
|
|
|
1605
1618
|
const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
|
|
1606
1619
|
if (!bar) continue;
|
|
1607
1620
|
const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
|
|
1608
|
-
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access',
|
|
1621
|
+
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _120 => _120[0], 'optionalAccess', _121 => _121.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
|
|
1609
1622
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
1610
1623
|
}
|
|
1611
1624
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -1707,7 +1720,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
1707
1720
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
1708
1721
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
1709
1722
|
const bar = cur.find(isBarItem);
|
|
1710
|
-
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access',
|
|
1723
|
+
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _122 => _122[0], 'optionalAccess', _123 => _123[0]]), () => ( cur[0].y));
|
|
1711
1724
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
1712
1725
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
1713
1726
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -2053,7 +2066,7 @@ function joinVerticalColumns(items) {
|
|
|
2053
2066
|
const groups = [];
|
|
2054
2067
|
for (const col of columns) {
|
|
2055
2068
|
const g2 = groups[groups.length - 1];
|
|
2056
|
-
const last = _optionalChain([g2, 'optionalAccess',
|
|
2069
|
+
const last = _optionalChain([g2, 'optionalAccess', _124 => _124[g2.length - 1]]);
|
|
2057
2070
|
const fs = col.items[0].fontSize;
|
|
2058
2071
|
if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
|
|
2059
2072
|
else groups.push([col]);
|
|
@@ -2239,7 +2252,7 @@ function relocateEndnotes(blocks) {
|
|
|
2239
2252
|
}
|
|
2240
2253
|
const shapes = /* @__PURE__ */ new Map();
|
|
2241
2254
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
2242
|
-
const main = _optionalChain([[...shapes], 'access',
|
|
2255
|
+
const main = _optionalChain([[...shapes], 'access', _125 => _125.sort, 'call', _126 => _126((a, b) => b[1] - a[1]), 'access', _127 => _127[0], 'optionalAccess', _128 => _128[0]]);
|
|
2243
2256
|
if (!main || !/#/.test(main)) return blocks;
|
|
2244
2257
|
const lastRun = (hs) => {
|
|
2245
2258
|
let run2 = [];
|
|
@@ -2377,7 +2390,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
2377
2390
|
open = true;
|
|
2378
2391
|
continue;
|
|
2379
2392
|
}
|
|
2380
|
-
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access',
|
|
2393
|
+
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _129 => _129.style, 'optionalAccess', _130 => _130.fontSize]), () => ( _optionalChain([b, 'access', _131 => _131.bbox, 'optionalAccess', _132 => _132.height]))), () => ( 10))) * 1.5;
|
|
2381
2394
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
2382
2395
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
2383
2396
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -2400,7 +2413,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
2400
2413
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
2401
2414
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
2402
2415
|
function isRunningHead(block, page, pageHeight) {
|
|
2403
|
-
const box = block.bbox, text = _optionalChain([block, 'access',
|
|
2416
|
+
const box = block.bbox, text = _optionalChain([block, 'access', _133 => _133.text, 'optionalAccess', _134 => _134.trim, 'call', _135 => _135()]);
|
|
2404
2417
|
if (!box || !text || !pageHeight) return false;
|
|
2405
2418
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
2406
2419
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -2408,7 +2421,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
2408
2421
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
2409
2422
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
2410
2423
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
2411
|
-
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access',
|
|
2424
|
+
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _136 => _136.style, 'optionalAccess', _137 => _137.fontSize]), () => ( 0))) * 1.6) return true;
|
|
2412
2425
|
if (!text.includes(" ")) return false;
|
|
2413
2426
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
2414
2427
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -2417,7 +2430,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
2417
2430
|
return right > left && box.width >= (right - left) * 0.6;
|
|
2418
2431
|
}
|
|
2419
2432
|
function unbalancedClose(text) {
|
|
2420
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
2433
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _138 => _138.match, 'call', _139 => _139(/\)/g), 'optionalAccess', _140 => _140.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _141 => _141.match, 'call', _142 => _142(/\(/g), 'optionalAccess', _143 => _143.length]), () => ( 0)));
|
|
2421
2434
|
}
|
|
2422
2435
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
2423
2436
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -2433,7 +2446,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2433
2446
|
const sizes = /* @__PURE__ */ new Map();
|
|
2434
2447
|
let proseChars = 0;
|
|
2435
2448
|
for (const b of page) {
|
|
2436
|
-
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access',
|
|
2449
|
+
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _144 => _144.style, 'optionalAccess', _145 => _145.fontName]) || !b.style.fontSize) continue;
|
|
2437
2450
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
2438
2451
|
chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
|
|
2439
2452
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
@@ -2458,49 +2471,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
2458
2471
|
const block = blocks[i];
|
|
2459
2472
|
if (block.type !== "heading" || !block.text) continue;
|
|
2460
2473
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
2461
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
2462
|
-
const tocEntry = i > 0 &&
|
|
2474
|
+
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _146 => _146.style, 'optionalAccess', _147 => _147.fontSize]), () => ( 0));
|
|
2475
|
+
const tocEntry = i > 0 && _chunkWN5YLP7Hcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkWN5YLP7Hcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
2463
2476
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
2464
|
-
const proseStyle = _optionalChain([block, 'access',
|
|
2477
|
+
const proseStyle = _optionalChain([block, 'access', _148 => _148.style, 'optionalAccess', _149 => _149.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
2465
2478
|
const next = blocks[i + 1];
|
|
2466
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
2467
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
2468
|
-
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess',
|
|
2479
|
+
const nb = _optionalChain([next, 'optionalAccess', _150 => _150.bbox]), bb = block.bbox;
|
|
2480
|
+
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _151 => _151.style, 'optionalAccess', _152 => _152.fontSize]), () => ( 0))) * 1.2 && Math.abs(bb.x - nb.x) > fsz && Math.abs(bb.x + bb.width / 2 - (nb.x + nb.width / 2)) < nb.width * 0.1;
|
|
2481
|
+
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _153 => _153.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
|
|
2469
2482
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
2470
2483
|
blocks.splice(i--, 1);
|
|
2471
2484
|
continue;
|
|
2472
2485
|
}
|
|
2473
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
2486
|
+
if ((_optionalChain([next, 'optionalAccess', _154 => _154.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _155 => _155.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontName]) === _optionalChain([block, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.fontName]) && _optionalChain([next, 'access', _160 => _160.style, 'optionalAccess', _161 => _161.fontSize]) === _optionalChain([block, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
|
|
2474
2487
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
2475
2488
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
2476
2489
|
blocks.splice(i + 1, 1);
|
|
2477
2490
|
}
|
|
2478
2491
|
const after = blocks[i + 2];
|
|
2479
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
2492
|
+
if ((_optionalChain([next, 'optionalAccess', _164 => _164.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _165 => _165.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _166 => _166.text, 'optionalAccess', _167 => _167.trim, 'call', _168 => _168()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _169 => _169.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontSize]) === _optionalChain([block, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontSize])) {
|
|
2480
2493
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
2481
2494
|
blocks.splice(i + 1, 2);
|
|
2482
2495
|
}
|
|
2483
2496
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
2484
2497
|
const prev = blocks[i - 1];
|
|
2485
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
2498
|
+
if (_optionalChain([prev, 'optionalAccess', _174 => _174.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _175 => _175.text, 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
|
|
2486
2499
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
2487
2500
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
2488
2501
|
blocks.splice(i--, 1);
|
|
2489
2502
|
continue;
|
|
2490
2503
|
}
|
|
2491
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
2504
|
+
if (_optionalChain([prev, 'optionalAccess', _178 => _178.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _179 => _179.text, 'optionalAccess', _180 => _180.trim, 'call', _181 => _181()]), () => ( ""))) && prev.bbox && block.bbox && fsz > 0 && (Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x && block.bbox.x - (prev.bbox.x + prev.bbox.width) < fsz * 3 || Math.abs(prev.bbox.x - block.bbox.x) < 2 && (_nullishCoalesce(_optionalChain([prev, 'access', _182 => _182.style, 'optionalAccess', _183 => _183.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
|
|
2492
2505
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
2493
2506
|
blocks.splice(i - 1, 1);
|
|
2494
2507
|
i -= 2;
|
|
2495
2508
|
continue;
|
|
2496
2509
|
}
|
|
2497
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
2498
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
2499
|
-
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess',
|
|
2510
|
+
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _184 => _184.style, 'optionalAccess', _185 => _185.fontSize]), () => ( 0));
|
|
2511
|
+
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _186 => _186.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontSize]), () => ( 0))) >= size * 1.3 && box.y - (next.bbox.y + next.bbox.height) <= size * 3 && Math.min(box.x + box.width, next.bbox.x + next.bbox.width) - Math.max(box.x, next.bbox.x) >= Math.min(box.width, next.bbox.width) * 0.5 && !page.some((o) => o !== block && o.bbox && o.bbox.y > box.y + box.height && o.type !== "image");
|
|
2512
|
+
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _191 => _191.get, 'call', _192 => _192(_nullishCoalesce(_optionalChain([block, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]), () => ( "")))]), () => ( ""));
|
|
2500
2513
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
2501
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
2502
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
2503
|
-
const crowdedOcr = _optionalChain([block, 'access',
|
|
2514
|
+
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _195 => _195[i - 1], 'optionalAccess', _196 => _196.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
|
|
2515
|
+
const ocrFragment = _optionalChain([block, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _199 => _199.match, 'call', _200 => _200(/\p{L}/gu), 'optionalAccess', _201 => _201.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
|
|
2516
|
+
const crowdedOcr = _optionalChain([block, 'access', _202 => _202.style, 'optionalAccess', _203 => _203.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _204 => _204.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _205 => _205.style, 'optionalAccess', _206 => _206.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _207 => _207.text, 'optionalAccess', _208 => _208.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
|
|
2504
2517
|
if (ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
|
|
2505
2518
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
2506
2519
|
block.type = "paragraph";
|
|
@@ -2535,28 +2548,28 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
2535
2548
|
function captionTableText(t) {
|
|
2536
2549
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
2537
2550
|
const [label, body] = t.cells[0];
|
|
2538
|
-
if (!label || !body || _optionalChain([label, 'access',
|
|
2551
|
+
if (!label || !body || _optionalChain([label, 'access', _209 => _209.blocks, 'optionalAccess', _210 => _210.length]) || _optionalChain([body, 'access', _211 => _211.blocks, 'optionalAccess', _212 => _212.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
|
|
2539
2552
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
2540
2553
|
}
|
|
2541
2554
|
function splitSingleCellTables(blocks) {
|
|
2542
2555
|
const out = [];
|
|
2543
2556
|
for (const b of blocks) {
|
|
2544
2557
|
const t = b.type === "table" ? b.table : void 0;
|
|
2545
|
-
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access',
|
|
2558
|
+
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _213 => _213.cells, 'access', _214 => _214[0], 'optionalAccess', _215 => _215[0], 'optionalAccess', _216 => _216.blocks, 'optionalAccess', _217 => _217.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
|
|
2546
2559
|
const squash = (s) => s.replace(/\s/g, "");
|
|
2547
2560
|
const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
|
|
2548
|
-
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess',
|
|
2561
|
+
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _218 => _218.type]) === "table" ? captionTableText(inner.table) : null)));
|
|
2549
2562
|
if (caption) {
|
|
2550
2563
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
2551
2564
|
continue;
|
|
2552
2565
|
}
|
|
2553
|
-
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access',
|
|
2554
|
-
if (!cell || _optionalChain([cell, 'access',
|
|
2566
|
+
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _219 => _219.cells, 'access', _220 => _220[0], 'optionalAccess', _221 => _221[0]]) : void 0;
|
|
2567
|
+
if (!cell || _optionalChain([cell, 'access', _222 => _222.blocks, 'optionalAccess', _223 => _223.some, 'call', _224 => _224((x) => x.type === "table")])) {
|
|
2555
2568
|
out.push(b);
|
|
2556
2569
|
continue;
|
|
2557
2570
|
}
|
|
2558
2571
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
2559
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
2572
|
+
if (_optionalChain([t, 'optionalAccess', _225 => _225.caption, 'optionalAccess', _226 => _226.trim, 'call', _227 => _227()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
|
|
2560
2573
|
for (const text of lines) out.push({ type: "paragraph", text, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
2561
2574
|
}
|
|
2562
2575
|
return out;
|
|
@@ -2569,7 +2582,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
2569
2582
|
const lines = cell.text.split("\n");
|
|
2570
2583
|
const out = [lines[0]];
|
|
2571
2584
|
for (const line of lines.slice(1)) {
|
|
2572
|
-
if (
|
|
2585
|
+
if (_chunkWN5YLP7Hcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
2573
2586
|
else out.push(line);
|
|
2574
2587
|
}
|
|
2575
2588
|
cell.text = out.join("\n");
|
|
@@ -2580,19 +2593,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
2580
2593
|
}
|
|
2581
2594
|
function cleanPdfText(text, opts) {
|
|
2582
2595
|
let clean = normalizeAraea(stripControlChars(text));
|
|
2583
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
2596
|
+
if (!_optionalChain([opts, 'optionalAccess', _228 => _228.keepLoneNumbers])) {
|
|
2584
2597
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
2585
2598
|
}
|
|
2586
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
2599
|
+
if (!_optionalChain([opts, 'optionalAccess', _229 => _229.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
2587
2600
|
return mergeKoreanLines(
|
|
2588
2601
|
clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
|
|
2589
2602
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
2590
2603
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
2591
2604
|
if (line.startsWith("|")) {
|
|
2592
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
2605
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkWN5YLP7Hcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
2593
2606
|
}
|
|
2594
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
2595
|
-
return mark +
|
|
2607
|
+
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _230 => _230.exec, 'call', _231 => _231(line), 'optionalAccess', _232 => _232[0]]), () => ( ""));
|
|
2608
|
+
return mark + _chunkWN5YLP7Hcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
2596
2609
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
2597
2610
|
}
|
|
2598
2611
|
function startsWithMarker(line) {
|
|
@@ -2624,7 +2637,7 @@ function mergeKoreanLines(text) {
|
|
|
2624
2637
|
continue;
|
|
2625
2638
|
}
|
|
2626
2639
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
2627
|
-
result[result.length - 1] = prev +
|
|
2640
|
+
result[result.length - 1] = prev + _chunkWN5YLP7Hcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
2628
2641
|
} else {
|
|
2629
2642
|
result.push(curr);
|
|
2630
2643
|
}
|
|
@@ -2640,7 +2653,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
2640
2653
|
const wrapped = /* @__PURE__ */ new Set();
|
|
2641
2654
|
for (const a of annots) {
|
|
2642
2655
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
2643
|
-
const url =
|
|
2656
|
+
const url = _chunkSHRRD2TDcjs.sanitizeHref.call(void 0, a.url);
|
|
2644
2657
|
if (!url) continue;
|
|
2645
2658
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
2646
2659
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -2681,7 +2694,7 @@ function mergeLinkRuns(markdown) {
|
|
|
2681
2694
|
|
|
2682
2695
|
// src/pdf/formula-ocr.ts
|
|
2683
2696
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
2684
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
2697
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-BQ5RW5XD.cjs")));
|
|
2685
2698
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
2686
2699
|
await ensureFormulaModels((p) => {
|
|
2687
2700
|
if (p.phase === "download" && p.total) {
|
|
@@ -2860,13 +2873,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
2860
2873
|
try {
|
|
2861
2874
|
return await Promise.race([
|
|
2862
2875
|
loadingTask.promise.catch((e) => {
|
|
2863
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
2876
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkSHRRD2TDcjs.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)");
|
|
2864
2877
|
throw e;
|
|
2865
2878
|
}),
|
|
2866
2879
|
new Promise((_, reject) => {
|
|
2867
2880
|
timer = setTimeout(() => {
|
|
2868
2881
|
loadingTask.destroy();
|
|
2869
|
-
reject(new (0,
|
|
2882
|
+
reject(new (0, _chunkSHRRD2TDcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
2870
2883
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
2871
2884
|
})
|
|
2872
2885
|
]);
|
|
@@ -2875,13 +2888,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
2875
2888
|
}
|
|
2876
2889
|
}
|
|
2877
2890
|
async function parsePdfDocument(buffer, options) {
|
|
2878
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
2879
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
2880
|
-
const ocrBuffer = _optionalChain([options, 'optionalAccess',
|
|
2891
|
+
const formulaBuffer = _optionalChain([options, 'optionalAccess', _233 => _233.formulaOcr]) ? buffer : null;
|
|
2892
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _234 => _234.ocr]) === void 0 && await _chunkWN5YLP7Hcjs.ocrModelsCached.call(void 0, );
|
|
2893
|
+
const ocrBuffer = _optionalChain([options, 'optionalAccess', _235 => _235.ocr]) || autoOcr ? buffer : null;
|
|
2881
2894
|
const doc = await loadPdfWithTimeout(buffer);
|
|
2882
2895
|
try {
|
|
2883
2896
|
const pageCount = doc.numPages;
|
|
2884
|
-
if (pageCount === 0) throw new (0,
|
|
2897
|
+
if (pageCount === 0) throw new (0, _chunkSHRRD2TDcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
2885
2898
|
const metadata = { pageCount, pageMode: "layout" };
|
|
2886
2899
|
await extractPdfMetadata(doc, metadata);
|
|
2887
2900
|
const blocks = [];
|
|
@@ -2890,8 +2903,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2890
2903
|
let totalChars = 0;
|
|
2891
2904
|
let totalTextBytes = 0;
|
|
2892
2905
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
2893
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
2894
|
-
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess',
|
|
2906
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _236 => _236.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
2907
|
+
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _237 => _237.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
|
|
2895
2908
|
warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
|
|
2896
2909
|
}
|
|
2897
2910
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -2908,7 +2921,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2908
2921
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
2909
2922
|
const carry = {};
|
|
2910
2923
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
2911
|
-
const wrapLexicon = new (0,
|
|
2924
|
+
const wrapLexicon = new (0, _chunkWN5YLP7Hcjs.WrapLexicon)();
|
|
2912
2925
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
2913
2926
|
let parsedPages = 0;
|
|
2914
2927
|
for (let i = 1; i <= effectivePageCount; i++) {
|
|
@@ -2931,13 +2944,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2931
2944
|
return void 0;
|
|
2932
2945
|
}
|
|
2933
2946
|
};
|
|
2934
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
2935
|
-
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call',
|
|
2947
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _238 => _238(loadedName), 'optionalAccess', _239 => _239.differences]);
|
|
2948
|
+
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _240 => _240(n), 'optionalAccess', _241 => _241.name]));
|
|
2936
2949
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
2937
2950
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
2938
2951
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
2939
|
-
const items =
|
|
2940
|
-
const filtered =
|
|
2952
|
+
const items = _chunkWN5YLP7Hcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
2953
|
+
const filtered = _chunkWN5YLP7Hcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
2941
2954
|
const joined = joinVerticalColumns(filtered.visible);
|
|
2942
2955
|
const visible = dropTabLeaderDots(joined);
|
|
2943
2956
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -2961,7 +2974,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2961
2974
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
2962
2975
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
2963
2976
|
} : rawOps;
|
|
2964
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
2977
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _242 => _242(loadedName), 'optionalAccess', _243 => _243.name]));
|
|
2965
2978
|
remapControlGlyphs(visible, differencesOf);
|
|
2966
2979
|
const faces = /* @__PURE__ */ new Map();
|
|
2967
2980
|
for (const it of visible) {
|
|
@@ -2969,18 +2982,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
2969
2982
|
let face = faces.get(it.fontName);
|
|
2970
2983
|
if (face === void 0) {
|
|
2971
2984
|
const obj = fontObj(it.fontName);
|
|
2972
|
-
face = _optionalChain([obj, 'optionalAccess',
|
|
2985
|
+
face = _optionalChain([obj, 'optionalAccess', _244 => _244.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
|
|
2973
2986
|
faces.set(it.fontName, face);
|
|
2974
2987
|
}
|
|
2975
2988
|
it.fontName = face;
|
|
2976
|
-
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call',
|
|
2989
|
+
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _245 => _245(face), 'optionalAccess', _246 => _246.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
2977
2990
|
}
|
|
2978
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
2979
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
2991
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunk2ZBLQVAScjs.escapeLiteralDollar.call(void 0, it.text);
|
|
2992
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunk2ZBLQVAScjs.escapeLiteralTags.call(void 0, it.text);
|
|
2980
2993
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
2981
2994
|
const pageArea = pageW * pageH;
|
|
2982
2995
|
if (pageArea > 0) {
|
|
2983
|
-
const imageRegions =
|
|
2996
|
+
const imageRegions = _chunkWN5YLP7Hcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
2984
2997
|
let uncovered = 0;
|
|
2985
2998
|
for (const r of imageRegions) {
|
|
2986
2999
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3006,14 +3019,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3006
3019
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3007
3020
|
}
|
|
3008
3021
|
const marks = superscriptNoteMarks(visible);
|
|
3009
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3022
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkWN5YLP7Hcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3010
3023
|
const stamp = marginStamp(visible);
|
|
3011
3024
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3012
|
-
const pageBlocks = orderTwoUpPage(
|
|
3025
|
+
const pageBlocks = orderTwoUpPage(_chunkWN5YLP7Hcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _247 => _247.tables]) !== false, carry, wrapLexicon), pageW, pageH);
|
|
3013
3026
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3014
3027
|
for (const b of pageBlocks) blocks.push(b);
|
|
3015
3028
|
try {
|
|
3016
|
-
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess',
|
|
3029
|
+
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _248 => _248.images]) !== false);
|
|
3017
3030
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
3018
3031
|
extractedImages.push(...pageImages);
|
|
3019
3032
|
} catch (e6) {
|
|
@@ -3032,27 +3045,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3032
3045
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
3033
3046
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
3034
3047
|
pageQuality.push(quality);
|
|
3035
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3048
|
+
if (_optionalChain([options, 'optionalAccess', _249 => _249.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3036
3049
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3037
3050
|
}
|
|
3038
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3051
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkSHRRD2TDcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3039
3052
|
parsedPages++;
|
|
3040
|
-
_optionalChain([options, 'optionalAccess',
|
|
3053
|
+
_optionalChain([options, 'optionalAccess', _250 => _250.onProgress, 'optionalCall', _251 => _251(parsedPages, totalTarget)]);
|
|
3041
3054
|
} catch (pageErr) {
|
|
3042
|
-
if (pageErr instanceof
|
|
3055
|
+
if (pageErr instanceof _chunkSHRRD2TDcjs.KordocError) throw pageErr;
|
|
3043
3056
|
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" });
|
|
3044
3057
|
} finally {
|
|
3045
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
3058
|
+
_optionalChain([loadedPage, 'optionalAccess', _252 => _252.cleanup, 'call', _253 => _253()]);
|
|
3046
3059
|
}
|
|
3047
3060
|
}
|
|
3048
3061
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
3049
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
3062
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _254 => _254.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
3050
3063
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
3051
|
-
const ocrRegions = _optionalChain([options, 'optionalAccess',
|
|
3064
|
+
const ocrRegions = _optionalChain([options, 'optionalAccess', _255 => _255.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _256 => _256.ocr]) === true) : /* @__PURE__ */ new Map();
|
|
3052
3065
|
if (ocrBuffer) {
|
|
3053
3066
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
3054
3067
|
const targets = /* @__PURE__ */ new Set();
|
|
3055
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3068
|
+
if (_optionalChain([options, 'optionalAccess', _257 => _257.ocr]) === "force" || isImageBased) {
|
|
3056
3069
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
3057
3070
|
} else {
|
|
3058
3071
|
for (const pq of pageQuality) {
|
|
@@ -3065,16 +3078,16 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3065
3078
|
}
|
|
3066
3079
|
if (targets.size > 0) {
|
|
3067
3080
|
try {
|
|
3068
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3069
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
3070
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
3071
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
3072
|
-
for (const obs of ocrPageBlocks.values())
|
|
3081
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-NF4AY5MI.cjs")));
|
|
3082
|
+
const mode = typeof _optionalChain([options, 'optionalAccess', _258 => _258.ocr]) === "function" ? options.ocr : "builtin";
|
|
3083
|
+
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _259 => _259.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _260 => _260.find, 'call', _261 => _261((q) => q.page === p), 'optionalAccess', _262 => _262.needsOcr])));
|
|
3084
|
+
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _263 => _263.onProgress]), _optionalChain([options, 'optionalAccess', _264 => _264.tables]) !== false, vectorPageOps, regionPages);
|
|
3085
|
+
for (const obs of ocrPageBlocks.values()) _chunk2ZBLQVAScjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3073
3086
|
if (ocrPageBlocks.size > 0) {
|
|
3074
3087
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3075
3088
|
for (const [p, obs] of ocrPageBlocks) {
|
|
3076
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
3077
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3089
|
+
const needsOcr = _optionalChain([pageQuality, 'access', _265 => _265.find, 'call', _266 => _266((q) => q.page === p), 'optionalAccess', _267 => _267.needsOcr]);
|
|
3090
|
+
if (_optionalChain([options, 'optionalAccess', _268 => _268.ocr]) === "force" || isImageBased || needsOcr) {
|
|
3078
3091
|
replacePages.add(p);
|
|
3079
3092
|
ocrDone.add(p);
|
|
3080
3093
|
continue;
|
|
@@ -3082,7 +3095,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3082
3095
|
const regions = ocrRegions.get(p);
|
|
3083
3096
|
if (!regions || mergeOcrImageRegions(blocks, p, regions, obs) === 0) continue;
|
|
3084
3097
|
ocrDone.add(p);
|
|
3085
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
3098
|
+
if (_optionalChain([pageImageBlocks, 'access', _269 => _269.get, 'call', _270 => _270(p), 'optionalAccess', _271 => _271.length]) === 1) pageImageBlocks.delete(p);
|
|
3086
3099
|
}
|
|
3087
3100
|
if (replacePages.size) {
|
|
3088
3101
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -3132,12 +3145,12 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3132
3145
|
warnings.push({ page, message: `${count}\uAC1C \uC774\uBBF8\uC9C0 \uC601\uC5ED\uC5D0 \uCD94\uCD9C \uAC00\uB2A5\uD55C \uD14D\uC2A4\uD2B8 \uC5C6\uC74C (\uADF8\uB9BC/\uCC28\uD2B8/\uB3C4\uC7A5 \uB0B4\uC6A9 \uB204\uB77D \uAC00\uB2A5 \u2014 \uADF8\uB9BC \uC18D \uAE00\uC740 ocr: true / CLI --ocr \uB85C \uC77D\uC2B5\uB2C8\uB2E4)`, code: "SKIPPED_IMAGE" });
|
|
3133
3146
|
}
|
|
3134
3147
|
}
|
|
3135
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3136
|
-
const removed =
|
|
3148
|
+
if (_optionalChain([options, 'optionalAccess', _272 => _272.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3149
|
+
const removed = _chunkWN5YLP7Hcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks);
|
|
3137
3150
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3138
3151
|
blocks.splice(removed[ri], 1);
|
|
3139
3152
|
}
|
|
3140
|
-
const kept =
|
|
3153
|
+
const kept = _chunkWN5YLP7Hcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3141
3154
|
if (kept !== blocks) {
|
|
3142
3155
|
blocks.length = 0;
|
|
3143
3156
|
blocks.push(...kept);
|
|
@@ -3145,15 +3158,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3145
3158
|
}
|
|
3146
3159
|
mergeContinuedCells(blocks, pageHeights);
|
|
3147
3160
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3148
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3149
|
-
const boxes =
|
|
3161
|
+
if (_optionalChain([options, 'optionalAccess', _273 => _273.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3162
|
+
const boxes = _chunkWN5YLP7Hcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3150
3163
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3151
3164
|
}
|
|
3152
3165
|
splitContactTables(blocks);
|
|
3153
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3154
|
-
|
|
3166
|
+
if (!_optionalChain([options, 'optionalAccess', _274 => _274.keepTrailingEmptyCols])) _chunkWN5YLP7Hcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3167
|
+
_chunkWN5YLP7Hcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3155
3168
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3156
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3169
|
+
if (_optionalChain([options, 'optionalAccess', _275 => _275.formulaOcr]) && formulaBuffer) {
|
|
3157
3170
|
try {
|
|
3158
3171
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
3159
3172
|
} catch (e) {
|
|
@@ -3163,49 +3176,49 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3163
3176
|
});
|
|
3164
3177
|
}
|
|
3165
3178
|
}
|
|
3166
|
-
const medianFontSize =
|
|
3179
|
+
const medianFontSize = _chunkWN5YLP7Hcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3167
3180
|
if (medianFontSize > 0) {
|
|
3168
|
-
|
|
3169
|
-
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3181
|
+
_chunkWN5YLP7Hcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3182
|
+
}
|
|
3183
|
+
_chunkWN5YLP7Hcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3184
|
+
_chunkWN5YLP7Hcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3185
|
+
_chunkWN5YLP7Hcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3186
|
+
_chunkWN5YLP7Hcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3187
|
+
_chunkWN5YLP7Hcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3188
|
+
_chunkWN5YLP7Hcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3189
|
+
_chunkWN5YLP7Hcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3190
|
+
_chunkWN5YLP7Hcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3178
3191
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3179
|
-
|
|
3180
|
-
|
|
3192
|
+
_chunkWN5YLP7Hcjs.detectTableCaptions.call(void 0, blocks);
|
|
3193
|
+
_chunkWN5YLP7Hcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3181
3194
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3182
3195
|
sanitizeBlockControlChars(blocks);
|
|
3183
3196
|
let outBlocks = splitSingleCellTables(blocks);
|
|
3184
3197
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
3185
3198
|
outBlocks = relocateEndnotes(outBlocks);
|
|
3186
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3199
|
+
if (_optionalChain([options, 'optionalAccess', _276 => _276.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
3187
3200
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
3188
3201
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
3189
3202
|
if (!b.bbox || !h) return false;
|
|
3190
3203
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
3191
3204
|
});
|
|
3192
3205
|
joinLatinCellWraps(outBlocks);
|
|
3193
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3206
|
+
if (_optionalChain([options, 'optionalAccess', _277 => _277.layoutTables]) !== "keep") {
|
|
3194
3207
|
const hancom = await isHancomPdf(doc);
|
|
3195
3208
|
const shown = /* @__PURE__ */ new Map();
|
|
3196
3209
|
const markContent = (bs) => {
|
|
3197
3210
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3198
|
-
if (
|
|
3211
|
+
if (_chunkWN5YLP7Hcjs.IMAGE_CELLS.has(c)) _chunk2ZBLQVAScjs.CONTENT_CELLS.add(c);
|
|
3199
3212
|
markContent(c.blocks);
|
|
3200
3213
|
}
|
|
3201
3214
|
};
|
|
3202
3215
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3203
3216
|
if (b.type !== "table") return [b];
|
|
3204
|
-
if (!hancom && b.table &&
|
|
3217
|
+
if (!hancom && b.table && _chunkWN5YLP7Hcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3205
3218
|
let v = shown.get(b);
|
|
3206
3219
|
if (!v) {
|
|
3207
3220
|
markContent([b]);
|
|
3208
|
-
shown.set(b, v =
|
|
3221
|
+
shown.set(b, v = _chunk2ZBLQVAScjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _278 => _278.keepTrailingEmptyCols])));
|
|
3209
3222
|
}
|
|
3210
3223
|
return v;
|
|
3211
3224
|
});
|
|
@@ -3214,11 +3227,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3214
3227
|
blocks.length = 0;
|
|
3215
3228
|
for (const b of kept) blocks.push(b);
|
|
3216
3229
|
}
|
|
3217
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3230
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunk2ZBLQVAScjs.blocksToMarkdown.call(void 0, bs), { keepLoneNumbers: true }));
|
|
3218
3231
|
let markdown = finishMarkdown(outBlocks);
|
|
3219
3232
|
return {
|
|
3220
3233
|
markdown,
|
|
3221
|
-
pages:
|
|
3234
|
+
pages: _chunkV4BKT65Dcjs.blocksToPages.call(void 0, outBlocks, finishMarkdown),
|
|
3222
3235
|
blocks,
|
|
3223
3236
|
metadata,
|
|
3224
3237
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3236,7 +3249,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3236
3249
|
async function extractPdfMetadata(doc, metadata) {
|
|
3237
3250
|
try {
|
|
3238
3251
|
const result = await doc.getMetadata();
|
|
3239
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
3252
|
+
if (!_optionalChain([result, 'optionalAccess', _279 => _279.info])) return;
|
|
3240
3253
|
const info = result.info;
|
|
3241
3254
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
3242
3255
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -3252,8 +3265,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
3252
3265
|
}
|
|
3253
3266
|
async function isHancomPdf(doc) {
|
|
3254
3267
|
try {
|
|
3255
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
3256
|
-
return [_optionalChain([info, 'optionalAccess',
|
|
3268
|
+
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _280 => _280.info]);
|
|
3269
|
+
return [_optionalChain([info, 'optionalAccess', _281 => _281.Producer]), _optionalChain([info, 'optionalAccess', _282 => _282.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
|
|
3257
3270
|
} catch (e8) {
|
|
3258
3271
|
return false;
|
|
3259
3272
|
}
|
|
@@ -3296,5 +3309,5 @@ function marginStamp(items) {
|
|
|
3296
3309
|
|
|
3297
3310
|
|
|
3298
3311
|
|
|
3299
|
-
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3300
|
-
//# sourceMappingURL=parser-
|
|
3312
|
+
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkWN5YLP7Hcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkWN5YLP7Hcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkWN5YLP7Hcjs.removeHeaderFooterBlocks;
|
|
3313
|
+
//# sourceMappingURL=parser-JOMFOZLH.cjs.map
|