diff --git a/helpdesk/models.py b/helpdesk/models.py index 73b2ba7c..ab19c9bd 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -44,10 +44,9 @@ def format_time_spent(time_spent): class EscapeHtml(Extension): - def extendMarkdown(self, md, md_globals=None): - # del md.preprocessors['html_block'] - # del md.inlinePatterns['html'] - pass + def extendMarkdown(self, md): + md.preprocessors.deregister('html_block') + md.inlinePatterns.deregister('html') def get_markdown(text): diff --git a/helpdesk/tests/test_markdown.py b/helpdesk/tests/test_markdown.py new file mode 100644 index 00000000..7eeccb02 --- /dev/null +++ b/helpdesk/tests/test_markdown.py @@ -0,0 +1,44 @@ + +from django.test import SimpleTestCase +from helpdesk.models import get_markdown + + +class MarkDown(SimpleTestCase): + """Test work Markdown functional""" + def test_markdown_html_tab(self): + expected_value = "

<div>test<div>

" + input_value = "
test
" + output_value = get_markdown(input_value) + self.assertEqual(output_value, expected_value) + + def test_markdown_nl2br(self): + """ warning, after Line 1 - two withespace, esle did't work""" + expected_value = "

Line 1
\n Line 2

" + input_value = """Line 1 + Line 2""" + output_value = get_markdown(input_value) + self.assertEqual(output_value, expected_value) + + def test_markdown_fenced_code(self): + expected_value = '

Title

\n
# import os\n
' + input_value = """ +# Title + +```python +# import os +``` + """ + output_value = get_markdown(input_value) + self.assertEqual(output_value, expected_value) + + def test_markdown_link_correct_protokol(self): + expected_value = '

www.google.com

' + input_value = "[www.google.com](http://www.yahoo.ru)" + output_value = get_markdown(input_value) + self.assertEqual(output_value, expected_value) + + def test_markdown_link_not_correct_protokol(self): + expected_value = '

www.google.com

' + input_value = "[www.google.com](aaaa://www.yahoo.ru)" + output_value = get_markdown(input_value) + self.assertEqual(output_value, expected_value)