feat: Created the raw_markdown configuration flag
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -86,6 +86,7 @@ pub struct AppConfig {
|
||||
pub document_loaders: HashMap<String, String>,
|
||||
|
||||
pub highlight: bool,
|
||||
pub raw_markdown: bool,
|
||||
pub theme: Option<String>,
|
||||
pub left_prompt: Option<String>,
|
||||
pub right_prompt: Option<String>,
|
||||
@@ -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::<String>(&get_env_name("theme")) {
|
||||
self.theme = v;
|
||||
|
||||
@@ -262,6 +262,7 @@ pub struct Config {
|
||||
pub document_loaders: HashMap<String, String>,
|
||||
|
||||
pub highlight: bool,
|
||||
pub raw_markdown: bool,
|
||||
pub theme: Option<String>,
|
||||
pub left_prompt: Option<String>,
|
||||
pub right_prompt: Option<String>,
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -202,6 +202,8 @@ pub struct RenderOptions {
|
||||
pub theme: Option<Theme>,
|
||||
pub wrap: Option<String>,
|
||||
pub wrap_code: bool,
|
||||
#[allow(dead_code)]
|
||||
pub raw_markdown: bool,
|
||||
pub truecolor: bool,
|
||||
}
|
||||
|
||||
@@ -210,12 +212,14 @@ impl RenderOptions {
|
||||
theme: Option<Theme>,
|
||||
wrap: Option<String>,
|
||||
wrap_code: bool,
|
||||
raw_markdown: bool,
|
||||
truecolor: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
theme,
|
||||
wrap,
|
||||
wrap_code,
|
||||
raw_markdown,
|
||||
truecolor,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user