mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
open graph: Include multiple paragraphs in description tags.
This commit is contained in:
@@ -460,9 +460,13 @@ class FinalizeOpenGraphDescription(MiddlewareMixin):
|
||||
for tag in bs.find_all('div', class_="admonition"):
|
||||
tag.clear()
|
||||
|
||||
# Find the first paragraph after that, and convert it from HTML to text.
|
||||
first_paragraph_text = bs.find('p').text.replace('\n', ' ')
|
||||
return first_paragraph_text
|
||||
text = ''
|
||||
for paragraph in bs.find_all('p'):
|
||||
# .text converts it from HTML to text
|
||||
text = text + paragraph.text.replace('\n', ' ') + ' '
|
||||
if len(text) > 500:
|
||||
return text.strip()
|
||||
return text.strip()
|
||||
|
||||
def alter_content(content: bytes) -> bytes:
|
||||
first_paragraph_text = get_content_description(content, request)
|
||||
|
||||
Reference in New Issue
Block a user