layout

package
v0.0.0-...-5d3bb56 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const YTolerance = 10

YTolerance is the maximum vertical distance (in pixels) for two blocks to be considered on the same text line / cluster.

Variables

This section is empty.

Functions

func DetectTables

func DetectTables() document.Processor

DetectTables returns a Processor that identifies table-like structures where blocks form a grid pattern.

This is a basic heuristic detector. It looks for blocks whose bounding boxes align on both X and Y axes, suggesting a table/cell layout.

func MergeParagraph

func MergeParagraph() document.Processor

MergeParagraph returns a Processor that merges adjacent blocks that are on the same text line (same Y cluster) and close horizontally into a single paragraph block.

func Sort

func Sort() document.Processor

Sort returns a Processor that sorts blocks into natural reading order. The algorithm:

  1. Compute the center Y for each block.
  2. Group blocks whose center Ys are within YTolerance of each other.
  3. Sort clusters by their average Y (top to bottom).
  4. Within each cluster, sort blocks by X (left to right).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL