diff --git a/src/commands/eval.rs b/src/commands/eval.rs index 5487583..8383c51 100644 --- a/src/commands/eval.rs +++ b/src/commands/eval.rs @@ -7,8 +7,21 @@ pub async fn eval(ctx: Context<'_>, #[rest] expr: String) -> Result<(), Error> { - let expr = expr.strip_prefix("```") - .and_then(|s| s.strip_suffix("```")).unwrap_or(&expr); + let expr = if expr.starts_with("```\n") { + expr.strip_prefix("```\n") + .and_then(|s| s.strip_suffix("```")) + .unwrap_or(&expr) + } else if expr.starts_with("```") { + expr.strip_prefix("```") + .and_then(|s| s.strip_suffix("```")) + .unwrap_or(&expr) + } else if expr.starts_with('`') { + expr.strip_prefix("`") + .and_then(|s| s.strip_suffix("`")) + .unwrap_or(&expr) + } else { + &expr + }; let runtime = lamm::Runtime::new(Cursor::new(expr), ""); @@ -32,4 +45,4 @@ pub async fn eval(ctx: Context<'_>, }?; Ok(()) -} +} \ No newline at end of file