2016-02-19 21:35:49 +01:00
|
|
|
|
The configuration file
|
|
|
|
|
======================
|
|
|
|
|
|
|
|
|
|
If you want to use Crowbook for your book, this configuration file
|
2016-03-01 21:41:23 +01:00
|
|
|
|
is all you'll have to add (assuming you already have the book in
|
2016-02-19 21:35:49 +01:00
|
|
|
|
Markdown files; if you don't, you'll also have to write a book first,
|
|
|
|
|
but that's besides the scope of this document).
|
|
|
|
|
|
2016-03-01 18:46:59 +01:00
|
|
|
|
The format is not very complicated. This is an example of it:
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
|
|
|
|
```
|
2016-02-20 19:23:02 +01:00
|
|
|
|
# metadata
|
2016-02-19 21:35:49 +01:00
|
|
|
|
author: Joan Doe
|
|
|
|
|
title: Some book
|
|
|
|
|
lang: en
|
|
|
|
|
|
2016-02-21 05:29:40 +01:00
|
|
|
|
output.html: some_book.html
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
2016-02-20 19:23:02 +01:00
|
|
|
|
# list of chapters
|
2016-02-19 21:35:49 +01:00
|
|
|
|
- preface.md
|
|
|
|
|
+ chapter_1.md
|
|
|
|
|
+ chapter_2.md
|
|
|
|
|
+ chapter_3.md
|
|
|
|
|
+ chapter_4.md
|
|
|
|
|
- epilogue.md
|
|
|
|
|
```
|
|
|
|
|
Basically, it is divided in two parts:
|
|
|
|
|
|
2016-03-01 18:46:59 +01:00
|
|
|
|
* a list of options, under the form `key: value`, following YAML syntax.
|
2016-02-19 21:35:49 +01:00
|
|
|
|
* a list of Markdown files.
|
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
Lines starting with the `#` characters are comments and are discarded.
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
|
|
|
|
The list of files
|
|
|
|
|
-----------------
|
|
|
|
|
|
2016-02-20 19:23:02 +01:00
|
|
|
|
There are various options to include a markdown file.
|
|
|
|
|
|
|
|
|
|
* `+ file_name.md` includes a numbered chapter.
|
|
|
|
|
* `- file_name.md` includes an unnumbered chapter.
|
|
|
|
|
* `! file_name.md` includes a chapter whose title won't be displayed
|
2016-03-01 21:41:23 +01:00
|
|
|
|
(except in the table of contents); this is useful for e.g. including a
|
2016-02-20 19:23:02 +01:00
|
|
|
|
copyright at the beginning or the book, or for short stories where
|
|
|
|
|
there is only one chapter.
|
|
|
|
|
* `42. file_name.md` specifies the number for a chapter.
|
|
|
|
|
|
|
|
|
|
So a typical usage might look like this:
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
2016-02-20 19:23:02 +01:00
|
|
|
|
```
|
|
|
|
|
! copyright.md
|
|
|
|
|
- preface.md
|
|
|
|
|
# We want first chapter to be Chapter 0 because we are programmers!
|
|
|
|
|
0. chapter_0.md
|
|
|
|
|
# Next chapters can be numbered automatically
|
|
|
|
|
+ chapter_1.md
|
2016-03-01 21:41:23 +01:00
|
|
|
|
+ chapter_2.md
|
2016-02-20 19:23:02 +01:00
|
|
|
|
...
|
|
|
|
|
```
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
|
|
|
|
There are two important things to note:
|
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
1. you must *not* use quotes around the file names.
|
2016-02-19 21:35:49 +01:00
|
|
|
|
2. the path of these files are relative to the directory where your
|
|
|
|
|
config file is, *not* to the directory where you are when running
|
|
|
|
|
`crowbook`. E.g. you can run `crowbook
|
|
|
|
|
books/my_trilogy/first_book/config.book` without being in the
|
|
|
|
|
book's directory.
|
|
|
|
|
|
|
|
|
|
Also note that you don't have to specify a title. This is because the title
|
|
|
|
|
of the chapter is inferred from the Markdown document. To go back to
|
|
|
|
|
our previous example:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
+ chapter_1.md
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
does not specify a chapter title, because it will read it directly in
|
|
|
|
|
`chapter_1.md`, e.g.:
|
|
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
|
The day I was born
|
|
|
|
|
==================
|
|
|
|
|
|
2016-02-20 19:23:02 +01:00
|
|
|
|
...
|
2016-02-19 21:35:49 +01:00
|
|
|
|
```
|
|
|
|
|
|
2016-02-20 19:23:02 +01:00
|
|
|
|
You should have one and only one level-one header (i.e. chapter title)
|
|
|
|
|
in each markdown file.
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
If you have more than one, Crowbook will print a warning and treat it
|
|
|
|
|
as another chapter (numbered according to the scheme specified for
|
|
|
|
|
including the file). It might however mess the table of contents in
|
|
|
|
|
some cases (e.g. for Epub).
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
If you do *not* have a level-1 header in a
|
|
|
|
|
markdown file:
|
|
|
|
|
* if it is a numbered chapter, Crowbook will infer a chapter name from
|
|
|
|
|
the numbering scheme;
|
|
|
|
|
* if it is not numbered, chapter's title will default to the empty
|
|
|
|
|
string and won't be displayed in the TOC.
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Crowbook options
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
The first part of the configuration file is dedicated to pass options
|
2016-03-01 21:41:23 +01:00
|
|
|
|
to Crowbook. This is
|
|
|
|
|
[YAML syntax](https://en.wikipedia.org/wiki/YAML), so each line should
|
|
|
|
|
be of the form `key: value`. Note that in most cases you don't have to
|
|
|
|
|
put string in quotes, e.g.:
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
title: My title
|
|
|
|
|
```
|
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
It is however possible (and sometimes necessary to escape some
|
|
|
|
|
characters) to use quotes around strings:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
title: "My title!"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2016-03-01 18:46:59 +01:00
|
|
|
|
It is possible to use multiline strings with `>-` and
|
2016-02-25 15:29:35 +01:00
|
|
|
|
then indenting the lines that are part of the string:
|
|
|
|
|
|
|
|
|
|
```
|
2016-03-01 18:46:59 +01:00
|
|
|
|
title: >-
|
2016-02-25 15:29:35 +01:00
|
|
|
|
A
|
|
|
|
|
long
|
|
|
|
|
title
|
|
|
|
|
author: Joan Doe
|
|
|
|
|
```
|
|
|
|
|
|
2016-03-01 18:46:59 +01:00
|
|
|
|
will set `title` to `"A long title"`. See
|
|
|
|
|
[block literals in YAML](https://en.wikipedia.org/wiki/YAML#Block_literals)
|
2016-03-01 21:41:23 +01:00
|
|
|
|
for more information on the various way to insert multiline strings
|
|
|
|
|
(which mostly change the way newlines will or won't be inserted).
|
2016-02-25 15:29:35 +01:00
|
|
|
|
|
2016-02-25 20:11:06 +01:00
|
|
|
|
Here is the complete list of options, with a short description. The
|
|
|
|
|
usage of some of them is detailed later on.
|
2016-02-23 23:45:35 +01:00
|
|
|
|
|
|
|
|
|
### Metadata ###
|
|
|
|
|
- **`author`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `Anonymous`
|
|
|
|
|
- The author of the book
|
|
|
|
|
- **`title`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `Untitled`
|
|
|
|
|
- The title of the book
|
|
|
|
|
- **`lang`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `en`
|
|
|
|
|
- The language of the book
|
|
|
|
|
- **`subject`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Subject of the book (used for EPUB metadata)
|
|
|
|
|
- **`description`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Description of the book (used for EPUB metadata)
|
|
|
|
|
- **`cover`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- File name of the cover of the book
|
|
|
|
|
|
|
|
|
|
### Output options ###
|
|
|
|
|
- **`output.epub`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Output file name for EPUB rendering
|
|
|
|
|
- **`output.html`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Output file name for HTML rendering
|
|
|
|
|
- **`output.tex`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Output file name for LaTeX rendering
|
|
|
|
|
- **`output.pdf`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Output file name for PDF rendering
|
|
|
|
|
- **`output.odt`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Output file name for ODT rendering
|
|
|
|
|
|
|
|
|
|
### Misc options ###
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **`zip.command`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `zip`
|
|
|
|
|
- Command to use to zip files (for EPUB/ODT)
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **`numbering`**
|
|
|
|
|
- **type**: integer
|
|
|
|
|
- **default value**: `1`
|
|
|
|
|
- The maximum heading levels to number (0: no numbering, 1: only chapters, ..., 6: all)
|
2016-02-25 20:11:06 +01:00
|
|
|
|
- **`display_toc`**
|
|
|
|
|
- **type**: boolean
|
|
|
|
|
- **default value**: `false`
|
|
|
|
|
- If true, display a table of content in the document
|
|
|
|
|
- **`toc_name`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `Table of contents`
|
|
|
|
|
- Name of the table of contents if toc is displayed in line
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **`autoclean`**
|
|
|
|
|
- **type**: boolean
|
|
|
|
|
- **default value**: `true`
|
|
|
|
|
- Toggles cleaning of input markdown (not used for LaTeX)
|
|
|
|
|
- **`verbose`**
|
|
|
|
|
- **type**: boolean
|
|
|
|
|
- **default value**: `false`
|
2016-03-01 21:41:23 +01:00
|
|
|
|
- If set to true, print warnings in Markdown processing
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **`side_notes`**
|
|
|
|
|
- **type**: boolean
|
|
|
|
|
- **default value**: `false`
|
|
|
|
|
- Display footnotes as side notes in HTML/Epub
|
|
|
|
|
- **`temp_dir`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
|
|
|
|
- **default value**: ``
|
|
|
|
|
- Path where to create a temporary directory (default: uses result from Rust's std::env::temp_dir())
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **`numbering_template`**
|
|
|
|
|
- **type**: string
|
2016-03-01 21:41:23 +01:00
|
|
|
|
- **default value**: `"{{number}}. {{title}}"`
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- Format of numbered titles
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **`nb_char`**
|
|
|
|
|
- **type**: char
|
|
|
|
|
- **default value**: `' '`
|
|
|
|
|
- The non-breaking character to use for autoclean when lang is set to fr
|
2016-02-23 23:45:35 +01:00
|
|
|
|
|
|
|
|
|
### HTML options ###
|
|
|
|
|
- **`html.template`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Path of an HTML template
|
|
|
|
|
- **`html.css`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Path of a stylesheet to use with HTML rendering
|
|
|
|
|
|
|
|
|
|
### EPUB options ###
|
|
|
|
|
- **`epub.version`**
|
|
|
|
|
- **type**: integer
|
|
|
|
|
- **default value**: `2`
|
|
|
|
|
- The EPUB version to generate
|
|
|
|
|
- **`epub.css`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Path of a stylesheet to use with EPUB rendering
|
|
|
|
|
- **`epub.template`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Path of an epub template for chapter
|
|
|
|
|
|
|
|
|
|
### LaTeX options ###
|
|
|
|
|
- **`tex.links_as_footnotes`**
|
|
|
|
|
- **type**: boolean
|
|
|
|
|
- **default value**: `true`
|
|
|
|
|
- If set to true, will add foontotes to URL of links in LaTeX/PDF output
|
|
|
|
|
- **`tex.command`**
|
|
|
|
|
- **type**: string
|
|
|
|
|
- **default value**: `pdflatex`
|
|
|
|
|
- LaTeX flavour to use for generating PDF
|
|
|
|
|
- **`tex.template`**
|
2016-02-27 17:02:35 +01:00
|
|
|
|
- **type**: path
|
2016-02-23 23:45:35 +01:00
|
|
|
|
- **default value**: `not set`
|
|
|
|
|
- Path of a LaTeX template file
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
Note that these options have a type, which in most case should be
|
2016-02-27 17:02:35 +01:00
|
|
|
|
pretty straightforward (a boolean can be `true` or `false`, an integer
|
2016-03-01 21:41:23 +01:00
|
|
|
|
must be composed a number, a string is, well, any string). The `path`
|
|
|
|
|
type might puzzle you a
|
2016-02-27 17:02:35 +01:00
|
|
|
|
bit, but it's equivalent a string, except Crowbook will consider it
|
|
|
|
|
relatively to the book file.
|
|
|
|
|
|
2016-02-25 20:11:06 +01:00
|
|
|
|
|
2016-02-19 21:35:49 +01:00
|
|
|
|
### Output options ###
|
|
|
|
|
|
|
|
|
|
These options specify which files to generate. You must at least set
|
|
|
|
|
one of this option, or Crowbook won't do anything.
|
|
|
|
|
|
|
|
|
|
Recall that all file paths are relative to the directory where the
|
|
|
|
|
config file is, not to the one where you run `crowbook`. So if you set
|
|
|
|
|
|
|
|
|
|
```
|
2016-02-21 05:29:40 +01:00
|
|
|
|
output.epub = foo.epub
|
2016-02-19 21:35:49 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
and runs
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ crowbook some/dir/config.book
|
|
|
|
|
```
|
|
|
|
|
|
2016-02-21 02:06:14 +01:00
|
|
|
|
`foo.epub` will be generated in `some/dir`, not in your current
|
|
|
|
|
directory.
|
|
|
|
|
|
2016-02-21 05:29:40 +01:00
|
|
|
|
Crowbook will try to generate each of the `output.xxx` files that are
|
2016-02-21 02:06:14 +01:00
|
|
|
|
specified. That means that you'll have to set at least one of those if you want a call to
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ crowbook my.book
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
to generate anything. (It's still possible to generate a specific
|
2016-02-23 23:45:35 +01:00
|
|
|
|
format, and only this one, by using the `--to` argument on the command
|
|
|
|
|
line).
|
|
|
|
|
|
|
|
|
|
Note that some formats depend on some commands being installed on your
|
|
|
|
|
system. Most notably, Crowbook depends on LaTeX (`pdflatex` by
|
|
|
|
|
default, though you can specify the command to use with `tex.command`) to generate a PDF file,
|
|
|
|
|
so PDF rendering won't work if it is not installed on your
|
|
|
|
|
system. Crowbook also uses the `zip` command to generate the EPUB and
|
|
|
|
|
ODT, files.
|
2016-02-21 02:06:14 +01:00
|
|
|
|
|
2016-02-21 05:29:40 +01:00
|
|
|
|
### Generic options for rendering ###
|
|
|
|
|
|
|
|
|
|
#### numbering ####
|
|
|
|
|
|
2016-02-23 23:45:35 +01:00
|
|
|
|
An integer that represents the maximum level of numbering for your
|
|
|
|
|
book. E.g., `1` will only number chapters, while `2` will number
|
|
|
|
|
chapters, sections, but not anything below that. `6` is the maximum level
|
|
|
|
|
and turns numbering on for all headers.
|
2016-02-21 05:29:40 +01:00
|
|
|
|
|
2016-03-01 21:41:23 +01:00
|
|
|
|
**default**: `1`
|
2016-02-21 05:29:40 +01:00
|
|
|
|
|
2016-02-19 22:30:21 +01:00
|
|
|
|
|
|
|
|
|
#### numbering_template ####
|
|
|
|
|
|
2016-02-23 23:45:35 +01:00
|
|
|
|
A string that will be used for chapter titles. You can use `{{number}}` and
|
2016-02-19 22:30:21 +01:00
|
|
|
|
`{{title}}` in this string, e.g.:
|
|
|
|
|
|
|
|
|
|
```
|
2016-03-01 21:41:23 +01:00
|
|
|
|
numbering_template: "Chapter {{number}} {{title}}"
|
2016-02-19 22:30:21 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Note that:
|
2016-03-01 21:41:23 +01:00
|
|
|
|
* in this case, quoting is necessary because `{` and `}` have special
|
|
|
|
|
meaning in YAML;
|
|
|
|
|
* this string won't be used for unnumbered chapters;
|
|
|
|
|
* this string isn't currently used by LaTeX, either.
|
2016-02-19 22:30:21 +01:00
|
|
|
|
|
2016-02-21 05:29:40 +01:00
|
|
|
|
#### autoclean ####
|
|
|
|
|
|
|
|
|
|
This option cleans a bit the input markdown. With the default
|
|
|
|
|
implementation, it only removes consecutive spaces, which has not real
|
|
|
|
|
impact (they are ignored anyway both by HTML viewers and by LaTeX).
|
|
|
|
|
|
|
|
|
|
However, if `lang` is set to `fr`, it also tries to add non-breaking
|
|
|
|
|
spaces in front (or after) characters like '?', '!', ';' to respect
|
|
|
|
|
french typography.
|
|
|
|
|
|
2016-02-19 21:35:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|