You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/01/10 19:08:22 UTC
[18/50] git commit: [#4647] Make html2text import in ForgeWiki
optional
[#4647] Make html2text import in ForgeWiki optional
Signed-off-by: Peter Hartmann <pe...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/46c751ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/46c751ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/46c751ed
Branch: refs/heads/cj/4691
Commit: 46c751edf5ffd68301dc642c06bd6451d530a4b7
Parents: 57aa625
Author: Peter Hartmann <pe...@apache.org>
Authored: Tue Dec 18 01:19:31 2012 +0100
Committer: Dave Brondsema <db...@geek.net>
Committed: Wed Jan 9 19:47:11 2013 +0000
----------------------------------------------------------------------
ForgeWiki/forgewiki/converters.py | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/46c751ed/ForgeWiki/forgewiki/converters.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/converters.py b/ForgeWiki/forgewiki/converters.py
index 3fcfc41..0fb6ad0 100644
--- a/ForgeWiki/forgewiki/converters.py
+++ b/ForgeWiki/forgewiki/converters.py
@@ -1,10 +1,7 @@
#-*- python -*-
-import html2text
import re
from BeautifulSoup import BeautifulSoup
-html2text.BODY_WIDTH = 0
-
_inline_img = re.compile(r'\[\[(File|Image):([^\]|]+)[^]]*\]\]', re.UNICODE)
_inline_img_markdown = r'[[img src=\2]]'
_link_to_attach = re.compile(r'\[\[Media:([^\]|]+)\|?([^]]*)\]\]', re.UNICODE)
@@ -44,11 +41,15 @@ def _convert_toc(wiki_html):
def mediawiki2markdown(source):
try:
+ import html2text
from mediawiki import wiki2html
except ImportError:
- raise ImportError('GPL library "mediawiki" from https://github.com/zikzakmedia/python-mediawiki.git '
- 'is required for this operation')
-
+ raise ImportError("""This operation requires GPL libraries:
+ "mediawiki" (https://github.com/zikzakmedia/python-mediawiki.git)
+ "html2text" (https://github.com/aaronsw/html2text.git)""")
+
+ html2text.BODY_WIDTH = 0
+
wiki_content = wiki2html(source, True)
wiki_content = _convert_toc(wiki_content)
markdown_text = html2text.html2text(wiki_content)