mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
27 lines
659 B
Rust
27 lines
659 B
Rust
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
|
|
|
/// [Quote](https://geminiprotocol.net/docs/gemtext-specification.gmi#quote-lines) entity holder
|
|
pub struct Quote {
|
|
pub value: String,
|
|
}
|
|
|
|
impl Quote {
|
|
// Constructors
|
|
|
|
/// Parse `Self` from line string
|
|
pub fn from(line: &str) -> Option<Self> {
|
|
// Parse line
|
|
let regex = Regex::split_simple(
|
|
r"^>\s*(.+)$",
|
|
line,
|
|
RegexCompileFlags::DEFAULT,
|
|
RegexMatchFlags::DEFAULT,
|
|
);
|
|
|
|
// Extract formatted value
|
|
let value = regex.get(1)?.trim().to_string();
|
|
|
|
// Result
|
|
Some(Self { value })
|
|
}
|
|
}
|