Skip to content

Commit

Permalink
Basic support for Wiki images
Browse files Browse the repository at this point in the history
  • Loading branch information
tweekmonster committed Jun 8, 2016
1 parent 6f48a63 commit 9059cb8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion grip/renderers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import print_function, unicode_literals

import os
import re
import json
import sys
Expand Down Expand Up @@ -124,7 +125,11 @@ def wiki_url(match):
url = match.group(2) or match.group(1)
url = re.sub(r'[\s\+]', '-', url)
url = re.sub(r'[^a-z0-9\-_]', urlencode, url)
return '[{0}]({1})'.format(match.group(1), url)
md = '[{0}]({1})'.format(match.group(1), url)
ext = os.path.splitext(url)[1]
if ext and ext in ('.jpg', '.jpeg', '.png', '.gif'):
return '!' + md
return md

return re.sub(r'\[\[([^\]\|]+)(?:\|([^\]]+))?\]\]', wiki_url, text)

Expand Down

0 comments on commit 9059cb8

Please sign in to comment.