Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ragaeeb/kokokor/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Filters out horizontal lines that are contained within any of the provided rectangles. This is useful for removing header/footer lines that appear within document sections while preserving lines that mark true document boundaries or section separators.

Signature

filterHorizontalLinesOutsideRectangles(
    rectangles: BoundingBox[],
    horizontalLines: BoundingBox[],
    tolerance?: number
): BoundingBox[]

Parameters

rectangles
BoundingBox[]
required
Array of rectangles to check containment against
horizontalLines
BoundingBox[]
required
Array of horizontal lines to filter
tolerance
number
default:"5"
Pixel tolerance for boundary checking

Returns

BoundingBox[] - Array of horizontal lines that are NOT contained within any rectangle

What It Does

Filters the horizontal lines array to exclude any lines that are contained within rectangles. This helps boundary detection ignore lines that appear inside headings, callouts, or other boxed content.

Usage Example

import { filterHorizontalLinesOutsideRectangles } from 'kokokor';

const rectangles = [
  { x: 100, y: 50, width: 400, height: 100 }, // Header box
];

const horizontalLines = [
  { x: 150, y: 80, width: 300, height: 2 },   // Inside header
  { x: 50, y: 500, width: 500, height: 2 },   // Footer separator
];

const relevantLines = filterHorizontalLinesOutsideRectangles(
  rectangles,
  horizontalLines,
  5  // Pixel tolerance
);

// Result: Only the footer separator line (not inside any rectangle)
// relevantLines = [{ x: 50, y: 500, width: 500, height: 2 }]

Build docs developers (and LLMs) love