@effortlessmotion/pdf-to-md 0.1.0
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/LICENSE +21 -0
- package/README.md +157 -0
- package/bin/cli.js +9 -0
- package/dist/cjs/analyze.d.cts +35 -0
- package/dist/cjs/analyze.d.ts +35 -0
- package/dist/cjs/analyze.js +620 -0
- package/dist/cjs/analyze.js.map +1 -0
- package/dist/cjs/audit.d.cts +38 -0
- package/dist/cjs/audit.d.ts +38 -0
- package/dist/cjs/audit.js +252 -0
- package/dist/cjs/audit.js.map +1 -0
- package/dist/cjs/cli/audit.d.cts +3 -0
- package/dist/cjs/cli/audit.d.ts +3 -0
- package/dist/cjs/cli/audit.js +269 -0
- package/dist/cjs/cli/audit.js.map +1 -0
- package/dist/cjs/cli/extract.d.cts +3 -0
- package/dist/cjs/cli/extract.d.ts +3 -0
- package/dist/cjs/cli/extract.js +704 -0
- package/dist/cjs/cli/extract.js.map +1 -0
- package/dist/cjs/cli/index.d.cts +5 -0
- package/dist/cjs/cli/index.d.ts +5 -0
- package/dist/cjs/cli/index.js +58 -0
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/cli/render.d.cts +3 -0
- package/dist/cjs/cli/render.d.ts +3 -0
- package/dist/cjs/cli/render.js +361 -0
- package/dist/cjs/cli/render.js.map +1 -0
- package/dist/cjs/cli/types.d.cts +10 -0
- package/dist/cjs/cli/types.d.ts +10 -0
- package/dist/cjs/cli/types.js +7 -0
- package/dist/cjs/cli/types.js.map +1 -0
- package/dist/cjs/cli.d.cts +2 -0
- package/dist/cjs/cli.d.ts +2 -0
- package/dist/cjs/cli.js +345 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/collect.d.cts +6 -0
- package/dist/cjs/collect.d.ts +6 -0
- package/dist/cjs/collect.js +370 -0
- package/dist/cjs/collect.js.map +1 -0
- package/dist/cjs/dict.d.cts +8 -0
- package/dist/cjs/dict.d.ts +8 -0
- package/dist/cjs/dict.js +55 -0
- package/dist/cjs/dict.js.map +1 -0
- package/dist/cjs/emit.d.cts +27 -0
- package/dist/cjs/emit.d.ts +27 -0
- package/dist/cjs/emit.js +187 -0
- package/dist/cjs/emit.js.map +1 -0
- package/dist/cjs/engines/tesseract.d.cts +30 -0
- package/dist/cjs/engines/tesseract.d.ts +30 -0
- package/dist/cjs/engines/tesseract.js +650 -0
- package/dist/cjs/engines/tesseract.js.map +1 -0
- package/dist/cjs/errors.d.cts +21 -0
- package/dist/cjs/errors.d.ts +21 -0
- package/dist/cjs/errors.js +124 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/extract.d.cts +88 -0
- package/dist/cjs/extract.d.ts +88 -0
- package/dist/cjs/extract.js +436 -0
- package/dist/cjs/extract.js.map +1 -0
- package/dist/cjs/geometry.d.cts +63 -0
- package/dist/cjs/geometry.d.ts +63 -0
- package/dist/cjs/geometry.js +521 -0
- package/dist/cjs/geometry.js.map +1 -0
- package/dist/cjs/index.d.cts +15 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lines.d.cts +3 -0
- package/dist/cjs/lines.d.ts +3 -0
- package/dist/cjs/lines.js +181 -0
- package/dist/cjs/lines.js.map +1 -0
- package/dist/cjs/markdown.d.cts +2 -0
- package/dist/cjs/markdown.d.ts +2 -0
- package/dist/cjs/markdown.js +222 -0
- package/dist/cjs/markdown.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/page-marker.d.cts +16 -0
- package/dist/cjs/page-marker.d.ts +16 -0
- package/dist/cjs/page-marker.js +85 -0
- package/dist/cjs/page-marker.js.map +1 -0
- package/dist/cjs/pdf-open.d.cts +12 -0
- package/dist/cjs/pdf-open.d.ts +12 -0
- package/dist/cjs/pdf-open.js +257 -0
- package/dist/cjs/pdf-open.js.map +1 -0
- package/dist/cjs/raster.d.cts +26 -0
- package/dist/cjs/raster.d.ts +26 -0
- package/dist/cjs/raster.js +262 -0
- package/dist/cjs/raster.js.map +1 -0
- package/dist/cjs/render-analysis.d.cts +25 -0
- package/dist/cjs/render-analysis.d.ts +25 -0
- package/dist/cjs/render-analysis.js +319 -0
- package/dist/cjs/render-analysis.js.map +1 -0
- package/dist/cjs/report.d.cts +12 -0
- package/dist/cjs/report.d.ts +12 -0
- package/dist/cjs/report.js +392 -0
- package/dist/cjs/report.js.map +1 -0
- package/dist/cjs/resolve.d.cts +1 -0
- package/dist/cjs/resolve.d.ts +1 -0
- package/dist/cjs/resolve.js +18 -0
- package/dist/cjs/resolve.js.map +1 -0
- package/dist/cjs/types.d.cts +171 -0
- package/dist/cjs/types.d.ts +171 -0
- package/dist/cjs/types.js +9 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/validate.d.cts +14 -0
- package/dist/cjs/validate.d.ts +14 -0
- package/dist/cjs/validate.js +96 -0
- package/dist/cjs/validate.js.map +1 -0
- package/dist/esm/analyze.d.ts +35 -0
- package/dist/esm/analyze.js +270 -0
- package/dist/esm/analyze.js.map +1 -0
- package/dist/esm/audit.d.ts +38 -0
- package/dist/esm/audit.js +113 -0
- package/dist/esm/audit.js.map +1 -0
- package/dist/esm/cli/audit.d.ts +3 -0
- package/dist/esm/cli/audit.js +20 -0
- package/dist/esm/cli/audit.js.map +1 -0
- package/dist/esm/cli/extract.d.ts +3 -0
- package/dist/esm/cli/extract.js +313 -0
- package/dist/esm/cli/extract.js.map +1 -0
- package/dist/esm/cli/index.d.ts +5 -0
- package/dist/esm/cli/index.js +7 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/render.d.ts +3 -0
- package/dist/esm/cli/render.js +77 -0
- package/dist/esm/cli/render.js.map +1 -0
- package/dist/esm/cli/types.d.ts +10 -0
- package/dist/esm/cli/types.js +3 -0
- package/dist/esm/cli/types.js.map +1 -0
- package/dist/esm/cli.d.ts +2 -0
- package/dist/esm/cli.js +90 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/collect.d.ts +6 -0
- package/dist/esm/collect.js +80 -0
- package/dist/esm/collect.js.map +1 -0
- package/dist/esm/dict.d.ts +8 -0
- package/dist/esm/dict.js +28 -0
- package/dist/esm/dict.js.map +1 -0
- package/dist/esm/emit.d.ts +27 -0
- package/dist/esm/emit.js +131 -0
- package/dist/esm/emit.js.map +1 -0
- package/dist/esm/engines/tesseract.d.ts +30 -0
- package/dist/esm/engines/tesseract.js +190 -0
- package/dist/esm/engines/tesseract.js.map +1 -0
- package/dist/esm/errors.d.ts +21 -0
- package/dist/esm/errors.js +9 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/extract.d.ts +88 -0
- package/dist/esm/extract.js +147 -0
- package/dist/esm/extract.js.map +1 -0
- package/dist/esm/geometry.d.ts +63 -0
- package/dist/esm/geometry.js +279 -0
- package/dist/esm/geometry.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lines.d.ts +3 -0
- package/dist/esm/lines.js +67 -0
- package/dist/esm/lines.js.map +1 -0
- package/dist/esm/markdown.d.ts +2 -0
- package/dist/esm/markdown.js +153 -0
- package/dist/esm/markdown.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/page-marker.d.ts +16 -0
- package/dist/esm/page-marker.js +40 -0
- package/dist/esm/page-marker.js.map +1 -0
- package/dist/esm/pdf-open.d.ts +12 -0
- package/dist/esm/pdf-open.js +61 -0
- package/dist/esm/pdf-open.js.map +1 -0
- package/dist/esm/raster.d.ts +26 -0
- package/dist/esm/raster.js +60 -0
- package/dist/esm/raster.js.map +1 -0
- package/dist/esm/render-analysis.d.ts +25 -0
- package/dist/esm/render-analysis.js +115 -0
- package/dist/esm/render-analysis.js.map +1 -0
- package/dist/esm/report.d.ts +12 -0
- package/dist/esm/report.js +182 -0
- package/dist/esm/report.js.map +1 -0
- package/dist/esm/resolve.d.ts +1 -0
- package/dist/esm/resolve.js +7 -0
- package/dist/esm/resolve.js.map +1 -0
- package/dist/esm/types.d.ts +171 -0
- package/dist/esm/types.js +6 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/validate.d.ts +14 -0
- package/dist/esm/validate.js +56 -0
- package/dist/esm/validate.js.map +1 -0
- package/package.json +67 -0
- package/skills/pdf-to-md/SKILL.md +102 -0
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
// analyze() plus the OCR-path core (buildOcrAnalysisPages) that extractOcr
|
|
2
|
+
// shares with it — same buildPageOCR -> emitPage -> renderPagesToMarkdown pipeline, so OCR-path markdown is byte-identical by construction, not two implementations kept in sync by hand. The TEXT path is NOT shared this way (see analyzeText).
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
get analyze () {
|
|
15
|
+
return analyze;
|
|
16
|
+
},
|
|
17
|
+
get buildOcrAnalysisPages () {
|
|
18
|
+
return buildOcrAnalysisPages;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var _collectts = require("./collect.js");
|
|
22
|
+
var _dictts = require("./dict.js");
|
|
23
|
+
var _emitts = require("./emit.js");
|
|
24
|
+
var _geometryts = require("./geometry.js");
|
|
25
|
+
var _linests = require("./lines.js");
|
|
26
|
+
var _markdownts = require("./markdown.js");
|
|
27
|
+
var _renderanalysists = require("./render-analysis.js");
|
|
28
|
+
var _reportts = require("./report.js");
|
|
29
|
+
var _validatets = require("./validate.js");
|
|
30
|
+
function _array_like_to_array(arr, len) {
|
|
31
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
32
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
33
|
+
return arr2;
|
|
34
|
+
}
|
|
35
|
+
function _array_without_holes(arr) {
|
|
36
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
37
|
+
}
|
|
38
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
39
|
+
try {
|
|
40
|
+
var info = gen[key](arg);
|
|
41
|
+
var value = info.value;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
reject(error);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (info.done) resolve(value);
|
|
47
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
48
|
+
}
|
|
49
|
+
function _async_to_generator(fn) {
|
|
50
|
+
return function() {
|
|
51
|
+
var self = this, args = arguments;
|
|
52
|
+
return new Promise(function(resolve, reject) {
|
|
53
|
+
var gen = fn.apply(self, args);
|
|
54
|
+
function _next(value) {
|
|
55
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
56
|
+
}
|
|
57
|
+
function _throw(err) {
|
|
58
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
59
|
+
}
|
|
60
|
+
_next(undefined);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function _define_property(obj, key, value) {
|
|
65
|
+
if (key in obj) {
|
|
66
|
+
Object.defineProperty(obj, key, {
|
|
67
|
+
value: value,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true
|
|
71
|
+
});
|
|
72
|
+
} else obj[key] = value;
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
76
|
+
if (typeof WeakMap !== "function") return null;
|
|
77
|
+
var cacheBabelInterop = new WeakMap();
|
|
78
|
+
var cacheNodeInterop = new WeakMap();
|
|
79
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
80
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
81
|
+
})(nodeInterop);
|
|
82
|
+
}
|
|
83
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
84
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
85
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
86
|
+
default: obj
|
|
87
|
+
};
|
|
88
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
89
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
90
|
+
var newObj = {
|
|
91
|
+
__proto__: null
|
|
92
|
+
};
|
|
93
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
94
|
+
for(var key in obj){
|
|
95
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
96
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
97
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
98
|
+
else newObj[key] = obj[key];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
newObj.default = obj;
|
|
102
|
+
if (cache) cache.set(obj, newObj);
|
|
103
|
+
return newObj;
|
|
104
|
+
}
|
|
105
|
+
function _iterable_to_array(iter) {
|
|
106
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
107
|
+
return Array.from(iter);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function _non_iterable_spread() {
|
|
111
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
112
|
+
}
|
|
113
|
+
function _object_spread(target) {
|
|
114
|
+
for(var i = 1; i < arguments.length; i++){
|
|
115
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
116
|
+
var ownKeys = Object.keys(source);
|
|
117
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
118
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
119
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
ownKeys.forEach(function(key) {
|
|
123
|
+
_define_property(target, key, source[key]);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return target;
|
|
127
|
+
}
|
|
128
|
+
function _to_consumable_array(arr) {
|
|
129
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
130
|
+
}
|
|
131
|
+
function _ts_generator(thisArg, body) {
|
|
132
|
+
var f, y, t, _ = {
|
|
133
|
+
label: 0,
|
|
134
|
+
sent: function() {
|
|
135
|
+
if (t[0] & 1) throw t[1];
|
|
136
|
+
return t[1];
|
|
137
|
+
},
|
|
138
|
+
trys: [],
|
|
139
|
+
ops: []
|
|
140
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
141
|
+
return d(g, "next", {
|
|
142
|
+
value: verb(0)
|
|
143
|
+
}), d(g, "throw", {
|
|
144
|
+
value: verb(1)
|
|
145
|
+
}), d(g, "return", {
|
|
146
|
+
value: verb(2)
|
|
147
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
148
|
+
value: function() {
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
}), g;
|
|
152
|
+
function verb(n) {
|
|
153
|
+
return function(v) {
|
|
154
|
+
return step([
|
|
155
|
+
n,
|
|
156
|
+
v
|
|
157
|
+
]);
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function step(op) {
|
|
161
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
162
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
163
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
164
|
+
if (y = 0, t) op = [
|
|
165
|
+
op[0] & 2,
|
|
166
|
+
t.value
|
|
167
|
+
];
|
|
168
|
+
switch(op[0]){
|
|
169
|
+
case 0:
|
|
170
|
+
case 1:
|
|
171
|
+
t = op;
|
|
172
|
+
break;
|
|
173
|
+
case 4:
|
|
174
|
+
_.label++;
|
|
175
|
+
return {
|
|
176
|
+
value: op[1],
|
|
177
|
+
done: false
|
|
178
|
+
};
|
|
179
|
+
case 5:
|
|
180
|
+
_.label++;
|
|
181
|
+
y = op[1];
|
|
182
|
+
op = [
|
|
183
|
+
0
|
|
184
|
+
];
|
|
185
|
+
continue;
|
|
186
|
+
case 7:
|
|
187
|
+
op = _.ops.pop();
|
|
188
|
+
_.trys.pop();
|
|
189
|
+
continue;
|
|
190
|
+
default:
|
|
191
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
192
|
+
_ = 0;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
196
|
+
_.label = op[1];
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
200
|
+
_.label = t[1];
|
|
201
|
+
t = op;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
if (t && _.label < t[2]) {
|
|
205
|
+
_.label = t[2];
|
|
206
|
+
_.ops.push(op);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
if (t[2]) _.ops.pop();
|
|
210
|
+
_.trys.pop();
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
op = body.call(thisArg, _);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
op = [
|
|
216
|
+
6,
|
|
217
|
+
e
|
|
218
|
+
];
|
|
219
|
+
y = 0;
|
|
220
|
+
} finally{
|
|
221
|
+
f = t = 0;
|
|
222
|
+
}
|
|
223
|
+
if (op[0] & 5) throw op[1];
|
|
224
|
+
return {
|
|
225
|
+
value: op[0] ? op[1] : void 0,
|
|
226
|
+
done: true
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
231
|
+
if (!o) return;
|
|
232
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
233
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
234
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
235
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
236
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
237
|
+
}
|
|
238
|
+
function toAnalysisWord(w) {
|
|
239
|
+
var box = {
|
|
240
|
+
x: w.x,
|
|
241
|
+
y: w.y,
|
|
242
|
+
w: w.w,
|
|
243
|
+
h: w.h
|
|
244
|
+
};
|
|
245
|
+
return w.confidence === undefined ? {
|
|
246
|
+
text: w.text,
|
|
247
|
+
box: box
|
|
248
|
+
} : {
|
|
249
|
+
text: w.text,
|
|
250
|
+
box: box,
|
|
251
|
+
confidence: w.confidence
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
// EmitBlock -> AnalysisBlock: collapses emit.ts's 'quote' kind (a pull-quote)
|
|
255
|
+
// into Analysis's 'paragraph' type, `text` keeping its literal '> ' prefix — see AnalysisBlock's doc comment (src/types.ts) for why.
|
|
256
|
+
function toAnalysisBlock(b, wordIndex) {
|
|
257
|
+
var wordIndexes = b.words.map(function(w) {
|
|
258
|
+
return wordIndex.get(w);
|
|
259
|
+
});
|
|
260
|
+
if (b.kind === 'heading') return {
|
|
261
|
+
type: 'heading',
|
|
262
|
+
text: b.text,
|
|
263
|
+
level: b.level,
|
|
264
|
+
wordIndexes: wordIndexes
|
|
265
|
+
};
|
|
266
|
+
if (b.kind === 'review') return {
|
|
267
|
+
type: 'review',
|
|
268
|
+
text: (0, _emitts.renderEmitBlock)(b),
|
|
269
|
+
wordIndexes: wordIndexes
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
type: 'paragraph',
|
|
273
|
+
text: (0, _emitts.renderEmitBlock)(b),
|
|
274
|
+
wordIndexes: wordIndexes
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function buildOcrAnalysisPages(input, opts, warn) {
|
|
278
|
+
return _async_to_generator(function() {
|
|
279
|
+
var _byPage_get, _opts_onWords, tuning, validated, words, first, last, _Math, _ref, _ref1, _ref2, _opts_pages, _opts_pages1, _opts_pages2, _ref3, _ref4, _opts_pages3, _opts_pages4, recognizePdf, totalPages, rawFirst, rawLast, result, byPage, wordIndex, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, w, list, pageOcrs, pn, levelOf, pages, pn1, _byPage_get1, p, blocks;
|
|
280
|
+
return _ts_generator(this, function(_state) {
|
|
281
|
+
switch(_state.label){
|
|
282
|
+
case 0:
|
|
283
|
+
tuning = _object_spread({}, _geometryts.DEFAULT_TUNING, opts.tuning);
|
|
284
|
+
validated = (0, _validatets.validateOcrAnalysisInput)(input);
|
|
285
|
+
if (!('words' in validated)) return [
|
|
286
|
+
3,
|
|
287
|
+
1
|
|
288
|
+
];
|
|
289
|
+
// Replay: page range from --pages if given, else every page up to the highest one the dump mentions.
|
|
290
|
+
words = validated.words;
|
|
291
|
+
first = (_ref = (_opts_pages = opts.pages) === null || _opts_pages === void 0 ? void 0 : _opts_pages.first) !== null && _ref !== void 0 ? _ref : 1;
|
|
292
|
+
last = (_ref1 = (_ref2 = (_opts_pages1 = opts.pages) === null || _opts_pages1 === void 0 ? void 0 : _opts_pages1.last) !== null && _ref2 !== void 0 ? _ref2 : (_opts_pages2 = opts.pages) === null || _opts_pages2 === void 0 ? void 0 : _opts_pages2.first) !== null && _ref1 !== void 0 ? _ref1 : (_Math = Math).max.apply(_Math, [
|
|
293
|
+
1
|
|
294
|
+
].concat(_to_consumable_array(words.map(function(w) {
|
|
295
|
+
return w.page;
|
|
296
|
+
}))));
|
|
297
|
+
return [
|
|
298
|
+
3,
|
|
299
|
+
5
|
|
300
|
+
];
|
|
301
|
+
case 1:
|
|
302
|
+
return [
|
|
303
|
+
4,
|
|
304
|
+
Promise.resolve().then(function() {
|
|
305
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./engines/tesseract.js"));
|
|
306
|
+
})
|
|
307
|
+
];
|
|
308
|
+
case 2:
|
|
309
|
+
recognizePdf = _state.sent().recognizePdf;
|
|
310
|
+
return [
|
|
311
|
+
4,
|
|
312
|
+
(0, _collectts.pageCount)(validated.pdfPath)
|
|
313
|
+
];
|
|
314
|
+
case 3:
|
|
315
|
+
totalPages = _state.sent();
|
|
316
|
+
rawFirst = (_ref3 = (_opts_pages3 = opts.pages) === null || _opts_pages3 === void 0 ? void 0 : _opts_pages3.first) !== null && _ref3 !== void 0 ? _ref3 : 1;
|
|
317
|
+
rawLast = (_ref4 = (_opts_pages4 = opts.pages) === null || _opts_pages4 === void 0 ? void 0 : _opts_pages4.last) !== null && _ref4 !== void 0 ? _ref4 : opts.pages ? rawFirst : totalPages;
|
|
318
|
+
first = Math.min(Math.max(1, rawFirst), Math.max(1, totalPages));
|
|
319
|
+
last = Math.min(Math.max(first, rawLast), totalPages);
|
|
320
|
+
return [
|
|
321
|
+
4,
|
|
322
|
+
recognizePdf(validated.pdfPath, first, last, {
|
|
323
|
+
dpi: opts.dpi,
|
|
324
|
+
onProgress: opts.onProgress,
|
|
325
|
+
onWarning: warn
|
|
326
|
+
})
|
|
327
|
+
];
|
|
328
|
+
case 4:
|
|
329
|
+
result = _state.sent();
|
|
330
|
+
words = result.words;
|
|
331
|
+
_state.label = 5;
|
|
332
|
+
case 5:
|
|
333
|
+
(_opts_onWords = opts.onWords) === null || _opts_onWords === void 0 ? void 0 : _opts_onWords.call(opts, words);
|
|
334
|
+
// Stable per-page index, assigned in recognition/replay order — this IS
|
|
335
|
+
// the page's flat `words` list order; `wordIndex` recovers it later since geometry.ts never clones a Word (object identity survives row-building).
|
|
336
|
+
byPage = new Map();
|
|
337
|
+
wordIndex = new Map();
|
|
338
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
339
|
+
try {
|
|
340
|
+
for(_iterator = words[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
341
|
+
w = _step.value;
|
|
342
|
+
list = byPage.get(w.page);
|
|
343
|
+
if (list) {
|
|
344
|
+
wordIndex.set(w, list.length);
|
|
345
|
+
list.push(w);
|
|
346
|
+
} else {
|
|
347
|
+
wordIndex.set(w, 0);
|
|
348
|
+
byPage.set(w.page, [
|
|
349
|
+
w
|
|
350
|
+
]);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} catch (err) {
|
|
354
|
+
_didIteratorError = true;
|
|
355
|
+
_iteratorError = err;
|
|
356
|
+
} finally{
|
|
357
|
+
try {
|
|
358
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
359
|
+
_iterator.return();
|
|
360
|
+
}
|
|
361
|
+
} finally{
|
|
362
|
+
if (_didIteratorError) {
|
|
363
|
+
throw _iteratorError;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
pageOcrs = new Map();
|
|
368
|
+
for(pn = first; pn <= last; pn++)pageOcrs.set(pn, (0, _geometryts.buildPageOCR)((_byPage_get = byPage.get(pn)) !== null && _byPage_get !== void 0 ? _byPage_get : [], tuning));
|
|
369
|
+
levelOf = (0, _geometryts.headingLevels)(_to_consumable_array(pageOcrs.values()), tuning).levelOf;
|
|
370
|
+
pages = [];
|
|
371
|
+
for(pn1 = first; pn1 <= last; pn1++){
|
|
372
|
+
;
|
|
373
|
+
p = pageOcrs.get(pn1);
|
|
374
|
+
// An in-range page with no recognized words stays visible (marker +
|
|
375
|
+
// warning), never silently absent — same rule as extractOcr.
|
|
376
|
+
if (!byPage.has(pn1)) warn("p".concat(pn1, ": no recognized words, page emitted with no OCR text"));
|
|
377
|
+
blocks = (0, _emitts.emitPage)(p, levelOf, tuning).map(function(b) {
|
|
378
|
+
return toAnalysisBlock(b, wordIndex);
|
|
379
|
+
});
|
|
380
|
+
// Decorative fragments always render as one visible "> [floats]" aside
|
|
381
|
+
// per page (matching the one printed line) — see geometry.ts's PageOCR.floats.
|
|
382
|
+
if (p.floats.length) {
|
|
383
|
+
blocks.push({
|
|
384
|
+
type: 'float',
|
|
385
|
+
text: "> [floats] ".concat(p.floats.map(function(f) {
|
|
386
|
+
return f.text;
|
|
387
|
+
}).join(' · ')),
|
|
388
|
+
wordIndexes: p.floats.flatMap(function(f) {
|
|
389
|
+
return f.words;
|
|
390
|
+
}).map(function(w) {
|
|
391
|
+
return wordIndex.get(w);
|
|
392
|
+
})
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
pages.push({
|
|
396
|
+
page: pn1,
|
|
397
|
+
words: ((_byPage_get1 = byPage.get(pn1)) !== null && _byPage_get1 !== void 0 ? _byPage_get1 : []).map(toAnalysisWord),
|
|
398
|
+
blocks: blocks
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
return [
|
|
402
|
+
2,
|
|
403
|
+
{
|
|
404
|
+
pages: pages,
|
|
405
|
+
words: words
|
|
406
|
+
}
|
|
407
|
+
];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
})();
|
|
411
|
+
}
|
|
412
|
+
function analyzeOcr(input, opts) {
|
|
413
|
+
return _async_to_generator(function() {
|
|
414
|
+
var warn, _ref, pages, words, md, report;
|
|
415
|
+
return _ts_generator(this, function(_state) {
|
|
416
|
+
switch(_state.label){
|
|
417
|
+
case 0:
|
|
418
|
+
warn = function warn(m) {
|
|
419
|
+
var _opts_onWarning;
|
|
420
|
+
return (_opts_onWarning = opts.onWarning) === null || _opts_onWarning === void 0 ? void 0 : _opts_onWarning.call(opts, m);
|
|
421
|
+
};
|
|
422
|
+
if (!(0, _dictts.dictAvailable)()) warn((0, _dictts.dictUnavailableWarning)());
|
|
423
|
+
return [
|
|
424
|
+
4,
|
|
425
|
+
buildOcrAnalysisPages(input, opts, warn)
|
|
426
|
+
];
|
|
427
|
+
case 1:
|
|
428
|
+
_ref = _state.sent(), pages = _ref.pages, words = _ref.words;
|
|
429
|
+
md = (0, _renderanalysists.renderPagesToMarkdown)(pages, {
|
|
430
|
+
forcePageMarkers: true,
|
|
431
|
+
pageMarkers: true
|
|
432
|
+
});
|
|
433
|
+
report = (0, _reportts.buildOcrReport)({
|
|
434
|
+
md: md,
|
|
435
|
+
fallback: opts.fallback,
|
|
436
|
+
words: words
|
|
437
|
+
});
|
|
438
|
+
return [
|
|
439
|
+
2,
|
|
440
|
+
{
|
|
441
|
+
outputVersion: _reportts.OUTPUT_VERSION,
|
|
442
|
+
report: report,
|
|
443
|
+
pages: pages
|
|
444
|
+
}
|
|
445
|
+
];
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
})();
|
|
449
|
+
}
|
|
450
|
+
// TEXT path: deliberately NOT routed through the OCR shared-core pattern —
|
|
451
|
+
// buildMarkdown's reflow/hyphen-rejoin/list rules don't fit the 4-type Analysis block union, so this is an independent, intentionally coarser reconstruction (one word/block per visual LINE) — honest, not byte-identical to extractText (see AnalysisPage, src/types.ts).
|
|
452
|
+
// Converts a text-path Line's page-point geometry (src/lines.ts) into the
|
|
453
|
+
// same normalized box contract the OCR path uses (see AnalysisPage.words) — only the coordinate SYSTEM changes; `box.y` anchors on the line's baseline, `box.w` stays 0.
|
|
454
|
+
function textLineBox(l, dims) {
|
|
455
|
+
var width = dims.width, height = dims.height;
|
|
456
|
+
return {
|
|
457
|
+
x: width > 0 ? l.x / width : 0,
|
|
458
|
+
y: height > 0 ? (height - l.y) / height : 0,
|
|
459
|
+
w: 0,
|
|
460
|
+
h: height > 0 ? l.h / height : 0
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function analyzeText(pdfPath, opts) {
|
|
464
|
+
return _async_to_generator(function() {
|
|
465
|
+
var _opts_pages_last, _opts_pageMarkers, warn, range, _ref, numPages, pages, heightChars, pageDims, pageLines, pageMarkers, _buildMarkdown, md, stats, bodyH, headingSizes, statsMd, hybridPages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, n, report, levelOf, analysisPages;
|
|
466
|
+
return _ts_generator(this, function(_state) {
|
|
467
|
+
switch(_state.label){
|
|
468
|
+
case 0:
|
|
469
|
+
warn = function warn(m) {
|
|
470
|
+
var _opts_onWarning;
|
|
471
|
+
return (_opts_onWarning = opts.onWarning) === null || _opts_onWarning === void 0 ? void 0 : _opts_onWarning.call(opts, m);
|
|
472
|
+
};
|
|
473
|
+
if (!(0, _dictts.dictAvailable)()) warn((0, _dictts.dictUnavailableWarning)());
|
|
474
|
+
range = opts.pages ? {
|
|
475
|
+
first: opts.pages.first,
|
|
476
|
+
last: (_opts_pages_last = opts.pages.last) !== null && _opts_pages_last !== void 0 ? _opts_pages_last : opts.pages.first
|
|
477
|
+
} : {};
|
|
478
|
+
return [
|
|
479
|
+
4,
|
|
480
|
+
(0, _collectts.collect)(pdfPath, range)
|
|
481
|
+
];
|
|
482
|
+
case 1:
|
|
483
|
+
_ref = _state.sent(), numPages = _ref.numPages, pages = _ref.pages, heightChars = _ref.heightChars;
|
|
484
|
+
pageDims = new Map(pages.map(function(p) {
|
|
485
|
+
return [
|
|
486
|
+
p.page,
|
|
487
|
+
{
|
|
488
|
+
width: p.width,
|
|
489
|
+
height: p.height
|
|
490
|
+
}
|
|
491
|
+
];
|
|
492
|
+
}));
|
|
493
|
+
pageLines = pages.map(function(p) {
|
|
494
|
+
return {
|
|
495
|
+
page: p.page,
|
|
496
|
+
lines: (0, _linests.toLines)(p)
|
|
497
|
+
};
|
|
498
|
+
});
|
|
499
|
+
pageMarkers = (_opts_pageMarkers = opts.pageMarkers) !== null && _opts_pageMarkers !== void 0 ? _opts_pageMarkers : false;
|
|
500
|
+
_buildMarkdown = (0, _markdownts.buildMarkdown)(pageLines, heightChars, {
|
|
501
|
+
pageMarkers: pageMarkers
|
|
502
|
+
}), md = _buildMarkdown.md, stats = _buildMarkdown.stats, bodyH = _buildMarkdown.bodyH, headingSizes = _buildMarkdown.headingSizes;
|
|
503
|
+
statsMd = pageMarkers ? md : (0, _markdownts.buildMarkdown)(pageLines, heightChars, {
|
|
504
|
+
pageMarkers: true
|
|
505
|
+
}).md;
|
|
506
|
+
hybridPages = pages.filter(function(p) {
|
|
507
|
+
return p.largeImage;
|
|
508
|
+
}).map(function(p) {
|
|
509
|
+
return p.page;
|
|
510
|
+
});
|
|
511
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
512
|
+
try {
|
|
513
|
+
for(_iterator = hybridPages[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
514
|
+
n = _step.value;
|
|
515
|
+
warn("p".concat(n, ": text layer used but page carries large image(s); if it has baked-in text this output won't have it — compare (don't blindly replace) against --pages ").concat(n, " --ocr, which can itself introduce errors"));
|
|
516
|
+
}
|
|
517
|
+
} catch (err) {
|
|
518
|
+
_didIteratorError = true;
|
|
519
|
+
_iteratorError = err;
|
|
520
|
+
} finally{
|
|
521
|
+
try {
|
|
522
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
523
|
+
_iterator.return();
|
|
524
|
+
}
|
|
525
|
+
} finally{
|
|
526
|
+
if (_didIteratorError) {
|
|
527
|
+
throw _iteratorError;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
// Report is measured from the REAL markdown above — accurate regardless of
|
|
532
|
+
// the coarser block/word reconstruction below.
|
|
533
|
+
report = (0, _reportts.buildReport)({
|
|
534
|
+
numPages: numPages,
|
|
535
|
+
md: md,
|
|
536
|
+
statsMd: statsMd,
|
|
537
|
+
stats: stats,
|
|
538
|
+
bodyH: bodyH,
|
|
539
|
+
headingSizes: headingSizes,
|
|
540
|
+
hybridPages: hybridPages
|
|
541
|
+
});
|
|
542
|
+
// headingSizes is offset-independent — reused directly, then re-leveled
|
|
543
|
+
// here with offset 0 regardless of `opts.pageMarkers` (see AnalysisPage).
|
|
544
|
+
levelOf = new Map(headingSizes.slice(0, 6).map(function(h, i) {
|
|
545
|
+
return [
|
|
546
|
+
h,
|
|
547
|
+
Math.min(6, i + 1)
|
|
548
|
+
];
|
|
549
|
+
}));
|
|
550
|
+
analysisPages = pageLines.map(function(param) {
|
|
551
|
+
var page = param.page, lines = param.lines;
|
|
552
|
+
var dims = pageDims.get(page);
|
|
553
|
+
var words = lines.map(function(l) {
|
|
554
|
+
return {
|
|
555
|
+
text: l.text,
|
|
556
|
+
box: textLineBox(l, dims)
|
|
557
|
+
};
|
|
558
|
+
});
|
|
559
|
+
var blocks = lines.map(function(l, i) {
|
|
560
|
+
var level = levelOf.get(l.h);
|
|
561
|
+
return level !== undefined ? {
|
|
562
|
+
type: 'heading',
|
|
563
|
+
text: l.text,
|
|
564
|
+
level: level,
|
|
565
|
+
wordIndexes: [
|
|
566
|
+
i
|
|
567
|
+
]
|
|
568
|
+
} : {
|
|
569
|
+
type: 'paragraph',
|
|
570
|
+
text: l.text,
|
|
571
|
+
wordIndexes: [
|
|
572
|
+
i
|
|
573
|
+
]
|
|
574
|
+
};
|
|
575
|
+
});
|
|
576
|
+
return {
|
|
577
|
+
page: page,
|
|
578
|
+
words: words,
|
|
579
|
+
blocks: blocks
|
|
580
|
+
};
|
|
581
|
+
});
|
|
582
|
+
return [
|
|
583
|
+
2,
|
|
584
|
+
{
|
|
585
|
+
outputVersion: _reportts.OUTPUT_VERSION,
|
|
586
|
+
report: report,
|
|
587
|
+
pages: analysisPages
|
|
588
|
+
}
|
|
589
|
+
];
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
})();
|
|
593
|
+
}
|
|
594
|
+
function analyze(_0) {
|
|
595
|
+
return _async_to_generator(function(input) {
|
|
596
|
+
var opts;
|
|
597
|
+
var _arguments = arguments;
|
|
598
|
+
return _ts_generator(this, function(_state) {
|
|
599
|
+
opts = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
600
|
+
(0, _validatets.validatePages)(opts.pages);
|
|
601
|
+
if (typeof input !== 'string') return [
|
|
602
|
+
2,
|
|
603
|
+
analyzeOcr({
|
|
604
|
+
words: (0, _validatets.validateWordsInput)(input)
|
|
605
|
+
}, opts)
|
|
606
|
+
];
|
|
607
|
+
if (opts.path === 'ocr') return [
|
|
608
|
+
2,
|
|
609
|
+
analyzeOcr({
|
|
610
|
+
pdfPath: input
|
|
611
|
+
}, opts)
|
|
612
|
+
];
|
|
613
|
+
return [
|
|
614
|
+
2,
|
|
615
|
+
analyzeText(input, opts)
|
|
616
|
+
];
|
|
617
|
+
});
|
|
618
|
+
}).apply(this, arguments);
|
|
619
|
+
}
|
|
620
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/analyze.ts"],"sourcesContent":["// analyze() plus the OCR-path core (buildOcrAnalysisPages) that extractOcr\n// shares with it — same buildPageOCR -> emitPage -> renderPagesToMarkdown pipeline, so OCR-path markdown is byte-identical by construction, not two implementations kept in sync by hand. The TEXT path is NOT shared this way (see analyzeText).\nimport { collect, pageCount } from './collect.ts';\nimport { dictAvailable, dictUnavailableWarning } from './dict.ts';\nimport type { EmitBlock } from './emit.ts';\nimport { emitPage, renderEmitBlock } from './emit.ts';\n// Type-only: erased at compile time, so this does NOT create a runtime\n// circular dependency even though src/extract.ts imports (value-level) from this module.\nimport type { ExtractOcrOptions, ExtractTextOptions, OcrWordInput } from './extract.ts';\nimport type { PageOCR, Tuning, Word } from './geometry.ts';\nimport { buildPageOCR, DEFAULT_TUNING, headingLevels } from './geometry.ts';\nimport { toLines } from './lines.ts';\nimport { buildMarkdown } from './markdown.ts';\nimport { renderPagesToMarkdown } from './render-analysis.ts';\nimport { buildOcrReport, buildReport, OUTPUT_VERSION } from './report.ts';\nimport type { Analysis, AnalysisBlock, AnalysisPage, AnalysisWord, Line, PageLines } from './types.ts';\nimport { validateOcrAnalysisInput, validatePages, validateWordsInput } from './validate.ts';\n\n/** analyze(pdf) with the default/'text' path — OCR-only fields don't exist\n * on this branch, so passing e.g. `tuning` without `path: 'ocr'` is a compile error. */\nexport type AnalyzeTextOptions = ExtractTextOptions & { path?: 'text' };\n\n/** analyze(pdf, {path:'ocr'}) — same fields as {@link ExtractOcrOptions},\n * unlocked only once `path: 'ocr'` is set. */\nexport type AnalyzeOcrOptions = ExtractOcrOptions & { path: 'ocr' };\n\n/** Options for {@link analyze}: which fields type-check depends on `path`\n * (ignored, forced 'ocr', when `input` is a `{ words }` replay). */\nexport type AnalyzeOptions = AnalyzeTextOptions | AnalyzeOcrOptions;\n\nfunction toAnalysisWord(w: OcrWordInput): AnalysisWord {\n const box = { x: w.x, y: w.y, w: w.w, h: w.h };\n return w.confidence === undefined ? { text: w.text, box } : { text: w.text, box, confidence: w.confidence };\n}\n\n// EmitBlock -> AnalysisBlock: collapses emit.ts's 'quote' kind (a pull-quote)\n// into Analysis's 'paragraph' type, `text` keeping its literal '> ' prefix — see AnalysisBlock's doc comment (src/types.ts) for why.\nfunction toAnalysisBlock(b: EmitBlock, wordIndex: Map<Word, number>): AnalysisBlock {\n const wordIndexes = b.words.map((w) => wordIndex.get(w) as number);\n if (b.kind === 'heading') return { type: 'heading', text: b.text, level: b.level, wordIndexes };\n if (b.kind === 'review') return { type: 'review', text: renderEmitBlock(b), wordIndexes };\n return { type: 'paragraph', text: renderEmitBlock(b), wordIndexes };\n}\n\n/** The OCR-path core shared by extractOcr and analyze(..., {path:'ocr'}):\n * recognizes (or replays) words and runs the unchanged buildPageOCR/emitPage pipeline. Word IDENTITY (object reference), not value, carries indices through into the emitted blocks — see `geometry.ts`'s OcrLine.words. */\nexport async function buildOcrAnalysisPages(input: { pdfPath: string } | { words: OcrWordInput[] }, opts: ExtractOcrOptions, warn: (m: string) => void): Promise<{ pages: AnalysisPage[]; words: OcrWordInput[] }> {\n const tuning: Tuning = { ...DEFAULT_TUNING, ...opts.tuning };\n const validated = validateOcrAnalysisInput(input);\n\n let words: OcrWordInput[];\n let first: number;\n let last: number;\n if ('words' in validated) {\n // Replay: page range from --pages if given, else every page up to the highest one the dump mentions.\n words = validated.words;\n first = opts.pages?.first ?? 1;\n last = opts.pages?.last ?? opts.pages?.first ?? Math.max(1, ...words.map((w) => w.page));\n } else {\n const { recognizePdf } = await import('./engines/tesseract.ts');\n const totalPages = await pageCount(validated.pdfPath);\n const rawFirst = opts.pages?.first ?? 1;\n const rawLast = opts.pages?.last ?? (opts.pages ? rawFirst : totalPages);\n first = Math.min(Math.max(1, rawFirst), Math.max(1, totalPages));\n last = Math.min(Math.max(first, rawLast), totalPages);\n const result = await recognizePdf(validated.pdfPath, first, last, {\n dpi: opts.dpi,\n onProgress: opts.onProgress,\n onWarning: warn,\n });\n words = result.words;\n }\n\n opts.onWords?.(words);\n\n // Stable per-page index, assigned in recognition/replay order — this IS\n // the page's flat `words` list order; `wordIndex` recovers it later since geometry.ts never clones a Word (object identity survives row-building).\n const byPage = new Map<number, OcrWordInput[]>();\n const wordIndex = new Map<Word, number>();\n for (const w of words) {\n const list = byPage.get(w.page);\n if (list) {\n wordIndex.set(w, list.length);\n list.push(w);\n } else {\n wordIndex.set(w, 0);\n byPage.set(w.page, [w]);\n }\n }\n\n const pageOcrs = new Map<number, PageOCR>();\n for (let pn = first; pn <= last; pn++) pageOcrs.set(pn, buildPageOCR(byPage.get(pn) ?? [], tuning));\n const { levelOf } = headingLevels([...pageOcrs.values()], tuning);\n\n const pages: AnalysisPage[] = [];\n for (let pn = first; pn <= last; pn++) {\n const p = pageOcrs.get(pn) as PageOCR;\n // An in-range page with no recognized words stays visible (marker +\n // warning), never silently absent — same rule as extractOcr.\n if (!byPage.has(pn)) warn(`p${pn}: no recognized words, page emitted with no OCR text`);\n\n const blocks: AnalysisBlock[] = emitPage(p, levelOf, tuning).map((b) => toAnalysisBlock(b, wordIndex));\n // Decorative fragments always render as one visible \"> [floats]\" aside\n // per page (matching the one printed line) — see geometry.ts's PageOCR.floats.\n if (p.floats.length) {\n blocks.push({\n type: 'float',\n text: `> [floats] ${p.floats.map((f) => f.text).join(' · ')}`,\n wordIndexes: p.floats.flatMap((f) => f.words).map((w) => wordIndex.get(w) as number),\n });\n }\n\n pages.push({\n page: pn,\n words: (byPage.get(pn) ?? []).map(toAnalysisWord),\n blocks,\n });\n }\n\n return { pages, words };\n}\n\nasync function analyzeOcr(input: { pdfPath: string } | { words: OcrWordInput[] }, opts: ExtractOcrOptions): Promise<Analysis> {\n const warn = (m: string) => opts.onWarning?.(m);\n if (!dictAvailable()) warn(dictUnavailableWarning());\n const { pages, words } = await buildOcrAnalysisPages(input, opts, warn);\n const md = renderPagesToMarkdown(pages, { forcePageMarkers: true, pageMarkers: true });\n const report = buildOcrReport({ md, fallback: opts.fallback, words });\n return { outputVersion: OUTPUT_VERSION, report, pages };\n}\n\n// TEXT path: deliberately NOT routed through the OCR shared-core pattern —\n// buildMarkdown's reflow/hyphen-rejoin/list rules don't fit the 4-type Analysis block union, so this is an independent, intentionally coarser reconstruction (one word/block per visual LINE) — honest, not byte-identical to extractText (see AnalysisPage, src/types.ts).\n\n// Converts a text-path Line's page-point geometry (src/lines.ts) into the\n// same normalized box contract the OCR path uses (see AnalysisPage.words) — only the coordinate SYSTEM changes; `box.y` anchors on the line's baseline, `box.w` stays 0.\nfunction textLineBox(l: Line, dims: { width: number; height: number }): AnalysisWord['box'] {\n const { width, height } = dims;\n return {\n x: width > 0 ? l.x / width : 0,\n y: height > 0 ? (height - l.y) / height : 0,\n w: 0,\n h: height > 0 ? l.h / height : 0,\n };\n}\n\nasync function analyzeText(pdfPath: string, opts: ExtractTextOptions): Promise<Analysis> {\n const warn = (m: string) => opts.onWarning?.(m);\n if (!dictAvailable()) warn(dictUnavailableWarning());\n const range = opts.pages ? { first: opts.pages.first, last: opts.pages.last ?? opts.pages.first } : {};\n const { numPages, pages, heightChars } = await collect(pdfPath, range);\n const pageDims = new Map(pages.map((p) => [p.page, { width: p.width, height: p.height }]));\n const pageLines: PageLines[] = pages.map((p) => ({ page: p.page, lines: toLines(p) }));\n const pageMarkers = opts.pageMarkers ?? false;\n const { md, stats, bodyH, headingSizes } = buildMarkdown(pageLines, heightChars, { pageMarkers });\n const statsMd = pageMarkers ? md : buildMarkdown(pageLines, heightChars, { pageMarkers: true }).md;\n\n const hybridPages = pages.filter((p) => p.largeImage).map((p) => p.page);\n for (const n of hybridPages) {\n warn(`p${n}: text layer used but page carries large image(s); if it has baked-in text this output won't have it — compare (don't blindly replace) against --pages ${n} --ocr, which can itself introduce errors`);\n }\n\n // Report is measured from the REAL markdown above — accurate regardless of\n // the coarser block/word reconstruction below.\n const report = buildReport({ numPages, md, statsMd, stats, bodyH, headingSizes, hybridPages });\n\n // headingSizes is offset-independent — reused directly, then re-leveled\n // here with offset 0 regardless of `opts.pageMarkers` (see AnalysisPage).\n const levelOf = new Map(headingSizes.slice(0, 6).map((h, i) => [h, Math.min(6, i + 1)]));\n const analysisPages: AnalysisPage[] = pageLines.map(({ page, lines }) => {\n const dims = pageDims.get(page) as { width: number; height: number };\n const words: AnalysisWord[] = lines.map((l) => ({ text: l.text, box: textLineBox(l, dims) }));\n const blocks: AnalysisBlock[] = lines.map((l, i) => {\n const level = levelOf.get(l.h);\n return level !== undefined ? { type: 'heading' as const, text: l.text, level, wordIndexes: [i] } : { type: 'paragraph' as const, text: l.text, wordIndexes: [i] };\n });\n return { page, words, blocks };\n });\n\n return { outputVersion: OUTPUT_VERSION, report, pages: analysisPages };\n}\n\n/**\n * Analyze a PDF (or replay an already-recognized OCR word dump) into\n * `Analysis`: plain, JSON-serializable per-page `words`/`blocks` plus the same QA `report` the other entry points return. Render with toMarkdown()/toText(), or hand-edit/splice it (no merge API — see toMarkdown's doc comment).\n *\n * @param input a bare pdf path, or `{ words }` to replay a dump (always analyzed as OCR) — unlike extractOcr, never `{ pdfPath }`\n * @param opts see {@link AnalyzeOptions}; for a pdf path, `opts.path` picks 'text' (default) or 'ocr' — analyze() makes no auto-fallback decision (that's pdfToMarkdown's job)\n */\nexport async function analyze(input: string | { words: OcrWordInput[] }, opts: AnalyzeOptions = {}): Promise<Analysis> {\n validatePages(opts.pages);\n if (typeof input !== 'string') return analyzeOcr({ words: validateWordsInput(input) }, opts);\n if (opts.path === 'ocr') return analyzeOcr({ pdfPath: input }, opts);\n return analyzeText(input, opts);\n}\n"],"names":["analyze","buildOcrAnalysisPages","toAnalysisWord","w","box","x","y","h","confidence","undefined","text","toAnalysisBlock","b","wordIndex","wordIndexes","words","map","get","kind","type","level","renderEmitBlock","input","opts","warn","byPage","tuning","validated","first","last","Math","recognizePdf","totalPages","rawFirst","rawLast","result","list","pageOcrs","pn","levelOf","pages","p","blocks","DEFAULT_TUNING","validateOcrAnalysisInput","max","page","pageCount","pdfPath","min","dpi","onProgress","onWarning","onWords","Map","set","length","push","buildPageOCR","headingLevels","values","has","emitPage","floats","f","join","flatMap","analyzeOcr","md","report","m","dictAvailable","dictUnavailableWarning","renderPagesToMarkdown","forcePageMarkers","pageMarkers","buildOcrReport","fallback","outputVersion","OUTPUT_VERSION","textLineBox","l","dims","width","height","analyzeText","range","numPages","heightChars","pageDims","pageLines","buildMarkdown","stats","bodyH","headingSizes","statsMd","hybridPages","n","analysisPages","collect","lines","toLines","filter","largeImage","buildReport","slice","i","validatePages","validateWordsInput","path"],"mappings":"AAAA,2EAA2E;AAC3E,kPAAkP;;;;;;;;;;;;QA4L5NA;eAAAA;;QA/IAC;eAAAA;;;yBA5Ca;sBACmB;sBAEZ;0BAKkB;uBACpC;0BACM;gC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