diff options
author | metamuffin <metamuffin@disroot.org> | 2022-08-29 17:26:42 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-08-29 17:26:42 +0200 |
commit | bde6205cd1b268094460c90ccfb7610e52be5dc1 (patch) | |
tree | 3af1cc3c7fffcbe8b32062bc7ec1e0a375823563 | |
parent | 7853c8a551806007c3697a38fa5f929ca45a0985 (diff) | |
download | metamuffin-blog-bde6205cd1b268094460c90ccfb7610e52be5dc1.tar metamuffin-blog-bde6205cd1b268094460c90ccfb7610e52be5dc1.tar.bz2 metamuffin-blog-bde6205cd1b268094460c90ccfb7610e52be5dc1.tar.zst |
test
-rw-r--r-- | code/src/main.rs | 41 | ||||
-rw-r--r-- | content/articles/2022-08-29-blog-start.md | 14 | ||||
-rw-r--r-- | content/articles/2022-08-29-blog-test.md | 22 | ||||
-rw-r--r-- | content/makefile | 2 |
4 files changed, 58 insertions, 21 deletions
diff --git a/code/src/main.rs b/code/src/main.rs index 09ce3d8..bbc0e89 100644 --- a/code/src/main.rs +++ b/code/src/main.rs @@ -6,7 +6,7 @@ use std::{ use clap::{Parser, Subcommand}; use laby::{html, internal::Buffer, iter, li, raw, ul, Render}; -use markdown::{Block, Span}; +use markdown::{Block, ListItem, Span}; #[derive(Parser)] struct Args { @@ -50,7 +50,10 @@ fn write_output(t: &Option<String>, o: String) { fn scaffold(title: String, body: impl Render) -> impl Render { html!( - head!(title!(title)), + head!( + link!(rel = "stylesheet", href = "./style.css"), + title!(title) + ), body!( nav!(h2!("metamuffin's blog"), a!(href = "./index.html", "index")), article!(body) @@ -97,7 +100,7 @@ fn span_to_html(ss: Vec<Span>) -> String { out += match s { Span::Break => format!("<br/>"), Span::Text(t) => escape(&t), - Span::Code(c) => format!("<pre><code>{}</code></pre>", escape(&c)), + Span::Code(c) => format!("<code>{}</code>", escape(&c)), Span::Link(text, url, _) => { format!("<a href=\"{}\">{}</a>", escape(&url), escape(&text)) } @@ -119,10 +122,36 @@ fn blocks_to_html(blocks: Vec<Block>) -> String { markdown::Block::Paragraph(p) => format!("<p>{}</p>", span_to_html(p)), markdown::Block::Blockquote(q) => format!("<quote>{}</quote>", blocks_to_html(q)), markdown::Block::CodeBlock(_syntax, content) => { - format!("<pre><code>{}</code></pre>", escape(&content)) // TODO syntax highlighting + format!("<code><pre>{}</pre></code>", escape(&content)) // TODO syntax highlighting + } + markdown::Block::OrderedList(els, _) => format!( + "<ol>{}</ol>", + els.into_iter() + .map(|e| format!( + "<li>{}</li>", + match e { + ListItem::Simple(s) => span_to_html(s), + ListItem::Paragraph(b) => blocks_to_html(b), + } + )) + .collect::<Vec<_>>() + .join("") + ), + markdown::Block::UnorderedList(els) => { + format!( + "<ul>{}</ul>", + els.into_iter() + .map(|e| format!( + "<li>{}</li>", + match e { + ListItem::Simple(s) => span_to_html(s), + ListItem::Paragraph(b) => blocks_to_html(b), + } + )) + .collect::<Vec<_>>() + .join("") + ) } - markdown::Block::OrderedList(_, _) => todo!(), - markdown::Block::UnorderedList(_) => todo!(), markdown::Block::Raw(r) => r, markdown::Block::Hr => format!("<hr/>"), } diff --git a/content/articles/2022-08-29-blog-start.md b/content/articles/2022-08-29-blog-start.md deleted file mode 100644 index 49c3ba6..0000000 --- a/content/articles/2022-08-29-blog-start.md +++ /dev/null @@ -1,14 +0,0 @@ -# Blog test - -Hello world! - -## heading - -_italic_ **bold** `code` - -### sub heading - -``` -code -block -``` diff --git a/content/articles/2022-08-29-blog-test.md b/content/articles/2022-08-29-blog-test.md new file mode 100644 index 0000000..6cbe4fd --- /dev/null +++ b/content/articles/2022-08-29-blog-test.md @@ -0,0 +1,22 @@ +# Blog test + +Hello world! + +## heading + +_italic_ **bold** `code` [Link](https://metamuffin.org/) + +### sub heading + +``` +code +block +``` + +- list +- list +- list + +1. first this +2. then that +3. done diff --git a/content/makefile b/content/makefile index 1d87267..84e109f 100644 --- a/content/makefile +++ b/content/makefile @@ -1 +1 @@ -include ../tools/makefile
\ No newline at end of file +include ../code/makefile
\ No newline at end of file |