Python-Markdown extension allowing arbitrary scripts to modify MkDocs input files
Project description
mkpatcher
mkpatcher
is a Python-Markdown extension allowing arbitrary scripts to modify MkDocs input files.
Table of Contents
Installation
-
pip install mkpatcher
-
Include the extension in your
mkdocs.yml
config file:... markdown_extensions: - mkpatcher: ...
Usage
This extension works as a pre-processor and will allow modifying the raw lines of Markdown before any other extension runs.
Raw script
The script
option takes arbitrary Python code and will provide the Markdown lines as a variable named lines
.
You can modify the lines directly:
...
markdown_extensions:
- mkpatcher:
script: |
lines.extend(('', 'some footer', ''))
or you can shadow the variable:
...
markdown_extensions:
...
- mkpatcher:
script: |
lines = ['entirely', 'new']
lines.append('markdown')
Scripts on filesystem
The location
option takes a path to either a single Python file or a directory containing multiple Python files.
If the location refers to a directory, the scripts will be loaded and eventually executed in lexicographical order
based on file names.
Each script must define a callable object named patch
that accepts a single parameter which will be the Markdown lines.
You can modify the lines directly:
def patch(lines):
lines.extend(('', 'some footer', ''))
or you can return new lines:
def patch(lines):
new_lines = ['entirely', 'new']
new_lines.append('markdown')
return new_lines
License
mkpatcher
is distributed under the terms of both
at your option.
Project details
Release history Release notifications | RSS feed
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 mkpatcher-1.0.0.tar.gz
.
File metadata
- Download URL: mkpatcher-1.0.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40abe48f221ab51eb964f59c84c071c45c6d10964466e6e4ad7abcb743032483 |
|
MD5 | eacb56433708bc055f9c3eb0c60e60a4 |
|
BLAKE2b-256 | 73785af45597ee56aab6292e5e59675b69ac79bc9365f2f6a5365d4536eec779 |
File details
Details for the file mkpatcher-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: mkpatcher-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d75e6542583dc4d17ffb2ee41f1646c5e404d137316df3082042fd157382773d |
|
MD5 | 15b22fb1b437dc7627533aa57aff478b |
|
BLAKE2b-256 | fcfca1f926a2bff4488b46da29ed201ae2cdcfc1576452f05510e7c441432630 |