Commit 0229d23e authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat(ext/markdown): add urlize extension

parent 1fc8cf641c3c
Pipeline #23352 passed with stages
in 36 minutes and 17 seconds
......@@ -18,7 +18,7 @@ def markdown_publish(context, data):
:return:
the data formatted as HTML or the original data if an error occurred
"""
md = markdown.Markdown()
md = markdown.Markdown(extensions=['mdx_urlize:UrlizeExtension'])
try:
return md.convert(data)
except:
......
# copyright 2020 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
#
# CubicWeb is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
from logilab.common.testlib import unittest_main
from cubicweb.devtools.testlib import CubicWebTC
from cubicweb.ext.markdown import markdown_publish
class MarkdownTC(CubicWebTC):
def context(self, req):
return req.execute('CWUser X WHERE X login "admin"').get_entity(0, 0)
def test_basic(self):
self.assertEqual(markdown_publish(None, '_test_'), '<p><em>test</em></p>')
def test_urlify(self):
self.assertEqual(markdown_publish(None, 'https://www.logilab.fr/'),
'<p><a href="https://www.logilab.fr/">https://www.logilab.fr/</a></p>')
if __name__ == '__main__':
unittest_main()
......@@ -72,6 +72,7 @@ setup(
'passlib >= 1.7',
'pytz',
'Markdown',
'markdown-urlize',
'filelock',
'rdflib',
'rdflib-jsonld',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment