Metadata-Version: 2.1
Name: foliantcontrib.replace
Version: 1.0.5
Summary: Replace text by dictionary.
Home-page: https://github.com/foliant-docs/foliantcontrib.replace
Author: Anton Bukhtiyarov
Author-email: apkraft@gmail.com
License: MIT
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Documentation
Classifier: Topic :: Utilities
Description-Content-Type: text/markdown
Requires-Dist: foliant (>=1.0.8)
Requires-Dist: PyYAML

# Replace text for Foliant

Replace preprocessor reads the dictionary (yaml format) placed in foliant project folder and changes one word to another in created document.


## Installation

```shell
$ pip install foliantcontrib.replace
```


## Config

To enable the preprocessor, add `replace` to `preprocessors` section in the project config:

```yaml
preprocessors:
  - replace
```

The preprocessor has two options (default values stated):

```yaml
preprocessors:
  - replace:
      dictionary_filename: replace_dictionary.yml
      with_confirmation: false

```

`dictionary_filename`
:   File in foliant project folder with dictionary in it (*replace_dictionary.yml* by default).

`with_confirmation`
:   if `true` you will be prompted to confirm any changes.

### Dictionary format

Dictionary stores data in yaml format. It has two sections — with words and with regular expressions. You can pass the lambda function in `regexs` section. For example:

```yaml
words:
  cod: CoD
  epg: EPG
  vod: VoD
regexs:
  '!\w*!': ''
  '\. *(\w)': 'lambda x: x.group(0).upper()'
```


## Usage

Just add the preprocessor to the project config, set the dictionary and enjoy the result.


