#mdbook #preprocessor #replace #text #pattern

app mdbook-yapp

A mdbook preprocessor for simple text replacements

4 releases

0.0.3 Nov 10, 2023
0.0.2 Nov 9, 2023
0.0.1 Nov 9, 2023
0.0.0 Nov 9, 2023

#223 in Text processing

Download history 97/week @ 2023-11-08 9/week @ 2023-11-15 10/week @ 2023-11-22 10/week @ 2023-11-29 8/week @ 2023-12-06 5/week @ 2023-12-13 4/week @ 2023-12-20 8/week @ 2023-12-27 1/week @ 2024-01-10 2/week @ 2024-01-17 5/week @ 2024-01-24 7/week @ 2024-01-31 1/week @ 2024-02-07 51/week @ 2024-02-14

64 downloads per month

MIT/Apache

25KB
181 lines

Yet another preprocessor for mdBook

MIT licensed Apache 2.0 licensed Contributor Covenant

Overview

A mdbook preprocessor that simply replaces text in chapters.

Phrases to be replaced with specified content are defined in plain-text configuration file.

Installation

Install using Cargo:

$ cargo install mdbook-yapp

Configure this preprocessor by adding to your book.toml the following line:

[preprocessor.yapp]

Build you book as usual:

$ mdbook build

There should be a warning message displayed when no configuration file is found.

2023-11-11 12:01:02 [INFO] (mdbook::book): Book building has started
[WARNING][Yapp] configuration file not found, in current directory expected a file with the name starting with prefix: yapp
[WARNING][Yapp] configuration file not found, in current directory expected a file with the name starting with prefix: yapp
2023-11-11 12:01:03 [INFO] (mdbook::book): Running the html backend

Prepare the configuration file as described in the next section.

Configuration

This preprocessor requires single configuration file in plain-text format. This file's name should start with the prefix yapp. Letter case is not significant. So names like yapp, Yapp, Yappi, yapp.config and similar will do.

Configuration file must contain pairs of lines of text. First line is the phrase to be searched in the chapter and the second line is the replacement. Having a configuration file named yapp.config with the following content:

jd
John Doe

will inform this preprocessor to search for all jd instances in all chapters of the book and to replace them with the text John Doe.

Configuration files may have empty lines, which are ignored. Empty lines may make the configuration more readable when there are multiple replacements defined, like this:

jd
John Doe

^note
**Note**:

@version
1.23.4

Replacements are done in the order defined in configuration file, so the substitutions may be chained, like this:

a
ab

ab
abb

abb
abba

abba
ABBA

Every letter a in all chapters will be replaced with ABBA. Note that each line in configuration file is trimmed before used. So configuration file with the content like:

a
    ab

         ab
 abb

   abb
                     abba

 abba
   ABBA

will have the same effect as the file in the previous example.

License

Licensed under either of

at your option.

Contribution

All contributions intentionally submitted for inclusion in the work by you, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~11–25MB
~332K SLoC