diff options
| author | sigoden <sigoden@gmail.com> | 2024-03-03 09:57:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-03 09:57:50 +0800 |
| commit | 8421f23b450643ca3c66cb3f6fd21ef862a2369d (patch) | |
| tree | d64addd1104a01f3d60193f9912b4d0a3508edf3 /src/utils/mod.rs | |
| parent | b2f86f2899b79b291eb56435f99402509105b7ec (diff) | |
| download | aichat-8421f23b450643ca3c66cb3f6fd21ef862a2369d.tar.gz | |
feat: allow overriding execute/code role (#331)
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 8 |
1 files changed, 6 insertions, 2 deletions
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)] |
