diff --git a/Cargo.lock b/Cargo.lock index 79f40b8c..5b6b3458 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -769,6 +769,7 @@ dependencies = [ "hashbrown", "hex", "hhmmss", + "horrorshow", "hyper", "is_elevated", "itertools", @@ -827,6 +828,12 @@ dependencies = [ "time 0.2.27", ] +[[package]] +name = "horrorshow" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8371fb981840150b1a54f7cb117bf6699f7466a1d4861daac33bc6fe2b5abea0" + [[package]] name = "http" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index bf36ee69..f1435d16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ num-format = "*" comfy-table = "6.*" pulldown-cmark = { version = "0.9.*", default-features = false, features = ["simd"] } reqwest = {version = "0.11.*", features = ["blocking", "json"]} +horrorshow = "0.8.*" [build-dependencies] static_vcruntime = "2.*" diff --git a/src/lib.rs b/src/lib.rs index 45a8b1e5..db666270 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,3 +8,5 @@ pub mod timeline; pub mod yaml; #[macro_use] extern crate prettytable; +#[macro_use] +extern crate horrorshow; diff --git a/src/options/htmlreport.rs b/src/options/htmlreport.rs index db8e9ebc..673796f4 100644 --- a/src/options/htmlreport.rs +++ b/src/options/htmlreport.rs @@ -8,6 +8,8 @@ use std::io::BufWriter; use std::io::Write; use std::path::Path; use std::sync::RwLock; +use horrorshow::prelude::*; +use horrorshow::helper::doctype; lazy_static! { pub static ref HTML_REPORTER: RwLock = RwLock::new(HtmlReporter::new()); @@ -103,7 +105,18 @@ pub fn create_html_file(input_html: String, path_str: String) { return; } let mut html_writer = BufWriter::new(File::create(path).unwrap()); - writeln!(html_writer, "{}", input_html).ok(); + let html_data = format!("{}", html! { + : doctype::HTML; + html { + head { + meta(charset="UTF-8"); + link(rel="stylesheet", type="text/css", href="./hayabusa_report.css"); + } + body : Raw(input_html.clone().as_str()) + } + }); + + writeln!(html_writer,"{}", html_data).ok(); println!( "HTML Report was generated. Please check {} for details.", path_str