Commit 7d4287c8 authored by Mario Chirinos's avatar Mario Chirinos

news details

parent c92a88c4
......@@ -278,19 +278,19 @@ def newsDetails(request, newsId):
news = News.objects.get(id=newsId)
news.text = news.text
print (request.GET)
if "text" in request.GET and request.GET["text"] != '' and request.GET["text"] != None:
translator = str.maketrans('', '', string.punctuation)
searchtext = request.GET['text'].translate(translator)
print("search text:", searchtext)
for i in searchtext.split():
print("search for: ", i)
txtlen = len(i)
index = news.text.lower().find(i.lower())
print("index:", i, index)
if index>0:
word = news.text[index:index+txtlen]
print(word)
news.text = news.text.replace(word, "<b>"+word+"</b>")
# if "text" in request.GET and request.GET["text"] != '' and request.GET["text"] != None:
# translator = str.maketrans('', '', string.punctuation)
# searchtext = request.GET['text'].translate(translator)
# print("search text:", searchtext)
# for i in searchtext.split():
# print("search for: ", i)
# txtlen = len(i)
# index = news.text.lower().find(i.lower())
# print("index:", i, index)
# if index>0:
# word = news.text[index:index+txtlen]
# print(word)
# news.text = news.text.replace(word, "<b>"+word+"</b>")
paragraphs = news.text.split(". \n")
paragraphs = ["<p>" + p + "</p>" for p in paragraphs]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment