summaryrefslogtreecommitdiffstats
path: root/src/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/build.rs')
-rw-r--r--src/build.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/build.rs b/src/build.rs
index 1c12476..cf34e2f 100644
--- a/src/build.rs
+++ b/src/build.rs
@@ -14,12 +14,22 @@ const HTML_TEMPLATE: &str = include_str!("../res/template.html");
14 14
15pub fn do_build(config: &crate::config::Config) -> Result<()> { 15pub fn do_build(config: &crate::config::Config) -> Result<()> {
16 let tmpdir = tempfile::tempdir().wrap_err("Could not create temporary directory")?; 16 let tmpdir = tempfile::tempdir().wrap_err("Could not create temporary directory")?;
17 debug!("Created temporary directory at: '{}'", tmpdir.path().display()); 17 debug!(
18 "Created temporary directory at: '{}'",
19 tmpdir.path().display()
20 );
21
18 let template_path = tmpdir.path().join("template.html"); 22 let template_path = tmpdir.path().join("template.html");
19 trace!("Writing HTML template to: '{}'", template_path.display()); 23 trace!("Writing HTML template to: '{}'", template_path.display());
20 std::fs::write(&template_path, HTML_TEMPLATE) 24 std::fs::write(&template_path, HTML_TEMPLATE)
21 .wrap_err("Could not save HTML template in temporary directory")?; 25 .wrap_err("Could not save HTML template in temporary directory")?;
22 26
27 let defaults_path = tmpdir.path().join("defaults.yaml");
28 debug!("Generating file: '{}'", defaults_path.display());
29 let defaults =
30 std::fs::File::create(&defaults_path).wrap_err("Could not create defaults.yaml")?;
31 serde_json::to_writer(defaults, &config.pandoc).wrap_err("Could not create defaults.yaml")?;
32
23 let source_root = Path::new(&config.book.summary) 33 let source_root = Path::new(&config.book.summary)
24 .parent() 34 .parent()
25 .expect("Summary has no parent"); 35 .expect("Summary has no parent");
@@ -99,6 +109,7 @@ pub fn do_build(config: &crate::config::Config) -> Result<()> {
99 .set_output_format(pandoc::OutputFormat::Html5, vec![]) 109 .set_output_format(pandoc::OutputFormat::Html5, vec![])
100 .add_options(&[ 110 .add_options(&[
101 pandoc::PandocOption::Css(style_path.to_string()), 111 pandoc::PandocOption::Css(style_path.to_string()),
112 pandoc::PandocOption::Defaults(defaults_path.clone()),
102 pandoc::PandocOption::SectionDivs, 113 pandoc::PandocOption::SectionDivs,
103 pandoc::PandocOption::Standalone, 114 pandoc::PandocOption::Standalone,
104 pandoc::PandocOption::Template(template_path.clone()), 115 pandoc::PandocOption::Template(template_path.clone()),