Reformat using black
This commit is contained in:
parent
efee4ad081
commit
a87fb49918
221 changed files with 19127 additions and 7310 deletions
|
@ -10,15 +10,15 @@ def generate_opengraph(cache_key, data, style):
|
|||
if metadata is None:
|
||||
description = None
|
||||
tree = reference(markdown(data, style)).tree
|
||||
for p in tree.iterfind('.//p'):
|
||||
for p in tree.iterfind(".//p"):
|
||||
text = p.text_content().strip()
|
||||
if text:
|
||||
description = text
|
||||
break
|
||||
if description:
|
||||
for remove in (r'\[', r'\]', r'\(', r'\)'):
|
||||
description = description.replace(remove, '')
|
||||
img = tree.xpath('.//img')
|
||||
metadata = truncatewords(description, 60), img[0].get('src') if img else None
|
||||
for remove in (r"\[", r"\]", r"\(", r"\)"):
|
||||
description = description.replace(remove, "")
|
||||
img = tree.xpath(".//img")
|
||||
metadata = truncatewords(description, 60), img[0].get("src") if img else None
|
||||
cache.set(cache_key, metadata, 86400)
|
||||
return metadata
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue