diff --git a/src/main.rs b/src/main.rs index e92043d..ac6a5fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,10 @@ mod app; mod config; +mod highlighter; +mod renderer; mod signals; mod terminal; +mod vault; fn main() { // ── PRE-TERMINAL PHASE ──────────────────────────────────────────────────── diff --git a/src/renderer.rs b/src/renderer.rs new file mode 100644 index 0000000..8f9773f --- /dev/null +++ b/src/renderer.rs @@ -0,0 +1,713 @@ +//! Markdown-to-styled-lines renderer for bbs-md. +//! +//! Converts a markdown string into `Vec>` using pulldown-cmark +//! event processing, CGA-themed styling, syntax-highlighted code blocks, and +//! box-drawing table grids. +//! +//! # Public API +//! +//! - `render_markdown(input: &str, width: u16) -> Vec>` + +use pulldown_cmark::{ + Alignment, CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd, TextMergeStream, +}; +use ratatui::style::{Color, Modifier, Style}; +use ratatui::text::{Line, Span}; + +// ── RenderState ─────────────────────────────────────────────────────────────── + +/// Internal mutable state threaded through the event handler. +struct RenderState { + /// Accumulated output lines. + lines: Vec>, + /// Spans for the current (in-progress) line. + current_spans: Vec>, + /// Style stack — push on block/inline Start, pop on End. + style_stack: Vec