mdbook-selfpath

Crates.iomdbook-selfpath
lib.rsmdbook-selfpath
version0.2.2
created_at2025-06-14 02:25:42.137807+00
updated_at2025-06-17 00:06:53.465032+00
descriptionA preprocessor for mdbook that allows self-referencing paths
homepage
repository
max_upload_size
id1712065
size106,337
Hao Luo (howlowck)

documentation

README

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

cargo install mdbook-selfpath

This will produce the binary in target/release/mdbook-filepath.

2. Register the Preprocessor in book.toml

Add the following to your book.toml:

[preprocessor.selfpath]

Here is the configuration available:

  • include-file-ext if 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

mdbook build

Development

  • Source code is in src/.
  • Example book for testing is in testbook/.
  • Use make or the provided makefile for common tasks (if available).

License

This project is licensed under the MIT License.

Acknowledgements

Commit count: 0

cargo fmt