Markdown extension: Add static tag to image source
pip install markdown-djangostaticimage==0.1
Author: Melvin Koh
pip install markdown-djangostaticimage
from markdown import Markdown
from django_static_image import DjangoStaticImageExtension
text = """![profile_pic](images/profile_pic.png)"""
md = markdown.Markdown(extensions=[DjangoStaticImageExtension()])
html = md.convert(text)
print(html)
# Output
'<p><img alt="profile_pic" src="{% static 'images/profile_pic.png' %}" /></p>'
Note that Markdown by default converts each line as a paragraph
![profile_picture](images/my_profile_picture.png)
<img alt="profile_picture" src="images/my_profile_picture.png" />
<img alt="profile_picture" src={% static "images/my_profile_picture.png" %} />
<img alt="profile_picture" src={% static "<prefix>/images/my_profile_picture.png" %} />