From 645ce17c6f9f9a027b4469fcfd554d2afe099dcc Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 23 Jul 2022 22:16:07 +0700 Subject: [PATCH 1/4] Fix. Fix problem wich version package in requirements --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 97472289..3647bb5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ -Django>=2.2 +Django>=2.2,<4.0 django-bootstrap4-form celery email-reply-parser akismet -markdown +markdown<3.0 beautifulsoup4 lxml simplejson From a28569a984d890191fe469d539d0e5a9c95065c0 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 27 Jul 2022 19:58:39 +0700 Subject: [PATCH 2/4] Fix. Fix problem wich version package in requirements and add test markdown --- helpdesk/tests/test_markdown.py | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 helpdesk/tests/test_markdown.py diff --git a/helpdesk/tests/test_markdown.py b/helpdesk/tests/test_markdown.py new file mode 100644 index 00000000..edfb4dbd --- /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) From cf5be66fae1de2b708f03e815ac69d4c48c1c642 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 6 Aug 2022 18:34:16 +0700 Subject: [PATCH 3/4] Fix. Fix problem wich version package in requirements and add test markdown and rewrite for new markdown --- helpdesk/models.py | 6 +++--- helpdesk/tests/test_markdown.py | 4 ++-- requirements.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index 7ef1b9c9..6a20091d 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -50,9 +50,9 @@ def format_time_spent(time_spent): class EscapeHtml(Extension): - def extendMarkdown(self, md, md_globals): - del md.preprocessors['html_block'] - del md.inlinePatterns['html'] + 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 index edfb4dbd..7eeccb02 100644 --- a/helpdesk/tests/test_markdown.py +++ b/helpdesk/tests/test_markdown.py @@ -20,14 +20,14 @@ class MarkDown(SimpleTestCase): self.assertEqual(output_value, expected_value) def test_markdown_fenced_code(self): - expected_value = '

Title

\n
# import os\n
' + 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) diff --git a/requirements.txt b/requirements.txt index 3647bb5e..5093ae89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ django-bootstrap4-form celery email-reply-parser akismet -markdown<3.0 +markdown beautifulsoup4 lxml simplejson From 8abf0ab8a80963b5b5fa3818f107babef71d81d8 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Aug 2022 18:16:18 +0700 Subject: [PATCH 4/4] Fix. Add test markdown and rewrite for last markdown is working --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5093ae89..97472289 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django>=2.2,<4.0 +Django>=2.2 django-bootstrap4-form celery email-reply-parser