kordoc 4.22.1 → 4.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/dist/{-FYKHW5G6.js → -AOWV7MNY.js} +11 -11
- package/dist/{chunk-QH4B3PL7.js → chunk-24YLYR6Q.js} +4 -4
- package/dist/{chunk-OSFB5SQS.cjs → chunk-2BCQVQO2.cjs} +3 -3
- package/dist/{chunk-OSFB5SQS.cjs.map → chunk-2BCQVQO2.cjs.map} +1 -1
- package/dist/{chunk-5VBAHUGC.js → chunk-3ANXRVI2.js} +3 -3
- package/dist/{chunk-IB5TO2CO.js → chunk-3H2IEU4V.js} +2 -2
- package/dist/{chunk-MDS3GH43.js → chunk-4NQ4EZEE.js} +14 -4
- package/dist/chunk-4NQ4EZEE.js.map +1 -0
- package/dist/{chunk-7FASIFQP.js → chunk-6LIBF2ZB.js} +2 -2
- package/dist/{chunk-5SVJU22Z.js → chunk-6QBBGZST.js} +2 -2
- package/dist/{chunk-YE4IN3D7.js → chunk-7XITVUAK.js} +11 -11
- package/dist/{chunk-M4JC7TXG.js → chunk-AXX5AQT4.js} +4 -4
- package/dist/{chunk-AIAIBNIB.js → chunk-BS2XWGT5.js} +2 -2
- package/dist/{chunk-TSZQ4LMV.js → chunk-DKJ2RNDG.js} +2 -2
- package/dist/{chunk-7RND4SNB.js → chunk-FDFXL7VJ.js} +3 -3
- package/dist/{chunk-3SPOIAST.js → chunk-IRNWAHHZ.js} +2 -2
- package/dist/{chunk-SMPK5TUQ.js → chunk-J5PYESLX.js} +14 -4
- package/dist/chunk-J5PYESLX.js.map +1 -0
- package/dist/{chunk-5FD3LAKC.js → chunk-KBGNPGVY.js} +2 -2
- package/dist/{chunk-DOBJ7BW5.js → chunk-M2X766AY.js} +2 -2
- package/dist/{chunk-ME4NQSLE.js → chunk-MEIQ476H.js} +2 -2
- package/dist/{chunk-M2CBEXHN.cjs → chunk-MI655NV5.cjs} +2 -2
- package/dist/{chunk-M2CBEXHN.cjs.map → chunk-MI655NV5.cjs.map} +1 -1
- package/dist/{chunk-EXVTF6XE.cjs → chunk-NJEMRAIF.cjs} +24 -24
- package/dist/{chunk-EXVTF6XE.cjs.map → chunk-NJEMRAIF.cjs.map} +1 -1
- package/dist/{chunk-ZECSXHYP.cjs → chunk-NLGOMLGU.cjs} +188 -166
- package/dist/{chunk-ZECSXHYP.cjs.map → chunk-NLGOMLGU.cjs.map} +1 -1
- package/dist/{chunk-B35C5HJK.cjs → chunk-O3OS6FAW.cjs} +3 -3
- package/dist/{chunk-B35C5HJK.cjs.map → chunk-O3OS6FAW.cjs.map} +1 -1
- package/dist/{chunk-3H5QG6I2.js → chunk-O5E25RHU.js} +2 -2
- package/dist/{chunk-MGJYVNDX.js → chunk-OIF5HRVP.js} +29 -7
- package/dist/{chunk-JHHXTNZQ.js.map → chunk-OIF5HRVP.js.map} +1 -1
- package/dist/{chunk-RO7AORMO.cjs → chunk-SJ5OZXEL.cjs} +23 -13
- package/dist/chunk-SJ5OZXEL.cjs.map +1 -0
- package/dist/{chunk-JHHXTNZQ.js → chunk-SKRWKVVW.js} +28 -6
- package/dist/chunk-SKRWKVVW.js.map +1 -0
- package/dist/{chunk-LHO7E3RW.js → chunk-UCLDUUBX.js} +2 -2
- package/dist/{chunk-IK4W2M4P.js → chunk-VJCQOSMT.js} +2 -2
- package/dist/{chunk-ATODI25J.js → chunk-X45Q7EAC.js} +2 -2
- package/dist/{chunk-R37TFXMP.js → chunk-YOGMCRM7.js} +108 -29
- package/dist/chunk-YOGMCRM7.js.map +1 -0
- package/dist/chunks-7KXTS7IV.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-PYDSQGLS.cjs → formula-5V2WG4BH.cjs} +9 -9
- package/dist/{formula-PYDSQGLS.cjs.map → formula-5V2WG4BH.cjs.map} +1 -1
- package/dist/{formula-RUS4SF3O.js → formula-C26FMMGO.js} +3 -3
- package/dist/{formula-JBTYYSKB.js → formula-W4OL33YQ.js} +4 -4
- package/dist/{image-ocr-PLNNCEOR.cjs → image-ocr-BELHEWPX.cjs} +17 -17
- package/dist/{image-ocr-PLNNCEOR.cjs.map → image-ocr-BELHEWPX.cjs.map} +1 -1
- package/dist/{image-ocr-QJT4EIQU.js → image-ocr-NSQ34Y6T.js} +9 -9
- package/dist/{image-ocr-VA6WV6E4.js → image-ocr-T72HMX2W.js} +6 -6
- package/dist/index.cjs +507 -428
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -29
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-U2YY7ATC.js → model-bundle-34T2LJB4.js} +5 -5
- package/dist/{models-BOJ2SFCR.js → models-TQH5EM6V.js} +5 -5
- package/dist/{parse-worker-v2-ZHMFK3U3.js → parse-worker-v2-YEYLILGJ.js} +12 -12
- package/dist/{parser-A2EWLK2J.js → parser-E6BG3ECD.js} +133 -27
- package/dist/parser-E6BG3ECD.js.map +1 -0
- package/dist/{parser-6337Z4U2.cjs → parser-OAXCXVQ4.cjs} +383 -277
- package/dist/parser-OAXCXVQ4.cjs.map +1 -0
- package/dist/{parser-HM6N7J4R.js → parser-SJHCBL7T.js} +136 -30
- package/dist/parser-SJHCBL7T.js.map +1 -0
- package/dist/{pdf-ocr-JDER5BHI.js → pdf-ocr-LGPSJM22.js} +6 -6
- package/dist/pdf-ocr-RKXDY3ZA.cjs +31 -0
- package/dist/{pdf-ocr-PGXNUFU7.cjs.map → pdf-ocr-RKXDY3ZA.cjs.map} +1 -1
- package/dist/{pdf-ocr-MEVC6HXG.js → pdf-ocr-T5ASSUKK.js} +9 -9
- package/dist/{profile-io-OJ23SPYO.js → profile-io-KMCAFTMG.js} +3 -3
- package/dist/{rasterize-76CWCLSU.js → rasterize-M52AKY7R.js} +3 -3
- package/dist/{redact-doc-EZQIHRVT.js → redact-doc-SWJC27LL.js} +11 -11
- package/dist/{render-JZFJPFWK.js → render-45AB5YZR.js} +7 -7
- package/dist/seal-7KWG6VHS.js +10 -0
- package/dist/{setup-RIVS74JN.js → setup-5PBMUI6M.js} +3 -3
- package/dist/visual-OMJNXLNZ.js +21 -0
- package/dist/{watch-WMH222E5.js → watch-QOGKV52T.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-MDS3GH43.js.map +0 -1
- package/dist/chunk-MGJYVNDX.js.map +0 -1
- package/dist/chunk-R37TFXMP.js.map +0 -1
- package/dist/chunk-RO7AORMO.cjs.map +0 -1
- package/dist/chunk-SMPK5TUQ.js.map +0 -1
- package/dist/chunks-4XIAEJEX.js +0 -10
- package/dist/parser-6337Z4U2.cjs.map +0 -1
- package/dist/parser-A2EWLK2J.js.map +0 -1
- package/dist/parser-HM6N7J4R.js.map +0 -1
- package/dist/pdf-ocr-PGXNUFU7.cjs +0 -31
- package/dist/seal-P2NOP4LC.js +0 -10
- package/dist/visual-R5GGZBTU.js +0 -21
- /package/dist/{-FYKHW5G6.js.map → -AOWV7MNY.js.map} +0 -0
- /package/dist/{chunk-QH4B3PL7.js.map → chunk-24YLYR6Q.js.map} +0 -0
- /package/dist/{chunk-5VBAHUGC.js.map → chunk-3ANXRVI2.js.map} +0 -0
- /package/dist/{chunk-IB5TO2CO.js.map → chunk-3H2IEU4V.js.map} +0 -0
- /package/dist/{chunk-7FASIFQP.js.map → chunk-6LIBF2ZB.js.map} +0 -0
- /package/dist/{chunk-5SVJU22Z.js.map → chunk-6QBBGZST.js.map} +0 -0
- /package/dist/{chunk-YE4IN3D7.js.map → chunk-7XITVUAK.js.map} +0 -0
- /package/dist/{chunk-M4JC7TXG.js.map → chunk-AXX5AQT4.js.map} +0 -0
- /package/dist/{chunk-AIAIBNIB.js.map → chunk-BS2XWGT5.js.map} +0 -0
- /package/dist/{chunk-TSZQ4LMV.js.map → chunk-DKJ2RNDG.js.map} +0 -0
- /package/dist/{chunk-7RND4SNB.js.map → chunk-FDFXL7VJ.js.map} +0 -0
- /package/dist/{chunk-3SPOIAST.js.map → chunk-IRNWAHHZ.js.map} +0 -0
- /package/dist/{chunk-5FD3LAKC.js.map → chunk-KBGNPGVY.js.map} +0 -0
- /package/dist/{chunk-DOBJ7BW5.js.map → chunk-M2X766AY.js.map} +0 -0
- /package/dist/{chunk-ME4NQSLE.js.map → chunk-MEIQ476H.js.map} +0 -0
- /package/dist/{chunk-3H5QG6I2.js.map → chunk-O5E25RHU.js.map} +0 -0
- /package/dist/{chunk-LHO7E3RW.js.map → chunk-UCLDUUBX.js.map} +0 -0
- /package/dist/{chunk-IK4W2M4P.js.map → chunk-VJCQOSMT.js.map} +0 -0
- /package/dist/{chunk-ATODI25J.js.map → chunk-X45Q7EAC.js.map} +0 -0
- /package/dist/{chunks-4XIAEJEX.js.map → chunks-7KXTS7IV.js.map} +0 -0
- /package/dist/{formula-RUS4SF3O.js.map → formula-C26FMMGO.js.map} +0 -0
- /package/dist/{formula-JBTYYSKB.js.map → formula-W4OL33YQ.js.map} +0 -0
- /package/dist/{image-ocr-QJT4EIQU.js.map → image-ocr-NSQ34Y6T.js.map} +0 -0
- /package/dist/{image-ocr-VA6WV6E4.js.map → image-ocr-T72HMX2W.js.map} +0 -0
- /package/dist/{model-bundle-U2YY7ATC.js.map → model-bundle-34T2LJB4.js.map} +0 -0
- /package/dist/{models-BOJ2SFCR.js.map → models-TQH5EM6V.js.map} +0 -0
- /package/dist/{parse-worker-v2-ZHMFK3U3.js.map → parse-worker-v2-YEYLILGJ.js.map} +0 -0
- /package/dist/{pdf-ocr-JDER5BHI.js.map → pdf-ocr-LGPSJM22.js.map} +0 -0
- /package/dist/{pdf-ocr-MEVC6HXG.js.map → pdf-ocr-T5ASSUKK.js.map} +0 -0
- /package/dist/{profile-io-OJ23SPYO.js.map → profile-io-KMCAFTMG.js.map} +0 -0
- /package/dist/{rasterize-76CWCLSU.js.map → rasterize-M52AKY7R.js.map} +0 -0
- /package/dist/{redact-doc-EZQIHRVT.js.map → redact-doc-SWJC27LL.js.map} +0 -0
- /package/dist/{render-JZFJPFWK.js.map → render-45AB5YZR.js.map} +0 -0
- /package/dist/{seal-P2NOP4LC.js.map → seal-7KWG6VHS.js.map} +0 -0
- /package/dist/{setup-RIVS74JN.js.map → setup-5PBMUI6M.js.map} +0 -0
- /package/dist/{visual-R5GGZBTU.js.map → visual-OMJNXLNZ.js.map} +0 -0
- /package/dist/{watch-WMH222E5.js.map → watch-QOGKV52T.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"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 _chunk2BCQVQO2cjs = require('./chunk-2BCQVQO2.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -61,7 +61,7 @@ var _chunkJ55UQC5Hcjs = require('./chunk-J55UQC5H.cjs');
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunkNLGOMLGUcjs = require('./chunk-NLGOMLGU.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -75,12 +75,12 @@ var _chunkZECSXHYPcjs = require('./chunk-ZECSXHYP.cjs');
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
var
|
|
79
|
-
require('./chunk-
|
|
78
|
+
var _chunkSJ5OZXELcjs = require('./chunk-SJ5OZXEL.cjs');
|
|
79
|
+
require('./chunk-O3OS6FAW.cjs');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkMI655NV5cjs = require('./chunk-MI655NV5.cjs');
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -217,7 +217,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
217
217
|
const filename = `image_${String(state.imageIndex).padStart(3, "0")}.png`;
|
|
218
218
|
state.seen.set(hash, filename);
|
|
219
219
|
if (withBytes) {
|
|
220
|
-
const png =
|
|
220
|
+
const png = _chunk2BCQVQO2cjs.encodePng.call(void 0, w, h, rgba);
|
|
221
221
|
state.totalBytes += png.length;
|
|
222
222
|
images.push({ filename, data: png, mimeType: "image/png" });
|
|
223
223
|
}
|
|
@@ -613,7 +613,62 @@ function ocrVectorOps(opList, paths) {
|
|
|
613
613
|
|
|
614
614
|
// src/pdf/split-row-pattern.ts
|
|
615
615
|
var textOf = (cell) => cell.text.replace(/<\/?u>|~~/g, "").trim();
|
|
616
|
-
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !
|
|
616
|
+
var plain = (cell) => !_optionalChain([cell, 'access', _9 => _9.blocks, 'optionalAccess', _10 => _10.length]) && !_chunkNLGOMLGUcjs.IMAGE_CELLS.has(cell);
|
|
617
|
+
function matchesIndependentRowPair(table, owner, first) {
|
|
618
|
+
const norm = (cell) => textOf(cell).replace(/\s+/g, "");
|
|
619
|
+
const pairs = [];
|
|
620
|
+
for (let c = 0; c < table.cols; ) {
|
|
621
|
+
const u = _optionalChain([owner, 'access', _11 => _11[first - 1], 'optionalAccess', _12 => _12[c]]), d = _optionalChain([owner, 'access', _13 => _13[first], 'optionalAccess', _14 => _14[c]]);
|
|
622
|
+
if (u && u === d) {
|
|
623
|
+
c = u.c + u.cs;
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
627
|
+
if (!_optionalChain([upper, 'optionalAccess', _15 => _15.text, 'access', _16 => _16.trim, 'call', _17 => _17()]) && !_optionalChain([lower, 'optionalAccess', _18 => _18.text, 'access', _19 => _19.trim, 'call', _20 => _20()])) {
|
|
628
|
+
c++;
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
if (!u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !norm(upper) || !norm(lower)) return false;
|
|
632
|
+
pairs.push({ c, cs: u.cs, upper: norm(upper), lower: norm(lower) });
|
|
633
|
+
c += u.cs;
|
|
634
|
+
}
|
|
635
|
+
if (pairs.length < 2 || pairs.every((p) => p.upper === p.lower)) return false;
|
|
636
|
+
return table.cells.some((_, r) => {
|
|
637
|
+
if (r + 1 >= table.rows || r + 1 >= first - 1 && r <= first) return false;
|
|
638
|
+
return pairs.every((p) => [p.upper, p.lower].every((text, i) => {
|
|
639
|
+
const a = _optionalChain([owner, 'access', _21 => _21[r + i], 'optionalAccess', _22 => _22[p.c]]), cell = _optionalChain([table, 'access', _23 => _23.cells, 'access', _24 => _24[r + i], 'optionalAccess', _25 => _25[p.c]]);
|
|
640
|
+
return _optionalChain([a, 'optionalAccess', _26 => _26.r]) === r + i && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(cell) === text;
|
|
641
|
+
}));
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function matchesCompleteContextRow(table, owner, first) {
|
|
645
|
+
const norm = (s) => s.replace(/\s+/g, "");
|
|
646
|
+
const context = [];
|
|
647
|
+
let value;
|
|
648
|
+
for (let c = 0; c < table.cols; ) {
|
|
649
|
+
const u = _optionalChain([owner, 'access', _27 => _27[first - 1], 'optionalAccess', _28 => _28[c]]), d = _optionalChain([owner, 'access', _29 => _29[first], 'optionalAccess', _30 => _30[c]]);
|
|
650
|
+
if (u && u === d) {
|
|
651
|
+
const cell = table.cells[u.r][u.c];
|
|
652
|
+
if (u.r === first - 1 && u.rs === 2 && plain(cell) && textOf(cell)) context.push({ c, cs: u.cs, text: norm(textOf(cell)) });
|
|
653
|
+
c = u.c + u.cs;
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
const upper = u ? table.cells[u.r][u.c] : void 0, lower = d ? table.cells[d.r][d.c] : void 0;
|
|
657
|
+
if (!_optionalChain([upper, 'optionalAccess', _31 => _31.text, 'access', _32 => _32.trim, 'call', _33 => _33()]) && !_optionalChain([lower, 'optionalAccess', _34 => _34.text, 'access', _35 => _35.trim, 'call', _36 => _36()])) {
|
|
658
|
+
c++;
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
if (value || !u || !d || !upper || !lower || u.r !== first - 1 || d.r !== first || u.c !== c || d.c !== c || u.rs !== 1 || d.rs !== 1 || u.cs !== d.cs || !plain(upper) || !plain(lower) || !textOf(upper) || !textOf(lower)) return false;
|
|
662
|
+
value = { c, cs: u.cs, text: norm(textOf(upper) + textOf(lower)) };
|
|
663
|
+
c += u.cs;
|
|
664
|
+
}
|
|
665
|
+
if (!value || !context.length) return false;
|
|
666
|
+
const proof = [...context, value];
|
|
667
|
+
return table.cells.some((row, r) => r !== first - 1 && r !== first && proof.every((p) => {
|
|
668
|
+
const a = _optionalChain([owner, 'access', _37 => _37[r], 'optionalAccess', _38 => _38[p.c]]), cell = row[p.c];
|
|
669
|
+
return _optionalChain([a, 'optionalAccess', _39 => _39.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && !!cell && plain(cell) && norm(textOf(cell)) === p.text;
|
|
670
|
+
}));
|
|
671
|
+
}
|
|
617
672
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
618
673
|
const pairs = [];
|
|
619
674
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -639,7 +694,7 @@ function matchesCompleteSiblingRow(table, owner, first) {
|
|
|
639
694
|
const norm = (s, title) => (title ? s.replace(/^[가-힣]\.\s*/, "") : s).replace(/\s+/g, "");
|
|
640
695
|
return table.cells.some((row, r) => r !== first - 1 && r !== first && pairs.every((p) => {
|
|
641
696
|
const anchor = owner[r][p.c], peer = row[p.c];
|
|
642
|
-
return _optionalChain([anchor, 'optionalAccess',
|
|
697
|
+
return _optionalChain([anchor, 'optionalAccess', _40 => _40.r]) === r && anchor.c === p.c && anchor.rs === 1 && anchor.cs === p.cs && plain(peer) && norm(textOf(peer), p === main) === norm(textOf(p.upper) + "\n" + textOf(p.lower), p === main);
|
|
643
698
|
}));
|
|
644
699
|
}
|
|
645
700
|
function matchesCompleteRubricRow(table, owner, first) {
|
|
@@ -673,12 +728,47 @@ function matchesCompleteRubricRow(table, owner, first) {
|
|
|
673
728
|
return table.cells.some((row, r) => {
|
|
674
729
|
if (r === first - 1 || r === first || !pairs.every((p) => {
|
|
675
730
|
const a = owner[r][p.c];
|
|
676
|
-
return _optionalChain([a, 'optionalAccess',
|
|
731
|
+
return _optionalChain([a, 'optionalAccess', _41 => _41.r]) === r && a.c === p.c && a.rs === 1 && a.cs === p.cs && plain(row[p.c]);
|
|
677
732
|
})) return false;
|
|
678
733
|
const peer = textOf(row[main.c]), peerMarks = items(peer);
|
|
679
734
|
return peerMarks.length === marks.length && peerMarks.every((m, i) => m.n === marks[i].n) && values(row[score.c]).join("|") === scores.join("|") && norm(peer.slice(peerMarks[peerMarks.length - 1].at)) === tail;
|
|
680
735
|
});
|
|
681
736
|
}
|
|
737
|
+
var KO_ORDER = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558";
|
|
738
|
+
function itemMark(line) {
|
|
739
|
+
line = line.replace(/<\/?u>|~~/g, "").trim();
|
|
740
|
+
let m = /^(\d{1,2})([.)])(?!\d)/.exec(line);
|
|
741
|
+
if (m) return { style: "1" + m[2], n: +m[1] };
|
|
742
|
+
if (m = /^\((\d{1,2})\)/.exec(line)) return { style: "(1)", n: +m[1] };
|
|
743
|
+
if ((m = /^([가-하])([.)])/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "\uAC00" + m[2], n: KO_ORDER.indexOf(m[1]) };
|
|
744
|
+
if ((m = /^\(([가-하])\)/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "(\uAC00)", n: KO_ORDER.indexOf(m[1]) };
|
|
745
|
+
if (m = /^[①-⑳]/.exec(line)) return { style: "\u2460", n: m[0].charCodeAt(0) };
|
|
746
|
+
if (m = /^([A-Z])\.\s/.exec(line)) return { style: "A.", n: m[1].charCodeAt(0) };
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
function hasNumberedRowSequence(table, owner, first) {
|
|
750
|
+
if (first < 3) return false;
|
|
751
|
+
const rows = [first - 3, first - 2, first - 1, first];
|
|
752
|
+
const separate = (c, cs) => rows.every((r) => {
|
|
753
|
+
const a = _optionalChain([owner, 'access', _42 => _42[r], 'optionalAccess', _43 => _43[c]]), cell = _optionalChain([table, 'access', _44 => _44.cells, 'access', _45 => _45[r], 'optionalAccess', _46 => _46[c]]);
|
|
754
|
+
return _optionalChain([a, 'optionalAccess', _47 => _47.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
|
|
755
|
+
});
|
|
756
|
+
for (let c = 0; c < table.cols; c++) {
|
|
757
|
+
const a = _optionalChain([owner, 'access', _48 => _48[first], 'optionalAccess', _49 => _49[c]]);
|
|
758
|
+
if (!a || !separate(c, a.cs)) continue;
|
|
759
|
+
const marks = rows.map((r) => {
|
|
760
|
+
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
761
|
+
return firstMark && lines.slice(1).every((l) => !itemMark(l)) ? firstMark : null;
|
|
762
|
+
});
|
|
763
|
+
const head = marks[0];
|
|
764
|
+
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
765
|
+
for (let d = 0; d < table.cols; d++) {
|
|
766
|
+
const side = _optionalChain([owner, 'access', _50 => _50[first], 'optionalAccess', _51 => _51[d]]);
|
|
767
|
+
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
682
772
|
|
|
683
773
|
// src/pdf/contact-table.ts
|
|
684
774
|
var CONTACT_HEAD = /^(?:담당\s*부서|<[^<>]+>)$/;
|
|
@@ -697,8 +787,25 @@ function splitContactTables(blocks) {
|
|
|
697
787
|
const whole = PERSON.exec(r[3].text.replace(/\s+/g, " ").trim());
|
|
698
788
|
return whole ? [whole] : null;
|
|
699
789
|
});
|
|
700
|
-
if (people.some((p) => !p) || rows.some((r) =>
|
|
790
|
+
if (people.some((p) => !p) || rows.some((r) => r[3].rowSpan !== 1 || r[3].colSpan !== 1)) continue;
|
|
791
|
+
let roleEnd = 0;
|
|
792
|
+
const validRoles = rows.every((r, i) => {
|
|
793
|
+
const role = r[2];
|
|
794
|
+
if (role.colSpan !== 1) return false;
|
|
795
|
+
if (i < roleEnd) return !role.text.trim() && role.rowSpan === 1;
|
|
796
|
+
if (!CONTACT_ROLE.test(role.text.replace(/\s+/g, "")) || role.rowSpan < 1 || i + role.rowSpan > t.rows) return false;
|
|
797
|
+
roleEnd = i + role.rowSpan;
|
|
798
|
+
return true;
|
|
799
|
+
});
|
|
800
|
+
if (!validRoles) continue;
|
|
701
801
|
if (!people.some((p) => p.some(spaced))) continue;
|
|
802
|
+
const one = (text) => ({ text, colSpan: 1, rowSpan: 1 });
|
|
803
|
+
const part = (i, k) => one(people[i].map((p) => p[k]).join("\n"));
|
|
804
|
+
if (rows.some((r) => r[2].rowSpan > 1)) {
|
|
805
|
+
t.cells = rows.map((r, i) => [...r.slice(0, 3), part(i, 1), part(i, 2), part(i, 3)]);
|
|
806
|
+
t.cols = 6;
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
702
809
|
const lead = [];
|
|
703
810
|
let ok = true;
|
|
704
811
|
for (const c of [0, 1]) {
|
|
@@ -719,8 +826,6 @@ function splitContactTables(blocks) {
|
|
|
719
826
|
lead.push(col);
|
|
720
827
|
}
|
|
721
828
|
if (!ok) continue;
|
|
722
|
-
const one = (text) => ({ text, colSpan: 1, rowSpan: 1 });
|
|
723
|
-
const part = (i, k) => one(people[i].map((p) => p[k]).join("\n"));
|
|
724
829
|
t.cells = rows.map((r, i) => [one(lead[0][i]), one(lead[1][i]), one(r[2].text), part(i, 1), part(i, 2), part(i, 3)]);
|
|
725
830
|
t.cols = 6;
|
|
726
831
|
}
|
|
@@ -731,7 +836,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
|
731
836
|
function relocate(src, dst, from = 0) {
|
|
732
837
|
const out = [];
|
|
733
838
|
for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
|
|
734
|
-
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access',
|
|
839
|
+
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _52 => _52.at, 'call', _53 => _53(-1), 'optionalAccess', _54 => _54.at]), () => ( 0))));
|
|
735
840
|
if (at >= 0) out.push({ at, page: s.page });
|
|
736
841
|
}
|
|
737
842
|
return out;
|
|
@@ -755,7 +860,7 @@ function rowStarts(t) {
|
|
|
755
860
|
const starts = [];
|
|
756
861
|
for (let c = 0; c < t.cols; c++) {
|
|
757
862
|
if (covered.has(r * 1e5 + c)) continue;
|
|
758
|
-
const cell = _optionalChain([t, 'access',
|
|
863
|
+
const cell = _optionalChain([t, 'access', _55 => _55.cells, 'access', _56 => _56[r], 'optionalAccess', _57 => _57[c]]);
|
|
759
864
|
if (!cell) continue;
|
|
760
865
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
|
|
761
866
|
starts.push({ cell, c });
|
|
@@ -766,8 +871,8 @@ function rowStarts(t) {
|
|
|
766
871
|
}
|
|
767
872
|
var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
|
|
768
873
|
function cellPage(cell) {
|
|
769
|
-
const p =
|
|
770
|
-
if (p !== void 0 || !_optionalChain([cell, 'access',
|
|
874
|
+
const p = _chunkSJ5OZXELcjs.CELL_PAGES.get(cell);
|
|
875
|
+
if (p !== void 0 || !_optionalChain([cell, 'access', _58 => _58.blocks, 'optionalAccess', _59 => _59.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
771
876
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
772
877
|
}
|
|
773
878
|
function tableRowPages(t, pageNumber) {
|
|
@@ -778,7 +883,7 @@ function tableRowPages(t, pageNumber) {
|
|
|
778
883
|
for (const { cell } of starts) {
|
|
779
884
|
const p = cellPage(cell);
|
|
780
885
|
if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
|
|
781
|
-
else if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
886
|
+
else if (cell.text.trim() || _optionalChain([cell, 'access', _60 => _60.blocks, 'optionalAccess', _61 => _61.length])) text = true;
|
|
782
887
|
}
|
|
783
888
|
const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
|
|
784
889
|
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
|
|
@@ -795,8 +900,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
795
900
|
rows.forEach((starts, r) => {
|
|
796
901
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
797
902
|
for (const { cell } of starts) {
|
|
798
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
799
|
-
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess',
|
|
903
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkSJ5OZXELcjs.CELL_PAGES.set(cell, page2);
|
|
904
|
+
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _62 => _62.find, 'call', _63 => _63((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
800
905
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
801
906
|
}
|
|
802
907
|
});
|
|
@@ -806,7 +911,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
806
911
|
for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
|
|
807
912
|
const heads = covering(pt, pt.rows - 1);
|
|
808
913
|
for (const cell of covering(table, pt.rows - 1)) {
|
|
809
|
-
if (_optionalChain([cell, 'access',
|
|
914
|
+
if (_optionalChain([cell, 'access', _64 => _64.blocks, 'optionalAccess', _65 => _65.length])) continue;
|
|
810
915
|
const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
|
|
811
916
|
if (!head) continue;
|
|
812
917
|
const from = head.text.trimEnd().length;
|
|
@@ -817,7 +922,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
817
922
|
}
|
|
818
923
|
function splitCell(cell, page) {
|
|
819
924
|
if (page === void 0) return null;
|
|
820
|
-
if (_optionalChain([cell, 'access',
|
|
925
|
+
if (_optionalChain([cell, 'access', _66 => _66.blocks, 'optionalAccess', _67 => _67.length])) {
|
|
821
926
|
const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
|
|
822
927
|
if (k2 <= 0) return null;
|
|
823
928
|
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
@@ -844,8 +949,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
844
949
|
if (!splits.length) continue;
|
|
845
950
|
const clone = (cell, patch) => {
|
|
846
951
|
const out = { ...cell, ...patch };
|
|
847
|
-
const p =
|
|
848
|
-
if (p !== void 0)
|
|
952
|
+
const p = _chunkSJ5OZXELcjs.CELL_PAGES.get(cell);
|
|
953
|
+
if (p !== void 0) _chunkSJ5OZXELcjs.CELL_PAGES.set(out, p);
|
|
849
954
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
850
955
|
return out;
|
|
851
956
|
};
|
|
@@ -855,7 +960,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
855
960
|
for (const { cell, c, split } of splits) {
|
|
856
961
|
cells[r][c] = clone(cell, split.head);
|
|
857
962
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
858
|
-
|
|
963
|
+
_chunkSJ5OZXELcjs.CELL_PAGES.set(tail, split.page);
|
|
859
964
|
setSplits(tail, split.rest);
|
|
860
965
|
row[c] = tail;
|
|
861
966
|
}
|
|
@@ -897,7 +1002,7 @@ function anchorsOf(table) {
|
|
|
897
1002
|
for (let r = 0; r < table.rows; r++) {
|
|
898
1003
|
for (let c = 0; c < table.cols; c++) {
|
|
899
1004
|
if (covered.has(r * 1e5 + c)) continue;
|
|
900
|
-
const cell = _optionalChain([table, 'access',
|
|
1005
|
+
const cell = _optionalChain([table, 'access', _68 => _68.cells, 'access', _69 => _69[r], 'optionalAccess', _70 => _70[c]]);
|
|
901
1006
|
if (!cell) continue;
|
|
902
1007
|
out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
|
|
903
1008
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
@@ -974,24 +1079,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
974
1079
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
975
1080
|
}
|
|
976
1081
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
977
|
-
const lines =
|
|
978
|
-
if (lines)
|
|
979
|
-
if (
|
|
980
|
-
const edges =
|
|
1082
|
+
const lines = _chunkNLGOMLGUcjs.CELL_LINES.get(a.cell);
|
|
1083
|
+
if (lines) _chunkNLGOMLGUcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1084
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(a.cell)) _chunkNLGOMLGUcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1085
|
+
const edges = _chunkSJ5OZXELcjs.CELL_EDGES.get(a.cell);
|
|
981
1086
|
if (edges) {
|
|
982
|
-
|
|
1087
|
+
_chunkSJ5OZXELcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
983
1088
|
edged = true;
|
|
984
1089
|
}
|
|
985
1090
|
return true;
|
|
986
1091
|
};
|
|
987
|
-
for (const a of pa) if (!
|
|
1092
|
+
for (const a of pa) if (!_chunkNLGOMLGUcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
988
1093
|
for (const a of ca) {
|
|
989
|
-
if (a.r < skip ||
|
|
1094
|
+
if (a.r < skip || _chunkNLGOMLGUcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
990
1095
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
991
1096
|
}
|
|
992
1097
|
const first = prev.rows;
|
|
993
1098
|
for (let c = 0; c < cols; c++) {
|
|
994
|
-
const above = _optionalChain([owner, 'access',
|
|
1099
|
+
const above = _optionalChain([owner, 'access', _71 => _71[first - 1], 'optionalAccess', _72 => _72[c]]);
|
|
995
1100
|
if (!above) continue;
|
|
996
1101
|
let r = first;
|
|
997
1102
|
while (r < rows && owner[r][c] === null) r++;
|
|
@@ -1010,9 +1115,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1010
1115
|
const grown = { ...above, rs: newRs };
|
|
1011
1116
|
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;
|
|
1012
1117
|
}
|
|
1013
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1118
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkNLGOMLGUcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1014
1119
|
if (edged) {
|
|
1015
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1120
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkSJ5OZXELcjs.CELL_EDGES.set(grid[r][c], _chunkNLGOMLGUcjs.NO_EDGES);
|
|
1016
1121
|
}
|
|
1017
1122
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1018
1123
|
let r = prev.rows;
|
|
@@ -1021,7 +1126,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1021
1126
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1022
1127
|
}
|
|
1023
1128
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1024
|
-
const pr =
|
|
1129
|
+
const pr = _chunkNLGOMLGUcjs.ROW_RULES.get(prev), cr = _chunkNLGOMLGUcjs.ROW_RULES.get(curr);
|
|
1025
1130
|
const shifted = dx !== 0;
|
|
1026
1131
|
const cut = {
|
|
1027
1132
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1032,7 +1137,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1032
1137
|
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 });
|
|
1033
1138
|
if (pr && cr) {
|
|
1034
1139
|
const cutRuled = pr.bottom || cr.top;
|
|
1035
|
-
|
|
1140
|
+
_chunkNLGOMLGUcjs.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) });
|
|
1036
1141
|
}
|
|
1037
1142
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1038
1143
|
}
|
|
@@ -1093,19 +1198,19 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1093
1198
|
c = u.c + u.cs;
|
|
1094
1199
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1095
1200
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1096
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1097
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1201
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkNLGOMLGUcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1202
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkNLGOMLGUcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1098
1203
|
if (!r || r === first) return false;
|
|
1099
1204
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1100
1205
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1101
|
-
const ue =
|
|
1206
|
+
const ue = _chunkSJ5OZXELcjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkSJ5OZXELcjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1102
1207
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1103
1208
|
});
|
|
1104
1209
|
if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1105
1210
|
if (!straddles && !midWord) continue;
|
|
1106
1211
|
if (u.r >= last && d.rs < 2) continue;
|
|
1107
|
-
const U =
|
|
1108
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1212
|
+
const U = _chunkNLGOMLGUcjs.CELL_LINES.get(a);
|
|
1213
|
+
if (!_optionalChain([U, 'optionalAccess', _73 => _73.length]) || !hasContent(b)) continue;
|
|
1109
1214
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1110
1215
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
1111
1216
|
const lu = U[U.length - 1];
|
|
@@ -1122,7 +1227,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1122
1227
|
return merged;
|
|
1123
1228
|
}
|
|
1124
1229
|
function longLastLine(c) {
|
|
1125
|
-
const L =
|
|
1230
|
+
const L = _chunkNLGOMLGUcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _74 => _74[L.length - 1]]);
|
|
1126
1231
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1127
1232
|
}
|
|
1128
1233
|
function filledToBottom(U, bottom) {
|
|
@@ -1155,8 +1260,8 @@ function nextItemHead(prev, next) {
|
|
|
1155
1260
|
return false;
|
|
1156
1261
|
}
|
|
1157
1262
|
function continuesAcross(u, d, x1, x2) {
|
|
1158
|
-
const U =
|
|
1159
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1263
|
+
const U = _chunkNLGOMLGUcjs.CELL_LINES.get(u), D = _chunkNLGOMLGUcjs.CELL_LINES.get(d);
|
|
1264
|
+
if (!_optionalChain([U, 'optionalAccess', _75 => _75.length]) || !_optionalChain([D, 'optionalAccess', _76 => _76.length])) return false;
|
|
1160
1265
|
const last = U[U.length - 1];
|
|
1161
1266
|
const fs = last.h || 10;
|
|
1162
1267
|
let minL = Infinity, maxR = -Infinity;
|
|
@@ -1173,7 +1278,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1173
1278
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1174
1279
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1175
1280
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1176
|
-
const newItem =
|
|
1281
|
+
const newItem = _chunkNLGOMLGUcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1177
1282
|
const all = D.length ? U.concat(D) : U;
|
|
1178
1283
|
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));
|
|
1179
1284
|
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;
|
|
@@ -1190,12 +1295,12 @@ function outlineContinues(u, d) {
|
|
|
1190
1295
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1191
1296
|
}
|
|
1192
1297
|
function lineEnded(c, x1, x2, next) {
|
|
1193
|
-
const L =
|
|
1298
|
+
const L = _chunkNLGOMLGUcjs.CELL_LINES.get(c);
|
|
1194
1299
|
if (!L || L.length !== 1) return false;
|
|
1195
1300
|
const l = L[0], h = l.h || 10;
|
|
1196
|
-
const d0 = next ? _optionalChain([
|
|
1301
|
+
const d0 = next ? _optionalChain([_chunkNLGOMLGUcjs.CELL_LINES, 'access', _77 => _77.get, 'call', _78 => _78(next), 'optionalAccess', _79 => _79[0]]) : void 0;
|
|
1197
1302
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1198
|
-
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
1303
|
+
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _80 => _80.text]), () => ( "")))) * h;
|
|
1199
1304
|
}
|
|
1200
1305
|
function firstWordUnits(text) {
|
|
1201
1306
|
const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
|
|
@@ -1204,15 +1309,15 @@ function firstWordUnits(text) {
|
|
|
1204
1309
|
return units;
|
|
1205
1310
|
}
|
|
1206
1311
|
function appendCell(a, b) {
|
|
1207
|
-
if (
|
|
1208
|
-
if (_optionalChain([a, 'access',
|
|
1209
|
-
const asBlocks = (c) => _optionalChain([c, 'access',
|
|
1312
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(b)) _chunkNLGOMLGUcjs.IMAGE_CELLS.add(a);
|
|
1313
|
+
if (_optionalChain([a, 'access', _81 => _81.blocks, 'optionalAccess', _82 => _82.length]) || _optionalChain([b, 'access', _83 => _83.blocks, 'optionalAccess', _84 => _84.length])) {
|
|
1314
|
+
const asBlocks = (c) => _optionalChain([c, 'access', _85 => _85.blocks, 'optionalAccess', _86 => _86.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1210
1315
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1211
1316
|
}
|
|
1212
1317
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1213
|
-
|
|
1318
|
+
_chunkNLGOMLGUcjs.joinCellEdges.call(void 0, a, b);
|
|
1214
1319
|
}
|
|
1215
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access',
|
|
1320
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _87 => _87.blocks, 'optionalAccess', _88 => _88.length]) || _chunkNLGOMLGUcjs.IMAGE_CELLS.has(cell);
|
|
1216
1321
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1217
1322
|
var batchim = (ch) => {
|
|
1218
1323
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1220,7 +1325,7 @@ var batchim = (ch) => {
|
|
|
1220
1325
|
};
|
|
1221
1326
|
function clauseContinues(u, d) {
|
|
1222
1327
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1223
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1328
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkNLGOMLGUcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1224
1329
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1225
1330
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1226
1331
|
}
|
|
@@ -1228,30 +1333,18 @@ function quantityContinues(u, d) {
|
|
|
1228
1333
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1229
1334
|
}
|
|
1230
1335
|
function wordOverflows(u, d, x1, x2) {
|
|
1231
|
-
const U =
|
|
1232
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1336
|
+
const U = _chunkNLGOMLGUcjs.CELL_LINES.get(u);
|
|
1337
|
+
if (!_optionalChain([U, 'optionalAccess', _89 => _89.length]) || _chunkNLGOMLGUcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1233
1338
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1234
1339
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1235
1340
|
}
|
|
1236
|
-
var KO_ORDER = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558";
|
|
1237
|
-
function itemMark(line) {
|
|
1238
|
-
line = flowText(line).trim();
|
|
1239
|
-
let m = /^(\d{1,2})([.)])(?!\d)/.exec(line);
|
|
1240
|
-
if (m) return { style: "1" + m[2], n: +m[1] };
|
|
1241
|
-
if (m = /^\((\d{1,2})\)/.exec(line)) return { style: "(1)", n: +m[1] };
|
|
1242
|
-
if ((m = /^([가-하])([.)])/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "\uAC00" + m[2], n: KO_ORDER.indexOf(m[1]) };
|
|
1243
|
-
if ((m = /^\(([가-하])\)/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "(\uAC00)", n: KO_ORDER.indexOf(m[1]) };
|
|
1244
|
-
if (m = /^[①-⑳]/.exec(line)) return { style: "\u2460", n: m[0].charCodeAt(0) };
|
|
1245
|
-
if (m = /^([A-Z])\.\s/.exec(line)) return { style: "A.", n: m[1].charCodeAt(0) };
|
|
1246
|
-
return null;
|
|
1247
|
-
}
|
|
1248
1341
|
function listContinues(u, d, multi = false) {
|
|
1249
1342
|
const head = itemMark(d.text.trim());
|
|
1250
1343
|
if (!head) return false;
|
|
1251
1344
|
const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
|
|
1252
1345
|
let last = -1, count = 0;
|
|
1253
1346
|
marks.forEach((m, i) => {
|
|
1254
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1347
|
+
if (_optionalChain([m, 'optionalAccess', _90 => _90.style]) === head.style) {
|
|
1255
1348
|
last = i;
|
|
1256
1349
|
count++;
|
|
1257
1350
|
}
|
|
@@ -1292,18 +1385,20 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1292
1385
|
const a = serial(cell(u)), b = serial(cell(d));
|
|
1293
1386
|
return a !== null && b === a + 1;
|
|
1294
1387
|
})) return false;
|
|
1388
|
+
if (cut.ruled && hasNumberedRowSequence(table, owner, first)) return false;
|
|
1389
|
+
if (cut.ruled && matchesIndependentRowPair(table, owner, first)) return false;
|
|
1295
1390
|
const contentPairs = pairs.filter(([u, d]) => hasContent(u.cell) && hasContent(d.cell));
|
|
1296
1391
|
const carriedSplit = !textOnly && carried && !newCell && (contentPairs.length <= 1 || contentPairs.every(([, d]) => d.rs > 1) || !cut.ruled && contentPairs.some(([u, d]) => wordOverflows(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs])));
|
|
1297
1392
|
if (!carriedSplit) {
|
|
1298
1393
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1299
1394
|
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;
|
|
1300
|
-
const oneLine = (c) => _optionalChain([
|
|
1395
|
+
const oneLine = (c) => _optionalChain([_chunkNLGOMLGUcjs.CELL_LINES, 'access', _91 => _91.get, 'call', _92 => _92(c), 'optionalAccess', _93 => _93.length]) === 1;
|
|
1301
1396
|
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;
|
|
1302
1397
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d)) || quantityContinues(cell(u), cell(d));
|
|
1303
1398
|
if (!(cut.open && !newCell)) {
|
|
1304
1399
|
if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
|
|
1305
1400
|
const one = pairs.filter(([, d]) => d.rs === 1);
|
|
1306
|
-
if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
|
|
1401
|
+
if (!matchesCompleteSiblingRow(table, owner, first) && !matchesCompleteRubricRow(table, owner, first) && !(cut.ruled && matchesCompleteContextRow(table, owner, first)) && !outlineOnly(pairs, cell) && !one.some(flows) && (cut.list === "none" || !one.some(([u, d]) => listContinues(cell(u), cell(d), cut.list === "multi")))) return false;
|
|
1307
1402
|
}
|
|
1308
1403
|
}
|
|
1309
1404
|
for (const [u, d] of pairs) {
|
|
@@ -1328,8 +1423,8 @@ function besideOwn(b, p, c) {
|
|
|
1328
1423
|
}
|
|
1329
1424
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
1330
1425
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
1331
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1332
|
-
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess',
|
|
1426
|
+
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _94 => _94.text, 'optionalAccess', _95 => _95.trim, 'call', _96 => _96()]), () => ( "")))) return false;
|
|
1427
|
+
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _97 => _97.get, 'call', _98 => _98(b.pageNumber)]) : void 0;
|
|
1333
1428
|
if (!h) return false;
|
|
1334
1429
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
1335
1430
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -1353,7 +1448,7 @@ function insideTable(b, t) {
|
|
|
1353
1448
|
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;
|
|
1354
1449
|
}
|
|
1355
1450
|
function startsWithUnitRow(table) {
|
|
1356
|
-
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access',
|
|
1451
|
+
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _99 => _99.cells, 'access', _100 => _100[0], 'optionalAccess', _101 => _101[0], 'optionalAccess', _102 => _102.text]), () => ( ""))) && _optionalChain([table, 'access', _103 => _103.cells, 'access', _104 => _104[0], 'optionalAccess', _105 => _105.slice, 'call', _106 => _106(1), 'access', _107 => _107.every, 'call', _108 => _108((c) => !c.text.trim())]);
|
|
1357
1452
|
}
|
|
1358
1453
|
function sameHeadShape(a, b) {
|
|
1359
1454
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -1364,6 +1459,12 @@ function sameHeadShape(a, b) {
|
|
|
1364
1459
|
}
|
|
1365
1460
|
return tall;
|
|
1366
1461
|
}
|
|
1462
|
+
function hasBoxTitle(t) {
|
|
1463
|
+
const titles = _nullishCoalesce(_optionalChain([t, 'access', _109 => _109.cells, 'access', _110 => _110[0], 'optionalAccess', _111 => _111.filter, 'call', _112 => _112((c) => c.text.trim())]), () => ( []));
|
|
1464
|
+
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
1465
|
+
const body = t.cells[titles[0].rowSpan];
|
|
1466
|
+
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
1467
|
+
}
|
|
1367
1468
|
function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
1368
1469
|
mergeColumnFlow(blocks, pageHeights, lex);
|
|
1369
1470
|
for (let i = blocks.length - 2; i >= 0; i--) {
|
|
@@ -1373,28 +1474,29 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1373
1474
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
1374
1475
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
1375
1476
|
const curr = blocks[j];
|
|
1376
|
-
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess',
|
|
1477
|
+
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _113 => _113.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
|
|
1377
1478
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1378
1479
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1379
1480
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
1481
|
+
if (hasBoxTitle(prev.table) && hasBoxTitle(curr.table) && !rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1380
1482
|
const joined = j === i + 1 || blocks.slice(i + 1, j).every((b) => besideOwn(b, prev, curr) || insideTable(b, prev) || insideTable(b, curr) || pageNumberBetween(b, prev, curr, pageHeights)) ? looksContinued(prev, curr, pageHeights) && !restartsTable(blocks, i, curr.table, pageHeights) ? _nullishCoalesce(joinClipParts(prev, curr, pageHeights, lex), () => ( false)) : null : null;
|
|
1381
1483
|
if (joined) {
|
|
1382
1484
|
placeJoined(blocks, i, j, joined);
|
|
1383
1485
|
continue;
|
|
1384
1486
|
}
|
|
1385
|
-
if (
|
|
1487
|
+
if (_chunkNLGOMLGUcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1386
1488
|
blocks.splice(j, 1);
|
|
1387
1489
|
i++;
|
|
1388
1490
|
continue;
|
|
1389
1491
|
}
|
|
1390
1492
|
if (joined === null) continue;
|
|
1391
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1493
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkNLGOMLGUcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1392
1494
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1393
1495
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1394
1496
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1395
1497
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1396
|
-
const px =
|
|
1397
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1498
|
+
const px = _chunkNLGOMLGUcjs.TABLE_COLXS.get(prev.table), cx = _chunkNLGOMLGUcjs.TABLE_COLXS.get(curr.table);
|
|
1499
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkNLGOMLGUcjs.CLIP_TABLES.has(prev.table) && !_chunkNLGOMLGUcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1398
1500
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1399
1501
|
let currCells = curr.table.cells;
|
|
1400
1502
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1405,16 +1507,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1405
1507
|
blocks.splice(j, 1);
|
|
1406
1508
|
continue;
|
|
1407
1509
|
}
|
|
1408
|
-
if (px && cx && !
|
|
1510
|
+
if (px && cx && !_chunkNLGOMLGUcjs.CLIP_TABLES.has(prev.table) && !_chunkNLGOMLGUcjs.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 && _chunkNLGOMLGUcjs.CELL_LINES.has(c))) {
|
|
1409
1511
|
const dx = px[0] - cx[0];
|
|
1410
1512
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1411
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
1513
|
+
if (_optionalChain([part, 'optionalAccess', _114 => _114.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1412
1514
|
const last = prev.table.rows - 1;
|
|
1413
1515
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1414
|
-
const U =
|
|
1415
|
-
|
|
1516
|
+
const U = _chunkNLGOMLGUcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkNLGOMLGUcjs.CELL_LINES.get(currCells[0][c]);
|
|
1517
|
+
_chunkNLGOMLGUcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1416
1518
|
}
|
|
1417
|
-
|
|
1519
|
+
_chunkNLGOMLGUcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1418
1520
|
placeJoined(blocks, i, j, part.table);
|
|
1419
1521
|
continue;
|
|
1420
1522
|
}
|
|
@@ -1427,20 +1529,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1427
1529
|
caption: prev.table.caption,
|
|
1428
1530
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1429
1531
|
};
|
|
1430
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1431
|
-
if (
|
|
1532
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkNLGOMLGUcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1533
|
+
if (_chunkNLGOMLGUcjs.CLIP_TABLES.has(prev.table) || _chunkNLGOMLGUcjs.CLIP_TABLES.has(curr.table)) _chunkNLGOMLGUcjs.CLIP_TABLES.add(merged);
|
|
1432
1534
|
placeJoined(blocks, i, j, merged);
|
|
1433
1535
|
}
|
|
1434
1536
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1435
1537
|
const t = blocks[i].table;
|
|
1436
|
-
if (blocks[i].type === "table" && t &&
|
|
1538
|
+
if (blocks[i].type === "table" && t && _chunkNLGOMLGUcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1437
1539
|
}
|
|
1438
1540
|
}
|
|
1439
1541
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1440
1542
|
if (!pageHeights) return;
|
|
1441
1543
|
for (let i = 0; i < blocks.length; i++) {
|
|
1442
1544
|
const L = blocks[i];
|
|
1443
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1545
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(L.table) || _chunkNLGOMLGUcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1444
1546
|
const ph = pageHeights.get(L.pageNumber);
|
|
1445
1547
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1446
1548
|
let s0 = i, s1 = i;
|
|
@@ -1469,12 +1571,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1469
1571
|
}
|
|
1470
1572
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1471
1573
|
const pt = prev.table, ct = curr.table;
|
|
1472
|
-
if (!
|
|
1473
|
-
const px =
|
|
1574
|
+
if (!_chunkNLGOMLGUcjs.CLIP_TABLES.has(pt) || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(ct)) return null;
|
|
1575
|
+
const px = _chunkNLGOMLGUcjs.TABLE_COLXS.get(pt), cx = _chunkNLGOMLGUcjs.TABLE_COLXS.get(ct);
|
|
1474
1576
|
if (!px || !cx) return null;
|
|
1475
1577
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1476
1578
|
if (!shiftedSame(px, cx, false)) {
|
|
1477
|
-
if (!_optionalChain([pageHeights, 'optionalAccess',
|
|
1579
|
+
if (!_optionalChain([pageHeights, 'optionalAccess', _115 => _115.get, 'call', _116 => _116(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _117 => _117.get, 'call', _118 => _118(curr.pageNumber)])) return null;
|
|
1478
1580
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1479
1581
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1480
1582
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -1486,19 +1588,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1486
1588
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1487
1589
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1488
1590
|
};
|
|
1489
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1591
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkNLGOMLGUcjs.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);
|
|
1490
1592
|
}
|
|
1491
|
-
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access',
|
|
1593
|
+
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _119 => _119.bbox, 'optionalAccess', _120 => _120.y]), lex);
|
|
1492
1594
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1493
|
-
|
|
1494
|
-
const ys =
|
|
1495
|
-
if (ys)
|
|
1496
|
-
|
|
1497
|
-
|
|
1595
|
+
_chunkNLGOMLGUcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1596
|
+
const ys = _chunkNLGOMLGUcjs.TABLE_ROWYS.get(pt);
|
|
1597
|
+
if (ys) _chunkNLGOMLGUcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1598
|
+
_chunkNLGOMLGUcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkNLGOMLGUcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1599
|
+
_chunkNLGOMLGUcjs.CLIP_TABLES.add(res.table);
|
|
1498
1600
|
return res.table;
|
|
1499
1601
|
}
|
|
1500
1602
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
1501
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1603
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _121 => _121.get, 'call', _122 => _122(prev.pageNumber)]);
|
|
1502
1604
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
1503
1605
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
1504
1606
|
}
|
|
@@ -1509,21 +1611,21 @@ function headingRow(row) {
|
|
|
1509
1611
|
}
|
|
1510
1612
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
1511
1613
|
function looksContinued(prev, curr, pageHeights) {
|
|
1512
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1614
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _123 => _123.get, 'call', _124 => _124(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _125 => _125.get, 'call', _126 => _126(curr.pageNumber)]);
|
|
1513
1615
|
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;
|
|
1514
1616
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
1515
|
-
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access',
|
|
1617
|
+
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _127 => _127.find, 'call', _128 => _128((c) => c.text.trim()), 'optionalAccess', _129 => _129.text]), () => ( ""));
|
|
1516
1618
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
1517
1619
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
1518
1620
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1519
1621
|
}
|
|
1520
1622
|
function pushedLead(prev, curr) {
|
|
1521
|
-
if (!
|
|
1623
|
+
if (!_chunkNLGOMLGUcjs.CLIP_TABLES.has(prev.table) || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1522
1624
|
const lead = leadRows(curr.table);
|
|
1523
1625
|
return lead.image && lead.height > prev.bbox.y;
|
|
1524
1626
|
}
|
|
1525
1627
|
function leadRows(t) {
|
|
1526
|
-
const ys =
|
|
1628
|
+
const ys = _chunkNLGOMLGUcjs.TABLE_ROWYS.get(t);
|
|
1527
1629
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1528
1630
|
const anchors = anchorsOf(t);
|
|
1529
1631
|
let end = 1, image = false;
|
|
@@ -1531,17 +1633,17 @@ function leadRows(t) {
|
|
|
1531
1633
|
for (const a of anchors) {
|
|
1532
1634
|
if (a.r !== r) continue;
|
|
1533
1635
|
end = Math.max(end, r + a.rs);
|
|
1534
|
-
if (
|
|
1636
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1535
1637
|
}
|
|
1536
1638
|
}
|
|
1537
1639
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1538
1640
|
}
|
|
1539
1641
|
function tailOf(b) {
|
|
1540
|
-
const t = b.table &&
|
|
1642
|
+
const t = b.table && _chunkNLGOMLGUcjs.TABLE_TAIL.get(b.table);
|
|
1541
1643
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1542
1644
|
}
|
|
1543
1645
|
function firstRowSig(t) {
|
|
1544
|
-
const x =
|
|
1646
|
+
const x = _chunkNLGOMLGUcjs.TABLE_COLXS.get(t);
|
|
1545
1647
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1546
1648
|
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, "") }));
|
|
1547
1649
|
}
|
|
@@ -1566,9 +1668,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
1566
1668
|
}
|
|
1567
1669
|
function restartsTitledForm(head, curr) {
|
|
1568
1670
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
1569
|
-
const full = (t) => _optionalChain([t, 'access',
|
|
1671
|
+
const full = (t) => _optionalChain([t, 'access', _130 => _130.cells, 'access', _131 => _131[0], 'access', _132 => _132[0], 'optionalAccess', _133 => _133.colSpan]) === t.cols;
|
|
1570
1672
|
if (!full(head) || !full(curr)) return false;
|
|
1571
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
1673
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _134 => _134.text]), () => ( ""))).replace(/\s+/g, "");
|
|
1572
1674
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
1573
1675
|
if (!ht || !ct || ht === ct) return false;
|
|
1574
1676
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -1594,7 +1696,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1594
1696
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1595
1697
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1596
1698
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1597
|
-
const px =
|
|
1699
|
+
const px = _chunkNLGOMLGUcjs.TABLE_COLXS.get(pb.table), cx = _chunkNLGOMLGUcjs.TABLE_COLXS.get(cur.table);
|
|
1598
1700
|
if (!px || !cx) break;
|
|
1599
1701
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1600
1702
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1611,7 +1713,7 @@ function continueRowSpans(prevCells, currCells) {
|
|
|
1611
1713
|
if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
|
|
1612
1714
|
let anchor;
|
|
1613
1715
|
for (let r = last - 1; r >= 0 && !anchor; r--) {
|
|
1614
|
-
const a = _optionalChain([prevCells, 'access',
|
|
1716
|
+
const a = _optionalChain([prevCells, 'access', _135 => _135[r], 'optionalAccess', _136 => _136[c]]);
|
|
1615
1717
|
if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
|
|
1616
1718
|
}
|
|
1617
1719
|
if (!anchor) continue;
|
|
@@ -1665,12 +1767,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1665
1767
|
var COL_MATCH_TOL = 0.5;
|
|
1666
1768
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1667
1769
|
function lastRowCell(t, x1, x2) {
|
|
1668
|
-
const xs =
|
|
1770
|
+
const xs = _chunkNLGOMLGUcjs.TABLE_COLXS.get(t);
|
|
1669
1771
|
const covered = /* @__PURE__ */ new Set();
|
|
1670
1772
|
for (let r = 0; r < t.rows; r++) {
|
|
1671
1773
|
for (let c = 0; c < t.cols; c++) {
|
|
1672
1774
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1673
|
-
const cell = _optionalChain([t, 'access',
|
|
1775
|
+
const cell = _optionalChain([t, 'access', _137 => _137.cells, 'access', _138 => _138[r], 'optionalAccess', _139 => _139[c]]);
|
|
1674
1776
|
if (!cell) continue;
|
|
1675
1777
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
1676
1778
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -1683,25 +1785,28 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1683
1785
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1684
1786
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1685
1787
|
const part = blocks[j];
|
|
1686
|
-
const from = part.table ?
|
|
1687
|
-
if (!from || !part.table)
|
|
1788
|
+
const from = part.table ? _chunkNLGOMLGUcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1789
|
+
if (!from || !part.table) {
|
|
1790
|
+
unwrapContinuedTable(blocks, j, pageHeights, true);
|
|
1791
|
+
continue;
|
|
1792
|
+
}
|
|
1688
1793
|
let i = j - 1;
|
|
1689
1794
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
1690
1795
|
const prev = blocks[i];
|
|
1691
1796
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
1692
1797
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
1693
|
-
const add = _optionalChain([part, 'access',
|
|
1798
|
+
const add = _optionalChain([part, 'access', _140 => _140.table, 'access', _141 => _141.cells, 'access', _142 => _142[0], 'optionalAccess', _143 => _143[0]]);
|
|
1694
1799
|
if (!cell || !add) continue;
|
|
1695
1800
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1696
1801
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1697
1802
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1698
1803
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1701
|
-
const lines =
|
|
1702
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
1703
|
-
if (part.pageNumber && part.bbox)
|
|
1704
|
-
if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
1804
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(add)) _chunkNLGOMLGUcjs.IMAGE_CELLS.add(cell);
|
|
1805
|
+
_chunkNLGOMLGUcjs.joinCellEdges.call(void 0, cell, add);
|
|
1806
|
+
const lines = _chunkNLGOMLGUcjs.CELL_LINES.get(add);
|
|
1807
|
+
if (_optionalChain([lines, 'optionalAccess', _144 => _144.length])) _chunkNLGOMLGUcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkNLGOMLGUcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1808
|
+
if (part.pageNumber && part.bbox) _chunkNLGOMLGUcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkNLGOMLGUcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1809
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length]) || _chunkNLGOMLGUcjs.IMAGE_CELLS.has(cell)) _chunkNLGOMLGUcjs.EMPTY_PARTS.delete(prev.table);
|
|
1705
1810
|
blocks.splice(j, 1);
|
|
1706
1811
|
if (cell.blocks && at > 0) {
|
|
1707
1812
|
const nextAt = cell.blocks[at];
|
|
@@ -1711,30 +1816,31 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1711
1816
|
if (cell.blocks) mergeCrossPageTables(cell.blocks, pageHeights);
|
|
1712
1817
|
}
|
|
1713
1818
|
}
|
|
1714
|
-
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1819
|
+
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1715
1820
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1716
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
1717
|
-
const inner = _optionalChain([frame, 'access',
|
|
1718
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
1719
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
1720
|
-
const px =
|
|
1821
|
+
if (!_optionalChain([prev, 'optionalAccess', _147 => _147.table]) || !_optionalChain([frame, 'optionalAccess', _148 => _148.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1822
|
+
const inner = _optionalChain([frame, 'access', _149 => _149.table, 'access', _150 => _150.cells, 'access', _151 => _151[0], 'optionalAccess', _152 => _152[0], 'optionalAccess', _153 => _153.blocks]);
|
|
1823
|
+
const next = _optionalChain([inner, 'optionalAccess', _154 => _154[0]]);
|
|
1824
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _155 => _155.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(prev.table) || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1825
|
+
const px = _chunkNLGOMLGUcjs.TABLE_COLXS.get(prev.table), nx = _chunkNLGOMLGUcjs.TABLE_COLXS.get(next.table);
|
|
1721
1826
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1722
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1827
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _156 => _156.get, 'call', _157 => _157(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _158 => _158.get, 'call', _159 => _159(next.pageNumber)]);
|
|
1723
1828
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
1829
|
+
if (splitOnly && (inner.length !== 1 || !_optionalChain([joinSplitParts, 'call', _160 => _160(prev.table, px, next.table, nx, 0, prev.bbox.y), 'optionalAccess', _161 => _161.split]))) return;
|
|
1724
1830
|
blocks.splice(at, 1, ...inner);
|
|
1725
1831
|
}
|
|
1726
1832
|
function fillNestedContinuation(blocks, at) {
|
|
1727
1833
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1728
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
1729
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1730
|
-
const xs =
|
|
1834
|
+
const t = _optionalChain([prev, 'optionalAccess', _162 => _162.table]), u = _optionalChain([next, 'optionalAccess', _163 => _163.table]);
|
|
1835
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(t) || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1836
|
+
const xs = _chunkNLGOMLGUcjs.TABLE_COLXS.get(u);
|
|
1731
1837
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1732
|
-
const add = _optionalChain([u, 'access',
|
|
1733
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access',
|
|
1838
|
+
const add = _optionalChain([u, 'access', _164 => _164.cells, 'access', _165 => _165[0], 'optionalAccess', _166 => _166[0]]);
|
|
1839
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _167 => _167.blocks, 'optionalAccess', _168 => _168.length]) || _chunkNLGOMLGUcjs.IMAGE_CELLS.has(cell)) return;
|
|
1734
1840
|
cell.text = add.text;
|
|
1735
1841
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1736
|
-
if (
|
|
1737
|
-
|
|
1842
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(add)) _chunkNLGOMLGUcjs.IMAGE_CELLS.add(cell);
|
|
1843
|
+
_chunkNLGOMLGUcjs.joinCellEdges.call(void 0, cell, add);
|
|
1738
1844
|
blocks.splice(at, 1);
|
|
1739
1845
|
}
|
|
1740
1846
|
|
|
@@ -1907,7 +2013,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
1907
2013
|
if (!cache.has(key)) {
|
|
1908
2014
|
let sym = null;
|
|
1909
2015
|
try {
|
|
1910
|
-
const data = _optionalChain([fontObj, 'call',
|
|
2016
|
+
const data = _optionalChain([fontObj, 'call', _169 => _169(font), 'optionalAccess', _170 => _170.data]);
|
|
1911
2017
|
const code = glyph.fontChar.codePointAt(0);
|
|
1912
2018
|
const outline = data && code !== void 0 ? readOutline(data, code) : null;
|
|
1913
2019
|
if (outline) sym = classifyOutline(outline);
|
|
@@ -1931,7 +2037,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
1931
2037
|
}
|
|
1932
2038
|
for (const [f, list] of byFont) {
|
|
1933
2039
|
const q = queues.get(f);
|
|
1934
|
-
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access',
|
|
2040
|
+
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _171 => _171.str, 'access', _172 => _172.match, 'call', _173 => _173(//g), 'optionalAccess', _174 => _174.length]), () => ( 0))), 0);
|
|
1935
2041
|
if (!q || q.length !== want) continue;
|
|
1936
2042
|
let k = 0;
|
|
1937
2043
|
for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
|
|
@@ -1954,15 +2060,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1954
2060
|
function marginContextBlocks(raw, page, view) {
|
|
1955
2061
|
const [x1, y1, x2, y2] = view;
|
|
1956
2062
|
const width = x2 - x1, height = y2 - y1;
|
|
1957
|
-
const items =
|
|
2063
|
+
const items = _chunkNLGOMLGUcjs.filterHiddenText.call(void 0, _chunkNLGOMLGUcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1958
2064
|
for (const item of items) {
|
|
1959
2065
|
item.x -= x1;
|
|
1960
2066
|
item.y -= y1;
|
|
1961
2067
|
}
|
|
1962
|
-
return
|
|
1963
|
-
const bbox =
|
|
2068
|
+
return _chunkNLGOMLGUcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2069
|
+
const bbox = _chunkNLGOMLGUcjs.computeBBox.call(void 0, line, page);
|
|
1964
2070
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1965
|
-
return [{ type: "paragraph", text:
|
|
2071
|
+
return [{ type: "paragraph", text: _chunkNLGOMLGUcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkNLGOMLGUcjs.dominantStyle.call(void 0, line) }];
|
|
1966
2072
|
});
|
|
1967
2073
|
}
|
|
1968
2074
|
|
|
@@ -1998,7 +2104,7 @@ var WINANSI_REVERSE = {
|
|
|
1998
2104
|
};
|
|
1999
2105
|
function symbolFontTable(fontName) {
|
|
2000
2106
|
if (!fontName) return void 0;
|
|
2001
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2107
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkSJ5OZXELcjs.WINGDINGS;
|
|
2002
2108
|
return void 0;
|
|
2003
2109
|
}
|
|
2004
2110
|
function remapSymbolText(text, table) {
|
|
@@ -2126,7 +2232,7 @@ function layout(toks) {
|
|
|
2126
2232
|
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);
|
|
2127
2233
|
if (!bar) continue;
|
|
2128
2234
|
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);
|
|
2129
|
-
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access',
|
|
2235
|
+
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _175 => _175[0], 'optionalAccess', _176 => _176.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
|
|
2130
2236
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
2131
2237
|
}
|
|
2132
2238
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -2228,7 +2334,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
2228
2334
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
2229
2335
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
2230
2336
|
const bar = cur.find(isBarItem);
|
|
2231
|
-
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access',
|
|
2337
|
+
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _177 => _177[0], 'optionalAccess', _178 => _178[0]]), () => ( cur[0].y));
|
|
2232
2338
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
2233
2339
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
2234
2340
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -2585,7 +2691,7 @@ function joinVerticalColumns(items) {
|
|
|
2585
2691
|
const groups = [];
|
|
2586
2692
|
for (const col of columns) {
|
|
2587
2693
|
const g2 = groups[groups.length - 1];
|
|
2588
|
-
const last = _optionalChain([g2, 'optionalAccess',
|
|
2694
|
+
const last = _optionalChain([g2, 'optionalAccess', _179 => _179[g2.length - 1]]);
|
|
2589
2695
|
const fs = col.items[0].fontSize;
|
|
2590
2696
|
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);
|
|
2591
2697
|
else groups.push([col]);
|
|
@@ -2801,7 +2907,7 @@ function relocateEndnotes(blocks) {
|
|
|
2801
2907
|
}
|
|
2802
2908
|
const shapes = /* @__PURE__ */ new Map();
|
|
2803
2909
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
2804
|
-
const main = _optionalChain([[...shapes], 'access',
|
|
2910
|
+
const main = _optionalChain([[...shapes], 'access', _180 => _180.sort, 'call', _181 => _181((a, b) => b[1] - a[1]), 'access', _182 => _182[0], 'optionalAccess', _183 => _183[0]]);
|
|
2805
2911
|
if (!main || !/#/.test(main)) return blocks;
|
|
2806
2912
|
const lastRun = (hs) => {
|
|
2807
2913
|
let run2 = [];
|
|
@@ -2864,7 +2970,7 @@ function dropTabLeaderDots(items) {
|
|
|
2864
2970
|
let run = [];
|
|
2865
2971
|
const flush = () => {
|
|
2866
2972
|
const last = run[run.length - 1];
|
|
2867
|
-
const tailPage = _optionalChain([DOTS_PAGE, 'access',
|
|
2973
|
+
const tailPage = _optionalChain([DOTS_PAGE, 'access', _184 => _184.exec, 'call', _185 => _185(last.text.trim()), 'optionalAccess', _186 => _186[1]]);
|
|
2868
2974
|
const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
|
|
2869
2975
|
if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
|
|
2870
2976
|
const body = tailPage ? run.slice(0, -1) : run;
|
|
@@ -2952,7 +3058,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
2952
3058
|
open = true;
|
|
2953
3059
|
continue;
|
|
2954
3060
|
}
|
|
2955
|
-
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3061
|
+
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontSize]), () => ( _optionalChain([b, 'access', _189 => _189.bbox, 'optionalAccess', _190 => _190.height]))), () => ( 10))) * 1.5;
|
|
2956
3062
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
2957
3063
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
2958
3064
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -2975,7 +3081,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
2975
3081
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
2976
3082
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
2977
3083
|
function isRunningHead(block, page, pageHeight) {
|
|
2978
|
-
const box = block.bbox, text = _optionalChain([block, 'access',
|
|
3084
|
+
const box = block.bbox, text = _optionalChain([block, 'access', _191 => _191.text, 'optionalAccess', _192 => _192.trim, 'call', _193 => _193()]);
|
|
2979
3085
|
if (!box || !text || !pageHeight) return false;
|
|
2980
3086
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
2981
3087
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -2983,7 +3089,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
2983
3089
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
2984
3090
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
2985
3091
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
2986
|
-
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access',
|
|
3092
|
+
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _194 => _194.style, 'optionalAccess', _195 => _195.fontSize]), () => ( 0))) * 1.6) return true;
|
|
2987
3093
|
if (!text.includes(" ")) return false;
|
|
2988
3094
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
2989
3095
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -2992,7 +3098,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
2992
3098
|
return right > left && box.width >= (right - left) * 0.6;
|
|
2993
3099
|
}
|
|
2994
3100
|
function unbalancedClose(text) {
|
|
2995
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
3101
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _196 => _196.match, 'call', _197 => _197(/\)/g), 'optionalAccess', _198 => _198.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _199 => _199.match, 'call', _200 => _200(/\(/g), 'optionalAccess', _201 => _201.length]), () => ( 0)));
|
|
2996
3102
|
}
|
|
2997
3103
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
2998
3104
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -3008,7 +3114,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3008
3114
|
const sizes = /* @__PURE__ */ new Map();
|
|
3009
3115
|
let proseChars = 0;
|
|
3010
3116
|
for (const b of page) {
|
|
3011
|
-
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access',
|
|
3117
|
+
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _202 => _202.style, 'optionalAccess', _203 => _203.fontName]) || !b.style.fontSize) continue;
|
|
3012
3118
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
3013
3119
|
chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
|
|
3014
3120
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
@@ -3032,13 +3138,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3032
3138
|
const citedProse = /* @__PURE__ */ new Set();
|
|
3033
3139
|
const numberedProse = /* @__PURE__ */ new Set();
|
|
3034
3140
|
for (const page of byPage.values()) {
|
|
3035
|
-
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3141
|
+
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _204 => _204.text, 'optionalAccess', _205 => _205.trim, 'call', _206 => _206()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _207 => _207.style, 'optionalAccess', _208 => _208.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _209 => _209.get, 'call', _210 => _210(b.style.fontName)]), () => ( ""))));
|
|
3036
3142
|
let chain = [];
|
|
3037
3143
|
const finish = () => {
|
|
3038
|
-
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access',
|
|
3144
|
+
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _211 => _211.text, 'optionalAccess', _212 => _212.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
|
|
3039
3145
|
for (const b of chain) numberedProse.add(b);
|
|
3040
3146
|
const first = chain[0], size = first.style.fontSize;
|
|
3041
|
-
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3147
|
+
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _213 => _213.text, 'optionalAccess', _214 => _214.trim, 'call', _215 => _215()]), () => ( ""))) && _optionalChain([b, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName]) === _optionalChain([first, 'access', _218 => _218.style, 'optionalAccess', _219 => _219.fontName]) && _optionalChain([b, 'access', _220 => _220.style, 'optionalAccess', _221 => _221.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _222 => _222.text, 'optionalAccess', _223 => _223.length]), () => ( 0))) >= 15) numberedProse.add(b);
|
|
3042
3148
|
};
|
|
3043
3149
|
for (const b of numbered) {
|
|
3044
3150
|
const prev = chain.at(-1), size = b.style.fontSize;
|
|
@@ -3052,9 +3158,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3052
3158
|
}
|
|
3053
3159
|
for (let i = 0; i + 1 < blocks.length; i++) {
|
|
3054
3160
|
const prose = blocks[i], reference = blocks[i + 1];
|
|
3055
|
-
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access',
|
|
3056
|
-
const source = _nullishCoalesce(_optionalChain([reference, 'access',
|
|
3057
|
-
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access',
|
|
3161
|
+
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontSize]), () => ( 0));
|
|
3162
|
+
const source = _nullishCoalesce(_optionalChain([reference, 'access', _226 => _226.text, 'optionalAccess', _227 => _227.replace, 'call', _228 => _228(/<[^>]+>/g, ""), 'access', _229 => _229.trim, 'call', _230 => _230()]), () => ( ""));
|
|
3163
|
+
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _231 => _231.text, 'optionalAccess', _232 => _232.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _233 => _233.style, 'optionalAccess', _234 => _234.fontName]) !== _optionalChain([reference, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) || _optionalChain([prose, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontSize]) !== _optionalChain([reference, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
|
|
3058
3164
|
citedProse.add(prose);
|
|
3059
3165
|
citedProse.add(reference);
|
|
3060
3166
|
}
|
|
@@ -3062,49 +3168,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3062
3168
|
const block = blocks[i];
|
|
3063
3169
|
if (block.type !== "heading" || !block.text) continue;
|
|
3064
3170
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3065
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3066
|
-
const tocEntry = i > 0 &&
|
|
3171
|
+
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _241 => _241.style, 'optionalAccess', _242 => _242.fontSize]), () => ( 0));
|
|
3172
|
+
const tocEntry = i > 0 && _chunkNLGOMLGUcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkNLGOMLGUcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3067
3173
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3068
|
-
const proseStyle = _optionalChain([block, 'access',
|
|
3174
|
+
const proseStyle = _optionalChain([block, 'access', _243 => _243.style, 'optionalAccess', _244 => _244.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3069
3175
|
const next = blocks[i + 1];
|
|
3070
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
3071
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
3072
|
-
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess',
|
|
3176
|
+
const nb = _optionalChain([next, 'optionalAccess', _245 => _245.bbox]), bb = block.bbox;
|
|
3177
|
+
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _246 => _246.style, 'optionalAccess', _247 => _247.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;
|
|
3178
|
+
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _248 => _248.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
|
|
3073
3179
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3074
3180
|
blocks.splice(i--, 1);
|
|
3075
3181
|
continue;
|
|
3076
3182
|
}
|
|
3077
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
3183
|
+
if ((_optionalChain([next, 'optionalAccess', _249 => _249.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _250 => _250.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontName]) === _optionalChain([block, 'access', _253 => _253.style, 'optionalAccess', _254 => _254.fontName]) && _optionalChain([next, 'access', _255 => _255.style, 'optionalAccess', _256 => _256.fontSize]) === _optionalChain([block, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.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) {
|
|
3078
3184
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3079
3185
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
3080
3186
|
blocks.splice(i + 1, 1);
|
|
3081
3187
|
}
|
|
3082
3188
|
const after = blocks[i + 2];
|
|
3083
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
3189
|
+
if ((_optionalChain([next, 'optionalAccess', _259 => _259.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _260 => _260.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _261 => _261.text, 'optionalAccess', _262 => _262.trim, 'call', _263 => _263()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _264 => _264.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _265 => _265.style, 'optionalAccess', _266 => _266.fontSize]) === _optionalChain([block, 'access', _267 => _267.style, 'optionalAccess', _268 => _268.fontSize])) {
|
|
3084
3190
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
3085
3191
|
blocks.splice(i + 1, 2);
|
|
3086
3192
|
}
|
|
3087
3193
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
3088
3194
|
const prev = blocks[i - 1];
|
|
3089
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
3195
|
+
if (_optionalChain([prev, 'optionalAccess', _269 => _269.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _270 => _270.text, 'optionalAccess', _271 => _271.trim, 'call', _272 => _272()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
|
|
3090
3196
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3091
3197
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
3092
3198
|
blocks.splice(i--, 1);
|
|
3093
3199
|
continue;
|
|
3094
3200
|
}
|
|
3095
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
3201
|
+
if (_optionalChain([prev, 'optionalAccess', _273 => _273.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _274 => _274.text, 'optionalAccess', _275 => _275.trim, 'call', _276 => _276()]), () => ( ""))) && 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', _277 => _277.style, 'optionalAccess', _278 => _278.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
|
|
3096
3202
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3097
3203
|
blocks.splice(i - 1, 1);
|
|
3098
3204
|
i -= 2;
|
|
3099
3205
|
continue;
|
|
3100
3206
|
}
|
|
3101
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3102
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
3103
|
-
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess',
|
|
3207
|
+
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _279 => _279.style, 'optionalAccess', _280 => _280.fontSize]), () => ( 0));
|
|
3208
|
+
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _281 => _281.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.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");
|
|
3209
|
+
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _286 => _286.get, 'call', _287 => _287(_nullishCoalesce(_optionalChain([block, 'access', _288 => _288.style, 'optionalAccess', _289 => _289.fontName]), () => ( "")))]), () => ( ""));
|
|
3104
3210
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
3105
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
3106
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
3107
|
-
const crowdedOcr = _optionalChain([block, 'access',
|
|
3211
|
+
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _290 => _290[i - 1], 'optionalAccess', _291 => _291.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
|
|
3212
|
+
const ocrFragment = _optionalChain([block, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _294 => _294.match, 'call', _295 => _295(/\p{L}/gu), 'optionalAccess', _296 => _296.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
|
|
3213
|
+
const crowdedOcr = _optionalChain([block, 'access', _297 => _297.style, 'optionalAccess', _298 => _298.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _299 => _299.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _300 => _300.style, 'optionalAccess', _301 => _301.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _302 => _302.text, 'optionalAccess', _303 => _303.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;
|
|
3108
3214
|
if (numberedProse.has(block) || citedProse.has(block) || 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)"·"가)" 앞머리 번호는 빼고 센다
|
|
3109
3215
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
3110
3216
|
block.type = "paragraph";
|
|
@@ -3154,34 +3260,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
3154
3260
|
function captionTableText(t) {
|
|
3155
3261
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
3156
3262
|
const [label, body] = t.cells[0];
|
|
3157
|
-
if (!label || !body || _optionalChain([label, 'access',
|
|
3263
|
+
if (!label || !body || _optionalChain([label, 'access', _304 => _304.blocks, 'optionalAccess', _305 => _305.length]) || _optionalChain([body, 'access', _306 => _306.blocks, 'optionalAccess', _307 => _307.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
|
|
3158
3264
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
3159
3265
|
}
|
|
3160
3266
|
function splitSingleCellTables(blocks) {
|
|
3161
3267
|
const out = [];
|
|
3162
3268
|
for (const b of blocks) {
|
|
3163
3269
|
const t = b.type === "table" ? b.table : void 0;
|
|
3164
|
-
const title = t &&
|
|
3270
|
+
const title = t && _chunkNLGOMLGUcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3165
3271
|
if (title) {
|
|
3166
3272
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3167
3273
|
continue;
|
|
3168
3274
|
}
|
|
3169
|
-
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access',
|
|
3275
|
+
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _308 => _308.cells, 'access', _309 => _309[0], 'optionalAccess', _310 => _310[0], 'optionalAccess', _311 => _311.blocks, 'optionalAccess', _312 => _312.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
|
|
3170
3276
|
const squash = (s) => s.replace(/\s/g, "");
|
|
3171
3277
|
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;
|
|
3172
|
-
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess',
|
|
3278
|
+
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _313 => _313.type]) === "table" ? captionTableText(inner.table) : null)));
|
|
3173
3279
|
if (caption) {
|
|
3174
3280
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3175
3281
|
continue;
|
|
3176
3282
|
}
|
|
3177
|
-
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access',
|
|
3283
|
+
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _314 => _314.cells, 'access', _315 => _315[0], 'optionalAccess', _316 => _316[0]]) : void 0;
|
|
3178
3284
|
if (!cell) {
|
|
3179
3285
|
out.push(b);
|
|
3180
3286
|
continue;
|
|
3181
3287
|
}
|
|
3182
3288
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
3183
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
3184
|
-
if (_optionalChain([cell, 'access',
|
|
3289
|
+
if (_optionalChain([t, 'optionalAccess', _317 => _317.caption, 'optionalAccess', _318 => _318.trim, 'call', _319 => _319()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3290
|
+
if (_optionalChain([cell, 'access', _320 => _320.blocks, 'optionalAccess', _321 => _321.length])) {
|
|
3185
3291
|
out.push(...splitSingleCellTables(cell.blocks));
|
|
3186
3292
|
continue;
|
|
3187
3293
|
}
|
|
@@ -3197,7 +3303,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3197
3303
|
const lines = cell.text.split("\n");
|
|
3198
3304
|
const out = [lines[0]];
|
|
3199
3305
|
for (const line of lines.slice(1)) {
|
|
3200
|
-
if (
|
|
3306
|
+
if (_chunkNLGOMLGUcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3201
3307
|
else out.push(line);
|
|
3202
3308
|
}
|
|
3203
3309
|
cell.text = out.join("\n");
|
|
@@ -3208,19 +3314,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
3208
3314
|
}
|
|
3209
3315
|
function cleanPdfText(text, opts) {
|
|
3210
3316
|
let clean = normalizeAraea(stripControlChars(text));
|
|
3211
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3317
|
+
if (!_optionalChain([opts, 'optionalAccess', _322 => _322.keepLoneNumbers])) {
|
|
3212
3318
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
3213
3319
|
}
|
|
3214
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3320
|
+
if (!_optionalChain([opts, 'optionalAccess', _323 => _323.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
3215
3321
|
return mergeKoreanLines(
|
|
3216
3322
|
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))
|
|
3217
3323
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3218
3324
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3219
3325
|
if (line.startsWith("|")) {
|
|
3220
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3326
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkNLGOMLGUcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3221
3327
|
}
|
|
3222
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
3223
|
-
return mark +
|
|
3328
|
+
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _324 => _324.exec, 'call', _325 => _325(line), 'optionalAccess', _326 => _326[0]]), () => ( ""));
|
|
3329
|
+
return mark + _chunkNLGOMLGUcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3224
3330
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3225
3331
|
}
|
|
3226
3332
|
function startsWithMarker(line) {
|
|
@@ -3252,7 +3358,7 @@ function mergeKoreanLines(text) {
|
|
|
3252
3358
|
continue;
|
|
3253
3359
|
}
|
|
3254
3360
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3255
|
-
result[result.length - 1] = prev +
|
|
3361
|
+
result[result.length - 1] = prev + _chunkNLGOMLGUcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3256
3362
|
} else {
|
|
3257
3363
|
result.push(curr);
|
|
3258
3364
|
}
|
|
@@ -3268,7 +3374,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3268
3374
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3269
3375
|
for (const a of annots) {
|
|
3270
3376
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3271
|
-
const url =
|
|
3377
|
+
const url = _chunkMI655NV5cjs.sanitizeHref.call(void 0, a.url);
|
|
3272
3378
|
if (!url) continue;
|
|
3273
3379
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3274
3380
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3320,7 +3426,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3320
3426
|
|
|
3321
3427
|
// src/pdf/formula-ocr.ts
|
|
3322
3428
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3323
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3429
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-5V2WG4BH.cjs")));
|
|
3324
3430
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3325
3431
|
await ensureFormulaModels((p) => {
|
|
3326
3432
|
if (p.phase === "download" && p.total) {
|
|
@@ -3511,13 +3617,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3511
3617
|
try {
|
|
3512
3618
|
return await Promise.race([
|
|
3513
3619
|
loadingTask.promise.catch((e) => {
|
|
3514
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3620
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkMI655NV5cjs.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)");
|
|
3515
3621
|
throw e;
|
|
3516
3622
|
}),
|
|
3517
3623
|
new Promise((_, reject) => {
|
|
3518
3624
|
timer = setTimeout(() => {
|
|
3519
3625
|
loadingTask.destroy();
|
|
3520
|
-
reject(new (0,
|
|
3626
|
+
reject(new (0, _chunkMI655NV5cjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3521
3627
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3522
3628
|
})
|
|
3523
3629
|
]);
|
|
@@ -3526,15 +3632,15 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3526
3632
|
}
|
|
3527
3633
|
}
|
|
3528
3634
|
async function parsePdfDocument(buffer, options) {
|
|
3529
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
3530
|
-
const ocrOptionError =
|
|
3531
|
-
if (ocrOptionError) throw new (0,
|
|
3532
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
3533
|
-
const ocrBuffer = _optionalChain([options, 'optionalAccess',
|
|
3635
|
+
const formulaBuffer = _optionalChain([options, 'optionalAccess', _327 => _327.formulaOcr]) ? buffer : null;
|
|
3636
|
+
const ocrOptionError = _chunkSJ5OZXELcjs.validateOcrOptions.call(void 0, options);
|
|
3637
|
+
if (ocrOptionError) throw new (0, _chunkMI655NV5cjs.KordocError)(ocrOptionError);
|
|
3638
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _328 => _328.ocr]) === void 0 && await _chunkNLGOMLGUcjs.ocrModelsCached.call(void 0, _chunkNLGOMLGUcjs.resolveOcrModels.call(void 0, options));
|
|
3639
|
+
const ocrBuffer = _optionalChain([options, 'optionalAccess', _329 => _329.ocr]) || autoOcr ? buffer : null;
|
|
3534
3640
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3535
3641
|
try {
|
|
3536
3642
|
const pageCount = doc.numPages;
|
|
3537
|
-
if (pageCount === 0) throw new (0,
|
|
3643
|
+
if (pageCount === 0) throw new (0, _chunkMI655NV5cjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3538
3644
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3539
3645
|
await extractPdfMetadata(doc, metadata);
|
|
3540
3646
|
const blocks = [];
|
|
@@ -3543,8 +3649,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3543
3649
|
let totalChars = 0;
|
|
3544
3650
|
let totalTextBytes = 0;
|
|
3545
3651
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
3546
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3547
|
-
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess',
|
|
3652
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _330 => _330.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
3653
|
+
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _331 => _331.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
|
|
3548
3654
|
warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
|
|
3549
3655
|
}
|
|
3550
3656
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -3563,10 +3669,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3563
3669
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3564
3670
|
const carry = {};
|
|
3565
3671
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3566
|
-
const wrapLexicon = new (0,
|
|
3672
|
+
const wrapLexicon = new (0, _chunkNLGOMLGUcjs.WrapLexicon)();
|
|
3567
3673
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3568
3674
|
const headerContext = [];
|
|
3569
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
3675
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _332 => _332.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
3570
3676
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
3571
3677
|
let contextPage;
|
|
3572
3678
|
try {
|
|
@@ -3576,7 +3682,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3576
3682
|
headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
|
|
3577
3683
|
} catch (e6) {
|
|
3578
3684
|
} finally {
|
|
3579
|
-
_optionalChain([contextPage, 'optionalAccess',
|
|
3685
|
+
_optionalChain([contextPage, 'optionalAccess', _333 => _333.cleanup, 'call', _334 => _334()]);
|
|
3580
3686
|
}
|
|
3581
3687
|
}
|
|
3582
3688
|
}
|
|
@@ -3603,15 +3709,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3603
3709
|
return void 0;
|
|
3604
3710
|
}
|
|
3605
3711
|
};
|
|
3606
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
3712
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _335 => _335(loadedName), 'optionalAccess', _336 => _336.differences]);
|
|
3607
3713
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3608
3714
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3609
|
-
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call',
|
|
3715
|
+
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _337 => _337(n), 'optionalAccess', _338 => _338.name]));
|
|
3610
3716
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
3611
3717
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3612
3718
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3613
|
-
const items =
|
|
3614
|
-
const filtered =
|
|
3719
|
+
const items = _chunkNLGOMLGUcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3720
|
+
const filtered = _chunkNLGOMLGUcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3615
3721
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3616
3722
|
const visible = dropTabLeaderDots(joined);
|
|
3617
3723
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3635,27 +3741,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3635
3741
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
3636
3742
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
3637
3743
|
} : rawOps;
|
|
3638
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
3744
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _339 => _339(loadedName), 'optionalAccess', _340 => _340.name]));
|
|
3639
3745
|
remapControlGlyphs(visible, differencesOf);
|
|
3640
|
-
await
|
|
3746
|
+
await _chunkNLGOMLGUcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3641
3747
|
const faces = /* @__PURE__ */ new Map();
|
|
3642
3748
|
for (const it of visible) {
|
|
3643
3749
|
if (!it.fontName) continue;
|
|
3644
3750
|
let face = faces.get(it.fontName);
|
|
3645
3751
|
if (face === void 0) {
|
|
3646
3752
|
const obj = fontObj(it.fontName);
|
|
3647
|
-
face = _optionalChain([obj, 'optionalAccess',
|
|
3753
|
+
face = _optionalChain([obj, 'optionalAccess', _341 => _341.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
|
|
3648
3754
|
faces.set(it.fontName, face);
|
|
3649
3755
|
}
|
|
3650
3756
|
it.fontName = face;
|
|
3651
|
-
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call',
|
|
3757
|
+
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _342 => _342(face), 'optionalAccess', _343 => _343.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3652
3758
|
}
|
|
3653
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3654
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3759
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkSJ5OZXELcjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3760
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkSJ5OZXELcjs.escapeLiteralTags.call(void 0, it.text);
|
|
3655
3761
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3656
3762
|
const pageArea = pageW * pageH;
|
|
3657
3763
|
if (pageArea > 0) {
|
|
3658
|
-
const imageRegions =
|
|
3764
|
+
const imageRegions = _chunkNLGOMLGUcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3659
3765
|
let uncovered = 0;
|
|
3660
3766
|
for (const r of imageRegions) {
|
|
3661
3767
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3681,15 +3787,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3681
3787
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3682
3788
|
}
|
|
3683
3789
|
const marks = superscriptNoteMarks(visible);
|
|
3684
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3790
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkNLGOMLGUcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3685
3791
|
const stamp = marginStamp(visible);
|
|
3686
3792
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3687
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
3688
|
-
const pageBlocks = orderTwoUpPage(
|
|
3793
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _344 => _344.tables]) !== false ? await _chunkNLGOMLGUcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3794
|
+
const pageBlocks = orderTwoUpPage(_chunkNLGOMLGUcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _345 => _345.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3689
3795
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3690
3796
|
for (const b of pageBlocks) blocks.push(b);
|
|
3691
3797
|
try {
|
|
3692
|
-
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess',
|
|
3798
|
+
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _346 => _346.images]) !== false);
|
|
3693
3799
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
3694
3800
|
extractedImages.push(...pageImages);
|
|
3695
3801
|
} catch (e9) {
|
|
@@ -3708,17 +3814,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3708
3814
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
3709
3815
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
3710
3816
|
pageQuality.push(quality);
|
|
3711
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3817
|
+
if (_optionalChain([options, 'optionalAccess', _347 => _347.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3712
3818
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3713
3819
|
}
|
|
3714
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3820
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkMI655NV5cjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3715
3821
|
parsedPages++;
|
|
3716
|
-
_optionalChain([options, 'optionalAccess',
|
|
3822
|
+
_optionalChain([options, 'optionalAccess', _348 => _348.onProgress, 'optionalCall', _349 => _349(parsedPages, totalTarget)]);
|
|
3717
3823
|
} catch (pageErr) {
|
|
3718
|
-
if (pageErr instanceof
|
|
3824
|
+
if (pageErr instanceof _chunkMI655NV5cjs.KordocError) throw pageErr;
|
|
3719
3825
|
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" });
|
|
3720
3826
|
} finally {
|
|
3721
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
3827
|
+
_optionalChain([loadedPage, 'optionalAccess', _350 => _350.cleanup, 'call', _351 => _351()]);
|
|
3722
3828
|
}
|
|
3723
3829
|
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
3724
3830
|
await doc.cleanup();
|
|
@@ -3726,14 +3832,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3726
3832
|
}
|
|
3727
3833
|
}
|
|
3728
3834
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
3729
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
3835
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _352 => _352.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
3730
3836
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
3731
3837
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
3732
|
-
const ocrRegions = _optionalChain([options, 'optionalAccess',
|
|
3838
|
+
const ocrRegions = _optionalChain([options, 'optionalAccess', _353 => _353.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _354 => _354.ocr]) === true) : /* @__PURE__ */ new Map();
|
|
3733
3839
|
if (ocrBuffer) {
|
|
3734
3840
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
3735
3841
|
const targets = /* @__PURE__ */ new Set();
|
|
3736
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3842
|
+
if (_optionalChain([options, 'optionalAccess', _355 => _355.ocr]) === "force" || isImageBased) {
|
|
3737
3843
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
3738
3844
|
} else {
|
|
3739
3845
|
for (const pq of pageQuality) {
|
|
@@ -3746,25 +3852,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3746
3852
|
}
|
|
3747
3853
|
if (targets.size > 0) {
|
|
3748
3854
|
try {
|
|
3749
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3750
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
3751
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
3752
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3753
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
3754
|
-
for (const obs of ocrPageBlocks.values())
|
|
3855
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-RKXDY3ZA.cjs")));
|
|
3856
|
+
const mode = typeof _optionalChain([options, 'optionalAccess', _356 => _356.ocr]) === "function" ? options.ocr : "builtin";
|
|
3857
|
+
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _357 => _357.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _358 => _358.find, 'call', _359 => _359((q) => q.page === p), 'optionalAccess', _360 => _360.needsOcr])));
|
|
3858
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-RKXDY3ZA.cjs")));
|
|
3859
|
+
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _361 => _361.onProgress]), _optionalChain([options, 'optionalAccess', _362 => _362.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
3860
|
+
for (const obs of ocrPageBlocks.values()) _chunkSJ5OZXELcjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3755
3861
|
if (ocrPageBlocks.size > 0) {
|
|
3756
3862
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3757
3863
|
for (const [p, obs] of ocrPageBlocks) {
|
|
3758
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
3759
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3864
|
+
const needsOcr = _optionalChain([pageQuality, 'access', _363 => _363.find, 'call', _364 => _364((q) => q.page === p), 'optionalAccess', _365 => _365.needsOcr]);
|
|
3865
|
+
if (_optionalChain([options, 'optionalAccess', _366 => _366.ocr]) === "force" || isImageBased || needsOcr) {
|
|
3760
3866
|
replacePages.add(p);
|
|
3761
3867
|
ocrDone.add(p);
|
|
3762
3868
|
continue;
|
|
3763
3869
|
}
|
|
3764
3870
|
const regions = ocrRegions.get(p);
|
|
3765
|
-
if (!regions ||
|
|
3871
|
+
if (!regions || _chunkNLGOMLGUcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3766
3872
|
ocrDone.add(p);
|
|
3767
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
3873
|
+
if (_optionalChain([pageImageBlocks, 'access', _367 => _367.get, 'call', _368 => _368(p), 'optionalAccess', _369 => _369.length]) === 1) pageImageBlocks.delete(p);
|
|
3768
3874
|
}
|
|
3769
3875
|
if (replacePages.size) {
|
|
3770
3876
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -3814,18 +3920,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3814
3920
|
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" });
|
|
3815
3921
|
}
|
|
3816
3922
|
}
|
|
3817
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3818
|
-
const removed =
|
|
3819
|
-
const running =
|
|
3923
|
+
if (_optionalChain([options, 'optionalAccess', _370 => _370.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3924
|
+
const removed = _chunkNLGOMLGUcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3925
|
+
const running = _chunkNLGOMLGUcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
3820
3926
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3821
3927
|
blocks.splice(removed[ri], 1);
|
|
3822
3928
|
}
|
|
3823
|
-
const stripped =
|
|
3929
|
+
const stripped = _chunkNLGOMLGUcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3824
3930
|
if (stripped !== blocks) {
|
|
3825
3931
|
blocks.length = 0;
|
|
3826
3932
|
blocks.push(...stripped);
|
|
3827
3933
|
}
|
|
3828
|
-
const kept =
|
|
3934
|
+
const kept = _chunkNLGOMLGUcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3829
3935
|
if (kept !== blocks) {
|
|
3830
3936
|
blocks.length = 0;
|
|
3831
3937
|
blocks.push(...kept);
|
|
@@ -3833,15 +3939,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3833
3939
|
}
|
|
3834
3940
|
mergeContinuedCells(blocks, pageHeights);
|
|
3835
3941
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3836
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3837
|
-
const boxes =
|
|
3942
|
+
if (_optionalChain([options, 'optionalAccess', _371 => _371.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3943
|
+
const boxes = _chunkNLGOMLGUcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3838
3944
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3839
3945
|
}
|
|
3840
3946
|
splitContactTables(blocks);
|
|
3841
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3842
|
-
|
|
3947
|
+
if (!_optionalChain([options, 'optionalAccess', _372 => _372.keepTrailingEmptyCols])) _chunkNLGOMLGUcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3948
|
+
_chunkNLGOMLGUcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3843
3949
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3844
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3950
|
+
if (_optionalChain([options, 'optionalAccess', _373 => _373.formulaOcr]) && formulaBuffer) {
|
|
3845
3951
|
try {
|
|
3846
3952
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
3847
3953
|
} catch (e) {
|
|
@@ -3851,54 +3957,54 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3851
3957
|
});
|
|
3852
3958
|
}
|
|
3853
3959
|
}
|
|
3854
|
-
const medianFontSize =
|
|
3960
|
+
const medianFontSize = _chunkNLGOMLGUcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3855
3961
|
if (medianFontSize > 0) {
|
|
3856
|
-
|
|
3857
|
-
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3962
|
+
_chunkNLGOMLGUcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3963
|
+
}
|
|
3964
|
+
_chunkNLGOMLGUcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3965
|
+
_chunkNLGOMLGUcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3966
|
+
_chunkNLGOMLGUcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3967
|
+
_chunkNLGOMLGUcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3968
|
+
_chunkNLGOMLGUcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3969
|
+
_chunkNLGOMLGUcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3970
|
+
_chunkNLGOMLGUcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3971
|
+
_chunkNLGOMLGUcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3866
3972
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3867
|
-
|
|
3868
|
-
|
|
3973
|
+
_chunkNLGOMLGUcjs.detectTableCaptions.call(void 0, blocks);
|
|
3974
|
+
_chunkNLGOMLGUcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3869
3975
|
sanitizeBlockControlChars(blocks);
|
|
3870
3976
|
let outBlocks = splitSingleCellTables(blocks);
|
|
3871
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3977
|
+
if (_optionalChain([options, 'optionalAccess', _374 => _374.layoutTables]) !== "keep") {
|
|
3872
3978
|
blocks.length = 0;
|
|
3873
3979
|
for (const block of outBlocks) blocks.push(block);
|
|
3874
3980
|
}
|
|
3875
3981
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
3876
3982
|
outBlocks = relocateEndnotes(outBlocks);
|
|
3877
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3983
|
+
if (_optionalChain([options, 'optionalAccess', _375 => _375.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
3878
3984
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
3879
3985
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
3880
3986
|
if (!b.bbox || !h) return false;
|
|
3881
3987
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
3882
3988
|
});
|
|
3883
3989
|
joinLatinCellWraps(outBlocks);
|
|
3884
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3990
|
+
if (_optionalChain([options, 'optionalAccess', _376 => _376.layoutTables]) !== "keep") {
|
|
3885
3991
|
const hancom = await isHancomPdf(doc);
|
|
3886
3992
|
const shown = /* @__PURE__ */ new Map();
|
|
3887
3993
|
const markContent = (bs) => {
|
|
3888
3994
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3889
|
-
if (
|
|
3890
|
-
const lines =
|
|
3891
|
-
if (lines)
|
|
3995
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(c)) _chunkSJ5OZXELcjs.CONTENT_CELLS.add(c);
|
|
3996
|
+
const lines = _chunkNLGOMLGUcjs.CELL_LINES.get(c);
|
|
3997
|
+
if (lines) _chunkSJ5OZXELcjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
3892
3998
|
markContent(c.blocks);
|
|
3893
3999
|
}
|
|
3894
4000
|
};
|
|
3895
4001
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3896
4002
|
if (b.type !== "table") return [b];
|
|
3897
|
-
if (!hancom && b.table &&
|
|
4003
|
+
if (!hancom && b.table && _chunkNLGOMLGUcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3898
4004
|
let v = shown.get(b);
|
|
3899
4005
|
if (!v) {
|
|
3900
4006
|
markContent([b]);
|
|
3901
|
-
shown.set(b, v =
|
|
4007
|
+
shown.set(b, v = _chunkSJ5OZXELcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _377 => _377.keepTrailingEmptyCols])));
|
|
3902
4008
|
}
|
|
3903
4009
|
return v;
|
|
3904
4010
|
});
|
|
@@ -3907,13 +4013,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3907
4013
|
blocks.length = 0;
|
|
3908
4014
|
for (const b of kept) blocks.push(b);
|
|
3909
4015
|
}
|
|
3910
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3911
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
4016
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkSJ5OZXELcjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _378 => _378.tableFormat]) }), { keepLoneNumbers: true }));
|
|
4017
|
+
if (_optionalChain([options, 'optionalAccess', _379 => _379.tableFormat]) === "gfm") _chunkSJ5OZXELcjs.assignTableIds.call(void 0, blocks);
|
|
3912
4018
|
let markdown = finishMarkdown(outBlocks);
|
|
3913
4019
|
const outline = collectPdfOutline(outBlocks);
|
|
3914
4020
|
return {
|
|
3915
4021
|
markdown,
|
|
3916
|
-
pages:
|
|
4022
|
+
pages: _chunk2BCQVQO2cjs.blocksToPages.call(void 0, splitPageTables(_chunkNLGOMLGUcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3917
4023
|
blocks,
|
|
3918
4024
|
metadata,
|
|
3919
4025
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3922,7 +4028,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3922
4028
|
pageQuality,
|
|
3923
4029
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
3924
4030
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
3925
|
-
..._optionalChain([options, 'optionalAccess',
|
|
4031
|
+
..._optionalChain([options, 'optionalAccess', _380 => _380.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
3926
4032
|
};
|
|
3927
4033
|
} finally {
|
|
3928
4034
|
await doc.destroy().catch(() => {
|
|
@@ -3932,7 +4038,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3932
4038
|
async function extractPdfMetadata(doc, metadata) {
|
|
3933
4039
|
try {
|
|
3934
4040
|
const result = await doc.getMetadata();
|
|
3935
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
4041
|
+
if (!_optionalChain([result, 'optionalAccess', _381 => _381.info])) return;
|
|
3936
4042
|
const info = result.info;
|
|
3937
4043
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
3938
4044
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -3948,8 +4054,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
3948
4054
|
}
|
|
3949
4055
|
async function isHancomPdf(doc) {
|
|
3950
4056
|
try {
|
|
3951
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
3952
|
-
return [_optionalChain([info, 'optionalAccess',
|
|
4057
|
+
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _382 => _382.info]);
|
|
4058
|
+
return [_optionalChain([info, 'optionalAccess', _383 => _383.Producer]), _optionalChain([info, 'optionalAccess', _384 => _384.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
|
|
3953
4059
|
} catch (e11) {
|
|
3954
4060
|
return false;
|
|
3955
4061
|
}
|
|
@@ -3993,5 +4099,5 @@ function marginStamp(items) {
|
|
|
3993
4099
|
|
|
3994
4100
|
|
|
3995
4101
|
|
|
3996
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3997
|
-
//# sourceMappingURL=parser-
|
|
4102
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkNLGOMLGUcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkNLGOMLGUcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkNLGOMLGUcjs.removeHeaderFooterBlocks;
|
|
4103
|
+
//# sourceMappingURL=parser-OAXCXVQ4.cjs.map
|