mttransforms.py
changeset 10012 8c2c6fdd8d56
parent 7577 9892937d9041
--- a/mttransforms.py	Thu Oct 23 14:57:02 2014 +0200
+++ b/mttransforms.py	Wed Apr 30 21:04:14 2014 +0200
@@ -28,7 +28,7 @@
                                  register_pygments_transforms)
 
 from cubicweb.utils import UStringIO
-from cubicweb.uilib import rest_publish, html_publish
+from cubicweb.uilib import rest_publish, markdown_publish, html_publish
 
 HTML_MIMETYPES = ('text/html', 'text/xhtml', 'application/xhtml+xml')
 
@@ -40,6 +40,12 @@
     def _convert(self, trdata):
         return rest_publish(trdata.appobject, trdata.decode())
 
+class markdown_to_html(Transform):
+    inputs = ('text/markdown', 'text/x-markdown')
+    output = 'text/html'
+    def _convert(self, trdata):
+        return markdown_publish(trdata.appobject, trdata.decode())
+
 class html_to_html(Transform):
     inputs = HTML_MIMETYPES
     output = 'text/html'
@@ -53,6 +59,7 @@
 
 ENGINE = TransformEngine()
 ENGINE.add_transform(rest_to_html())
+ENGINE.add_transform(markdown_to_html())
 ENGINE.add_transform(html_to_html())
 
 try: