|
|
@ -1,4 +1,5 @@
|
|
|
|
use crate::elements::*;
|
|
|
|
use crate::elements::*;
|
|
|
|
|
|
|
|
use minify::html::minify;
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! combine_with_lb {
|
|
|
|
macro_rules! combine_with_lb {
|
|
|
|
($a:expr, $b:expr) => {
|
|
|
|
($a:expr, $b:expr) => {
|
|
|
@ -60,9 +61,9 @@ impl ToHtml for Document {
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.fold("".to_string(), |a, b| format!("{}{}", a, b.to_html()));
|
|
|
|
.fold("".to_string(), |a, b| format!("{}{}", a, b.to_html()));
|
|
|
|
if self.is_root {
|
|
|
|
if self.is_root {
|
|
|
|
let style = std::include_str!("assets/style.css");
|
|
|
|
let style = minify(std::include_str!("assets/style.css"));
|
|
|
|
format!(
|
|
|
|
format!(
|
|
|
|
"<html><head><style>{}</style></head><body><div class='content'>{}</div></body></html>",
|
|
|
|
"<!DOCTYPE html>\n<html><head><style>{}</style></head><body><div class='content'>{}</div></body></html>",
|
|
|
|
style, inner
|
|
|
|
style, inner
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -107,7 +108,7 @@ impl ToHtml for Paragraph {
|
|
|
|
.elements
|
|
|
|
.elements
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.fold("".to_string(), |a, b| combine_with_lb!(a, b));
|
|
|
|
.fold("".to_string(), |a, b| combine_with_lb!(a, b));
|
|
|
|
format!("<p>{}</p>", inner)
|
|
|
|
minify(format!("<p>{}</p>", inner).as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -190,11 +191,11 @@ impl ToHtml for Quote {
|
|
|
|
.fold("".to_string(), |a, b| combine_with_lb!(a, b));
|
|
|
|
.fold("".to_string(), |a, b| combine_with_lb!(a, b));
|
|
|
|
if let Some(meta) = self.metadata.clone() {
|
|
|
|
if let Some(meta) = self.metadata.clone() {
|
|
|
|
format!(
|
|
|
|
format!(
|
|
|
|
"<div><blockquote>{}</blockquote><span>- {}</span></div>",
|
|
|
|
"<div class='quote'><blockquote>{}</blockquote><span class='metadata'>{}</span></div>",
|
|
|
|
text, meta.data
|
|
|
|
text, meta.data
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
format!("<blockquote>{}</blockquote>", text)
|
|
|
|
format!("<div class='quote'><blockquote>{}</blockquote></div>", text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|