mirror of
https://github.com/lise-henry/crowbook
synced 2024-11-18 00:13:55 +01:00
book option numbering is now an i32 instead of a false,
This commit is contained in:
parent
38db23b8ae
commit
7653d2e767
@ -46,7 +46,7 @@ output.odt:str # Output file name for ODT rendering
|
||||
|
||||
|
||||
# Misc options
|
||||
numbering:bool:true # Toggles chapter/sections numbering
|
||||
numbering:int:1 # The maximum heading levels to number (0: no numbering, 1: only chapters, ..., 6: all)
|
||||
autoclean:bool:true # Toggles cleaning of input markdown (not used for LaTeX)
|
||||
verbose:bool:false # Toggle verbose mode
|
||||
side_notes:bool:false # Display footnotes as side notes in HTML/Epub
|
||||
|
@ -60,16 +60,16 @@ impl<'a> EpubRenderer<'a> {
|
||||
// Write chapters
|
||||
for (i, &(n, ref v)) in self.book.chapters.iter().enumerate() {
|
||||
self.html.current_hide = false;
|
||||
let book_numbering = self.book.get_bool("numbering").unwrap();
|
||||
let book_numbering = self.book.get_i32("numbering").unwrap();
|
||||
match n {
|
||||
Number::Unnumbered => self.html.current_numbering = false,
|
||||
Number::Unnumbered => self.html.current_numbering = 0,
|
||||
Number::Default => self.html.current_numbering = book_numbering,
|
||||
Number::Specified(n) => {
|
||||
self.html.current_numbering = book_numbering;
|
||||
self.html.current_chapter[0] = n - 1;
|
||||
},
|
||||
Number::Hidden => {
|
||||
self.html.current_numbering = false;
|
||||
self.html.current_numbering = 0;
|
||||
self.html.current_hide = true;
|
||||
}
|
||||
}
|
||||
@ -293,7 +293,7 @@ impl<'a> EpubRenderer<'a> {
|
||||
self.html.render_end_notes(&mut content);
|
||||
|
||||
if title.is_empty() {
|
||||
if self.html.current_numbering {
|
||||
if self.html.current_numbering >= 1 {
|
||||
let number = self.html.current_chapter[0] + 1;
|
||||
title = try!(self.book.get_header(number, ""));
|
||||
} else {
|
||||
|
@ -30,7 +30,7 @@ pub struct HtmlRenderer<'a> {
|
||||
|
||||
pub footnotes: Vec<(String, String)>,
|
||||
pub current_chapter: [i32;6],
|
||||
pub current_numbering: bool,
|
||||
pub current_numbering: i32,
|
||||
pub current_hide: bool,
|
||||
table_head: bool,
|
||||
footnote_number: u32,
|
||||
@ -45,7 +45,7 @@ impl<'a> HtmlRenderer<'a> {
|
||||
HtmlRenderer {
|
||||
book: book,
|
||||
current_chapter: [0, 0, 0, 0, 0, 0],
|
||||
current_numbering: book.get_bool("numbering").unwrap(),
|
||||
current_numbering: book.get_i32("numbering").unwrap(),
|
||||
current_hide: false,
|
||||
table_head: false,
|
||||
footnote_number: 0,
|
||||
@ -89,16 +89,16 @@ impl<'a> HtmlRenderer<'a> {
|
||||
|
||||
for &(n, ref v) in &self.book.chapters {
|
||||
self.current_hide = false;
|
||||
let book_numbering = self.book.get_bool("numbering").unwrap();
|
||||
let book_numbering = self.book.get_i32("numbering").unwrap();
|
||||
match n {
|
||||
Number::Unnumbered => self.current_numbering = false,
|
||||
Number::Unnumbered => self.current_numbering = 0,
|
||||
Number::Default => self.current_numbering = book_numbering,
|
||||
Number::Specified(n) => {
|
||||
self.current_numbering = book_numbering;
|
||||
self.current_chapter[0] = n - 1;
|
||||
},
|
||||
Number::Hidden => {
|
||||
self.current_numbering = false;
|
||||
self.current_numbering = 0;
|
||||
self.current_hide = true;
|
||||
},
|
||||
}
|
||||
@ -176,10 +176,10 @@ impl<'a> HtmlRenderer<'a> {
|
||||
if n == 1 && self.current_hide {
|
||||
return String::new();
|
||||
}
|
||||
let s = if n == 1 && self.current_numbering {
|
||||
let s = if n == 1 && self.current_numbering >= 1 {
|
||||
let chapter = self.current_chapter[0];
|
||||
self.book.get_header(chapter, &self.render_vec(vec)).unwrap()
|
||||
} else if self.current_numbering {
|
||||
} else if self.current_numbering >= n {
|
||||
format!("{} {}", self.get_numbers(), self.render_vec(vec))
|
||||
} else {
|
||||
self.render_vec(vec)
|
||||
|
@ -11,7 +11,7 @@ use mustache;
|
||||
/// (Experimental)
|
||||
pub struct OdtRenderer<'a> {
|
||||
book: &'a Book,
|
||||
current_numbering: bool,
|
||||
current_numbering: i32,
|
||||
current_hide: bool,
|
||||
current_chapter: i32,
|
||||
automatic_styles: String,
|
||||
@ -23,7 +23,7 @@ impl<'a> OdtRenderer<'a> {
|
||||
OdtRenderer {
|
||||
book: book,
|
||||
current_chapter: 1,
|
||||
current_numbering: book.get_bool("numbering").unwrap(),
|
||||
current_numbering: book.get_i32("numbering").unwrap(),
|
||||
current_hide: false,
|
||||
automatic_styles: String::from("
|
||||
<style:style style:name=\"T1\" style:family=\"text\">
|
||||
@ -62,14 +62,14 @@ impl<'a> OdtRenderer<'a> {
|
||||
for &(n, ref v) in &self.book.chapters {
|
||||
self.current_hide = false;
|
||||
match n {
|
||||
Number::Unnumbered => self.current_numbering = false,
|
||||
Number::Default => self.current_numbering = self.book.get_bool("numbering").unwrap(),
|
||||
Number::Unnumbered => self.current_numbering = 0,
|
||||
Number::Default => self.current_numbering = self.book.get_i32("numbering").unwrap(),
|
||||
Number::Specified(n) => {
|
||||
self.current_numbering = self.book.get_bool("numbering").unwrap();
|
||||
self.current_numbering = self.book.get_i32("numbering").unwrap();
|
||||
self.current_chapter = n;
|
||||
},
|
||||
Number::Hidden => {
|
||||
self.current_numbering = false;
|
||||
self.current_numbering = 0;
|
||||
self.current_hide = true;
|
||||
},
|
||||
}
|
||||
@ -110,7 +110,7 @@ impl<'a> OdtRenderer<'a> {
|
||||
if n == 1 && self.current_hide {
|
||||
return String::new();
|
||||
}
|
||||
let s = if n == 1 && self.current_numbering {
|
||||
let s = if n == 1 && self.current_numbering >= 1 {
|
||||
let chapter = self.current_chapter;
|
||||
self.current_chapter += 1;
|
||||
self.book.get_header(chapter, &self.render_vec(vec)).unwrap()
|
||||
|
Loading…
Reference in New Issue
Block a user