better code block parsing
This commit is contained in:
@@ -7,8 +7,21 @@ pub async fn eval(ctx: Context<'_>,
|
|||||||
#[rest]
|
#[rest]
|
||||||
expr: String) -> Result<(), Error>
|
expr: String) -> Result<(), Error>
|
||||||
{
|
{
|
||||||
let expr = expr.strip_prefix("```")
|
let expr = if expr.starts_with("```\n") {
|
||||||
.and_then(|s| s.strip_suffix("```")).unwrap_or(&expr);
|
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), "<eval>");
|
let runtime = lamm::Runtime::new(Cursor::new(expr), "<eval>");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user