From c8507f1398c3765013e35d9aff469c0731cbc249 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 22 2014 10:50:21 +0000 Subject: Add method in doc_utils to convert a given content according to the extension of the file containing this content --- diff --git a/progit/doc_utils.py b/progit/doc_utils.py index 74dcfa2..08f6d78 100644 --- a/progit/doc_utils.py +++ b/progit/doc_utils.py @@ -12,6 +12,7 @@ import docutils import docutils.examples import markupsafe +import markdown def modify_rst(rst): @@ -68,3 +69,15 @@ def convert_doc(rst_string): html_string = markupsafe.Markup(html_string) return html_string + + +def convert_readme(content, ext): + ''' Convert the provided content according to the extension of the file + provided. + ''' + output = content + if ext and ext in ['.rst']: + output= convert_doc(unicode(content)) + elif ext and ext in ['.mk']: + output = markdown.markdown(content) + return output