rustdoc: Fix short summaries in search results

They should be run through a Markdown renderer in rustdoc to remove
links.

This also fixes the mouse over text for the Crates list on the sidebar.
This commit is contained in:
Oliver Middleton
2016-12-12 18:39:36 +00:00
parent 368e092c26
commit 4f15e1183c
3 changed files with 28 additions and 19 deletions

View File

@@ -609,7 +609,7 @@
displayPath + '<span class="' + type + '">' +
name + '</span></a></td><td>' +
'<a href="' + href + '">' +
'<span class="desc">' + item.desc +
'<span class="desc">' + escape(item.desc) +
'&nbsp;</span></a></td></tr>';
});
} else {
@@ -807,14 +807,6 @@
search();
}
function plainSummaryLine(markdown) {
markdown.replace(/\n/g, ' ')
.replace(/'/g, "\'")
.replace(/^#+? (.+?)/, "$1")
.replace(/\[(.*?)\]\(.*?\)/g, "$1")
.replace(/\[(.*?)\]\[.*?\]/g, "$1");
}
index = buildIndex(rawSearchIndex);
startSearch();
@@ -836,13 +828,10 @@
if (crates[i] === window.currentCrate) {
klass += ' current';
}
if (rawSearchIndex[crates[i]].items[0]) {
var desc = rawSearchIndex[crates[i]].items[0][3];
var link = $('<a>', {'href': '../' + crates[i] + '/index.html',
'title': plainSummaryLine(desc),
'class': klass}).text(crates[i]);
ul.append($('<li>').append(link));
}
var link = $('<a>', {'href': '../' + crates[i] + '/index.html',
'title': rawSearchIndex[crates[i]].doc,
'class': klass}).text(crates[i]);
ul.append($('<li>').append(link));
}
sidebar.append(div);
}