incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [33/50] git commit: [#6534] ticket:449 Don't convert markdown
Date Wed, 09 Oct 2013 12:48:49 GMT
[#6534] ticket:449 Don't convert markdown


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

Branch: refs/heads/cj/6422
Commit: a6a62ab8bd1efebd806d29454d100e4409007788
Parents: 3bd2b02
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Sep 30 18:00:13 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:24 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/tests/test_wiki.py    | 23 ++++++--------------
 ForgeImporters/forgeimporters/github/wiki.py    | 14 ++++++------
 2 files changed, 14 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a6a62ab8/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 91b5190..9a78fa9 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -245,19 +245,10 @@ Our website is [[http://sf.net]].
 
 [External link](https://github.com/a/b/issues/1)'''
 
-        result = u'''Look at [this page](Some Page)
-
-More info at: [MoreInfo] [Even More Info]
-
-Our website is <http://sf.net>.
-
-[[Escaped Tag]]
-
-[External link to the wiki page](/p/test/wiki/Page)
-
-[External link](https://github.com/a/b/issues/1)\n\n'''
+        # markdown should be untouched
+        assert_equal(f(source, 'test.md'), source)
 
-        assert_equal(f(source, 'test.md'), result)
+        assert_equal(f(u'h1. Hello', 't.textile'), u'# Hello\n\n')
 
     @without_module('html2text')
     def test_convert_markup_without_html2text(self):
@@ -278,14 +269,14 @@ Our website is [[http://sf.net]].
 
 [External link](https://github.com/a/b/issues/1)'''
 
-        result = u'''<div class="markdown_content"><p>Look at [[this page|Some
Page]]</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><a class="" href="/p/test/wiki/Page" rel="nofollow">External link to the wiki
page</a></p>
-<p><a class="" href="https://github.com/a/b/issues/1" rel="nofollow">External
link</a></p></div>'''
+<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>'''
 
-        assert_equal(f(source, 'test.md'), result)
+        assert_equal(f(source, 'test.textile'), result)
 
     def test_rewrite_links(self):
         f = GitHubWikiImporter().rewrite_links

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a6a62ab8/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 163f657..45f29e8 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -118,16 +118,13 @@ class GitHubWikiImporter(ToolImporter):
     tool_label = 'Wiki'
     tool_description = 'Import your wiki from GitHub'
     tool_option = {"import_history": "Import history"}
+
     mediawiki_exts = ['.wiki', '.mediawiki']
+    markdown_exts = ['.markdown,' '.mdown', '.mkdn', '.mkd', '.md']
     # List of supported formats https://github.com/gollum/gollum/wiki#page-files
     supported_formats = [
             '.asciidoc',
             '.creole',
-            '.markdown',
-            '.mdown',
-            '.mkdn',
-            '.mkd',
-            '.md',
             '.org',
             '.pod',
             '.rdoc',
@@ -136,7 +133,7 @@ class GitHubWikiImporter(ToolImporter):
             '.rest',
             '.rst',
             '.textile',
-    ] + mediawiki_exts
+    ] + mediawiki_exts + markdown_exts
 
     def import_tool(self, project, user, project_name=None, mount_point=None, mount_label=None,
user_name=None,
                     tool_option=None, **kw):
@@ -227,12 +224,15 @@ class GitHubWikiImporter(ToolImporter):
         Files in mediawiki format are converted using mediawiki2markdown
         if html2text is available.
         """
+        name, ext = os.path.splitext(filename)
+        if ext in self.markdown_exts:
+            return text
+
         try:
             import html2text
         except ImportError:
             html2text = None
 
-        name, ext = os.path.splitext(filename)
         if ext and ext in self.mediawiki_exts:
             if html2text:
                 text = mediawiki2markdown(text)


Mime
View raw message