File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ import re
2
+ from bs4 import BeautifulSoup
3
+
4
+
5
+ def on_post_page (output , page , config ):
6
+ is_cn_tag_page = page .abs_url == "/leetcode/tags/"
7
+ is_en_tag_page = page .abs_url == "/leetcode/en/tags/"
8
+ if not is_cn_tag_page and not is_en_tag_page :
9
+ return output
10
+ soup = BeautifulSoup (output , "html.parser" )
11
+ tags = soup .find_all ("span" , class_ = "md-tag" )
12
+ for tag in tags :
13
+ tag_li = tag .find_next ("ul" ).find_all ("li" )
14
+ tag_li .sort (key = lambda x : int (re .search (r"\d+" , x .a .text ).group ()))
15
+ tag .find_next ("ul" ).clear ()
16
+ for li in tag_li :
17
+ tag .find_next ("ul" ).append (li )
18
+ return str (soup )
Original file line number Diff line number Diff line change 85
85
- hooks/committer.py
86
86
- hooks/fix_markdown_block.py
87
87
- hooks/ext_info.py
88
+ - hooks/tags.py
88
89
89
90
markdown_extensions :
90
91
- admonition
You can’t perform that action at this time.
0 commit comments