use vy::{DOCTYPE, IntoHtml, PreEscaped, body, div, head, html, link, meta, title}; pub(crate) fn make_page( content: impl IntoHtml, description: &str, title: Option<&str>, ) -> impl IntoHtml { ( DOCTYPE, html!( lang = "en", head!( title!(title.unwrap_or("Back")), link!(rel = "icon", href = "/favicon.ico"), link!(rel = "stylesheet", "type" = "text/css", href = "/style.css"), meta!(charset = "UTF-8"), meta!( name = "viewport", content = "width=device-width,initial-scale=1" ), meta!(name = "description", content = description), ), body!(div!(class = "content", content)) ), ) } pub(super) fn to_markdown(input: &str, is_title: bool) -> PreEscaped { let markdown = markdown::to_html(input.trim()); // If the markdown contains only one line line, assuming that it is a title is okay. if input.lines().count() == 1 && markdown.starts_with("

") && is_title { PreEscaped( markdown .strip_prefix("

") .expect("We checked") .strip_suffix("

") .expect("markdown crate produces no invalid html") .to_owned(), ) } else { PreEscaped(markdown) } }