Skip to content

Add arborium-ratatui adapter crate #142

@fasterthanlime

Description

@fasterthanlime

When using arborium with ratatui, you can't use spans_to_ansi because ratatui wants structured Line<'_> with Span objects that have Style attached - it does its own terminal rendering.

This means users need to reimplement the span deduplication and overlap handling logic that already exists in spans_to_themed / spans_to_ansi.

A small arborium-ratatui adapter crate could provide:

pub fn highlight_to_lines(
    highlighter: &mut Highlighter,
    theme: &Theme,
    language: &str,
    source: &str,
) -> Vec<Line<'static>>

This would handle converting arborium's themed spans to ratatui's Line/Span types with proper Style mapping, keeping the deduplication logic in one place.

Context: Implemented this manually in dibs-cli and initially got it wrong (text duplication from overlapping spans) before realizing I needed the event-based stack algorithm from spans_to_ansi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions