email_link = re.compile(r"\[\[([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)(?:\|(.+?))?\]\]")
# Images
- images = re.compile(r"{{([\w\d\/\-\.]+)(?:\|(.+?))?}}")
+ images = re.compile(r"<img src=\"(.*?)\" alt=\"(.*?)\" (?:title=\"(.*?)\" )?/>")
def init(self, path):
self.path = path
% (address, alias or address)
def _render_image(self, m):
- url, caption = m.groups()
+ url, alt_text, caption = m.groups()
# Skip any absolute and external URLs
if url.startswith("/") or url.startswith("https://") or url.startswith("http://"):
return """<figure class="figure"><img src="%s" class="figure-img img-fluid rounded" alt="%s">
<figcaption class="figure-caption">%s</figcaption></figure>
- """ % (url, url, caption or "")
+ """ % (url, alt_text, caption or "")
# Try to split query string
url, delimiter, qs = url.partition("?")
# Handle email links
text = self.email_link.sub(self._render_email_link, text)
- # Handle images
+ # Borrow this from the blog
+ text = self.backend.blog._render_text(text, lang="markdown")
+
+ # Postprocess images to <figure>
text = self.images.sub(self._render_image, text)
- # Borrow this from the blog
- return self.backend.blog._render_text(text, lang="markdown")
+ return text