mirror of
https://github.com/lise-henry/crowbook
synced 2024-11-18 00:13:55 +01:00
Set book's path when creating with new_from_markdown_file
This should allow a single markdown file to link to e.g. a cover file and still be rendered correctly even if crowbook is called from another directory.
This commit is contained in:
parent
81180d39cf
commit
6e99258062
@ -112,6 +112,12 @@ impl Book {
|
||||
pub fn new_from_markdown_file(filename: &str, verbosity: InfoLevel) -> Result<Book> {
|
||||
let mut book = Book::new();
|
||||
book.logger.set_verbosity(verbosity);
|
||||
|
||||
// Set book path to book's directory
|
||||
if let Some(parent) = Path::new(filename).parent() {
|
||||
book.root = parent.to_owned();
|
||||
book.options.root = book.root.clone();
|
||||
}
|
||||
|
||||
// Add the file as chapter with hidden title
|
||||
try!(book.add_chapter(Number::Hidden, filename));
|
||||
|
Loading…
Reference in New Issue
Block a user