diff --git a/core/src/lib.rs b/core/src/lib.rs index ca4de17f..97772109 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -32,7 +32,7 @@ impl Unimarkup { doc: Umi::create_um(um_content, &mut config).unwrap(), }, _ => Unimarkup { - doc: parser::parse_unimarkup(um_content, &mut config), + doc: parser::parse_unimarkup(um_content, config), }, } } diff --git a/render/src/umi/mod.rs b/render/src/umi/mod.rs index 91330372..8c4c15f1 100644 --- a/render/src/umi/mod.rs +++ b/render/src/umi/mod.rs @@ -371,6 +371,7 @@ impl Umi { .preamble .i18n .lang + .clone() .unwrap_or(locale!("en")) .to_string() .to_owned(), diff --git a/render/src/umi/render.rs b/render/src/umi/render.rs index 8f1d70bf..a4996e5b 100644 --- a/render/src/umi/render.rs +++ b/render/src/umi/render.rs @@ -233,42 +233,50 @@ impl Renderer for UmiRenderer { &mut self, context: &Context, ) -> Result { - let entry = UmiRow::new( - self.pos, - String::new(), - "Bibliography".to_string(), - String::new(), - self.depth, - "{$um.bibliography}".to_string(), - String::new(), - ); + if context.bibliography.is_some() { + let entry = UmiRow::new( + self.pos, + String::new(), + "Bibliography".to_string(), + String::new(), + self.depth, + "{$um.bibliography}".to_string(), + String::new(), + ); - self.pos += 1; + self.pos += 1; - self.proceed(Umi::with_um( - vec![entry], - context.get_config().clone(), - context.get_lang().to_string(), - )) + self.proceed(Umi::with_um( + vec![entry], + context.get_config().clone(), + context.get_lang().to_string(), + )) + } else { + Ok(Umi::default()) + } } fn render_footnotes(&mut self, context: &Context) -> Result { - let entry = UmiRow::new( - self.pos, - String::new(), - "Footnotes".to_string(), - String::new(), - self.depth, - "{$um.footnotes}".to_string(), - String::new(), - ); + if context.footnotes.is_some() { + let entry = UmiRow::new( + self.pos, + String::new(), + "Footnotes".to_string(), + String::new(), + self.depth, + "{$um.footnotes}".to_string(), + String::new(), + ); - self.pos += 1; + self.pos += 1; - self.proceed(Umi::with_um( - vec![entry], - context.get_config().clone(), - context.get_lang().to_string(), - )) + self.proceed(Umi::with_um( + vec![entry], + context.get_config().clone(), + context.get_lang().to_string(), + )) + } else { + Ok(Umi::default()) + } } }