File tree 2 files changed +9
-6
lines changed
2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 4
4
{% for post in blog.posts %}
5
5
< div class ="card ">
6
6
< div class ="card-body ">
7
- < h3 class ="card-title "> < a href ="{{post.link }} " target ="_blank "> {{ post.title }}</ a > </ h3 >
8
- < h6 class ="card-subtitle "> Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}</ h6 >
9
- < div class ="card-text "> {{ post.summary }}</ div >
10
- < a class ="card-link " href ="{{post.link }} " target ="_blank "> Read</ a >
7
+ < h5 class ="card-title "> < a href ="{{post.link }} " target ="_blank "> {{ post.title }}</ a > </ h5 >
8
+ < h6 class ="card-subtitle text-muted small mb-4 "> Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}</ h6 >
9
+ < div class ="card-text mb-2 "> {{ post.summary }}</ div >
10
+ < a class ="card-link small " href ="{{post.link }} " target ="_blank "> Read more </ a >
11
11
</ div >
12
12
</ div >
13
13
{% endfor %}
Original file line number Diff line number Diff line change 28
28
import importlib
29
29
import operator
30
30
import os
31
+ import re
31
32
import shutil
32
33
import sys
33
34
import time
34
35
import typing
35
36
36
37
import feedparser
37
- import markdown
38
38
import jinja2
39
+ import markdown
39
40
import requests
40
41
import yaml
41
42
@@ -74,13 +75,15 @@ def blog_add_posts(context):
74
75
preprocessor fetches the posts in the feeds, and returns the relevant
75
76
information for them (sorted from newest to oldest).
76
77
"""
78
+ tag_expr = re .compile ("<.*?>" )
77
79
posts = []
78
80
for feed_url in context ["blog" ]["feed" ]:
79
81
feed_data = feedparser .parse (feed_url )
80
82
for entry in feed_data .entries :
81
83
published = datetime .datetime .fromtimestamp (
82
84
time .mktime (entry .published_parsed )
83
85
)
86
+ summary = re .sub (tag_expr , "" , entry .summary )
84
87
posts .append (
85
88
{
86
89
"title" : entry .title ,
@@ -89,7 +92,7 @@ def blog_add_posts(context):
89
92
"feed" : feed_data ["feed" ]["title" ],
90
93
"link" : entry .link ,
91
94
"description" : entry .description ,
92
- "summary" : entry . summary ,
95
+ "summary" : summary ,
93
96
}
94
97
)
95
98
posts .sort (key = operator .itemgetter ("published" ), reverse = True )
You can’t perform that action at this time.
0 commit comments