initial commit

This commit is contained in:
yggverse 2024-10-18 19:16:25 +03:00
parent c608e711c4
commit 7df3bfeb91
11 changed files with 334 additions and 0 deletions

View file

@ -0,0 +1,29 @@
use gtk::glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags};
pub struct Inline {
pub value: GString,
}
impl Inline {
pub fn from(line: &str) -> Option<Self> {
// Parse line
let regex = Regex::split_simple(
r"^`{3}([^`]*)`{3}$",
line,
RegexCompileFlags::DEFAULT,
RegexMatchFlags::DEFAULT,
);
// Detect value
let value = regex.get(1)?;
if value.trim().is_empty() {
return None;
}
// Result
Some(Self {
value: GString::from(value.as_str()),
})
}
}