From: Michael Tremer Date: Tue, 16 Jul 2019 15:38:55 +0000 (+0100) Subject: wiki: Post-process images to format them nicely X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9881e9efac55dba5f21dfa38b999da29a3c9f98e;p=ipfire.org.git wiki: Post-process images to format them nicely Signed-off-by: Michael Tremer --- diff --git a/src/backend/wiki.py b/src/backend/wiki.py index 4601be4c..5c4d0499 100644 --- a/src/backend/wiki.py +++ b/src/backend/wiki.py @@ -505,7 +505,7 @@ class WikiRenderer(misc.Object): 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"\"(.*?)\"") def init(self, path): self.path = path @@ -569,13 +569,13 @@ class WikiRenderer(misc.Object): % (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 """
%s
%s
- """ % (url, url, caption or "") + """ % (url, alt_text, caption or "") # Try to split query string url, delimiter, qs = url.partition("?") @@ -614,8 +614,10 @@ class WikiRenderer(misc.Object): # 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
text = self.images.sub(self._render_image, text) - # Borrow this from the blog - return self.backend.blog._render_text(text, lang="markdown") + return text