A fast, helpful, and open-source document parser
remove unused code
Logan Markewichbdc91b7cb516
diff --git a/AGENTS.md b/AGENTS.mdindex b439618..c23acba 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -10,7 +10,6 @@- **Spatial text extraction** with precise bounding boxes- **Flexible OCR** (built-in Tesseract.js or pluggable HTTP servers)- **Multi-format support** (PDFs, DOCX, XLSX, PPTX, images via conversion)-- **Table detection** via heuristic line/path analysis- **TypeScript/Node.js** with both library and CLI interfaces## Directory Structure@@ -42,7 +41,7 @@ liteparse/3. **PDF Loading**: PDF.js extracts text items, paths, images, metadata4. **OCR** (if enabled): Images rendered and OCR'd for text-sparse areas5. **Grid Projection**: Spatial reconstruction of text layout using anchor system-6. **Post-processing**: Bounding boxes, table detection, text cleanup+6. **Post-processing**: Bounding boxes, text cleanup7. **Output**: Formatted as JSON or plain text## Key Design Decisions@@ -86,7 +85,6 @@ Rather than implementing format parsers, LiteParse converts non-PDF formats usinThe processing pipeline is in `src/processing/`. Key files:- `gridProjection.ts` - Layout reconstruction (most complex)- `bbox.ts` - Bounding box calculation-- `tables.ts` - Table detection- `cleanText.ts` - Text cleanup### Adding CLI Optionsdiff --git a/README.md b/README.mdindex e9b61ba..cf3c99c 100644--- a/README.md+++ b/README.md@@ -16,7 +16,6 @@ LiteParse is a standalone OSS PDF parsing tool focused exclusively on **fast and- **Screenshot Generation**: Generate high-quality page screenshots for LLM agents- **Multiple Output Formats**: JSON and Text- **Bounding Boxes**: Precise text positioning information-- **Table Detection**: Heuristic table detection (outlined tables)- **Standalone Binary**: No cloud dependencies, runs entirely locally- **Multi-platform**: Linux, macOS (Intel/ARM), Windows@@ -150,7 +149,6 @@ Options:--target-pages <pages> Target pages (e.g., "1-5,10,15-20")--pdf-engine <engine> PDF engine: pdfjs|pdfium (default: "pdfjs")--dpi <dpi> DPI for rendering (default: "150")- --no-tables Disable table detection--no-precise-bbox Disable precise bounding boxes--skip-diagonal-text Skip diagonal text--preserve-small-text Preserve very small text@@ -171,7 +169,6 @@ Options:--ocr-language <lang> OCR language(s) (default: "en")--max-pages <n> Max pages to parse per file (default: "1000")--dpi <dpi> DPI for rendering (default: "150")- --no-tables Disable table detection--no-precise-bbox Disable precise bounding boxes--recursive Recursively search input directory--extension <ext> Only process files with this extension (e.g., ".pdf")@@ -277,7 +274,6 @@ Create a `liteparse.config.json` file:"outputFormat": "json","includeImages": true,"includeCharts": true,- "tableDetection": true,"preciseBoundingBox": true,"skipDiagonalText": false,"preserveVerySmallText": falsediff --git a/cli/README.md b/cli/README.mdindex 4b373e9..0493011 100644--- a/cli/README.md+++ b/cli/README.md@@ -25,7 +25,6 @@ Parse documents and extract text.| `--max-pages <n>` | Maximum pages to parse | `1000` || `--target-pages <pages>` | Specific pages (e.g., "1-5,10") | all || `--dpi <dpi>` | Render resolution | `150` |-| `--no-tables` | Disable table detection | enabled || `--no-precise-bbox` | Disable bounding boxes | enabled || `--skip-diagonal-text` | Skip diagonal/rotated text | false || `--preserve-small-text` | Keep very small text | false |@@ -91,7 +90,6 @@ Both commands accept `--config <file>` to load settings from JSON:"maxPages": 100,"dpi": 200,"outputFormat": "json",- "tableDetection": true,"preciseBoundingBox": true}```diff --git a/cli/parse.ts b/cli/parse.tsindex 385f97d..c144092 100644--- a/cli/parse.ts+++ b/cli/parse.ts@@ -22,7 +22,6 @@ interface ParseCommandOptions {maxPages?: string;targetPages?: string;dpi?: string;- tables?: boolean;preciseBbox?: boolean;skipDiagonalText?: boolean;preserveSmallText?: boolean;@@ -46,7 +45,6 @@ interface BatchParseCommandOptions {ocrLanguage?: string;maxPages?: string;dpi?: string;- tables?: boolean;preciseBbox?: boolean;recursive?: boolean;extension?: string;@@ -72,7 +70,6 @@ program.option("--max-pages <n>", "Max pages to parse", DEFAULT_MAX_PAGES.toString()).option("--target-pages <pages>", 'Target pages (e.g., "1-5,10,15-20")').option("--dpi <dpi>", "DPI for rendering", DEFAULT_DPI.toString())- .option("--no-tables", "Disable table detection").option("--no-precise-bbox", "Disable precise bounding boxes").option("--skip-diagonal-text", "Skip diagonal text").option("--preserve-small-text", "Preserve very small text")@@ -110,7 +107,6 @@ programmaxPages: parseInt(options.maxPages || DEFAULT_MAX_PAGES.toString()),targetPages: options.targetPages,dpi: parseInt(options.dpi || DEFAULT_DPI.toString()),- tableDetection: options.tables !== false,preciseBoundingBox: options.preciseBbox !== false,skipDiagonalText: options.skipDiagonalText || false,preserveVerySmallText: options.preserveSmallText || false,@@ -286,7 +282,6 @@ program.option("--ocr-language <lang>", "OCR language(s)", DEFAULT_LANGUAGE).option("--max-pages <n>", "Max pages to parse per file", DEFAULT_MAX_PAGES.toString()).option("--dpi <dpi>", "DPI for rendering", DEFAULT_DPI.toString())- .option("--no-tables", "Disable table detection").option("--no-precise-bbox", "Disable precise bounding boxes").option("--recursive", "Recursively search input directory").option("--extension <ext>", 'Only process files with this extension (e.g., ".pdf")')@@ -346,7 +341,6 @@ programocrLanguage: options.ocrLanguage,maxPages: parseInt(options.maxPages || DEFAULT_MAX_PAGES.toString()),dpi: parseInt(options.dpi || DEFAULT_DPI.toString()),- tableDetection: options.tables !== false,preciseBoundingBox: options.preciseBbox !== false,};diff --git a/packages/python/README.md b/packages/python/README.mdindex 6445800..76e20dc 100644--- a/packages/python/README.md+++ b/packages/python/README.md@@ -31,10 +31,6 @@ print(result.text)# Access structured datafor page in result.pages:print(f"Page {page.pageNum}: {len(page.textItems)} text items")-- # Detected tables from heuristic line analysis- for table in page.tables:- print(f" Table: {table.rows}x{table.cols}")```## Configuration@@ -90,7 +86,6 @@ class LiteParse:ocr_language: str = "en",max_pages: int = 1000,dpi: int = 150,- table_detection: bool = True,precise_bounding_box: bool = True,cli_path: Optional[str] = None,): ...@@ -156,7 +151,6 @@ class ParsedPage:text: strtextItems: List[TextItem]boundingBoxes: List[BoundingBox]- tables: List[DetectedTable]```## Supported Formatsdiff --git a/packages/python/liteparse/__init__.py b/packages/python/liteparse/__init__.pyindex 4b310bb..4dd104d 100644--- a/packages/python/liteparse/__init__.py+++ b/packages/python/liteparse/__init__.py@@ -9,8 +9,6 @@ from .types import (ParsedPage,TextItem,BoundingBox,- DetectedTable,- TableCell,ScreenshotResult,ScreenshotBatchResult,# Errors@@ -31,8 +29,6 @@ __all__ = ["ParsedPage","TextItem","BoundingBox",- "DetectedTable",- "TableCell","ScreenshotResult","ScreenshotBatchResult",# Errorsdiff --git a/packages/python/liteparse/parser.py b/packages/python/liteparse/parser.pyindex d413c06..ef95e35 100644--- a/packages/python/liteparse/parser.py+++ b/packages/python/liteparse/parser.py@@ -14,8 +14,6 @@ from .types import (ParsedPage,TextItem,BoundingBox,- DetectedTable,- TableCell,OutputFormat,ImageFormat,ScreenshotResult,@@ -88,34 +86,6 @@ def _parse_json_result(json_data: dict) -> ParseResult:))- # Parse tables- tables: List[DetectedTable] = []- for table in page_data.get("tables", []):- cells: List[TableCell] = []- for cell in table.get("cells", []):- cells.append(- TableCell(- x1=cell.get("x1", 0),- y1=cell.get("y1", 0),- x2=cell.get("x2", 0),- y2=cell.get("y2", 0),- text=cell.get("text", ""),- row=cell.get("row", 0),- col=cell.get("col", 0),- )- )- tables.append(- DetectedTable(- x1=table.get("x1", 0),- y1=table.get("y1", 0),- x2=table.get("x2", 0),- y2=table.get("y2", 0),- rows=table.get("rows", 0),- cols=table.get("cols", 0),- cells=cells,- )- )-pages.append(ParsedPage(pageNum=page_data.get("page", page_data.get("pageNum", 0)),@@ -124,7 +94,6 @@ def _parse_json_result(json_data: dict) -> ParseResult:text=page_data.get("text", ""),textItems=text_items,boundingBoxes=bounding_boxes,- tables=tables,))@@ -145,7 +114,6 @@ def _build_parse_cli_args(max_pages: int,target_pages: Optional[str],dpi: int,- table_detection: bool,precise_bounding_box: bool,skip_diagonal_text: bool,preserve_very_small_text: bool,@@ -166,9 +134,6 @@ def _build_parse_cli_args(args.extend(["--dpi", str(dpi)])- if not table_detection:- args.append("--no-tables")-if not precise_bounding_box:args.append("--no-precise-bbox")@@ -189,7 +154,6 @@ def _build_batch_cli_args(ocr_language: str,max_pages: int,dpi: int,- table_detection: bool,precise_bounding_box: bool,recursive: bool,extension_filter: Optional[str],@@ -206,9 +170,6 @@ def _build_batch_cli_args(args.extend(["--max-pages", str(max_pages)])args.extend(["--dpi", str(dpi)])- if not table_detection:- args.append("--no-tables")-if not precise_bounding_box:args.append("--no-precise-bbox")@@ -261,7 +222,6 @@ class LiteParse:max_pages: int = 1000,target_pages: Optional[str] = None,dpi: int = 150,- table_detection: bool = True,precise_bounding_box: bool = True,skip_diagonal_text: bool = False,preserve_very_small_text: bool = False,@@ -278,7 +238,6 @@ class LiteParse:max_pages: Maximum number of pages to parsetarget_pages: Specific pages to parse (e.g., "1-5,10,15-20")dpi: DPI for rendering (affects OCR quality)- table_detection: Whether to detect tablesprecise_bounding_box: Whether to compute precise bounding boxesskip_diagonal_text: Whether to skip diagonal textpreserve_very_small_text: Whether to preserve very small text@@ -308,7 +267,6 @@ class LiteParse:max_pages=max_pages,target_pages=target_pages,dpi=dpi,- table_detection=table_detection,precise_bounding_box=precise_bounding_box,skip_diagonal_text=skip_diagonal_text,preserve_very_small_text=preserve_very_small_text,@@ -350,7 +308,6 @@ class LiteParse:ocr_language: str = "en",max_pages: int = 1000,dpi: int = 150,- table_detection: bool = True,precise_bounding_box: bool = True,recursive: bool = False,extension_filter: Optional[str] = None,@@ -371,7 +328,6 @@ class LiteParse:ocr_language: Language code for OCRmax_pages: Maximum number of pages to parse per filedpi: DPI for rendering- table_detection: Whether to detect tablesprecise_bounding_box: Whether to compute precise bounding boxesrecursive: Whether to recursively search subdirectoriesextension_filter: Only process files with this extension (e.g., ".pdf")@@ -408,7 +364,6 @@ class LiteParse:ocr_language=ocr_language,max_pages=max_pages,dpi=dpi,- table_detection=table_detection,precise_bounding_box=precise_bounding_box,recursive=recursive,extension_filter=extension_filter,diff --git a/packages/python/liteparse/types.py b/packages/python/liteparse/types.pyindex c973bf3..d04308a 100644--- a/packages/python/liteparse/types.py+++ b/packages/python/liteparse/types.py@@ -41,30 +41,6 @@ class TextItem:fontSize: Optional[float] = None-@dataclass-class TableCell:- """A cell within a detected table."""- x1: float- y1: float- x2: float- y2: float- text: str- row: int- col: int---@dataclass-class DetectedTable:- """A detected table in the document."""- x1: float- y1: float- x2: float- y2: float- rows: int- cols: int- cells: List[TableCell] = field(default_factory=list)--@dataclassclass ParsedPage:"""A parsed page from a document."""@@ -74,7 +50,6 @@ class ParsedPage:text: strtextItems: List[TextItem] = field(default_factory=list)boundingBoxes: List[BoundingBox] = field(default_factory=list)- tables: List[DetectedTable] = field(default_factory=list)@dataclassdiff --git a/src/core/README.md b/src/core/README.mdindex 6d1323a..271e253 100644--- a/src/core/README.md+++ b/src/core/README.md@@ -25,9 +25,8 @@ The core module contains the main orchestrator class, configuration management,4. Run OCR on text-sparse pages/embedded images5. Project pages to grid (spatial text reconstruction)6. Build bounding boxes (if enabled)-7. Detect tables (if enabled)-8. Format output (JSON or text)-9. Cleanup resources+7. Format output (JSON or text)+8. Cleanup resources**Design Decisions:**- **Engine auto-detection**: If `ocrServerUrl` is provided, uses HTTP OCR; otherwise defaults to Tesseract.js for zero-setup experience@@ -48,7 +47,7 @@ The core module contains the main orchestrator class, configuration management,- `TextItem` - Individual text element with position, font, rotation- `ProjectionTextBox` - Extended text item with projection metadata (snap, anchors, etc.)- `BoundingBox` - Coordinates (x1, y1, x2, y2)-- `ParsedPage` - Complete page data (text, textItems, tables, images)+- `ParsedPage` - Complete page data (text, textItems)- `ParseResult` - Final parse output- `ScreenshotResult` - Screenshot output with image buffer@@ -84,7 +83,6 @@ The core module contains the main orchestrator class, configuration management,outputFormat: 'json',includeImages: true,includeCharts: true,- tableDetection: true,preciseBoundingBox: true,skipDiagonalText: false,preserveVerySmallText: false,diff --git a/src/core/config.ts b/src/core/config.tsindex fdd9d1a..094550e 100644--- a/src/core/config.ts+++ b/src/core/config.ts@@ -18,7 +18,6 @@ export const DEFAULT_CONFIG: LiteParseConfig = {includeCharts: true,// Features- tableDetection: true,preciseBoundingBox: true,skipDiagonalText: false,preserveVerySmallText: false,diff --git a/src/core/parser.ts b/src/core/parser.tsindex f85d4d0..7a1ff99 100644--- a/src/core/parser.ts+++ b/src/core/parser.ts@@ -8,7 +8,6 @@ import { TesseractEngine } from "../engines/ocr/tesseract.js";import { HttpOcrEngine } from "../engines/ocr/http-simple.js";import { projectPagesToGrid } from "../processing/grid.js";import { buildBoundingBoxes } from "../processing/bbox.js";-import { detectTables } from "../processing/tables.js";import { formatJSON } from "../output/json.js";import { convertToPdf, cleanupConversionFiles } from "../conversion/convertToPdf.js";@@ -98,15 +97,6 @@ export class LiteParse {}}- // Detect tables if enabled- if (this.config.tableDetection) {- for (let i = 0; i < processedPages.length; i++) {- const page = processedPages[i];- const tables = detectTables(pages[i].paths, pages[i].textItems);- page.tables = tables;- }- }-// Build final textconst fullText = processedPages.map((p) => p.text).join("\n\n");diff --git a/src/core/types.ts b/src/core/types.tsindex 4e9d9dd..56271df 100644--- a/src/core/types.ts+++ b/src/core/types.ts@@ -1,5 +1,3 @@-import { DetectedTable } from "../processing/tables.js";-export type OutputFormat = "json" | "text";export interface LiteParseConfig {@@ -21,7 +19,6 @@ export interface LiteParseConfig {includeCharts: boolean;// Features- tableDetection: boolean;preciseBoundingBox: boolean;skipDiagonalText: boolean;preserveVerySmallText: boolean;@@ -112,7 +109,6 @@ export interface ParsedPage {text: string;textItems: TextItem[];boundingBoxes?: BoundingBox[];- tables?: DetectedTable[];}export interface ParseResultJson {@@ -131,7 +127,6 @@ export interface ParseResultJson {fontSize?: number;}>;boundingBoxes: BoundingBox[];- tables: DetectedTable[];}>;}diff --git a/src/lib.ts b/src/lib.tsindex 36d0d6a..1791d6e 100644--- a/src/lib.ts+++ b/src/lib.ts@@ -3,9 +3,6 @@ export type {LiteParseConfig,OutputFormat,ParseResult,- // PageResult,BoundingBox,TextItem,- // ImageItem,- // TableItem} from "./core/types.js";diff --git a/src/output/README.md b/src/output/README.mdindex b9de3b4..7596759 100644--- a/src/output/README.md+++ b/src/output/README.md@@ -24,8 +24,6 @@ Output formatters that convert parsed document data into different formats.fontSize: number}],boundingBoxes: BoundingBox[],- tables: DetectedTable[],- images: Image[]}]}```diff --git a/src/output/json.ts b/src/output/json.tsindex dde402c..52f2d30 100644--- a/src/output/json.ts+++ b/src/output/json.ts@@ -20,7 +20,6 @@ export function buildJSON(pages: ParsedPage[]): ParseResultJson {fontSize: item.fontSize,})),boundingBoxes: page.boundingBoxes || [],- tables: page.tables || [],})),};}diff --git a/src/processing/README.md b/src/processing/README.mdindex 1a3704a..e5c7744 100644--- a/src/processing/README.md+++ b/src/processing/README.md@@ -1,6 +1,6 @@# src/processing/-The processing module is the **heart of LiteParse** - responsible for transforming raw PDF content into structured, spatially-aware text. This is where text extraction, layout reconstruction, table detection, and OCR integration happen.+The processing module is the **heart of LiteParse** - responsible for transforming raw PDF content into structured, spatially-aware text. This is where text extraction, layout reconstruction, and OCR integration happen.## Files@@ -83,43 +83,10 @@ This is the core algorithm that converts raw PDF text items into readable, prope----### tables.ts-**Heuristic table detection via line intersection analysis.**--Detects tables with explicit borders (outlined tables). Does not detect borderless tables.--**Algorithm:**-1. Extract horizontal and vertical lines from PDF paths-2. Cluster nearby lines to reduce noise (5px threshold)-3. Find line intersections (tolerance: 3px)-4. Create grid cells from intersection points-5. Assign text items to cells based on center point-6. Validate table has minimum rows/cols (2x2, 4 cells min)--**Key Functions:**-- `detectTables(paths, textItems)` - Main entry point-- `extractLines(paths)` - Gets lines from paths and rectangles-- `findIntersections(horizontal, vertical)` - Finds grid points-- `createCellsFromIntersections(intersections)` - Builds cell grid-- `assignTextToCells(cells, textItems)` - Maps text to cells--**Output:**-```typescript-interface DetectedTable {- x1, y1, x2, y2: number; // Table bounds- rows, cols: number; // Grid dimensions- cells: TableCell[]; // Cell data with text-}-```--**Limitation:** Only works with outlined/bordered tables. Borderless tables require layout analysis not yet implemented.------### pathUtils.ts**Extract lines from PDF vector paths.**-Provides input for table detection and layout analysis.+Provides input for layout analysis.`getVerticalAndHorizontalLinesFromPagePaths(config, paths)`:- Extracts vertical lines (x1 ≈ x2) from line paths@@ -240,6 +207,3 @@ Modify `OCR_OVERLAP_THRESHOLD` in `bbox.ts` (default: 0.5 = 50%).### Adding new markup types1. Add field to `MarkupData` in `src/core/types.ts`2. Add case in `applyMarkupTags()` in `markupUtils.ts`--### Improving table detection-The current approach only handles bordered tables. To support borderless tables, you'd need to add layout analysis based on text alignment patterns in `tables.ts`.diff --git a/src/processing/gridProjection.ts b/src/processing/gridProjection.tsindex 041356f..b55117f 100644--- a/src/processing/gridProjection.ts+++ b/src/processing/gridProjection.ts@@ -1607,7 +1607,6 @@ export function projectPagesToGrid(pages: PageData[], config: LiteParseConfig):text,textItems: page.textItems,boundingBoxes: [],- tables: [],});}diff --git a/src/processing/pathUtils.ts b/src/processing/pathUtils.tsindex 6e58337..48f6eed 100644--- a/src/processing/pathUtils.ts+++ b/src/processing/pathUtils.ts@@ -14,7 +14,6 @@ export type HorizontalLine = Line;/*** Extract vertical and horizontal lines from PDF paths- * This is used to detect table borders and layout structure*/export function getVerticalAndHorizontalLinesFromPagePaths(_config: LiteParseConfig,@@ -53,7 +52,7 @@ export function getVerticalAndHorizontalLinesFromPagePaths(});}}- // Handle rectangles as potential table borders+ // Handle rectangles as potential borderselse if (path.type === "rectangle" && path.points.length >= 4) {const xs = path.points.map((p) => p[0]);const ys = path.points.map((p) => p[1]);