Skip to main content

Replace text by dictionary.

Project description

Replace text for Foliant

Preprocessor for simple search and replace in Markdown sources with support of regular expressions.

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:

preprocessors:
  - replace:
      dictionary:
        Mike: Michael
        Sam: Samuel
        Tim: Timoel
      re_dictionary:
        '!\[\]\((.+?)\)': '![Figure](\1)'

dictionary : YAML mapping where key is string to replace, value is the replacement string.

re_dictionary : YAML mapping where key is Python regular expression pattern, value is the replacement string.

Usage

Fill up the dictionary or/and re_dictionary in preprocessor options and the keys will be replaced with values.

For example, if you wish that all images without title in your Markdown sources were titled "Figure", use the following config:

preprocessors:
  - replace:
      re_dictionary:
        '!\[\]\((.+?)\)': '![Figure](\1)'

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-2.0.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

foliantcontrib.replace-2.0.0-py3-none-any.whl (3.6 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