diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2024-04-21 13:57:03 +1200 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2024-04-21 13:57:36 +1200 |
commit | 13cb719b87bcef41c4dd398f5a651ddb2b561e0d (patch) | |
tree | e9e52ed33d5ed5a4d68a1161c3db5c2d8c38dd42 /src/table.rs | |
parent | 54f5e9fd883e207931baa9c87b6181ca724d6bab (diff) | |
download | markdown-13cb719b87bcef41c4dd398f5a651ddb2b561e0d.zip |
Completely rewrite the libraryv1.0.0
Diffstat (limited to 'src/table.rs')
-rw-r--r-- | src/table.rs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/table.rs b/src/table.rs deleted file mode 100644 index cc01ffc..0000000 --- a/src/table.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::Line; - -pub struct Table { - pub columns: Vec<Column>, - pub rows: Vec<Vec<Line>>, -} - -pub struct Column { - pub name: Line, - pub alignment: Alignment, -} - -pub enum Alignment { - Left, - Center, - Right, -} -impl Alignment { - pub fn from_str(s: &str) -> Result<Self, ()> { - let mut start = false; - let mut end = false; - for (i, c) in s.chars().enumerate() { - if c == ':' { - if i == 0 { - start = true; - } else if i == s.len() - 1 { - end = true; - } else { - return Err(()); - } - } else if c != '-' { - return Err(()); - } - } - Ok(match (start, end) { - (false, false) => Self::Left, - (true, false) => Self::Left, - (false, true) => Self::Right, - (true, true) => Self::Center, - }) - } -} -impl std::fmt::Display for Alignment { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - f.write_str(match self { - Self::Left => "left", - Self::Center => "center", - Self::Right => "right", - }) - } -} -impl std::fmt::Debug for Alignment { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - f.write_str(match self { - Self::Left => "Left", - Self::Center => "Center", - Self::Right => "Right", - }) - } -} |