Skip to content

Commit

Permalink
Keep code coloring in search results short text
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 25, 2020
1 parent 2dc5b60 commit d57901d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,17 @@ function getSearchElement() {
return tmp;
}

function colorCode(s) {
var parts = s.split("`");
if (parts.length < 3) {
return s;
}
for (var it = 1; it < parts.length; it += 2) {
parts[it] = "<code>" + parts[it] + "</code>";
}
return parts.join("");
}

function addTab(array, query, display) {
var extraStyle = "";
if (display === false) {
Expand Down Expand Up @@ -1458,7 +1469,7 @@ function getSearchElement() {
item.displayPath + "<span class=\"" + type + "\">" +
name + "</span></a></td><td>" +
"<a href=\"" + item.href + "\">" +
"<span class=\"desc\">" + escape(item.desc) +
"<span class=\"desc\">" + colorCode(escape(item.desc)) +
"&nbsp;</span></a></td></tr>";
});
output += "</table>";
Expand Down

0 comments on commit d57901d

Please sign in to comment.