Simple shortcodes for Python.
Project description
shrtcodes
pip install shrtcodes
Simple shortcodes for Python.
Example:
A toy example:
# example.txt
Hello!
{% img http://cutedogs.com/dog123.jpg "A very cute dog" %}
Foo bar baz...
{% repeat 3 %}
Woop
{% / %}
Bye!
# example.py
from shrtcodes import Shrtcodes
shortcodes = Shrtcodes()
@shortcodes.register_inline("img")
def handle_img(src, alt):
return f'<img src="{src}" alt="{alt}"/>'
@shortcodes.register_block("repeat")
def handle_repeat(block, n):
return block * int(n)
shortcodes.create_cli()
python example.py example.txt
Output:
Hello!
<img src="http://cutedogs.com/dog123.jpg" alt="A very cute dog"/>
Foo bar baz...
Woop
Woop
Woop
Bye!
A more useful example would be the generation of this README itself.
See create_readme.py
and README.template.md
.
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
shrtcodes-1.0.2.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for shrtcodes-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b9384f220a996da91af8803396580078f89a0e24062345d97ad720b05586b6d |
|
MD5 | 63bea230e2df106627246ee7d9445830 |
|
BLAKE2b-256 | d38577860add4da46627c5df3c44358ed5624e1a28a575a8a8dd1846dc74d894 |