diff --git a/app/utils.py b/app/utils.py index 196e6888..7228a49d 100644 --- a/app/utils.py +++ b/app/utils.py @@ -250,9 +250,10 @@ def microblog_content_to_title(html: str) -> str: title = '' for tag in soup.find_all('p'): - title = tag.get_text() + title = tag.get_text(separator=" ") break else: + html = html.replace('<', '.', 1) title = shorten_string(html, 160) period_index = title.find('.') @@ -270,9 +271,9 @@ def microblog_content_to_title(html: str) -> str: return title if end_index != -1: - if question_index != -1: + if question_index != -1 and question_index == end_index: end_index += 1 # Add the ? back on - if exclamation_index != -1: + if exclamation_index != -1 and exclamation_index == end_index: end_index += 1 # Add the ! back on title = title[:end_index]