diff --git a/Cargo.lock b/Cargo.lock
index 0fef12b..21deb62 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,24 @@
# It is not intended for manual editing.
version = 4
+[[package]]
+name = "markdown"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5cab8f2cadc416a82d2e783a1946388b31654d391d1c7d92cc1f03e295b1deb"
+dependencies = [
+ "unicode-id",
+]
+
[[package]]
name = "mdf-blog"
version = "0.1.0"
+dependencies = [
+ "markdown",
+]
+
+[[package]]
+name = "unicode-id"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ba288e709927c043cbe476718d37be306be53fb1fafecd0dbe36d072be2580"
diff --git a/Cargo.toml b/Cargo.toml
index 2f4db7a..be73476 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2024"
[dependencies]
+markdown = "*"
diff --git a/src/main.rs b/src/main.rs
index c3eaaf3..bfe2b6d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,80 +1,8 @@
-fn header(i: &str) -> Option<(&str, String)> {
- let mut itr = i.chars();
- if let Some(next) = itr.next() && next == '\n' {
- if let Some(maybe_star) = itr.skip_while(|c| *c == ' ' || *c == '\t').next() && maybe_star == '*' {
-
- }
- }
- Some((i, "
".to_string()))
-}
+use markdown::to_html;
fn main() {
// arg 1: src, arg 2: dest
let args: Vec = std::env::args().collect();
let input: String = std::fs::read_to_string(&args[1]).unwrap();
- let mut output: String = String::new();
-
- let mut is_bold = false;
- let mut title: Option = None;
-
- let mut itr = input.chars().peekable();
- while let Some(c) = itr.next() {
- match c {
- '*' => {
- if !is_bold {
- output.push_str("");
- is_bold = true;
- } else {
- output.push_str("");
- is_bold = false;
- }
- }
- '\n' => {
- if let Some(title_count) = title {
- title = None;
- output.push_str(&format!(""));
- } else {
- let mut title_count = 0;
- while let Some(c) = itr.peek() {
- if *c == '#' {
- title_count += 1;
- } else if *c == ' ' || *c == '\t' {
- // it is title
- output.push_str(&format!(""));
- title = Some(title_count);
- } else {
-
- }
- }
- }
- output.push('\n');
- }
- _ => {
- output.push(c);
- }
- }
- }
- println!("{output}");
-
- //let output: String = input.lines().map(|l| {
- // // Titles
- // let count = l.chars().take_while(|c| *c == '#').count();
- // if count > 0 {
- // format!("{}", &l[count..])
- // } else {
- // l.to_string()
- // }
- //})
- //.map(|l| {
- // if l.chars().skip_while(|c| *c == ' ' || *c == '\t').next().unwrap_or('g') == '*' {
- //
- // } else {
- // l.to_string()
- // }
- //})
- //.collect();
-
- // headings: replace # - newline to -
-
- //println!("{}", output);
+ print!("{}", to_html(&input));
}