Skip to content

Commit a9acda2

Browse files
committed
remove logic for removing new line
1 parent 4857a80 commit a9acda2

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

readthedocs/search/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_link(self, obj):
3737
def get_highlight(self, obj):
3838
highlight = getattr(obj.meta, 'highlight', None)
3939
if highlight:
40-
ret = utils._remove_newlines_from_dict(highlight.to_dict())
40+
ret = highlight.to_dict()
4141
log.debug('API Search highlight [Page title]: %s', pformat(ret))
4242
return ret
4343

readthedocs/search/utils.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -155,35 +155,10 @@ def _indexing_helper(html_objs_qs, wipe=False):
155155
delete_objects_in_es.delay(**kwargs)
156156

157157

158-
def _remove_newlines_from_dict(highlight):
159-
"""
160-
Recursively change results to turn newlines into periods.
161-
162-
See: https://github.com/rtfd/readthedocs.org/issues/5168
163-
:param highlight: highlight dict whose contents are to be edited.
164-
:type highlight: dict
165-
:returns: dict with all the newlines changed to periods.
166-
:rtype: dict
167-
"""
168-
for k, v in highlight.items():
169-
if isinstance(v, dict):
170-
highlight[k] = _remove_newlines_from_dict(v)
171-
else:
172-
# elastic returns the contents of the
173-
# highlighted field in a list.
174-
if isinstance(v, list):
175-
v_new_list = [res.replace('\n', '. ') for res in v]
176-
highlight[k] = v_new_list
177-
178-
return highlight
179-
180-
181158
def _get_inner_hits_highlights(hit, logging=False):
182-
"""Removes new lines from highlight dict"""
159+
"""Returns highlight dict and does conditional logging of the same."""
183160
if hasattr(hit, 'highlight'):
184-
highlight_dict = _remove_newlines_from_dict(
185-
hit.highlight.to_dict()
186-
)
161+
highlight_dict = hit.highlight.to_dict()
187162

188163
if logging:
189164
log.debug('API Search highlight: %s', pformat(highlight_dict))

0 commit comments

Comments
 (0)