#mdbook #chapter #header #append #footer #regex #padding

bin+lib mdbook_header_footer

mdBook preprocessor to prepend header and append footer to certain chapters

3 releases

0.0.2 Dec 7, 2024
0.0.1 Sep 13, 2024
0.0.0 Sep 13, 2024

#587 in Text processing

Download history 305/week @ 2024-09-09 108/week @ 2024-09-16 45/week @ 2024-09-23 21/week @ 2024-09-30 9/week @ 2024-10-07 1/week @ 2024-11-04 109/week @ 2024-12-02 48/week @ 2024-12-09

157 downloads per month

MIT license

14KB
189 lines

mdBook-Header-Footer

This mdBook preprocessor prepends headers and appends footers to all chapters in the book whose URL path match the corresponding regex. The headers and footers are two lists of object with the regex and padding string fields, where regex specifies what Regex the URL path needs to match and padding specifies what to pad. regex is optional, if not specified, it will match all paths (.*).

For example, if you add the following to your book.toml:

[preprocessor.header-footer]
headers = [{ regex = "^notes/", padding = "Notes\n" }]
footers = [{ padding = "\nHaha" }]

Then, all chapters whose URL path starts with notes/ will have Notes plus a newline prepended to the top of the chapter; all chapters will have a newline plus Haha appended to the bottom of the chapter.

Installation

cargo install mdbook_header_footer

Debugging

We use tracing-subscriber with the env-filter feature to emit logs. Please configure the log level by setting the RUST_LOG environment variable.

Dependencies

~18–29MB
~452K SLoC