kordoc 4.22.1 → 4.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/{-FYKHW5G6.js → -C437ZARA.js} +11 -11
- package/dist/{chunk-5SVJU22Z.js → chunk-2X64TI7I.js} +2 -2
- package/dist/{chunk-JHHXTNZQ.js → chunk-3LJ6QO53.js} +28 -6
- package/dist/chunk-3LJ6QO53.js.map +1 -0
- package/dist/{chunk-TSZQ4LMV.js → chunk-4BJZGXNM.js} +2 -2
- package/dist/{chunk-3H5QG6I2.js → chunk-4GCS7WJJ.js} +2 -2
- package/dist/{chunk-7FASIFQP.js → chunk-56GBOIOE.js} +2 -2
- package/dist/{chunk-M2CBEXHN.cjs → chunk-AUWO57ED.cjs} +2 -2
- package/dist/{chunk-M2CBEXHN.cjs.map → chunk-AUWO57ED.cjs.map} +1 -1
- package/dist/{chunk-5FD3LAKC.js → chunk-AXR7OKQY.js} +2 -2
- package/dist/{chunk-IB5TO2CO.js → chunk-CNMUT5YW.js} +2 -2
- package/dist/{chunk-ATODI25J.js → chunk-DQXP3ELP.js} +2 -2
- package/dist/{chunk-OSFB5SQS.cjs → chunk-EKKZNKJD.cjs} +3 -3
- package/dist/{chunk-OSFB5SQS.cjs.map → chunk-EKKZNKJD.cjs.map} +1 -1
- package/dist/{chunk-EXVTF6XE.cjs → chunk-ENV25MPM.cjs} +24 -24
- package/dist/{chunk-EXVTF6XE.cjs.map → chunk-ENV25MPM.cjs.map} +1 -1
- package/dist/{chunk-YE4IN3D7.js → chunk-FPUBEM3F.js} +11 -11
- package/dist/{chunk-5VBAHUGC.js → chunk-GFQIKYBV.js} +3 -3
- package/dist/{chunk-MDS3GH43.js → chunk-GVBQVXXB.js} +2 -2
- package/dist/{chunk-ZECSXHYP.cjs → chunk-I4BS4BXE.cjs} +188 -166
- package/dist/{chunk-ZECSXHYP.cjs.map → chunk-I4BS4BXE.cjs.map} +1 -1
- package/dist/{chunk-7RND4SNB.js → chunk-IRP6QS3K.js} +3 -3
- package/dist/{chunk-R37TFXMP.js → chunk-L6N4OMKR.js} +60 -28
- package/dist/chunk-L6N4OMKR.js.map +1 -0
- package/dist/{chunk-IK4W2M4P.js → chunk-L6PFPBTK.js} +2 -2
- package/dist/{chunk-RO7AORMO.cjs → chunk-MED2MR6O.cjs} +6 -6
- package/dist/{chunk-RO7AORMO.cjs.map → chunk-MED2MR6O.cjs.map} +1 -1
- package/dist/{chunk-MGJYVNDX.js → chunk-NGDMJICC.js} +29 -7
- package/dist/{chunk-JHHXTNZQ.js.map → chunk-NGDMJICC.js.map} +1 -1
- package/dist/{chunk-SMPK5TUQ.js → chunk-QFJCEHY7.js} +2 -2
- package/dist/{chunk-M4JC7TXG.js → chunk-S4KQUVBV.js} +4 -4
- package/dist/{chunk-AIAIBNIB.js → chunk-U3TZVR7A.js} +2 -2
- package/dist/{chunk-QH4B3PL7.js → chunk-UMNKY2EZ.js} +4 -4
- package/dist/{chunk-DOBJ7BW5.js → chunk-UV2G6XFA.js} +2 -2
- package/dist/{chunk-LHO7E3RW.js → chunk-VUC4JJUM.js} +2 -2
- package/dist/{chunk-3SPOIAST.js → chunk-YOFKJ7IM.js} +2 -2
- package/dist/{chunk-ME4NQSLE.js → chunk-YTEMFVZB.js} +2 -2
- package/dist/{chunk-B35C5HJK.cjs → chunk-ZLFUZM7H.cjs} +3 -3
- package/dist/{chunk-B35C5HJK.cjs.map → chunk-ZLFUZM7H.cjs.map} +1 -1
- package/dist/chunks-MPOOHZVO.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-PYDSQGLS.cjs → formula-3TVRNJ66.cjs} +9 -9
- package/dist/{formula-PYDSQGLS.cjs.map → formula-3TVRNJ66.cjs.map} +1 -1
- package/dist/{formula-JBTYYSKB.js → formula-43QBPAL5.js} +4 -4
- package/dist/{formula-RUS4SF3O.js → formula-HUENRCPJ.js} +3 -3
- package/dist/{image-ocr-VA6WV6E4.js → image-ocr-BAHDLDV5.js} +6 -6
- package/dist/{image-ocr-QJT4EIQU.js → image-ocr-HYAKWJGE.js} +9 -9
- package/dist/{image-ocr-PLNNCEOR.cjs → image-ocr-OC3TCXMV.cjs} +17 -17
- package/dist/{image-ocr-PLNNCEOR.cjs.map → image-ocr-OC3TCXMV.cjs.map} +1 -1
- package/dist/index.cjs +356 -324
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -28
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-U2YY7ATC.js → model-bundle-23WBSECG.js} +5 -5
- package/dist/{models-BOJ2SFCR.js → models-NRZQY45P.js} +5 -5
- package/dist/{parse-worker-v2-ZHMFK3U3.js → parse-worker-v2-DPNXGJ73.js} +12 -12
- package/dist/{parser-HM6N7J4R.js → parser-FNUQW2F3.js} +73 -27
- package/dist/parser-FNUQW2F3.js.map +1 -0
- package/dist/{parser-6337Z4U2.cjs → parser-OKAQRZKM.cjs} +318 -272
- package/dist/parser-OKAQRZKM.cjs.map +1 -0
- package/dist/{parser-A2EWLK2J.js → parser-XNOLC3MZ.js} +70 -24
- package/dist/parser-XNOLC3MZ.js.map +1 -0
- package/dist/pdf-ocr-6UXBIQE6.cjs +31 -0
- package/dist/{pdf-ocr-PGXNUFU7.cjs.map → pdf-ocr-6UXBIQE6.cjs.map} +1 -1
- package/dist/{pdf-ocr-JDER5BHI.js → pdf-ocr-FAGA3O6B.js} +6 -6
- package/dist/{pdf-ocr-MEVC6HXG.js → pdf-ocr-N5LYC5LA.js} +9 -9
- package/dist/{profile-io-OJ23SPYO.js → profile-io-HC6FMYX4.js} +3 -3
- package/dist/{rasterize-76CWCLSU.js → rasterize-QLTROEV2.js} +3 -3
- package/dist/{redact-doc-EZQIHRVT.js → redact-doc-V4KMM2QV.js} +11 -11
- package/dist/{render-JZFJPFWK.js → render-V4S3QLTR.js} +7 -7
- package/dist/seal-MQ5TB5YZ.js +10 -0
- package/dist/{setup-RIVS74JN.js → setup-HU7ZOQNM.js} +3 -3
- package/dist/visual-RLIFC4XC.js +21 -0
- package/dist/{watch-WMH222E5.js → watch-NPIZ6DSJ.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-MGJYVNDX.js.map +0 -1
- package/dist/chunk-R37TFXMP.js.map +0 -1
- package/dist/chunks-4XIAEJEX.js +0 -10
- package/dist/parser-6337Z4U2.cjs.map +0 -1
- package/dist/parser-A2EWLK2J.js.map +0 -1
- package/dist/parser-HM6N7J4R.js.map +0 -1
- package/dist/pdf-ocr-PGXNUFU7.cjs +0 -31
- package/dist/seal-P2NOP4LC.js +0 -10
- package/dist/visual-R5GGZBTU.js +0 -21
- /package/dist/{-FYKHW5G6.js.map → -C437ZARA.js.map} +0 -0
- /package/dist/{chunk-5SVJU22Z.js.map → chunk-2X64TI7I.js.map} +0 -0
- /package/dist/{chunk-TSZQ4LMV.js.map → chunk-4BJZGXNM.js.map} +0 -0
- /package/dist/{chunk-3H5QG6I2.js.map → chunk-4GCS7WJJ.js.map} +0 -0
- /package/dist/{chunk-7FASIFQP.js.map → chunk-56GBOIOE.js.map} +0 -0
- /package/dist/{chunk-5FD3LAKC.js.map → chunk-AXR7OKQY.js.map} +0 -0
- /package/dist/{chunk-IB5TO2CO.js.map → chunk-CNMUT5YW.js.map} +0 -0
- /package/dist/{chunk-ATODI25J.js.map → chunk-DQXP3ELP.js.map} +0 -0
- /package/dist/{chunk-YE4IN3D7.js.map → chunk-FPUBEM3F.js.map} +0 -0
- /package/dist/{chunk-5VBAHUGC.js.map → chunk-GFQIKYBV.js.map} +0 -0
- /package/dist/{chunk-MDS3GH43.js.map → chunk-GVBQVXXB.js.map} +0 -0
- /package/dist/{chunk-7RND4SNB.js.map → chunk-IRP6QS3K.js.map} +0 -0
- /package/dist/{chunk-IK4W2M4P.js.map → chunk-L6PFPBTK.js.map} +0 -0
- /package/dist/{chunk-SMPK5TUQ.js.map → chunk-QFJCEHY7.js.map} +0 -0
- /package/dist/{chunk-M4JC7TXG.js.map → chunk-S4KQUVBV.js.map} +0 -0
- /package/dist/{chunk-AIAIBNIB.js.map → chunk-U3TZVR7A.js.map} +0 -0
- /package/dist/{chunk-QH4B3PL7.js.map → chunk-UMNKY2EZ.js.map} +0 -0
- /package/dist/{chunk-DOBJ7BW5.js.map → chunk-UV2G6XFA.js.map} +0 -0
- /package/dist/{chunk-LHO7E3RW.js.map → chunk-VUC4JJUM.js.map} +0 -0
- /package/dist/{chunk-3SPOIAST.js.map → chunk-YOFKJ7IM.js.map} +0 -0
- /package/dist/{chunk-ME4NQSLE.js.map → chunk-YTEMFVZB.js.map} +0 -0
- /package/dist/{chunks-4XIAEJEX.js.map → chunks-MPOOHZVO.js.map} +0 -0
- /package/dist/{formula-JBTYYSKB.js.map → formula-43QBPAL5.js.map} +0 -0
- /package/dist/{formula-RUS4SF3O.js.map → formula-HUENRCPJ.js.map} +0 -0
- /package/dist/{image-ocr-VA6WV6E4.js.map → image-ocr-BAHDLDV5.js.map} +0 -0
- /package/dist/{image-ocr-QJT4EIQU.js.map → image-ocr-HYAKWJGE.js.map} +0 -0
- /package/dist/{model-bundle-U2YY7ATC.js.map → model-bundle-23WBSECG.js.map} +0 -0
- /package/dist/{models-BOJ2SFCR.js.map → models-NRZQY45P.js.map} +0 -0
- /package/dist/{parse-worker-v2-ZHMFK3U3.js.map → parse-worker-v2-DPNXGJ73.js.map} +0 -0
- /package/dist/{pdf-ocr-JDER5BHI.js.map → pdf-ocr-FAGA3O6B.js.map} +0 -0
- /package/dist/{pdf-ocr-MEVC6HXG.js.map → pdf-ocr-N5LYC5LA.js.map} +0 -0
- /package/dist/{profile-io-OJ23SPYO.js.map → profile-io-HC6FMYX4.js.map} +0 -0
- /package/dist/{rasterize-76CWCLSU.js.map → rasterize-QLTROEV2.js.map} +0 -0
- /package/dist/{redact-doc-EZQIHRVT.js.map → redact-doc-V4KMM2QV.js.map} +0 -0
- /package/dist/{render-JZFJPFWK.js.map → render-V4S3QLTR.js.map} +0 -0
- /package/dist/{seal-P2NOP4LC.js.map → seal-MQ5TB5YZ.js.map} +0 -0
- /package/dist/{setup-RIVS74JN.js.map → setup-HU7ZOQNM.js.map} +0 -0
- /package/dist/{visual-R5GGZBTU.js.map → visual-RLIFC4XC.js.map} +0 -0
- /package/dist/{watch-WMH222E5.js.map → watch-NPIZ6DSJ.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 _chunkEKKZNKJDcjs = require('./chunk-EKKZNKJD.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 _chunkI4BS4BXEcjs = require('./chunk-I4BS4BXE.cjs');
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
@@ -75,12 +75,12 @@ var _chunkZECSXHYPcjs = require('./chunk-ZECSXHYP.cjs');
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
var
|
|
79
|
-
require('./chunk-
|
|
78
|
+
var _chunkMED2MR6Ocjs = require('./chunk-MED2MR6O.cjs');
|
|
79
|
+
require('./chunk-ZLFUZM7H.cjs');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkAUWO57EDcjs = require('./chunk-AUWO57ED.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 = _chunkEKKZNKJDcjs.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,7 @@ 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]) && !_chunkI4BS4BXEcjs.IMAGE_CELLS.has(cell);
|
|
617
617
|
function matchesCompleteSiblingRow(table, owner, first) {
|
|
618
618
|
const pairs = [];
|
|
619
619
|
for (let c = 0; c < table.cols; ) {
|
|
@@ -679,6 +679,41 @@ function matchesCompleteRubricRow(table, owner, first) {
|
|
|
679
679
|
return peerMarks.length === marks.length && peerMarks.every((m, i) => m.n === marks[i].n) && values(row[score.c]).join("|") === scores.join("|") && norm(peer.slice(peerMarks[peerMarks.length - 1].at)) === tail;
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
|
+
var KO_ORDER = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558";
|
|
683
|
+
function itemMark(line) {
|
|
684
|
+
line = line.replace(/<\/?u>|~~/g, "").trim();
|
|
685
|
+
let m = /^(\d{1,2})([.)])(?!\d)/.exec(line);
|
|
686
|
+
if (m) return { style: "1" + m[2], n: +m[1] };
|
|
687
|
+
if (m = /^\((\d{1,2})\)/.exec(line)) return { style: "(1)", n: +m[1] };
|
|
688
|
+
if ((m = /^([가-하])([.)])/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "\uAC00" + m[2], n: KO_ORDER.indexOf(m[1]) };
|
|
689
|
+
if ((m = /^\(([가-하])\)/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "(\uAC00)", n: KO_ORDER.indexOf(m[1]) };
|
|
690
|
+
if (m = /^[①-⑳]/.exec(line)) return { style: "\u2460", n: m[0].charCodeAt(0) };
|
|
691
|
+
if (m = /^([A-Z])\.\s/.exec(line)) return { style: "A.", n: m[1].charCodeAt(0) };
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
function hasNumberedRowSequence(table, owner, first) {
|
|
695
|
+
if (first < 3) return false;
|
|
696
|
+
const rows = [first - 3, first - 2, first - 1, first];
|
|
697
|
+
const separate = (c, cs) => rows.every((r) => {
|
|
698
|
+
const a = _optionalChain([owner, 'access', _13 => _13[r], 'optionalAccess', _14 => _14[c]]), cell = _optionalChain([table, 'access', _15 => _15.cells, 'access', _16 => _16[r], 'optionalAccess', _17 => _17[c]]);
|
|
699
|
+
return _optionalChain([a, 'optionalAccess', _18 => _18.r]) === r && a.c === c && a.rs === 1 && a.cs === cs && !!cell && plain(cell) && !!textOf(cell);
|
|
700
|
+
});
|
|
701
|
+
for (let c = 0; c < table.cols; c++) {
|
|
702
|
+
const a = _optionalChain([owner, 'access', _19 => _19[first], 'optionalAccess', _20 => _20[c]]);
|
|
703
|
+
if (!a || !separate(c, a.cs)) continue;
|
|
704
|
+
const marks = rows.map((r) => {
|
|
705
|
+
const lines = textOf(table.cells[r][c]).split("\n"), firstMark = itemMark(lines[0]);
|
|
706
|
+
return firstMark && lines.slice(1).every((l) => !itemMark(l)) ? firstMark : null;
|
|
707
|
+
});
|
|
708
|
+
const head = marks[0];
|
|
709
|
+
if (!head || marks.some((m, i) => !m || m.style !== head.style || m.n !== head.n + i)) continue;
|
|
710
|
+
for (let d = 0; d < table.cols; d++) {
|
|
711
|
+
const side = _optionalChain([owner, 'access', _21 => _21[first], 'optionalAccess', _22 => _22[d]]);
|
|
712
|
+
if (side && (d + side.cs <= c || d >= c + a.cs) && separate(d, side.cs)) return true;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
682
717
|
|
|
683
718
|
// src/pdf/contact-table.ts
|
|
684
719
|
var CONTACT_HEAD = /^(?:담당\s*부서|<[^<>]+>)$/;
|
|
@@ -697,8 +732,25 @@ function splitContactTables(blocks) {
|
|
|
697
732
|
const whole = PERSON.exec(r[3].text.replace(/\s+/g, " ").trim());
|
|
698
733
|
return whole ? [whole] : null;
|
|
699
734
|
});
|
|
700
|
-
if (people.some((p) => !p) || rows.some((r) =>
|
|
735
|
+
if (people.some((p) => !p) || rows.some((r) => r[3].rowSpan !== 1 || r[3].colSpan !== 1)) continue;
|
|
736
|
+
let roleEnd = 0;
|
|
737
|
+
const validRoles = rows.every((r, i) => {
|
|
738
|
+
const role = r[2];
|
|
739
|
+
if (role.colSpan !== 1) return false;
|
|
740
|
+
if (i < roleEnd) return !role.text.trim() && role.rowSpan === 1;
|
|
741
|
+
if (!CONTACT_ROLE.test(role.text.replace(/\s+/g, "")) || role.rowSpan < 1 || i + role.rowSpan > t.rows) return false;
|
|
742
|
+
roleEnd = i + role.rowSpan;
|
|
743
|
+
return true;
|
|
744
|
+
});
|
|
745
|
+
if (!validRoles) continue;
|
|
701
746
|
if (!people.some((p) => p.some(spaced))) continue;
|
|
747
|
+
const one = (text) => ({ text, colSpan: 1, rowSpan: 1 });
|
|
748
|
+
const part = (i, k) => one(people[i].map((p) => p[k]).join("\n"));
|
|
749
|
+
if (rows.some((r) => r[2].rowSpan > 1)) {
|
|
750
|
+
t.cells = rows.map((r, i) => [...r.slice(0, 3), part(i, 1), part(i, 2), part(i, 3)]);
|
|
751
|
+
t.cols = 6;
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
702
754
|
const lead = [];
|
|
703
755
|
let ok = true;
|
|
704
756
|
for (const c of [0, 1]) {
|
|
@@ -719,8 +771,6 @@ function splitContactTables(blocks) {
|
|
|
719
771
|
lead.push(col);
|
|
720
772
|
}
|
|
721
773
|
if (!ok) continue;
|
|
722
|
-
const one = (text) => ({ text, colSpan: 1, rowSpan: 1 });
|
|
723
|
-
const part = (i, k) => one(people[i].map((p) => p[k]).join("\n"));
|
|
724
774
|
t.cells = rows.map((r, i) => [one(lead[0][i]), one(lead[1][i]), one(r[2].text), part(i, 1), part(i, 2), part(i, 3)]);
|
|
725
775
|
t.cols = 6;
|
|
726
776
|
}
|
|
@@ -731,7 +781,7 @@ var CELL_SPLITS = /* @__PURE__ */ new WeakMap();
|
|
|
731
781
|
function relocate(src, dst, from = 0) {
|
|
732
782
|
const out = [];
|
|
733
783
|
for (const s of _nullishCoalesce(CELL_SPLITS.get(src), () => ( []))) {
|
|
734
|
-
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access',
|
|
784
|
+
const at = dst.text.indexOf(src.text.slice(s.at, s.at + 20).trimEnd(), Math.max(from, _nullishCoalesce(_optionalChain([out, 'access', _23 => _23.at, 'call', _24 => _24(-1), 'optionalAccess', _25 => _25.at]), () => ( 0))));
|
|
735
785
|
if (at >= 0) out.push({ at, page: s.page });
|
|
736
786
|
}
|
|
737
787
|
return out;
|
|
@@ -755,7 +805,7 @@ function rowStarts(t) {
|
|
|
755
805
|
const starts = [];
|
|
756
806
|
for (let c = 0; c < t.cols; c++) {
|
|
757
807
|
if (covered.has(r * 1e5 + c)) continue;
|
|
758
|
-
const cell = _optionalChain([t, 'access',
|
|
808
|
+
const cell = _optionalChain([t, 'access', _26 => _26.cells, 'access', _27 => _27[r], 'optionalAccess', _28 => _28[c]]);
|
|
759
809
|
if (!cell) continue;
|
|
760
810
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) if (dr || dc) covered.add((r + dr) * 1e5 + c + dc);
|
|
761
811
|
starts.push({ cell, c });
|
|
@@ -766,8 +816,8 @@ function rowStarts(t) {
|
|
|
766
816
|
}
|
|
767
817
|
var covering = (t, r) => rowStarts(t).slice(0, r + 1).flatMap((starts, rr) => starts.filter((s) => rr + s.cell.rowSpan > r).map((s) => s.cell));
|
|
768
818
|
function cellPage(cell) {
|
|
769
|
-
const p =
|
|
770
|
-
if (p !== void 0 || !_optionalChain([cell, 'access',
|
|
819
|
+
const p = _chunkMED2MR6Ocjs.CELL_PAGES.get(cell);
|
|
820
|
+
if (p !== void 0 || !_optionalChain([cell, 'access', _29 => _29.blocks, 'optionalAccess', _30 => _30.length]) || cell.blocks.some((b) => b.pageNumber === void 0)) return p;
|
|
771
821
|
return Math.min(...cell.blocks.map((b) => b.pageNumber));
|
|
772
822
|
}
|
|
773
823
|
function tableRowPages(t, pageNumber) {
|
|
@@ -778,7 +828,7 @@ function tableRowPages(t, pageNumber) {
|
|
|
778
828
|
for (const { cell } of starts) {
|
|
779
829
|
const p = cellPage(cell);
|
|
780
830
|
if (p !== void 0) mark = Math.max(_nullishCoalesce(mark, () => ( p)), p);
|
|
781
|
-
else if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
831
|
+
else if (cell.text.trim() || _optionalChain([cell, 'access', _31 => _31.blocks, 'optionalAccess', _32 => _32.length])) text = true;
|
|
782
832
|
}
|
|
783
833
|
const page = _nullishCoalesce(mark, () => ( (text ? pageNumber : prev)));
|
|
784
834
|
prev = page !== void 0 && prev !== void 0 ? Math.max(prev, page) : _nullishCoalesce(page, () => ( prev));
|
|
@@ -795,8 +845,8 @@ function markJoinedPages(table, prev, curr) {
|
|
|
795
845
|
rows.forEach((starts, r) => {
|
|
796
846
|
const page2 = r < pt.rows ? pp[r] : cp[r - off];
|
|
797
847
|
for (const { cell } of starts) {
|
|
798
|
-
if (page2 !== void 0 && page2 !== prev.pageNumber)
|
|
799
|
-
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess',
|
|
848
|
+
if (page2 !== void 0 && page2 !== prev.pageNumber) _chunkMED2MR6Ocjs.CELL_PAGES.set(cell, page2);
|
|
849
|
+
const src = _optionalChain([(r < pt.rows ? ptRows[r] : ctRows[r - off]), 'optionalAccess', _33 => _33.find, 'call', _34 => _34((s) => s.cell !== cell && s.cell.text === cell.text && CELL_SPLITS.has(s.cell))]);
|
|
800
850
|
if (src) setSplits(cell, relocate(src.cell, cell));
|
|
801
851
|
}
|
|
802
852
|
});
|
|
@@ -806,7 +856,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
806
856
|
for (const { cell } of ctRows[cr]) for (const b of _nullishCoalesce(cell.blocks, () => ( []))) b.pageNumber ??= page;
|
|
807
857
|
const heads = covering(pt, pt.rows - 1);
|
|
808
858
|
for (const cell of covering(table, pt.rows - 1)) {
|
|
809
|
-
if (_optionalChain([cell, 'access',
|
|
859
|
+
if (_optionalChain([cell, 'access', _35 => _35.blocks, 'optionalAccess', _36 => _36.length])) continue;
|
|
810
860
|
const head = heads.filter((h) => h.text.trim() && cell.text.startsWith(h.text.trimEnd()) && cell.text.trim().length > h.text.trim().length).sort((a, b) => b.text.length - a.text.length)[0];
|
|
811
861
|
if (!head) continue;
|
|
812
862
|
const from = head.text.trimEnd().length;
|
|
@@ -817,7 +867,7 @@ function markJoinedPages(table, prev, curr) {
|
|
|
817
867
|
}
|
|
818
868
|
function splitCell(cell, page) {
|
|
819
869
|
if (page === void 0) return null;
|
|
820
|
-
if (_optionalChain([cell, 'access',
|
|
870
|
+
if (_optionalChain([cell, 'access', _37 => _37.blocks, 'optionalAccess', _38 => _38.length])) {
|
|
821
871
|
const k2 = cell.blocks.findIndex((b) => (_nullishCoalesce(b.pageNumber, () => ( page))) > page);
|
|
822
872
|
if (k2 <= 0) return null;
|
|
823
873
|
const head = cell.blocks.slice(0, k2), tail = cell.blocks.slice(k2);
|
|
@@ -844,8 +894,8 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
844
894
|
if (!splits.length) continue;
|
|
845
895
|
const clone = (cell, patch) => {
|
|
846
896
|
const out = { ...cell, ...patch };
|
|
847
|
-
const p =
|
|
848
|
-
if (p !== void 0)
|
|
897
|
+
const p = _chunkMED2MR6Ocjs.CELL_PAGES.get(cell);
|
|
898
|
+
if (p !== void 0) _chunkMED2MR6Ocjs.CELL_PAGES.set(out, p);
|
|
849
899
|
if (!("text" in patch) && CELL_SPLITS.has(cell)) CELL_SPLITS.set(out, CELL_SPLITS.get(cell));
|
|
850
900
|
return out;
|
|
851
901
|
};
|
|
@@ -855,7 +905,7 @@ function splitCrossPageRows(t, pageNumber) {
|
|
|
855
905
|
for (const { cell, c, split } of splits) {
|
|
856
906
|
cells[r][c] = clone(cell, split.head);
|
|
857
907
|
const tail = { ...cell, ...split.tail, rowSpan: 1 };
|
|
858
|
-
|
|
908
|
+
_chunkMED2MR6Ocjs.CELL_PAGES.set(tail, split.page);
|
|
859
909
|
setSplits(tail, split.rest);
|
|
860
910
|
row[c] = tail;
|
|
861
911
|
}
|
|
@@ -897,7 +947,7 @@ function anchorsOf(table) {
|
|
|
897
947
|
for (let r = 0; r < table.rows; r++) {
|
|
898
948
|
for (let c = 0; c < table.cols; c++) {
|
|
899
949
|
if (covered.has(r * 1e5 + c)) continue;
|
|
900
|
-
const cell = _optionalChain([table, 'access',
|
|
950
|
+
const cell = _optionalChain([table, 'access', _39 => _39.cells, 'access', _40 => _40[r], 'optionalAccess', _41 => _41[c]]);
|
|
901
951
|
if (!cell) continue;
|
|
902
952
|
out.push({ r, c, rs: cell.rowSpan, cs: cell.colSpan, cell });
|
|
903
953
|
for (let dr = 0; dr < cell.rowSpan; dr++) {
|
|
@@ -974,24 +1024,24 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
974
1024
|
if (r + dr < rows) owner[r + dr][dc] = placed;
|
|
975
1025
|
}
|
|
976
1026
|
grid[r][c1] = { ...a.cell, colSpan: c2 - c1, rowSpan: a.rs };
|
|
977
|
-
const lines =
|
|
978
|
-
if (lines)
|
|
979
|
-
if (
|
|
980
|
-
const edges =
|
|
1027
|
+
const lines = _chunkI4BS4BXEcjs.CELL_LINES.get(a.cell);
|
|
1028
|
+
if (lines) _chunkI4BS4BXEcjs.CELL_LINES.set(grid[r][c1], shift ? lines.map((l) => ({ ...l, l: l.l + shift, r: l.r + shift })) : lines);
|
|
1029
|
+
if (_chunkI4BS4BXEcjs.IMAGE_CELLS.has(a.cell)) _chunkI4BS4BXEcjs.IMAGE_CELLS.add(grid[r][c1]);
|
|
1030
|
+
const edges = _chunkMED2MR6Ocjs.CELL_EDGES.get(a.cell);
|
|
981
1031
|
if (edges) {
|
|
982
|
-
|
|
1032
|
+
_chunkMED2MR6Ocjs.CELL_EDGES.set(grid[r][c1], edges);
|
|
983
1033
|
edged = true;
|
|
984
1034
|
}
|
|
985
1035
|
return true;
|
|
986
1036
|
};
|
|
987
|
-
for (const a of pa) if (!
|
|
1037
|
+
for (const a of pa) if (!_chunkI4BS4BXEcjs.FILLER_CELLS.has(a.cell) && !place(a, pcx, 0)) return null;
|
|
988
1038
|
for (const a of ca) {
|
|
989
|
-
if (a.r < skip ||
|
|
1039
|
+
if (a.r < skip || _chunkI4BS4BXEcjs.FILLER_CELLS.has(a.cell)) continue;
|
|
990
1040
|
if (!place(a, cxU, prev.rows - skip, dx)) return null;
|
|
991
1041
|
}
|
|
992
1042
|
const first = prev.rows;
|
|
993
1043
|
for (let c = 0; c < cols; c++) {
|
|
994
|
-
const above = _optionalChain([owner, 'access',
|
|
1044
|
+
const above = _optionalChain([owner, 'access', _42 => _42[first - 1], 'optionalAccess', _43 => _43[c]]);
|
|
995
1045
|
if (!above) continue;
|
|
996
1046
|
let r = first;
|
|
997
1047
|
while (r < rows && owner[r][c] === null) r++;
|
|
@@ -1010,9 +1060,9 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1010
1060
|
const grown = { ...above, rs: newRs };
|
|
1011
1061
|
for (let rr = above.r; rr < above.r + newRs; rr++) for (let dc = above.c; dc < above.c + above.cs; dc++) owner[rr][dc] = grown;
|
|
1012
1062
|
}
|
|
1013
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1063
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkI4BS4BXEcjs.FILLER_CELLS.add(grid[r][c]);
|
|
1014
1064
|
if (edged) {
|
|
1015
|
-
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null)
|
|
1065
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) if (owner[r][c] === null) _chunkMED2MR6Ocjs.CELL_EDGES.set(grid[r][c], _chunkI4BS4BXEcjs.NO_EDGES);
|
|
1016
1066
|
}
|
|
1017
1067
|
for (let c = 0; c < cols && U[c + 1] <= pcx[0] + PART_COL_TOL; c++) {
|
|
1018
1068
|
let r = prev.rows;
|
|
@@ -1021,7 +1071,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1021
1071
|
for (let rr = 0; rr < r; rr++) owner[rr][c] = through;
|
|
1022
1072
|
}
|
|
1023
1073
|
const table = { rows, cols, cells: grid, hasHeader: prev.hasHeader, ...prev.caption ? { caption: prev.caption } : {} };
|
|
1024
|
-
const pr =
|
|
1074
|
+
const pr = _chunkI4BS4BXEcjs.ROW_RULES.get(prev), cr = _chunkI4BS4BXEcjs.ROW_RULES.get(curr);
|
|
1025
1075
|
const shifted = dx !== 0;
|
|
1026
1076
|
const cut = {
|
|
1027
1077
|
open: !!pr && !!cr && !pr.bottom && !cr.top && pr.innerOpen + cr.innerOpen === 0 && pr.innerRuled + cr.innerRuled > 0,
|
|
@@ -1032,7 +1082,7 @@ function joinSplitParts(prev, pcx, curr, ccx, dx = 0, prevBottom, lex) {
|
|
|
1032
1082
|
if (rows > prev.rows && !split && prevBottom !== void 0 && mergeStraddlingCells(table, owner, prev.rows, prevBottom, lex, U)) split = mergeSplitRow(table, owner, prev.rows, U, true, { ...cut, open: false });
|
|
1033
1083
|
if (pr && cr) {
|
|
1034
1084
|
const cutRuled = pr.bottom || cr.top;
|
|
1035
|
-
|
|
1085
|
+
_chunkI4BS4BXEcjs.ROW_RULES.set(table, { top: pr.top, bottom: cr.bottom, innerRuled: pr.innerRuled + cr.innerRuled + (!split && cutRuled ? 1 : 0), innerOpen: pr.innerOpen + cr.innerOpen + (!split && !cutRuled ? 1 : 0) });
|
|
1036
1086
|
}
|
|
1037
1087
|
return { table, colXs: U, split, header: ca.filter((a) => a.r < skip && a.cell.text.trim()).length >= 2 };
|
|
1038
1088
|
}
|
|
@@ -1093,19 +1143,19 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1093
1143
|
c = u.c + u.cs;
|
|
1094
1144
|
if (!d || d === u || u.r + u.rs - 1 !== last || d.r !== first || d.c !== u.c || d.cs !== u.cs) continue;
|
|
1095
1145
|
const a = table.cells[u.r][u.c], b = table.cells[first][d.c];
|
|
1096
|
-
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !
|
|
1097
|
-
const openSeam = hasContent(a) && hasContent(b) &&
|
|
1146
|
+
const flowsOn = itemBreak && straddles && !!colXs && hasContent(a) && hasContent(b) && longLastLine(a) && !_chunkI4BS4BXEcjs.startsNewItem.call(void 0, a.text, b.text) && continuesAcross(a, b, colXs[u.c], colXs[u.c + u.cs]);
|
|
1147
|
+
const openSeam = hasContent(a) && hasContent(b) && _chunkI4BS4BXEcjs.hasOpenCellSeam.call(void 0, a, b) && !owner.some((row, r) => {
|
|
1098
1148
|
if (!r || r === first) return false;
|
|
1099
1149
|
const up = owner[r - 1][u.c], down = row[u.c];
|
|
1100
1150
|
if (!up || !down || up === down || up.c !== u.c || down.c !== u.c || up.cs !== u.cs || down.cs !== u.cs) return false;
|
|
1101
|
-
const ue =
|
|
1151
|
+
const ue = _chunkMED2MR6Ocjs.CELL_EDGES.get(table.cells[up.r][up.c]), de = _chunkMED2MR6Ocjs.CELL_EDGES.get(table.cells[down.r][down.c]);
|
|
1102
1152
|
return !!ue && !!de && !ue.b && !de.t;
|
|
1103
1153
|
});
|
|
1104
1154
|
if (!openSeam && !flowsOn && !crossed.has(shape(u, d)) && !(u.rs >= 2 && u.c + u.cs <= firstNew && hasContent(a) && !hasContent(b))) {
|
|
1105
1155
|
if (!straddles && !midWord) continue;
|
|
1106
1156
|
if (u.r >= last && d.rs < 2) continue;
|
|
1107
|
-
const U =
|
|
1108
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1157
|
+
const U = _chunkI4BS4BXEcjs.CELL_LINES.get(a);
|
|
1158
|
+
if (!_optionalChain([U, 'optionalAccess', _44 => _44.length]) || !hasContent(b)) continue;
|
|
1109
1159
|
if (!(straddles && filledToBottom(U, prevBottom) && clauseContinues(a, b))) {
|
|
1110
1160
|
if (U.length > STRADDLE_MAX_LINES) continue;
|
|
1111
1161
|
const lu = U[U.length - 1];
|
|
@@ -1122,7 +1172,7 @@ function mergeStraddlingCells(table, owner, first, prevBottom, lex, colXs) {
|
|
|
1122
1172
|
return merged;
|
|
1123
1173
|
}
|
|
1124
1174
|
function longLastLine(c) {
|
|
1125
|
-
const L =
|
|
1175
|
+
const L = _chunkI4BS4BXEcjs.CELL_LINES.get(c), l = _optionalChain([L, 'optionalAccess', _45 => _45[L.length - 1]]);
|
|
1126
1176
|
return !!l && l.r - l.l >= 6 * (l.h || 10);
|
|
1127
1177
|
}
|
|
1128
1178
|
function filledToBottom(U, bottom) {
|
|
@@ -1155,8 +1205,8 @@ function nextItemHead(prev, next) {
|
|
|
1155
1205
|
return false;
|
|
1156
1206
|
}
|
|
1157
1207
|
function continuesAcross(u, d, x1, x2) {
|
|
1158
|
-
const U =
|
|
1159
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1208
|
+
const U = _chunkI4BS4BXEcjs.CELL_LINES.get(u), D = _chunkI4BS4BXEcjs.CELL_LINES.get(d);
|
|
1209
|
+
if (!_optionalChain([U, 'optionalAccess', _46 => _46.length]) || !_optionalChain([D, 'optionalAccess', _47 => _47.length])) return false;
|
|
1160
1210
|
const last = U[U.length - 1];
|
|
1161
1211
|
const fs = last.h || 10;
|
|
1162
1212
|
let minL = Infinity, maxR = -Infinity;
|
|
@@ -1173,7 +1223,7 @@ function continuesAcross(u, d, x1, x2) {
|
|
|
1173
1223
|
if (U.length === 1 && x2 - last.r > Math.max(FULL_LINE_EDGE_MIN, SINGLE_LINE_WORD_GAP * fs)) return false;
|
|
1174
1224
|
const indented = last.l - minL >= HANGING_MIN * fs;
|
|
1175
1225
|
if (last.r - last.l < FULL_LINE_MIN_FRAC * (indented ? x2 - last.l : x2 - x1)) return false;
|
|
1176
|
-
const newItem =
|
|
1226
|
+
const newItem = _chunkI4BS4BXEcjs.startsNewItem.call(void 0, u.text, d.text);
|
|
1177
1227
|
const all = D.length ? U.concat(D) : U;
|
|
1178
1228
|
const leftAligned = (l) => maxR - l.r > SHORT_LINE_GAP * fs && (l.l - minL <= fs || !newItem && all.some((o) => o !== l && Math.abs(o.l - l.l) <= HANGING_TOL && Math.abs(o.r - l.r) >= HANGING_MIN * fs));
|
|
1179
1229
|
const hanging = U.length >= 2 && U.every((l) => maxR - l.r <= FULL_LINE_TOL * fs) && indented && Math.abs(D[0].l - last.l) <= HANGING_TOL;
|
|
@@ -1190,12 +1240,12 @@ function outlineContinues(u, d) {
|
|
|
1190
1240
|
return U.length >= 2 && D.length >= 1 && U.some((l) => OUTLINE_HEAD.test(l)) && OUTLINE_ITEM.test(D[0]);
|
|
1191
1241
|
}
|
|
1192
1242
|
function lineEnded(c, x1, x2, next) {
|
|
1193
|
-
const L =
|
|
1243
|
+
const L = _chunkI4BS4BXEcjs.CELL_LINES.get(c);
|
|
1194
1244
|
if (!L || L.length !== 1) return false;
|
|
1195
1245
|
const l = L[0], h = l.h || 10;
|
|
1196
|
-
const d0 = next ? _optionalChain([
|
|
1246
|
+
const d0 = next ? _optionalChain([_chunkI4BS4BXEcjs.CELL_LINES, 'access', _48 => _48.get, 'call', _49 => _49(next), 'optionalAccess', _50 => _50[0]]) : void 0;
|
|
1197
1247
|
if (d0 && d0.l - l.l >= HANGING_MIN * h) return false;
|
|
1198
|
-
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
1248
|
+
return x2 - l.r - (l.l - x1) >= Math.max(LABEL_ROOM, firstWordUnits(_nullishCoalesce(_optionalChain([next, 'optionalAccess', _51 => _51.text]), () => ( "")))) * h;
|
|
1199
1249
|
}
|
|
1200
1250
|
function firstWordUnits(text) {
|
|
1201
1251
|
const word = _nullishCoalesce(flowText(text).trim().replace(/^([(\[「『<〈])\s+/, "$1").split(/\s+/)[0], () => ( ""));
|
|
@@ -1204,15 +1254,15 @@ function firstWordUnits(text) {
|
|
|
1204
1254
|
return units;
|
|
1205
1255
|
}
|
|
1206
1256
|
function appendCell(a, b) {
|
|
1207
|
-
if (
|
|
1208
|
-
if (_optionalChain([a, 'access',
|
|
1209
|
-
const asBlocks = (c) => _optionalChain([c, 'access',
|
|
1257
|
+
if (_chunkI4BS4BXEcjs.IMAGE_CELLS.has(b)) _chunkI4BS4BXEcjs.IMAGE_CELLS.add(a);
|
|
1258
|
+
if (_optionalChain([a, 'access', _52 => _52.blocks, 'optionalAccess', _53 => _53.length]) || _optionalChain([b, 'access', _54 => _54.blocks, 'optionalAccess', _55 => _55.length])) {
|
|
1259
|
+
const asBlocks = (c) => _optionalChain([c, 'access', _56 => _56.blocks, 'optionalAccess', _57 => _57.length]) ? c.blocks : c.text.split("\n").map((l) => l.trim()).filter(Boolean).map((text) => ({ type: "paragraph", text }));
|
|
1210
1260
|
a.blocks = [...asBlocks(a), ...asBlocks(b)];
|
|
1211
1261
|
}
|
|
1212
1262
|
if (b.text.trim()) a.text = a.text.trim() ? a.text + "\n" + b.text : b.text;
|
|
1213
|
-
|
|
1263
|
+
_chunkI4BS4BXEcjs.joinCellEdges.call(void 0, a, b);
|
|
1214
1264
|
}
|
|
1215
|
-
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access',
|
|
1265
|
+
var hasContent = (cell) => !!cell.text.trim() || !!_optionalChain([cell, 'access', _58 => _58.blocks, 'optionalAccess', _59 => _59.length]) || _chunkI4BS4BXEcjs.IMAGE_CELLS.has(cell);
|
|
1216
1266
|
var CLAUSE_OPEN_ENDING = /(?:하는|되는|하고|하며|하여|되어|되고|되며|이며|으며|어야|아야|여야)$/;
|
|
1217
1267
|
var batchim = (ch) => {
|
|
1218
1268
|
const k = ch.charCodeAt(0) - 44032;
|
|
@@ -1220,7 +1270,7 @@ var batchim = (ch) => {
|
|
|
1220
1270
|
};
|
|
1221
1271
|
function clauseContinues(u, d) {
|
|
1222
1272
|
const tail = _nullishCoalesce(flowText(u.text).trim().split(/\s+/).pop(), () => ( "")), head = flowText(d.text).trim();
|
|
1223
|
-
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) ||
|
|
1273
|
+
if (!/^[가-힣]{2,}$/.test(tail) || !/^[가-힣]/.test(head) || _chunkI4BS4BXEcjs.startsNewItem.call(void 0, u.text, head)) return false;
|
|
1224
1274
|
const last = tail[tail.length - 1], before = tail[tail.length - 2];
|
|
1225
1275
|
return last === "\uC744" && batchim(before) || last === "\uB97C" && !batchim(before) || CLAUSE_OPEN_ENDING.test(tail);
|
|
1226
1276
|
}
|
|
@@ -1228,30 +1278,18 @@ function quantityContinues(u, d) {
|
|
|
1228
1278
|
return /\d[\d,.]*\s*(?:%|[가-힣]{1,2})?$/.test(flowText(u.text).trim()) && /^(?:미만|이상|이하|초과)(?![가-힣])/.test(flowText(d.text).trim());
|
|
1229
1279
|
}
|
|
1230
1280
|
function wordOverflows(u, d, x1, x2) {
|
|
1231
|
-
const U =
|
|
1232
|
-
if (!_optionalChain([U, 'optionalAccess',
|
|
1281
|
+
const U = _chunkI4BS4BXEcjs.CELL_LINES.get(u);
|
|
1282
|
+
if (!_optionalChain([U, 'optionalAccess', _60 => _60.length]) || _chunkI4BS4BXEcjs.startsNewItem.call(void 0, u.text, d.text)) return false;
|
|
1233
1283
|
const last = U[U.length - 1], units = firstWordUnits(d.text);
|
|
1234
1284
|
return units > 0 && last.r - last.l + units * (last.h || 10) > x2 - x1;
|
|
1235
1285
|
}
|
|
1236
|
-
var KO_ORDER = "\uAC00\uB098\uB2E4\uB77C\uB9C8\uBC14\uC0AC\uC544\uC790\uCC28\uCE74\uD0C0\uD30C\uD558";
|
|
1237
|
-
function itemMark(line) {
|
|
1238
|
-
line = flowText(line).trim();
|
|
1239
|
-
let m = /^(\d{1,2})([.)])(?!\d)/.exec(line);
|
|
1240
|
-
if (m) return { style: "1" + m[2], n: +m[1] };
|
|
1241
|
-
if (m = /^\((\d{1,2})\)/.exec(line)) return { style: "(1)", n: +m[1] };
|
|
1242
|
-
if ((m = /^([가-하])([.)])/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "\uAC00" + m[2], n: KO_ORDER.indexOf(m[1]) };
|
|
1243
|
-
if ((m = /^\(([가-하])\)/.exec(line)) && KO_ORDER.includes(m[1])) return { style: "(\uAC00)", n: KO_ORDER.indexOf(m[1]) };
|
|
1244
|
-
if (m = /^[①-⑳]/.exec(line)) return { style: "\u2460", n: m[0].charCodeAt(0) };
|
|
1245
|
-
if (m = /^([A-Z])\.\s/.exec(line)) return { style: "A.", n: m[1].charCodeAt(0) };
|
|
1246
|
-
return null;
|
|
1247
|
-
}
|
|
1248
1286
|
function listContinues(u, d, multi = false) {
|
|
1249
1287
|
const head = itemMark(d.text.trim());
|
|
1250
1288
|
if (!head) return false;
|
|
1251
1289
|
const marks = u.text.split("\n").map((l) => itemMark(l.trim()));
|
|
1252
1290
|
let last = -1, count = 0;
|
|
1253
1291
|
marks.forEach((m, i) => {
|
|
1254
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1292
|
+
if (_optionalChain([m, 'optionalAccess', _61 => _61.style]) === head.style) {
|
|
1255
1293
|
last = i;
|
|
1256
1294
|
count++;
|
|
1257
1295
|
}
|
|
@@ -1292,12 +1330,13 @@ function mergeSplitRow(table, owner, first, colXs, textOnly = false, cut = NO_CU
|
|
|
1292
1330
|
const a = serial(cell(u)), b = serial(cell(d));
|
|
1293
1331
|
return a !== null && b === a + 1;
|
|
1294
1332
|
})) return false;
|
|
1333
|
+
if (cut.ruled && hasNumberedRowSequence(table, owner, first)) return false;
|
|
1295
1334
|
const contentPairs = pairs.filter(([u, d]) => hasContent(u.cell) && hasContent(d.cell));
|
|
1296
1335
|
const carriedSplit = !textOnly && carried && !newCell && (contentPairs.length <= 1 || contentPairs.every(([, d]) => d.rs > 1) || !cut.ruled && contentPairs.some(([u, d]) => wordOverflows(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs])));
|
|
1297
1336
|
if (!carriedSplit) {
|
|
1298
1337
|
const norm = (c) => flowText(c.text).replace(/\s+/g, "");
|
|
1299
1338
|
if (pairs.some(([u, d]) => hasContent(d.cell) && norm(cell(d)) !== norm(cell(u)) && lineEnded(cell(u), colXs[u.c], colXs[u.c + u.cs], cell(d)))) return false;
|
|
1300
|
-
const oneLine = (c) => _optionalChain([
|
|
1339
|
+
const oneLine = (c) => _optionalChain([_chunkI4BS4BXEcjs.CELL_LINES, 'access', _62 => _62.get, 'call', _63 => _63(c), 'optionalAccess', _64 => _64.length]) === 1;
|
|
1301
1340
|
if (pairs.some(([u, d]) => nextItemHead(cell(u).text, cell(d).text)) && pairs.some(([u, d]) => hasContent(u.cell) && hasContent(d.cell) && oneLine(cell(u)) && oneLine(cell(d)) && norm(cell(u)) !== norm(cell(d)))) return false;
|
|
1302
1341
|
const flows = ([u, d]) => continuesAcross(cell(u), cell(d), colXs[u.c], colXs[u.c + u.cs]) || clauseContinues(cell(u), cell(d)) || quantityContinues(cell(u), cell(d));
|
|
1303
1342
|
if (!(cut.open && !newCell)) {
|
|
@@ -1328,8 +1367,8 @@ function besideOwn(b, p, c) {
|
|
|
1328
1367
|
}
|
|
1329
1368
|
var PAGE_NUMBER_TEXT = /^[-–—]?\s*\d{1,4}\s*[-–—]?$/;
|
|
1330
1369
|
function pageNumberBetween(b, p, c, pageHeights) {
|
|
1331
|
-
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1332
|
-
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess',
|
|
1370
|
+
if (b.type !== "paragraph" || !b.bbox || !PAGE_NUMBER_TEXT.test(_nullishCoalesce(_optionalChain([b, 'access', _65 => _65.text, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()]), () => ( "")))) return false;
|
|
1371
|
+
const h = b.pageNumber ? _optionalChain([pageHeights, 'optionalAccess', _68 => _68.get, 'call', _69 => _69(b.pageNumber)]) : void 0;
|
|
1333
1372
|
if (!h) return false;
|
|
1334
1373
|
if (b.pageNumber === p.pageNumber) return b.bbox.y + b.bbox.height <= Math.min(p.bbox.y, h * PAGE_EDGE_BAND) + 1;
|
|
1335
1374
|
if (b.pageNumber === c.pageNumber) return b.bbox.y >= Math.max(c.bbox.y + c.bbox.height, h * (1 - PAGE_EDGE_BAND)) - 1;
|
|
@@ -1353,7 +1392,7 @@ function insideTable(b, t) {
|
|
|
1353
1392
|
return b.bbox.x >= o.x - 1 && b.bbox.x + b.bbox.width <= o.x + o.width + 1 && b.bbox.y >= o.y - 1 && b.bbox.y + b.bbox.height <= o.y + o.height + 1;
|
|
1354
1393
|
}
|
|
1355
1394
|
function startsWithUnitRow(table) {
|
|
1356
|
-
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access',
|
|
1395
|
+
return /^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([table, 'access', _70 => _70.cells, 'access', _71 => _71[0], 'optionalAccess', _72 => _72[0], 'optionalAccess', _73 => _73.text]), () => ( ""))) && _optionalChain([table, 'access', _74 => _74.cells, 'access', _75 => _75[0], 'optionalAccess', _76 => _76.slice, 'call', _77 => _77(1), 'access', _78 => _78.every, 'call', _79 => _79((c) => !c.text.trim())]);
|
|
1357
1396
|
}
|
|
1358
1397
|
function sameHeadShape(a, b) {
|
|
1359
1398
|
if (!a || !b || a.length !== b.length) return false;
|
|
@@ -1364,6 +1403,12 @@ function sameHeadShape(a, b) {
|
|
|
1364
1403
|
}
|
|
1365
1404
|
return tall;
|
|
1366
1405
|
}
|
|
1406
|
+
function hasBoxTitle(t) {
|
|
1407
|
+
const titles = _nullishCoalesce(_optionalChain([t, 'access', _80 => _80.cells, 'access', _81 => _81[0], 'optionalAccess', _82 => _82.filter, 'call', _83 => _83((c) => c.text.trim())]), () => ( []));
|
|
1408
|
+
if (titles.length !== 1 || titles[0].rowSpan < 2) return false;
|
|
1409
|
+
const body = t.cells[titles[0].rowSpan];
|
|
1410
|
+
return !!body && body[0].colSpan === t.cols && !!body[0].text.trim();
|
|
1411
|
+
}
|
|
1367
1412
|
function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
1368
1413
|
mergeColumnFlow(blocks, pageHeights, lex);
|
|
1369
1414
|
for (let i = blocks.length - 2; i >= 0; i--) {
|
|
@@ -1373,28 +1418,29 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1373
1418
|
const skip = (b) => b.type !== "table" || [blocks[i], tail].some((t) => insideTable(b, t) || leftColumnOf(b, t));
|
|
1374
1419
|
while (j < blocks.length && skip(blocks[j]) && (_nullishCoalesce(blocks[j].pageNumber, () => ( 0))) <= tail.pageNumber + 1) j++;
|
|
1375
1420
|
const curr = blocks[j];
|
|
1376
|
-
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess',
|
|
1421
|
+
const prev = tail !== blocks[i] && _optionalChain([curr, 'optionalAccess', _84 => _84.pageNumber]) === tail.pageNumber ? blocks[i] : tail;
|
|
1377
1422
|
if (!prev.table || !prev.bbox || !prev.pageNumber) continue;
|
|
1378
1423
|
if (!curr || curr.type !== "table" || !curr.table || !curr.bbox || curr.pageNumber !== prev.pageNumber + 1) continue;
|
|
1379
1424
|
if (startsWithUnitRow(prev.table) && startsWithUnitRow(curr.table)) continue;
|
|
1425
|
+
if (hasBoxTitle(prev.table) && hasBoxTitle(curr.table) && !rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1380
1426
|
const joined = j === i + 1 || blocks.slice(i + 1, j).every((b) => besideOwn(b, prev, curr) || insideTable(b, prev) || insideTable(b, curr) || pageNumberBetween(b, prev, curr, pageHeights)) ? looksContinued(prev, curr, pageHeights) && !restartsTable(blocks, i, curr.table, pageHeights) ? _nullishCoalesce(joinClipParts(prev, curr, pageHeights, lex), () => ( false)) : null : null;
|
|
1381
1427
|
if (joined) {
|
|
1382
1428
|
placeJoined(blocks, i, j, joined);
|
|
1383
1429
|
continue;
|
|
1384
1430
|
}
|
|
1385
|
-
if (
|
|
1431
|
+
if (_chunkI4BS4BXEcjs.EMPTY_PARTS.has(curr.table)) {
|
|
1386
1432
|
blocks.splice(j, 1);
|
|
1387
1433
|
i++;
|
|
1388
1434
|
continue;
|
|
1389
1435
|
}
|
|
1390
1436
|
if (joined === null) continue;
|
|
1391
|
-
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable ||
|
|
1437
|
+
if (prev.table.cols !== curr.table.cols || prev.table.renderAsTable !== curr.table.renderAsTable || _chunkI4BS4BXEcjs.EMPTY_PARTS.has(prev.table)) continue;
|
|
1392
1438
|
const width = Math.max(prev.bbox.width, curr.bbox.width, 1);
|
|
1393
1439
|
const leftDiff = Math.abs(prev.bbox.x - curr.bbox.x);
|
|
1394
1440
|
const rightDiff = Math.abs(prev.bbox.x + prev.bbox.width - (curr.bbox.x + curr.bbox.width));
|
|
1395
1441
|
if (leftDiff > width * NEIGHBOR_TABLE_EPSILON || rightDiff > width * NEIGHBOR_TABLE_EPSILON) continue;
|
|
1396
|
-
const px =
|
|
1397
|
-
if (px && cx && !shiftedSame(px, cx, !
|
|
1442
|
+
const px = _chunkI4BS4BXEcjs.TABLE_COLXS.get(prev.table), cx = _chunkI4BS4BXEcjs.TABLE_COLXS.get(curr.table);
|
|
1443
|
+
if (px && cx && !shiftedSame(px, cx, !_chunkI4BS4BXEcjs.CLIP_TABLES.has(prev.table) && !_chunkI4BS4BXEcjs.CLIP_TABLES.has(curr.table))) continue;
|
|
1398
1444
|
if (!rowTextsEqual(prev.table.cells[0], curr.table.cells[0]) && sameHeadShape(prev.table.cells[0], curr.table.cells[0])) continue;
|
|
1399
1445
|
let currCells = curr.table.cells;
|
|
1400
1446
|
const headRows = repeatedHeaderRows(prev.table, curr.table);
|
|
@@ -1405,16 +1451,16 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1405
1451
|
blocks.splice(j, 1);
|
|
1406
1452
|
continue;
|
|
1407
1453
|
}
|
|
1408
|
-
if (px && cx && !
|
|
1454
|
+
if (px && cx && !_chunkI4BS4BXEcjs.CLIP_TABLES.has(prev.table) && !_chunkI4BS4BXEcjs.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 && _chunkI4BS4BXEcjs.CELL_LINES.has(c))) {
|
|
1409
1455
|
const dx = px[0] - cx[0];
|
|
1410
1456
|
const part = joinSplitParts(prev.table, px, curr.table, cx.map((x) => x + dx), dx, void 0, lex);
|
|
1411
|
-
if (_optionalChain([part, 'optionalAccess',
|
|
1457
|
+
if (_optionalChain([part, 'optionalAccess', _85 => _85.split]) && part.table.rows === prev.table.rows + currCells.length - 1) {
|
|
1412
1458
|
const last = prev.table.rows - 1;
|
|
1413
1459
|
for (let c = 0; c < part.table.cols; c++) {
|
|
1414
|
-
const U =
|
|
1415
|
-
|
|
1460
|
+
const U = _chunkI4BS4BXEcjs.CELL_LINES.get(prev.table.cells[last][c]), D = _chunkI4BS4BXEcjs.CELL_LINES.get(currCells[0][c]);
|
|
1461
|
+
_chunkI4BS4BXEcjs.CELL_LINES.set(part.table.cells[last][c], U.concat(D.map((l) => ({ ...l, l: l.l + dx, r: l.r + dx }))));
|
|
1416
1462
|
}
|
|
1417
|
-
|
|
1463
|
+
_chunkI4BS4BXEcjs.TABLE_COLXS.set(part.table, part.colXs);
|
|
1418
1464
|
placeJoined(blocks, i, j, part.table);
|
|
1419
1465
|
continue;
|
|
1420
1466
|
}
|
|
@@ -1427,20 +1473,20 @@ function mergeCrossPageTables(blocks, pageHeights, lex) {
|
|
|
1427
1473
|
caption: prev.table.caption,
|
|
1428
1474
|
...prev.table.renderAsTable ? { renderAsTable: true } : {}
|
|
1429
1475
|
};
|
|
1430
|
-
if (_nullishCoalesce(px, () => ( cx)))
|
|
1431
|
-
if (
|
|
1476
|
+
if (_nullishCoalesce(px, () => ( cx))) _chunkI4BS4BXEcjs.TABLE_COLXS.set(merged, _nullishCoalesce(px, () => ( cx)));
|
|
1477
|
+
if (_chunkI4BS4BXEcjs.CLIP_TABLES.has(prev.table) || _chunkI4BS4BXEcjs.CLIP_TABLES.has(curr.table)) _chunkI4BS4BXEcjs.CLIP_TABLES.add(merged);
|
|
1432
1478
|
placeJoined(blocks, i, j, merged);
|
|
1433
1479
|
}
|
|
1434
1480
|
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
1435
1481
|
const t = blocks[i].table;
|
|
1436
|
-
if (blocks[i].type === "table" && t &&
|
|
1482
|
+
if (blocks[i].type === "table" && t && _chunkI4BS4BXEcjs.EMPTY_PARTS.has(t)) blocks.splice(i, 1);
|
|
1437
1483
|
}
|
|
1438
1484
|
}
|
|
1439
1485
|
function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
1440
1486
|
if (!pageHeights) return;
|
|
1441
1487
|
for (let i = 0; i < blocks.length; i++) {
|
|
1442
1488
|
const L = blocks[i];
|
|
1443
|
-
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !
|
|
1489
|
+
if (L.type !== "table" || !L.table || !L.bbox || !L.pageNumber || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(L.table) || _chunkI4BS4BXEcjs.EMPTY_PARTS.has(L.table)) continue;
|
|
1444
1490
|
const ph = pageHeights.get(L.pageNumber);
|
|
1445
1491
|
if (!ph || L.bbox.y > ph * PAGE_EDGE_BAND) continue;
|
|
1446
1492
|
let s0 = i, s1 = i;
|
|
@@ -1469,12 +1515,12 @@ function mergeColumnFlow(blocks, pageHeights, lex) {
|
|
|
1469
1515
|
}
|
|
1470
1516
|
function joinClipParts(prev, curr, pageHeights, lex) {
|
|
1471
1517
|
const pt = prev.table, ct = curr.table;
|
|
1472
|
-
if (!
|
|
1473
|
-
const px =
|
|
1518
|
+
if (!_chunkI4BS4BXEcjs.CLIP_TABLES.has(pt) || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(ct)) return null;
|
|
1519
|
+
const px = _chunkI4BS4BXEcjs.TABLE_COLXS.get(pt), cx = _chunkI4BS4BXEcjs.TABLE_COLXS.get(ct);
|
|
1474
1520
|
if (!px || !cx) return null;
|
|
1475
1521
|
let xs = cx, shifted = false, dx = 0, foreign = false, within = false;
|
|
1476
1522
|
if (!shiftedSame(px, cx, false)) {
|
|
1477
|
-
if (!_optionalChain([pageHeights, 'optionalAccess',
|
|
1523
|
+
if (!_optionalChain([pageHeights, 'optionalAccess', _86 => _86.get, 'call', _87 => _87(prev.pageNumber)]) || !_optionalChain([pageHeights, 'optionalAccess', _88 => _88.get, 'call', _89 => _89(curr.pageNumber)])) return null;
|
|
1478
1524
|
dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1479
1525
|
within = Math.abs(dx) > CONTINUATION_COL_TOL && cx.length >= 3 && cx.every((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1480
1526
|
if (Math.abs(dx) > CONTINUATION_COL_TOL && !within) {
|
|
@@ -1486,19 +1532,19 @@ function joinClipParts(prev, curr, pageHeights, lex) {
|
|
|
1486
1532
|
const inner = b.slice(1, -1).map((x) => x + dx);
|
|
1487
1533
|
return inner.length > 0 && !inner.some((x) => px.some((p) => Math.abs(p - x) <= CONTINUATION_COL_TOL));
|
|
1488
1534
|
};
|
|
1489
|
-
foreign = unrelated(cx) && unrelated(_nullishCoalesce(
|
|
1535
|
+
foreign = unrelated(cx) && unrelated(_nullishCoalesce(_chunkI4BS4BXEcjs.PART_COLXS.get(ct), () => ( cx))) && (headingRow(_nullishCoalesce(ct.cells[0], () => ( []))) || px.length > FOREIGN_FIRST_ROW_CELLS && anchorsOf(ct).filter((a) => a.r === 0).length >= FOREIGN_FIRST_ROW_CELLS);
|
|
1490
1536
|
}
|
|
1491
|
-
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access',
|
|
1537
|
+
const res = joinSplitParts(pt, px, ct, xs, dx, _optionalChain([prev, 'access', _90 => _90.bbox, 'optionalAccess', _91 => _91.y]), lex);
|
|
1492
1538
|
if (!res || (shifted || foreign || within) && !res.split && !res.header) return null;
|
|
1493
|
-
|
|
1494
|
-
const ys =
|
|
1495
|
-
if (ys)
|
|
1496
|
-
|
|
1497
|
-
|
|
1539
|
+
_chunkI4BS4BXEcjs.TABLE_COLXS.set(res.table, res.colXs);
|
|
1540
|
+
const ys = _chunkI4BS4BXEcjs.TABLE_ROWYS.get(pt);
|
|
1541
|
+
if (ys) _chunkI4BS4BXEcjs.TABLE_ROWYS.set(res.table, ys);
|
|
1542
|
+
_chunkI4BS4BXEcjs.PART_COLXS.set(res.table, _nullishCoalesce(_chunkI4BS4BXEcjs.PART_COLXS.get(pt), () => ( px)));
|
|
1543
|
+
_chunkI4BS4BXEcjs.CLIP_TABLES.add(res.table);
|
|
1498
1544
|
return res.table;
|
|
1499
1545
|
}
|
|
1500
1546
|
function prevLacksLeftCols(prev, px, xs, pageHeights) {
|
|
1501
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1547
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _92 => _92.get, 'call', _93 => _93(prev.pageNumber)]);
|
|
1502
1548
|
if (!ph || prev.bbox.y + prev.bbox.height < ph * (1 - PAGE_EDGE_BAND)) return false;
|
|
1503
1549
|
return xs[0] < px[0] && xs.slice(1, -1).some((x) => Math.abs(x - px[0]) <= CONTINUATION_COL_TOL);
|
|
1504
1550
|
}
|
|
@@ -1509,21 +1555,21 @@ function headingRow(row) {
|
|
|
1509
1555
|
}
|
|
1510
1556
|
var ANNEX_HEAD_RE = /^\s*[<\[(【]?\s*(?:붙\s*임|참\s*고|별\s*첨|별\s*지|별\s*표|첨\s*부|부\s*록)(?:\s*\d|\s*$|\s*[>\])】])|^\s*■/;
|
|
1511
1557
|
function looksContinued(prev, curr, pageHeights) {
|
|
1512
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1558
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _94 => _94.get, 'call', _95 => _95(prev.pageNumber)]), ch = _optionalChain([pageHeights, 'optionalAccess', _96 => _96.get, 'call', _97 => _97(curr.pageNumber)]);
|
|
1513
1559
|
if (ph && ch && (prev.bbox.y > ph * PAGE_EDGE_BAND && !pushedLead(prev, curr) || curr.bbox.y + curr.bbox.height < ch * (1 - PAGE_EDGE_BAND))) return false;
|
|
1514
1560
|
const firstRow = _nullishCoalesce(curr.table.cells[0], () => ( []));
|
|
1515
|
-
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access',
|
|
1561
|
+
const firstText = _nullishCoalesce(_optionalChain([firstRow, 'access', _98 => _98.find, 'call', _99 => _99((c) => c.text.trim()), 'optionalAccess', _100 => _100.text]), () => ( ""));
|
|
1516
1562
|
if (!ANNEX_HEAD_RE.test(firstText)) return true;
|
|
1517
1563
|
const filled = firstRow.map((c) => flowText(c.text).replace(/\s+/g, "")).filter(Boolean);
|
|
1518
1564
|
return filled.length >= 2 && filled.every((t) => t === filled[0]);
|
|
1519
1565
|
}
|
|
1520
1566
|
function pushedLead(prev, curr) {
|
|
1521
|
-
if (!
|
|
1567
|
+
if (!_chunkI4BS4BXEcjs.CLIP_TABLES.has(prev.table) || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(curr.table)) return false;
|
|
1522
1568
|
const lead = leadRows(curr.table);
|
|
1523
1569
|
return lead.image && lead.height > prev.bbox.y;
|
|
1524
1570
|
}
|
|
1525
1571
|
function leadRows(t) {
|
|
1526
|
-
const ys =
|
|
1572
|
+
const ys = _chunkI4BS4BXEcjs.TABLE_ROWYS.get(t);
|
|
1527
1573
|
if (!ys || ys.length < 2) return { height: 0, image: false };
|
|
1528
1574
|
const anchors = anchorsOf(t);
|
|
1529
1575
|
let end = 1, image = false;
|
|
@@ -1531,17 +1577,17 @@ function leadRows(t) {
|
|
|
1531
1577
|
for (const a of anchors) {
|
|
1532
1578
|
if (a.r !== r) continue;
|
|
1533
1579
|
end = Math.max(end, r + a.rs);
|
|
1534
|
-
if (
|
|
1580
|
+
if (_chunkI4BS4BXEcjs.IMAGE_CELLS.has(a.cell)) image = true;
|
|
1535
1581
|
}
|
|
1536
1582
|
}
|
|
1537
1583
|
return { height: ys[0] - ys[Math.min(end, ys.length - 1)], image };
|
|
1538
1584
|
}
|
|
1539
1585
|
function tailOf(b) {
|
|
1540
|
-
const t = b.table &&
|
|
1586
|
+
const t = b.table && _chunkI4BS4BXEcjs.TABLE_TAIL.get(b.table);
|
|
1541
1587
|
return t && b.bbox ? { ...b, pageNumber: t.page, bbox: { ...b.bbox, page: t.page, y: t.y, height: t.height } } : b;
|
|
1542
1588
|
}
|
|
1543
1589
|
function firstRowSig(t) {
|
|
1544
|
-
const x =
|
|
1590
|
+
const x = _chunkI4BS4BXEcjs.TABLE_COLXS.get(t);
|
|
1545
1591
|
if (!x || x.length !== t.cols + 1) return null;
|
|
1546
1592
|
return anchorsOf(t).filter((a) => a.r === 0).map((a) => ({ x1: x[a.c], x2: x[a.c + a.cs], t: flowText(a.cell.text).replace(/\s+/g, "") }));
|
|
1547
1593
|
}
|
|
@@ -1566,9 +1612,9 @@ function restartsTable(blocks, i, curr, pageHeights) {
|
|
|
1566
1612
|
}
|
|
1567
1613
|
function restartsTitledForm(head, curr) {
|
|
1568
1614
|
if (head.rows < 2 || curr.rows < 2 || head.cols !== curr.cols) return false;
|
|
1569
|
-
const full = (t) => _optionalChain([t, 'access',
|
|
1615
|
+
const full = (t) => _optionalChain([t, 'access', _101 => _101.cells, 'access', _102 => _102[0], 'access', _103 => _103[0], 'optionalAccess', _104 => _104.colSpan]) === t.cols;
|
|
1570
1616
|
if (!full(head) || !full(curr)) return false;
|
|
1571
|
-
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
1617
|
+
const norm = (c) => flowText(_nullishCoalesce(_optionalChain([c, 'optionalAccess', _105 => _105.text]), () => ( ""))).replace(/\s+/g, "");
|
|
1572
1618
|
const ht = norm(head.cells[0][0]), ct = norm(curr.cells[0][0]);
|
|
1573
1619
|
if (!ht || !ct || ht === ct) return false;
|
|
1574
1620
|
const titleLike = (t) => t.length <= TITLE_ROW_MAX_CHARS && !/^[ㅇ○◦•·\-–※*□■▪☞]/.test(t);
|
|
@@ -1594,7 +1640,7 @@ function chainHead(blocks, i, pageHeights) {
|
|
|
1594
1640
|
if (pb.pageNumber !== (_nullishCoalesce(cur.pageNumber, () => ( 0))) - 1) break;
|
|
1595
1641
|
if (!blocks.slice(p + 1, k).every((b) => besideOwn(b, pb, cur) || insideTable(b, pb) || pageNumberBetween(b, pb, cur, pageHeights))) break;
|
|
1596
1642
|
if (!looksContinued(pb, cur, pageHeights)) break;
|
|
1597
|
-
const px =
|
|
1643
|
+
const px = _chunkI4BS4BXEcjs.TABLE_COLXS.get(pb.table), cx = _chunkI4BS4BXEcjs.TABLE_COLXS.get(cur.table);
|
|
1598
1644
|
if (!px || !cx) break;
|
|
1599
1645
|
const dx = px[px.length - 1] - cx[cx.length - 1];
|
|
1600
1646
|
if (!shiftedSame(px, cx) && !px.some((x) => Math.abs(x - (cx[0] + dx)) <= CONTINUATION_COL_TOL) && !prevLacksLeftCols(pb, px, cx, pageHeights)) break;
|
|
@@ -1611,7 +1657,7 @@ function continueRowSpans(prevCells, currCells) {
|
|
|
1611
1657
|
if (hasContent(cell) || (cell.rowSpan || 1) < 2) continue;
|
|
1612
1658
|
let anchor;
|
|
1613
1659
|
for (let r = last - 1; r >= 0 && !anchor; r--) {
|
|
1614
|
-
const a = _optionalChain([prevCells, 'access',
|
|
1660
|
+
const a = _optionalChain([prevCells, 'access', _106 => _106[r], 'optionalAccess', _107 => _107[c]]);
|
|
1615
1661
|
if (a && r + (a.rowSpan || 1) === last && (a.colSpan || 1) === (cell.colSpan || 1) && (hasContent(a) || a.rowSpan >= 2)) anchor = a;
|
|
1616
1662
|
}
|
|
1617
1663
|
if (!anchor) continue;
|
|
@@ -1665,12 +1711,12 @@ var RESTART_LOOKBACK_PAGES = 5;
|
|
|
1665
1711
|
var COL_MATCH_TOL = 0.5;
|
|
1666
1712
|
var CONTINUED_TABLE_PAGE_BAND = 0.16;
|
|
1667
1713
|
function lastRowCell(t, x1, x2) {
|
|
1668
|
-
const xs =
|
|
1714
|
+
const xs = _chunkI4BS4BXEcjs.TABLE_COLXS.get(t);
|
|
1669
1715
|
const covered = /* @__PURE__ */ new Set();
|
|
1670
1716
|
for (let r = 0; r < t.rows; r++) {
|
|
1671
1717
|
for (let c = 0; c < t.cols; c++) {
|
|
1672
1718
|
if (covered.has(r * 1e5 + c)) continue;
|
|
1673
|
-
const cell = _optionalChain([t, 'access',
|
|
1719
|
+
const cell = _optionalChain([t, 'access', _108 => _108.cells, 'access', _109 => _109[r], 'optionalAccess', _110 => _110[c]]);
|
|
1674
1720
|
if (!cell) continue;
|
|
1675
1721
|
for (let dr = 0; dr < cell.rowSpan; dr++) for (let dc = 0; dc < cell.colSpan; dc++) covered.add((r + dr) * 1e5 + c + dc);
|
|
1676
1722
|
if (r + cell.rowSpan !== t.rows) continue;
|
|
@@ -1683,25 +1729,25 @@ var cellBlocks = (cell, pageNumber) => _nullishCoalesce(cell.blocks, () => ( cel
|
|
|
1683
1729
|
function mergeContinuedCells(blocks, pageHeights) {
|
|
1684
1730
|
for (let j = blocks.length - 1; j > 0; j--) {
|
|
1685
1731
|
const part = blocks[j];
|
|
1686
|
-
const from = part.table ?
|
|
1732
|
+
const from = part.table ? _chunkI4BS4BXEcjs.CONT_PARTS.get(part.table) : void 0;
|
|
1687
1733
|
if (!from || !part.table) continue;
|
|
1688
1734
|
let i = j - 1;
|
|
1689
1735
|
while (i >= 0 && blocks[i].type !== "table") i--;
|
|
1690
1736
|
const prev = blocks[i];
|
|
1691
1737
|
if (i < 0 || !prev.table || prev.pageNumber !== (_nullishCoalesce(part.pageNumber, () => ( 0))) - 1) continue;
|
|
1692
1738
|
const cell = lastRowCell(prev.table, from.x1, from.x2);
|
|
1693
|
-
const add = _optionalChain([part, 'access',
|
|
1739
|
+
const add = _optionalChain([part, 'access', _111 => _111.table, 'access', _112 => _112.cells, 'access', _113 => _113[0], 'optionalAccess', _114 => _114[0]]);
|
|
1694
1740
|
if (!cell || !add) continue;
|
|
1695
1741
|
const at = cell.blocks || add.blocks ? cellBlocks(cell, prev.pageNumber).length : -1;
|
|
1696
1742
|
if (cell.blocks || add.blocks) cell.blocks = [...cellBlocks(cell, prev.pageNumber), ...cellBlocks(add, part.pageNumber)];
|
|
1697
1743
|
else if (part.pageNumber) markContinuedText(cell, add, part.pageNumber);
|
|
1698
1744
|
cell.text = [cell.text, add.text].filter((s) => s.trim()).join("\n");
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1701
|
-
const lines =
|
|
1702
|
-
if (_optionalChain([lines, 'optionalAccess',
|
|
1703
|
-
if (part.pageNumber && part.bbox)
|
|
1704
|
-
if (cell.text.trim() || _optionalChain([cell, 'access',
|
|
1745
|
+
if (_chunkI4BS4BXEcjs.IMAGE_CELLS.has(add)) _chunkI4BS4BXEcjs.IMAGE_CELLS.add(cell);
|
|
1746
|
+
_chunkI4BS4BXEcjs.joinCellEdges.call(void 0, cell, add);
|
|
1747
|
+
const lines = _chunkI4BS4BXEcjs.CELL_LINES.get(add);
|
|
1748
|
+
if (_optionalChain([lines, 'optionalAccess', _115 => _115.length])) _chunkI4BS4BXEcjs.CELL_LINES.set(cell, [..._nullishCoalesce(_chunkI4BS4BXEcjs.CELL_LINES.get(cell), () => ( [])), ...lines]);
|
|
1749
|
+
if (part.pageNumber && part.bbox) _chunkI4BS4BXEcjs.TABLE_TAIL.set(prev.table, _nullishCoalesce(_chunkI4BS4BXEcjs.TABLE_TAIL.get(part.table), () => ( { page: part.pageNumber, y: part.bbox.y, height: part.bbox.height })));
|
|
1750
|
+
if (cell.text.trim() || _optionalChain([cell, 'access', _116 => _116.blocks, 'optionalAccess', _117 => _117.length]) || _chunkI4BS4BXEcjs.IMAGE_CELLS.has(cell)) _chunkI4BS4BXEcjs.EMPTY_PARTS.delete(prev.table);
|
|
1705
1751
|
blocks.splice(j, 1);
|
|
1706
1752
|
if (cell.blocks && at > 0) {
|
|
1707
1753
|
const nextAt = cell.blocks[at];
|
|
@@ -1713,28 +1759,28 @@ function mergeContinuedCells(blocks, pageHeights) {
|
|
|
1713
1759
|
}
|
|
1714
1760
|
function unwrapContinuedTable(blocks, at, pageHeights) {
|
|
1715
1761
|
const prev = blocks[at - 1], frame = blocks[at];
|
|
1716
|
-
if (!_optionalChain([prev, 'optionalAccess',
|
|
1717
|
-
const inner = _optionalChain([frame, 'access',
|
|
1718
|
-
const next = _optionalChain([inner, 'optionalAccess',
|
|
1719
|
-
if (!inner || !_optionalChain([next, 'optionalAccess',
|
|
1720
|
-
const px =
|
|
1762
|
+
if (!_optionalChain([prev, 'optionalAccess', _118 => _118.table]) || !_optionalChain([frame, 'optionalAccess', _119 => _119.table]) || frame.table.rows !== 1 || frame.table.cols !== 1 || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(frame.table)) return;
|
|
1763
|
+
const inner = _optionalChain([frame, 'access', _120 => _120.table, 'access', _121 => _121.cells, 'access', _122 => _122[0], 'optionalAccess', _123 => _123[0], 'optionalAccess', _124 => _124.blocks]);
|
|
1764
|
+
const next = _optionalChain([inner, 'optionalAccess', _125 => _125[0]]);
|
|
1765
|
+
if (!inner || !_optionalChain([next, 'optionalAccess', _126 => _126.table]) || !prev.bbox || !next.bbox || !prev.pageNumber || next.pageNumber !== prev.pageNumber + 1 || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(prev.table) || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(next.table) || prev.table.cols !== next.table.cols) return;
|
|
1766
|
+
const px = _chunkI4BS4BXEcjs.TABLE_COLXS.get(prev.table), nx = _chunkI4BS4BXEcjs.TABLE_COLXS.get(next.table);
|
|
1721
1767
|
if (!px || !nx || px.length !== nx.length || px.some((x, i) => Math.abs(x - nx[i]) > COL_MATCH_TOL)) return;
|
|
1722
|
-
const ph = _optionalChain([pageHeights, 'optionalAccess',
|
|
1768
|
+
const ph = _optionalChain([pageHeights, 'optionalAccess', _127 => _127.get, 'call', _128 => _128(prev.pageNumber)]), nh = _optionalChain([pageHeights, 'optionalAccess', _129 => _129.get, 'call', _130 => _130(next.pageNumber)]);
|
|
1723
1769
|
if (!ph || !nh || prev.bbox.y > ph * CONTINUED_TABLE_PAGE_BAND || next.bbox.y + next.bbox.height < nh * (1 - CONTINUED_TABLE_PAGE_BAND)) return;
|
|
1724
1770
|
blocks.splice(at, 1, ...inner);
|
|
1725
1771
|
}
|
|
1726
1772
|
function fillNestedContinuation(blocks, at) {
|
|
1727
1773
|
const prev = blocks[at - 1], next = blocks[at];
|
|
1728
|
-
const t = _optionalChain([prev, 'optionalAccess',
|
|
1729
|
-
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !
|
|
1730
|
-
const xs =
|
|
1774
|
+
const t = _optionalChain([prev, 'optionalAccess', _131 => _131.table]), u = _optionalChain([next, 'optionalAccess', _132 => _132.table]);
|
|
1775
|
+
if (!t || !u || u.rows !== 1 || u.cols !== 1 || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(t) || !_chunkI4BS4BXEcjs.CLIP_TABLES.has(u) || next.pageNumber !== (_nullishCoalesce(prev.pageNumber, () => ( 0))) + 1) return;
|
|
1776
|
+
const xs = _chunkI4BS4BXEcjs.TABLE_COLXS.get(u);
|
|
1731
1777
|
const cell = xs ? lastRowCell(t, xs[0], xs[xs.length - 1]) : void 0;
|
|
1732
|
-
const add = _optionalChain([u, 'access',
|
|
1733
|
-
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access',
|
|
1778
|
+
const add = _optionalChain([u, 'access', _133 => _133.cells, 'access', _134 => _134[0], 'optionalAccess', _135 => _135[0]]);
|
|
1779
|
+
if (!cell || !add || cell.text.trim() || _optionalChain([cell, 'access', _136 => _136.blocks, 'optionalAccess', _137 => _137.length]) || _chunkI4BS4BXEcjs.IMAGE_CELLS.has(cell)) return;
|
|
1734
1780
|
cell.text = add.text;
|
|
1735
1781
|
if (add.blocks) cell.blocks = add.blocks;
|
|
1736
|
-
if (
|
|
1737
|
-
|
|
1782
|
+
if (_chunkI4BS4BXEcjs.IMAGE_CELLS.has(add)) _chunkI4BS4BXEcjs.IMAGE_CELLS.add(cell);
|
|
1783
|
+
_chunkI4BS4BXEcjs.joinCellEdges.call(void 0, cell, add);
|
|
1738
1784
|
blocks.splice(at, 1);
|
|
1739
1785
|
}
|
|
1740
1786
|
|
|
@@ -1907,7 +1953,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
1907
1953
|
if (!cache.has(key)) {
|
|
1908
1954
|
let sym = null;
|
|
1909
1955
|
try {
|
|
1910
|
-
const data = _optionalChain([fontObj, 'call',
|
|
1956
|
+
const data = _optionalChain([fontObj, 'call', _138 => _138(font), 'optionalAccess', _139 => _139.data]);
|
|
1911
1957
|
const code = glyph.fontChar.codePointAt(0);
|
|
1912
1958
|
const outline = data && code !== void 0 ? readOutline(data, code) : null;
|
|
1913
1959
|
if (outline) sym = classifyOutline(outline);
|
|
@@ -1931,7 +1977,7 @@ function restoreUnmappedGlyphs(items, fnArray, argsArray, fontObj) {
|
|
|
1931
1977
|
}
|
|
1932
1978
|
for (const [f, list] of byFont) {
|
|
1933
1979
|
const q = queues.get(f);
|
|
1934
|
-
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access',
|
|
1980
|
+
const want = list.reduce((n, it) => n + (_nullishCoalesce(_optionalChain([it, 'access', _140 => _140.str, 'access', _141 => _141.match, 'call', _142 => _142(//g), 'optionalAccess', _143 => _143.length]), () => ( 0))), 0);
|
|
1935
1981
|
if (!q || q.length !== want) continue;
|
|
1936
1982
|
let k = 0;
|
|
1937
1983
|
for (const it of list) it.str = it.str.replace(//g, () => q[k++]);
|
|
@@ -1954,15 +2000,15 @@ function selectionContextPages(selected, pageCount) {
|
|
|
1954
2000
|
function marginContextBlocks(raw, page, view) {
|
|
1955
2001
|
const [x1, y1, x2, y2] = view;
|
|
1956
2002
|
const width = x2 - x1, height = y2 - y1;
|
|
1957
|
-
const items =
|
|
2003
|
+
const items = _chunkI4BS4BXEcjs.filterHiddenText.call(void 0, _chunkI4BS4BXEcjs.normalizeItems.call(void 0, raw), width, height, x1, y1).visible;
|
|
1958
2004
|
for (const item of items) {
|
|
1959
2005
|
item.x -= x1;
|
|
1960
2006
|
item.y -= y1;
|
|
1961
2007
|
}
|
|
1962
|
-
return
|
|
1963
|
-
const bbox =
|
|
2008
|
+
return _chunkI4BS4BXEcjs.groupByY.call(void 0, items).flatMap((line) => {
|
|
2009
|
+
const bbox = _chunkI4BS4BXEcjs.computeBBox.call(void 0, line, page);
|
|
1964
2010
|
if (bbox.y + bbox.height < height * 0.88 && bbox.y > height * 0.12) return [];
|
|
1965
|
-
return [{ type: "paragraph", text:
|
|
2011
|
+
return [{ type: "paragraph", text: _chunkI4BS4BXEcjs.mergeLineSimple.call(void 0, line), pageNumber: page, bbox, style: _chunkI4BS4BXEcjs.dominantStyle.call(void 0, line) }];
|
|
1966
2012
|
});
|
|
1967
2013
|
}
|
|
1968
2014
|
|
|
@@ -1998,7 +2044,7 @@ var WINANSI_REVERSE = {
|
|
|
1998
2044
|
};
|
|
1999
2045
|
function symbolFontTable(fontName) {
|
|
2000
2046
|
if (!fontName) return void 0;
|
|
2001
|
-
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return
|
|
2047
|
+
if (/wingdings(?![\s-]*[23])/i.test(fontName)) return _chunkMED2MR6Ocjs.WINGDINGS;
|
|
2002
2048
|
return void 0;
|
|
2003
2049
|
}
|
|
2004
2050
|
function remapSymbolText(text, table) {
|
|
@@ -2126,7 +2172,7 @@ function layout(toks) {
|
|
|
2126
2172
|
const bar = rest.find((t) => t.bar && t.x >= rt.x && t.x <= rt.x + rt.w + 2 && Math.abs(t.y - rt.y) <= size * 1.5);
|
|
2127
2173
|
if (!bar) continue;
|
|
2128
2174
|
const inner = rest.filter((t) => !t.bar && t !== rt && t.x + t.w / 2 > bar.x && t.x + t.w / 2 < bar.x + bar.w && bar.y - t.y > 0 && bar.y - t.y <= size * 1.4);
|
|
2129
|
-
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access',
|
|
2175
|
+
const tok = { text: `\\sqrt{${linear(inner)}}`, x: rt.x, w: bar.x + bar.w - rt.x, y: _nullishCoalesce(_optionalChain([inner, 'access', _144 => _144[0], 'optionalAccess', _145 => _145.y]), () => ( rt.y)), size: Math.max(rt.size, ...inner.map((t) => t.size)), bar: false };
|
|
2130
2176
|
rest = [...rest.filter((t) => t !== rt && t !== bar && !inner.includes(t)), tok];
|
|
2131
2177
|
}
|
|
2132
2178
|
const bars = rest.filter((t) => t.bar).sort((a, b) => a.w - b.w);
|
|
@@ -2228,7 +2274,7 @@ function wrapEquationRuns(items, faceName) {
|
|
|
2228
2274
|
for (const i of mains) ys.set(i.y, (_nullishCoalesce(ys.get(i.y), () => ( 0))) + 1);
|
|
2229
2275
|
const top = [...ys].sort((p, q) => q[1] - p[1]);
|
|
2230
2276
|
const bar = cur.find(isBarItem);
|
|
2231
|
-
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access',
|
|
2277
|
+
const lineY = bar && top.length > 1 && top[0][1] === top[1][1] ? Math.round(bar.y + size * 0.3) : _nullishCoalesce(_optionalChain([top, 'access', _146 => _146[0], 'optionalAccess', _147 => _147[0]]), () => ( cur[0].y));
|
|
2232
2278
|
const base = { ..._nullishCoalesce(mains[0], () => ( cur[0])), y: lineY, fontSize: size || cur[0].fontSize };
|
|
2233
2279
|
const x1 = Math.min(...cur.map((i) => i.x)), x2 = Math.max(...cur.map((i) => i.x + i.w));
|
|
2234
2280
|
added.push({ ...base, text: `$${tex}$`, x: x1, w: x2 - x1, hasSpaceBefore: true });
|
|
@@ -2585,7 +2631,7 @@ function joinVerticalColumns(items) {
|
|
|
2585
2631
|
const groups = [];
|
|
2586
2632
|
for (const col of columns) {
|
|
2587
2633
|
const g2 = groups[groups.length - 1];
|
|
2588
|
-
const last = _optionalChain([g2, 'optionalAccess',
|
|
2634
|
+
const last = _optionalChain([g2, 'optionalAccess', _148 => _148[g2.length - 1]]);
|
|
2589
2635
|
const fs = col.items[0].fontSize;
|
|
2590
2636
|
if (last && last.x - col.x >= fs * 1.2 && last.x - col.x <= fs * 4 && Math.abs(last.items[0].y - col.items[0].y) <= fs * 1.2) g2.push(col);
|
|
2591
2637
|
else groups.push([col]);
|
|
@@ -2801,7 +2847,7 @@ function relocateEndnotes(blocks) {
|
|
|
2801
2847
|
}
|
|
2802
2848
|
const shapes = /* @__PURE__ */ new Map();
|
|
2803
2849
|
for (const h of heads) shapes.set(h.shape, (_nullishCoalesce(shapes.get(h.shape), () => ( 0))) + 1);
|
|
2804
|
-
const main = _optionalChain([[...shapes], 'access',
|
|
2850
|
+
const main = _optionalChain([[...shapes], 'access', _149 => _149.sort, 'call', _150 => _150((a, b) => b[1] - a[1]), 'access', _151 => _151[0], 'optionalAccess', _152 => _152[0]]);
|
|
2805
2851
|
if (!main || !/#/.test(main)) return blocks;
|
|
2806
2852
|
const lastRun = (hs) => {
|
|
2807
2853
|
let run2 = [];
|
|
@@ -2864,7 +2910,7 @@ function dropTabLeaderDots(items) {
|
|
|
2864
2910
|
let run = [];
|
|
2865
2911
|
const flush = () => {
|
|
2866
2912
|
const last = run[run.length - 1];
|
|
2867
|
-
const tailPage = _optionalChain([DOTS_PAGE, 'access',
|
|
2913
|
+
const tailPage = _optionalChain([DOTS_PAGE, 'access', _153 => _153.exec, 'call', _154 => _154(last.text.trim()), 'optionalAccess', _155 => _155[1]]);
|
|
2868
2914
|
const dots = run.reduce((n, d) => n + d.text.trim().replace(/\d+$/, "").length, 0);
|
|
2869
2915
|
if (dots >= MIN_DOTS && (tailPage ? run.length > 1 : pageNoAfter(last.x + last.w, last))) {
|
|
2870
2916
|
const body = tailPage ? run.slice(0, -1) : run;
|
|
@@ -2952,7 +2998,7 @@ function inlineFootnotes(blocks, pages) {
|
|
|
2952
2998
|
open = true;
|
|
2953
2999
|
continue;
|
|
2954
3000
|
}
|
|
2955
|
-
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3001
|
+
const prev = pb[j - 1], line = (_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontSize]), () => ( _optionalChain([b, 'access', _158 => _158.bbox, 'optionalAccess', _159 => _159.height]))), () => ( 10))) * 1.5;
|
|
2956
3002
|
if (open && b.bbox && prev.bbox && prev.bbox.y - top(b) <= line && !/^[-–—\s\d]+$/.test(b.text)) {
|
|
2957
3003
|
notes[notes.length - 1].text += " " + b.text.trim();
|
|
2958
3004
|
notes[notes.length - 1].blocks.push(b);
|
|
@@ -2975,7 +3021,7 @@ var CAPTION = /^(?:Table|Figure|Fig\.?)\s*\d+(?:\.\d+)*\s*[.:]/i;
|
|
|
2975
3021
|
var EQUATION_NUMBER = /\t\(\d{1,3}[a-z]?\)\s*$/;
|
|
2976
3022
|
var DISPLAY_MATH = /=|[√∑∏∫∂∇≤≥≈≠∈∀∃]/;
|
|
2977
3023
|
function isRunningHead(block, page, pageHeight) {
|
|
2978
|
-
const box = block.bbox, text = _optionalChain([block, 'access',
|
|
3024
|
+
const box = block.bbox, text = _optionalChain([block, 'access', _160 => _160.text, 'optionalAccess', _161 => _161.trim, 'call', _162 => _162()]);
|
|
2979
3025
|
if (!box || !text || !pageHeight) return false;
|
|
2980
3026
|
const top = box.y + box.height >= pageHeight * 0.9;
|
|
2981
3027
|
const bottom = box.y <= pageHeight * 0.1;
|
|
@@ -2983,7 +3029,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
2983
3029
|
const others = page.filter((o) => o !== block && o.bbox && o.type !== "image" && o.type !== "separator");
|
|
2984
3030
|
if (top && others.some((o) => o.bbox.y + o.bbox.height > box.y + box.height)) return false;
|
|
2985
3031
|
if (bottom && others.some((o) => o.bbox.y < box.y)) return false;
|
|
2986
|
-
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access',
|
|
3032
|
+
if (bottom && box.height <= (_nullishCoalesce(_optionalChain([block, 'access', _163 => _163.style, 'optionalAccess', _164 => _164.fontSize]), () => ( 0))) * 1.6) return true;
|
|
2987
3033
|
if (!text.includes(" ")) return false;
|
|
2988
3034
|
const parts = text.split(/\t+/).map((part) => part.trim()).filter(Boolean);
|
|
2989
3035
|
if (parts.length >= 2 && (PAGE_NUMBER.test(parts[0]) || PAGE_NUMBER.test(parts[parts.length - 1]))) return true;
|
|
@@ -2992,7 +3038,7 @@ function isRunningHead(block, page, pageHeight) {
|
|
|
2992
3038
|
return right > left && box.width >= (right - left) * 0.6;
|
|
2993
3039
|
}
|
|
2994
3040
|
function unbalancedClose(text) {
|
|
2995
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
3041
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _165 => _165.match, 'call', _166 => _166(/\)/g), 'optionalAccess', _167 => _167.length]), () => ( 0))) > (_nullishCoalesce(_optionalChain([text, 'access', _168 => _168.match, 'call', _169 => _169(/\(/g), 'optionalAccess', _170 => _170.length]), () => ( 0)));
|
|
2996
3042
|
}
|
|
2997
3043
|
function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
2998
3044
|
const byPage = /* @__PURE__ */ new Map();
|
|
@@ -3008,7 +3054,7 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3008
3054
|
const sizes = /* @__PURE__ */ new Map();
|
|
3009
3055
|
let proseChars = 0;
|
|
3010
3056
|
for (const b of page) {
|
|
3011
|
-
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access',
|
|
3057
|
+
if (b.type !== "paragraph" && b.type !== "heading" || !b.text || !_optionalChain([b, 'access', _171 => _171.style, 'optionalAccess', _172 => _172.fontName]) || !b.style.fontSize) continue;
|
|
3012
3058
|
const key2 = `${b.style.fontName}:${b.style.fontSize}`;
|
|
3013
3059
|
chars.set(key2, (_nullishCoalesce(chars.get(key2), () => ( 0))) + b.text.length);
|
|
3014
3060
|
if (b.type === "paragraph" && b.style.fontName === "ocr") {
|
|
@@ -3032,13 +3078,13 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3032
3078
|
const citedProse = /* @__PURE__ */ new Set();
|
|
3033
3079
|
const numberedProse = /* @__PURE__ */ new Set();
|
|
3034
3080
|
for (const page of byPage.values()) {
|
|
3035
|
-
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3081
|
+
const numbered = page.filter((b) => (b.type === "heading" || b.type === "paragraph") && /^[①-⑮]\s*/.test(_nullishCoalesce(_optionalChain([b, 'access', _173 => _173.text, 'optionalAccess', _174 => _174.trim, 'call', _175 => _175()]), () => ( ""))) && b.bbox && _optionalChain([b, 'access', _176 => _176.style, 'optionalAccess', _177 => _177.fontName]) && b.style.fontSize && !/Bold|Black|Heavy|Semibold/i.test(_nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _178 => _178.get, 'call', _179 => _179(b.style.fontName)]), () => ( ""))));
|
|
3036
3082
|
let chain = [];
|
|
3037
3083
|
const finish = () => {
|
|
3038
|
-
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access',
|
|
3084
|
+
if (chain.length < 3 || !chain.some((b) => (_nullishCoalesce(_optionalChain([b, 'access', _180 => _180.text, 'optionalAccess', _181 => _181.length]), () => ( 0))) >= 40 && b.bbox.height >= b.style.fontSize * 2.4)) return;
|
|
3039
3085
|
for (const b of chain) numberedProse.add(b);
|
|
3040
3086
|
const first = chain[0], size = first.style.fontSize;
|
|
3041
|
-
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3087
|
+
for (const b of page) if (/^[○●•◦]\s/.test(_nullishCoalesce(_optionalChain([b, 'access', _182 => _182.text, 'optionalAccess', _183 => _183.trim, 'call', _184 => _184()]), () => ( ""))) && _optionalChain([b, 'access', _185 => _185.style, 'optionalAccess', _186 => _186.fontName]) === _optionalChain([first, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontName]) && _optionalChain([b, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontSize]) === size && b.bbox && Math.abs(b.bbox.x - first.bbox.x) <= size * 0.5 && (_nullishCoalesce(_optionalChain([b, 'access', _191 => _191.text, 'optionalAccess', _192 => _192.length]), () => ( 0))) >= 15) numberedProse.add(b);
|
|
3042
3088
|
};
|
|
3043
3089
|
for (const b of numbered) {
|
|
3044
3090
|
const prev = chain.at(-1), size = b.style.fontSize;
|
|
@@ -3052,9 +3098,9 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3052
3098
|
}
|
|
3053
3099
|
for (let i = 0; i + 1 < blocks.length; i++) {
|
|
3054
3100
|
const prose = blocks[i], reference = blocks[i + 1];
|
|
3055
|
-
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access',
|
|
3056
|
-
const source = _nullishCoalesce(_optionalChain([reference, 'access',
|
|
3057
|
-
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access',
|
|
3101
|
+
const a = prose.bbox, b = reference.bbox, size = _nullishCoalesce(_optionalChain([prose, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontSize]), () => ( 0));
|
|
3102
|
+
const source = _nullishCoalesce(_optionalChain([reference, 'access', _195 => _195.text, 'optionalAccess', _196 => _196.replace, 'call', _197 => _197(/<[^>]+>/g, ""), 'access', _198 => _198.trim, 'call', _199 => _199()]), () => ( ""));
|
|
3103
|
+
if (prose.type !== "heading" && prose.type !== "paragraph" && prose.type !== "list" || reference.type !== "heading" && reference.type !== "paragraph" || (_nullishCoalesce(_optionalChain([prose, 'access', _200 => _200.text, 'optionalAccess', _201 => _201.length]), () => ( 0))) < 40 || !a || !b || size <= 0 || a.height < size * 2.4 || prose.pageNumber !== reference.pageNumber || _optionalChain([prose, 'access', _202 => _202.style, 'optionalAccess', _203 => _203.fontName]) !== _optionalChain([reference, 'access', _204 => _204.style, 'optionalAccess', _205 => _205.fontName]) || _optionalChain([prose, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]) !== _optionalChain([reference, 'access', _208 => _208.style, 'optionalAccess', _209 => _209.fontSize]) || Math.abs(a.x - b.x) > size && !(/^[○●•◦]\s/.test(_nullishCoalesce(prose.text, () => ( ""))) && b.x >= a.x && b.x - a.x <= size * 2) || a.y - (b.y + b.height) < 0 || a.y - (b.y + b.height) > size || !/^[((].*(?:제\s*\d+\s*조|(?:Article|Section)\s+\d+).*[))]$/i.test(source)) continue;
|
|
3058
3104
|
citedProse.add(prose);
|
|
3059
3105
|
citedProse.add(reference);
|
|
3060
3106
|
}
|
|
@@ -3062,49 +3108,49 @@ function demoteNonHeadingRoles(blocks, pageHeights, faceNames) {
|
|
|
3062
3108
|
const block = blocks[i];
|
|
3063
3109
|
if (block.type !== "heading" || !block.text) continue;
|
|
3064
3110
|
const text = block.text.replace(/<[^>]+>/g, "").trim();
|
|
3065
|
-
const fsz = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3066
|
-
const tocEntry = i > 0 &&
|
|
3111
|
+
const fsz = _nullishCoalesce(_optionalChain([block, 'access', _210 => _210.style, 'optionalAccess', _211 => _211.fontSize]), () => ( 0));
|
|
3112
|
+
const tocEntry = i > 0 && _chunkI4BS4BXEcjs.TOC_BLOCKS.has(blocks[i - 1]) && _chunkI4BS4BXEcjs.TOC_BLOCKS.has(blocks[i + 1]);
|
|
3067
3113
|
const page = _nullishCoalesce(byPage.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( []));
|
|
3068
|
-
const proseStyle = _optionalChain([block, 'access',
|
|
3114
|
+
const proseStyle = _optionalChain([block, 'access', _212 => _212.style, 'optionalAccess', _213 => _213.fontName]) && bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))) === `${block.style.fontName}:${block.style.fontSize}` && text.length > 60;
|
|
3069
3115
|
const next = blocks[i + 1];
|
|
3070
|
-
const nb = _optionalChain([next, 'optionalAccess',
|
|
3071
|
-
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
3072
|
-
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess',
|
|
3116
|
+
const nb = _optionalChain([next, 'optionalAccess', _214 => _214.bbox]), bb = block.bbox;
|
|
3117
|
+
const chapterNumber = !!nb && !!bb && fsz >= (_nullishCoalesce(_optionalChain([next, 'optionalAccess', _215 => _215.style, 'optionalAccess', _216 => _216.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;
|
|
3118
|
+
if (/^\d+(?:\.\d+)*\.?$/.test(text) && _optionalChain([next, 'optionalAccess', _217 => _217.type]) === "heading" && next.text && next.pageNumber === block.pageNumber && !chapterNumber) {
|
|
3073
3119
|
next.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3074
3120
|
blocks.splice(i--, 1);
|
|
3075
3121
|
continue;
|
|
3076
3122
|
}
|
|
3077
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
3123
|
+
if ((_optionalChain([next, 'optionalAccess', _218 => _218.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _219 => _219.type]) === "heading" && !CAPTION.test(text)) && next.pageNumber === block.pageNumber && next.text && next.bbox && block.bbox && _optionalChain([next, 'access', _220 => _220.style, 'optionalAccess', _221 => _221.fontName]) === _optionalChain([block, 'access', _222 => _222.style, 'optionalAccess', _223 => _223.fontName]) && _optionalChain([next, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontSize]) === _optionalChain([block, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontSize]) && fsz > 0 && /^[a-z]/.test(next.text.trim()) && next.text.trim().length <= 40 && !/[.:;!?]$/.test(next.text.trim()) && block.bbox.y - (next.bbox.y + next.bbox.height) < fsz * 1.2 && Math.abs(next.bbox.x - block.bbox.x) < fsz) {
|
|
3078
3124
|
block.text = `${block.text.trim()} ${next.text.trim()}`;
|
|
3079
3125
|
block.bbox = { ...block.bbox, y: next.bbox.y, height: block.bbox.y + block.bbox.height - next.bbox.y };
|
|
3080
3126
|
blocks.splice(i + 1, 1);
|
|
3081
3127
|
}
|
|
3082
3128
|
const after = blocks[i + 2];
|
|
3083
|
-
if ((_optionalChain([next, 'optionalAccess',
|
|
3129
|
+
if ((_optionalChain([next, 'optionalAccess', _228 => _228.type]) === "paragraph" || _optionalChain([next, 'optionalAccess', _229 => _229.type]) === "heading") && /^(?:&|\+|and|or)$/i.test(_nullishCoalesce(_optionalChain([next, 'access', _230 => _230.text, 'optionalAccess', _231 => _231.trim, 'call', _232 => _232()]), () => ( ""))) && _optionalChain([after, 'optionalAccess', _233 => _233.type]) === "heading" && after.text && after.pageNumber === block.pageNumber && next.pageNumber === block.pageNumber && _optionalChain([after, 'access', _234 => _234.style, 'optionalAccess', _235 => _235.fontSize]) === _optionalChain([block, 'access', _236 => _236.style, 'optionalAccess', _237 => _237.fontSize])) {
|
|
3084
3130
|
block.text = `${block.text.trim()} ${next.text.trim()} ${after.text.trim()}`;
|
|
3085
3131
|
blocks.splice(i + 1, 2);
|
|
3086
3132
|
}
|
|
3087
3133
|
const tiny = fsz > 0 && fsz < 7.5;
|
|
3088
3134
|
const prev = blocks[i - 1];
|
|
3089
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
3135
|
+
if (_optionalChain([prev, 'optionalAccess', _238 => _238.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^[a-z]{1,3}[.)]$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _239 => _239.text, 'optionalAccess', _240 => _240.trim, 'call', _241 => _241()]), () => ( ""))) && prev.bbox && block.bbox && Math.abs(prev.bbox.y - block.bbox.y) < 2 && prev.bbox.x + prev.bbox.width <= block.bbox.x) {
|
|
3090
3136
|
prev.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3091
3137
|
prev.bbox = { ...prev.bbox, width: block.bbox.x + block.bbox.width - prev.bbox.x };
|
|
3092
3138
|
blocks.splice(i--, 1);
|
|
3093
3139
|
continue;
|
|
3094
3140
|
}
|
|
3095
|
-
if (_optionalChain([prev, 'optionalAccess',
|
|
3141
|
+
if (_optionalChain([prev, 'optionalAccess', _242 => _242.type]) === "paragraph" && prev.pageNumber === block.pageNumber && /^\d{1,2}(?:\.\d{1,2})*\.?$/.test(_nullishCoalesce(_optionalChain([prev, 'access', _243 => _243.text, 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]), () => ( ""))) && 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', _246 => _246.style, 'optionalAccess', _247 => _247.fontSize]), () => ( 0))) >= fsz && prev.bbox.y - (block.bbox.y + block.bbox.height) < fsz * 1.5)) {
|
|
3096
3142
|
block.text = `${prev.text.trim()} ${block.text.trim()}`;
|
|
3097
3143
|
blocks.splice(i - 1, 1);
|
|
3098
3144
|
i -= 2;
|
|
3099
3145
|
continue;
|
|
3100
3146
|
}
|
|
3101
|
-
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3102
|
-
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess',
|
|
3103
|
-
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess',
|
|
3147
|
+
const box = block.bbox, size = _nullishCoalesce(_optionalChain([block, 'access', _248 => _248.style, 'optionalAccess', _249 => _249.fontSize]), () => ( 0));
|
|
3148
|
+
const kicker = !!box && size > 0 && _optionalChain([next, 'optionalAccess', _250 => _250.type]) === "heading" && next.pageNumber === block.pageNumber && !!next.bbox && (_optionalChain([block, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontName]) !== "ocr" || size < (_nullishCoalesce(bodySizes.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( Infinity))) * 2) && (_nullishCoalesce(_optionalChain([next, 'access', _253 => _253.style, 'optionalAccess', _254 => _254.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");
|
|
3149
|
+
const face = _nullishCoalesce(_optionalChain([faceNames, 'optionalAccess', _255 => _255.get, 'call', _256 => _256(_nullishCoalesce(_optionalChain([block, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.fontName]), () => ( "")))]), () => ( ""));
|
|
3104
3150
|
const [bodyFace, bodySize] = (_nullishCoalesce(bodyStyle.get(_nullishCoalesce(block.pageNumber, () => ( 0))), () => ( ""))).split(":");
|
|
3105
|
-
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access',
|
|
3106
|
-
const ocrFragment = _optionalChain([block, 'access',
|
|
3107
|
-
const crowdedOcr = _optionalChain([block, 'access',
|
|
3151
|
+
const byline = /Italic|Oblique/i.test(face) && !/Bold|Black|Heavy|Semibold/i.test(face) && !!bodyFace && size <= Number(bodySize) + 0.5 && _optionalChain([blocks, 'access', _259 => _259[i - 1], 'optionalAccess', _260 => _260.type]) === "heading" && blocks[i - 1].pageNumber === block.pageNumber;
|
|
3152
|
+
const ocrFragment = _optionalChain([block, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName]) === "ocr" && (/^[.,;:…·•-]/.test(text) || text.includes("\u2026") || (_nullishCoalesce(_optionalChain([text, 'access', _263 => _263.match, 'call', _264 => _264(/\p{L}/gu), 'optionalAccess', _265 => _265.length]), () => ( 0))) < 2 || text.split(/\s+/).length > 7);
|
|
3153
|
+
const crowdedOcr = _optionalChain([block, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontName]) === "ocr" && !!box && [prev, next].every((o) => _optionalChain([o, 'optionalAccess', _268 => _268.type]) === "paragraph" && o.pageNumber === block.pageNumber && _optionalChain([o, 'access', _269 => _269.style, 'optionalAccess', _270 => _270.fontName]) === "ocr" && !!o.bbox && (_nullishCoalesce(_optionalChain([o, 'access', _271 => _271.text, 'optionalAccess', _272 => _272.length]), () => ( 0))) >= 15 && Math.abs(o.bbox.x - box.x) <= size * 0.25 && Math.min(o.bbox.y + o.bbox.height, box.y + box.height) - Math.max(o.bbox.y, box.y) >= o.bbox.height * 0.2) && prev.bbox.y > box.y && next.bbox.y < box.y;
|
|
3108
3154
|
if (numberedProse.has(block) || citedProse.has(block) || ocrFragment || crowdedOcr || tocEntry || proseStyle || kicker || byline || tiny || !/\p{L}/u.test(text) && !chapterNumber || /^[a-z]/.test(text) || CAPTION.test(text) || EQUATION_NUMBER.test(block.text) || DISPLAY_MATH.test(text) || // 닫는 괄호가 여는 괄호보다 많으면 앞 줄에서 이어진 문장 조각이다 ("Fact-checking) and is used …") — "1)"·"가)" 앞머리 번호는 빼고 센다
|
|
3109
3155
|
unbalancedClose(text.replace(/^\s*[\dA-Za-z가-힣ⅰ-ⅹ]{1,3}\)\s*/, "")) || isRunningHead(block, page, pageHeights.get(_nullishCoalesce(block.pageNumber, () => ( 0))))) {
|
|
3110
3156
|
block.type = "paragraph";
|
|
@@ -3154,34 +3200,34 @@ var CAPTION_LABEL = /^(?:figure|fig\.|diagram|table|chart|graph|exhibit|box)\s*[
|
|
|
3154
3200
|
function captionTableText(t) {
|
|
3155
3201
|
if (!t || t.rows !== 1 || t.cols !== 2) return null;
|
|
3156
3202
|
const [label, body] = t.cells[0];
|
|
3157
|
-
if (!label || !body || _optionalChain([label, 'access',
|
|
3203
|
+
if (!label || !body || _optionalChain([label, 'access', _273 => _273.blocks, 'optionalAccess', _274 => _274.length]) || _optionalChain([body, 'access', _275 => _275.blocks, 'optionalAccess', _276 => _276.length]) || !CAPTION_LABEL.test(label.text.trim()) || !body.text.trim()) return null;
|
|
3158
3204
|
return `${label.text.trim()} ${body.text.replace(/\s*\n\s*/g, " ").trim()}`;
|
|
3159
3205
|
}
|
|
3160
3206
|
function splitSingleCellTables(blocks) {
|
|
3161
3207
|
const out = [];
|
|
3162
3208
|
for (const b of blocks) {
|
|
3163
3209
|
const t = b.type === "table" ? b.table : void 0;
|
|
3164
|
-
const title = t &&
|
|
3210
|
+
const title = t && _chunkI4BS4BXEcjs.FRAME_TITLE_BLOCKS.get(t);
|
|
3165
3211
|
if (title) {
|
|
3166
3212
|
out.push({ ...title, text: `${t.cells[0][0].text.trim()} ${t.cells[0][2].text.trim()}` });
|
|
3167
3213
|
continue;
|
|
3168
3214
|
}
|
|
3169
|
-
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access',
|
|
3215
|
+
const only = t && t.rows === 1 && t.cols === 1 && _optionalChain([t, 'access', _277 => _277.cells, 'access', _278 => _278[0], 'optionalAccess', _279 => _279[0], 'optionalAccess', _280 => _280.blocks, 'optionalAccess', _281 => _281.length]) === 1 ? t.cells[0][0].blocks[0] : void 0;
|
|
3170
3216
|
const squash = (s) => s.replace(/\s/g, "");
|
|
3171
3217
|
const inner = only && (!squash(t.cells[0][0].text) || only.type === "table" && squash(t.cells[0][0].text) === squash(only.table.cells.flat().map((c) => c.text).join(""))) ? only : void 0;
|
|
3172
|
-
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess',
|
|
3218
|
+
const caption = _nullishCoalesce(captionTableText(t), () => ( (_optionalChain([inner, 'optionalAccess', _282 => _282.type]) === "table" ? captionTableText(inner.table) : null)));
|
|
3173
3219
|
if (caption) {
|
|
3174
3220
|
out.push({ type: "paragraph", text: caption, pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3175
3221
|
continue;
|
|
3176
3222
|
}
|
|
3177
|
-
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access',
|
|
3223
|
+
const cell = t && t.rows === 1 && t.cols === 1 ? _optionalChain([t, 'access', _283 => _283.cells, 'access', _284 => _284[0], 'optionalAccess', _285 => _285[0]]) : void 0;
|
|
3178
3224
|
if (!cell) {
|
|
3179
3225
|
out.push(b);
|
|
3180
3226
|
continue;
|
|
3181
3227
|
}
|
|
3182
3228
|
const lines = (_nullishCoalesce(cell.text, () => ( ""))).split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
3183
|
-
if (_optionalChain([t, 'optionalAccess',
|
|
3184
|
-
if (_optionalChain([cell, 'access',
|
|
3229
|
+
if (_optionalChain([t, 'optionalAccess', _286 => _286.caption, 'optionalAccess', _287 => _287.trim, 'call', _288 => _288()])) out.push({ type: "paragraph", text: t.caption.trim(), pageNumber: b.pageNumber, bbox: b.bbox });
|
|
3230
|
+
if (_optionalChain([cell, 'access', _289 => _289.blocks, 'optionalAccess', _290 => _290.length])) {
|
|
3185
3231
|
out.push(...splitSingleCellTables(cell.blocks));
|
|
3186
3232
|
continue;
|
|
3187
3233
|
}
|
|
@@ -3197,7 +3243,7 @@ function joinLatinCellWraps(blocks) {
|
|
|
3197
3243
|
const lines = cell.text.split("\n");
|
|
3198
3244
|
const out = [lines[0]];
|
|
3199
3245
|
for (const line of lines.slice(1)) {
|
|
3200
|
-
if (
|
|
3246
|
+
if (_chunkI4BS4BXEcjs.latinSoftWrap.call(void 0, out[out.length - 1], line)) out[out.length - 1] = out[out.length - 1].trimEnd() + " " + line.trim();
|
|
3201
3247
|
else out.push(line);
|
|
3202
3248
|
}
|
|
3203
3249
|
cell.text = out.join("\n");
|
|
@@ -3208,19 +3254,19 @@ function joinLatinCellWraps(blocks) {
|
|
|
3208
3254
|
}
|
|
3209
3255
|
function cleanPdfText(text, opts) {
|
|
3210
3256
|
let clean = normalizeAraea(stripControlChars(text));
|
|
3211
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3257
|
+
if (!_optionalChain([opts, 'optionalAccess', _291 => _291.keepLoneNumbers])) {
|
|
3212
3258
|
clean = clean.replace(/^\d{1,4}\n/, "").replace(/\n\d{1,4}\n/g, "\n").replace(/\n\d{1,4}$/, "");
|
|
3213
3259
|
}
|
|
3214
|
-
if (!_optionalChain([opts, 'optionalAccess',
|
|
3260
|
+
if (!_optionalChain([opts, 'optionalAccess', _292 => _292.keepLoneNumbers])) clean = clean.replace(/^#{1,6}\s*\d{1,4}\s*$/gm, "");
|
|
3215
3261
|
return mergeKoreanLines(
|
|
3216
3262
|
clean.replace(/^[\s]*[-–—]\s*[-–—]?\d+[-–—]?[\s]*[-–—]?[\s]*$/gm, "").replace(/^\s*\d+\s*\/\s*\d+\s*$/gm, "").replace(/\.(?: \.){3,}/g, (m) => ".".repeat(m.length + 1 >> 1))
|
|
3217
3263
|
).replace(/^(?!\| ---).*$/gm, (line) => {
|
|
3218
3264
|
if (/^\s*\${1,2}.+\${1,2}\s*$/.test(line)) return line;
|
|
3219
3265
|
if (line.startsWith("|")) {
|
|
3220
|
-
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) =>
|
|
3266
|
+
return line.replace(/(?:\\.|[^|\\])+/g, (cell) => cell.split("<br>").map((seg) => seg.replace(/\S(?:.*\S)?/, (t) => _chunkI4BS4BXEcjs.collapseEvenSpacing.call(void 0, t, false))).join("<br>"));
|
|
3221
3267
|
}
|
|
3222
|
-
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access',
|
|
3223
|
-
return mark +
|
|
3268
|
+
const mark = _nullishCoalesce(_optionalChain([/^(?:#{1,6}|-) /, 'access', _293 => _293.exec, 'call', _294 => _294(line), 'optionalAccess', _295 => _295[0]]), () => ( ""));
|
|
3269
|
+
return mark + _chunkI4BS4BXEcjs.collapseEvenSpacing.call(void 0, line.slice(mark.length), false);
|
|
3224
3270
|
}).replace(/\\~\\~/g, "~~").replace(/~~~~/g, "").replace(/<u>\s*<\/u>/g, "").replace(/<(sup|sub)>\s*<\/\1>/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
3225
3271
|
}
|
|
3226
3272
|
function startsWithMarker(line) {
|
|
@@ -3252,7 +3298,7 @@ function mergeKoreanLines(text) {
|
|
|
3252
3298
|
continue;
|
|
3253
3299
|
}
|
|
3254
3300
|
if (/[가-힣·,\-]$/.test(prev) && /^[가-힣(]/.test(curr) && !startsWithMarker(curr) && !isStandaloneHeader(prev) && !startsWithMarker(prev)) {
|
|
3255
|
-
result[result.length - 1] = prev +
|
|
3301
|
+
result[result.length - 1] = prev + _chunkI4BS4BXEcjs.wrapJoiner.call(void 0, prev, curr) + curr;
|
|
3256
3302
|
} else {
|
|
3257
3303
|
result.push(curr);
|
|
3258
3304
|
}
|
|
@@ -3268,7 +3314,7 @@ function applyLinkAnnotations(items, annots) {
|
|
|
3268
3314
|
const wrapped = /* @__PURE__ */ new Set();
|
|
3269
3315
|
for (const a of annots) {
|
|
3270
3316
|
if (a.subtype !== "Link" || !a.url || !a.rect || a.rect.length < 4) continue;
|
|
3271
|
-
const url =
|
|
3317
|
+
const url = _chunkAUWO57EDcjs.sanitizeHref.call(void 0, a.url);
|
|
3272
3318
|
if (!url) continue;
|
|
3273
3319
|
const x1 = Math.min(a.rect[0], a.rect[2]), x2 = Math.max(a.rect[0], a.rect[2]);
|
|
3274
3320
|
const y1 = Math.min(a.rect[1], a.rect[3]), y2 = Math.max(a.rect[1], a.rect[3]);
|
|
@@ -3320,7 +3366,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3320
3366
|
|
|
3321
3367
|
// src/pdf/formula-ocr.ts
|
|
3322
3368
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3323
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3369
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-3TVRNJ66.cjs")));
|
|
3324
3370
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3325
3371
|
await ensureFormulaModels((p) => {
|
|
3326
3372
|
if (p.phase === "download" && p.total) {
|
|
@@ -3511,13 +3557,13 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3511
3557
|
try {
|
|
3512
3558
|
return await Promise.race([
|
|
3513
3559
|
loadingTask.promise.catch((e) => {
|
|
3514
|
-
if (e instanceof Error && e.name === "PasswordException") throw new (0,
|
|
3560
|
+
if (e instanceof Error && e.name === "PasswordException") throw new (0, _chunkAUWO57EDcjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C PDF \uD30C\uC77C\uC785\uB2C8\uB2E4 (PDF \uC5F4\uAE30 \uC554\uD638\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4)");
|
|
3515
3561
|
throw e;
|
|
3516
3562
|
}),
|
|
3517
3563
|
new Promise((_, reject) => {
|
|
3518
3564
|
timer = setTimeout(() => {
|
|
3519
3565
|
loadingTask.destroy();
|
|
3520
|
-
reject(new (0,
|
|
3566
|
+
reject(new (0, _chunkAUWO57EDcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
3521
3567
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
3522
3568
|
})
|
|
3523
3569
|
]);
|
|
@@ -3526,15 +3572,15 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
3526
3572
|
}
|
|
3527
3573
|
}
|
|
3528
3574
|
async function parsePdfDocument(buffer, options) {
|
|
3529
|
-
const formulaBuffer = _optionalChain([options, 'optionalAccess',
|
|
3530
|
-
const ocrOptionError =
|
|
3531
|
-
if (ocrOptionError) throw new (0,
|
|
3532
|
-
const autoOcr = _optionalChain([options, 'optionalAccess',
|
|
3533
|
-
const ocrBuffer = _optionalChain([options, 'optionalAccess',
|
|
3575
|
+
const formulaBuffer = _optionalChain([options, 'optionalAccess', _296 => _296.formulaOcr]) ? buffer : null;
|
|
3576
|
+
const ocrOptionError = _chunkMED2MR6Ocjs.validateOcrOptions.call(void 0, options);
|
|
3577
|
+
if (ocrOptionError) throw new (0, _chunkAUWO57EDcjs.KordocError)(ocrOptionError);
|
|
3578
|
+
const autoOcr = _optionalChain([options, 'optionalAccess', _297 => _297.ocr]) === void 0 && await _chunkI4BS4BXEcjs.ocrModelsCached.call(void 0, _chunkI4BS4BXEcjs.resolveOcrModels.call(void 0, options));
|
|
3579
|
+
const ocrBuffer = _optionalChain([options, 'optionalAccess', _298 => _298.ocr]) || autoOcr ? buffer : null;
|
|
3534
3580
|
const doc = await loadPdfWithTimeout(buffer);
|
|
3535
3581
|
try {
|
|
3536
3582
|
const pageCount = doc.numPages;
|
|
3537
|
-
if (pageCount === 0) throw new (0,
|
|
3583
|
+
if (pageCount === 0) throw new (0, _chunkAUWO57EDcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
3538
3584
|
const metadata = { pageCount, pageMode: "layout" };
|
|
3539
3585
|
await extractPdfMetadata(doc, metadata);
|
|
3540
3586
|
const blocks = [];
|
|
@@ -3543,8 +3589,8 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3543
3589
|
let totalChars = 0;
|
|
3544
3590
|
let totalTextBytes = 0;
|
|
3545
3591
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
3546
|
-
const pageFilter = _optionalChain([options, 'optionalAccess',
|
|
3547
|
-
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess',
|
|
3592
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _299 => _299.pages]) ? _chunkJ55UQC5Hcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
3593
|
+
if (pageCount > MAX_PAGES && (!_optionalChain([options, 'optionalAccess', _300 => _300.pages]) || _chunkJ55UQC5Hcjs.hasRequestedPagesAfter.call(void 0, options.pages, MAX_PAGES, pageCount))) {
|
|
3548
3594
|
warnings.push({ message: `${pageCount}\uCABD \uC911 \uC55E ${MAX_PAGES}\uCABD\uB9CC \uD30C\uC2F1\uD588\uC2B5\uB2C8\uB2E4 (\uCABD \uC218 \uC0C1\uD55C)`, code: "PARTIAL_PARSE" });
|
|
3549
3595
|
}
|
|
3550
3596
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
@@ -3563,10 +3609,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3563
3609
|
const pageImageBlocks = /* @__PURE__ */ new Map();
|
|
3564
3610
|
const carry = {};
|
|
3565
3611
|
const vectorPageOps = /* @__PURE__ */ new Map();
|
|
3566
|
-
const wrapLexicon = new (0,
|
|
3612
|
+
const wrapLexicon = new (0, _chunkI4BS4BXEcjs.WrapLexicon)();
|
|
3567
3613
|
const noteMarks = /* @__PURE__ */ new Map();
|
|
3568
3614
|
const headerContext = [];
|
|
3569
|
-
if (pageFilter && _optionalChain([options, 'optionalAccess',
|
|
3615
|
+
if (pageFilter && _optionalChain([options, 'optionalAccess', _301 => _301.removeHeaderFooter]) !== false && pageFilter.size < effectivePageCount) {
|
|
3570
3616
|
for (const number of selectionContextPages(pageFilter, effectivePageCount)) {
|
|
3571
3617
|
let contextPage;
|
|
3572
3618
|
try {
|
|
@@ -3576,7 +3622,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3576
3622
|
headerContext.push(...marginContextBlocks(content.items, number, contextPage.view));
|
|
3577
3623
|
} catch (e6) {
|
|
3578
3624
|
} finally {
|
|
3579
|
-
_optionalChain([contextPage, 'optionalAccess',
|
|
3625
|
+
_optionalChain([contextPage, 'optionalAccess', _302 => _302.cleanup, 'call', _303 => _303()]);
|
|
3580
3626
|
}
|
|
3581
3627
|
}
|
|
3582
3628
|
}
|
|
@@ -3603,15 +3649,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3603
3649
|
return void 0;
|
|
3604
3650
|
}
|
|
3605
3651
|
};
|
|
3606
|
-
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call',
|
|
3652
|
+
const differencesOf = (loadedName) => _optionalChain([fontObj, 'call', _304 => _304(loadedName), 'optionalAccess', _305 => _305.differences]);
|
|
3607
3653
|
const occluded = occludedTextItems(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3608
3654
|
markTrailingSpaceGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3609
|
-
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call',
|
|
3655
|
+
restoreNamedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, differencesOf, (n) => _optionalChain([fontObj, 'call', _306 => _306(n), 'optionalAccess', _307 => _307.name]));
|
|
3610
3656
|
restoreUnmappedGlyphs(rawItems, rawOps.fnArray, rawOps.argsArray, (n) => fontObj(n));
|
|
3611
3657
|
restoreTrackedSpacing(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3612
3658
|
markSyntheticSpaces(rawItems, rawOps.fnArray, rawOps.argsArray);
|
|
3613
|
-
const items =
|
|
3614
|
-
const filtered =
|
|
3659
|
+
const items = _chunkI4BS4BXEcjs.normalizeItems.call(void 0, occluded.size ? rawItems.filter((it) => !occluded.has(it)) : rawItems);
|
|
3660
|
+
const filtered = _chunkI4BS4BXEcjs.filterHiddenText.call(void 0, items, pageW, pageH, viewX1, viewY1);
|
|
3615
3661
|
const joined = joinVerticalColumns(filtered.visible);
|
|
3616
3662
|
const visible = dropTabLeaderDots(joined);
|
|
3617
3663
|
const hiddenCount = filtered.hiddenCount + occluded.size;
|
|
@@ -3635,27 +3681,27 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3635
3681
|
fnArray: [_pdfmjs.OPS.transform, ...rawOps.fnArray],
|
|
3636
3682
|
argsArray: [[1, 0, 0, 1, -viewX1, -viewY1], ...rawOps.argsArray]
|
|
3637
3683
|
} : rawOps;
|
|
3638
|
-
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call',
|
|
3684
|
+
remapSymbolFontItems(visible, (loadedName) => _optionalChain([fontObj, 'call', _308 => _308(loadedName), 'optionalAccess', _309 => _309.name]));
|
|
3639
3685
|
remapControlGlyphs(visible, differencesOf);
|
|
3640
|
-
await
|
|
3686
|
+
await _chunkI4BS4BXEcjs.restoreImageBullets.call(void 0, visible, page, opList.fnArray, opList.argsArray, imageBulletShapes);
|
|
3641
3687
|
const faces = /* @__PURE__ */ new Map();
|
|
3642
3688
|
for (const it of visible) {
|
|
3643
3689
|
if (!it.fontName) continue;
|
|
3644
3690
|
let face = faces.get(it.fontName);
|
|
3645
3691
|
if (face === void 0) {
|
|
3646
3692
|
const obj = fontObj(it.fontName);
|
|
3647
|
-
face = _optionalChain([obj, 'optionalAccess',
|
|
3693
|
+
face = _optionalChain([obj, 'optionalAccess', _310 => _310.isType3Font]) && /^[A-Z]{6}\+./.test(_nullishCoalesce(obj.name, () => ( ""))) && obj.name.slice(7) || it.fontName;
|
|
3648
3694
|
faces.set(it.fontName, face);
|
|
3649
3695
|
}
|
|
3650
3696
|
it.fontName = face;
|
|
3651
|
-
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call',
|
|
3697
|
+
if (!faceNames.has(face)) faceNames.set(face, (_nullishCoalesce(_optionalChain([fontObj, 'call', _311 => _311(face), 'optionalAccess', _312 => _312.name]), () => ( ""))).replace(/^[A-Z]{6}\+/, ""));
|
|
3652
3698
|
}
|
|
3653
|
-
for (const it of visible) if (it.text.includes("$")) it.text =
|
|
3654
|
-
for (const it of visible) if (it.text.includes("<")) it.text =
|
|
3699
|
+
for (const it of visible) if (it.text.includes("$")) it.text = _chunkMED2MR6Ocjs.escapeLiteralDollar.call(void 0, it.text);
|
|
3700
|
+
for (const it of visible) if (it.text.includes("<")) it.text = _chunkMED2MR6Ocjs.escapeLiteralTags.call(void 0, it.text);
|
|
3655
3701
|
wrapEquationRuns(visible, (face) => faceNames.get(face));
|
|
3656
3702
|
const pageArea = pageW * pageH;
|
|
3657
3703
|
if (pageArea > 0) {
|
|
3658
|
-
const imageRegions =
|
|
3704
|
+
const imageRegions = _chunkI4BS4BXEcjs.extractImageRegions.call(void 0, opList.fnArray, opList.argsArray);
|
|
3659
3705
|
let uncovered = 0;
|
|
3660
3706
|
for (const r of imageRegions) {
|
|
3661
3707
|
const area = (r.x2 - r.x1) * (r.y2 - r.y1);
|
|
@@ -3681,15 +3727,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3681
3727
|
if (uncovered > 0) skippedImagePages.set(i, uncovered);
|
|
3682
3728
|
}
|
|
3683
3729
|
const marks = superscriptNoteMarks(visible);
|
|
3684
|
-
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(
|
|
3730
|
+
if (marks.length) noteMarks.set(i, { marks, seps: footnoteSeparators(_chunkI4BS4BXEcjs.extractLines.call(void 0, opList.fnArray, opList.argsArray).horizontals, pageW, pageH) });
|
|
3685
3731
|
const stamp = marginStamp(visible);
|
|
3686
3732
|
const flow = stamp.length ? visible.filter((it) => !stamp.includes(it)) : visible;
|
|
3687
|
-
const rightArrows = _optionalChain([options, 'optionalAccess',
|
|
3688
|
-
const pageBlocks = orderTwoUpPage(
|
|
3733
|
+
const rightArrows = _optionalChain([options, 'optionalAccess', _313 => _313.tables]) !== false ? await _chunkI4BS4BXEcjs.detectRightArrowRegions.call(void 0, page, opList.fnArray, opList.argsArray, imageArrowDirections) : [];
|
|
3734
|
+
const pageBlocks = orderTwoUpPage(_chunkI4BS4BXEcjs.extractPageBlocksWithLines.call(void 0, flow, i, opList, pageW, pageH, void 0, _optionalChain([options, 'optionalAccess', _314 => _314.tables]) !== false, carry, wrapLexicon, rightArrows), pageW, pageH);
|
|
3689
3735
|
if (stamp.length) pageBlocks.unshift({ type: "paragraph", text: [...stamp].sort((a, b) => a.y - b.y).map((it) => it.text).join(" "), pageNumber: i });
|
|
3690
3736
|
for (const b of pageBlocks) blocks.push(b);
|
|
3691
3737
|
try {
|
|
3692
|
-
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess',
|
|
3738
|
+
const { blocks: imgBlocks, images: pageImages } = await extractPageImages(page, opList.fnArray, opList.argsArray, i, imageState, warnings, _optionalChain([options, 'optionalAccess', _315 => _315.images]) !== false);
|
|
3693
3739
|
if (imgBlocks.length > 0) pageImageBlocks.set(i, imgBlocks);
|
|
3694
3740
|
extractedImages.push(...pageImages);
|
|
3695
3741
|
} catch (e9) {
|
|
@@ -3708,17 +3754,17 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3708
3754
|
const vector = scanVectorGlyphs(opList.fnArray, opList.argsArray, visible);
|
|
3709
3755
|
const quality = computePageQuality(i, pageText, vector.glyphs);
|
|
3710
3756
|
pageQuality.push(quality);
|
|
3711
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3757
|
+
if (_optionalChain([options, 'optionalAccess', _316 => _316.ocr]) && quality.ocrReason === "vector_text" && page.rotate % 360 === 0 && page.view[0] === 0 && page.view[1] === 0) {
|
|
3712
3758
|
vectorPageOps.set(i, ocrVectorOps(opList, vector.paths));
|
|
3713
3759
|
}
|
|
3714
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
3760
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkAUWO57EDcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
3715
3761
|
parsedPages++;
|
|
3716
|
-
_optionalChain([options, 'optionalAccess',
|
|
3762
|
+
_optionalChain([options, 'optionalAccess', _317 => _317.onProgress, 'optionalCall', _318 => _318(parsedPages, totalTarget)]);
|
|
3717
3763
|
} catch (pageErr) {
|
|
3718
|
-
if (pageErr instanceof
|
|
3764
|
+
if (pageErr instanceof _chunkAUWO57EDcjs.KordocError) throw pageErr;
|
|
3719
3765
|
warnings.push({ page: i, message: `\uD398\uC774\uC9C0 ${i} \uD30C\uC2F1 \uC2E4\uD328: ${pageErr instanceof Error ? pageErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3720
3766
|
} finally {
|
|
3721
|
-
_optionalChain([loadedPage, 'optionalAccess',
|
|
3767
|
+
_optionalChain([loadedPage, 'optionalAccess', _319 => _319.cleanup, 'call', _320 => _320()]);
|
|
3722
3768
|
}
|
|
3723
3769
|
if (loadedFonts.size > FONT_CACHE_LIMIT) {
|
|
3724
3770
|
await doc.cleanup();
|
|
@@ -3726,14 +3772,14 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3726
3772
|
}
|
|
3727
3773
|
}
|
|
3728
3774
|
const parsedPageCount = parsedPages || (pageFilter ? pageFilter.size : effectivePageCount);
|
|
3729
|
-
const isImageBased = _optionalChain([pageFilter, 'optionalAccess',
|
|
3775
|
+
const isImageBased = _optionalChain([pageFilter, 'optionalAccess', _321 => _321.size]) !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
3730
3776
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
3731
3777
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
3732
|
-
const ocrRegions = _optionalChain([options, 'optionalAccess',
|
|
3778
|
+
const ocrRegions = _optionalChain([options, 'optionalAccess', _322 => _322.ocr]) === true || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, _optionalChain([options, 'optionalAccess', _323 => _323.ocr]) === true) : /* @__PURE__ */ new Map();
|
|
3733
3779
|
if (ocrBuffer) {
|
|
3734
3780
|
const inScope = (p) => !pageFilter || pageFilter.has(p);
|
|
3735
3781
|
const targets = /* @__PURE__ */ new Set();
|
|
3736
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3782
|
+
if (_optionalChain([options, 'optionalAccess', _324 => _324.ocr]) === "force" || isImageBased) {
|
|
3737
3783
|
for (let i = 1; i <= effectivePageCount; i++) if (inScope(i)) targets.add(i);
|
|
3738
3784
|
} else {
|
|
3739
3785
|
for (const pq of pageQuality) {
|
|
@@ -3746,25 +3792,25 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3746
3792
|
}
|
|
3747
3793
|
if (targets.size > 0) {
|
|
3748
3794
|
try {
|
|
3749
|
-
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3750
|
-
const mode = typeof _optionalChain([options, 'optionalAccess',
|
|
3751
|
-
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess',
|
|
3752
|
-
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-
|
|
3753
|
-
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess',
|
|
3754
|
-
for (const obs of ocrPageBlocks.values())
|
|
3795
|
+
const { runPdfOcr } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-6UXBIQE6.cjs")));
|
|
3796
|
+
const mode = typeof _optionalChain([options, 'optionalAccess', _325 => _325.ocr]) === "function" ? options.ocr : "builtin";
|
|
3797
|
+
const regionPages = new Map([...ocrRegions].filter(([p]) => _optionalChain([options, 'optionalAccess', _326 => _326.ocr]) !== "force" && !isImageBased && !_optionalChain([pageQuality, 'access', _327 => _327.find, 'call', _328 => _328((q) => q.page === p), 'optionalAccess', _329 => _329.needsOcr])));
|
|
3798
|
+
const { builtinOcrConfig } = await Promise.resolve().then(() => _interopRequireWildcard(require("./pdf-ocr-6UXBIQE6.cjs")));
|
|
3799
|
+
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, _optionalChain([options, 'optionalAccess', _330 => _330.onProgress]), _optionalChain([options, 'optionalAccess', _331 => _331.tables]) !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut);
|
|
3800
|
+
for (const obs of ocrPageBlocks.values()) _chunkMED2MR6Ocjs.stripScriptTags.call(void 0, { blocks: obs });
|
|
3755
3801
|
if (ocrPageBlocks.size > 0) {
|
|
3756
3802
|
const replacePages = /* @__PURE__ */ new Set();
|
|
3757
3803
|
for (const [p, obs] of ocrPageBlocks) {
|
|
3758
|
-
const needsOcr = _optionalChain([pageQuality, 'access',
|
|
3759
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3804
|
+
const needsOcr = _optionalChain([pageQuality, 'access', _332 => _332.find, 'call', _333 => _333((q) => q.page === p), 'optionalAccess', _334 => _334.needsOcr]);
|
|
3805
|
+
if (_optionalChain([options, 'optionalAccess', _335 => _335.ocr]) === "force" || isImageBased || needsOcr) {
|
|
3760
3806
|
replacePages.add(p);
|
|
3761
3807
|
ocrDone.add(p);
|
|
3762
3808
|
continue;
|
|
3763
3809
|
}
|
|
3764
3810
|
const regions = ocrRegions.get(p);
|
|
3765
|
-
if (!regions ||
|
|
3811
|
+
if (!regions || _chunkI4BS4BXEcjs.mergeOcrImageRegions.call(void 0, blocks, p, regions, obs) === 0) continue;
|
|
3766
3812
|
ocrDone.add(p);
|
|
3767
|
-
if (_optionalChain([pageImageBlocks, 'access',
|
|
3813
|
+
if (_optionalChain([pageImageBlocks, 'access', _336 => _336.get, 'call', _337 => _337(p), 'optionalAccess', _338 => _338.length]) === 1) pageImageBlocks.delete(p);
|
|
3768
3814
|
}
|
|
3769
3815
|
if (replacePages.size) {
|
|
3770
3816
|
const merged = blocks.filter((b) => !(b.pageNumber && replacePages.has(b.pageNumber)));
|
|
@@ -3814,18 +3860,18 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3814
3860
|
warnings.push({ page, message: `${count}\uAC1C \uC774\uBBF8\uC9C0 \uC601\uC5ED\uC5D0 \uCD94\uCD9C \uAC00\uB2A5\uD55C \uD14D\uC2A4\uD2B8 \uC5C6\uC74C (\uADF8\uB9BC/\uCC28\uD2B8/\uB3C4\uC7A5 \uB0B4\uC6A9 \uB204\uB77D \uAC00\uB2A5 \u2014 \uADF8\uB9BC \uC18D \uAE00\uC740 ocr: true / CLI --ocr \uB85C \uC77D\uC2B5\uB2C8\uB2E4)`, code: "SKIPPED_IMAGE" });
|
|
3815
3861
|
}
|
|
3816
3862
|
}
|
|
3817
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3818
|
-
const removed =
|
|
3819
|
-
const running =
|
|
3863
|
+
if (_optionalChain([options, 'optionalAccess', _339 => _339.removeHeaderFooter]) !== false && (parsedPageCount >= 3 || headerContext.length)) {
|
|
3864
|
+
const removed = _chunkI4BS4BXEcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, false, headerContext);
|
|
3865
|
+
const running = _chunkI4BS4BXEcjs.runningLinePatterns.call(void 0, removed.map((ri) => blocks[ri]), pageHeights);
|
|
3820
3866
|
for (let ri = removed.length - 1; ri >= 0; ri--) {
|
|
3821
3867
|
blocks.splice(removed[ri], 1);
|
|
3822
3868
|
}
|
|
3823
|
-
const stripped =
|
|
3869
|
+
const stripped = _chunkI4BS4BXEcjs.stripAbsorbedRunningLines.call(void 0, blocks, pageHeights, running);
|
|
3824
3870
|
if (stripped !== blocks) {
|
|
3825
3871
|
blocks.length = 0;
|
|
3826
3872
|
blocks.push(...stripped);
|
|
3827
3873
|
}
|
|
3828
|
-
const kept =
|
|
3874
|
+
const kept = _chunkI4BS4BXEcjs.removeSideTabs.call(void 0, blocks, pageWidths);
|
|
3829
3875
|
if (kept !== blocks) {
|
|
3830
3876
|
blocks.length = 0;
|
|
3831
3877
|
blocks.push(...kept);
|
|
@@ -3833,15 +3879,15 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3833
3879
|
}
|
|
3834
3880
|
mergeContinuedCells(blocks, pageHeights);
|
|
3835
3881
|
mergeCrossPageTables(blocks, pageHeights, wrapLexicon);
|
|
3836
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3837
|
-
const boxes =
|
|
3882
|
+
if (_optionalChain([options, 'optionalAccess', _340 => _340.removeHeaderFooter]) !== false && parsedPageCount >= 3) {
|
|
3883
|
+
const boxes = _chunkI4BS4BXEcjs.removeHeaderFooterBlocks.call(void 0, blocks, pageHeights, warnings, noteMarks, true);
|
|
3838
3884
|
for (let ri = boxes.length - 1; ri >= 0; ri--) blocks.splice(boxes[ri], 1);
|
|
3839
3885
|
}
|
|
3840
3886
|
splitContactTables(blocks);
|
|
3841
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
3842
|
-
|
|
3887
|
+
if (!_optionalChain([options, 'optionalAccess', _341 => _341.keepTrailingEmptyCols])) _chunkI4BS4BXEcjs.trimTrailingEmptyTableCols.call(void 0, blocks);
|
|
3888
|
+
_chunkI4BS4BXEcjs.joinPageBreakWraps.call(void 0, blocks, wrapLexicon);
|
|
3843
3889
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
3844
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3890
|
+
if (_optionalChain([options, 'optionalAccess', _342 => _342.formulaOcr]) && formulaBuffer) {
|
|
3845
3891
|
try {
|
|
3846
3892
|
await applyFormulaOcr(formulaBuffer, blocks, pageFilter, effectivePageCount, warnings, options.onProgress);
|
|
3847
3893
|
} catch (e) {
|
|
@@ -3851,54 +3897,54 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3851
3897
|
});
|
|
3852
3898
|
}
|
|
3853
3899
|
}
|
|
3854
|
-
const medianFontSize =
|
|
3900
|
+
const medianFontSize = _chunkI4BS4BXEcjs.computeMedianFontSizeFromFreq.call(void 0, fontSizeFreq);
|
|
3855
3901
|
if (medianFontSize > 0) {
|
|
3856
|
-
|
|
3857
|
-
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3902
|
+
_chunkI4BS4BXEcjs.detectHeadings.call(void 0, blocks, medianFontSize);
|
|
3903
|
+
}
|
|
3904
|
+
_chunkI4BS4BXEcjs.detectDocumentStyleHeadings.call(void 0, blocks);
|
|
3905
|
+
_chunkI4BS4BXEcjs.detectTypographyHeadings.call(void 0, blocks);
|
|
3906
|
+
_chunkI4BS4BXEcjs.detectSiblingStyleHeadings.call(void 0, blocks);
|
|
3907
|
+
_chunkI4BS4BXEcjs.detectRepeatedPageLabels.call(void 0, blocks);
|
|
3908
|
+
_chunkI4BS4BXEcjs.detectPageLeadHeadings.call(void 0, blocks);
|
|
3909
|
+
_chunkI4BS4BXEcjs.mergeStackedHeadingLines.call(void 0, blocks, medianFontSize);
|
|
3910
|
+
_chunkI4BS4BXEcjs.refineDocumentStyleHeadings.call(void 0, blocks);
|
|
3911
|
+
_chunkI4BS4BXEcjs.detectMarkerHeadings.call(void 0, blocks);
|
|
3866
3912
|
demoteNonHeadingRoles(blocks, pageHeights, faceNames);
|
|
3867
|
-
|
|
3868
|
-
|
|
3913
|
+
_chunkI4BS4BXEcjs.detectTableCaptions.call(void 0, blocks);
|
|
3914
|
+
_chunkI4BS4BXEcjs.detectKoreanListBlocks.call(void 0, blocks);
|
|
3869
3915
|
sanitizeBlockControlChars(blocks);
|
|
3870
3916
|
let outBlocks = splitSingleCellTables(blocks);
|
|
3871
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3917
|
+
if (_optionalChain([options, 'optionalAccess', _343 => _343.layoutTables]) !== "keep") {
|
|
3872
3918
|
blocks.length = 0;
|
|
3873
3919
|
for (const block of outBlocks) blocks.push(block);
|
|
3874
3920
|
}
|
|
3875
3921
|
outBlocks = inlineFootnotes(outBlocks, noteMarks);
|
|
3876
3922
|
outBlocks = relocateEndnotes(outBlocks);
|
|
3877
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3923
|
+
if (_optionalChain([options, 'optionalAccess', _344 => _344.removeHeaderFooter]) !== false) outBlocks = outBlocks.filter((b) => {
|
|
3878
3924
|
if (b.type !== "paragraph" || !/^\s*\d{1,4}\s*$/.test(_nullishCoalesce(b.text, () => ( "")))) return true;
|
|
3879
3925
|
const h = pageHeights.get(_nullishCoalesce(b.pageNumber, () => ( 0)));
|
|
3880
3926
|
if (!b.bbox || !h) return false;
|
|
3881
3927
|
return b.bbox.y > h * 0.1 && b.bbox.y + b.bbox.height < h * 0.9;
|
|
3882
3928
|
});
|
|
3883
3929
|
joinLatinCellWraps(outBlocks);
|
|
3884
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3930
|
+
if (_optionalChain([options, 'optionalAccess', _345 => _345.layoutTables]) !== "keep") {
|
|
3885
3931
|
const hancom = await isHancomPdf(doc);
|
|
3886
3932
|
const shown = /* @__PURE__ */ new Map();
|
|
3887
3933
|
const markContent = (bs) => {
|
|
3888
3934
|
for (const b of _nullishCoalesce(bs, () => ( []))) if (b.table) for (const row of b.table.cells) for (const c of row) {
|
|
3889
|
-
if (
|
|
3890
|
-
const lines =
|
|
3891
|
-
if (lines)
|
|
3935
|
+
if (_chunkI4BS4BXEcjs.IMAGE_CELLS.has(c)) _chunkMED2MR6Ocjs.CONTENT_CELLS.add(c);
|
|
3936
|
+
const lines = _chunkI4BS4BXEcjs.CELL_LINES.get(c);
|
|
3937
|
+
if (lines) _chunkMED2MR6Ocjs.CELL_BASELINES.set(c, lines.map((l) => l.y));
|
|
3892
3938
|
markContent(c.blocks);
|
|
3893
3939
|
}
|
|
3894
3940
|
};
|
|
3895
3941
|
const visual = (bs) => bs.flatMap((b) => {
|
|
3896
3942
|
if (b.type !== "table") return [b];
|
|
3897
|
-
if (!hancom && b.table &&
|
|
3943
|
+
if (!hancom && b.table && _chunkI4BS4BXEcjs.CLIP_TABLES.has(b.table)) return [b];
|
|
3898
3944
|
let v = shown.get(b);
|
|
3899
3945
|
if (!v) {
|
|
3900
3946
|
markContent([b]);
|
|
3901
|
-
shown.set(b, v =
|
|
3947
|
+
shown.set(b, v = _chunkMED2MR6Ocjs.unframeLayoutTables.call(void 0, [b], !!_optionalChain([options, 'optionalAccess', _346 => _346.keepTrailingEmptyCols])));
|
|
3902
3948
|
}
|
|
3903
3949
|
return v;
|
|
3904
3950
|
});
|
|
@@ -3907,13 +3953,13 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3907
3953
|
blocks.length = 0;
|
|
3908
3954
|
for (const b of kept) blocks.push(b);
|
|
3909
3955
|
}
|
|
3910
|
-
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(
|
|
3911
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
3956
|
+
const finishMarkdown = (bs) => mergeLinkRuns(cleanPdfText(_chunkMED2MR6Ocjs.blocksToMarkdown.call(void 0, bs, { tableFormat: _optionalChain([options, 'optionalAccess', _347 => _347.tableFormat]) }), { keepLoneNumbers: true }));
|
|
3957
|
+
if (_optionalChain([options, 'optionalAccess', _348 => _348.tableFormat]) === "gfm") _chunkMED2MR6Ocjs.assignTableIds.call(void 0, blocks);
|
|
3912
3958
|
let markdown = finishMarkdown(outBlocks);
|
|
3913
3959
|
const outline = collectPdfOutline(outBlocks);
|
|
3914
3960
|
return {
|
|
3915
3961
|
markdown,
|
|
3916
|
-
pages:
|
|
3962
|
+
pages: _chunkEKKZNKJDcjs.blocksToPages.call(void 0, splitPageTables(_chunkI4BS4BXEcjs.splitPageBreakWraps.call(void 0, outBlocks)), finishMarkdown),
|
|
3917
3963
|
blocks,
|
|
3918
3964
|
metadata,
|
|
3919
3965
|
outline: outline.length > 0 ? outline : void 0,
|
|
@@ -3922,7 +3968,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3922
3968
|
pageQuality,
|
|
3923
3969
|
qualitySummary: summarizeDocumentQuality(pageQuality),
|
|
3924
3970
|
images: extractedImages.length > 0 ? extractedImages : void 0,
|
|
3925
|
-
..._optionalChain([options, 'optionalAccess',
|
|
3971
|
+
..._optionalChain([options, 'optionalAccess', _349 => _349.ocrLines]) ? { ocrLines: [...ocrLinesOut.values()].sort((a, b) => a.pageNumber - b.pageNumber) } : {}
|
|
3926
3972
|
};
|
|
3927
3973
|
} finally {
|
|
3928
3974
|
await doc.destroy().catch(() => {
|
|
@@ -3932,7 +3978,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
3932
3978
|
async function extractPdfMetadata(doc, metadata) {
|
|
3933
3979
|
try {
|
|
3934
3980
|
const result = await doc.getMetadata();
|
|
3935
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
3981
|
+
if (!_optionalChain([result, 'optionalAccess', _350 => _350.info])) return;
|
|
3936
3982
|
const info = result.info;
|
|
3937
3983
|
if (typeof info.Title === "string" && info.Title.trim()) metadata.title = info.Title.trim();
|
|
3938
3984
|
if (typeof info.Author === "string" && info.Author.trim()) metadata.author = info.Author.trim();
|
|
@@ -3948,8 +3994,8 @@ async function extractPdfMetadata(doc, metadata) {
|
|
|
3948
3994
|
}
|
|
3949
3995
|
async function isHancomPdf(doc) {
|
|
3950
3996
|
try {
|
|
3951
|
-
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async
|
|
3952
|
-
return [_optionalChain([info, 'optionalAccess',
|
|
3997
|
+
const info = await _asyncOptionalChain([(await doc.getMetadata()), 'optionalAccess', async _351 => _351.info]);
|
|
3998
|
+
return [_optionalChain([info, 'optionalAccess', _352 => _352.Producer]), _optionalChain([info, 'optionalAccess', _353 => _353.Creator])].some((v) => typeof v === "string" && /^\s*(?:hancom\b|hwp\b)/i.test(v));
|
|
3953
3999
|
} catch (e11) {
|
|
3954
4000
|
return false;
|
|
3955
4001
|
}
|
|
@@ -3993,5 +4039,5 @@ function marginStamp(items) {
|
|
|
3993
4039
|
|
|
3994
4040
|
|
|
3995
4041
|
|
|
3996
|
-
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks =
|
|
3997
|
-
//# sourceMappingURL=parser-
|
|
4042
|
+
exports.PDFJS_DOCUMENT_OPTIONS = PDFJS_DOCUMENT_OPTIONS; exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = _chunkI4BS4BXEcjs.detectKoreanListBlocks; exports.detectTableCaptions = _chunkI4BS4BXEcjs.detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.ocrImageRegions = ocrImageRegions; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = _chunkI4BS4BXEcjs.removeHeaderFooterBlocks;
|
|
4043
|
+
//# sourceMappingURL=parser-OKAQRZKM.cjs.map
|