Insert dynamic content in markdown, without using a separate template file.
Project description
minsert
Insert dynamic content in markdown, without using a separate template file.
Motivation
Inspired by jinja.
Your actual markdown file is the template file itself. Just make a block of content just by using comments, which indicate the start and end of the block.
This is really great for making a dynamic GitHub README. No hassle of creating a separate template file. Using a simple python script and GitHub Actions, you can automatically update the contents of the markdown file.
Installation
pip install minsert
Syntax
Using minsert is easy. Just write normal markdown. The start and end of named blocks are marked by special comments.
Start a block named my_block
<!-- start my_block -->
End a block
<!-- end -->
You must end the current block before starting a new one.
Usage
For example you have a markdown file test.md
like this.
hello
<!-- start thing1 -->
<!-- end -->
what is happening
<!-- start thing2 -->
<!-- end -->
Bye!
Create a simple script update.py
for updating the markdown file.
# update.py
from minsert import MarkdownFile
file = MarkdownFile("test.md")
things = {
"thing1": "hi hello",
"thing2": "ping pong",
}
file.insert(things)
The markdown file gets updated with the value of the blocks.
hello
<!-- start thing1 -->
hi hello
<!-- end -->
what is happening
<!-- start thing2 -->
ping pong
<!-- end -->
Bye!
Now try running update.py
after changing the values in the things
dictionary.
You will see that minsert will neatly update the test.md
without fail.
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 minsert-0.1.0.tar.gz
.
File metadata
- Download URL: minsert-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.8.0-55-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc172bb3991c2dc53f6970a2f779d9827c6c382db719ac6901a4c97524475dc9 |
|
MD5 | e06bf7662e78d0c1325cfacc142d4a71 |
|
BLAKE2b-256 | d353f6820469d53abe04fa8797148a4f84966e50eac8c394f774db2519376954 |
File details
Details for the file minsert-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: minsert-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.8.0-55-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f69899cac5e4180695be0ecef049f3b6604716896e5fa1286888ea5feddfd093 |
|
MD5 | adc55713e75f7ca3f65ae11859399341 |
|
BLAKE2b-256 | b8be9eb54eded6e4ba73f633296ea7078dfdc59c41440763b74aa7ad4592a7a8 |