From bde6205cd1b268094460c90ccfb7610e52be5dc1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 29 Aug 2022 17:26:42 +0200 Subject: test --- code/src/main.rs | 41 ++++++++++++++++++++++++++----- content/articles/2022-08-29-blog-start.md | 14 ----------- content/articles/2022-08-29-blog-test.md | 22 +++++++++++++++++ content/makefile | 2 +- 4 files changed, 58 insertions(+), 21 deletions(-) delete mode 100644 content/articles/2022-08-29-blog-start.md create mode 100644 content/articles/2022-08-29-blog-test.md 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, 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) -> String { out += match s { Span::Break => format!("
"), Span::Text(t) => escape(&t), - Span::Code(c) => format!("
{}
", escape(&c)), + Span::Code(c) => format!("{}", escape(&c)), Span::Link(text, url, _) => { format!("{}", escape(&url), escape(&text)) } @@ -119,10 +122,36 @@ fn blocks_to_html(blocks: Vec) -> String { markdown::Block::Paragraph(p) => format!("

{}

", span_to_html(p)), markdown::Block::Blockquote(q) => format!("{}", blocks_to_html(q)), markdown::Block::CodeBlock(_syntax, content) => { - format!("
{}
", escape(&content)) // TODO syntax highlighting + format!("
{}
", escape(&content)) // TODO syntax highlighting + } + markdown::Block::OrderedList(els, _) => format!( + "
    {}
", + els.into_iter() + .map(|e| format!( + "
  • {}
  • ", + match e { + ListItem::Simple(s) => span_to_html(s), + ListItem::Paragraph(b) => blocks_to_html(b), + } + )) + .collect::>() + .join("") + ), + markdown::Block::UnorderedList(els) => { + format!( + "
      {}
    ", + els.into_iter() + .map(|e| format!( + "
  • {}
  • ", + match e { + ListItem::Simple(s) => span_to_html(s), + ListItem::Paragraph(b) => blocks_to_html(b), + } + )) + .collect::>() + .join("") + ) } - markdown::Block::OrderedList(_, _) => todo!(), - markdown::Block::UnorderedList(_) => todo!(), markdown::Block::Raw(r) => r, markdown::Block::Hr => format!("
    "), } 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 -- cgit v1.2.3-70-g09d2