formatferry 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +46 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22397,7 +22397,8 @@ function renderTextBlockEnhanced(items, medianPageFontSize, outlineTitles) {
|
|
|
22397
22397
|
htmlBlocks.push(`<h${headingLevel}>${inlineHtml}</h${headingLevel}>`);
|
|
22398
22398
|
} else {
|
|
22399
22399
|
const hasWideGap = /( {3,}|\u00A0\u00A0|\t)/.test(normalizedPlain);
|
|
22400
|
-
const
|
|
22400
|
+
const looksLikeSentence = normalizedPlain.length > 40 && /^[A-Z]/.test(normalizedPlain);
|
|
22401
|
+
const isShort = normalizedPlain.length < 80 && !/[.,:;!?]$/.test(normalizedPlain) && !/\n/.test(normalizedPlain) && !hasWideGap && !looksLikeSentence;
|
|
22401
22402
|
if (isShort && !hasAnyStyle) {
|
|
22402
22403
|
htmlBlocks.push(`<p><strong>${inlineHtml}</strong></p>`);
|
|
22403
22404
|
} else {
|
|
@@ -22528,7 +22529,15 @@ function isHeaderFooterItem(it, suppressSet, Y_TOLERANCE = 5) {
|
|
|
22528
22529
|
const yBucket = Math.round(it.y / Y_TOLERANCE) * Y_TOLERANCE;
|
|
22529
22530
|
return suppressSet.has(`${normalized}@${yBucket}`);
|
|
22530
22531
|
}
|
|
22531
|
-
var PDF_OP = {
|
|
22532
|
+
var PDF_OP = {
|
|
22533
|
+
moveTo: 13,
|
|
22534
|
+
lineTo: 14,
|
|
22535
|
+
closePath: 18,
|
|
22536
|
+
rectangle: 92,
|
|
22537
|
+
stroke: 19,
|
|
22538
|
+
closeStroke: 20,
|
|
22539
|
+
fillStroke: 37
|
|
22540
|
+
};
|
|
22532
22541
|
function extractVectorLines(fnArray, argsArray, pageWidth, pageHeight) {
|
|
22533
22542
|
const MIN_H_SPAN = pageWidth * 0.3;
|
|
22534
22543
|
const MIN_V_SPAN = pageHeight * 0.3;
|
|
@@ -22537,22 +22546,28 @@ function extractVectorLines(fnArray, argsArray, pageWidth, pageHeight) {
|
|
|
22537
22546
|
let curY = 0;
|
|
22538
22547
|
let pathStartX = 0;
|
|
22539
22548
|
let pathStartY = 0;
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22549
|
+
let pending = [];
|
|
22550
|
+
const isPathOp = (op) => op === PDF_OP.moveTo || op === PDF_OP.lineTo || op === PDF_OP.closePath || op === PDF_OP.rectangle;
|
|
22551
|
+
const isStrokeOp = (op) => op === PDF_OP.stroke || op === PDF_OP.closeStroke || op === PDF_OP.fillStroke;
|
|
22552
|
+
const flushPending = () => {
|
|
22553
|
+
for (const p of pending) {
|
|
22554
|
+
const dx = Math.abs(p.x1 - p.x0);
|
|
22555
|
+
const dy = Math.abs(p.y1 - p.y0);
|
|
22556
|
+
if (dy < 2 && dx >= MIN_H_SPAN) {
|
|
22557
|
+
lines.push({
|
|
22558
|
+
orientation: "h",
|
|
22559
|
+
position: (p.y0 + p.y1) / 2,
|
|
22560
|
+
span: [Math.min(p.x0, p.x1), Math.max(p.x0, p.x1)]
|
|
22561
|
+
});
|
|
22562
|
+
} else if (dx < 2 && dy >= MIN_V_SPAN) {
|
|
22563
|
+
lines.push({
|
|
22564
|
+
orientation: "v",
|
|
22565
|
+
position: (p.x0 + p.x1) / 2,
|
|
22566
|
+
span: [Math.min(p.y0, p.y1), Math.max(p.y0, p.y1)]
|
|
22567
|
+
});
|
|
22568
|
+
}
|
|
22555
22569
|
}
|
|
22570
|
+
pending = [];
|
|
22556
22571
|
};
|
|
22557
22572
|
for (let i = 0; i < fnArray.length; i++) {
|
|
22558
22573
|
const op = fnArray[i];
|
|
@@ -22565,7 +22580,7 @@ function extractVectorLines(fnArray, argsArray, pageWidth, pageHeight) {
|
|
|
22565
22580
|
} else if (op === PDF_OP.lineTo) {
|
|
22566
22581
|
const nx = args[0] ?? 0;
|
|
22567
22582
|
const ny = args[1] ?? 0;
|
|
22568
|
-
|
|
22583
|
+
pending.push({ x0: curX, y0: curY, x1: nx, y1: ny });
|
|
22569
22584
|
curX = nx;
|
|
22570
22585
|
curY = ny;
|
|
22571
22586
|
} else if (op === PDF_OP.rectangle) {
|
|
@@ -22573,14 +22588,18 @@ function extractVectorLines(fnArray, argsArray, pageWidth, pageHeight) {
|
|
|
22573
22588
|
const ry = args[1] ?? 0;
|
|
22574
22589
|
const rw = args[2] ?? 0;
|
|
22575
22590
|
const rh = args[3] ?? 0;
|
|
22576
|
-
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22591
|
+
pending.push({ x0: rx, y0: ry, x1: rx + rw, y1: ry });
|
|
22592
|
+
pending.push({ x0: rx, y0: ry + rh, x1: rx + rw, y1: ry + rh });
|
|
22593
|
+
pending.push({ x0: rx, y0: ry, x1: rx, y1: ry + rh });
|
|
22594
|
+
pending.push({ x0: rx + rw, y0: ry, x1: rx + rw, y1: ry + rh });
|
|
22580
22595
|
} else if (op === PDF_OP.closePath) {
|
|
22581
|
-
|
|
22596
|
+
pending.push({ x0: curX, y0: curY, x1: pathStartX, y1: pathStartY });
|
|
22582
22597
|
curX = pathStartX;
|
|
22583
22598
|
curY = pathStartY;
|
|
22599
|
+
} else if (isStrokeOp(op)) {
|
|
22600
|
+
flushPending();
|
|
22601
|
+
} else if (!isPathOp(op)) {
|
|
22602
|
+
pending = [];
|
|
22584
22603
|
}
|
|
22585
22604
|
}
|
|
22586
22605
|
return lines;
|
|
@@ -22703,7 +22722,8 @@ function renderPage(items, pageNum, nextPageNum, enableTableDetection, translate
|
|
|
22703
22722
|
const hasWideGap = /( {3,}|\u00A0\u00A0|\t)/.test(trimmed);
|
|
22704
22723
|
const isFirstPara = paraIdx === 1;
|
|
22705
22724
|
const looksTabular = hasWideGap || isFirstPara && topRowLooksTabular;
|
|
22706
|
-
const
|
|
22725
|
+
const looksLikeSentence = trimmed.length > 40 && /^[A-Z]/.test(trimmed);
|
|
22726
|
+
const short = trimmed.length < 80 && !/[.,:;!?]$/.test(trimmed) && !/\n/.test(trimmed) && !looksTabular && !looksLikeSentence;
|
|
22707
22727
|
if (short) {
|
|
22708
22728
|
htmlBlocks.push(`<p><strong>${escapeHtml(trimmed)}</strong></p>`);
|
|
22709
22729
|
} else {
|
|
@@ -25294,8 +25314,8 @@ import { readFileSync as readFileSync4 } from "fs";
|
|
|
25294
25314
|
import { resolve, dirname as dirname3 } from "path";
|
|
25295
25315
|
import { fileURLToPath } from "url";
|
|
25296
25316
|
var getVersion = () => {
|
|
25297
|
-
if ("1.0.
|
|
25298
|
-
return "1.0.
|
|
25317
|
+
if ("1.0.15") {
|
|
25318
|
+
return "1.0.15";
|
|
25299
25319
|
}
|
|
25300
25320
|
try {
|
|
25301
25321
|
const __dirname = dirname3(fileURLToPath(import.meta.url));
|