incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [16/50] git commit: [#6534] ticket:450 converting lists properly now
Date Tue, 22 Oct 2013 15:00:43 GMT
[#6534] ticket:450 converting lists properly now


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

Branch: refs/heads/cj/6692
Commit: b1b7f4ee76cbe7f062ac5f052c8e2bd5fea7169b
Parents: 924e020
Author: coldmind <sokandpal@yandex.ru>
Authored: Tue Oct 8 15:48:17 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Oct 15 21:27:52 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b1b7f4ee/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 0cced81..9dc4d67 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -415,6 +415,29 @@ See [Page]'''
         assert_equal(f(source, 'test.textile').strip(), result)
 
 
+    def test_convert_markup_textile(self):
+        importer = GitHubWikiImporter()
+        importer.github_wiki_url = 'https://github.com/a/b/wiki'
+        importer.app = Mock()
+        importer.app.url = '/p/test/wiki/'
+        f = importer.convert_markup
+
+        # check if lists converting works properly
+        source = u'''There are good reasons for this:
+
+  # Duplicate libraries regularly break builds
+  # Subtle bugs emerge with duplicate libraries, and to a lesser extent, duplicate tools
+  # We want you to try harder to make your formula work with what OS X comes with
+'''
+        result = u'''There are good reasons for this:
+
+  1. Duplicate libraries regularly break builds
+  2. Subtle bugs emerge with duplicate libraries, and to a lesser extent, duplicate tools
+  3. We want you to try harder to make your formula work with what OS X comes with
+'''
+
+        assert_equal(f(source, 'test.textile'), result)
+
 class TestGitHubWikiImportController(TestController, TestCase):
 
     url = '/p/%s/admin/ext/import/github-wiki/' % test_project_with_wiki

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b1b7f4ee/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 16b011f..944bf79 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -120,6 +120,7 @@ class GitHubWikiImporter(ToolImporter):
 
     mediawiki_exts = ['.wiki', '.mediawiki']
     markdown_exts = ['.markdown,' '.mdown', '.mkdn', '.mkd', '.md']
+    textile_exts = ['.textile']
     # List of supported formats https://github.com/gollum/gollum/wiki#page-files
     supported_formats = [
             '.asciidoc',
@@ -131,8 +132,7 @@ class GitHubWikiImporter(ToolImporter):
             '.rst.txt',
             '.rest',
             '.rst',
-            '.textile',
-    ] + mediawiki_exts + markdown_exts
+    ] + mediawiki_exts + markdown_exts + textile_exts
     available_pages = []
 
     def import_tool(self, project, user, project_name=None, mount_point=None, mount_label=None,
user_name=None,
@@ -278,6 +278,14 @@ class GitHubWikiImporter(ToolImporter):
                 text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
             return text
         else:
+            if ext and ext in self.textile_exts:
+                # need to convert lists properly
+                text_lines = text.splitlines()
+                for i, l in enumerate(text_lines):
+                    if l.lstrip().startswith('#'):
+                        text_lines[i] = l.lstrip()
+                text = '\n'.join(text_lines)
+
             text = h.render_any_markup(filename, text)
             text = self.rewrite_links(text, self.github_wiki_url, self.app.url)
             if html2text:


Mime
View raw message