summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2014-01-10 23:38:08 +0100
committerasciimoo <asciimoo@gmail.com>2014-01-10 23:38:08 +0100
commit7b4ec5c5e9a89fc1bc3b3fc8dfad26450530a2da (patch)
treed7d83df0a8910bea8aae6100749f8009b2c7c740 /searx/webapp.py
parent04c408389d3d1a97a6a4b59502490372d67357cf (diff)
[fix] highlighting only html
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 9905bce37..606e109b9 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -29,6 +29,7 @@ import json
import cStringIO
from searx.utils import UnicodeWriter
from flask import send_from_directory
+from searx.utils import highlight_content, html_to_text
@@ -104,6 +105,14 @@ def index():
results, suggestions = search(query, request, selected_engines)
for result in results:
+ if request_data.get('format', 'html') == 'html':
+ if 'content' in result:
+ result['content'] = highlight_content(result['content'], query)
+ result['title'] = highlight_content(result['title'], query)
+ else:
+ if 'content' in result:
+ result['content'] = html_to_text(result['content']).strip()
+ result['title'] = html_to_text(result['title']).strip()
if len(result['url']) > 74:
result['pretty_url'] = result['url'][:35] + '[..]' + result['url'][-35:]
else: