mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
remove middle-level code api, update comments
This commit is contained in:
parent
d739181a76
commit
84c72ae3a3
9 changed files with 13 additions and 57 deletions
|
|
@ -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> {
|
||||
Inline::from(line)
|
||||
}
|
||||
|
||||
/// 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(()),
|
||||
Err(e) => Err(Error::Multiline(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
pub use inline::Inline;
|
||||
pub use multiline::Multiline;
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
|
|
@ -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<Self> {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
|
|
@ -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<Self> {
|
||||
// Define initial values
|
||||
let mut alt = None;
|
||||
|
|
|
|||
|
|
@ -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<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
|
|
@ -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<Self> {
|
||||
// Parse line
|
||||
let regex = Regex::split_simple(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue