mirror of
https://github.com/zulip/zulip.git
synced 2025-10-29 11:03:54 +00:00
python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
11741543da
commit
6e4c3e41dc
@@ -7,20 +7,20 @@ from django.utils.html import escape
|
||||
from zerver.lib.cache import cache_with_key, open_graph_description_cache_key
|
||||
|
||||
|
||||
def html_to_text(content: Union[str, bytes], tags: Mapping[str, str] = {'p': ' | '}) -> str:
|
||||
bs = BeautifulSoup(content, features='lxml')
|
||||
def html_to_text(content: Union[str, bytes], tags: Mapping[str, str] = {"p": " | "}) -> str:
|
||||
bs = BeautifulSoup(content, features="lxml")
|
||||
# Skip any admonition (warning) blocks, since they're
|
||||
# usually something about users needing to be an
|
||||
# organization administrator, and not useful for
|
||||
# describing the page.
|
||||
for tag in bs.find_all('div', class_="admonition"):
|
||||
for tag in bs.find_all("div", class_="admonition"):
|
||||
tag.clear()
|
||||
|
||||
# Skip code-sections, which just contains navigation instructions.
|
||||
for tag in bs.find_all('div', class_="code-section"):
|
||||
for tag in bs.find_all("div", class_="code-section"):
|
||||
tag.clear()
|
||||
|
||||
text = ''
|
||||
text = ""
|
||||
for element in bs.find_all(tags.keys()):
|
||||
# Ignore empty elements
|
||||
if not element.text:
|
||||
@@ -31,7 +31,7 @@ def html_to_text(content: Union[str, bytes], tags: Mapping[str, str] = {'p': ' |
|
||||
text += element.text
|
||||
if len(text) > 500:
|
||||
break
|
||||
return escape(' '.join(text.split()))
|
||||
return escape(" ".join(text.split()))
|
||||
|
||||
|
||||
@cache_with_key(open_graph_description_cache_key, timeout=3600 * 24)
|
||||
|
||||
Reference in New Issue
Block a user