| Crates.io | mdbook-regex |
| lib.rs | mdbook-regex |
| version | 0.0.2 |
| created_at | 2020-11-20 23:02:40.618209+00 |
| updated_at | 2020-11-20 23:13:09.810561+00 |
| description | Mdbook preprocessor replacing regular expression patterns with specified strings. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 314545 |
| size | 52,196 |
A Rust preprocessor for mdBook, replacing regular expression patterns with specified strings. Regex syntax is based on the Regex Rust crate.
Install the crate
cargo install mdbook-regex
Specify the patterns and string replacement in a .json file
[
{
"pattern" : "Your Pattern",
"template" : "Your Template"
}
]
Add the preprocessor to your book.toml file, and specify the path of the .json patterns file
[preprocessor.regex]
patterns = "path/to/patterns.json"
The following pattern
[
{
"pattern" : "``collapse:(?P<title>([^\n])*)\n(?P<content>(?s:.)*)\n``",
"template" : "<details>\n<summary>${title}</summary>\n<div class='collapsed'>\n${content}\n</div>\n</details>"
}
]
allows the creation of collapsible regions, turning this
``collapse:Title
Content
``
into this
<details>
<summary>Title</summary>
<div class='collapsed'>
Content
</div>
</details>