kordoc 4.22.2 → 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 +10 -6
- package/dist/{-C437ZARA.js → -AOWV7MNY.js} +11 -11
- package/dist/{chunk-UMNKY2EZ.js → chunk-24YLYR6Q.js} +4 -4
- package/dist/{chunk-EKKZNKJD.cjs → chunk-2BCQVQO2.cjs} +3 -3
- package/dist/{chunk-EKKZNKJD.cjs.map → chunk-2BCQVQO2.cjs.map} +1 -1
- package/dist/{chunk-GFQIKYBV.js → chunk-3ANXRVI2.js} +3 -3
- package/dist/{chunk-CNMUT5YW.js → chunk-3H2IEU4V.js} +2 -2
- package/dist/{chunk-GVBQVXXB.js → chunk-4NQ4EZEE.js} +14 -4
- package/dist/chunk-4NQ4EZEE.js.map +1 -0
- package/dist/{chunk-56GBOIOE.js → chunk-6LIBF2ZB.js} +2 -2
- package/dist/{chunk-2X64TI7I.js → chunk-6QBBGZST.js} +2 -2
- package/dist/{chunk-FPUBEM3F.js → chunk-7XITVUAK.js} +11 -11
- package/dist/{chunk-S4KQUVBV.js → chunk-AXX5AQT4.js} +4 -4
- package/dist/{chunk-U3TZVR7A.js → chunk-BS2XWGT5.js} +2 -2
- package/dist/{chunk-4BJZGXNM.js → chunk-DKJ2RNDG.js} +2 -2
- package/dist/{chunk-IRP6QS3K.js → chunk-FDFXL7VJ.js} +3 -3
- package/dist/{chunk-YOFKJ7IM.js → chunk-IRNWAHHZ.js} +2 -2
- package/dist/{chunk-QFJCEHY7.js → chunk-J5PYESLX.js} +14 -4
- package/dist/chunk-J5PYESLX.js.map +1 -0
- package/dist/{chunk-AXR7OKQY.js → chunk-KBGNPGVY.js} +2 -2
- package/dist/{chunk-UV2G6XFA.js → chunk-M2X766AY.js} +2 -2
- package/dist/{chunk-YTEMFVZB.js → chunk-MEIQ476H.js} +2 -2
- package/dist/{chunk-AUWO57ED.cjs → chunk-MI655NV5.cjs} +2 -2
- package/dist/{chunk-AUWO57ED.cjs.map → chunk-MI655NV5.cjs.map} +1 -1
- package/dist/{chunk-ENV25MPM.cjs → chunk-NJEMRAIF.cjs} +24 -24
- package/dist/{chunk-ENV25MPM.cjs.map → chunk-NJEMRAIF.cjs.map} +1 -1
- package/dist/{chunk-I4BS4BXE.cjs → chunk-NLGOMLGU.cjs} +23 -23
- package/dist/{chunk-I4BS4BXE.cjs.map → chunk-NLGOMLGU.cjs.map} +1 -1
- package/dist/{chunk-ZLFUZM7H.cjs → chunk-O3OS6FAW.cjs} +3 -3
- package/dist/{chunk-ZLFUZM7H.cjs.map → chunk-O3OS6FAW.cjs.map} +1 -1
- package/dist/{chunk-4GCS7WJJ.js → chunk-O5E25RHU.js} +2 -2
- package/dist/{chunk-NGDMJICC.js → chunk-OIF5HRVP.js} +4 -4
- package/dist/{chunk-MED2MR6O.cjs → chunk-SJ5OZXEL.cjs} +23 -13
- package/dist/chunk-SJ5OZXEL.cjs.map +1 -0
- package/dist/{chunk-3LJ6QO53.js → chunk-SKRWKVVW.js} +3 -3
- package/dist/{chunk-VUC4JJUM.js → chunk-UCLDUUBX.js} +2 -2
- package/dist/{chunk-L6PFPBTK.js → chunk-VJCQOSMT.js} +2 -2
- package/dist/{chunk-DQXP3ELP.js → chunk-X45Q7EAC.js} +2 -2
- package/dist/{chunk-L6N4OMKR.js → chunk-YOGMCRM7.js} +54 -7
- package/dist/chunk-YOGMCRM7.js.map +1 -0
- package/dist/chunks-7KXTS7IV.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-3TVRNJ66.cjs → formula-5V2WG4BH.cjs} +9 -9
- package/dist/{formula-3TVRNJ66.cjs.map → formula-5V2WG4BH.cjs.map} +1 -1
- package/dist/{formula-HUENRCPJ.js → formula-C26FMMGO.js} +3 -3
- package/dist/{formula-43QBPAL5.js → formula-W4OL33YQ.js} +4 -4
- package/dist/{image-ocr-OC3TCXMV.cjs → image-ocr-BELHEWPX.cjs} +17 -17
- package/dist/{image-ocr-OC3TCXMV.cjs.map → image-ocr-BELHEWPX.cjs.map} +1 -1
- package/dist/{image-ocr-HYAKWJGE.js → image-ocr-NSQ34Y6T.js} +9 -9
- package/dist/{image-ocr-BAHDLDV5.js → image-ocr-T72HMX2W.js} +6 -6
- package/dist/index.cjs +453 -406
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-23WBSECG.js → model-bundle-34T2LJB4.js} +5 -5
- package/dist/{models-NRZQY45P.js → models-TQH5EM6V.js} +5 -5
- package/dist/{parse-worker-v2-DPNXGJ73.js → parse-worker-v2-YEYLILGJ.js} +12 -12
- package/dist/{parser-XNOLC3MZ.js → parser-E6BG3ECD.js} +72 -12
- package/dist/parser-E6BG3ECD.js.map +1 -0
- package/dist/{parser-OKAQRZKM.cjs → parser-OAXCXVQ4.cjs} +327 -267
- package/dist/parser-OAXCXVQ4.cjs.map +1 -0
- package/dist/{parser-FNUQW2F3.js → parser-SJHCBL7T.js} +75 -15
- package/dist/parser-SJHCBL7T.js.map +1 -0
- package/dist/{pdf-ocr-FAGA3O6B.js → pdf-ocr-LGPSJM22.js} +6 -6
- package/dist/pdf-ocr-RKXDY3ZA.cjs +31 -0
- package/dist/{pdf-ocr-6UXBIQE6.cjs.map → pdf-ocr-RKXDY3ZA.cjs.map} +1 -1
- package/dist/{pdf-ocr-N5LYC5LA.js → pdf-ocr-T5ASSUKK.js} +9 -9
- package/dist/{profile-io-HC6FMYX4.js → profile-io-KMCAFTMG.js} +3 -3
- package/dist/{rasterize-QLTROEV2.js → rasterize-M52AKY7R.js} +3 -3
- package/dist/{redact-doc-V4KMM2QV.js → redact-doc-SWJC27LL.js} +11 -11
- package/dist/{render-V4S3QLTR.js → render-45AB5YZR.js} +7 -7
- package/dist/seal-7KWG6VHS.js +10 -0
- package/dist/{setup-HU7ZOQNM.js → setup-5PBMUI6M.js} +3 -3
- package/dist/visual-OMJNXLNZ.js +21 -0
- package/dist/{watch-NPIZ6DSJ.js → watch-QOGKV52T.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-GVBQVXXB.js.map +0 -1
- package/dist/chunk-L6N4OMKR.js.map +0 -1
- package/dist/chunk-MED2MR6O.cjs.map +0 -1
- package/dist/chunk-QFJCEHY7.js.map +0 -1
- package/dist/chunks-MPOOHZVO.js +0 -10
- package/dist/parser-FNUQW2F3.js.map +0 -1
- package/dist/parser-OKAQRZKM.cjs.map +0 -1
- package/dist/parser-XNOLC3MZ.js.map +0 -1
- package/dist/pdf-ocr-6UXBIQE6.cjs +0 -31
- package/dist/seal-MQ5TB5YZ.js +0 -10
- package/dist/visual-RLIFC4XC.js +0 -21
- /package/dist/{-C437ZARA.js.map → -AOWV7MNY.js.map} +0 -0
- /package/dist/{chunk-UMNKY2EZ.js.map → chunk-24YLYR6Q.js.map} +0 -0
- /package/dist/{chunk-GFQIKYBV.js.map → chunk-3ANXRVI2.js.map} +0 -0
- /package/dist/{chunk-CNMUT5YW.js.map → chunk-3H2IEU4V.js.map} +0 -0
- /package/dist/{chunk-56GBOIOE.js.map → chunk-6LIBF2ZB.js.map} +0 -0
- /package/dist/{chunk-2X64TI7I.js.map → chunk-6QBBGZST.js.map} +0 -0
- /package/dist/{chunk-FPUBEM3F.js.map → chunk-7XITVUAK.js.map} +0 -0
- /package/dist/{chunk-S4KQUVBV.js.map → chunk-AXX5AQT4.js.map} +0 -0
- /package/dist/{chunk-U3TZVR7A.js.map → chunk-BS2XWGT5.js.map} +0 -0
- /package/dist/{chunk-4BJZGXNM.js.map → chunk-DKJ2RNDG.js.map} +0 -0
- /package/dist/{chunk-IRP6QS3K.js.map → chunk-FDFXL7VJ.js.map} +0 -0
- /package/dist/{chunk-YOFKJ7IM.js.map → chunk-IRNWAHHZ.js.map} +0 -0
- /package/dist/{chunk-AXR7OKQY.js.map → chunk-KBGNPGVY.js.map} +0 -0
- /package/dist/{chunk-UV2G6XFA.js.map → chunk-M2X766AY.js.map} +0 -0
- /package/dist/{chunk-YTEMFVZB.js.map → chunk-MEIQ476H.js.map} +0 -0
- /package/dist/{chunk-4GCS7WJJ.js.map → chunk-O5E25RHU.js.map} +0 -0
- /package/dist/{chunk-NGDMJICC.js.map → chunk-OIF5HRVP.js.map} +0 -0
- /package/dist/{chunk-3LJ6QO53.js.map → chunk-SKRWKVVW.js.map} +0 -0
- /package/dist/{chunk-VUC4JJUM.js.map → chunk-UCLDUUBX.js.map} +0 -0
- /package/dist/{chunk-L6PFPBTK.js.map → chunk-VJCQOSMT.js.map} +0 -0
- /package/dist/{chunk-DQXP3ELP.js.map → chunk-X45Q7EAC.js.map} +0 -0
- /package/dist/{chunks-MPOOHZVO.js.map → chunks-7KXTS7IV.js.map} +0 -0
- /package/dist/{formula-HUENRCPJ.js.map → formula-C26FMMGO.js.map} +0 -0
- /package/dist/{formula-43QBPAL5.js.map → formula-W4OL33YQ.js.map} +0 -0
- /package/dist/{image-ocr-HYAKWJGE.js.map → image-ocr-NSQ34Y6T.js.map} +0 -0
- /package/dist/{image-ocr-BAHDLDV5.js.map → image-ocr-T72HMX2W.js.map} +0 -0
- /package/dist/{model-bundle-23WBSECG.js.map → model-bundle-34T2LJB4.js.map} +0 -0
- /package/dist/{models-NRZQY45P.js.map → models-TQH5EM6V.js.map} +0 -0
- /package/dist/{parse-worker-v2-DPNXGJ73.js.map → parse-worker-v2-YEYLILGJ.js.map} +0 -0
- /package/dist/{pdf-ocr-FAGA3O6B.js.map → pdf-ocr-LGPSJM22.js.map} +0 -0
- /package/dist/{pdf-ocr-N5LYC5LA.js.map → pdf-ocr-T5ASSUKK.js.map} +0 -0
- /package/dist/{profile-io-HC6FMYX4.js.map → profile-io-KMCAFTMG.js.map} +0 -0
- /package/dist/{rasterize-QLTROEV2.js.map → rasterize-M52AKY7R.js.map} +0 -0
- /package/dist/{redact-doc-V4KMM2QV.js.map → redact-doc-SWJC27LL.js.map} +0 -0
- /package/dist/{render-V4S3QLTR.js.map → render-45AB5YZR.js.map} +0 -0
- /package/dist/{seal-MQ5TB5YZ.js.map → seal-7KWG6VHS.js.map} +0 -0
- /package/dist/{setup-HU7ZOQNM.js.map → setup-5PBMUI6M.js.map} +0 -0
- /package/dist/{visual-RLIFC4XC.js.map → visual-OMJNXLNZ.js.map} +0 -0
- /package/dist/{watch-NPIZ6DSJ.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 _chunkI4BS4BXEcjs = require('./chunk-I4BS4BXE.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,7 +728,7 @@ 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;
|
|
@@ -695,11 +750,11 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
695
750
|
if (first < 3) return false;
|
|
696
751
|
const rows = [first - 3, first - 2, first - 1, first];
|
|
697
752
|
const separate = (c, cs) => rows.every((r) => {
|
|
698
|
-
const a = _optionalChain([owner, 'access',
|
|
699
|
-
return _optionalChain([a, 'optionalAccess',
|
|
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);
|
|
700
755
|
});
|
|
701
756
|
for (let c = 0; c < table.cols; c++) {
|
|
702
|
-
const a = _optionalChain([owner, 'access',
|
|
757
|
+
const a = _optionalChain([owner, 'access', _48 => _48[first], 'optionalAccess', _49 => _49[c]]);
|
|
703
758
|
if (!a || !separate(c, a.cs)) continue;
|
|
704
759
|
const marks = rows.map((r) => {
|
|
705
760
|
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
@@ -708,7 +763,7 @@ function hasNumberedRowSequence(table, owner, first) {
|
|
|
708
763
|
const head = marks[0];
|
|
709
764
|
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
710
765
|
for (let d = 0; d < table.cols; d++) {
|
|
711
|
-
const side = _optionalChain([owner, 'access',
|
|
766
|
+
const side = _optionalChain([owner, 'access', _50 => _50[first], 'optionalAccess', _51 => _51[d]]);
|
|
712
767
|
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
713
768
|
}
|
|
714
769
|
}
|
|
@@ -781,7 +836,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
|
781
836
|
function relocate(src, dst, from = 0) {
|
|
782
837
|
const out = [];
|
|
783
838
|
for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
|
|
784
|
-
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))));
|
|
785
840
|
if (at >= 0) out.push({ at, page: s.page });
|
|
786
841
|
}
|
|
787
842
|
return out;
|
|
@@ -805,7 +860,7 @@ function rowStarts(t) {
|
|
|
805
860
|
const starts = [];
|
|
806
861
|
for (let c = 0; c < t.cols; c++) {
|
|
807
862
|
if (covered.has(r * 1e5 + c)) continue;
|
|
808
|
-
const cell = _optionalChain([t, 'access',
|
|
863
|
+
const cell = _optionalChain([t, 'access', _55 => _55.cells, 'access', _56 => _56[r], 'optionalAccess', _57 => _57[c]]);
|
|
809
864
|
if (!cell) continue;
|
|
810
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);
|
|
811
866
|
starts.push({ cell, c });
|
|
@@ -816,8 +871,8 @@ function rowStarts(t) {
|
|
|
816
871
|
}
|
|
817
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));
|
|
818
873
|
function cellPage(cell) {
|
|
819
|
-
const p =
|
|
820
|
-
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;
|
|
821
876
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
822
877
|
}
|
|
823
878
|
function tableRowPages(t, pageNumber) {
|
|
@@ -828,7 +883,7 @@ function tableRowPages(t, pageNumber) {
|
|
|
828
883
|
for (const { cell } of starts) {
|
|
829
884
|
const p = cellPage(cell);
|
|
830
885
|
if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
|
|
831
|
-
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;
|
|
832
887
|
}
|
|
833
888
|
const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
|
|
834
889
|
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
|
|
@@ -845,8 +900,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
845
900
|
rows.forEach((starts, r) => {
|
|
846
901
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
847
902
|
for (const { cell } of starts) {
|
|
848
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
849
|
-
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))]);
|
|
850
905
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
851
906
|
}
|
|
852
907
|
});
|
|
@@ -856,7 +911,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
856
911
|
for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
|
|
857
912
|
const heads = covering(pt, pt.rows - 1);
|
|
858
913
|
for (const cell of covering(table, pt.rows - 1)) {
|
|
859
|
-
if (_optionalChain([cell, 'access',
|
|
914
|
+
if (_optionalChain([cell, 'access', _64 => _64.blocks, 'optionalAccess', _65 => _65.length])) continue;
|
|
860
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];
|
|
861
916
|
if (!head) continue;
|
|
862
917
|
const from = head.text.trimEnd().length;
|
|
@@ -867,7 +922,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
867
922
|
}
|
|
868
923
|
function splitCell(cell, page) {
|
|
869
924
|
if (page === void 0) return null;
|
|
870
|
-
if (_optionalChain([cell, 'access',
|
|
925
|
+
if (_optionalChain([cell, 'access', _66 => _66.blocks, 'optionalAccess', _67 => _67.length])) {
|
|
871
926
|
const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
|
|
872
927
|
if (k2 <= 0) return null;
|
|
873
928
|
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
@@ -894,8 +949,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
894
949
|
if (!splits.length) continue;
|
|
895
950
|
const clone = (cell, patch) => {
|
|
896
951
|
const out = { ...cell, ...patch };
|
|
897
|
-
const p =
|
|
898
|
-
if (p !== void 0)
|
|
952
|
+
const p = _chunkSJ5OZXELcjs.CELL_PAGES.get(cell);
|
|
953
|
+
if (p !== void 0) _chunkSJ5OZXELcjs.CELL_PAGES.set(out, p);
|
|
899
954
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
900
955
|
return out;
|
|
901
956
|
};
|
|
@@ -905,7 +960,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
905
960
|
for (const { cell, c, split } of splits) {
|
|
906
961
|
cells[r][c] = clone(cell, split.head);
|
|
907
962
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
908
|
-
|
|
963
|
+
_chunkSJ5OZXELcjs.CELL_PAGES.set(tail, split.page);
|
|
909
964
|
setSplits(tail, split.rest);
|
|
910
965
|
row[c] = tail;
|
|
911
966
|
}
|
|
@@ -947,7 +1002,7 @@ function anchorsOf(table) {
|
|
|
947
1002
|
for (let r = 0; r < table.rows; r++) {
|
|
948
1003
|
for (let c = 0; c < table.cols; c++) {
|
|
949
1004
|
if (covered.has(r * 1e5 + c)) continue;
|
|
950
|
-
const cell = _optionalChain([table, 'access',
|
|
1005
|
+
const cell = _optionalChain([table, 'access', _68 => _68.cells, 'access', _69 => _69[r], 'optionalAccess', _70 => _70[c]]);
|
|
951
1006
|
if (!cell) continue;
|
|
952
1007
|
out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
|
|
953
1008
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
@@ -1024,24 +1079,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1024
1079
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
1025
1080
|
}
|
|
1026
1081
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
1027
|
-
const lines =
|
|
1028
|
-
if (lines)
|
|
1029
|
-
if (
|
|
1030
|
-
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);
|
|
1031
1086
|
if (edges) {
|
|
1032
|
-
|
|
1087
|
+
_chunkSJ5OZXELcjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
1033
1088
|
edged = true;
|
|
1034
1089
|
}
|
|
1035
1090
|
return true;
|
|
1036
1091
|
};
|
|
1037
|
-
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;
|
|
1038
1093
|
for (const a of ca) {
|
|
1039
|
-
if (a.r < skip ||
|
|
1094
|
+
if (a.r < skip || _chunkNLGOMLGUcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
1040
1095
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
1041
1096
|
}
|
|
1042
1097
|
const first = prev.rows;
|
|
1043
1098
|
for (let c = 0; c < cols; c++) {
|
|
1044
|
-
const above = _optionalChain([owner, 'access',
|
|
1099
|
+
const above = _optionalChain([owner, 'access', _71 => _71[first - 1], 'optionalAccess', _72 => _72[c]]);
|
|
1045
1100
|
if (!above) continue;
|
|
1046
1101
|
let r = first;
|
|
1047
1102
|
while (r < rows && owner[r][c] === null) r++;
|
|
@@ -1060,9 +1115,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1060
1115
|
const grown = { ...above, rs: newRs };
|
|
1061
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;
|
|
1062
1117
|
}
|
|
1063
|
-
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]);
|
|
1064
1119
|
if (edged) {
|
|
1065
|
-
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);
|
|
1066
1121
|
}
|
|
1067
1122
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1068
1123
|
let r = prev.rows;
|
|
@@ -1071,7 +1126,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1071
1126
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1072
1127
|
}
|
|
1073
1128
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1074
|
-
const pr =
|
|
1129
|
+
const pr = _chunkNLGOMLGUcjs.ROW_RULES.get(prev), cr = _chunkNLGOMLGUcjs.ROW_RULES.get(curr);
|
|
1075
1130
|
const shifted = dx !== 0;
|
|
1076
1131
|
const cut = {
|
|
1077
1132
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1082,7 +1137,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1082
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 });
|
|
1083
1138
|
if (pr && cr) {
|
|
1084
1139
|
const cutRuled = pr.bottom || cr.top;
|
|
1085
|
-
|
|
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) });
|
|
1086
1141
|
}
|
|
1087
1142
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1088
1143
|
}
|
|
@@ -1143,19 +1198,19 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1143
1198
|
c = u.c + u.cs;
|
|
1144
1199
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1145
1200
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1146
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1147
|
-
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) => {
|
|
1148
1203
|
if (!r || r === first) return false;
|
|
1149
1204
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1150
1205
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1151
|
-
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]);
|
|
1152
1207
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1153
1208
|
});
|
|
1154
1209
|
if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1155
1210
|
if (!straddles && !midWord) continue;
|
|
1156
1211
|
if (u.r >= last && d.rs < 2) continue;
|
|
1157
|
-
const U =
|
|
1158
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1212
|
+
const U = _chunkNLGOMLGUcjs.CELL_LINES.get(a);
|
|
1213
|
+
if (!_optionalChain([U, 'optionalAccess', _73 => _73.length]) || !hasContent(b)) continue;
|
|
1159
1214
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1160
1215
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
1161
1216
|
const lu = U[U.length - 1];
|
|
@@ -1172,7 +1227,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1172
1227
|
return merged;
|
|
1173
1228
|
}
|
|
1174
1229
|
function longLastLine(c) {
|
|
1175
|
-
const L =
|
|
1230
|
+
const L = _chunkNLGOMLGUcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _74 => _74[L.length - 1]]);
|
|
1176
1231
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1177
1232
|
}
|
|
1178
1233
|
function filledToBottom(U, bottom) {
|
|
@@ -1205,8 +1260,8 @@ function nextItemHead(prev, next) {
|
|
|
1205
1260
|
return false;
|
|
1206
1261
|
}
|
|
1207
1262
|
function continuesAcross(u, d, x1, x2) {
|
|
1208
|
-
const U =
|
|
1209
|
-
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;
|
|
1210
1265
|
const last = U[U.length - 1];
|
|
1211
1266
|
const fs = last.h || 10;
|
|
1212
1267
|
let minL = Infinity, maxR = -Infinity;
|
|
@@ -1223,7 +1278,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1223
1278
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1224
1279
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1225
1280
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1226
|
-
const newItem =
|
|
1281
|
+
const newItem = _chunkNLGOMLGUcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1227
1282
|
const all = D.length ? U.concat(D) : U;
|
|
1228
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));
|
|
1229
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;
|
|
@@ -1240,12 +1295,12 @@ function outlineContinues(u, d) {
|
|
|
1240
1295
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1241
1296
|
}
|
|
1242
1297
|
function lineEnded(c, x1, x2, next) {
|
|
1243
|
-
const L =
|
|
1298
|
+
const L = _chunkNLGOMLGUcjs.CELL_LINES.get(c);
|
|
1244
1299
|
if (!L || L.length !== 1) return false;
|
|
1245
1300
|
const l = L[0], h = l.h || 10;
|
|
1246
|
-
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;
|
|
1247
1302
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1248
|
-
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;
|
|
1249
1304
|
}
|
|
1250
1305
|
function firstWordUnits(text) {
|
|
1251
1306
|
const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
|
|
@@ -1254,15 +1309,15 @@ function firstWordUnits(text) {
|
|
|
1254
1309
|
return units;
|
|
1255
1310
|
}
|
|
1256
1311
|
function appendCell(a, b) {
|
|
1257
|
-
if (
|
|
1258
|
-
if (_optionalChain([a, 'access',
|
|
1259
|
-
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 }));
|
|
1260
1315
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1261
1316
|
}
|
|
1262
1317
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1263
|
-
|
|
1318
|
+
_chunkNLGOMLGUcjs.joinCellEdges.call(void 0, a, b);
|
|
1264
1319
|
}
|
|
1265
|
-
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);
|
|
1266
1321
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1267
1322
|
var batchim = (ch) => {
|
|
1268
1323
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1270,7 +1325,7 @@ var batchim = (ch) => {
|
|
|
1270
1325
|
};
|
|
1271
1326
|
function clauseContinues(u, d) {
|
|
1272
1327
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1273
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1328
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkNLGOMLGUcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1274
1329
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1275
1330
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1276
1331
|
}
|
|
@@ -1278,8 +1333,8 @@ function quantityContinues(u, d) {
|
|
|
1278
1333
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1279
1334
|
}
|
|
1280
1335
|
function wordOverflows(u, d, x1, x2) {
|
|
1281
|
-
const U =
|
|
1282
|
-
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;
|
|
1283
1338
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1284
1339
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1285
1340
|
}
|
|
@@ -1289,7 +1344,7 @@ function listContinues(u, d, multi = false) {
|
|
|
1289
1344
|
const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
|
|
1290
1345
|
let last = -1, count = 0;
|
|
1291
1346
|
marks.forEach((m, i) => {
|
|
1292
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1347
|
+
if (_optionalChain([m, 'optionalAccess', _90 => _90.style]) === head.style) {
|
|
1293
1348
|
last = i;
|
|
1294
1349
|
count++;
|
|
1295
1350
|
}
|
|
@@ -1331,18 +1386,19 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1331
1386
|
return a !== null && b === a + 1;
|
|
1332
1387
|
})) return false;
|
|
1333
1388
|
if (cut.ruled && hasNumberedRowSequence(table, owner, first)) return false;
|
|
1389
|
+
if (cut.ruled && matchesIndependentRowPair(table, owner, first)) return false;
|
|
1334
1390
|
const contentPairs = pairs.filter(([u, d]) => hasContent(u.cell) && hasContent(d.cell));
|
|
1335
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])));
|
|
1336
1392
|
if (!carriedSplit) {
|
|
1337
1393
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1338
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;
|
|
1339
|
-
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;
|
|
1340
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;
|
|
1341
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));
|
|
1342
1398
|
if (!(cut.open && !newCell)) {
|
|
1343
1399
|
if (pairs.some((p) => p[1].rs > 1 && !flows(p))) return false;
|
|
1344
1400
|
const one = pairs.filter(([, d]) => d.rs === 1);
|
|
1345
|
-
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;
|
|
1346
1402
|
}
|
|
1347
1403
|
}
|
|
1348
1404
|
for (const [u, d] of pairs) {
|
|
@@ -1367,8 +1423,8 @@ function besideOwn(b, p, c) {
|
|
|
1367
1423
|
}
|
|
1368
1424
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
1369
1425
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
1370
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1371
|
-
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;
|
|
1372
1428
|
if (!h) return false;
|
|
1373
1429
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
1374
1430
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -1392,7 +1448,7 @@ function insideTable(b, t) {
|
|
|
1392
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;
|
|
1393
1449
|
}
|
|
1394
1450
|
function startsWithUnitRow(table) {
|
|
1395
|
-
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())]);
|
|
1396
1452
|
}
|
|
1397
1453
|
function sameHeadShape(a, b) {
|
|
1398
1454
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -1404,7 +1460,7 @@ function sameHeadShape(a, b) {
|
|
|
1404
1460
|
return tall;
|
|
1405
1461
|
}
|
|
1406
1462
|
function hasBoxTitle(t) {
|
|
1407
|
-
const titles = _nullishCoalesce(_optionalChain([t, 'access',
|
|
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())]), () => ( []));
|
|
1408
1464
|
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
1409
1465
|
const body = t.cells[titles[0].rowSpan];
|
|
1410
1466
|
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
@@ -1418,7 +1474,7 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1418
1474
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
1419
1475
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
1420
1476
|
const curr = blocks[j];
|
|
1421
|
-
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;
|
|
1422
1478
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1423
1479
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1424
1480
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
@@ -1428,19 +1484,19 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1428
1484
|
placeJoined(blocks, i, j, joined);
|
|
1429
1485
|
continue;
|
|
1430
1486
|
}
|
|
1431
|
-
if (
|
|
1487
|
+
if (_chunkNLGOMLGUcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1432
1488
|
blocks.splice(j, 1);
|
|
1433
1489
|
i++;
|
|
1434
1490
|
continue;
|
|
1435
1491
|
}
|
|
1436
1492
|
if (joined === null) continue;
|
|
1437
|
-
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;
|
|
1438
1494
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1439
1495
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1440
1496
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1441
1497
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1442
|
-
const px =
|
|
1443
|
-
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;
|
|
1444
1500
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1445
1501
|
let currCells = curr.table.cells;
|
|
1446
1502
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1451,16 +1507,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1451
1507
|
blocks.splice(j, 1);
|
|
1452
1508
|
continue;
|
|
1453
1509
|
}
|
|
1454
|
-
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))) {
|
|
1455
1511
|
const dx = px[0] - cx[0];
|
|
1456
1512
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1457
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
1513
|
+
if (_optionalChain([part, 'optionalAccess', _114 => _114.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1458
1514
|
const last = prev.table.rows - 1;
|
|
1459
1515
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1460
|
-
const U =
|
|
1461
|
-
|
|
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 }))));
|
|
1462
1518
|
}
|
|
1463
|
-
|
|
1519
|
+
_chunkNLGOMLGUcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1464
1520
|
placeJoined(blocks, i, j, part.table);
|
|
1465
1521
|
continue;
|
|
1466
1522
|
}
|
|
@@ -1473,20 +1529,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1473
1529
|
caption: prev.table.caption,
|
|
1474
1530
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1475
1531
|
};
|
|
1476
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1477
|
-
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);
|
|
1478
1534
|
placeJoined(blocks, i, j, merged);
|
|
1479
1535
|
}
|
|
1480
1536
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1481
1537
|
const t = blocks[i].table;
|
|
1482
|
-
if (blocks[i].type === "table" && t &&
|
|
1538
|
+
if (blocks[i].type === "table" && t && _chunkNLGOMLGUcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1483
1539
|
}
|
|
1484
1540
|
}
|
|
1485
1541
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1486
1542
|
if (!pageHeights) return;
|
|
1487
1543
|
for (let i = 0; i < blocks.length; i++) {
|
|
1488
1544
|
const L = blocks[i];
|
|
1489
|
-
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;
|
|
1490
1546
|
const ph = pageHeights.get(L.pageNumber);
|
|
1491
1547
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1492
1548
|
let s0 = i, s1 = i;
|
|
@@ -1515,12 +1571,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1515
1571
|
}
|
|
1516
1572
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1517
1573
|
const pt = prev.table, ct = curr.table;
|
|
1518
|
-
if (!
|
|
1519
|
-
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);
|
|
1520
1576
|
if (!px || !cx) return null;
|
|
1521
1577
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1522
1578
|
if (!shiftedSame(px, cx, false)) {
|
|
1523
|
-
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;
|
|
1524
1580
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1525
1581
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1526
1582
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -1532,19 +1588,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1532
1588
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1533
1589
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1534
1590
|
};
|
|
1535
|
-
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);
|
|
1536
1592
|
}
|
|
1537
|
-
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);
|
|
1538
1594
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1539
|
-
|
|
1540
|
-
const ys =
|
|
1541
|
-
if (ys)
|
|
1542
|
-
|
|
1543
|
-
|
|
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);
|
|
1544
1600
|
return res.table;
|
|
1545
1601
|
}
|
|
1546
1602
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
1547
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1603
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _121 => _121.get, 'call', _122 => _122(prev.pageNumber)]);
|
|
1548
1604
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
1549
1605
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
1550
1606
|
}
|
|
@@ -1555,21 +1611,21 @@ function headingRow(row) {
|
|
|
1555
1611
|
}
|
|
1556
1612
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
1557
1613
|
function looksContinued(prev, curr, pageHeights) {
|
|
1558
|
-
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)]);
|
|
1559
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;
|
|
1560
1616
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
1561
|
-
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]), () => ( ""));
|
|
1562
1618
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
1563
1619
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
1564
1620
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1565
1621
|
}
|
|
1566
1622
|
function pushedLead(prev, curr) {
|
|
1567
|
-
if (!
|
|
1623
|
+
if (!_chunkNLGOMLGUcjs.CLIP_TABLES.has(prev.table) || !_chunkNLGOMLGUcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1568
1624
|
const lead = leadRows(curr.table);
|
|
1569
1625
|
return lead.image && lead.height > prev.bbox.y;
|
|
1570
1626
|
}
|
|
1571
1627
|
function leadRows(t) {
|
|
1572
|
-
const ys =
|
|
1628
|
+
const ys = _chunkNLGOMLGUcjs.TABLE_ROWYS.get(t);
|
|
1573
1629
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1574
1630
|
const anchors = anchorsOf(t);
|
|
1575
1631
|
let end = 1, image = false;
|
|
@@ -1577,17 +1633,17 @@ function leadRows(t) {
|
|
|
1577
1633
|
for (const a of anchors) {
|
|
1578
1634
|
if (a.r !== r) continue;
|
|
1579
1635
|
end = Math.max(end, r + a.rs);
|
|
1580
|
-
if (
|
|
1636
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1581
1637
|
}
|
|
1582
1638
|
}
|
|
1583
1639
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1584
1640
|
}
|
|
1585
1641
|
function tailOf(b) {
|
|
1586
|
-
const t = b.table &&
|
|
1642
|
+
const t = b.table && _chunkNLGOMLGUcjs.TABLE_TAIL.get(b.table);
|
|
1587
1643
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1588
1644
|
}
|
|
1589
1645
|
function firstRowSig(t) {
|
|
1590
|
-
const x =
|
|
1646
|
+
const x = _chunkNLGOMLGUcjs.TABLE_COLXS.get(t);
|
|
1591
1647
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1592
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, "") }));
|
|
1593
1649
|
}
|
|
@@ -1612,9 +1668,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
1612
1668
|
}
|
|
1613
1669
|
function restartsTitledForm(head, curr) {
|
|
1614
1670
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
1615
|
-
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;
|
|
1616
1672
|
if (!full(head) || !full(curr)) return false;
|
|
1617
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
1673
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _134 => _134.text]), () => ( ""))).replace(/\s+/g, "");
|
|
1618
1674
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
1619
1675
|
if (!ht || !ct || ht === ct) return false;
|
|
1620
1676
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -1640,7 +1696,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1640
1696
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1641
1697
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1642
1698
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1643
|
-
const px =
|
|
1699
|
+
const px = _chunkNLGOMLGUcjs.TABLE_COLXS.get(pb.table), cx = _chunkNLGOMLGUcjs.TABLE_COLXS.get(cur.table);
|
|
1644
1700
|
if (!px || !cx) break;
|
|
1645
1701
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1646
1702
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1657,7 +1713,7 @@ function continueRowSpans(prevCells, currCells) {
|
|
|
1657
1713
|
if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
|
|
1658
1714
|
let anchor;
|
|
1659
1715
|
for (let r = last - 1; r >= 0 && !anchor; r--) {
|
|
1660
|
-
const a = _optionalChain([prevCells, 'access',
|
|
1716
|
+
const a = _optionalChain([prevCells, 'access', _135 => _135[r], 'optionalAccess', _136 => _136[c]]);
|
|
1661
1717
|
if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
|
|
1662
1718
|
}
|
|
1663
1719
|
if (!anchor) continue;
|
|
@@ -1711,12 +1767,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1711
1767
|
var COL_MATCH_TOL = 0.5;
|
|
1712
1768
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1713
1769
|
function lastRowCell(t, x1, x2) {
|
|
1714
|
-
const xs =
|
|
1770
|
+
const xs = _chunkNLGOMLGUcjs.TABLE_COLXS.get(t);
|
|
1715
1771
|
const covered = /* @__PURE__ */ new Set();
|
|
1716
1772
|
for (let r = 0; r < t.rows; r++) {
|
|
1717
1773
|
for (let c = 0; c < t.cols; c++) {
|
|
1718
1774
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1719
|
-
const cell = _optionalChain([t, 'access',
|
|
1775
|
+
const cell = _optionalChain([t, 'access', _137 => _137.cells, 'access', _138 => _138[r], 'optionalAccess', _139 => _139[c]]);
|
|
1720
1776
|
if (!cell) continue;
|
|
1721
1777
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
1722
1778
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -1729,25 +1785,28 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1729
1785
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1730
1786
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1731
1787
|
const part = blocks[j];
|
|
1732
|
-
const from = part.table ?
|
|
1733
|
-
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
|
+
}
|
|
1734
1793
|
let i = j - 1;
|
|
1735
1794
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
1736
1795
|
const prev = blocks[i];
|
|
1737
1796
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
1738
1797
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
1739
|
-
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]]);
|
|
1740
1799
|
if (!cell || !add) continue;
|
|
1741
1800
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1742
1801
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1743
1802
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1744
1803
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1745
|
-
if (
|
|
1746
|
-
|
|
1747
|
-
const lines =
|
|
1748
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
1749
|
-
if (part.pageNumber && part.bbox)
|
|
1750
|
-
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);
|
|
1751
1810
|
blocks.splice(j, 1);
|
|
1752
1811
|
if (cell.blocks && at > 0) {
|
|
1753
1812
|
const nextAt = cell.blocks[at];
|
|
@@ -1757,30 +1816,31 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1757
1816
|
if (cell.blocks) mergeCrossPageTables(cell.blocks, pageHeights);
|
|
1758
1817
|
}
|
|
1759
1818
|
}
|
|
1760
|
-
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1819
|
+
function unwrapContinuedTable(blocks, at, pageHeights, splitOnly = false) {
|
|
1761
1820
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1762
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
1763
|
-
const inner = _optionalChain([frame, 'access',
|
|
1764
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
1765
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
1766
|
-
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);
|
|
1767
1826
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1768
|
-
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)]);
|
|
1769
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;
|
|
1770
1830
|
blocks.splice(at, 1, ...inner);
|
|
1771
1831
|
}
|
|
1772
1832
|
function fillNestedContinuation(blocks, at) {
|
|
1773
1833
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1774
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
1775
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1776
|
-
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);
|
|
1777
1837
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1778
|
-
const add = _optionalChain([u, 'access',
|
|
1779
|
-
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;
|
|
1780
1840
|
cell.text = add.text;
|
|
1781
1841
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1782
|
-
if (
|
|
1783
|
-
|
|
1842
|
+
if (_chunkNLGOMLGUcjs.IMAGE_CELLS.has(add)) _chunkNLGOMLGUcjs.IMAGE_CELLS.add(cell);
|
|
1843
|
+
_chunkNLGOMLGUcjs.joinCellEdges.call(void 0, cell, add);
|
|
1784
1844
|
blocks.splice(at, 1);
|
|
1785
1845
|
}
|
|
1786
1846
|
|
|
@@ -1953,7 +2013,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
1953
2013
|
if (!cache.has(key)) {
|
|
1954
2014
|
let sym = null;
|
|
1955
2015
|
try {
|
|
1956
|
-
const data = _optionalChain([fontObj, 'call',
|
|
2016
|
+
const data = _optionalChain([fontObj, 'call', _169 => _169(font), 'optionalAccess', _170 => _170.data]);
|
|
1957
2017
|
const code = glyph.fontChar.codePointAt(0);
|
|
1958
2018
|
const outline = data && code !== void 0 ? readOutline(data, code) : null;
|
|
1959
2019
|
if (outline) sym = classifyOutline(outline);
|
|
@@ -1977,7 +2037,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
1977
2037
|
}
|
|
1978
2038
|
for (const [f, list] of byFont) {
|
|
1979
2039
|
const q = queues.get(f);
|
|
1980
|
-
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);
|
|
1981
2041
|
if (!q || q.length !== want) continue;
|
|
1982
2042
|
let k = 0;
|
|
1983
2043
|
for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
|
|
@@ -2000,15 +2060,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
2000
2060
|
function marginContextBlocks(raw, page, view) {
|
|
2001
2061
|
const [x1, y1, x2, y2] = view;
|
|
2002
2062
|
const width = x2 - x1, height = y2 - y1;
|
|
2003
|
-
const items =
|
|
2063
|
+
const items = _chunkNLGOMLGUcjs.filterHiddenText.call(void 0, _chunkNLGOMLGUcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
2004
2064
|
for (const item of items) {
|
|
2005
2065
|
item.x -= x1;
|
|
2006
2066
|
item.y -= y1;
|
|
2007
2067
|
}
|
|
2008
|
-
return
|
|
2009
|
-
const bbox =
|
|
2068
|
+
return _chunkNLGOMLGUcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2069
|
+
const bbox = _chunkNLGOMLGUcjs.computeBBox.call(void 0, line, page);
|
|
2010
2070
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
2011
|
-
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) }];
|
|
2012
2072
|
});
|
|
2013
2073
|
}
|
|
2014
2074
|
|
|
@@ -2044,7 +2104,7 @@ var WINANSI_REVERSE = {
|
|
|
2044
2104
|
};
|
|
2045
2105
|
function symbolFontTable(fontName) {
|
|
2046
2106
|
if (!fontName) return void 0;
|
|
2047
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2107
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkSJ5OZXELcjs.WINGDINGS;
|
|
2048
2108
|
return void 0;
|
|
2049
2109
|
}
|
|
2050
2110
|
function remapSymbolText(text, table) {
|
|
@@ -2172,7 +2232,7 @@ function layout(toks) {
|
|
|
2172
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);
|
|
2173
2233
|
if (!bar) continue;
|
|
2174
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);
|
|
2175
|
-
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 };
|
|
2176
2236
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
2177
2237
|
}
|
|
2178
2238
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -2274,7 +2334,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
2274
2334
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
2275
2335
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
2276
2336
|
const bar = cur.find(isBarItem);
|
|
2277
|
-
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));
|
|
2278
2338
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
2279
2339
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
2280
2340
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -2631,7 +2691,7 @@ function joinVerticalColumns(items) {
|
|
|
2631
2691
|
const groups = [];
|
|
2632
2692
|
for (const col of columns) {
|
|
2633
2693
|
const g2 = groups[groups.length - 1];
|
|
2634
|
-
const last = _optionalChain([g2, 'optionalAccess',
|
|
2694
|
+
const last = _optionalChain([g2, 'optionalAccess', _179 => _179[g2.length - 1]]);
|
|
2635
2695
|
const fs = col.items[0].fontSize;
|
|
2636
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);
|
|
2637
2697
|
else groups.push([col]);
|
|
@@ -2847,7 +2907,7 @@ function relocateEndnotes(blocks) {
|
|
|
2847
2907
|
}
|
|
2848
2908
|
const shapes = /* @__PURE__ */ new Map();
|
|
2849
2909
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
2850
|
-
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]]);
|
|
2851
2911
|
if (!main || !/#/.test(main)) return blocks;
|
|
2852
2912
|
const lastRun = (hs) => {
|
|
2853
2913
|
let run2 = [];
|
|
@@ -2910,7 +2970,7 @@ function dropTabLeaderDots(items) {
|
|
|
2910
2970
|
let run = [];
|
|
2911
2971
|
const flush = () => {
|
|
2912
2972
|
const last = run[run.length - 1];
|
|
2913
|
-
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]]);
|
|
2914
2974
|
const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
|
|
2915
2975
|
if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
|
|
2916
2976
|
const body = tailPage ? run.slice(0, -1) : run;
|
|
@@ -2998,7 +3058,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
2998
3058
|
open = true;
|
|
2999
3059
|
continue;
|
|
3000
3060
|
}
|
|
3001
|
-
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;
|
|
3002
3062
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
3003
3063
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
3004
3064
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -3021,7 +3081,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
3021
3081
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
3022
3082
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
3023
3083
|
function isRunningHead(block, page, pageHeight) {
|
|
3024
|
-
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()]);
|
|
3025
3085
|
if (!box || !text || !pageHeight) return false;
|
|
3026
3086
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
3027
3087
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -3029,7 +3089,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
3029
3089
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
3030
3090
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
3031
3091
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
3032
|
-
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;
|
|
3033
3093
|
if (!text.includes(" ")) return false;
|
|
3034
3094
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
3035
3095
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -3038,7 +3098,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
3038
3098
|
return right > left && box.width >= (right - left) * 0.6;
|
|
3039
3099
|
}
|
|
3040
3100
|
function unbalancedClose(text) {
|
|
3041
|
-
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)));
|
|
3042
3102
|
}
|
|
3043
3103
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
3044
3104
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -3054,7 +3114,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3054
3114
|
const sizes = /* @__PURE__ */ new Map();
|
|
3055
3115
|
let proseChars = 0;
|
|
3056
3116
|
for (const b of page) {
|
|
3057
|
-
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;
|
|
3058
3118
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
3059
3119
|
chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
|
|
3060
3120
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
@@ -3078,13 +3138,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3078
3138
|
const citedProse = /* @__PURE__ */ new Set();
|
|
3079
3139
|
const numberedProse = /* @__PURE__ */ new Set();
|
|
3080
3140
|
for (const page of byPage.values()) {
|
|
3081
|
-
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)]), () => ( ""))));
|
|
3082
3142
|
let chain = [];
|
|
3083
3143
|
const finish = () => {
|
|
3084
|
-
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;
|
|
3085
3145
|
for (const b of chain) numberedProse.add(b);
|
|
3086
3146
|
const first = chain[0], size = first.style.fontSize;
|
|
3087
|
-
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);
|
|
3088
3148
|
};
|
|
3089
3149
|
for (const b of numbered) {
|
|
3090
3150
|
const prev = chain.at(-1), size = b.style.fontSize;
|
|
@@ -3098,9 +3158,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3098
3158
|
}
|
|
3099
3159
|
for (let i = 0; i + 1 < blocks.length; i++) {
|
|
3100
3160
|
const prose = blocks[i], reference = blocks[i + 1];
|
|
3101
|
-
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access',
|
|
3102
|
-
const source = _nullishCoalesce(_optionalChain([reference, 'access',
|
|
3103
|
-
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;
|
|
3104
3164
|
citedProse.add(prose);
|
|
3105
3165
|
citedProse.add(reference);
|
|
3106
3166
|
}
|
|
@@ -3108,49 +3168,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3108
3168
|
const block = blocks[i];
|
|
3109
3169
|
if (block.type !== "heading" || !block.text) continue;
|
|
3110
3170
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3111
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3112
|
-
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]);
|
|
3113
3173
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3114
|
-
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;
|
|
3115
3175
|
const next = blocks[i + 1];
|
|
3116
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
3117
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
3118
|
-
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) {
|
|
3119
3179
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3120
3180
|
blocks.splice(i--, 1);
|
|
3121
3181
|
continue;
|
|
3122
3182
|
}
|
|
3123
|
-
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) {
|
|
3124
3184
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3125
3185
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
3126
3186
|
blocks.splice(i + 1, 1);
|
|
3127
3187
|
}
|
|
3128
3188
|
const after = blocks[i + 2];
|
|
3129
|
-
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])) {
|
|
3130
3190
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
3131
3191
|
blocks.splice(i + 1, 2);
|
|
3132
3192
|
}
|
|
3133
3193
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
3134
3194
|
const prev = blocks[i - 1];
|
|
3135
|
-
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) {
|
|
3136
3196
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3137
3197
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
3138
3198
|
blocks.splice(i--, 1);
|
|
3139
3199
|
continue;
|
|
3140
3200
|
}
|
|
3141
|
-
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)) {
|
|
3142
3202
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3143
3203
|
blocks.splice(i - 1, 1);
|
|
3144
3204
|
i -= 2;
|
|
3145
3205
|
continue;
|
|
3146
3206
|
}
|
|
3147
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3148
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
3149
|
-
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]), () => ( "")))]), () => ( ""));
|
|
3150
3210
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
3151
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
3152
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
3153
|
-
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;
|
|
3154
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)"·"가)" 앞머리 번호는 빼고 센다
|
|
3155
3215
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
3156
3216
|
block.type = "paragraph";
|
|
@@ -3200,34 +3260,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
3200
3260
|
function captionTableText(t) {
|
|
3201
3261
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
3202
3262
|
const [label, body] = t.cells[0];
|
|
3203
|
-
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;
|
|
3204
3264
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
3205
3265
|
}
|
|
3206
3266
|
function splitSingleCellTables(blocks) {
|
|
3207
3267
|
const out = [];
|
|
3208
3268
|
for (const b of blocks) {
|
|
3209
3269
|
const t = b.type === "table" ? b.table : void 0;
|
|
3210
|
-
const title = t &&
|
|
3270
|
+
const title = t && _chunkNLGOMLGUcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3211
3271
|
if (title) {
|
|
3212
3272
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3213
3273
|
continue;
|
|
3214
3274
|
}
|
|
3215
|
-
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;
|
|
3216
3276
|
const squash = (s) => s.replace(/\s/g, "");
|
|
3217
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;
|
|
3218
|
-
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)));
|
|
3219
3279
|
if (caption) {
|
|
3220
3280
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3221
3281
|
continue;
|
|
3222
3282
|
}
|
|
3223
|
-
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;
|
|
3224
3284
|
if (!cell) {
|
|
3225
3285
|
out.push(b);
|
|
3226
3286
|
continue;
|
|
3227
3287
|
}
|
|
3228
3288
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
3229
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
3230
|
-
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])) {
|
|
3231
3291
|
out.push(...splitSingleCellTables(cell.blocks));
|
|
3232
3292
|
continue;
|
|
3233
3293
|
}
|
|
@@ -3243,7 +3303,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3243
3303
|
const lines = cell.text.split("\n");
|
|
3244
3304
|
const out = [lines[0]];
|
|
3245
3305
|
for (const line of lines.slice(1)) {
|
|
3246
|
-
if (
|
|
3306
|
+
if (_chunkNLGOMLGUcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3247
3307
|
else out.push(line);
|
|
3248
3308
|
}
|
|
3249
3309
|
cell.text = out.join("\n");
|
|
@@ -3254,19 +3314,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
3254
3314
|
}
|
|
3255
3315
|
function cleanPdfText(text, opts) {
|
|
3256
3316
|
let clean = normalizeAraea(stripControlChars(text));
|
|
3257
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3317
|
+
if (!_optionalChain([opts, 'optionalAccess', _322 => _322.keepLoneNumbers])) {
|
|
3258
3318
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
3259
3319
|
}
|
|
3260
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3320
|
+
if (!_optionalChain([opts, 'optionalAccess', _323 => _323.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
3261
3321
|
return mergeKoreanLines(
|
|
3262
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))
|
|
3263
3323
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3264
3324
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3265
3325
|
if (line.startsWith("|")) {
|
|
3266
|
-
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>"));
|
|
3267
3327
|
}
|
|
3268
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
3269
|
-
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);
|
|
3270
3330
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3271
3331
|
}
|
|
3272
3332
|
function startsWithMarker(line) {
|
|
@@ -3298,7 +3358,7 @@ function mergeKoreanLines(text) {
|
|
|
3298
3358
|
continue;
|
|
3299
3359
|
}
|
|
3300
3360
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3301
|
-
result[result.length - 1] = prev +
|
|
3361
|
+
result[result.length - 1] = prev + _chunkNLGOMLGUcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3302
3362
|
} else {
|
|
3303
3363
|
result.push(curr);
|
|
3304
3364
|
}
|
|
@@ -3314,7 +3374,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3314
3374
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3315
3375
|
for (const a of annots) {
|
|
3316
3376
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3317
|
-
const url =
|
|
3377
|
+
const url = _chunkMI655NV5cjs.sanitizeHref.call(void 0, a.url);
|
|
3318
3378
|
if (!url) continue;
|
|
3319
3379
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3320
3380
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3366,7 +3426,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3366
3426
|
|
|
3367
3427
|
// src/pdf/formula-ocr.ts
|
|
3368
3428
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3369
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3429
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-5V2WG4BH.cjs")));
|
|
3370
3430
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3371
3431
|
await ensureFormulaModels((p) => {
|
|
3372
3432
|
if (p.phase === "download" && p.total) {
|
|
@@ -3557,13 +3617,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3557
3617
|
try {
|
|
3558
3618
|
return await Promise.race([
|
|
3559
3619
|
loadingTask.promise.catch((e) => {
|
|
3560
|
-
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)");
|
|
3561
3621
|
throw e;
|
|
3562
3622
|
}),
|
|
3563
3623
|
new Promise((_, reject) => {
|
|
3564
3624
|
timer = setTimeout(() => {
|
|
3565
3625
|
loadingTask.destroy();
|
|
3566
|
-
reject(new (0,
|
|
3626
|
+
reject(new (0, _chunkMI655NV5cjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3567
3627
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3568
3628
|
})
|
|
3569
3629
|
]);
|
|
@@ -3572,15 +3632,15 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3572
3632
|
}
|
|
3573
3633
|
}
|
|
3574
3634
|
async function parsePdfDocument(buffer, options) {
|
|
3575
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
3576
|
-
const ocrOptionError =
|
|
3577
|
-
if (ocrOptionError) throw new (0,
|
|
3578
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
3579
|
-
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;
|
|
3580
3640
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3581
3641
|
try {
|
|
3582
3642
|
const pageCount = doc.numPages;
|
|
3583
|
-
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.");
|
|
3584
3644
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3585
3645
|
await extractPdfMetadata(doc, metadata);
|
|
3586
3646
|
const blocks = [];
|
|
@@ -3589,8 +3649,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3589
3649
|
let totalChars = 0;
|
|
3590
3650
|
let totalTextBytes = 0;
|
|
3591
3651
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
3592
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3593
|
-
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))) {
|
|
3594
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" });
|
|
3595
3655
|
}
|
|
3596
3656
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -3609,10 +3669,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3609
3669
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3610
3670
|
const carry = {};
|
|
3611
3671
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3612
|
-
const wrapLexicon = new (0,
|
|
3672
|
+
const wrapLexicon = new (0, _chunkNLGOMLGUcjs.WrapLexicon)();
|
|
3613
3673
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3614
3674
|
const headerContext = [];
|
|
3615
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
3675
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _332 => _332.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
3616
3676
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
3617
3677
|
let contextPage;
|
|
3618
3678
|
try {
|
|
@@ -3622,7 +3682,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3622
3682
|
headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
|
|
3623
3683
|
} catch (e6) {
|
|
3624
3684
|
} finally {
|
|
3625
|
-
_optionalChain([contextPage, 'optionalAccess',
|
|
3685
|
+
_optionalChain([contextPage, 'optionalAccess', _333 => _333.cleanup, 'call', _334 => _334()]);
|
|
3626
3686
|
}
|
|
3627
3687
|
}
|
|
3628
3688
|
}
|
|
@@ -3649,15 +3709,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3649
3709
|
return void 0;
|
|
3650
3710
|
}
|
|
3651
3711
|
};
|
|
3652
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
3712
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _335 => _335(loadedName), 'optionalAccess', _336 => _336.differences]);
|
|
3653
3713
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3654
3714
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3655
|
-
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]));
|
|
3656
3716
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
3657
3717
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3658
3718
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3659
|
-
const items =
|
|
3660
|
-
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);
|
|
3661
3721
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3662
3722
|
const visible = dropTabLeaderDots(joined);
|
|
3663
3723
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3681,27 +3741,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3681
3741
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
3682
3742
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
3683
3743
|
} : rawOps;
|
|
3684
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
3744
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _339 => _339(loadedName), 'optionalAccess', _340 => _340.name]));
|
|
3685
3745
|
remapControlGlyphs(visible, differencesOf);
|
|
3686
|
-
await
|
|
3746
|
+
await _chunkNLGOMLGUcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3687
3747
|
const faces = /* @__PURE__ */ new Map();
|
|
3688
3748
|
for (const it of visible) {
|
|
3689
3749
|
if (!it.fontName) continue;
|
|
3690
3750
|
let face = faces.get(it.fontName);
|
|
3691
3751
|
if (face === void 0) {
|
|
3692
3752
|
const obj = fontObj(it.fontName);
|
|
3693
|
-
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;
|
|
3694
3754
|
faces.set(it.fontName, face);
|
|
3695
3755
|
}
|
|
3696
3756
|
it.fontName = face;
|
|
3697
|
-
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}\+/, ""));
|
|
3698
3758
|
}
|
|
3699
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3700
|
-
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);
|
|
3701
3761
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3702
3762
|
const pageArea = pageW * pageH;
|
|
3703
3763
|
if (pageArea > 0) {
|
|
3704
|
-
const imageRegions =
|
|
3764
|
+
const imageRegions = _chunkNLGOMLGUcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3705
3765
|
let uncovered = 0;
|
|
3706
3766
|
for (const r of imageRegions) {
|
|
3707
3767
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3727,15 +3787,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3727
3787
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3728
3788
|
}
|
|
3729
3789
|
const marks = superscriptNoteMarks(visible);
|
|
3730
|
-
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) });
|
|
3731
3791
|
const stamp = marginStamp(visible);
|
|
3732
3792
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3733
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
3734
|
-
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);
|
|
3735
3795
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3736
3796
|
for (const b of pageBlocks) blocks.push(b);
|
|
3737
3797
|
try {
|
|
3738
|
-
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);
|
|
3739
3799
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
3740
3800
|
extractedImages.push(...pageImages);
|
|
3741
3801
|
} catch (e9) {
|
|
@@ -3754,17 +3814,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3754
3814
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
3755
3815
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
3756
3816
|
pageQuality.push(quality);
|
|
3757
|
-
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) {
|
|
3758
3818
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3759
3819
|
}
|
|
3760
|
-
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");
|
|
3761
3821
|
parsedPages++;
|
|
3762
|
-
_optionalChain([options, 'optionalAccess',
|
|
3822
|
+
_optionalChain([options, 'optionalAccess', _348 => _348.onProgress, 'optionalCall', _349 => _349(parsedPages, totalTarget)]);
|
|
3763
3823
|
} catch (pageErr) {
|
|
3764
|
-
if (pageErr instanceof
|
|
3824
|
+
if (pageErr instanceof _chunkMI655NV5cjs.KordocError) throw pageErr;
|
|
3765
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" });
|
|
3766
3826
|
} finally {
|
|
3767
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
3827
|
+
_optionalChain([loadedPage, 'optionalAccess', _350 => _350.cleanup, 'call', _351 => _351()]);
|
|
3768
3828
|
}
|
|
3769
3829
|
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
3770
3830
|
await doc.cleanup();
|
|
@@ -3772,14 +3832,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3772
3832
|
}
|
|
3773
3833
|
}
|
|
3774
3834
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
3775
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
3835
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _352 => _352.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
3776
3836
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
3777
3837
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
3778
|
-
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();
|
|
3779
3839
|
if (ocrBuffer) {
|
|
3780
3840
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
3781
3841
|
const targets = /* @__PURE__ */ new Set();
|
|
3782
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3842
|
+
if (_optionalChain([options, 'optionalAccess', _355 => _355.ocr]) === "force" || isImageBased) {
|
|
3783
3843
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
3784
3844
|
} else {
|
|
3785
3845
|
for (const pq of pageQuality) {
|
|
@@ -3792,25 +3852,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3792
3852
|
}
|
|
3793
3853
|
if (targets.size > 0) {
|
|
3794
3854
|
try {
|
|
3795
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3796
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
3797
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
3798
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3799
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
3800
|
-
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 });
|
|
3801
3861
|
if (ocrPageBlocks.size > 0) {
|
|
3802
3862
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3803
3863
|
for (const [p, obs] of ocrPageBlocks) {
|
|
3804
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
3805
|
-
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) {
|
|
3806
3866
|
replacePages.add(p);
|
|
3807
3867
|
ocrDone.add(p);
|
|
3808
3868
|
continue;
|
|
3809
3869
|
}
|
|
3810
3870
|
const regions = ocrRegions.get(p);
|
|
3811
|
-
if (!regions ||
|
|
3871
|
+
if (!regions || _chunkNLGOMLGUcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3812
3872
|
ocrDone.add(p);
|
|
3813
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
3873
|
+
if (_optionalChain([pageImageBlocks, 'access', _367 => _367.get, 'call', _368 => _368(p), 'optionalAccess', _369 => _369.length]) === 1) pageImageBlocks.delete(p);
|
|
3814
3874
|
}
|
|
3815
3875
|
if (replacePages.size) {
|
|
3816
3876
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -3860,18 +3920,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3860
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" });
|
|
3861
3921
|
}
|
|
3862
3922
|
}
|
|
3863
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3864
|
-
const removed =
|
|
3865
|
-
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);
|
|
3866
3926
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3867
3927
|
blocks.splice(removed[ri], 1);
|
|
3868
3928
|
}
|
|
3869
|
-
const stripped =
|
|
3929
|
+
const stripped = _chunkNLGOMLGUcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3870
3930
|
if (stripped !== blocks) {
|
|
3871
3931
|
blocks.length = 0;
|
|
3872
3932
|
blocks.push(...stripped);
|
|
3873
3933
|
}
|
|
3874
|
-
const kept =
|
|
3934
|
+
const kept = _chunkNLGOMLGUcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3875
3935
|
if (kept !== blocks) {
|
|
3876
3936
|
blocks.length = 0;
|
|
3877
3937
|
blocks.push(...kept);
|
|
@@ -3879,15 +3939,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3879
3939
|
}
|
|
3880
3940
|
mergeContinuedCells(blocks, pageHeights);
|
|
3881
3941
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3882
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3883
|
-
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);
|
|
3884
3944
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3885
3945
|
}
|
|
3886
3946
|
splitContactTables(blocks);
|
|
3887
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3888
|
-
|
|
3947
|
+
if (!_optionalChain([options, 'optionalAccess', _372 => _372.keepTrailingEmptyCols])) _chunkNLGOMLGUcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3948
|
+
_chunkNLGOMLGUcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3889
3949
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3890
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3950
|
+
if (_optionalChain([options, 'optionalAccess', _373 => _373.formulaOcr]) && formulaBuffer) {
|
|
3891
3951
|
try {
|
|
3892
3952
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
3893
3953
|
} catch (e) {
|
|
@@ -3897,54 +3957,54 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3897
3957
|
});
|
|
3898
3958
|
}
|
|
3899
3959
|
}
|
|
3900
|
-
const medianFontSize =
|
|
3960
|
+
const medianFontSize = _chunkNLGOMLGUcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3901
3961
|
if (medianFontSize > 0) {
|
|
3902
|
-
|
|
3903
|
-
}
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
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);
|
|
3912
3972
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3913
|
-
|
|
3914
|
-
|
|
3973
|
+
_chunkNLGOMLGUcjs.detectTableCaptions.call(void 0, blocks);
|
|
3974
|
+
_chunkNLGOMLGUcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3915
3975
|
sanitizeBlockControlChars(blocks);
|
|
3916
3976
|
let outBlocks = splitSingleCellTables(blocks);
|
|
3917
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3977
|
+
if (_optionalChain([options, 'optionalAccess', _374 => _374.layoutTables]) !== "keep") {
|
|
3918
3978
|
blocks.length = 0;
|
|
3919
3979
|
for (const block of outBlocks) blocks.push(block);
|
|
3920
3980
|
}
|
|
3921
3981
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
3922
3982
|
outBlocks = relocateEndnotes(outBlocks);
|
|
3923
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3983
|
+
if (_optionalChain([options, 'optionalAccess', _375 => _375.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
3924
3984
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
3925
3985
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
3926
3986
|
if (!b.bbox || !h) return false;
|
|
3927
3987
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
3928
3988
|
});
|
|
3929
3989
|
joinLatinCellWraps(outBlocks);
|
|
3930
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3990
|
+
if (_optionalChain([options, 'optionalAccess', _376 => _376.layoutTables]) !== "keep") {
|
|
3931
3991
|
const hancom = await isHancomPdf(doc);
|
|
3932
3992
|
const shown = /* @__PURE__ */ new Map();
|
|
3933
3993
|
const markContent = (bs) => {
|
|
3934
3994
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3935
|
-
if (
|
|
3936
|
-
const lines =
|
|
3937
|
-
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));
|
|
3938
3998
|
markContent(c.blocks);
|
|
3939
3999
|
}
|
|
3940
4000
|
};
|
|
3941
4001
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3942
4002
|
if (b.type !== "table") return [b];
|
|
3943
|
-
if (!hancom && b.table &&
|
|
4003
|
+
if (!hancom && b.table && _chunkNLGOMLGUcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3944
4004
|
let v = shown.get(b);
|
|
3945
4005
|
if (!v) {
|
|
3946
4006
|
markContent([b]);
|
|
3947
|
-
shown.set(b, v =
|
|
4007
|
+
shown.set(b, v = _chunkSJ5OZXELcjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _377 => _377.keepTrailingEmptyCols])));
|
|
3948
4008
|
}
|
|
3949
4009
|
return v;
|
|
3950
4010
|
});
|
|
@@ -3953,13 +4013,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3953
4013
|
blocks.length = 0;
|
|
3954
4014
|
for (const b of kept) blocks.push(b);
|
|
3955
4015
|
}
|
|
3956
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3957
|
-
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);
|
|
3958
4018
|
let markdown = finishMarkdown(outBlocks);
|
|
3959
4019
|
const outline = collectPdfOutline(outBlocks);
|
|
3960
4020
|
return {
|
|
3961
4021
|
markdown,
|
|
3962
|
-
pages:
|
|
4022
|
+
pages: _chunk2BCQVQO2cjs.blocksToPages.call(void 0, splitPageTables(_chunkNLGOMLGUcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3963
4023
|
blocks,
|
|
3964
4024
|
metadata,
|
|
3965
4025
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3968,7 +4028,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3968
4028
|
pageQuality,
|
|
3969
4029
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
3970
4030
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
3971
|
-
..._optionalChain([options, 'optionalAccess',
|
|
4031
|
+
..._optionalChain([options, 'optionalAccess', _380 => _380.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
3972
4032
|
};
|
|
3973
4033
|
} finally {
|
|
3974
4034
|
await doc.destroy().catch(() => {
|
|
@@ -3978,7 +4038,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3978
4038
|
async function extractPdfMetadata(doc, metadata) {
|
|
3979
4039
|
try {
|
|
3980
4040
|
const result = await doc.getMetadata();
|
|
3981
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
4041
|
+
if (!_optionalChain([result, 'optionalAccess', _381 => _381.info])) return;
|
|
3982
4042
|
const info = result.info;
|
|
3983
4043
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
3984
4044
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -3994,8 +4054,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
3994
4054
|
}
|
|
3995
4055
|
async function isHancomPdf(doc) {
|
|
3996
4056
|
try {
|
|
3997
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
3998
|
-
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));
|
|
3999
4059
|
} catch (e11) {
|
|
4000
4060
|
return false;
|
|
4001
4061
|
}
|
|
@@ -4039,5 +4099,5 @@ function marginStamp(items) {
|
|
|
4039
4099
|
|
|
4040
4100
|
|
|
4041
4101
|
|
|
4042
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
4043
|
-
//# 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
|