mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 09:05:32 +00:00
add comments
This commit is contained in:
parent
2e0a1ae3ef
commit
155247a2ea
7 changed files with 30 additions and 3 deletions
|
|
@ -11,16 +11,19 @@ pub struct Code {
|
|||
}
|
||||
|
||||
impl Code {
|
||||
// Inline
|
||||
// Constructors
|
||||
|
||||
/// Parse inline `Self` from string
|
||||
pub fn inline_from(line: &str) -> Option<Inline> {
|
||||
Inline::from(line)
|
||||
}
|
||||
|
||||
// Multiline
|
||||
/// Begin multi-line parse `Self` from string
|
||||
pub fn multiline_begin_from(line: &str) -> Option<Multiline> {
|
||||
Multiline::begin_from(line)
|
||||
}
|
||||
|
||||
/// Continue multi-line parse `Self` from string
|
||||
pub fn multiline_continue_from(this: &mut Multiline, line: &str) -> Result<(), Error> {
|
||||
match Multiline::continue_from(this, line) {
|
||||
Ok(()) => Ok(()),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
||||
|
||||
/// Inline [preformatted](https://geminiprotocol.net/docs/gemtext-specification.gmi#in-pre-formatted-mode) entity holder
|
||||
pub struct Inline {
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl Inline {
|
||||
// Constructors
|
||||
|
||||
/// Parse `Self` from string
|
||||
pub fn from(line: &str) -> Option<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
// Shared defaults
|
||||
|
||||
pub const NEW_LINE: char = '\n';
|
||||
pub const TAG: &str = "```";
|
||||
|
||||
/// Multi-line [preformatted](https://geminiprotocol.net/docs/gemtext-specification.gmi#in-pre-formatted-mode) entity holder
|
||||
pub struct Multiline {
|
||||
pub alt: Option<String>,
|
||||
pub value: String,
|
||||
|
|
@ -11,6 +14,8 @@ pub struct Multiline {
|
|||
}
|
||||
|
||||
impl Multiline {
|
||||
// Constructors
|
||||
|
||||
/// Search in line for tag open,
|
||||
/// return Self constructed on success or None
|
||||
pub fn begin_from(line: &str) -> Option<Self> {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
use glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags};
|
||||
|
||||
/// [Header](https://geminiprotocol.net/docs/gemtext-specification.gmi#heading-lines) type holder
|
||||
pub enum Level {
|
||||
H1,
|
||||
H2,
|
||||
H3,
|
||||
}
|
||||
|
||||
/// [Header](https://geminiprotocol.net/docs/gemtext-specification.gmi#heading-lines) entity holder
|
||||
pub struct Header {
|
||||
pub value: GString,
|
||||
pub level: Level,
|
||||
}
|
||||
|
||||
impl Header {
|
||||
// Constructors
|
||||
|
||||
/// Parse `Self` from string
|
||||
pub fn from(line: &str) -> Option<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use glib::{DateTime, Regex, RegexCompileFlags, RegexMatchFlags, TimeZone, Uri, UriFlags};
|
||||
|
||||
/// [Link](https://geminiprotocol.net/docs/gemtext-specification.gmi#link-lines) entity holder
|
||||
pub struct Link {
|
||||
pub alt: Option<String>, // [optional] alternative link description
|
||||
pub is_external: Option<bool>, // [optional] external link indication, on base option provided
|
||||
|
|
@ -8,6 +9,9 @@ pub struct Link {
|
|||
}
|
||||
|
||||
impl Link {
|
||||
// Constructors
|
||||
|
||||
/// Parse `Self` from string
|
||||
pub fn from(line: &str, base: Option<&Uri>, timezone: Option<&TimeZone>) -> Option<Self> {
|
||||
// Define initial values
|
||||
let mut alt = None;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
||||
|
||||
/// [List item](https://geminiprotocol.net/docs/gemtext-specification.gmi#list-items)
|
||||
/// [List](https://geminiprotocol.net/docs/gemtext-specification.gmi#list-items) entity holder
|
||||
pub struct List {
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl List {
|
||||
// Constructors
|
||||
|
||||
/// Parse `Self` from string
|
||||
pub fn from(line: &str) -> Option<Self> {
|
||||
// Parse line
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
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 string
|
||||
pub fn from(line: &str) -> Option<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue