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
Built Distribution
File details
Details for the file foliantcontrib.replace-2.0.0.tar.gz
.
File metadata
- Download URL: foliantcontrib.replace-2.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e3a8b55e74ef85a43136d35d23b933cb3916635a0aabb85333d984926d54d0 |
|
MD5 | ee6fb52edccd0b0f2fffadc36635e015 |
|
BLAKE2b-256 | 9d547787a697419d9d81f5e33d145091f022e0cdf68e0513e59709c8013ea8a7 |
File details
Details for the file foliantcontrib.replace-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: foliantcontrib.replace-2.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 304329cc5878b43018378d079add4574a50eef7bb0768991f20060760e3160c5 |
|
MD5 | c049d51cc17717fda2dae105cb7efdbd |
|
BLAKE2b-256 | a9438179838b0d1a7bbd04082ecd139623ea0b68e9584d90c28973ad6e3f49a9 |