Skip to content

Commit bf0a72b

Browse files
committed
Bring back search highlight
This reverts #6087 Closes #6305
1 parent 6a07cf8 commit bf0a72b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

readthedocs/core/static-src/core/js/doc-embed/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function attach_elastic_search_query(data) {
8383
if ('BUILDER' in DOCUMENTATION_OPTIONS && DOCUMENTATION_OPTIONS.BUILDER === 'readthedocsdirhtml') {
8484
suffix = '';
8585
}
86-
var link = doc.link + suffix;
86+
var link = doc.link + suffix + "?highlight=" + $.urlencode(query);
8787

8888
var item = $('<a>', {'href': link});
8989

readthedocs/core/static/core/js/readthedocs-doc-embed.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocs/templates/search/elastic_search.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ <h3>
180180

181181
{% elif 'page' in result.meta.index %}
182182
{% with "100" as MAX_SUBSTRING_LIMIT %}
183-
<a href="{% doc_url result.project|get_project result.version result.full_path %}">
183+
<a href="{% doc_url result.project|get_project result.version result.full_path %}?highlight={{ query }}">
184184
{{ result.project }} - {% if result.meta.highlight.title %} {{ result.meta.highlight.title.0|safe }} {% else %} {{ result.title }} {% endif %}
185185
</a>
186186

187187
{% for inner_hit in result.meta.inner_hits %}
188188
{% if inner_hit.type == 'domains' %}
189189
<p>
190-
<a href="{% doc_url result.project|get_project result.version result.full_path %}#{{ inner_hit.source.anchor }}">
190+
<a href="{% doc_url result.project|get_project result.version result.full_path %}?highlight={{ query }}#{{ inner_hit.source.anchor }}">
191191
{% if inner_hit.highlight|get_key_or_none:"domains.name" %}
192192
{% with domain_name=inner_hit.highlight|get_key_or_none:"domains.name" %}
193193
[{{ inner_hit.source.role_name }}]: {{ domain_name.0|safe }}
@@ -211,7 +211,7 @@ <h3>
211211

212212
{% elif inner_hit.type == 'sections' %}
213213
<p>
214-
<a href="{% doc_url result.project|get_project result.version result.full_path %}#{{ inner_hit.source.id }}">
214+
<a href="{% doc_url result.project|get_project result.version result.full_path %}?highlight={{ query }}#{{ inner_hit.source.id }}">
215215
{% if inner_hit.highlight|get_key_or_none:"sections.title" %}
216216
{% with section_title=inner_hit.highlight|get_key_or_none:"sections.title" %}
217217
{{ section_title.0|safe }}

0 commit comments

Comments
 (0)