Compare commits

...

3 commits

Author SHA1 Message Date
Mouse Reeve
e26ba3857c Only modify pound symbols at the start of a word 2022-05-23 16:13:56 -07:00
Mouse Reeve
c022debee9 Appease pylint 2022-05-23 15:59:32 -07:00
Mouse Reeve
8605f5ac6b Don't erase hashtag symbol in markdown processing 2022-05-23 15:53:17 -07:00
2 changed files with 8 additions and 0 deletions

View file

@ -16,6 +16,7 @@ from bookwyrm.tests.validate_html import validate_html
@patch("bookwyrm.lists_stream.populate_lists_task.delay")
@patch("bookwyrm.activitystreams.remove_status_task.delay")
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
# pylint: disable=too-many-public-methods
class StatusViews(TestCase):
"""viewing and creating statuses"""
@ -299,6 +300,12 @@ http://www.fish.com/"""
result = views.status.to_markdown(text)
self.assertEqual(result, '<p><a href="http://fish.com">hi</a> ' "is rad</p>")
def test_to_markdown_hashtag(self, *_):
"""hashtags not titles"""
text = "#cool"
result = views.status.to_markdown(text)
self.assertEqual(result, "<p>#cool</p>")
def test_delete_status(self, mock, *_):
"""marks a status as deleted"""
view = views.DeleteStatus.as_view()

View file

@ -260,6 +260,7 @@ def _wrapped(text):
def to_markdown(content):
"""catch links and convert to markdown"""
content = format_links(content)
content = re.sub(r"\B#", "\\#", content)
content = markdown(content)
# sanitize resulting html
sanitizer = InputHtmlParser()