Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def to_html(cls, fmt, source):
extensions=[
# baselevel matches `initial_header_level` from BLOG_DOCUTILS_SETTINGS
TocExtension(baselevel=3, slugify=_md_slugify),
"tables",
],
)
raise ValueError(f"Unsupported format {fmt}")
Expand Down
22 changes: 22 additions & 0 deletions blog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@ def test_pub_date_localized(self):
with translation.override("nn"):
self.assertEqual(entry.pub_date_localized, "21. juli 2005")

def test_markdown_table_conversion(self):
body = (
"| Framework | Language |\n"
"|-----------|----------|\n"
"| Django | Python |\n"
"| Flask | Python |"
)

entry = Entry.objects.create(
pub_date=self.now,
slug="markdown-table",
body=body,
content_format=ContentFormat.MARKDOWN,
)
expected_html = (
"<table>\n"
"<thead>\n<tr>\n<th>Framework</th>\n<th>Language</th>\n</tr>\n</thead>\n"
"<tbody>\n<tr>\n<td>Django</td>\n<td>Python</td>\n</tr>\n"
"<tr>\n<td>Flask</td>\n<td>Python</td>\n</tr>\n</tbody>\n</table>"
)
self.assertInHTML(expected_html, entry.body_html)


class EventTestCase(DateTimeMixin, TestCase):
def test_manager_past_future(self):
Expand Down