Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the documentation for new preprocessor format #787

Merged

Conversation

rbuckland
Copy link
Contributor

@Michael-F-Bryan This is the documentation you require for the preprocessor change.

The link - [preprocessor-docs] is forward looking

  • that is a little harder - we need a preprocessor for that :-D

Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We just need to change

[preprocess]
index  = true
...

to

[preprocess.index]

...

Because each preprocessor should be given its own table instead of being flags that are toggled. This is also consistent with how renderers work.

@@ -14,6 +14,10 @@ description = "The example book covers examples."
build-dir = "my-example-book"
create-missing = false

[preprocess]
index = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. Each preprocessor gets its own table and you can enable/disable inserting the default preprocessors by setting build.use-default-preprocessors to true.

@@ -59,10 +62,8 @@ This controls the build process of your book.
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.
- **preprocess:** Specify which preprocessors to be applied. Default is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to mention the use-default-preprocessors flag here. It's used to enable/disable including the default preprocessors and defaults to true.

I've also added a couple tests in 18a36ec to make sure the build.use-default-preprocessors flag works as intended.

@@ -71,14 +72,39 @@ The following preprocessors are available and included by default:
- `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.

- `emoji`: Convert `:emoji:` text into Emojis. eg: `:smile:` to :smile:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, there's an emoji preprocessors? That's really cool!

renderers = ["html"] # mathjax only makes sense with the HTML renderer
```

#### Nested Configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section will probably need to mention that, like renderers, each preprocessor will always need to be given its own table (e.g. [preprocessor.mathjax]). From there, passing extra configuration to the preprocessor is just a case of adding key-value pairs to the table, so there isn't really a separate "style of configuration".


**book.toml**
```toml
[build]
build-dir = "build"
create-missing = false
preprocess = ["links", "index"]

[preprocess]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be changed to something like:

[preprocess.links]

[preprocess.index]

[preprocess.emoji]

Although those three preprocessors will be enabled by default, so it's kinda redundant to even mention them...

@Michael-F-Bryan
Copy link
Contributor

@rbuckland about the [preprocessor-docs] markdown link, turns out you can link to the latest version on docs.rs instead of writing an explicit version number.

https://docs.rs/mdbook/latest/mdbook/preprocess/trait.Preprocessor.html

@rbuckland
Copy link
Contributor Author

rbuckland commented Sep 9, 2018

@Michael-F-Bryan wrote:

Ooh, there's an emoji preprocessors? That's really cool!

oops - I didn't mean to include the text yet. Sorry.
Yes - I have completed it - and it is sitting here https://github.com/rbuckland/mdBook/tree/feature/emoji_v2

I will PR that once this change comes through. That is for issue #771

@rbuckland
Copy link
Contributor Author

I have updated that documentation - please take a read - and make sure I got it right :-D

@Michael-F-Bryan
Copy link
Contributor

LGTM 👍

@Michael-F-Bryan Michael-F-Bryan merged commit a00ccf8 into rust-lang:smart-preprocessor Sep 10, 2018
Michael-F-Bryan pushed a commit that referenced this pull request Sep 10, 2018
* Updated the documentation for new preprocessor format

* adjusted the descriptions for preprocessors
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
* Updated the documentation for new preprocessor format

* adjusted the descriptions for preprocessors
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
* Updated the documentation for new preprocessor format

* adjusted the descriptions for preprocessors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants