mirror of
https://github.com/searx/searx
synced 2024-12-28 20:15:10 +01:00
[fix] pep8
This commit is contained in:
parent
7e946a369b
commit
73948f3020
@ -51,7 +51,7 @@ class ViewsTestCase(SearxTestCase):
|
|||||||
result.data
|
result.data
|
||||||
)
|
)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'<p class="content">first <span class="highlight">test</span> content<br /></p>',
|
'<p class="content">first <span class="highlight">test</span> content<br /></p>', # noqa
|
||||||
result.data
|
result.data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ def highlight_content(content, query):
|
|||||||
query = query.decode('utf-8')
|
query = query.decode('utf-8')
|
||||||
if content.lower().find(query.lower()) > -1:
|
if content.lower().find(query.lower()) > -1:
|
||||||
query_regex = u'({0})'.format(re.escape(query))
|
query_regex = u'({0})'.format(re.escape(query))
|
||||||
content = re.sub(query_regex, '<span class="highlight">\\1</span>', content, flags=re.I | re.U)
|
content = re.sub(query_regex, '<span class="highlight">\\1</span>',
|
||||||
|
content, flags=re.I | re.U)
|
||||||
else:
|
else:
|
||||||
regex_parts = []
|
regex_parts = []
|
||||||
for chunk in query.split():
|
for chunk in query.split():
|
||||||
@ -37,7 +38,8 @@ def highlight_content(content, query):
|
|||||||
else:
|
else:
|
||||||
regex_parts.append(u'{0}'.format(re.escape(chunk)))
|
regex_parts.append(u'{0}'.format(re.escape(chunk)))
|
||||||
query_regex = u'({0})'.format('|'.join(regex_parts))
|
query_regex = u'({0})'.format('|'.join(regex_parts))
|
||||||
content = re.sub(query_regex, '<span class="highlight">\\1</span>', content, flags=re.I | re.U)
|
content = re.sub(query_regex, '<span class="highlight">\\1</span>',
|
||||||
|
content, flags=re.I | re.U)
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user