diff --git a/django_sql_dashboard/templatetags/django_sql_dashboard.py b/django_sql_dashboard/templatetags/django_sql_dashboard.py index fc3eb72..c9f758e 100644 --- a/django_sql_dashboard/templatetags/django_sql_dashboard.py +++ b/django_sql_dashboard/templatetags/django_sql_dashboard.py @@ -55,6 +55,7 @@ def sql_dashboard_bleach(value): @register.filter def sql_dashboard_markdown(value): + value = value or "" return mark_safe( bleach.linkify( bleach.clean( diff --git a/test_project/test_widgets.py b/test_project/test_widgets.py index 5642c7a..396ac51 100644 --- a/test_project/test_widgets.py +++ b/test_project/test_widgets.py @@ -140,14 +140,25 @@ def test_big_number_widget(admin_client, dashboard_db): ) in html -def test_markdown_widget(admin_client, dashboard_db): +@pytest.mark.parametrize( + "sql,expected", + ( + ( + "select '# Foo\n\n## Bar [link](/)' as markdown", + '