@@ -14,6 +14,10 @@ description = "The example book covers examples."
14
14
build-dir = " my-example-book"
15
15
create-missing = false
16
16
17
+ [preprocess .index ]
18
+
19
+ [preprocess .links ]
20
+
17
21
[output .html ]
18
22
additional-css = [" custom.css" ]
19
23
@@ -27,7 +31,6 @@ It is important to note that **any** relative path specified in the in the
27
31
configuration will always be taken relative from the root of the book where the
28
32
configuration file is located.
29
33
30
-
31
34
### General metadata
32
35
33
36
This is general information about your book.
@@ -59,15 +62,25 @@ This controls the build process of your book.
59
62
will be created when the book is built (i.e. ` create-missing = true ` ). If this
60
63
is ` false ` then the build process will instead exit with an error if any files
61
64
do not exist.
62
- - ** preprocess:** Specify which preprocessors to be applied. Default is
63
- ` ["links", "index"] ` . To disable default preprocessors, pass an empty array
64
- ` [] ` in.
65
+ - ** use-default-preprocessors:** Disable the default preprocessors of (` links ` &
66
+ ` index ` ) by setting this option to ` false ` .
65
67
68
+ If you have the same, and/or other preprocessors declared via their table
69
+ of configuration, they will run instead.
70
+
71
+ - For clarity, with no preprocessor configuration, the default ` links ` and
72
+ ` index ` will run.
73
+ - Setting ` use-default-preprocessors = false ` will disable these
74
+ default preprocessors from running.
75
+ - Adding ` [preprocessor.links] ` , for example, will ensure, regardless of
76
+ ` use-default-preprocessors ` that ` links ` it will run.
77
+
78
+ ## Configuring Preprocessors
66
79
67
80
The following preprocessors are available and included by default:
68
81
69
- - ` links ` : Expand the ` {{# playpen}} ` and ` {{# include}} ` handlebars helpers in
70
- a chapter.
82
+ - ` links ` : Expand the ` {{ # playpen }} ` and ` {{ # include }} ` handlebars helpers in
83
+ a chapter to include the contents of a file .
71
84
- ` index ` : Convert all chapter files named ` README.md ` into ` index.md ` . That is
72
85
to say, all ` README.md ` would be rendered to an index file ` index.html ` in the
73
86
rendered book.
@@ -78,10 +91,39 @@ The following preprocessors are available and included by default:
78
91
[build ]
79
92
build-dir = " build"
80
93
create-missing = false
81
- preprocess = [" links" , " index" ]
94
+
95
+ [preprocess .links ]
96
+
97
+ [preprocess .index ]
82
98
```
83
99
100
+ ### Custom Preprocessor Configuration
101
+
102
+ Like renderers, preprocessor will need to be given its own table (e.g. ` [preprocessor.mathjax] ` ).
103
+ In the section, you may then pass extra configuration to the preprocessor by adding key-value pairs to the table.
104
+
105
+ For example
106
+
107
+ ```
108
+ [preprocess.links]
109
+ # set the renderers this preprocessor will run for
110
+ renderers = ["html"]
111
+ some_extra_feature = true
112
+ ```
113
+
114
+ #### Locking a Preprocessor dependency to a renderer
115
+
116
+ You can explicitly specify that a preprocessor should run for a renderer by binding the two together.
117
+
118
+ ```
119
+ [preprocessor.mathjax]
120
+ renderers = ["html"] # mathjax only makes sense with the HTML renderer
121
+ ```
122
+
123
+ ## Configuring Renderers
124
+
84
125
### HTML renderer options
126
+
85
127
The HTML renderer has a couple of options as well. All the options for the
86
128
renderer need to be specified under the TOML table ` [output.html] ` .
87
129
@@ -214,4 +256,4 @@ book's title without needing to touch your `book.toml`.
214
256
215
257
The latter case may be useful in situations where `mdbook` is invoked from a
216
258
script or CI, where it sometimes isn't possible to update the `book.toml` before
217
- building.
259
+ building.
0 commit comments