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
$ pip install foliantcontrib.replace
Config
To enable the preprocessor, add replace
to preprocessors
section in the project config:
preprocessors:
- replace
The preprocessor has two options (default values stated):
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:
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
Built Distribution
Hashes for foliantcontrib.replace-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0fe170c173fdc1bd2e9bd89bb3944b340267061fc9314d6fde2a29a9d7a658 |
|
MD5 | 8bb1d2ef80100323f8970918a8075797 |
|
BLAKE2b-256 | 9562ddc2026ad92aa1aa54cc9464f44398b4e955069fe821ac886a07d3459a73 |
Hashes for foliantcontrib.replace-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72df38d8f8a8cbf170c42f60d1fb564e12ec732d84f53797f514bfeb8f16a3b9 |
|
MD5 | 20025b89753e4e45396919dd16a9cf8e |
|
BLAKE2b-256 | 56668045b2fbd7d0a62a5169b33e923e03669a5b6b18211f6148f80f12ee67a7 |