mdbook-selfpath
A Rust preprocessor for mdBook that allows you to insert the current file path into your book's Markdown content. This is useful for referencing the source file location within your documentation, tutorials, or codebooks.
Features
- Self Path Injection: Insert the current Markdown file's path using a custom syntax or directive.
- Easy Integration: Works as an mdBook preprocessor, so it fits seamlessly into your existing mdBook workflow.
- Configurable: Can be enabled or disabled per book or per file.
Usage
1. Install the Preprocessor
This will produce the binary in target/release/mdbook-filepath.
2. Register the Preprocessor in book.toml
Add the following to your book.toml:
[]
Here is the configuration available:
include-file-extif true, file extension will be included (i.e..md)
3. Use in Your Markdown
Insert a directive in your Markdown file where you want the file path to appear. For example:
[{{ selftitle }}](https://github.com/howlowck/example-repo/files/blob/main/{{ selfpath }})
The output will be
[Intro](https://github.com/howlowck/example-repo/files/blob/main/src/Intro.md)
When you build your book, this will be replaced with the relative path to the current Markdown file.
4. Build Your Book
Development
- Source code is in
src/. - Example book for testing is in
testbook/. - Use
makeor the providedmakefilefor common tasks (if available).
License
This project is licensed under the MIT License.