From 4ca7a1119e77afa2528b28282e91a5226367733a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 7 Jun 2021 11:12:27 +0200 Subject: [PATCH 1/2] Fix integration of codeblocks in search result description --- src/librustdoc/html/static/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/search.js b/src/librustdoc/html/static/search.js index b3242bf4df923..35be246b5bf2e 100644 --- a/src/librustdoc/html/static/search.js +++ b/src/librustdoc/html/static/search.js @@ -1024,7 +1024,7 @@ window.initSearch = function(rawSearchIndex) { var description = document.createElement("div"); description.className = "desc"; var spanDesc = document.createElement("span"); - spanDesc.innerText = item.desc + "\u00A0"; + spanDesc.insertAdjacentHTML("beforeend", item.desc); description.appendChild(spanDesc); wrapper.appendChild(description); From 314ef592e284b16d4cb1764cec79cd5f0e0d0171 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 7 Jun 2021 11:19:29 +0200 Subject: [PATCH 2/2] Add test to ensure the result descripton is correctly handling codeblocks --- src/test/rustdoc-gui/search-result-description.goml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/test/rustdoc-gui/search-result-description.goml diff --git a/src/test/rustdoc-gui/search-result-description.goml b/src/test/rustdoc-gui/search-result-description.goml new file mode 100644 index 0000000000000..a50d03cf48912 --- /dev/null +++ b/src/test/rustdoc-gui/search-result-description.goml @@ -0,0 +1,5 @@ +// This test is to ensure that the codeblocks are correctly rendered in the search results. +goto: file://|DOC_PATH|/test_docs/index.html?search=some_more_function +// Waiting for the search results to appear... +wait-for: "#titles" +assert: (".search-results .desc code", "format!")