Skip to content
Snippets Groups Projects
Commit e95b3fdc authored by HeJ's avatar HeJ
Browse files

Merge branch 'fix/markdown_matrix_urls' into 'develop'

markdown: ignore mastodon / matrix handles

See merge request hub/hub!1147
parents fb93c503 d1dddb10
Branches
Tags prod-2024-12-26_00-21
No related merge requests found
...@@ -35,7 +35,7 @@ class PageLink(SpanToken): ...@@ -35,7 +35,7 @@ class PageLink(SpanToken):
class ProfileLink(SpanToken): class ProfileLink(SpanToken):
pattern = re.compile(r'(?<!\S)@([-a-zA-Z0-9_]+)') pattern = re.compile(r'(?<!\S)@([-a-zA-Z0-9_]+)(?=\s|$)')
parse_inner = False parse_inner = False
def __init__(self, match): def __init__(self, match):
......
...@@ -90,6 +90,10 @@ class MarkdownTest(TestCase): ...@@ -90,6 +90,10 @@ class MarkdownTest(TestCase):
self.assertEqual(render_markdown(conf, '@nonexisting_user'), '<p><a href="/en/user/nonexisting_user/" class="internal">@nonexisting_user</a></p>\n') self.assertEqual(render_markdown(conf, '@nonexisting_user'), '<p><a href="/en/user/nonexisting_user/" class="internal">@nonexisting_user</a></p>\n')
self.assertEqual(render_markdown(conf, 'foo@bar'), '<p>foo@bar</p>\n') self.assertEqual(render_markdown(conf, 'foo@bar'), '<p>foo@bar</p>\n')
self.assertEqual(render_markdown(conf, '@"'), '<p>@"</p>\n') self.assertEqual(render_markdown(conf, '@"'), '<p>@"</p>\n')
# ignores element handles
self.assertEqual(render_markdown(conf, '@foo:bar.org'), '<p>@foo:bar.org</p>\n')
# ignores mastodon handles
self.assertEqual(render_markdown(conf, '@test@chaos.social'), '<p>@test@chaos.social</p>\n')
self.assertEqual(render_markdown_ex(conf, '@existing_user').linked_user_slugs, {'existing_user'}) self.assertEqual(render_markdown_ex(conf, '@existing_user').linked_user_slugs, {'existing_user'})
self.assertEqual(render_markdown_ex(conf, '@nonexisting_user').linked_user_slugs, {'nonexisting_user'}) self.assertEqual(render_markdown_ex(conf, '@nonexisting_user').linked_user_slugs, {'nonexisting_user'})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment