From 8421f23b450643ca3c66cb3f6fd21ef862a2369d Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 3 Mar 2024 09:57:50 +0800 Subject: feat: allow overriding execute/code role (#331) --- src/utils/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/utils') diff --git a/src/utils/mod.rs b/src/utils/mod.rs index da98cc6..15af4ca 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -17,7 +17,7 @@ use std::env; use std::process::Command; lazy_static! { - static ref CODE_BLOCK_RE: Regex = Regex::new(r"(?ms)```\w*(.*?)```").unwrap(); + pub static ref CODE_BLOCK_RE: Regex = Regex::new(r"(?ms)```\w*(.*)```").unwrap(); } pub fn now() -> String { @@ -165,7 +165,11 @@ pub fn extract_block(input: &str) -> String { .map(|m| String::from(m.as_str())) }) .collect(); - output.trim().to_string() + if output.is_empty() { + input.trim().to_string() + } else { + output.trim().to_string() + } } #[cfg(test)] -- cgit v1.2.3