| Crates.io | mdbook-tagger |
| lib.rs | mdbook-tagger |
| version | 0.2.0 |
| created_at | 2024-04-08 17:25:00.325937+00 |
| updated_at | 2024-04-09 02:04:02.313916+00 |
| description | A mdbook preprocessor to collect and build tag data in Json format |
| homepage | |
| repository | https://github.com/acheul/mdbook-collectors |
| max_upload_size | |
| id | 1200701 |
| size | 64,630 |
A mdbook preprocessor which collects and builds tag data in Json format.
cargo install mdbook-tagger
In a .md file of a post, include:
<!-- tags: computer; book -->
The preprocessor parses each post's tag data and then builds two consolidated json files:
{
"tag's name": [
["post's name", "post's path"],
["other-post's name", "other-post's path"],
...
],
...
}
{
"post's url": ["tag's name", "other tag's name", ...],
...
}
Mind that in the v.0.1.0, the key of this map was post's name(title). From v.0.2.0, each post's url path is the key of map.
Default setting (in book.toml):
[preprocessor.tagger]
marker = "tags"
split = ";"
tag2posts_path = "tag2posts.json"
post2tags_path = "post2tags.json"
By default, the preprocessor tries to parse any literal located between the first <!-- tags and --> in each post's source file. (<!--tags instead of <!-- tags is ok.)
<!-- tags: computer; book; duck; -->
This will be parsed into tags of ["computer", "book", "duck"].
You can change the default seperator pattern ";".
If split = ",",
<!-- tags: computer, book, duck -->
will be parsed into tags of ["computer", "book", "duck"].
The path where newly built json files will be saved.
Each json file will be saved at a path which combines book's src directory and the given tag2posts_path and post2tags_path.
🪧 Mind that the
mdbook servewatchessrcdirectory. Once you startmdbook servecommand then change any contents undersrcdirectory, the preprocessor will rebuild the json file and this leads to a repeat loop of watch and serve. To prevent this, make a .gitignore file at the book's root directory and add the to-be-built json file's name.