1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-06-01 22:16:30 +02:00

Rename some options

* rendering.chapter_template -> rendering.chapter.template
* rendering.part_template -> rendering.part.template
* rendering.roman_numerals.chapters -> rendering.chapter.roman_numerals
* rendering.roman_numerals.parts -> rendering.part.roman_numerals
This commit is contained in:
Elisabeth Henry 2016-12-22 17:43:09 +01:00
parent 663a2a5f5f
commit 9fd939d0bc
4 changed files with 23 additions and 21 deletions

View File

@ -32,8 +32,8 @@ proofread.languagetool: true
rendering.num_depth: 2
rendering.initials: false
rendering.inline_toc: false
rendering.chapter_template: "{{{number}}}\\. {{{chapter_title}}}"
rendering.roman_numerals.chapters: false
rendering.chapter.template: "{{{number}}}\\. {{{chapter_title}}}"
rendering.chapter.roman_numerals: false
# Html options
html.icon: crowbook.svg
@ -55,15 +55,16 @@ epub.version: 3
# Finally, our files.
# Paths are relative to the directory where this file is
#@ User guide
@ User guide
+ README.md
+ guide/arguments.md
+ guide/config.md
+ guide/templates.md
+ guide/proofreading.md
#@ More info
@ More info
+ guide/misc.md
+ guide/contribute.md
#@ Appendix
@ Appendix
- ChangeLog.md
- LICENSE.md

View File

@ -934,9 +934,9 @@ impl Book {
/// Sets the chapter_template once and for all
fn set_chapter_template(&mut self) -> Result<()> {
let template =
compile_str(self.options.get_str("rendering.chapter_template").unwrap(),
compile_str(self.options.get_str("rendering.chapter.template").unwrap(),
&self.source,
lformat!("could not compile template 'rendering.chapter_template'"))?;
lformat!("could not compile template 'rendering.chapter.template'"))?;
self.chapter_template = Some(template);
Ok(())
}
@ -951,7 +951,7 @@ impl Book {
if !title.is_empty() {
data = data.insert_bool("has_chapter_title", true);
}
let number = if self.options.get_bool("rendering.roman_numerals.chapters").unwrap() == true {
let number = if self.options.get_bool("rendering.chapter.roman_numerals").unwrap() == true {
if n <= 0 {
return Err(Error::render(Source::empty(),
lformat!("can not use roman numerals with zero or negative chapter numbers ({n})",
@ -971,10 +971,10 @@ impl Book {
template.render_data(&mut res, &data)?;
} else {
let template =
compile_str(self.options.get_str("rendering.chapter_template").unwrap(),
compile_str(self.options.get_str("rendering.chapter.template").unwrap(),
&self.source,
lformat!("could not compile template \
'rendering.chapter_template'"))?;
'rendering.chapter.template'"))?;
template.render_data(&mut res, &data)?;
}
@ -984,14 +984,13 @@ impl Book {
}
}
/// Returns the string corresponding to a number, title, and the numbering template for part
#[doc(hidden)]
pub fn get_part_header<F>(&self, n: i32, mut f: F) -> Result<String>
where F: FnMut(&str) -> Result<String>
{
let mut data = self.get_metadata(&mut f)?;
let number = if self.options.get_bool("rendering.roman_numerals.parts").unwrap() {
let number = if self.options.get_bool("rendering.part.roman_numerals").unwrap() {
if n <= 0 {
return Err(Error::render(Source::empty(),
lformat!("can not use roman numerals with zero or negative numbers ({n})",
@ -1011,10 +1010,10 @@ impl Book {
template.render_data(&mut res, &data)?;
} else {
let template =
compile_str(self.options.get_str("rendering.part_template").unwrap(),
compile_str(self.options.get_str("rendering.part.template").unwrap(),
&self.source,
lformat!("could not compile template \
'rendering.part_template'"))?;
'rendering.part.template'"))?;
template.render_data(&mut res, &data)?;
}

View File

@ -37,10 +37,11 @@ rendering.initials:bool:false # {renderin
rendering.inline_toc:bool:false # {inline_toc}
rendering.inline_toc.name:str:\"{{{{{{loc_toc}}}}}}\" # {toc_name}
rendering.num_depth:int:1 # {num_depth}
rendering.chapter_template:str:\"{{{{{{number}}}}}}\\\\. {{{{{{chapter_title}}}}}}\" # {chapter_template}
rendering.part_template:str:\"{{{{{{loc_part}}}}}} {{{{{{number}}}}}}\" # {part_template}
rendering.roman_numerals.parts:bool:true # {roman_numerals_parts}
rendering.roman_numerals.chapters:bool:false # {roman_numerals_chapters}
rendering.chapter.template:str:\"{{{{{{number}}}}}}\\\\. {{{{{{chapter_title}}}}}}\" # {chapter_template}
rendering.chapter.roman_numerals:bool:false # {roman_numerals_chapters}
rendering.part.template:str:\"{{{{{{loc_part}}}}}} {{{{{{number}}}}}}\" # {part_template}
rendering.part.roman_numerals:bool:true # {roman_numerals_parts}
# {special_ops}
import_config:path # {import_config}
@ -142,7 +143,7 @@ use_initials:alias:rendering.initials # {renamed}
toc_name:alias:rendering.inline_toc.name # {renamed}
display_toc:alias:rendering.inline_toc # {renamed}
numbering:alias:rendering.num_depth # {renamed}
numbering_template:alias:rendering.chapter_template # {renamed}
numbering_template:alias:rendering.chapter_tempalte # {renamed}
html.display_chapter:alias:html_single.one_chapter # {renamed}
temp_dir:alias:crowbook.temp_dir # {renamed}
zip.command:alias:crowbook.zip.command # {renamed}
@ -153,6 +154,7 @@ html.template:alias:html_single.html # {renamed}
html_dir.script:alias:html_dir.js # {renamed}
epub.template:alias:epub.chapter.xhtml # {renamed}
html_dir.css:alias:html.css # {renamed}
rendering.chapter_template:alias:rendering.chapter.template # {renamed}
nb_char:alias # {removed}
tex.short:alias # {removed}
html.crowbook_link:alias # {removed}

View File

@ -343,7 +343,7 @@ impl<'a> HtmlRenderer<'a> {
break;
}
}
if i != 1 || !self.book.options.get_bool("rendering.roman_numerals.chapters").unwrap() {
if i != 1 || !self.book.options.get_bool("rendering.chapter.roman_numerals").unwrap() {
output.push_str(&format!("{}.", self.current_chapter[i])); //todo
} else {
if self.current_chapter[i] >= 1 {
@ -498,7 +498,7 @@ impl<'a> HtmlRenderer<'a> {
this.as_mut().toc.add(n, url, s.clone());
} else {
let is_roman = this.as_ref().book.options.get_bool("rendering.roman_numerals.parts").unwrap();
let is_roman = this.as_ref().book.options.get_bool("rendering.part.roman_numerals").unwrap();
let number = this.as_ref().current_chapter[0];
let number = if is_roman && number >= 1 {
format!("{:X}", Roman::from(number as i16))