--- a/src/pyams_utils/text.py Fri Dec 14 18:32:37 2018 +0100
+++ b/src/pyams_utils/text.py Fri Dec 14 23:36:05 2018 +0100
@@ -15,6 +15,7 @@
import html
import docutils.core
+from markdown import markdown
from pyramid.interfaces import IRequest
from zope.interface import Interface
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
@@ -127,6 +128,18 @@
return ''.join((parts['body_pre_docinfo'], parts['docinfo'], parts['body']))
+@adapter_config(name='markdown', context=(str, IRequest), provides=IHTMLRenderer)
+class MarkdownTextRenderer(BaseHTMLRenderer):
+ """Markdown HTML renderer
+
+ This renderer is using *Markdown* HTML output.
+ """
+
+ def render(self, **kwargs):
+ """Renderer Markdown code to HTML"""
+ return markdown(self.context)
+
+
def text_to_html(text, renderer='text'):
"""Convert text to HTML using the given renderer