pdf-untangle 0.0.1

Untangle garbled PDF text: layout-aware extraction that reconstructs reading order, strips page furniture, and splits documents into structured, citable sections
Documentation
//! Layer 2 — positioned runs → ordered logical lines and blocks.
//!
//! The backend-agnostic hard part: reading order from run positions, column
//! detection, stripping repeated page furniture (headers/footers/page numbers,
//! found by cross-page repetition + position), de-hyphenating line-break
//! splits, merging paragraphs across page boundaries, and preserving
//! indentation levels (subdivision structure like (a)(1)(A) carries meaning).

use anyhow::Result;

use crate::extract::PageRuns;

/// A logical line in reading order, with the layout facts Layer 3 needs.
#[derive(Debug, Clone, PartialEq)]
pub struct Line {
    pub text: String,
    /// Indentation level relative to the block's left margin (0 = flush).
    pub indent: u8,
    pub font_size: f32,
    pub bold: bool,
    pub centered: bool,
    /// Pages this line touches (usually one; two when merged across a break).
    pub pages: Vec<usize>,
}

/// A contiguous block of lines (paragraph-ish unit) in reading order.
#[derive(Debug, Clone, PartialEq)]
pub struct Block {
    pub lines: Vec<Line>,
}

/// Reconstruct ordered blocks from per-page runs.
pub fn reconstruct(pages: &[PageRuns]) -> Result<Vec<Block>> {
    let _ = pages;
    anyhow::bail!("Layer 2 layout reconstruction lands in Phase 2 (see docs/DESIGN.md)")
}