Rewrap guide markdown at 80 columns
Much of the book was wrapped at around 80 columns, but let's make this consistent.
This commit is contained in:
parent
a8a460545f
commit
322e8fcf77
|
@ -1,15 +1,25 @@
|
||||||
# mdBook
|
# mdBook
|
||||||
|
|
||||||
**mdBook** is a command line tool and Rust crate to create books using Markdown files. It's very similar to Gitbook but written in [Rust](http://www.rust-lang.org).
|
**mdBook** is a command line tool and Rust crate to create books using Markdown
|
||||||
|
files. It's very similar to Gitbook but written in
|
||||||
|
[Rust](http://www.rust-lang.org).
|
||||||
|
|
||||||
What you are reading serves as an example of the output of mdBook and at the same time as a high-level documentation.
|
What you are reading serves as an example of the output of mdBook and at the
|
||||||
|
same time as a high-level documentation.
|
||||||
|
|
||||||
mdBook is free and open source, you can find the source code on [Github](https://github.com/rust-lang-nursery/mdBook). Issues and feature requests can be posted on the [Github Issue tracker](https://github.com/rust-lang-nursery/mdBook/issues).
|
mdBook is free and open source, you can find the source code on
|
||||||
|
[GitHub](https://github.com/rust-lang-nursery/mdBook). Issues and feature
|
||||||
|
requests can be posted on the [GitHub issue
|
||||||
|
tracker](https://github.com/rust-lang-nursery/mdBook/issues).
|
||||||
|
|
||||||
## API docs
|
## API docs
|
||||||
|
|
||||||
Alongside this book you can also read the [API docs](https://docs.rs/mdbook/*/mdbook/) generated by Rustdoc if you would like to use mdBook as a crate or write a new renderer and need a more low-level overview.
|
Alongside this book you can also read the [API
|
||||||
|
docs](https://docs.rs/mdbook/*/mdbook/) generated by Rustdoc if you would like
|
||||||
|
to use mdBook as a crate or write a new renderer and need a more low-level
|
||||||
|
overview.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
mdBook, all the source code, is released under the [Mozilla Public License v2.0](https://www.mozilla.org/MPL/2.0/)
|
mdBook, all the source code, is released under the [Mozilla Public License
|
||||||
|
v2.0](https://www.mozilla.org/MPL/2.0/).
|
||||||
|
|
|
@ -6,8 +6,8 @@ The build command is used to render your book:
|
||||||
mdbook build
|
mdbook build
|
||||||
```
|
```
|
||||||
|
|
||||||
It will try to parse your `SUMMARY.md` file to understand the structure of your book
|
It will try to parse your `SUMMARY.md` file to understand the structure of your
|
||||||
and fetch the corresponding files.
|
book and fetch the corresponding files.
|
||||||
|
|
||||||
The rendered output will maintain the same directory structure as the source for
|
The rendered output will maintain the same directory structure as the source for
|
||||||
convenience. Large books will therefore remain structured when rendered.
|
convenience. Large books will therefore remain structured when rendered.
|
||||||
|
@ -28,11 +28,11 @@ your default web browser after building it.
|
||||||
|
|
||||||
#### --dest-dir
|
#### --dest-dir
|
||||||
|
|
||||||
The `--dest-dir` (`-d`) option allows you to change the output directory for
|
The `--dest-dir` (`-d`) option allows you to change the output directory for the
|
||||||
the book. If not specified it will default to the value of the
|
book. If not specified it will default to the value of the `build.build-dir` key
|
||||||
`build.build-dir` key in `book.toml`, or to `./book` relative to the book's
|
in `book.toml`, or to `./book` relative to the book's root directory.
|
||||||
root directory.
|
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
***Note:*** *Make sure to run the build command in the root directory and not in the source directory*
|
***Note:*** *Make sure to run the build command in the root directory and not in
|
||||||
|
the source directory*
|
||||||
|
|
|
@ -19,9 +19,9 @@ mdbook clean path/to/book
|
||||||
#### --dest-dir
|
#### --dest-dir
|
||||||
|
|
||||||
The `--dest-dir` (`-d`) option allows you to override the book's output
|
The `--dest-dir` (`-d`) option allows you to override the book's output
|
||||||
directory, which will be deleted by this command. If not specified it
|
directory, which will be deleted by this command. If not specified it will
|
||||||
will default to the value of the `build.build-dir` key in `book.toml`, or to
|
default to the value of the `build.build-dir` key in `book.toml`, or to `./book`
|
||||||
`./book` relative to the book's root directory.
|
relative to the book's root directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mdbook clean --dest-dir=path/to/book
|
mdbook clean --dest-dir=path/to/book
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# The init command
|
# The init command
|
||||||
|
|
||||||
There is some minimal boilerplate that is the same for every new book. It's for this purpose
|
There is some minimal boilerplate that is the same for every new book. It's for
|
||||||
that mdBook includes an `init` command.
|
this purpose that mdBook includes an `init` command.
|
||||||
|
|
||||||
The `init` command is used like this:
|
The `init` command is used like this:
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ The `init` command is used like this:
|
||||||
mdbook init
|
mdbook init
|
||||||
```
|
```
|
||||||
|
|
||||||
When using the `init` command for the first time, a couple of files will be set up for you:
|
When using the `init` command for the first time, a couple of files will be set
|
||||||
|
up for you:
|
||||||
```bash
|
```bash
|
||||||
book-test/
|
book-test/
|
||||||
├── book
|
├── book
|
||||||
|
@ -18,25 +19,27 @@ book-test/
|
||||||
└── SUMMARY.md
|
└── SUMMARY.md
|
||||||
```
|
```
|
||||||
|
|
||||||
- The `src` directory is were you write your book in markdown. It contains all the source files,
|
- The `src` directory is were you write your book in markdown. It contains all
|
||||||
configuration files, etc.
|
the source files, configuration files, etc.
|
||||||
|
|
||||||
- The `book` directory is where your book is rendered. All the output is ready to be uploaded
|
- The `book` directory is where your book is rendered. All the output is ready
|
||||||
to a server to be seen by your audience.
|
to be uploaded to a server to be seen by your audience.
|
||||||
|
|
||||||
- The `SUMMARY.md` file is the most important file, it's the skeleton of your book and is
|
- The `SUMMARY.md` file is the most important file, it's the skeleton of your
|
||||||
discussed in more detail [in another chapter](../format/summary.md)
|
book and is discussed in more detail [in another
|
||||||
|
chapter](../format/summary.md)
|
||||||
|
|
||||||
#### Tip: Generate chapters from SUMMARY.md
|
#### Tip: Generate chapters from SUMMARY.md
|
||||||
|
|
||||||
When a `SUMMARY.md` file already exists, the `init` command will first parse it and generate the
|
When a `SUMMARY.md` file already exists, the `init` command will first parse it
|
||||||
missing files according to the paths used in the `SUMMARY.md`. This allows you to think and create
|
and generate the missing files according to the paths used in the `SUMMARY.md`.
|
||||||
the whole structure of your book and then let mdBook generate it for you.
|
This allows you to think and create the whole structure of your book and then
|
||||||
|
let mdBook generate it for you.
|
||||||
|
|
||||||
#### Specify a directory
|
#### Specify a directory
|
||||||
|
|
||||||
The `init` command can take a directory as an argument to use as the book's
|
The `init` command can take a directory as an argument to use as the book's root
|
||||||
root instead of the current working directory.
|
instead of the current working directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mdbook init path/to/book
|
mdbook init path/to/book
|
||||||
|
@ -44,8 +47,8 @@ mdbook init path/to/book
|
||||||
|
|
||||||
#### --theme
|
#### --theme
|
||||||
|
|
||||||
When you use the `--theme` flag, the default theme will be copied into a directory
|
When you use the `--theme` flag, the default theme will be copied into a
|
||||||
called `theme` in your source directory so that you can modify it.
|
directory called `theme` in your source directory so that you can modify it.
|
||||||
|
|
||||||
The theme is selectively overwritten, this means that if you don't want to overwrite a
|
The theme is selectively overwritten, this means that if you don't want to
|
||||||
specific file, just delete it and the default file will be used.
|
overwrite a specific file, just delete it and the default file will be used.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# The serve command
|
# The serve command
|
||||||
|
|
||||||
The serve command is used to preview a book by serving it over HTTP at
|
The serve command is used to preview a book by serving it over HTTP at
|
||||||
`localhost:3000` by default. Additionally it watches the book's directory
|
`localhost:3000` by default. Additionally it watches the book's directory for
|
||||||
for changes, rebuilding the book and refreshing clients for each change.
|
changes, rebuilding the book and refreshing clients for each change. A websocket
|
||||||
A websocket connection is used to trigger the client-side refresh.
|
connection is used to trigger the client-side refresh.
|
||||||
|
|
||||||
#### Specify a directory
|
#### Specify a directory
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ mdbook serve path/to/book
|
||||||
to listen on, and the hostname for the browser to connect to for WebSockets.
|
to listen on, and the hostname for the browser to connect to for WebSockets.
|
||||||
|
|
||||||
For example: suppose you have an nginx server for SSL termination which has a
|
For example: suppose you have an nginx server for SSL termination which has a
|
||||||
public address of 192.168.1.100 on port 80 and proxied that to 127.0.0.1 on
|
public address of 192.168.1.100 on port 80 and proxied that to 127.0.0.1 on port
|
||||||
port 8000. To run use the nginx proxy do:
|
8000\. To run use the nginx proxy do:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mdbook serve path/to/book -p 8000 -n 127.0.0.1 --websocket-hostname 192.168.1.100
|
mdbook serve path/to/book -p 8000 -n 127.0.0.1 --websocket-hostname 192.168.1.100
|
||||||
|
@ -34,17 +34,16 @@ configured.
|
||||||
|
|
||||||
#### --open
|
#### --open
|
||||||
|
|
||||||
When you use the `--open` (`-o`) flag, mdbook will open the book in your
|
When you use the `--open` (`-o`) flag, mdbook will open the book in your your
|
||||||
your default web browser after starting the server.
|
default web browser after starting the server.
|
||||||
|
|
||||||
#### --dest-dir
|
#### --dest-dir
|
||||||
|
|
||||||
The `--dest-dir` (`-d`) option allows you to change the output directory for
|
The `--dest-dir` (`-d`) option allows you to change the output directory for the
|
||||||
the book. If not specified it will default to the value of the
|
book. If not specified it will default to the value of the `build.build-dir` key
|
||||||
`build.build-dir` key in `book.toml`, or to `./book` relative to the book's
|
in `book.toml`, or to `./book` relative to the book's root directory.
|
||||||
root directory.
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
***Note:*** *The `serve` command is for testing, and is not intended
|
***Note:*** *The `serve` command is for testing, and is not intended to be a
|
||||||
to be a complete HTTP server for a website.*
|
complete HTTP server for a website.*
|
||||||
|
|
|
@ -5,9 +5,9 @@ When writing a book, you sometimes need to automate some tests. For example,
|
||||||
of code examples that could get outdated. Therefore it is very important for
|
of code examples that could get outdated. Therefore it is very important for
|
||||||
them to be able to automatically test these code examples.
|
them to be able to automatically test these code examples.
|
||||||
|
|
||||||
mdBook supports a `test` command that will run all available tests in a book.
|
mdBook supports a `test` command that will run all available tests in a book. At
|
||||||
At the moment, only rustdoc tests are supported, but this may be expanded upon
|
the moment, only rustdoc tests are supported, but this may be expanded upon in
|
||||||
in the future.
|
the future.
|
||||||
|
|
||||||
#### Disable tests on a code block
|
#### Disable tests on a code block
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ rustdoc *does* test code blocks which have no language specified:
|
||||||
|
|
||||||
#### Specify a directory
|
#### Specify a directory
|
||||||
|
|
||||||
The `test` command can take a directory as an argument to use as the book's
|
The `test` command can take a directory as an argument to use as the book's root
|
||||||
root instead of the current working directory.
|
instead of the current working directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mdbook test path/to/book
|
mdbook test path/to/book
|
||||||
|
@ -47,7 +47,6 @@ comma-delimited list (`-L foo,bar`).
|
||||||
|
|
||||||
#### --dest-dir
|
#### --dest-dir
|
||||||
|
|
||||||
The `--dest-dir` (`-d`) option allows you to change the output directory for
|
The `--dest-dir` (`-d`) option allows you to change the output directory for the
|
||||||
the book. If not specified it will default to the value of the
|
book. If not specified it will default to the value of the `build.build-dir` key
|
||||||
`build.build-dir` key in `book.toml`, or to `./book` relative to the book's
|
in `book.toml`, or to `./book` relative to the book's root directory.
|
||||||
root directory.
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
The `watch` command is useful when you want your book to be rendered on every
|
The `watch` command is useful when you want your book to be rendered on every
|
||||||
file change. You could repeatedly issue `mdbook build` every time a file is
|
file change. You could repeatedly issue `mdbook build` every time a file is
|
||||||
changed. But using `mdbook watch` once will watch your files and will trigger
|
changed. But using `mdbook watch` once will watch your files and will trigger a
|
||||||
a build automatically whenever you modify a file.
|
build automatically whenever you modify a file.
|
||||||
|
|
||||||
#### Specify a directory
|
#### Specify a directory
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ your default web browser.
|
||||||
|
|
||||||
#### --dest-dir
|
#### --dest-dir
|
||||||
|
|
||||||
The `--dest-dir` (`-d`) option allows you to change the output directory for
|
The `--dest-dir` (`-d`) option allows you to change the output directory for the
|
||||||
the book. If not specified it will default to the value of the
|
book. If not specified it will default to the value of the `build.build-dir` key
|
||||||
`build.build-dir` key in `book.toml`, or to `./book` relative to the book's
|
in `book.toml`, or to `./book` relative to the book's root directory.
|
||||||
root directory.
|
|
||||||
|
|
|
@ -34,9 +34,13 @@ script:
|
||||||
Following these instructions will result in your book being published to GitHub
|
Following these instructions will result in your book being published to GitHub
|
||||||
pages after a successful CI run on your repository's `master` branch.
|
pages after a successful CI run on your repository's `master` branch.
|
||||||
|
|
||||||
First, create a new GitHub "Personal Access Token" with the "public_repo" permissions (or "repo" for private repositories). Go to your repository's Travis CI settings page and add an environment variable named `GITHUB_TOKEN` that is marked secure and *not* shown in the logs.
|
First, create a new GitHub "Personal Access Token" with the "public_repo"
|
||||||
|
permissions (or "repo" for private repositories). Go to your repository's Travis
|
||||||
|
CI settings page and add an environment variable named `GITHUB_TOKEN` that is
|
||||||
|
marked secure and *not* shown in the logs.
|
||||||
|
|
||||||
Then, append this snippet to your `.travis.yml` and update the path to the `book` directory:
|
Then, append this snippet to your `.travis.yml` and update the path to the
|
||||||
|
`book` directory:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
deploy:
|
deploy:
|
||||||
|
|
|
@ -89,8 +89,8 @@ fn count_words(ch: &Chapter) -> usize {
|
||||||
|
|
||||||
## Enabling the Backend
|
## Enabling the Backend
|
||||||
|
|
||||||
Now we've got the basics running, we want to actually use it. First, install
|
Now we've got the basics running, we want to actually use it. First, install the
|
||||||
the program.
|
program.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cargo install
|
$ cargo install
|
||||||
|
@ -110,13 +110,12 @@ Then `cd` to the particular book you'd like to count the words of and update its
|
||||||
+ [output.wordcount]
|
+ [output.wordcount]
|
||||||
```
|
```
|
||||||
|
|
||||||
When it loads a book into memory, `mdbook` will inspect your `book.toml` file
|
When it loads a book into memory, `mdbook` will inspect your `book.toml` file to
|
||||||
to try and figure out which backends to use by looking for all `output.*`
|
try and figure out which backends to use by looking for all `output.*` tables.
|
||||||
tables. If none are provided it'll fall back to using the default HTML
|
If none are provided it'll fall back to using the default HTML renderer.
|
||||||
renderer.
|
|
||||||
|
|
||||||
Notably, this means if you want to add your own custom backend you'll also
|
Notably, this means if you want to add your own custom backend you'll also need
|
||||||
need to make sure to add the HTML backend, even if its table just stays empty.
|
to make sure to add the HTML backend, even if its table just stays empty.
|
||||||
|
|
||||||
Now you just need to build your book like normal, and everything should *Just
|
Now you just need to build your book like normal, and everything should *Just
|
||||||
Work*.
|
Work*.
|
||||||
|
@ -168,14 +167,14 @@ arguments or be an interpreted script), you can use the `command` field.
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Now imagine you don't want to count the number of words on a particular chapter
|
Now imagine you don't want to count the number of words on a particular chapter
|
||||||
(it might be generated text/code, etc). The canonical way to do this is via
|
(it might be generated text/code, etc). The canonical way to do this is via the
|
||||||
the usual `book.toml` configuration file by adding items to your `[output.foo]`
|
usual `book.toml` configuration file by adding items to your `[output.foo]`
|
||||||
table.
|
table.
|
||||||
|
|
||||||
The `Config` can be treated roughly as a nested hashmap which lets you call
|
The `Config` can be treated roughly as a nested hashmap which lets you call
|
||||||
methods like `get()` to access the config's contents, with a
|
methods like `get()` to access the config's contents, with a
|
||||||
`get_deserialized()` convenience method for retrieving a value and
|
`get_deserialized()` convenience method for retrieving a value and automatically
|
||||||
automatically deserializing to some arbitrary type `T`.
|
deserializing to some arbitrary type `T`.
|
||||||
|
|
||||||
To implement this, we'll create our own serializable `WordcountConfig` struct
|
To implement this, we'll create our own serializable `WordcountConfig` struct
|
||||||
which will encapsulate all configuration for this backend.
|
which will encapsulate all configuration for this backend.
|
||||||
|
@ -319,12 +318,12 @@ init has an odd number of words!
|
||||||
```
|
```
|
||||||
|
|
||||||
As you've probably already noticed, output from the plugin's subprocess is
|
As you've probably already noticed, output from the plugin's subprocess is
|
||||||
immediately passed through to the user. It is encouraged for plugins to
|
immediately passed through to the user. It is encouraged for plugins to follow
|
||||||
follow the "rule of silence" and only generate output when necessary (e.g. an
|
the "rule of silence" and only generate output when necessary (e.g. an error in
|
||||||
error in generation or a warning).
|
generation or a warning).
|
||||||
|
|
||||||
All environment variables are passed through to the backend, allowing you to
|
All environment variables are passed through to the backend, allowing you to use
|
||||||
use the usual `RUST_LOG` to control logging verbosity.
|
the usual `RUST_LOG` to control logging verbosity.
|
||||||
|
|
||||||
|
|
||||||
## Wrapping Up
|
## Wrapping Up
|
||||||
|
|
|
@ -33,10 +33,11 @@ pub struct PreprocessorContext {
|
||||||
|
|
||||||
## A complete Example
|
## A complete Example
|
||||||
|
|
||||||
The magic happens within the `run(...)` method of the [`Preprocessor`][preprocessor-docs] trait implementation.
|
The magic happens within the `run(...)` method of the
|
||||||
|
[`Preprocessor`][preprocessor-docs] trait implementation.
|
||||||
|
|
||||||
As direct access to the chapters is not possible, you will probably end up iterating
|
As direct access to the chapters is not possible, you will probably end up
|
||||||
them using `for_each_mut(...)`:
|
iterating them using `for_each_mut(...)`:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
book.for_each_mut(|item: &mut BookItem| {
|
book.for_each_mut(|item: &mut BookItem| {
|
||||||
|
@ -56,15 +57,15 @@ book.for_each_mut(|item: &mut BookItem| {
|
||||||
```
|
```
|
||||||
|
|
||||||
The `chapter.content` is just a markdown formatted string, and you will have to
|
The `chapter.content` is just a markdown formatted string, and you will have to
|
||||||
process it in some way. Even though it's entirely possible to implement some sort of
|
process it in some way. Even though it's entirely possible to implement some
|
||||||
manual find & replace operation, if that feels too unsafe you can use [`pulldown-cmark`][pc]
|
sort of manual find & replace operation, if that feels too unsafe you can use
|
||||||
to parse the string into events and work on them instead.
|
[`pulldown-cmark`][pc] to parse the string into events and work on them instead.
|
||||||
|
|
||||||
Finally you can use [`pulldown-cmark-to-cmark`][pctc] to transform these events back to
|
Finally you can use [`pulldown-cmark-to-cmark`][pctc] to transform these events
|
||||||
a string.
|
back to a string.
|
||||||
|
|
||||||
The following code block shows how to remove all emphasis from markdown, and do so
|
The following code block shows how to remove all emphasis from markdown, and do
|
||||||
safely.
|
so safely.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn remove_emphasis(num_removed_items: &mut i32, chapter: &mut Chapter) -> Result<String> {
|
fn remove_emphasis(num_removed_items: &mut i32, chapter: &mut Chapter) -> Result<String> {
|
||||||
|
|
|
@ -23,8 +23,9 @@ limit-results = 15
|
||||||
|
|
||||||
## Supported configuration options
|
## Supported configuration options
|
||||||
|
|
||||||
It is important to note that **any** relative path specified in the in the configuration will
|
It is important to note that **any** relative path specified in the in the
|
||||||
always be taken relative from the root of the book where the configuration file is located.
|
configuration will always be taken relative from the root of the book where the
|
||||||
|
configuration file is located.
|
||||||
|
|
||||||
|
|
||||||
### General metadata
|
### General metadata
|
||||||
|
@ -58,13 +59,18 @@ This controls the build process of your book.
|
||||||
will be created when the book is built (i.e. `create-missing = true`). If this
|
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
|
is `false` then the build process will instead exit with an error if any files
|
||||||
do not exist.
|
do not exist.
|
||||||
- **preprocess:** Specify which preprocessors to be applied. Default is `["links", "index"]`. To disable default preprocessors, pass an empty array `[]` in.
|
- **preprocess:** Specify which preprocessors to be applied. Default is
|
||||||
|
`["links", "index"]`. To disable default preprocessors, pass an empty array
|
||||||
|
`[]` in.
|
||||||
|
|
||||||
|
|
||||||
The following preprocessors are available and included by default:
|
The following preprocessors are available and included by default:
|
||||||
|
|
||||||
- `links`: Expand the `{{# playpen}}` and `{{# include}}` handlebars helpers in a chapter.
|
- `links`: Expand the `{{# playpen}}` and `{{# include}}` handlebars helpers in
|
||||||
- `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.
|
a chapter.
|
||||||
|
- `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.
|
||||||
|
|
||||||
|
|
||||||
**book.toml**
|
**book.toml**
|
||||||
|
@ -81,27 +87,26 @@ renderer need to be specified under the TOML table `[output.html]`.
|
||||||
|
|
||||||
The following configuration options are available:
|
The following configuration options are available:
|
||||||
|
|
||||||
- **theme:** mdBook comes with a default theme and all the resource files
|
- **theme:** mdBook comes with a default theme and all the resource files needed
|
||||||
needed for it. But if this option is set, mdBook will selectively overwrite
|
for it. But if this option is set, mdBook will selectively overwrite the theme
|
||||||
the theme files with the ones found in the specified folder.
|
files with the ones found in the specified folder.
|
||||||
- **curly-quotes:** Convert straight quotes to curly quotes, except for
|
- **curly-quotes:** Convert straight quotes to curly quotes, except for those
|
||||||
those that occur in code blocks and code spans. Defaults to `false`.
|
that occur in code blocks and code spans. Defaults to `false`.
|
||||||
- **google-analytics:** If you use Google Analytics, this option lets you
|
- **google-analytics:** If you use Google Analytics, this option lets you enable
|
||||||
enable it by simply specifying your ID in the configuration file.
|
it by simply specifying your ID in the configuration file.
|
||||||
- **additional-css:** If you need to slightly change the appearance of your
|
- **additional-css:** If you need to slightly change the appearance of your book
|
||||||
book without overwriting the whole style, you can specify a set of
|
without overwriting the whole style, you can specify a set of stylesheets that
|
||||||
stylesheets that will be loaded after the default ones where you can
|
will be loaded after the default ones where you can surgically change the
|
||||||
surgically change the style.
|
style.
|
||||||
- **additional-js:** If you need to add some behaviour to your book without
|
- **additional-js:** If you need to add some behaviour to your book without
|
||||||
removing the current behaviour, you can specify a set of JavaScript files
|
removing the current behaviour, you can specify a set of JavaScript files that
|
||||||
that will be loaded alongside the default one.
|
will be loaded alongside the default one.
|
||||||
- **no-section-label:** mdBook by defaults adds section label in table of
|
- **no-section-label:** mdBook by defaults adds section label in table of
|
||||||
contents column. For example, "1.", "2.1". Set this option to true to
|
contents column. For example, "1.", "2.1". Set this option to true to disable
|
||||||
disable those labels. Defaults to `false`.
|
those labels. Defaults to `false`.
|
||||||
- **playpen:** A subtable for configuring various playpen settings.
|
- **playpen:** A subtable for configuring various playpen settings.
|
||||||
- **search:** A subtable for configuring the in-browser search
|
- **search:** A subtable for configuring the in-browser search functionality.
|
||||||
functionality. mdBook must be compiled with the `search` feature enabled
|
mdBook must be compiled with the `search` feature enabled (on by default).
|
||||||
(on by default).
|
|
||||||
|
|
||||||
Available configuration options for the `[output.html.playpen]` table:
|
Available configuration options for the `[output.html.playpen]` table:
|
||||||
|
|
||||||
|
@ -117,23 +122,22 @@ Available configuration options for the `[output.html.search]` table:
|
||||||
- **limit-results:** The maximum number of search results. Defaults to `30`.
|
- **limit-results:** The maximum number of search results. Defaults to `30`.
|
||||||
- **teaser-word-count:** The number of words used for a search result teaser.
|
- **teaser-word-count:** The number of words used for a search result teaser.
|
||||||
Defaults to `30`.
|
Defaults to `30`.
|
||||||
- **use-boolean-and:** Define the logical link between multiple search words.
|
- **use-boolean-and:** Define the logical link between multiple search words. If
|
||||||
If true, all search words must appear in each result. Defaults to `true`.
|
true, all search words must appear in each result. Defaults to `true`.
|
||||||
- **boost-title:** Boost factor for the search result score if a search word
|
- **boost-title:** Boost factor for the search result score if a search word
|
||||||
appears in the header. Defaults to `2`.
|
appears in the header. Defaults to `2`.
|
||||||
- **boost-hierarchy:** Boost factor for the search result score if a search
|
- **boost-hierarchy:** Boost factor for the search result score if a search word
|
||||||
word appears in the hierarchy. The hierarchy contains all titles of the
|
appears in the hierarchy. The hierarchy contains all titles of the parent
|
||||||
parent documents and all parent headings. Defaults to `1`.
|
documents and all parent headings. Defaults to `1`.
|
||||||
- **boost-paragraph:** Boost factor for the search result score if a search
|
- **boost-paragraph:** Boost factor for the search result score if a search word
|
||||||
word appears in the text. Defaults to `1`.
|
appears in the text. Defaults to `1`.
|
||||||
- **expand:** True if search should match longer results e.g. search `micro`
|
- **expand:** True if search should match longer results e.g. search `micro`
|
||||||
should match `microwave`. Defaults to `true`.
|
should match `microwave`. Defaults to `true`.
|
||||||
- **heading-split-level:** Search results will link to a section of the document
|
- **heading-split-level:** Search results will link to a section of the document
|
||||||
which contains the result. Documents are split into sections by headings
|
which contains the result. Documents are split into sections by headings this
|
||||||
this level or less.
|
level or less. Defaults to `3`. (`### This is a level 3 heading`)
|
||||||
Defaults to `3`. (`### This is a level 3 heading`)
|
- **copy-js:** Copy JavaScript files for the search implementation to the output
|
||||||
- **copy-js:** Copy JavaScript files for the search implementation to the
|
directory. Defaults to `true`.
|
||||||
output directory. Defaults to `true`.
|
|
||||||
|
|
||||||
This shows all available options in the **book.toml**:
|
This shows all available options in the **book.toml**:
|
||||||
```toml
|
```toml
|
||||||
|
@ -180,10 +184,10 @@ corresponding environment variable. Because many operating systems restrict
|
||||||
environment variables to be alphanumeric characters or `_`, the configuration
|
environment variables to be alphanumeric characters or `_`, the configuration
|
||||||
key needs to be formatted slightly differently to the normal `foo.bar.baz` form.
|
key needs to be formatted slightly differently to the normal `foo.bar.baz` form.
|
||||||
|
|
||||||
Variables starting with `MDBOOK_` are used for configuration. The key is
|
Variables starting with `MDBOOK_` are used for configuration. The key is created
|
||||||
created by removing the `MDBOOK_` prefix and turning the resulting
|
by removing the `MDBOOK_` prefix and turning the resulting string into
|
||||||
string into `kebab-case`. Double underscores (`__`) separate nested
|
`kebab-case`. Double underscores (`__`) separate nested keys, while a single
|
||||||
keys, while a single underscore (`_`) is replaced with a dash (`-`).
|
underscore (`_`) is replaced with a dash (`-`).
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
@ -193,21 +197,21 @@ For example:
|
||||||
- `MDBOOK_FOO_BAR` -> `foo-bar`
|
- `MDBOOK_FOO_BAR` -> `foo-bar`
|
||||||
- `MDBOOK_FOO_bar__baz` -> `foo-bar.baz`
|
- `MDBOOK_FOO_bar__baz` -> `foo-bar.baz`
|
||||||
|
|
||||||
So by setting the `MDBOOK_BOOK__TITLE` environment variable you can
|
So by setting the `MDBOOK_BOOK__TITLE` environment variable you can override the
|
||||||
override the book's title without needing to touch your `book.toml`.
|
book's title without needing to touch your `book.toml`.
|
||||||
|
|
||||||
> **Note:** To facilitate setting more complex config items, the value
|
> **Note:** To facilitate setting more complex config items, the value of an
|
||||||
> of an environment variable is first parsed as JSON, falling back to a
|
> environment variable is first parsed as JSON, falling back to a string if the
|
||||||
> string if the parse fails.
|
> parse fails.
|
||||||
>
|
>
|
||||||
> This means, if you so desired, you could override all book metadata
|
> This means, if you so desired, you could override all book metadata when
|
||||||
> when building the book with something like
|
> building the book with something like
|
||||||
>
|
>
|
||||||
> ```text
|
> ```text
|
||||||
> $ export MDBOOK_BOOK="{'title': 'My Awesome Book', authors: ['Michael-F-Bryan']}"
|
> $ export MDBOOK_BOOK="{'title': 'My Awesome Book', authors: ['Michael-F-Bryan']}"
|
||||||
> $ mdbook build
|
> $ mdbook build
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
The latter case may be useful in situations where `mdbook` is invoked
|
The latter case may be useful in situations where `mdbook` is invoked from a
|
||||||
from a script or CI, where it sometimes isn't possible to update the
|
script or CI, where it sometimes isn't possible to update the `book.toml` before
|
||||||
`book.toml` before building.
|
building.
|
||||||
|
|
|
@ -1,29 +1,37 @@
|
||||||
# MathJax Support
|
# MathJax Support
|
||||||
|
|
||||||
mdBook has optional support for math equations through [MathJax](https://www.mathjax.org/).
|
mdBook has optional support for math equations through
|
||||||
|
[MathJax](https://www.mathjax.org/).
|
||||||
|
|
||||||
To enable MathJax, you need to add the `mathjax-support` key to your `book.toml` under the `output.html` section.
|
To enable MathJax, you need to add the `mathjax-support` key to your `book.toml`
|
||||||
|
under the `output.html` section.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[output.html]
|
[output.html]
|
||||||
mathjax-support = true
|
mathjax-support = true
|
||||||
```
|
```
|
||||||
|
|
||||||
>**Note:**
|
>**Note:** The usual delimiters MathJax uses are not yet supported. You can't
|
||||||
The usual delimiters MathJax uses are not yet supported. You can't currently use `$$ ... $$` as delimiters and the `\[ ... \]` delimiters need an extra backslash to work. Hopefully this limitation will be lifted soon.
|
currently use `$$ ... $$` as delimiters and the `\[ ... \]` delimiters need an
|
||||||
|
extra backslash to work. Hopefully this limitation will be lifted soon.
|
||||||
|
|
||||||
>**Note:**
|
>**Note:** When you use double backslashes in MathJax blocks (for example in
|
||||||
> When you use double backslashes in MathJax blocks (for example in commands such as `\begin{cases} \frac 1 2 \\ \frac 3 4 \end{cases}`) you need to add _two extra_ backslashes (e.g., `\begin{cases} \frac 1 2 \\\\ \frac 3 4 \end{cases}`).
|
> commands such as `\begin{cases} \frac 1 2 \\ \frac 3 4 \end{cases}`) you need
|
||||||
|
> to add _two extra_ backslashes (e.g., `\begin{cases} \frac 1 2 \\\\ \frac 3 4
|
||||||
|
> \end{cases}`).
|
||||||
|
|
||||||
|
|
||||||
### Inline equations
|
### Inline equations
|
||||||
Inline equations are delimited by `\\(` and `\\)`. So for example, to render the following inline equation \\( \int x dx = \frac{x^2}{2} + C \\) you would write the following:
|
Inline equations are delimited by `\\(` and `\\)`. So for example, to render the
|
||||||
|
following inline equation \\( \int x dx = \frac{x^2}{2} + C \\) you would write
|
||||||
|
the following:
|
||||||
```
|
```
|
||||||
\\( \int x dx = \frac{x^2}{2} + C \\)
|
\\( \int x dx = \frac{x^2}{2} + C \\)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Block equations
|
### Block equations
|
||||||
Block equations are delimited by `\\[` and `\\]`. To render the following equation
|
Block equations are delimited by `\\[` and `\\]`. To render the following
|
||||||
|
equation
|
||||||
|
|
||||||
\\[ \mu = \frac{1}{N} \sum_{i=0} x_i \\]
|
\\[ \mu = \frac{1}{N} \sum_{i=0} x_i \\]
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
## Hiding code lines
|
## Hiding code lines
|
||||||
|
|
||||||
There is a feature in mdBook that lets you hide code lines by prepending them with a `#`.
|
There is a feature in mdBook that lets you hide code lines by prepending them
|
||||||
|
with a `#`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# fn main() {
|
# fn main() {
|
||||||
|
@ -34,7 +35,10 @@ With the following syntax, you can include files into your book:
|
||||||
|
|
||||||
The path to the file has to be relative from the current source file.
|
The path to the file has to be relative from the current source file.
|
||||||
|
|
||||||
Usually, this command is used for including code snippets and examples. In this case, oftens one would include a specific part of the file e.g. which only contains the relevant lines for the example. We support four different modes of partial includes:
|
Usually, this command is used for including code snippets and examples. In this
|
||||||
|
case, oftens one would include a specific part of the file e.g. which only
|
||||||
|
contains the relevant lines for the example. We support four different modes of
|
||||||
|
partial includes:
|
||||||
|
|
||||||
```hbs
|
```hbs
|
||||||
\{{#include file.rs:2}}
|
\{{#include file.rs:2}}
|
||||||
|
@ -43,7 +47,11 @@ Usually, this command is used for including code snippets and examples. In this
|
||||||
\{{#include file.rs:2:10}}
|
\{{#include file.rs:2:10}}
|
||||||
```
|
```
|
||||||
|
|
||||||
The first command only includes the second line from file `file.rs`. The second command includes all lines up to line 10, i.e. the lines from 11 till the end of the file are omitted. The third command includes all lines from line 2, i.e. the first line is omitted. The last command includes the excerpt of `file.rs` consisting of lines 2 to 10.
|
The first command only includes the second line from file `file.rs`. The second
|
||||||
|
command includes all lines up to line 10, i.e. the lines from 11 till the end of
|
||||||
|
the file are omitted. The third command includes all lines from line 2, i.e. the
|
||||||
|
first line is omitted. The last command includes the excerpt of `file.rs`
|
||||||
|
consisting of lines 2 to 10.
|
||||||
|
|
||||||
## Inserting runnable Rust files
|
## Inserting runnable Rust files
|
||||||
|
|
||||||
|
@ -55,7 +63,9 @@ With the following syntax, you can insert runnable Rust files into your book:
|
||||||
|
|
||||||
The path to the Rust file has to be relative from the current source file.
|
The path to the Rust file has to be relative from the current source file.
|
||||||
|
|
||||||
When play is clicked, the code snippet will be sent to the [Rust Playpen] to be compiled and run. The result is sent back and displayed directly underneath the code.
|
When play is clicked, the code snippet will be sent to the [Rust Playpen] to be
|
||||||
|
compiled and run. The result is sent back and displayed directly underneath the
|
||||||
|
code.
|
||||||
|
|
||||||
Here is what a rendered code snippet looks like:
|
Here is what a rendered code snippet looks like:
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,38 @@
|
||||||
# SUMMARY.md
|
# SUMMARY.md
|
||||||
|
|
||||||
The summary file is used by mdBook to know what chapters to include,
|
The summary file is used by mdBook to know what chapters to include, in what
|
||||||
in what order they should appear, what their hierarchy is and where the source files are.
|
order they should appear, what their hierarchy is and where the source files
|
||||||
Without this file, there is no book.
|
are. Without this file, there is no book.
|
||||||
|
|
||||||
Even though `SUMMARY.md` is a markdown file, the formatting is very strict to
|
Even though `SUMMARY.md` is a markdown file, the formatting is very strict to
|
||||||
allow for easy parsing. Let's see how you should format your `SUMMARY.md` file.
|
allow for easy parsing. Let's see how you should format your `SUMMARY.md` file.
|
||||||
|
|
||||||
#### Allowed elements
|
#### Allowed elements
|
||||||
|
|
||||||
1. ***Title*** It's common practice to begin with a title, generally
|
1. ***Title*** It's common practice to begin with a title, generally <code
|
||||||
<code class="language-markdown"># Summary</code>.
|
class="language-markdown"># Summary</code>. But it is not mandatory, the
|
||||||
But it is not mandatory, the parser just ignores it. So you can too
|
parser just ignores it. So you can too if you feel like it.
|
||||||
if you feel like it.
|
|
||||||
|
|
||||||
2. ***Prefix Chapter*** Before the main numbered chapters you can add a couple of elements that will not be numbered. This is useful for
|
2. ***Prefix Chapter*** Before the main numbered chapters you can add a couple
|
||||||
forewords, introductions, etc. There are however some constraints. You can not nest prefix chapters, they should all be on the root level. And you can not add prefix chapters once you have added numbered chapters.
|
of elements that will not be numbered. This is useful for forewords,
|
||||||
|
introductions, etc. There are however some constraints. You can not nest
|
||||||
|
prefix chapters, they should all be on the root level. And you can not add
|
||||||
|
prefix chapters once you have added numbered chapters.
|
||||||
```markdown
|
```markdown
|
||||||
[Title of prefix element](relative/path/to/markdown.md)
|
[Title of prefix element](relative/path/to/markdown.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
3. ***Numbered Chapter*** Numbered chapters are the main content of the book, they will be numbered and can be nested,
|
3. ***Numbered Chapter*** Numbered chapters are the main content of the book,
|
||||||
resulting in a nice hierarchy (chapters, sub-chapters, etc.)
|
they will be numbered and can be nested, resulting in a nice hierarchy
|
||||||
|
(chapters, sub-chapters, etc.)
|
||||||
```markdown
|
```markdown
|
||||||
- [Title of the Chapter](relative/path/to/markdown.md)
|
- [Title of the Chapter](relative/path/to/markdown.md)
|
||||||
```
|
```
|
||||||
You can either use `-` or `*` to indicate a numbered chapter.
|
You can either use `-` or `*` to indicate a numbered chapter.
|
||||||
|
|
||||||
4. ***Suffix Chapter*** After the numbered chapters you can add a couple of non-numbered chapters. They are the same as prefix chapters but come after the numbered chapters instead of before.
|
4. ***Suffix Chapter*** After the numbered chapters you can add a couple of
|
||||||
|
non-numbered chapters. They are the same as prefix chapters but come after
|
||||||
|
the numbered chapters instead of before.
|
||||||
|
|
||||||
All other elements are unsupported and will be ignored at best or result in an error.
|
All other elements are unsupported and will be ignored at best or result in an
|
||||||
|
error.
|
||||||
|
|
|
@ -1,22 +1,34 @@
|
||||||
# Theme
|
# Theme
|
||||||
|
|
||||||
The default renderer uses a [handlebars](http://handlebarsjs.com/) template to render your markdown files and comes with a default theme
|
The default renderer uses a [handlebars](http://handlebarsjs.com/) template to
|
||||||
included in the mdBook binary.
|
render your markdown files and comes with a default theme included in the mdBook
|
||||||
|
binary.
|
||||||
|
|
||||||
The theme is totally customizable, you can selectively replace every file from the theme by your own by adding a
|
The theme is totally customizable, you can selectively replace every file from
|
||||||
`theme` directory next to `src` folder in your project root. Create a new file with the name of the file you want to override
|
the theme by your own by adding a `theme` directory next to `src` folder in your
|
||||||
|
project root. Create a new file with the name of the file you want to override
|
||||||
and now that file will be used instead of the default file.
|
and now that file will be used instead of the default file.
|
||||||
|
|
||||||
Here are the files you can override:
|
Here are the files you can override:
|
||||||
|
|
||||||
- ***index.hbs*** is the handlebars template.
|
- ***index.hbs*** is the handlebars template.
|
||||||
- ***book.css*** is the style used in the output. If you want to change the design of your book, this is probably the file you want to modify. Sometimes in conjunction with `index.hbs` when you want to radically change the layout.
|
- ***book.css*** is the style used in the output. If you want to change the
|
||||||
- ***book.js*** is mostly used to add client side functionality, like hiding / un-hiding the sidebar, changing the theme, ...
|
design of your book, this is probably the file you want to modify. Sometimes
|
||||||
- ***highlight.js*** is the JavaScript that is used to highlight code snippets, you should not need to modify this.
|
in conjunction with `index.hbs` when you want to radically change the layout.
|
||||||
|
- ***book.js*** is mostly used to add client side functionality, like hiding /
|
||||||
|
un-hiding the sidebar, changing the theme, ...
|
||||||
|
- ***highlight.js*** is the JavaScript that is used to highlight code snippets,
|
||||||
|
you should not need to modify this.
|
||||||
- ***highlight.css*** is the theme used for the code highlighting
|
- ***highlight.css*** is the theme used for the code highlighting
|
||||||
- ***favicon.png*** the favicon that will be used
|
- ***favicon.png*** the favicon that will be used
|
||||||
|
|
||||||
Generally, when you want to tweak the theme, you don't need to override all the files. If you only need changes in the stylesheet,
|
Generally, when you want to tweak the theme, you don't need to override all the
|
||||||
there is no point in overriding all the other files. Because custom files take precedence over built-in ones, they will not get updated with new fixes / features.
|
files. If you only need changes in the stylesheet, there is no point in
|
||||||
|
overriding all the other files. Because custom files take precedence over
|
||||||
|
built-in ones, they will not get updated with new fixes / features.
|
||||||
|
|
||||||
**Note:** When you override a file, it is possible that you break some functionality. Therefore I recommend to use the file from the default theme as template and only add / modify what you need. You can copy the default theme into your source directory automatically by using `mdbook init --theme` just remove the files you don't want to override.
|
**Note:** When you override a file, it is possible that you break some
|
||||||
|
functionality. Therefore I recommend to use the file from the default theme as
|
||||||
|
template and only add / modify what you need. You can copy the default theme
|
||||||
|
into your source directory automatically by using `mdbook init --theme` just
|
||||||
|
remove the files you don't want to override.
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
# Editor
|
# Editor
|
||||||
|
|
||||||
In addition to providing runnable code playpens, mdBook optionally allows them to be editable. In order to enable editable code blocks, the following needs to be added to the ***book.toml***:
|
In addition to providing runnable code playpens, mdBook optionally allows them
|
||||||
|
to be editable. In order to enable editable code blocks, the following needs to
|
||||||
|
be added to the ***book.toml***:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[output.html.playpen]
|
[output.html.playpen]
|
||||||
editable = true
|
editable = true
|
||||||
```
|
```
|
||||||
|
|
||||||
To make a specific block available for editing, the attribute `editable` needs to be added to it:
|
To make a specific block available for editing, the attribute `editable` needs
|
||||||
|
to be added to it:
|
||||||
|
|
||||||
<pre><code class="language-markdown">```rust,editable
|
<pre><code class="language-markdown">```rust,editable
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -29,7 +32,8 @@ Note the new `Undo Changes` button in the editable playpens.
|
||||||
|
|
||||||
## Customizing the Editor
|
## Customizing the Editor
|
||||||
|
|
||||||
By default, the editor is the [Ace](https://ace.c9.io/) editor, but, if desired, the functionality may be overriden by providing a different folder:
|
By default, the editor is the [Ace](https://ace.c9.io/) editor, but, if desired,
|
||||||
|
the functionality may be overriden by providing a different folder:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[output.html.playpen]
|
[output.html.playpen]
|
||||||
|
@ -37,4 +41,6 @@ editable = true
|
||||||
editor = "/path/to/editor"
|
editor = "/path/to/editor"
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that for the editor changes to function correctly, the `book.js` inside of the `theme` folder will need to be overriden as it has some couplings with the default Ace editor.
|
Note that for the editor changes to function correctly, the `book.js` inside of
|
||||||
|
the `theme` folder will need to be overriden as it has some couplings with the
|
||||||
|
default Ace editor.
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
# index.hbs
|
# index.hbs
|
||||||
|
|
||||||
`index.hbs` is the handlebars template that is used to render the book.
|
`index.hbs` is the handlebars template that is used to render the book. The
|
||||||
The markdown files are processed to html and then injected in that template.
|
markdown files are processed to html and then injected in that template.
|
||||||
|
|
||||||
If you want to change the layout or style of your book, chances are that you will
|
If you want to change the layout or style of your book, chances are that you
|
||||||
have to modify this template a little bit. Here is what you need to know.
|
will have to modify this template a little bit. Here is what you need to know.
|
||||||
|
|
||||||
## Data
|
## Data
|
||||||
|
|
||||||
A lot of data is exposed to the handlebars template with the "context".
|
A lot of data is exposed to the handlebars template with the "context". In the
|
||||||
In the handlebars template you can access this information by using
|
handlebars template you can access this information by using
|
||||||
|
|
||||||
```handlebars
|
```handlebars
|
||||||
{{name_of_property}}
|
{{name_of_property}}
|
||||||
|
@ -17,25 +17,31 @@ In the handlebars template you can access this information by using
|
||||||
|
|
||||||
Here is a list of the properties that are exposed:
|
Here is a list of the properties that are exposed:
|
||||||
|
|
||||||
- ***language*** Language of the book in the form `en`. To use in <code class="language-html">\<html lang="{{ language }}"></code> for example.
|
- ***language*** Language of the book in the form `en`. To use in <code
|
||||||
At the moment it is hardcoded.
|
class="language-html">\<html lang="{{ language }}"></code> for example. At the
|
||||||
|
moment it is hardcoded.
|
||||||
- ***title*** Title of the book, as specified in `book.toml`
|
- ***title*** Title of the book, as specified in `book.toml`
|
||||||
- ***chapter_title*** Title of the current chapter, as listed in `SUMMARY.md`
|
- ***chapter_title*** Title of the current chapter, as listed in `SUMMARY.md`
|
||||||
|
|
||||||
- ***path*** Relative path to the original markdown file from the source directory
|
- ***path*** Relative path to the original markdown file from the source
|
||||||
|
directory
|
||||||
- ***content*** This is the rendered markdown.
|
- ***content*** This is the rendered markdown.
|
||||||
- ***path_to_root*** This is a path containing exclusively `../`'s that points to the root of the book from the current file.
|
- ***path_to_root*** This is a path containing exclusively `../`'s that points
|
||||||
Since the original directory structure is maintained, it is useful to prepend relative links with this `path_to_root`.
|
to the root of the book from the current file. Since the original directory
|
||||||
|
structure is maintained, it is useful to prepend relative links with this
|
||||||
|
`path_to_root`.
|
||||||
|
|
||||||
- ***chapters*** Is an array of dictionaries of the form
|
- ***chapters*** Is an array of dictionaries of the form
|
||||||
```json
|
```json
|
||||||
{"section": "1.2.1", "name": "name of this chapter", "path": "dir/markdown.md"}
|
{"section": "1.2.1", "name": "name of this chapter", "path": "dir/markdown.md"}
|
||||||
```
|
```
|
||||||
containing all the chapters of the book. It is used for example to construct the table of contents (sidebar).
|
containing all the chapters of the book. It is used for example to construct
|
||||||
|
the table of contents (sidebar).
|
||||||
|
|
||||||
## Handlebars Helpers
|
## Handlebars Helpers
|
||||||
|
|
||||||
In addition to the properties you can access, there are some handlebars helpers at your disposal.
|
In addition to the properties you can access, there are some handlebars helpers
|
||||||
|
at your disposal.
|
||||||
|
|
||||||
### 1. toc
|
### 1. toc
|
||||||
|
|
||||||
|
@ -87,4 +93,5 @@ In addition to the properties you can access, there are some handlebars helpers
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
*If you would like other properties or helpers exposed, please [create a new issue](https://github.com/rust-lang-nursery/mdBook/issues)*
|
*If you would like other properties or helpers exposed, please [create a new
|
||||||
|
issue](https://github.com/rust-lang-nursery/mdBook/issues)*
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Syntax Highlighting
|
# Syntax Highlighting
|
||||||
|
|
||||||
For syntax highlighting I use [Highlight.js](https://highlightjs.org) with a custom theme.
|
For syntax highlighting I use [Highlight.js](https://highlightjs.org) with a
|
||||||
|
custom theme.
|
||||||
|
|
||||||
Automatic language detection has been turned off, so you will probably want to
|
Automatic language detection has been turned off, so you will probably want to
|
||||||
specify the programming language you use like this
|
specify the programming language you use like this
|
||||||
|
@ -12,19 +13,23 @@ fn main() {
|
||||||
```</code></pre>
|
```</code></pre>
|
||||||
|
|
||||||
## Custom theme
|
## Custom theme
|
||||||
Like the rest of the theme, the files used for syntax highlighting can be overridden with your own.
|
Like the rest of the theme, the files used for syntax highlighting can be
|
||||||
|
overridden with your own.
|
||||||
|
|
||||||
- ***highlight.js*** normally you shouldn't have to overwrite this file, unless you want to use a more recent version.
|
- ***highlight.js*** normally you shouldn't have to overwrite this file, unless
|
||||||
|
you want to use a more recent version.
|
||||||
- ***highlight.css*** theme used by highlight.js for syntax highlighting.
|
- ***highlight.css*** theme used by highlight.js for syntax highlighting.
|
||||||
|
|
||||||
If you want to use another theme for `highlight.js` download it from their website, or make it yourself,
|
If you want to use another theme for `highlight.js` download it from their
|
||||||
rename it to `highlight.css` and put it in `src/theme` (or the equivalent if you changed your source folder)
|
website, or make it yourself, rename it to `highlight.css` and put it in
|
||||||
|
`src/theme` (or the equivalent if you changed your source folder)
|
||||||
|
|
||||||
Now your theme will be used instead of the default theme.
|
Now your theme will be used instead of the default theme.
|
||||||
|
|
||||||
## Hiding code lines
|
## Hiding code lines
|
||||||
|
|
||||||
There is a feature in mdBook that let's you hide code lines by prepending them with a `#`.
|
There is a feature in mdBook that let's you hide code lines by prepending them
|
||||||
|
with a `#`.
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -47,13 +52,18 @@ Will render as
|
||||||
# }
|
# }
|
||||||
```
|
```
|
||||||
|
|
||||||
**At the moment, this only works for code examples that are annotated with `rust`. Because it would collide with semantics of some programming languages. In the future, we want to make this configurable through the `book.toml` so that everyone can benefit from it.**
|
**At the moment, this only works for code examples that are annotated with
|
||||||
|
`rust`. Because it would collide with semantics of some programming languages.
|
||||||
|
In the future, we want to make this configurable through the `book.toml` so that
|
||||||
|
everyone can benefit from it.**
|
||||||
|
|
||||||
|
|
||||||
## Improve default theme
|
## Improve default theme
|
||||||
|
|
||||||
If you think the default theme doesn't look quite right for a specific language, or could be improved.
|
If you think the default theme doesn't look quite right for a specific language,
|
||||||
Feel free to [submit a new issue](https://github.com/rust-lang-nursery/mdBook/issues) explaining what you have in mind and I will take a look at it.
|
or could be improved. Feel free to [submit a new
|
||||||
|
issue](https://github.com/rust-lang-nursery/mdBook/issues) explaining what you
|
||||||
|
have in mind and I will take a look at it.
|
||||||
|
|
||||||
You could also create a pull-request with the proposed improvements.
|
You could also create a pull-request with the proposed improvements.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Contributors
|
# Contributors
|
||||||
|
|
||||||
Here is a list of the contributors who have helped improving mdBook. Big shout-out to them!
|
Here is a list of the contributors who have helped improving mdBook. Big
|
||||||
|
shout-out to them!
|
||||||
If you have contributed to mdBook and I forgot to add you, don't hesitate to add yourself to the list. If you are in the list, feel free to add your real name & contact information if you wish.
|
|
||||||
|
|
||||||
- [mdinger](https://github.com/mdinger)
|
- [mdinger](https://github.com/mdinger)
|
||||||
- Kevin ([kbknapp](https://github.com/kbknapp))
|
- Kevin ([kbknapp](https://github.com/kbknapp))
|
||||||
|
@ -12,8 +11,10 @@ If you have contributed to mdBook and I forgot to add you, don't hesitate to add
|
||||||
- [funnkill](https://github.com/funkill)
|
- [funnkill](https://github.com/funkill)
|
||||||
- Fu Gangqiang ([FuGangqiang](https://github.com/FuGangqiang))
|
- Fu Gangqiang ([FuGangqiang](https://github.com/FuGangqiang))
|
||||||
- [Michael-F-Bryan](https://github.com/Michael-F-Bryan)
|
- [Michael-F-Bryan](https://github.com/Michael-F-Bryan)
|
||||||
- [Chris Spiegel](https://github.com/cspiegel)
|
- Chris Spiegel ([cspiegel](https://github.com/cspiegel))
|
||||||
- [projektir](https://github.com/projektir)
|
- [projektir](https://github.com/projektir)
|
||||||
- [Phaiax](https://github.com/Phaiax)
|
- [Phaiax](https://github.com/Phaiax)
|
||||||
- [Matt Ickstadt](https://github.com/mattico)
|
- Matt Ickstadt ([mattico](https://github.com/mattico))
|
||||||
- Weihang Lo ([@weihanglo](https://github.com/weihanglo))
|
- Weihang Lo ([@weihanglo](https://github.com/weihanglo))
|
||||||
|
|
||||||
|
If you feel you're missing from this list, feel free to add yourself in a PR.
|
Loading…
Reference in New Issue