mirror of
https://github.com/searxng/searxng.git
synced 2025-07-30 16:42:22 +02:00
[fix] highlighting only html
This commit is contained in:
parent
04c408389d
commit
7b4ec5c5e9
3 changed files with 35 additions and 28 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue