diff --git a/bookwyrm/tests/views/test_status.py b/bookwyrm/tests/views/test_status.py
index b782906d..893e0650 100644
--- a/bookwyrm/tests/views/test_status.py
+++ b/bookwyrm/tests/views/test_status.py
@@ -305,18 +305,16 @@ class StatusViews(TestCase):
)
url = "https://tech.lgbt/@bookwyrm"
self.assertEqual(
- views.status.format_links(url),
- 'tech.lgbt/@bookwyrm' % url
+ views.status.format_links(url), 'tech.lgbt/@bookwyrm' % url
)
url = "users.speakeasy.net/~lion/nb/book.pdf"
self.assertEqual(
views.status.format_links(url),
- 'users.speakeasy.net/~lion/nb/book.pdf' % url
+ 'users.speakeasy.net/~lion/nb/book.pdf' % url,
)
url = "pkm.one/#/page/The%20Book%20which%20launched%20a%201000%20Note%20taking%20apps"
self.assertEqual(
- views.status.format_links(url),
- '%s' % (url, url)
+ views.status.format_links(url), '%s' % (url, url)
)
def test_to_markdown(self, *_):
diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py
index a62e1b48..c415e4b2 100644
--- a/bookwyrm/views/status.py
+++ b/bookwyrm/views/status.py
@@ -157,7 +157,7 @@ def format_links(content):
formatted_content = ""
for potential_link in content.split():
try:
- # raises an error on anything that's not a valid
+ # raises an error on anything that's not a valid
URLValidator(potential_link)
except (ValidationError, UnicodeError):
formatted_content += potential_link + " "
@@ -165,32 +165,34 @@ def format_links(content):
wrapped = _wrapped(potential_link)
if wrapped:
wrapper_close = potential_link[-1]
- formatted_content += potential_link[0]
+ formatted_content += potential_link[0]
potential_link = potential_link[1:-1]
# so we can use everything but the scheme in the presentation of the link
url = urlparse(potential_link)
link = url.netloc + url.path + url.params
if url.query != "":
- link += "?" + url.query
+ link += "?" + url.query
if url.fragment != "":
link += "#" + url.fragment
formatted_content += '%s' % (potential_link, link)
if wrapped:
- formatted_content += wrapper_close
+ formatted_content += wrapper_close
return formatted_content
+
def _wrapped(text):
- """ check if a line of text is wrapped in parentheses, square brackets or curly brackets. return wrapped status """
- wrappers = [("(", ")"), ("[","]"), ("{", "}")]
+ """check if a line of text is wrapped in parentheses, square brackets or curly brackets. return wrapped status"""
+ wrappers = [("(", ")"), ("[", "]"), ("{", "}")]
for w in wrappers:
if text[0] == w[0] and text[-1] == w[-1]:
- return True
+ return True
return False
+
def to_markdown(content):
"""catch links and convert to markdown"""
content = markdown(content)