Skip to main content

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

foliantcontrib.replace-1.0.4.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

foliantcontrib.replace-1.0.4-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page