title: Very nice carrot soup
created_at: 2013-10-03 1:59:00
description: This is some really good carrot soup.....
### Ingredients ###
### Cooking ###
Boil some water. And eat it with all Ingredients
I wish this helpful for you You can use Python-Markdown's Extension API and develop a plugin which alters the src attribute of all images. In this specific case, you could override the image_link and image_reference inline processors by subclassing the ImageInlineProcessor and ReferenceInlineProcessor classes. But there is no need to alter the parser's behavior. You only need to modify the src attribute of all img tags. This would be easiest with a TreeProcessor.
from markdown.treeprocessors import Treeprocessor
from urllib.parse import urljoin
BASE = 'https://media.mydomain.com/'
def run(self, root):
# Loop through all img elements
for img in root.getiterator('img'):
# Join base to the src URL
img.set('src', urljoin(BASE, img.get('src'))
from markdown.extensions import Extension
def extendMarkdown(self, md, md_globals):
# register the new treeprocessor with priority 15 (run after 'inline')
md.treeprocessors.register(ImgBaseTreeprocessor(md), 'imgbase', 15)
from markdown import markdown
html = markdown(text, extensions=[ImgBase()])
How to convert HTML to Markdown while retaining non-markdown HTML tags?