Skip to content

Commit

Permalink
display plain summary line in javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
liigo committed Jan 21, 2015
1 parent 58a257b commit 0c06442
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/librustdoc/html/static/main.js
Expand Up @@ -669,6 +669,18 @@
search();
}

function plainSummaryLine(markdown) {
var str = markdown.replace(/\n/g, ' ')
str = str.replace(/</g, "&lt;")
str = str.replace(/>/g, "&gt;")
str = str.replace(/"/g, "&quot;")
str = str.replace(/'/g, "&#39;")
str = str.replace(/^#+? (.+?)/, "$1")
str = str.replace(/\[(.*?)\]\(.*?\)/g, "$1")
str = str.replace(/\[(.*?)\]\[.*?\]/g, "$1")
return str;
}

index = buildIndex(rawSearchIndex);
startSearch();

Expand All @@ -691,7 +703,7 @@
}
var desc = rawSearchIndex[crates[i]].items[0][3];
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
'title': desc.replace(/\n/g, ' '),
'title': plainSummaryLine(desc),
'class': klass}).text(crates[i]));
}
sidebar.append(div);
Expand Down

0 comments on commit 0c06442

Please sign in to comment.