|
|
@ -2,6 +2,7 @@ use snekdown::format::html::ToHtml;
|
|
|
|
use snekdown::parser::Parser;
|
|
|
|
use snekdown::parser::Parser;
|
|
|
|
use std::fs::write;
|
|
|
|
use std::fs::write;
|
|
|
|
use std::time::Instant;
|
|
|
|
use std::time::Instant;
|
|
|
|
|
|
|
|
use termion::style;
|
|
|
|
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use structopt::StructOpt;
|
|
|
|
use structopt::StructOpt;
|
|
|
@ -12,7 +13,7 @@ struct Opt {
|
|
|
|
input: PathBuf,
|
|
|
|
input: PathBuf,
|
|
|
|
#[structopt(parse(from_os_str))]
|
|
|
|
#[structopt(parse(from_os_str))]
|
|
|
|
output: PathBuf,
|
|
|
|
output: PathBuf,
|
|
|
|
#[structopt(short, long)]
|
|
|
|
#[structopt(short, long, default_value = "html")]
|
|
|
|
format: String,
|
|
|
|
format: String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -21,9 +22,12 @@ fn main() {
|
|
|
|
let start = Instant::now();
|
|
|
|
let start = Instant::now();
|
|
|
|
let mut parser = Parser::new_from_file(opt.input.to_str().unwrap().to_string()).unwrap();
|
|
|
|
let mut parser = Parser::new_from_file(opt.input.to_str().unwrap().to_string()).unwrap();
|
|
|
|
let document = parser.parse();
|
|
|
|
let document = parser.parse();
|
|
|
|
println!("Total duration: {:?}", start.elapsed());
|
|
|
|
println!("{}Parsing took: {:?}", style::Italic, start.elapsed());
|
|
|
|
|
|
|
|
let start_render = Instant::now();
|
|
|
|
match opt.format.as_str() {
|
|
|
|
match opt.format.as_str() {
|
|
|
|
"html" => write(opt.output.to_str().unwrap(), document.to_html()).unwrap(),
|
|
|
|
"html" => write(opt.output.to_str().unwrap(), document.to_html()).unwrap(),
|
|
|
|
_ => println!("Unknown format {}", opt.format),
|
|
|
|
_ => println!("Unknown format {}", opt.format),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("Rendering took: {:?}", start_render.elapsed());
|
|
|
|
|
|
|
|
println!("Total: {:?}{}", start.elapsed(), style::Reset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|