From 6ea5bc45761e688cc888c7a17a6399b31d04bcc7 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Mon, 28 Jul 2008 12:46:39 +0545 Subject: [PATCH] Implement himg syntax --- geekigeeki.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/geekigeeki.py b/geekigeeki.py index 854c715..dba75a2 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -33,6 +33,7 @@ word_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$") file_re = re.compile(r"^\b([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)\b$") img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg)$", re.IGNORECASE) url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$") +link_re = re.compile("(?:\[\[|{{)([^\s\|]+)(?:\s*\|\s*([^\]]+)|)(?:\]\]|}})") title_done = False @@ -342,20 +343,30 @@ class WikiFormatter: return '<<' + '|'.join(argv) + '>>' def _hurl_repl(self, word): - m = re.compile("\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word) + m = link_re.match(word) name = m.group(1) descr = m.group(2) or name if img_re.match(name): - name = relative_url(name) - # The "extthumb" nonsense works around a limitation of the HTML block model - return '
%s
%s
' % (name, name, descr, descr) + # DEPRECATED SYNTAX: use {{foo.jpg|descr}} instead + _inl_repl(self, word) else: if img_re.match(descr): descr = '' return link_tag(name, descr, 'wikilink') + def _inl_repl(self, word): + m = link_re.match(word) + name = m.group(1) + descr = m.group(2) or name + name = relative_url(name) + if descr: + # The "extthumb" nonsense works around a limitation of the HTML block model + return '
%s
%s
' % (name, name, descr, descr) + else: + return '' % (name, name) + def _email_repl(self, word): return '%s' % (word, word) -- 2.25.1