Skip to content

Commit 214ee16

Browse files
author
Agus Makmun
committed
fix: emoji issue
1 parent 1d23bb0 commit 214ee16

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

martor/tests/tests.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ def test_form(self):
3232
"living": "false", # enable/disable live updates in preview
3333
"spellcheck": "false", # enable/disable spellcheck in form textareas # noqa: E501
3434
"hljs": "true", # enable/disable hljs highlighting in preview
35-
}
35+
},
36+
MARTOR_MARKDOWN_BASE_EMOJI_URL="https://github.githubassets.com/images/icons/emoji/",
37+
MARTOR_MARKDOWN_BASE_MENTION_URL="https://python.web.id/author/",
3638
)
3739
def test_markdownify(self):
3840
# Heading
3941
response = self.client.post(
40-
"/martor/markdownify/", {"content": "# Hello world!"}
42+
"/martor/markdownify/",
43+
{"content": "# Hello world!"},
4144
)
4245
self.assertEqual(response.status_code, 200)
4346
self.assertEqual(
@@ -66,15 +69,26 @@ def test_markdownify(self):
6669
'<p><img alt="image" src="https://imgur.com/test.png"></p>',
6770
) # noqa: E501
6871

72+
# Emoji
73+
response = self.client.post(
74+
"/martor/markdownify/",
75+
{"content": ":heart:"},
76+
)
77+
self.assertEqual(response.status_code, 200)
78+
self.assertEqual(
79+
response.content.decode("utf-8"),
80+
'<p><img class="marked-emoji" src="https://github.githubassets.com/images/icons/emoji/heart.png"></p>',
81+
) # noqa: E501
82+
6983
# # Mention
7084
# response = self.client.post(
71-
# '/martor/markdownify/',
72-
# {'content': f'@[{self.user.username}]'}
85+
# "/martor/markdownify/",
86+
# {"content": f"@[{self.user.username}]"},
7387
# )
7488
# self.assertEqual(response.status_code, 200)
7589
# self.assertEqual(
76-
# response.content.decode('utf-8'),
77-
# '...fixme'
90+
# response.content.decode("utf-8"),
91+
# f'<p><a class="direct-mention-link" href="https://python.web.id/author/{self.user.username}/">{self.user.username}</a></p>',
7892
# )
7993

8094
def test_markdownify_xss_handled(self):

martor/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def markdownify(markdown_text):
4747
markdown_text,
4848
extensions=MARTOR_MARKDOWN_EXTENSIONS,
4949
extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS,
50-
output_format="html5",
5150
)
5251
return format_html(
5352
mark_safe(

0 commit comments

Comments
 (0)