From 9593092c8f2ee77547d6e071ce1b88eb061439ae Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 25 May 2022 13:57:31 +0100 Subject: [PATCH] Tab index for post links --- content.py | 17 +++++++++-------- tests.py | 28 +++++++++++++++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/content.py b/content.py index 911e34041..5c762c25b 100644 --- a/content.py +++ b/content.py @@ -616,8 +616,8 @@ def add_web_links(content: str) -> str: # the word contains a prefix if wrd.endswith('.') or wrd.endswith(';'): wrd = wrd[:-1] - markup = '' + markup = '' for prefix in prefixes: if wrd.startswith(prefix): markup += '' @@ -768,7 +768,7 @@ def _add_mention(word_str: str, http_prefix: str, following: str, replace_mentions[word_str] = \ "@" + \ + "\" tabindex=\"10\" class=\"u-url mention\">@" + \ possible_nickname + "" return True # try replacing petnames with mentions @@ -795,7 +795,8 @@ def _add_mention(word_str: str, http_prefix: str, following: str, replace_mentions[word_str] = \ "@" + \ + "\" tabindex=\"10\" " + \ + "class=\"u-url mention\">@" + \ replace_nickname + "" return True follow_ctr += 1 @@ -827,8 +828,8 @@ def _add_mention(word_str: str, http_prefix: str, following: str, replace_mentions[word_str] = \ "@" + possible_nickname + \ - "" + "\" tabindex=\"10\" class=\"u-url mention\">@" + \ + possible_nickname + "" return True # @nick@domain if not (possible_domain == 'localhost' or '.' in possible_domain): @@ -845,8 +846,8 @@ def _add_mention(word_str: str, http_prefix: str, following: str, replace_mentions[word_str] = \ "@" + possible_nickname + \ - "" + "\" tabindex=\"10\" class=\"u-url mention\">@" + \ + possible_nickname + "" return True diff --git a/tests.py b/tests.py index cbadeb96d..9271e656f 100644 --- a/tests.py +++ b/tests.py @@ -3583,10 +3583,15 @@ def _test_web_links(): example_text = \ 'This post has a web links https://somesite.net\n\nAnd some other text' linked_text = add_web_links(example_text) - assert \ - 'somesite.netsomesite.net None: low_bandwidth, content_license_url, languages_understood) # print(str(reply)) - assert reply['object']['content'] == \ + expected_str = \ '

' + \ - '@ninjarodent' + \ ' This is a test.

' + if reply['object']['content'] != expected_str: + print(expected_str + '\n') + print(reply['object']['content']) + assert reply['object']['content'] == expected_str reply['object']['contentMap'][system_language] = reply['object']['content'] assert reply['object']['tag'][0]['type'] == 'Mention' assert reply['object']['tag'][0]['name'] == '@ninjarodent@rat.site' @@ -5541,17 +5550,22 @@ def _test_links_within_post(base_dir: str) -> None: low_bandwidth, content_license_url, languages_understood) - assert post_json_object['object']['content'] == \ + expected_str = \ '

This is a test post with links.

' + \ '' + \ '' + \ '' + \ 'ftp.ncdc.noaa.gov/pub/data/ghcn/v4/' + \ - '



' + \ '' + \ 'libreserver.org

' + if post_json_object['object']['content'] != expected_str: + print(expected_str + '\n') + print(post_json_object['object']['content']) + assert post_json_object['object']['content'] == expected_str assert post_json_object['object']['content'] == \ post_json_object['object']['contentMap'][system_language]