1
Fork 0

address review comments: reuse Escape etc.

This commit is contained in:
Liigo Zhuang 2015-01-16 20:56:26 +08:00
parent 17ebb6053e
commit 2b11a80a60
2 changed files with 4 additions and 21 deletions

View file

@ -64,6 +64,7 @@ use html::item_type::ItemType;
use html::layout;
use html::markdown::Markdown;
use html::markdown;
use html::escape::Escape;
use stability_summary;
/// A pair of name and its optional document.
@ -2197,21 +2198,6 @@ fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
document(w, it)
}
fn escape_title(title: &str) -> String {
let title = markdown::plain_summary_line(title);
let mut result = String::with_capacity(title.len());
for c in title.chars() {
match c {
'<' => result.push_str("&lt;"),
'>' => result.push_str("&gt;"),
'"' => result.push_str("&quot;"),
'\'' => result.push_str("&#39;"),
_ => result.push(c),
}
}
result
}
impl<'a> fmt::String for Sidebar<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let cx = self.cx;
@ -2251,7 +2237,7 @@ impl<'a> fmt::String for Sidebar<'a> {
} else {
format!("{}.{}.html", short, name.as_slice())
},
title = escape_title(doc.as_ref().unwrap().as_slice()),
title = Escape(doc.as_ref().unwrap().as_slice()),
name = name.as_slice()));
}
try!(write!(w, "</div>"));