Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/younata/mdbook-chapter-path
mdbook preprocessor to provide paths to chapters.
https://github.com/younata/mdbook-chapter-path
Last synced: 27 days ago
JSON representation
mdbook preprocessor to provide paths to chapters.
- Host: GitHub
- URL: https://github.com/younata/mdbook-chapter-path
- Owner: younata
- Created: 2021-05-29T17:03:49.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-30T02:28:38.000Z (over 3 years ago)
- Last Synced: 2024-09-19T01:51:42.705Z (about 2 months ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - younata/mdbook-chapter-path - mdbook preprocessor to provide paths to chapters. (others)
README
# mdbook-chapter-path
[![CI status](https://ci.younata.com/api/v1/pipelines/knowledge/jobs/mdbook-chapter-path/badge)](https://ci.younata.com/teams/main/pipelines/knowledge/jobs/mdbook-chapter-path/)
[![Latest Version](https://img.shields.io/crates/v/mdbook-chapter-path.svg)](https://crates.io/crates/mdbook-chapter-path)[mdBook](https://github.com/rust-lang/mdbook) preprocessor for providing the path to a chapter based on its name.
## Getting Started
First, install the `mdbook-chapter-path` crate
```
cargo install mdbook-chapter-path
```Then, add the following line to your `book.toml` file:
```toml
[preprocessor.chapter-path]
```Once done, you can now use `{{#path_for $NAME_OF_CHAPTER}}` to insert the path (relative to `SUMMARY.md`) to that chapter.
E.g. If you have a chapter named "Whatever" located at "foo/whatever.md", the markdown `{{#path_for Whatever}}` will replace that with `/foo/whatever.md`.
This even works for anchor links, e.g. `{{#path_for Whatever#an_anchor}}` will replace that with `/foo/whatever.md#an_anchor`.
This is useful because it means the link will survive moving files around.
## Configuration
`mdbook-chapter-path` will use whatever is listed in `output.html.site-url` as the base path for all links, defaulting to '/'.
Additionally, you can enable `strict` mode. If this is set to `true`, `mdbook-chapter-path` will exit with an error whenever it encounters a duplicate chapter name. This defaults to `false`, meaning that duplicate chapter names are allowed.
⚠️ Without strict mode enabled, if you have multiple chapters with the same name (case-insensitive), then `mdbook-chapter-path` will provide the path for whichever chapter is listed last in the book.
```toml
[preprocessor.chapter-path]
strict = true
```