Skip to content

Yet another preprocessor for mdBook

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

EngosSoftware/yapp

Yet another preprocessor for mdBook

Crates.io 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 this:

a
    ab

         ab
 abb

   abb
                     abba

 abba
   ABBA

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

To preserve whitespaces in search pattern or replacement, enclose it in a single quotation mark:

' a '
' b c '

or double quotation mark:

" a "
" b c "

so the result of replacement for input │ a │ will be │ b c │.

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.

About

Yet another preprocessor for mdBook

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages