Struct crowbook::Book [] [src]

pub struct Book { /* fields omitted */ }

A Book.

Probably the central structure for of Crowbook, as it is the one that calls the other ones.

It has the tasks of loading a configuration file, loading chapters and using Parserto parse them, and then calling various renderers (HtmlRendrer, LatexRenderer, EpubRenderer and/or OdtRenderer) to convert the AST into documents.

Examples

use crowbook::{Book, Number};
// Create a book with some options
let mut book = Book::new(&[("author", "Joan Doe"),
                           ("title", "An untitled book"),
                           ("lang", "en")]);
// Add content to the book
book.add_chapter_as_str(Number::Default, "# The beginning#\nBla, bla, bla").unwrap();

// Render the book as html to stdout
book.render_html(&mut std::io::stdout()).unwrap();Run

Methods

impl Book
[src]

Creates a new Book with given options

Arguments

*options a list (or other iterator) of (key, value) tuples. Can be &[].

Creates a new book from a file, with options

Arguments

  • filename: the path of file to load. The directory of this file is used as a "root" directory for all paths referenced in books, whether chapter files, templates, cover images, and so on.
  • `verbosity: sets the book verbosity
  • options: a list of (key, value) options to pass to the book

Creates a book from a single markdown file

Sets options and load chapters according to configuration file

A line with "option: value" sets the option to value

  • chapter_name.md adds the (default numbered) chapter

  • chapter_name.md adds the (unnumbered) chapter

  1. chapter_name.md adds the (custom numbered) chapter

Generates output files acccording to book options

Render book to pdf according to book options

Render book to epub according to book options

Render book to HTML directory according to book options

Render book to HTML directory according to book options (proofread version)

Render book to PDF according to book options (proofread version)

Render book to odt according to book options

Render book to html according to book options

Render book to html according to book options (proofread version)

Render book to pdf according to book options

Render book to pdf according to book options (proofread version)

Adds a chapter, as a file name, to the book

Book will then parse the file and store the AST (i.e., a vector of Tokens).

Arguments

  • number: specifies if the chapter must be numbered, not numbered, or if its title must be hidden. See Number.
  • file: path of the file for this chapter

Returns an error if file does not exist, could not be read, of if there was some error parsing it.

Adds a chapter, as a string, to the book

Book will then parse the string and store the AST (i.e., a vector of Tokens).

Arguments

  • number: specifies if the chapter must be numbered, not numbered, or if its title must be hidden. See Number.
  • content: the content of the chapter.

Returns an error if there was some errror parsing content.