diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index cb2c63a..94d47cd 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -10,6 +10,7 @@ import datetime +import markdown import os import shutil import tempfile @@ -2176,3 +2177,21 @@ def add_token_to_user(session, project, acls, username): session.commit() return 'Token created' + +def text2markdown(text): + """ Simple text to html converter using the markdown library. + """ + if text: + # Hack to allow blockquotes to be marked by ~~~ + ntext = [] + indent = False + for line in text.split('\n'): + if line.startswith('~~~'): + indent = not indent + continue + if indent: + line = ' %s' % line + ntext.append(line) + return markdown.markdown('\n'.join(ntext)) + + return '' diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index e49e76f..703dc46 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -15,7 +15,6 @@ import urlparse import arrow import bleach import flask -import markdown from pygments import highlight from pygments.lexers.text import DiffLexer @@ -215,20 +214,7 @@ def markdown_filter(text): """ Template filter converting a string into html content using the markdown library. """ - if text: - # Hack to allow blockquotes to be marked by ~~~ - ntext = [] - indent = False - for line in text.split('\n'): - if line.startswith('~~~'): - indent = not indent - continue - if indent: - line = ' %s' % line - ntext.append(line) - return no_js(markdown.markdown('\n'.join(ntext))) - - return '' + return no_js(pagure.lib.text2markdown(text)) @APP.template_filter('html_diff')