print status

This commit is contained in:
Crispy 2024-04-26 19:28:28 +02:00
parent 000ec1e114
commit c785aa3ac8

View file

@ -8,6 +8,8 @@ use std::{
const SRC_DIR: &str = "write"; const SRC_DIR: &str = "write";
const OUT_DIR: &str = "site"; const OUT_DIR: &str = "site";
const CONTENT_MARKER: &str = "CONTENT HERE";
type Result = core::result::Result<(), Box<dyn Error>>; type Result = core::result::Result<(), Box<dyn Error>>;
fn main() -> Result { fn main() -> Result {
@ -56,7 +58,7 @@ fn convert_file(path: &Path) -> Result {
html += "</pre>\n"; html += "</pre>\n";
state = S::None; state = S::None;
continue; continue;
} else { }
if state == S::P { if state == S::P {
html += "</p>\n"; html += "</p>\n";
} }
@ -64,7 +66,6 @@ fn convert_file(path: &Path) -> Result {
html += "<pre>\n"; html += "<pre>\n";
continue; continue;
} }
}
if state == S::Code { if state == S::Code {
html += line; html += line;
@ -99,11 +100,11 @@ fn convert_file(path: &Path) -> Result {
} }
let template = read_to_string("template.html")?; let template = read_to_string("template.html")?;
let html = template.replace("CONTENT HERE", &html); let html = template.replacen(CONTENT_MARKER, &html, 1);
let mut file = File::create(out_path)?; let mut file = File::create(&out_path)?;
file.write_all(html.as_bytes())?; file.write_all(html.as_bytes())?;
println!("built {}", out_path.display());
Ok(()) Ok(())
} }