mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
25 lines
521 B
Rust
25 lines
521 B
Rust
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
|
|
|
pub struct List {
|
|
pub value: String,
|
|
}
|
|
|
|
impl List {
|
|
pub fn from(line: &str) -> Option<Self> {
|
|
// Parse line
|
|
let regex = Regex::split_simple(
|
|
r"^\*\s*(.+)$",
|
|
line,
|
|
RegexCompileFlags::DEFAULT,
|
|
RegexMatchFlags::DEFAULT,
|
|
);
|
|
|
|
// Detect value
|
|
let value = regex.get(1)?.trim();
|
|
|
|
// Result
|
|
Some(Self {
|
|
value: String::from(value),
|
|
})
|
|
}
|
|
}
|