A fast, helpful, and open-source document parser
formatting
Logan Markewicha64d4667f558
diff --git a/src/core/parser.ts b/src/core/parser.tsindex c402992..4600272 100644--- a/src/core/parser.ts+++ b/src/core/parser.ts@@ -255,10 +255,10 @@ export class LiteParse {// Check overlap with any garbled region (with some tolerance)const tolerance = 5; // PDF pointsfor (const region of page.garbledTextRegions) {- const overlapX = ocrX < region.x + region.width + tolerance &&- ocrX + ocrW > region.x - tolerance;- const overlapY = ocrY < region.y + region.height + tolerance &&- ocrY + ocrH > region.y - tolerance;+ const overlapX =+ ocrX < region.x + region.width + tolerance && ocrX + ocrW > region.x - tolerance;+ const overlapY =+ ocrY < region.y + region.height + tolerance && ocrY + ocrH > region.y - tolerance;if (overlapX && overlapY) {return true;}@@ -279,10 +279,8 @@ export class LiteParse {const itemRight = item.x + (item.width || item.w || 0);const itemBottom = item.y + (item.height || item.h || 0);- const overlapX = ocrX < itemRight + tolerance &&- ocrX + ocrW > item.x - tolerance;- const overlapY = ocrY < itemBottom + tolerance &&- ocrY + ocrH > item.y - tolerance;+ const overlapX = ocrX < itemRight + tolerance && ocrX + ocrW > item.x - tolerance;+ const overlapY = ocrY < itemBottom + tolerance && ocrY + ocrH > item.y - tolerance;if (overlapX && overlapY) {return true;diff --git a/src/engines/pdf/pdfjs.ts b/src/engines/pdf/pdfjs.tsindex a9a3bd5..cf14895 100644--- a/src/engines/pdf/pdfjs.ts+++ b/src/engines/pdf/pdfjs.ts@@ -164,10 +164,7 @@ function isGarbledFontOutput(str: string): boolean {}// Latin Extended-A (0x100-0x17F), Latin Extended-B (0x180-0x24F),// Latin Extended Additional (0x1E00-0x1EFF)- else if (- (code >= 0x100 && code <= 0x24f) ||- (code >= 0x1e00 && code <= 0x1eff)- ) {+ else if ((code >= 0x100 && code <= 0x24f) || (code >= 0x1e00 && code <= 0x1eff)) {latinExtendedCount++;}// Basic Latin letters (a-z, A-Z)@@ -213,10 +210,7 @@ function isGarbledFontOutput(str: string): boolean {// Text predominantly Latin Extended with very few basic Latin letters// (legitimate Latin-script text would have mostly basic Latin)- if (- latinExtendedCount > totalChars * 0.3 &&- basicLatinLetterCount < totalChars * 0.2- ) {+ if (latinExtendedCount > totalChars * 0.3 && basicLatinLetterCount < totalChars * 0.2) {return true;}