incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [18/50] git commit: [#6534] ticket:441 gollum external links conversion
Date Fri, 04 Oct 2013 16:30:46 GMT
[#6534] ticket:441 gollum external links conversion


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6f2f4e27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6f2f4e27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6f2f4e27

Branch: refs/heads/cj/5561
Commit: 6f2f4e2701c8fceab7a81a455a9da118f6aee03d
Parents: f06327a
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Sep 18 15:56:13 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:21 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6f2f4e27/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 027bc89..bfc4b21 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -225,4 +225,22 @@ class GitHubWikiImporter(ToolImporter):
         return _re.sub(repl, text)
 
     def convert_gollum_external_links(self, text):
-        return text
+        _re = re.compile(
+            r'''(?P<quote>')?                     # possible tag escaping
+                (?P<tag>\[\[                      # tag start
+                (?:(?P<title>[^]|]*)\|)?          # optional title
+                (?P<link>(?:http|https)://[^]]+)  # link
+                \]\])                             # tag end''', re.VERBOSE)
+
+        def repl(match):
+            link = match.group('link')
+            title = match.groupdict().get('title')
+            quote = match.groupdict().get('quote')
+            if quote:
+                # tag is escaped, return untouched
+                return match.group('tag')
+            if title:
+                return u'[{}]({})'.format(title, link)
+            return u'<{}>'.format(link)
+
+        return _re.sub(repl, text)


Mime
View raw message