Browse Source

generate_links works now

master
Cristina Cochior 5 years ago
parent
commit
f463bcbf23
  1. 11
      generate_links.py

11
generate_links.py

@ -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)

Loading…
Cancel
Save