Replace

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.