pub struct ComputedStyle {Show 19 fields
pub dark: String,
pub mid: String,
pub symbol: String,
pub head: String,
pub grey: String,
pub bright: String,
pub margin_spaces: String,
pub blockquote: String,
pub codebg: String,
pub link: String,
pub codepad: (String, String),
pub list_indent: String,
pub dark_fg: String,
pub dark_bg: String,
pub mid_fg: String,
pub symbol_fg: String,
pub head_fg: String,
pub grey_fg: String,
pub bright_fg: String,
}Expand description
Pre-computed ANSI color strings.
These values are computed from StyleConfig by applying HSV multipliers
to the base color. Each string is formatted for ANSI escape sequences,
e.g., “48;23;15m” for background colors or “255;128;64m” for foreground.
Fields§
§dark: StringDark color (for backgrounds, code block bg). Format: “r;g;bm”
mid: StringMid color (for secondary elements). Format: “r;g;bm”
symbol: StringSymbol color (for special characters, bullets). Format: “r;g;bm”
head: StringHead color (for headers). Format: “r;g;bm”
grey: StringGrey color (for muted text, blockquote bars). Format: “r;g;bm”
bright: StringBright color (for emphasis, links). Format: “r;g;bm”
margin_spaces: StringMargin spaces string (e.g., “ “ for margin=2).
blockquote: StringBlock quote prefix string with ANSI styling.
codebg: StringCode block background ANSI sequence.
link: StringLink color ANSI sequence.
codepad: (String, String)Code block padding characters (left, right). Used for pretty padding around code blocks.
list_indent: StringList indent string.
dark_fg: StringFull ANSI foreground escape for dark.
dark_bg: StringFull ANSI background escape for dark.
mid_fg: StringFull ANSI foreground escape for mid.
symbol_fg: StringFull ANSI foreground escape for symbol.
head_fg: StringFull ANSI foreground escape for head.
grey_fg: StringFull ANSI foreground escape for grey.
bright_fg: StringFull ANSI foreground escape for bright.
Implementations§
Source§impl ComputedStyle
impl ComputedStyle
Sourcepub fn from_config(config: &StyleConfig) -> Self
pub fn from_config(config: &StyleConfig) -> Self
Compute style values from a StyleConfig.
This applies the HSV multipliers to the base color to generate all derived colors, then formats them as ANSI escape sequences.
§Arguments
config- The style configuration to compute from
§Example
use streamdown_config::{StyleConfig, ComputedStyle};
let config = StyleConfig::default();
let computed = ComputedStyle::from_config(&config);
// Use the computed dark background
let bg_escape = format!("\x1b[48;2;{}", computed.dark);Sourcepub fn style_fg(&self, name: &str, text: &str) -> String
pub fn style_fg(&self, name: &str, text: &str) -> String
Format text with a specific foreground style.
Sourcepub fn heading(&self, level: u8, text: &str) -> String
pub fn heading(&self, level: u8, text: &str) -> String
Create a heading line with the head color.
Sourcepub fn code_start(&self, language: Option<&str>, width: usize) -> String
pub fn code_start(&self, language: Option<&str>, width: usize) -> String
Create a code block start line.
Sourcepub fn list_number(&self, indent: usize, num: usize) -> String
pub fn list_number(&self, indent: usize, num: usize) -> String
Create an ordered list number.
Trait Implementations§
Source§impl Clone for ComputedStyle
impl Clone for ComputedStyle
Source§fn clone(&self) -> ComputedStyle
fn clone(&self) -> ComputedStyle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more