mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
update value preparation, add comments
This commit is contained in:
parent
4741365154
commit
2e0a1ae3ef
1 changed files with 5 additions and 5 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
||||||
|
|
||||||
|
/// [List item](https://geminiprotocol.net/docs/gemtext-specification.gmi#list-items)
|
||||||
pub struct List {
|
pub struct List {
|
||||||
pub value: String,
|
pub value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl List {
|
impl List {
|
||||||
|
/// Parse `Self` from string
|
||||||
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(
|
||||||
|
|
@ -14,12 +16,10 @@ impl List {
|
||||||
RegexMatchFlags::DEFAULT,
|
RegexMatchFlags::DEFAULT,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Detect value
|
// Extract formatted value
|
||||||
let value = regex.get(1)?.trim();
|
let value = regex.get(1)?.trim().to_string();
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Some(Self {
|
Some(Self { value })
|
||||||
value: String::from(value),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue