diff --git a/src/line/code.rs b/src/line/code.rs index d213e00..4d5e21b 100644 --- a/src/line/code.rs +++ b/src/line/code.rs @@ -1,33 +1,5 @@ -pub mod error; pub mod inline; pub mod multiline; -pub use error::Error; -use inline::Inline; -use multiline::Multiline; - -pub struct Code { - // nothing yet.. -} - -impl Code { - // Constructors - - /// Parse inline `Self` from string - pub fn inline_from(line: &str) -> Option { - Inline::from(line) - } - - /// Begin multi-line parse `Self` from string - pub fn multiline_begin_from(line: &str) -> Option { - 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(()), - Err(e) => Err(Error::Multiline(e)), - } - } -} +pub use inline::Inline; +pub use multiline::Multiline; diff --git a/src/line/code/error.rs b/src/line/code/error.rs deleted file mode 100644 index 410dfe3..0000000 --- a/src/line/code/error.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::fmt::{Display, Formatter, Result}; - -#[derive(Debug)] -pub enum Error { - Multiline(crate::line::code::multiline::Error), -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> Result { - match self { - Self::Multiline(e) => { - write!(f, "Multiline error: {e}") - } - } - } -} diff --git a/src/line/code/inline.rs b/src/line/code/inline.rs index 7607595..9e94394 100644 --- a/src/line/code/inline.rs +++ b/src/line/code/inline.rs @@ -8,7 +8,7 @@ pub struct Inline { impl Inline { // Constructors - /// Parse `Self` from string + /// Parse `Self` from line string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple( diff --git a/src/line/code/multiline.rs b/src/line/code/multiline.rs index 2662a94..16e95a6 100644 --- a/src/line/code/multiline.rs +++ b/src/line/code/multiline.rs @@ -16,7 +16,7 @@ pub struct Multiline { impl Multiline { // Constructors - /// Search in line for tag open, + /// Search in line string for tag open, /// return Self constructed on success or None pub fn begin_from(line: &str) -> Option { if line.starts_with(TAG) { @@ -35,7 +35,7 @@ impl Multiline { None } - /// Continue preformatted buffer from line, + /// Continue preformatted buffer from line string, /// set `completed` as True on close tag found pub fn continue_from(&mut self, line: &str) -> Result<(), Error> { // Make sure buffer not completed yet diff --git a/src/line/header.rs b/src/line/header.rs index 1bf3e72..2e8eb6a 100644 --- a/src/line/header.rs +++ b/src/line/header.rs @@ -16,7 +16,7 @@ pub struct Header { impl Header { // Constructors - /// Parse `Self` from string + /// Parse `Self` from line string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple( diff --git a/src/line/link.rs b/src/line/link.rs index fdd3cd1..26c2726 100644 --- a/src/line/link.rs +++ b/src/line/link.rs @@ -11,7 +11,7 @@ pub struct Link { impl Link { // Constructors - /// Parse `Self` from string + /// Parse `Self` from line string pub fn from(line: &str, base: Option<&Uri>, timezone: Option<&TimeZone>) -> Option { // Define initial values let mut alt = None; diff --git a/src/line/list.rs b/src/line/list.rs index e2fc029..2a1f328 100644 --- a/src/line/list.rs +++ b/src/line/list.rs @@ -8,7 +8,7 @@ pub struct List { impl List { // Constructors - /// Parse `Self` from string + /// Parse `Self` from line string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple( diff --git a/src/line/quote.rs b/src/line/quote.rs index 9434305..aeef786 100644 --- a/src/line/quote.rs +++ b/src/line/quote.rs @@ -8,7 +8,7 @@ pub struct Quote { impl Quote { // Constructors - /// Parse `Self` from string + /// Parse `Self` from line string pub fn from(line: &str) -> Option { // Parse line let regex = Regex::split_simple( diff --git a/tests/integration.rs b/tests/integration.rs index 5ba2cda..c1b88a7 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,5 +1,5 @@ use ggemtext::line::{ - code::{inline::Inline, multiline::Multiline, Code}, + code::{inline::Inline, multiline::Multiline}, header::{Header, Level}, link::Link, list::List, @@ -36,7 +36,7 @@ fn gemtext() { // Parse document by line for line in gemtext.lines() { // Inline code - if let Some(result) = Code::inline_from(line) { + if let Some(result) = Inline::from(line) { code_inline.push(result); continue; } @@ -44,13 +44,13 @@ fn gemtext() { // Multiline code match code_multiline_buffer { None => { - if let Some(code) = Code::multiline_begin_from(line) { + if let Some(code) = Multiline::begin_from(line) { code_multiline_buffer = Some(code); continue; } } Some(ref mut result) => { - assert!(Code::multiline_continue_from(result, line).is_ok()); + assert!(Multiline::continue_from(result, line).is_ok()); if result.completed { code_multiline.push(code_multiline_buffer.take().unwrap()); code_multiline_buffer = None;