| Crates.io | mdbook-termlink |
| lib.rs | mdbook-termlink |
| version | 0.0.5 |
| created_at | 2026-01-12 16:42:01.230081+00 |
| updated_at | 2026-01-12 19:55:38.114544+00 |
| description | mdBook preprocessor that auto-links glossary terms throughout documentation |
| homepage | |
| repository | https://github.com/rubentalstra/mdbook-termlink |
| max_upload_size | |
| id | 2038144 |
| size | 94,070 |
An mdBook preprocessor that automatically links glossary terms throughout your documentation.
title attributecargo install mdbook-termlink
git clone https://github.com/rubentalstra/mdbook-termlink.git
cd mdbook-termlink
cargo install --path .
book.toml[preprocessor.termlink]
glossary-path = "reference/glossary.md"
Use Markdown definition lists in your glossary:
# Glossary
API (Application Programming Interface)
: A set of protocols and tools for building software applications.
REST
: Representational State Transfer, an architectural style for distributed systems.
JSON
: JavaScript Object Notation, a lightweight data interchange format.
mdbook build
Terms in your chapters will automatically link to their glossary definitions with tooltip previews on hover.
All configuration options with their defaults:
[preprocessor.termlink]
# Path to the glossary file (relative to src directory)
glossary-path = "reference/glossary.md"
# Only link the first occurrence of each term per page
link-first-only = true
# CSS class applied to glossary term links
css-class = "glossary-term"
# Whether term matching should be case-sensitive
case-sensitive = false
# Pages to exclude from term linking (glob patterns)
exclude-pages = ["changelog.md", "appendix/*"]
# Alternative names for terms
[preprocessor.termlink.aliases]
API = ["apis", "api endpoints"]
REST = ["RESTful"]
| Option | Type | Default | Description |
|---|---|---|---|
glossary-path |
String | "reference/glossary.md" |
Path to glossary file relative to src/ |
link-first-only |
Boolean | true |
Only link first occurrence per page |
css-class |
String | "glossary-term" |
CSS class for term links |
case-sensitive |
Boolean | false |
Case-sensitive term matching |
exclude-pages |
Array | [] |
Glob patterns for pages to skip |
aliases |
Map | {} |
Alternative names for terms |
Add custom styles for glossary links in your book.toml:
[output.html]
additional-css = ["custom.css"]
Example custom.css:
.glossary-term {
text-decoration: underline dotted;
color: inherit;
}
.glossary-term:hover {
background-color: rgba(0, 0, 0, 0.05);
}
Glossary Parsing: Parses your glossary file for definition lists (term followed by : definition)
Term Extraction: Extracts each term with its anchor, short form (if present), and definition
Content Processing: Processes each chapter, matching terms using word boundaries while skipping protected contexts
Link Generation: Replaces terms with HTML links including tooltip definitions:
<a href="../reference/glossary.html#api"
title="A set of protocols and tools for building software applications."
class="glossary-term">API</a>
# Run all tests (unit, integration, and e2e)
cargo test
# Run only e2e tests (requires mdBook installed)
cargo test --test e2e
# Run clippy
cargo clippy --all-targets --all-features -- -D warnings
# Check formatting
cargo fmt --all -- --check
# Build release
cargo build --release
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.