Cristina Cochior 6 years ago
parent
commit
296f3d7ab0
  1. 3
      contextualise.py
  2. 7
      generate_links.py

3
contextualise.py

@ -118,6 +118,9 @@ def description():
if file.lower().endswith(('.html')): if file.lower().endswith(('.html')):
with open("static/"+file,"r", encoding='utf-8') as f: with open("static/"+file,"r", encoding='utf-8') as f:
textfile = f.read() textfile = f.read()
word = "way"
wordlinked = "<a href='/diverge?search="+word+"'>"+word+"</a>"
textfile = re.sub(word, wordlinked, textfile)
textfile = Markup(textfile) textfile = Markup(textfile)
return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfile=textfile, idno=idno) return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfile=textfile, idno=idno)

7
generate_links.py

@ -15,4 +15,9 @@ for path, subdirs, files in os.walk(path):
textfile = f.read() textfile = f.read()
for word in wordlist_dict: for word in wordlist_dict:
wordlinked = "<a href='/diverge?search="+word+"'>"+word+"</a>" wordlinked = "<a href='/diverge?search="+word+"'>"+word+"</a>"
textfile = re.sub(word, wordlinked, textfile) # wordlinked = re.escape(wordlinked)
print(wordlinked)
# word = re.escape(word)
print(word)
# textfile = re.sub(word, wordlinked, textfile)
# print(textfile)

Loading…
Cancel
Save