Skip to content

Commit f99a892

Browse files
authored
Rollup merge of #86095 - GuillaumeGomez:search-description-codeblock, r=jsha
Search description codeblock The codeblocks are not displayed correctly: ![Screenshot from 2021-06-07 11-11-53](https://user-images.githubusercontent.com/3050060/120991915-5fb05680-c782-11eb-9b32-973a64b1f631.png) This PR interprets the HTML correctly (and still prevent invalid HTML because of how it inserts it): ![Screenshot from 2021-06-07 11-12-00](https://user-images.githubusercontent.com/3050060/120991919-6048ed00-c782-11eb-8ac5-c3aa6508bc8b.png) r? ```@jsha```
2 parents e062121 + 314ef59 commit f99a892

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustdoc/html/static/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ window.initSearch = function(rawSearchIndex) {
10241024
var description = document.createElement("div");
10251025
description.className = "desc";
10261026
var spanDesc = document.createElement("span");
1027-
spanDesc.innerText = item.desc + "\u00A0";
1027+
spanDesc.insertAdjacentHTML("beforeend", item.desc);
10281028

10291029
description.appendChild(spanDesc);
10301030
wrapper.appendChild(description);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This test is to ensure that the codeblocks are correctly rendered in the search results.
2+
goto: file://|DOC_PATH|/test_docs/index.html?search=some_more_function
3+
// Waiting for the search results to appear...
4+
wait-for: "#titles"
5+
assert: (".search-results .desc code", "format!")

0 commit comments

Comments
 (0)