Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Dec 3, 2024
1 parent 2e0a1ae commit 155247a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/line/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()),
Expand Down
4 changes: 4 additions & 0 deletions src/line/code/inline.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
5 changes: 5 additions & 0 deletions src/line/code/multiline.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
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,
pub completed: bool,
}

impl Multiline {
// Constructors

/// Search in line for tag open,
/// return Self constructed on success or None
pub fn begin_from(line: &str) -> Option<Self> {
Expand Down
5 changes: 5 additions & 0 deletions src/line/header.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 4 additions & 0 deletions src/line/link.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/line/list.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/line/quote.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down

0 comments on commit 155247a

Please sign in to comment.