From 7b4ec5c5e9a89fc1bc3b3fc8dfad26450530a2da Mon Sep 17 00:00:00 2001 From: asciimoo Date: Fri, 10 Jan 2014 23:38:08 +0100 Subject: [fix] highlighting only html --- searx/webapp.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'searx/webapp.py') 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: -- cgit v1.2.3