incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [20/50] git commit: [#6534] ticket:450 fixed gollum tags converting and fixed tests
Date Tue, 22 Oct 2013 15:00:47 GMT
[#6534] ticket:450 fixed gollum tags converting and fixed tests


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

Branch: refs/heads/cj/6692
Commit: b07a1fed3a82b605adf519b1e85e7fe983d5d3ed
Parents: 8589e2a
Author: coldmind <sokandpal@yandex.ru>
Authored: Wed Oct 9 18:42:01 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Oct 15 21:27:53 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/tests/test_wiki.py    | 10 +++---
 ForgeImporters/forgeimporters/github/wiki.py    | 37 ++++++++------------
 2 files changed, 20 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b07a1fed/ForgeImporters/forgeimporters/github/tests/test_wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_wiki.py b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
index c14ae63..edd9391 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -327,10 +327,10 @@ Our website is [[http://sf.net]].
 
 [External link](https://github.com/a/b/issues/1)'''
 
-        result = u'''<p>Look at <a href="Some%20Page" rel="nofollow">this page</a></p>
-<p>More info at: <a href="MoreInfo" rel="nofollow">MoreInfo</a> <a href="Even%20More%20Info"
rel="nofollow">Even More Info</a></p>
-<p>Our website is <a href="http://sf.net" rel="nofollow">http://sf.net</a>.</p>
-<p>'<a href="Escaped%20Tag" rel="nofollow">Escaped Tag</a></p>
+        result = u'''<p>Look at [[this page|Some Page]]</p>
+<p>More info at: [[MoreInfo]] [[Even More Info]]</p>
+<p>Our website is [[http://sf.net]].</p>
+<p>'[[Escaped Tag]]</p>
 <p>[External link to the wiki page](https://github.com/a/b/wiki/Page)</p>
 <p>[External link](https://github.com/a/b/issues/1)</p>'''
 
@@ -399,7 +399,7 @@ Some text 1.
 
 ## Header 2
 
-See [Page](Page)'''
+See [Page]'''
         assert_equal(f(source, 'test.textile').strip(), result)
 
     @skipif(module_not_available('html2text'))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b07a1fed/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index dbbaac9..a5989db 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -277,15 +277,24 @@ class GitHubWikiImporter(ToolImporter):
                 text = h.render_any_markup(filename, text)
                 text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
             return text
-        else:
-            if ext and ext in self.textile_exts:
-                text = self._prepare_textile_text(text)
+        elif ext and ext in self.textile_exts:
+            text = self._prepare_textile_text(text)
 
             text = h.render_any_markup(filename, text)
             text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
             if html2text:
                 text = html2text.html2text(text)
                 text = self.convert_gollum_tags(text)
+                text = text.replace('<notextile>', '').replace('</notextile>',
'')
+            else:
+                text = text.replace('&#60;notextile&#62;', '').replace('&#60;/notextile&#62;',
'')
+            return text
+        else:
+            text = h.render_any_markup(filename, text)
+            text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
+            if html2text:
+                text = html2text.html2text(text)
+                text = self.convert_gollum_tags(text)
             return text
 
     def convert_gollum_tags(self, text):
@@ -378,23 +387,7 @@ class GitHubWikiImporter(ToolImporter):
                 text_lines[i] = l.lstrip()
         text = '\n'.join(text_lines)
 
-        # if gollum-link, need to convert it to textile-link,
-        # because textile converter does not convert formatted
-        # gollum-link properly
-        link_re = re.compile("\[\[(?P<link>[^]]+)\]\]")
-        links = link_re.findall(text)
-        for link in links:
-            link = link.split('|')
-            if len(link) != 1:
-                title, link = link[0], link[1]
-                text = text.replace(u'[[%s|%s]]' % (title, link),
-                                    '"%s":%s' % (title, link.replace(' ', '%20')))
-            else:
-                link = link[0]
-                # textile importer doesn't works with some symbols
-                if "'" in link:
-                    text = text.replace(u'[[%s]]' % link, '[%s]' % link)
-                else:
-                    text = text.replace(u'[[%s]]' % link,
-                                        '"%s":%s' % (link, link.replace(' ', '%20')))
+        # to convert gollum tags properly used <notextile> tag,
+        # so these tags will not be affected by converter
+        text = text.replace('[[', '<notextile>[[').replace(']]', ']]</notextile>')
         return text


Mime
View raw message