improve post teasers by avoid common fail modes

This commit is contained in:
rimu 2024-12-01 08:40:35 +13:00
parent 91dbe4c30b
commit afcb4be96f

View file

@ -427,8 +427,9 @@ def first_paragraph(html):
first_para = soup.find('p')
if first_para:
if first_para.text.strip() == 'Summary' or \
first_para.text.strip() == '*Summary*' or \
first_para.text.strip() == 'Comments' or \
first_para.text.lower().startswith('cross-posted from: https'):
first_para.text.lower().startswith('cross-posted from:'):
second_paragraph = first_para.find_next('p')
if second_paragraph:
return f'<p>{second_paragraph.text}</p>'