address review comments: reuse Escape etc.
This commit is contained in:
parent
17ebb6053e
commit
2b11a80a60
@ -471,7 +471,7 @@ impl<'a> fmt::String for MarkdownWithToc<'a> {
|
||||
}
|
||||
|
||||
pub fn plain_summary_line(md: &str) -> String {
|
||||
extern "C" fn link(_ob: *mut hoedown_buffer,
|
||||
extern fn link(_ob: *mut hoedown_buffer,
|
||||
_link: *const hoedown_buffer,
|
||||
_title: *const hoedown_buffer,
|
||||
content: *const hoedown_buffer,
|
||||
@ -479,9 +479,6 @@ pub fn plain_summary_line(md: &str) -> String {
|
||||
{
|
||||
unsafe {
|
||||
if !content.is_null() && (*content).size > 0 {
|
||||
// FIXME(liigo): I don't know why the parameter `_ob` is
|
||||
// not the value passed in by `hoedown_document_render`.
|
||||
// I have to manually pass in `ob` through `opaque` currently.
|
||||
let ob = opaque as *mut hoedown_buffer;
|
||||
hoedown_buffer_put(ob, (*content).data as *const libc::c_char,
|
||||
(*content).size);
|
||||
@ -490,7 +487,7 @@ pub fn plain_summary_line(md: &str) -> String {
|
||||
1
|
||||
}
|
||||
|
||||
extern "C" fn normal_text(_ob: *mut hoedown_buffer,
|
||||
extern fn normal_text(_ob: *mut hoedown_buffer,
|
||||
text: *const hoedown_buffer,
|
||||
opaque: *mut libc::c_void)
|
||||
{
|
||||
|
@ -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("<"),
|
||||
'>' => result.push_str(">"),
|
||||
'"' => result.push_str("""),
|
||||
'\'' => result.push_str("'"),
|
||||
_ => 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>"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user