Skip to content

Commit 9c2eee9

Browse files
committed
main.py cards parse <title> and <meta name="description" (#2482)
(cherry picked from commit 8ef0111)
1 parent 7748bd3 commit 9c2eee9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,20 @@ def cards(pages, columns=1, style="cards", force_version=False):
6464
if match:
6565
title = match.groups()[0]
6666
else:
67-
title = ""
67+
match = re.search("<title>(.*)</title>", content, re.MULTILINE)
68+
if match:
69+
title = match.groups()[0]
70+
else:
71+
title = ""
6872
match = re.search("<meta property=\"og:description\" content=\"(.*)\"", content, re.MULTILINE)
6973
if match:
7074
description = match.groups()[0]
7175
else:
72-
description = ""
76+
match = re.search("<meta name=\"description\" content=\"(.*)\"", content, re.MULTILINE)
77+
if match:
78+
description = match.groups()[0]
79+
else:
80+
description = ""
7381
href = page
7482
else:
7583
with open("docs/%s.md" % page, "r") as doc_file:

0 commit comments

Comments
 (0)