diff --git a/config.example.yaml b/config.example.yaml index 601e115..a17487b 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -20,6 +20,7 @@ agent_session: null # Set a session to use when starting an agent ( # ---- Appearance ---- highlight: true # Controls syntax highlighting +raw_markdown: false # When true, render markdown as raw text with syntax highlighting only. When false (default), transforms markdown syntax (headings, bold, lists, etc.) into styled terminal output light_theme: false # Activates a light color theme when true. env: COYOTE_LIGHT_THEME # ---- Miscellaneous ---- diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 05a5a91..0a8ab3b 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -68,6 +68,9 @@ pub struct Cli { /// Turn off stream mode #[arg(short = 'S', long)] pub no_stream: bool, + /// Render markdown as raw text with syntax highlighting only (skip the rich markdown renderer) + #[arg(long)] + pub raw_markdown: bool, /// Display the message without sending it #[arg(long)] pub dry_run: bool, diff --git a/src/config/app_config.rs b/src/config/app_config.rs index 0c19ede..d269ef0 100644 --- a/src/config/app_config.rs +++ b/src/config/app_config.rs @@ -86,6 +86,7 @@ pub struct AppConfig { pub document_loaders: HashMap, pub highlight: bool, + pub raw_markdown: bool, pub theme: Option, pub left_prompt: Option, pub right_prompt: Option, @@ -165,6 +166,7 @@ impl Default for AppConfig { document_loaders: Default::default(), highlight: true, + raw_markdown: false, theme: None, left_prompt: None, right_prompt: None, @@ -246,6 +248,7 @@ impl AppConfig { document_loaders: config.document_loaders, highlight: config.highlight, + raw_markdown: config.raw_markdown, theme: config.theme, left_prompt: config.left_prompt, right_prompt: config.right_prompt, @@ -405,7 +408,13 @@ impl AppConfig { env::var("COLORTERM").as_ref().map(|v| v.as_str()), Ok("truecolor") ); - Ok(RenderOptions::new(theme, wrap, self.wrap_code, truecolor)) + Ok(RenderOptions::new( + theme, + wrap, + self.wrap_code, + self.raw_markdown, + truecolor, + )) } pub fn print_markdown(&self, text: &str) -> Result<()> { @@ -589,6 +598,9 @@ impl AppConfig { if *NO_COLOR { self.highlight = false; } + if let Some(Some(v)) = super::read_env_bool(&get_env_name("raw_markdown")) { + self.raw_markdown = v; + } if self.highlight && self.theme.is_none() { if let Some(v) = super::read_env_value::(&get_env_name("theme")) { self.theme = v; diff --git a/src/config/mod.rs b/src/config/mod.rs index 022e937..cd05a38 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -262,6 +262,7 @@ pub struct Config { pub document_loaders: HashMap, pub highlight: bool, + pub raw_markdown: bool, pub theme: Option, pub left_prompt: Option, pub right_prompt: Option, @@ -339,6 +340,7 @@ impl Default for Config { document_loaders: Default::default(), highlight: true, + raw_markdown: false, theme: None, left_prompt: None, right_prompt: None, diff --git a/src/config/request_context.rs b/src/config/request_context.rs index 476e385..f2b1af6 100644 --- a/src/config/request_context.rs +++ b/src/config/request_context.rs @@ -1598,6 +1598,7 @@ impl RequestContext { ("wrap", wrap), ("wrap_code", app.wrap_code.to_string()), ("highlight", app.highlight.to_string()), + ("raw_markdown", app.raw_markdown.to_string()), ("theme", super::format_option_value(&app.theme)), ("config_file", display_path(&paths::config_file())), ("env_file", display_path(&paths::env_file())), @@ -2724,6 +2725,10 @@ impl RequestContext { let value = value.parse().with_context(|| "Invalid value")?; self.update_app_config(|app| app.highlight = value); } + "raw_markdown" => { + let value = value.parse().with_context(|| "Invalid value")?; + self.update_app_config(|app| app.raw_markdown = value); + } "auto_continue" => { let value: bool = value.parse().with_context(|| "Invalid value")?; if value && !self.app.config.function_calling_support { @@ -2928,6 +2933,7 @@ impl RequestContext { "stream", "save", "highlight", + "raw_markdown", ]; if !self.current_model().reasoning_levels().is_empty() { values.push("reasoning_effort"); @@ -3187,6 +3193,7 @@ impl RequestContext { .map(|v| v.id()) .collect(), "highlight" => super::complete_bool(app.highlight), + "raw_markdown" => super::complete_bool(app.raw_markdown), "auto_continue" => { let config = self.auto_continue_config(); super::complete_bool(config.enabled) diff --git a/src/main.rs b/src/main.rs index 1afa726..e6eaaeb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,6 +367,9 @@ async fn run( if cli.no_stream { update_app_config(&mut ctx, |app| app.stream = false); } + if cli.raw_markdown { + update_app_config(&mut ctx, |app| app.raw_markdown = true); + } if cli.no_memory { update_app_config(&mut ctx, |app| app.memory = Some(false)); } diff --git a/src/render/markdown.rs b/src/render/markdown.rs index 3cb3821..76100ac 100644 --- a/src/render/markdown.rs +++ b/src/render/markdown.rs @@ -202,6 +202,8 @@ pub struct RenderOptions { pub theme: Option, pub wrap: Option, pub wrap_code: bool, + #[allow(dead_code)] + pub raw_markdown: bool, pub truecolor: bool, } @@ -210,12 +212,14 @@ impl RenderOptions { theme: Option, wrap: Option, wrap_code: bool, + raw_markdown: bool, truecolor: bool, ) -> Self { Self { theme, wrap, wrap_code, + raw_markdown, truecolor, } }