From 1dfd885ae38bfbb117dd2058e5223079095f8569 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 18 Sep 2020 17:19:14 -0400 Subject: [PATCH] more mara tests --- blog/mara-test.markdown | 5 ++- src/app/markdown.rs | 10 +++-- templates/blogpost.rs.html | 75 +++++++++++++++++++------------------- templates/mara.rs.html | 4 +- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/blog/mara-test.markdown b/blog/mara-test.markdown index bd0298e..aa321eb 100644 --- a/blog/mara-test.markdown +++ b/blog/mara-test.markdown @@ -8,8 +8,9 @@ date: 2020-09-18 [But if you do this thing, what about that other thing?](conversation://Mara/hmm) -[If you like using this, be sure to check out this other thing: -https://h.christine.website](conversation://Mara/hacker) +[If you like using this, be sure to check out this other thing, it is +cool!](conversation://Mara/hacker) [But, how does that make sense if you refrobnicated the bifrucated flopnax back there?](conversation://Mara/wat) diff --git a/src/app/markdown.rs b/src/app/markdown.rs index 996e764..fe33a21 100644 --- a/src/app/markdown.rs +++ b/src/app/markdown.rs @@ -1,7 +1,8 @@ use color_eyre::eyre::{Result, WrapErr}; use comrak::nodes::{Ast, AstNode, NodeValue}; -use comrak::{format_html, parse_document, Arena, ComrakOptions}; +use comrak::{format_html, parse_document, markdown_to_html, Arena, ComrakOptions}; use std::cell::RefCell; +use crate::templates::Html; use url::Url; pub fn render(inp: &str) -> Result { @@ -31,13 +32,16 @@ pub fn render(inp: &str) -> Result { let parent = node.parent().unwrap(); node.detach(); let mut message = vec![]; - format_html(node.first_child().unwrap(), &options, &mut message)?; + for child in node.children() { + format_html(child, &options, &mut message)?; + } let message = std::str::from_utf8(&message)?; + let message = markdown_to_html(message, &options); let mood = without_first(u.path()); let name = u.host_str().unwrap_or("Mara"); let mut html = vec![]; - crate::templates::mara(&mut html, mood, name, message)?; + crate::templates::mara(&mut html, mood, name, Html(message))?; let new_node = arena.alloc(AstNode::new(RefCell::new(Ast::new(NodeValue::HtmlInline(html))))); diff --git a/templates/blogpost.rs.html b/templates/blogpost.rs.html index 6b55850..d90a8e3 100644 --- a/templates/blogpost.rs.html +++ b/templates/blogpost.rs.html @@ -62,61 +62,62 @@

Tags: @for tag in post.front_matter.tags.as_ref().unwrap() { @tag }

} - @:footer_html() diff --git a/templates/mara.rs.html b/templates/mara.rs.html index 63f3507..c26f926 100644 --- a/templates/mara.rs.html +++ b/templates/mara.rs.html @@ -1,4 +1,4 @@ -@(mood: &str, character: &str, message: &str) +@(mood: &str, character: &str, message: Html)
@@ -9,6 +9,6 @@
-

@character

@message
+

@character

@message