5
5
import re
6
6
7
7
WORKER_SENTINEL = "\n \n // CONFIGS\n \n "
8
+ LIST_ITEM_REGEX = re .compile (r"^- " )
9
+
10
+
11
+ def render_search_terms (search_terms ):
12
+ rv = []
13
+ for term in search_terms :
14
+ term = re .compile (LIST_ITEM_REGEX ).sub ("" , term )
15
+ rv .append (term )
16
+ return rv
8
17
9
18
10
19
def parse_config (dirname , markdown_contents ):
@@ -28,9 +37,7 @@ def parse_config(dirname, markdown_contents):
28
37
for key in flat_keys :
29
38
config [key ] = " " .join (config [key ])
30
39
if "searchTerms" in config :
31
- config ["searchTerms" ] = [
32
- re .compile (r"^- " ).sub ("" , term ) for term in config ["searchTerms" ]
33
- ]
40
+ config ["searchTerms" ] = render_search_terms (config ["searchTerms" ])
34
41
if "avatar" in config :
35
42
matches = re .compile ("^.*\((.+)\)$" ).match (config ["avatar" ])
36
43
if matches :
@@ -46,7 +53,7 @@ def parse_config(dirname, markdown_contents):
46
53
config ["displayName" ] = display_name
47
54
48
55
if "isEnabled" in config :
49
- config ["isEnabled" ] = ( config ["isEnabled" ].lower () == "true" )
56
+ config ["isEnabled" ] = config ["isEnabled" ].lower () == "true"
50
57
else :
51
58
# for legacy support, if the section is missing, set to True
52
59
config ["isEnabled" ] = True
@@ -91,4 +98,5 @@ def main():
91
98
save_json_configs ("feed-generator/configs.json" , configs )
92
99
replace_json_configs ("cloudflare-worker/worker.js" , configs )
93
100
101
+
94
102
main ()
0 commit comments