diff --git a/apprise/conversion.py b/apprise/conversion.py index 86e967bc..b02edaa3 100644 --- a/apprise/conversion.py +++ b/apprise/conversion.py @@ -58,8 +58,7 @@ def markdown_to_html(content): """ Converts specified content from markdown to HTML. """ - - return markdown(content) + return markdown(content, extensions=['nl2br', 'tables']) def text_to_html(content): diff --git a/test/test_conversion.py b/test/test_conversion.py index 53646d03..e2a64401 100644 --- a/test/test_conversion.py +++ b/test/test_conversion.py @@ -29,6 +29,7 @@ from apprise import NotifyFormat from apprise.conversion import convert_between import pytest +from inspect import cleandoc # Disable logging for a cleaner testing output import logging @@ -150,3 +151,60 @@ def test_conversion_text_to(): assert response == \ '<title>Test Message</title><body>Body<'\ '/body>' + + +def test_conversion_markdown_to_html(): + """conversion: Test markdown to html + """ + + # While this uses the underlining markdown library + # what we're testing for are the edge cases we know it doesn't support + # hence, `-` (a dash) with the markdown library must be a `*` to work + # correctly + response = convert_between( + NotifyFormat.MARKDOWN, NotifyFormat.HTML, cleandoc(""" + ## Some Heading + + With Data: + + - Foo + - Bar + """)) + + assert '
  • Foo
  • ' in response + assert '
  • Bar
  • ' in response + assert '

    Some Heading

    ' in response + assert '
    ' not in response + + # if the - follows With Data on the very next line, it's consider to not + # requiring indentation + response = convert_between( + NotifyFormat.MARKDOWN, NotifyFormat.HTML, cleandoc(""" + ## Some Heading + + With Data: + - Foo + - Bar + """)) + + # Breaks are added: + assert '
    ' in response + assert '- Foo' in response + assert '- Bar' in response + + # Table formatting + response = convert_between( + NotifyFormat.MARKDOWN, NotifyFormat.HTML, cleandoc(""" + First Header | Second Header + -------------- | ------------- + Content Cell1 | Content Cell3 + Content Cell2 | Content Cell4 + """)) + + assert '' in response + assert '' in response + assert '' in response + assert '' in response + assert '' in response + assert '' in response + assert '' in response
    First HeaderSecond HeaderContent Cell1Content Cell2Content Cell3Content Cell4