--- a/src/pyams_portal/portlets/html/skin/__init__.py Fri Dec 14 23:07:52 2018 +0100
+++ b/src/pyams_portal/portlets/html/skin/__init__.py Fri Dec 14 23:37:33 2018 +0100
@@ -9,14 +9,13 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
-from pyams_utils.interfaces.text import IHTMLRenderer
-
__docformat__ = 'restructuredtext'
from zope.interface import Interface
from pyams_i18n.interfaces import II18n
+from pyams_portal import _
from pyams_portal.interfaces import IPortalContext, IPortletRenderer
from pyams_portal.portlet import PortletRenderer
from pyams_portal.portlets.html.interfaces import IHTMLPortletSettings, IRawPortletSettings
@@ -24,9 +23,8 @@
from pyams_template.template import template_config
from pyams_utils.adapter import adapter_config
from pyams_utils.fanstatic import ExternalResource
-from pyams_utils.pygments import render_source, IPygmentsCodeConfiguration, library
-
-from pyams_portal import _
+from pyams_utils.interfaces.text import IHTMLRenderer
+from pyams_utils.pygments import IPygmentsCodeConfiguration, library, render_source
#
@@ -97,6 +95,30 @@
#
+# Markdown renderer
+#
+
+@adapter_config(name='markdown',
+ context=(IPortalContext, IPyAMSLayer, Interface, IRawPortletSettings),
+ provides=IPortletRenderer)
+@template_config(template='templates/code.pt', layer=IPyAMSLayer)
+class RawPortletSourceMarkdownRenderer(PortletRenderer):
+ """Markdown text portlet renderer"""
+
+ label = _("Markdown text renderer")
+ weight = 30
+
+ @property
+ def body(self):
+ code = II18n(self.settings).query_attribute('body', request=self.request)
+ if code:
+ renderer = self.request.registry.queryMultiAdapter((code, self.request), IHTMLRenderer, name='markdown')
+ if renderer is not None:
+ return renderer.render()
+ return ''
+
+
+#
# Formatted HTML renderer
#