mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
fall back for if there's no recognised punctuation in microblog
This commit is contained in:
parent
f626ad95ff
commit
843e9d060a
1 changed files with 6 additions and 1 deletions
|
@ -259,11 +259,16 @@ def microblog_content_to_title(html: str) -> str:
|
|||
question_index = title.find('?')
|
||||
exclamation_index = title.find('!')
|
||||
|
||||
# Find the earliest occurrence of either '.' or '?'
|
||||
# Find the earliest occurrence of either '.' or '?' or '!'
|
||||
end_index = min(period_index if period_index != -1 else float('inf'),
|
||||
question_index if question_index != -1 else float('inf'),
|
||||
exclamation_index if exclamation_index != -1 else float('inf'))
|
||||
|
||||
# give up if there's no recognised punctuation
|
||||
if end_index == float('inf'):
|
||||
title = '(content in post body)'
|
||||
return title
|
||||
|
||||
if end_index != -1:
|
||||
if question_index != -1:
|
||||
end_index += 1 # Add the ? back on
|
||||
|
|
Loading…
Add table
Reference in a new issue