From a5ee9b1edd25f698813ebdc52404ec19fa479718 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 26 Sep 2022 15:16:05 +0200 Subject: new renderer --- code/src/html.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'code/src/html.rs') diff --git a/code/src/html.rs b/code/src/html.rs index 23ac6c8..e133528 100644 --- a/code/src/html.rs +++ b/code/src/html.rs @@ -1,10 +1,9 @@ use crate::{ article_metadata, file_history, get_articles, - markdown::{self, render::blocks_to_html}, + markdown::{self}, ArticleMeta, }; use laby::{frag, html, iter, li, ul, Render}; -use pest::Parser; use std::fs::read_to_string; pub fn scaffold(title: String, body: impl Render) -> impl Render { @@ -39,9 +38,9 @@ pub fn article(path: String) -> impl Render { scaffold( article_metadata(path.clone().into()).title, frag!( - laby::raw!(blocks_to_html(markdown::parser::parse( + laby::raw!(markdown::render( &read_to_string(&path).unwrap() - ))), + )), hr!(), p!("changes to this article (as recorded with git; visible on the git repo, that i will create soon)"), pre!(file_history(&path)) @@ -70,3 +69,11 @@ pub fn index(root: &str) -> impl Render { })), ) } + +pub fn escape(text: &str) -> String { + text.replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("'", "’") + .replace("\"", """) +} -- cgit v1.2.3-70-g09d2