diff --git a/source/test.md b/source/test.md index 5bdf4a5..3dc1590 100644 --- a/source/test.md +++ b/source/test.md @@ -9,7 +9,8 @@ mydata: 123 -- ненумерованный список, элемент 1 +- ненумерованный список, элемент 1, + даже с продолжением - элемент 2 - element 3 @@ -21,9 +22,13 @@ mydata: 123 - [ ] Todo - [ ] Won't fix +[[x] Task inside link](https://dc09.ru) + > [!WARNING] > > Some important quote +> continuing here \ +> With line break text text text `inline code` text text text diff --git a/src/markdown.rs b/src/markdown.rs index d4f6351..0ea80de 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -16,12 +16,15 @@ pub fn compile_markdown( let mut gmi = create_file(gmi)?; let mut state = State::Start; + let mut ol = false; // ordered list let mut counter: u64 = 0; let mut links: Vec> = vec![]; for event in Parser::new_ext(&src_text, Options::all()) { use pulldown_cmark::Event::*; + dbg!(&event); + match event { Start(tag) => { use pulldown_cmark::{CodeBlockKind, HeadingLevel, Tag::*}; @@ -29,9 +32,7 @@ pub fn compile_markdown( match tag { Paragraph => { html.write_all(b"

")?; - if state != State::Start { - gmi.write_all(b"\r\n\r\n")?; - } + write_paragraph_start(&mut gmi, state)?; } Heading { level, id, .. } => { @@ -41,95 +42,110 @@ pub fn compile_markdown( html.write_fmt(format_args!("<{}>", level))?; } + write_paragraph_start(&mut gmi, state)?; let hashes = match level { HeadingLevel::H1 => "# ", HeadingLevel::H2 => "## ", _ => "### ", }; gmi.write_all(hashes.as_bytes())?; - state = State::GmiPrefix(hashes); + state = State::Paragraph; } BlockQuote(_kind) => { html.write_all(b"

")?; + + write_paragraph_start(&mut gmi, state)?; gmi.write_all(b"> ")?; - state = State::GmiPrefix("> "); + state = State::Quote; } CodeBlock(CodeBlockKind::Fenced(lang)) => { - html.write_all(b"
")?;
                         // TODO: highlighting with syntect
+                        html.write_all(b"
")?;
+
+                        write_paragraph_start(&mut gmi, state)?;
                         gmi.write_fmt(format_args!("```{}\r\n", lang))?;
                     }
 
                     CodeBlock(CodeBlockKind::Indented) => {
                         html.write_all(b"
")?;
+
+                        write_paragraph_start(&mut gmi, state)?;
                         gmi.write_all(b"```")?;
                     }
 
                     List(None) => {
                         html.write_all(b"