@@ -14,6 +14,10 @@ description = "The example book covers examples."
1414build-dir = " my-example-book"
1515create-missing = false
1616
17+ [preprocess .index ]
18+
19+ [preprocess .links ]
20+
1721[output .html ]
1822additional-css = [" custom.css" ]
1923
@@ -27,7 +31,6 @@ It is important to note that **any** relative path specified in the in the
2731configuration will always be taken relative from the root of the book where the
2832configuration file is located.
2933
30-
3134### General metadata
3235
3336This is general information about your book.
@@ -59,15 +62,25 @@ This controls the build process of your book.
5962 will be created when the book is built (i.e. ` create-missing = true ` ). If this
6063 is ` false ` then the build process will instead exit with an error if any files
6164 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 ` .
6567
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
6679
6780The following preprocessors are available and included by default:
6881
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 .
7184- ` index ` : Convert all chapter files named ` README.md ` into ` index.md ` . That is
7285 to say, all ` README.md ` would be rendered to an index file ` index.html ` in the
7386 rendered book.
@@ -78,10 +91,39 @@ The following preprocessors are available and included by default:
7891[build ]
7992build-dir = " build"
8093create-missing = false
81- preprocess = [" links" , " index" ]
94+
95+ [preprocess .links ]
96+
97+ [preprocess .index ]
8298```
8399
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+
84125### HTML renderer options
126+
85127The HTML renderer has a couple of options as well. All the options for the
86128renderer need to be specified under the TOML table ` [output.html] ` .
87129
@@ -214,4 +256,4 @@ book's title without needing to touch your `book.toml`.
214256
215257The latter case may be useful in situations where `mdbook` is invoked from a
216258script or CI, where it sometimes isn't possible to update the `book.toml` before
217- building.
259+ building.
0 commit comments