https://github.com/aahnik/minsert
Insert dynamic content in markdown without using a separate template file.
https://github.com/aahnik/minsert
aahnik aahnik-daw jinja markdown python python3 template-engine
Last synced: 3 months ago
JSON representation
Insert dynamic content in markdown without using a separate template file.
- Host: GitHub
- URL: https://github.com/aahnik/minsert
- Owner: aahnik
- License: mit
- Created: 2021-05-21T06:17:16.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-07T13:40:16.000Z (almost 4 years ago)
- Last Synced: 2025-02-01T09:51:19.016Z (3 months ago)
- Topics: aahnik, aahnik-daw, jinja, markdown, python, python3, template-engine
- Language: Python
- Homepage: https://pypi.org/project/minsert
- Size: 24.4 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# minsert
Insert dynamic content in markdown, without using a separate template file.
[](https://github.com/aahnik/minsert/actions/workflows/test.yml)
[](https://github.com/aahnik/minsert/actions/workflows/quality.yml)

[](https://codecov.io/gh/aahnik/minsert)## 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
```shell
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`
```markdown
```
End a block
```markdown
```
You must end the current block before starting a new one.
## Usage
For example you have a markdown file `test.md` like this.
```markdown
hellowhat is happening
Bye!
```Create a simple script `update.py` for updating the markdown file.
```python
# update.pyfrom 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.
```markdown
hellohi hello
what is happening
ping pong
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.