remove extra condition by regex change

This commit is contained in:
yggverse 2024-12-03 19:38:39 +02:00
parent facb90dfa9
commit f08ae77b7c

View file

@ -12,22 +12,15 @@ impl Inline {
pub fn from(line: &str) -> Option<Self> { pub fn from(line: &str) -> Option<Self> {
// Parse line // Parse line
let regex = Regex::split_simple( let regex = Regex::split_simple(
r"^`{3}([^`]*)`{3}$", r"^`{3}([^`]+)`{3}$",
line, line,
RegexCompileFlags::DEFAULT, RegexCompileFlags::DEFAULT,
RegexMatchFlags::DEFAULT, RegexMatchFlags::DEFAULT,
); );
// Extract formatted value // Extract formatted value
let value = regex.get(1)?.trim();
if value.is_empty() {
return None;
}
// Result
Some(Self { Some(Self {
value: value.to_string(), value: regex.get(1)?.trim().to_string(),
}) })
} }
} }