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!
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)
with open("example.txt") as f:
print(shortcodes.process_text(f.read()))
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.
Release files for shrtcodes 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shrtcodes-1.0.1.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shrtcodes-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / shrtcodes-1.0.1.tar.gz
| Download URL | shrtcodes-1.0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2c1762d9315df182f2e502d3bea14372bc732cf1d6f1897b8f45f95bab8b9e2
|
|
BLAKE2b-256 checksum How to use checksums |
a9fb48e2c570c5e4098a032f61a677da23b1599e3e5a13284c649fcfe98bc38d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Linux/5.15.0-53-generic
|
Release files / shrtcodes-1.0.1-py3-none-any.whl
| Download URL | shrtcodes-1.0.1-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
364e2e287ff807c84e33527472ee16558e72fea2b1706c47e776b56d4d366b96
|
|
BLAKE2b-256 checksum How to use checksums |
8e3c9dd6ca561b149805333f02eb6db80dc02246b7aa5db41556efe2cf6baee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Linux/5.15.0-53-generic
|