generate_links works now

This commit is contained in:
Cristina Cochior 2019-05-05 01:56:05 +02:00
parent 296f3d7ab0
commit f463bcbf23

View File

@ -14,10 +14,7 @@ for path, subdirs, files in os.walk(path):
with open(file, encoding='utf-8') as f:
textfile = f.read()
for word in wordlist_dict:
wordlinked = "<a href='/diverge?search="+word+"'>"+word+"</a>"
# wordlinked = re.escape(wordlinked)
print(wordlinked)
# word = re.escape(word)
print(word)
# textfile = re.sub(word, wordlinked, textfile)
# print(textfile)
word = re.escape(word)
textfile = re.sub(r"(?<!<)(?<!</)(?<!ge\?)\b(%s)\b" %word, r"<a href='/diverge?search='\1'>\1</a>", textfile)
print(textfile)