Replace text by dictionary.
Project description
# 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.
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for foliantcontrib.replace-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 317b8560bd20166c4e2c485ee06c57b72801de8421b1ea995c7a2ab6f39982be |
|
MD5 | b39dd658a8b9500ffc2c57b99203d88c |
|
BLAKE2b-256 | 1df90349f22d19bfdb2a40e9fa32502deaa316cbf94e9192347340b04d886d27 |