2015-08-03 14:23:32 +02:00
|
|
|
# Configuration
|
|
|
|
|
|
2016-12-23 08:17:04 +00:00
|
|
|
You can configure the parameters for your book in the ***book.toml*** file.
|
2015-08-03 14:23:32 +02:00
|
|
|
|
2016-12-23 08:17:04 +00:00
|
|
|
Here is an example of what a ***book.toml*** file might look like:
|
|
|
|
|
|
|
|
|
|
```toml
|
2017-11-12 03:35:10 +08:00
|
|
|
[book]
|
2016-12-23 08:17:04 +00:00
|
|
|
title = "Example book"
|
2017-05-20 15:03:10 +02:00
|
|
|
author = "John Doe"
|
2016-12-23 08:17:04 +00:00
|
|
|
description = "The example book covers examples."
|
2020-03-10 00:02:54 +09:00
|
|
|
|
|
|
|
|
[rust]
|
2019-11-17 21:36:10 +03:00
|
|
|
edition = "2018"
|
2017-05-20 15:03:10 +02:00
|
|
|
|
2017-11-29 20:02:58 -08:00
|
|
|
[build]
|
2017-11-30 07:26:30 -08:00
|
|
|
build-dir = "my-example-book"
|
2017-11-29 20:02:58 -08:00
|
|
|
create-missing = false
|
|
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
[preprocessor.index]
|
2018-09-10 20:58:55 +10:00
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
[preprocessor.links]
|
2018-09-10 20:58:55 +10:00
|
|
|
|
2017-05-20 15:03:10 +02:00
|
|
|
[output.html]
|
|
|
|
|
additional-css = ["custom.css"]
|
2018-03-07 07:02:06 -06:00
|
|
|
|
|
|
|
|
[output.html.search]
|
|
|
|
|
limit-results = 15
|
2017-05-20 15:03:10 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Supported configuration options
|
|
|
|
|
|
2019-07-17 17:20:18 +02:00
|
|
|
It is important to note that **any** relative path specified in the
|
2018-08-02 21:34:26 -05:00
|
|
|
configuration will always be taken relative from the root of the book where the
|
|
|
|
|
configuration file is located.
|
2017-05-20 15:03:10 +02:00
|
|
|
|
2017-11-12 03:35:10 +08:00
|
|
|
### General metadata
|
2017-05-20 15:03:10 +02:00
|
|
|
|
2017-11-12 03:35:10 +08:00
|
|
|
This is general information about your book.
|
2017-05-20 15:03:10 +02:00
|
|
|
|
2017-11-12 03:35:10 +08:00
|
|
|
- **title:** The title of the book
|
|
|
|
|
- **authors:** The author(s) of the book
|
|
|
|
|
- **description:** A description for the book, which is added as meta
|
|
|
|
|
information in the html `<head>` of each page
|
|
|
|
|
- **src:** By default, the source directory is found in the directory named
|
|
|
|
|
`src` directly under the root folder. But this is configurable with the `src`
|
|
|
|
|
key in the configuration file.
|
2019-05-30 11:53:49 +09:00
|
|
|
- **language:** The main language of the book, which is used as a language attribute `<html lang="en">` for example.
|
2017-05-20 15:03:10 +02:00
|
|
|
|
|
|
|
|
**book.toml**
|
|
|
|
|
```toml
|
2017-11-12 03:35:10 +08:00
|
|
|
[book]
|
2017-05-20 15:03:10 +02:00
|
|
|
title = "Example book"
|
|
|
|
|
authors = ["John Doe", "Jane Doe"]
|
|
|
|
|
description = "The example book covers examples."
|
2017-11-12 03:35:10 +08:00
|
|
|
src = "my-src" # the source files will be found in `root/my-src` instead of `root/src`
|
2019-05-30 11:53:49 +09:00
|
|
|
language = "en"
|
2015-08-03 14:23:32 +02:00
|
|
|
```
|
|
|
|
|
|
2020-03-10 00:02:54 +09:00
|
|
|
### Rust options
|
|
|
|
|
|
2020-04-21 12:21:56 -07:00
|
|
|
Options for the Rust language, relevant to running tests and playground
|
|
|
|
|
integration.
|
|
|
|
|
|
|
|
|
|
- **edition**: Rust edition to use by default for the code snippets. Default
|
|
|
|
|
is "2015". Individual code blocks can be controlled with the `edition2015`
|
|
|
|
|
or `edition2018` annotations, such as:
|
|
|
|
|
|
|
|
|
|
~~~text
|
|
|
|
|
```rust,edition2015
|
|
|
|
|
// This only works in 2015.
|
|
|
|
|
let try = true;
|
|
|
|
|
```
|
|
|
|
|
~~~
|
2020-03-10 00:02:54 +09:00
|
|
|
|
2017-11-29 20:02:58 -08:00
|
|
|
### Build options
|
|
|
|
|
|
|
|
|
|
This controls the build process of your book.
|
|
|
|
|
|
2017-11-30 07:26:30 -08:00
|
|
|
- **build-dir:** The directory to put the rendered book in. By default this is
|
|
|
|
|
`book/` in the book's root directory.
|
2017-11-29 20:02:58 -08:00
|
|
|
- **create-missing:** By default, any missing files specified in `SUMMARY.md`
|
2017-11-30 07:26:30 -08:00
|
|
|
will be created when the book is built (i.e. `create-missing = true`). If this
|
|
|
|
|
is `false` then the build process will instead exit with an error if any files
|
|
|
|
|
do not exist.
|
2018-09-10 20:58:55 +10:00
|
|
|
- **use-default-preprocessors:** Disable the default preprocessors of (`links` &
|
|
|
|
|
`index`) by setting this option to `false`.
|
2018-05-06 23:48:11 +08:00
|
|
|
|
2018-09-10 20:58:55 +10:00
|
|
|
If you have the same, and/or other preprocessors declared via their table
|
|
|
|
|
of configuration, they will run instead.
|
|
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
- For clarity, with no preprocessor configuration, the default `links` and
|
2018-09-10 20:58:55 +10:00
|
|
|
`index` will run.
|
|
|
|
|
- Setting `use-default-preprocessors = false` will disable these
|
|
|
|
|
default preprocessors from running.
|
2019-05-18 15:05:57 -07:00
|
|
|
- Adding `[preprocessor.links]`, for example, will ensure, regardless of
|
2018-09-10 20:58:55 +10:00
|
|
|
`use-default-preprocessors` that `links` it will run.
|
|
|
|
|
|
|
|
|
|
## Configuring Preprocessors
|
2018-05-06 23:48:11 +08:00
|
|
|
|
|
|
|
|
The following preprocessors are available and included by default:
|
|
|
|
|
|
2019-10-05 18:27:03 -04:00
|
|
|
- `links`: Expand the `{{ #playpen }}`, `{{ #include }}`, and `{{ #rustdoc_include }}` handlebars
|
2018-10-20 14:16:07 +08:00
|
|
|
helpers in a chapter to include the contents of a file.
|
2018-08-02 21:34:26 -05:00
|
|
|
- `index`: Convert all chapter files named `README.md` into `index.md`. That is
|
|
|
|
|
to say, all `README.md` would be rendered to an index file `index.html` in the
|
|
|
|
|
rendered book.
|
2018-05-06 23:48:11 +08:00
|
|
|
|
2017-11-29 20:02:58 -08:00
|
|
|
|
|
|
|
|
**book.toml**
|
|
|
|
|
```toml
|
|
|
|
|
[build]
|
2017-11-30 07:26:30 -08:00
|
|
|
build-dir = "build"
|
2017-11-29 20:02:58 -08:00
|
|
|
create-missing = false
|
2018-09-10 20:58:55 +10:00
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
[preprocessor.links]
|
2018-09-10 20:58:55 +10:00
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
[preprocessor.index]
|
2017-11-29 20:02:58 -08:00
|
|
|
```
|
|
|
|
|
|
2018-09-10 20:58:55 +10:00
|
|
|
### Custom Preprocessor Configuration
|
|
|
|
|
|
2018-10-20 14:16:07 +08:00
|
|
|
Like renderers, preprocessor will need to be given its own table (e.g.
|
|
|
|
|
`[preprocessor.mathjax]`). In the section, you may then pass extra
|
|
|
|
|
configuration to the preprocessor by adding key-value pairs to the table.
|
2018-09-10 20:58:55 +10:00
|
|
|
|
|
|
|
|
For example
|
|
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
```toml
|
|
|
|
|
[preprocessor.links]
|
2018-09-10 20:58:55 +10:00
|
|
|
# set the renderers this preprocessor will run for
|
|
|
|
|
renderers = ["html"]
|
|
|
|
|
some_extra_feature = true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### Locking a Preprocessor dependency to a renderer
|
|
|
|
|
|
2018-10-20 14:16:07 +08:00
|
|
|
You can explicitly specify that a preprocessor should run for a renderer by
|
|
|
|
|
binding the two together.
|
2018-09-10 20:58:55 +10:00
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
```toml
|
2018-09-10 20:58:55 +10:00
|
|
|
[preprocessor.mathjax]
|
|
|
|
|
renderers = ["html"] # mathjax only makes sense with the HTML renderer
|
|
|
|
|
```
|
|
|
|
|
|
2018-10-20 14:16:07 +08:00
|
|
|
### Provide Your Own Command
|
|
|
|
|
|
|
|
|
|
By default when you add a `[preprocessor.foo]` table to your `book.toml` file,
|
2019-05-18 15:05:57 -07:00
|
|
|
`mdbook` will try to invoke the `mdbook-foo` executable. If you want to use a
|
2018-10-20 14:16:07 +08:00
|
|
|
different program name or pass in command-line arguments, this behaviour can
|
|
|
|
|
be overridden by adding a `command` field.
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[preprocessor.random]
|
|
|
|
|
command = "python random.py"
|
|
|
|
|
```
|
|
|
|
|
|
2018-09-10 20:58:55 +10:00
|
|
|
## Configuring Renderers
|
|
|
|
|
|
2017-05-20 15:03:10 +02:00
|
|
|
### HTML renderer options
|
2018-09-10 20:58:55 +10:00
|
|
|
|
2017-11-12 03:35:10 +08:00
|
|
|
The HTML renderer has a couple of options as well. All the options for the
|
|
|
|
|
renderer need to be specified under the TOML table `[output.html]`.
|
|
|
|
|
|
2017-05-20 15:03:10 +02:00
|
|
|
The following configuration options are available:
|
2015-08-03 14:23:32 +02:00
|
|
|
|
2018-08-02 21:34:26 -05:00
|
|
|
- **theme:** mdBook comes with a default theme and all the resource files needed
|
|
|
|
|
for it. But if this option is set, mdBook will selectively overwrite the theme
|
|
|
|
|
files with the ones found in the specified folder.
|
2019-05-18 15:05:57 -07:00
|
|
|
- **default-theme:** The theme color scheme to select by default in the
|
2018-10-21 13:16:59 +01:00
|
|
|
'Change Theme' dropdown. Defaults to `light`.
|
2019-10-04 19:32:03 -04:00
|
|
|
- **preferred-dark-theme:** The default dark theme. This theme will be used if
|
|
|
|
|
the browser requests the dark version of the site via the
|
|
|
|
|
['prefers-color-scheme'](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
|
|
|
|
CSS media query. Defaults to the same theme as `default-theme`.
|
2018-08-02 21:34:26 -05:00
|
|
|
- **curly-quotes:** Convert straight quotes to curly quotes, except for those
|
|
|
|
|
that occur in code blocks and code spans. Defaults to `false`.
|
2019-05-18 15:05:57 -07:00
|
|
|
- **mathjax-support:** Adds support for [MathJax](mathjax.md). Defaults to
|
|
|
|
|
`false`.
|
2020-05-19 03:09:25 -03:00
|
|
|
- **copy-fonts:** Copies fonts.css and respective font files to the output directory and use them in the default theme. Defaults to `true`.
|
2018-08-02 21:34:26 -05:00
|
|
|
- **google-analytics:** If you use Google Analytics, this option lets you enable
|
|
|
|
|
it by simply specifying your ID in the configuration file.
|
|
|
|
|
- **additional-css:** If you need to slightly change the appearance of your book
|
|
|
|
|
without overwriting the whole style, you can specify a set of stylesheets that
|
|
|
|
|
will be loaded after the default ones where you can surgically change the
|
|
|
|
|
style.
|
2017-11-12 03:35:10 +08:00
|
|
|
- **additional-js:** If you need to add some behaviour to your book without
|
2018-08-02 21:34:26 -05:00
|
|
|
removing the current behaviour, you can specify a set of JavaScript files that
|
|
|
|
|
will be loaded alongside the default one.
|
2018-03-07 07:02:06 -06:00
|
|
|
- **no-section-label:** mdBook by defaults adds section label in table of
|
2018-08-02 21:34:26 -05:00
|
|
|
contents column. For example, "1.", "2.1". Set this option to true to disable
|
|
|
|
|
those labels. Defaults to `false`.
|
2019-10-19 15:56:08 +08:00
|
|
|
- **fold:** A subtable for configuring sidebar section-folding behavior.
|
2018-03-07 07:02:06 -06:00
|
|
|
- **playpen:** A subtable for configuring various playpen settings.
|
2018-08-02 21:34:26 -05:00
|
|
|
- **search:** A subtable for configuring the in-browser search functionality.
|
|
|
|
|
mdBook must be compiled with the `search` feature enabled (on by default).
|
2019-05-18 15:05:57 -07:00
|
|
|
- **git-repository-url:** A url to the git repository for the book. If provided
|
2018-10-15 19:48:54 +01:00
|
|
|
an icon link will be output in the menu bar of the book.
|
2019-05-18 15:05:57 -07:00
|
|
|
- **git-repository-icon:** The FontAwesome icon class to use for the git
|
2018-10-15 19:48:54 +01:00
|
|
|
repository link. Defaults to `fa-github`.
|
2020-05-27 02:52:59 +08:00
|
|
|
- **redirect:** A subtable used for generating redirects when a page is moved.
|
2020-05-30 04:09:43 +08:00
|
|
|
The table contains key-value pairs where the key is where the redirect file
|
|
|
|
|
needs to be created, as an absolute path from the build directory, (e.g.
|
|
|
|
|
`/appendices/bibliography.html`). The value can be any valid URI the
|
|
|
|
|
browser should navigate to (e.g. `https://rust-lang.org/`,
|
|
|
|
|
`/overview.html`, or `../bibliography.html`).
|
2019-11-17 21:36:10 +03:00
|
|
|
|
2019-10-19 15:56:08 +08:00
|
|
|
Available configuration options for the `[output.html.fold]` table:
|
|
|
|
|
|
|
|
|
|
- **enable:** Enable section-folding. When off, all folds are open.
|
|
|
|
|
Defaults to `false`.
|
|
|
|
|
- **level:** The higher the more folded regions are open. When level is 0, all
|
|
|
|
|
folds are closed. Defaults to `0`.
|
2018-03-07 07:02:06 -06:00
|
|
|
|
|
|
|
|
Available configuration options for the `[output.html.playpen]` table:
|
|
|
|
|
|
|
|
|
|
- **editable:** Allow editing the source code. Defaults to `false`.
|
2019-10-17 21:44:54 +11:00
|
|
|
- **copyable:** Display the copy button on code snippets. Defaults to `true`.
|
2018-03-07 07:02:06 -06:00
|
|
|
- **copy-js:** Copy JavaScript files for the editor to the output directory.
|
|
|
|
|
Defaults to `true`.
|
2019-09-24 21:27:02 +08:00
|
|
|
- **line-numbers** Display line numbers on editable sections of code. Requires both `editable` and `copy-js` to be `true`. Defaults to `false`.
|
2018-03-07 07:02:06 -06:00
|
|
|
|
|
|
|
|
[Ace]: https://ace.c9.io/
|
|
|
|
|
|
|
|
|
|
Available configuration options for the `[output.html.search]` table:
|
|
|
|
|
|
2018-06-13 13:11:25 -05:00
|
|
|
- **enable:** Enables the search feature. Defaults to `true`.
|
2018-03-07 07:02:06 -06:00
|
|
|
- **limit-results:** The maximum number of search results. Defaults to `30`.
|
2018-08-02 21:34:26 -05:00
|
|
|
- **teaser-word-count:** The number of words used for a search result teaser.
|
2018-03-07 07:02:06 -06:00
|
|
|
Defaults to `30`.
|
2018-08-02 21:34:26 -05:00
|
|
|
- **use-boolean-and:** Define the logical link between multiple search words. If
|
2019-10-03 11:35:42 +09:00
|
|
|
true, all search words must appear in each result. Defaults to `false`.
|
2018-03-07 07:02:06 -06:00
|
|
|
- **boost-title:** Boost factor for the search result score if a search word
|
|
|
|
|
appears in the header. Defaults to `2`.
|
2018-08-02 21:34:26 -05:00
|
|
|
- **boost-hierarchy:** Boost factor for the search result score if a search word
|
|
|
|
|
appears in the hierarchy. The hierarchy contains all titles of the parent
|
|
|
|
|
documents and all parent headings. Defaults to `1`.
|
|
|
|
|
- **boost-paragraph:** Boost factor for the search result score if a search word
|
|
|
|
|
appears in the text. Defaults to `1`.
|
|
|
|
|
- **expand:** True if search should match longer results e.g. search `micro`
|
2018-03-07 07:02:06 -06:00
|
|
|
should match `microwave`. Defaults to `true`.
|
|
|
|
|
- **heading-split-level:** Search results will link to a section of the document
|
2018-08-02 21:34:26 -05:00
|
|
|
which contains the result. Documents are split into sections by headings this
|
|
|
|
|
level or less. Defaults to `3`. (`### This is a level 3 heading`)
|
|
|
|
|
- **copy-js:** Copy JavaScript files for the search implementation to the output
|
|
|
|
|
directory. Defaults to `true`.
|
2018-03-07 07:02:06 -06:00
|
|
|
|
2018-10-20 14:16:07 +08:00
|
|
|
This shows all available HTML output options in the **book.toml**:
|
|
|
|
|
|
2017-05-20 15:03:10 +02:00
|
|
|
```toml
|
2017-11-12 03:35:10 +08:00
|
|
|
[book]
|
2017-05-20 15:03:10 +02:00
|
|
|
title = "Example book"
|
|
|
|
|
authors = ["John Doe", "Jane Doe"]
|
|
|
|
|
description = "The example book covers examples."
|
|
|
|
|
|
|
|
|
|
[output.html]
|
|
|
|
|
theme = "my-theme"
|
2019-05-18 15:05:57 -07:00
|
|
|
default-theme = "light"
|
2019-09-26 12:13:25 -04:00
|
|
|
preferred-dark-theme = "navy"
|
2017-05-31 22:28:08 -07:00
|
|
|
curly-quotes = true
|
2019-05-18 15:05:57 -07:00
|
|
|
mathjax-support = false
|
2020-05-19 03:09:25 -03:00
|
|
|
copy-fonts = true
|
2017-05-20 15:03:10 +02:00
|
|
|
google-analytics = "123456"
|
|
|
|
|
additional-css = ["custom.css", "custom2.css"]
|
2017-08-10 17:39:28 +02:00
|
|
|
additional-js = ["custom.js"]
|
2019-05-18 15:05:57 -07:00
|
|
|
no-section-label = false
|
2019-10-29 08:04:16 -05:00
|
|
|
git-repository-url = "https://github.com/rust-lang/mdBook"
|
2019-05-18 15:05:57 -07:00
|
|
|
git-repository-icon = "fa-github"
|
2017-11-12 03:35:10 +08:00
|
|
|
|
2019-10-19 15:56:08 +08:00
|
|
|
[output.html.fold]
|
|
|
|
|
enable = false
|
|
|
|
|
level = 0
|
|
|
|
|
|
2017-11-12 03:35:10 +08:00
|
|
|
[output.html.playpen]
|
|
|
|
|
editable = false
|
2019-05-18 15:05:57 -07:00
|
|
|
copy-js = true
|
2019-09-24 21:27:02 +08:00
|
|
|
line-numbers = false
|
2018-03-07 07:02:06 -06:00
|
|
|
|
|
|
|
|
[output.html.search]
|
|
|
|
|
enable = true
|
|
|
|
|
limit-results = 30
|
|
|
|
|
teaser-word-count = 30
|
|
|
|
|
use-boolean-and = true
|
|
|
|
|
boost-title = 2
|
|
|
|
|
boost-hierarchy = 1
|
|
|
|
|
boost-paragraph = 1
|
|
|
|
|
expand = true
|
|
|
|
|
heading-split-level = 3
|
2018-06-13 13:11:25 -05:00
|
|
|
copy-js = true
|
2020-05-27 02:52:59 +08:00
|
|
|
|
|
|
|
|
[output.html.redirect]
|
2020-05-30 04:09:43 +08:00
|
|
|
/appendices/"bibliography.html" = "https://rustc-dev-guide.rust-lang.org/appendix/bibliography.html"
|
|
|
|
|
"/other-installation-methods.html" = "../infra/other-installation-methods.html"
|
2017-05-20 15:03:10 +02:00
|
|
|
```
|
2018-01-14 02:38:43 +08:00
|
|
|
|
2019-08-30 06:20:53 -04:00
|
|
|
### Markdown Renderer
|
|
|
|
|
|
|
|
|
|
The Markdown renderer will run preprocessors and then output the resulting
|
|
|
|
|
Markdown. This is mostly useful for debugging preprocessors, especially in
|
|
|
|
|
conjunction with `mdbook test` to see the Markdown that `mdbook` is passing
|
|
|
|
|
to `rustdoc`.
|
|
|
|
|
|
|
|
|
|
The Markdown renderer is included with `mdbook` but disabled by default.
|
2020-05-27 02:52:59 +08:00
|
|
|
Enable it by adding an empty table to your `book.toml` as follows:
|
2019-08-30 06:20:53 -04:00
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[output.markdown]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
There are no configuration options for the Markdown renderer at this time;
|
|
|
|
|
only whether it is enabled or disabled.
|
|
|
|
|
|
|
|
|
|
See [the preprocessors documentation](#configuring-preprocessors) for how to
|
|
|
|
|
specify which preprocessors should run before the Markdown renderer.
|
|
|
|
|
|
2018-10-20 14:16:07 +08:00
|
|
|
### Custom Renderers
|
|
|
|
|
|
2019-05-18 15:05:57 -07:00
|
|
|
A custom renderer can be enabled by adding a `[output.foo]` table to your
|
|
|
|
|
`book.toml`. Similar to [preprocessors](#configuring-preprocessors) this will
|
|
|
|
|
instruct `mdbook` to pass a representation of the book to `mdbook-foo` for
|
2020-04-21 15:34:59 -07:00
|
|
|
rendering. See the [alternative backends] chapter for more detail.
|
2018-10-20 14:16:07 +08:00
|
|
|
|
2020-04-21 15:34:59 -07:00
|
|
|
The custom renderer has access to all the fields within its table (i.e.
|
|
|
|
|
anything under `[output.foo]`). mdBook checks for two common fields:
|
|
|
|
|
|
|
|
|
|
- **command:** The command to execute for this custom renderer. Defaults to
|
|
|
|
|
the name of the renderer with the `mdbook-` prefix (such as `mdbook-foo`).
|
|
|
|
|
- **optional:** If `true`, then the command will be ignored if it is not
|
|
|
|
|
installed, otherwise mdBook will fail with an error. Defaults to `false`.
|
|
|
|
|
|
|
|
|
|
[alternative backends]: ../for_developers/backends.md
|
2018-01-14 02:38:43 +08:00
|
|
|
|
|
|
|
|
## Environment Variables
|
|
|
|
|
|
2018-02-05 13:00:41 +01:00
|
|
|
All configuration values can be overridden from the command line by setting the
|
2018-01-14 02:38:43 +08:00
|
|
|
corresponding environment variable. Because many operating systems restrict
|
|
|
|
|
environment variables to be alphanumeric characters or `_`, the configuration
|
|
|
|
|
key needs to be formatted slightly differently to the normal `foo.bar.baz` form.
|
|
|
|
|
|
2018-08-02 21:34:26 -05:00
|
|
|
Variables starting with `MDBOOK_` are used for configuration. The key is created
|
|
|
|
|
by removing the `MDBOOK_` prefix and turning the resulting string into
|
|
|
|
|
`kebab-case`. Double underscores (`__`) separate nested keys, while a single
|
|
|
|
|
underscore (`_`) is replaced with a dash (`-`).
|
2018-01-14 02:38:43 +08:00
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
- `MDBOOK_foo` -> `foo`
|
|
|
|
|
- `MDBOOK_FOO` -> `foo`
|
|
|
|
|
- `MDBOOK_FOO__BAR` -> `foo.bar`
|
|
|
|
|
- `MDBOOK_FOO_BAR` -> `foo-bar`
|
|
|
|
|
- `MDBOOK_FOO_bar__baz` -> `foo-bar.baz`
|
|
|
|
|
|
2018-08-02 21:34:26 -05:00
|
|
|
So by setting the `MDBOOK_BOOK__TITLE` environment variable you can override the
|
|
|
|
|
book's title without needing to touch your `book.toml`.
|
2018-01-14 02:38:43 +08:00
|
|
|
|
2018-08-02 21:34:26 -05:00
|
|
|
> **Note:** To facilitate setting more complex config items, the value of an
|
|
|
|
|
> environment variable is first parsed as JSON, falling back to a string if the
|
|
|
|
|
> parse fails.
|
2018-01-14 02:38:43 +08:00
|
|
|
>
|
2018-08-02 21:34:26 -05:00
|
|
|
> This means, if you so desired, you could override all book metadata when
|
|
|
|
|
> building the book with something like
|
2018-01-14 02:38:43 +08:00
|
|
|
>
|
2019-05-18 15:05:57 -07:00
|
|
|
> ```shell
|
2018-01-14 02:38:43 +08:00
|
|
|
> $ export MDBOOK_BOOK="{'title': 'My Awesome Book', authors: ['Michael-F-Bryan']}"
|
|
|
|
|
> $ mdbook build
|
|
|
|
|
> ```
|
|
|
|
|
|
2018-08-02 21:34:26 -05:00
|
|
|
The latter case may be useful in situations where `mdbook` is invoked from a
|
|
|
|
|
script or CI, where it sometimes isn't possible to update the `book.toml` before
|
2019-05-18 15:05:57 -07:00
|
|
|
building.
|