streamdown-syntax 0.1.0

Syntax highlighting for streamdown via syntect
Documentation
streamdown-syntax-0.1.0 has been yanked.

Streamdown Syntax

This crate provides syntax highlighting for code blocks using the syntect library. It's designed to work with streaming input (line-by-line) for real-time rendering.

Features

  • Streaming highlighting - Maintain state across lines for multi-line tokens
  • Language aliases - Map common names (py, js, ts) to proper syntax definitions
  • Background override - Override theme background for consistent code block styling
  • ANSI output - Generate 24-bit true color terminal escape codes

Example

use streamdown_syntax::Highlighter;

let highlighter = Highlighter::new();

// Highlight a complete code block
let code = "fn main() {\n    println!(\"Hello!\");\n}";
let highlighted = highlighter.highlight_block(code, "rust");

// For streaming, use HighlightState
use streamdown_syntax::HighlightState;
let mut hl = Highlighter::new();
let mut state = hl.new_highlight_state("rust");
let line1 = hl.highlight_line_with_state("fn main() {", &mut state);
let line2 = hl.highlight_line_with_state("    println!(\"Hello!\");", &mut state);