Skip to content

Commit

Permalink
squash 169
Browse files Browse the repository at this point in the history
  • Loading branch information
kalbfled committed Dec 6, 2024
1 parent 0ca3da4 commit 5c162ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions notifications_utils/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ class NotifyMarkdownRenderer(MarkdownRenderer):


notify_html_markdown = mistune.create_markdown(
hard_wrap=True,
renderer=NotifyHTMLRenderer(escape=False),
plugins=['url'],
)
Expand Down
38 changes: 20 additions & 18 deletions tests/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,26 @@ def test_html_template_has_urls_replaced_with_links():
), 'subject': ''}))


@pytest.mark.parametrize('markdown_function, expected_output', [
(notify_html_markdown, (
'<p style="Margin: 0 0 20px 0; font-size: 16px; line-height: 25px; color: #323A45;">'
'<a style="word-wrap: break-word; color: #004795;" href="https://example.com">'
'https://example.com'
'</a>'
'</p>'
'<p style="Margin: 0 0 20px 0; font-size: 16px; line-height: 25px; color: #323A45;">'
'Next paragraph'
'</p>'
)),
(notify_markdown, (
'\n'
'\nhttps://example.com'
'\n'
'\nNext paragraph'
)),
])
@pytest.mark.parametrize(
'markdown_function, expected_output',
[
(notify_html_markdown, (
'<p style="Margin: 0 0 20px 0; font-size: 16px; line-height: 25px; color: #323A45;">'
'<a style="word-wrap: break-word; color: #004795;" href="https://example.com">'
'https://example.com'
'</a>'
'</p>\n'
'<p style="Margin: 0 0 20px 0; font-size: 16px; line-height: 25px; color: #323A45;">'
'Next paragraph'
'</p>\n'
)),
(notify_markdown, (
'https://example.com\n\n'
'Next paragraph\n'
)),
],
ids=('notify_html_markdown', 'notify_markdown'),
)
def test_preserves_whitespace_when_making_links(
markdown_function, expected_output
):
Expand Down

0 comments on commit 5c162ae

Please sign in to comment.