//! Markdown-to-styled-spans rendering for the chat transcript. //! //! Flow: `render_markdown` walks a `pulldown_cmark` event stream and //! translates each markdown construct into styled `ratatui::text::Span`s, //! then re-wraps the flat span list to a target column width. //! //! Design: code blocks get a dark background with a labeled top bar, //! headings are bold with distinct colors, blockquotes get a vertical //! accent bar prefix, and inline code is highlighted with a background. //! Deliberately adds no leading indentation of its own for paragraphs, //! headings, or list bullets — the caller (`chat.rs`) owns column //! alignment via its `PREFIX_WIDTH` scheme, so any indent added here //! would only apply to a construct's first rendered line and throw //! wrapped continuation lines out of alignment with it. Code-block lines //! are the exception: every line gets its `" "` prefix independently //! and consistently, so there's no first-line-only misalignment there. use ratatui::style::{Modifier, Style}; use ratatui::text::Span; use super::theme::Theme; /// Apply the "tool output" dim/italic style, or pass `style` through /// unchanged, depending on `dim`. fn apply_dim(style: Style, dim: bool) -> Style { if dim { Style::default().fg(Theme::TEXT_DIM).add_modifier(Modifier::ITALIC) } else { style } } /// Classify a single line inside a ` ```diff ` fenced block by its unified-diff /// prefix, returning the color it should always render with (even when the /// surrounding tool output is dimmed) — or `None` for context lines and the /// `+++`/`---` file-header lines, which use the normal code-block color. fn diff_line_style(line: &str) -> Option