Skip to content

Commit d0aef45

Browse files
committed
feat: markdownify summaries
Use markdownify in feedergrabber27.py to convert HTML summaries to markdown ones.
1 parent dc29d0b commit d0aef45

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

home/feedergrabber27.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import feedparser
1111

12+
from markdownify import markdownify as md
13+
1214
from .utils import is_medium_comment
1315

1416

@@ -87,7 +89,7 @@ def feedergrabber(url):
8789
continue
8890

8991
# Post content
90-
content = getattr(entry, "summary", "")
92+
content = md(getattr(entry, "summary", ""))
9193
# Append
9294
post_links_and_titles.append((link, title, post_date, content))
9395
if len(post_links_and_titles) == 0:

home/zulip_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def announce_posts(posts, debug=True):
4646
path = reverse("view_post", kwargs={"slug": post.slug})
4747
url = "{}/{}".format(settings.ROOT_URL.rstrip("/"), path.lstrip("/"))
4848
content = ANNOUNCE_MESSAGE.format(author, title, url)
49-
if post.content
49+
if post.content:
5050
summary = post.content if len(post.content) <= 480 else post.content[:477] + "..."
5151
content = content + QUOTE.format(summary)
5252
send_message_zulip(to, subject, content, type_="stream")

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ text-unidecode==1.3; python_version >= "3.6"
4444
urllib3==1.26.6; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.6"
4545
zope.event==4.5.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_version > "3.5"
4646
zope.interface==5.4.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_version > "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version > "3.5"
47+
markdownify; python_version >= "3.6"

0 commit comments

Comments
 (0)