Skip to content

Commit 2b11a80

Browse files
committed
address review comments: reuse Escape etc.
1 parent 17ebb60 commit 2b11a80

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

Diff for: src/librustdoc/html/markdown.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -471,17 +471,14 @@ impl<'a> fmt::String for MarkdownWithToc<'a> {
471471
}
472472

473473
pub fn plain_summary_line(md: &str) -> String {
474-
extern "C" fn link(_ob: *mut hoedown_buffer,
474+
extern fn link(_ob: *mut hoedown_buffer,
475475
_link: *const hoedown_buffer,
476476
_title: *const hoedown_buffer,
477477
content: *const hoedown_buffer,
478478
opaque: *mut libc::c_void) -> libc::c_int
479479
{
480480
unsafe {
481481
if !content.is_null() && (*content).size > 0 {
482-
// FIXME(liigo): I don't know why the parameter `_ob` is
483-
// not the value passed in by `hoedown_document_render`.
484-
// I have to manually pass in `ob` through `opaque` currently.
485482
let ob = opaque as *mut hoedown_buffer;
486483
hoedown_buffer_put(ob, (*content).data as *const libc::c_char,
487484
(*content).size);
@@ -490,7 +487,7 @@ pub fn plain_summary_line(md: &str) -> String {
490487
1
491488
}
492489

493-
extern "C" fn normal_text(_ob: *mut hoedown_buffer,
490+
extern fn normal_text(_ob: *mut hoedown_buffer,
494491
text: *const hoedown_buffer,
495492
opaque: *mut libc::c_void)
496493
{

Diff for: src/librustdoc/html/render.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ use html::item_type::ItemType;
6464
use html::layout;
6565
use html::markdown::Markdown;
6666
use html::markdown;
67+
use html::escape::Escape;
6768
use stability_summary;
6869

6970
/// A pair of name and its optional document.
@@ -2197,21 +2198,6 @@ fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
21972198
document(w, it)
21982199
}
21992200

2200-
fn escape_title(title: &str) -> String {
2201-
let title = markdown::plain_summary_line(title);
2202-
let mut result = String::with_capacity(title.len());
2203-
for c in title.chars() {
2204-
match c {
2205-
'<' => result.push_str("&lt;"),
2206-
'>' => result.push_str("&gt;"),
2207-
'"' => result.push_str("&quot;"),
2208-
'\'' => result.push_str("&#39;"),
2209-
_ => result.push(c),
2210-
}
2211-
}
2212-
result
2213-
}
2214-
22152201
impl<'a> fmt::String for Sidebar<'a> {
22162202
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
22172203
let cx = self.cx;
@@ -2251,7 +2237,7 @@ impl<'a> fmt::String for Sidebar<'a> {
22512237
} else {
22522238
format!("{}.{}.html", short, name.as_slice())
22532239
},
2254-
title = escape_title(doc.as_ref().unwrap().as_slice()),
2240+
title = Escape(doc.as_ref().unwrap().as_slice()),
22552241
name = name.as_slice()));
22562242
}
22572243
try!(write!(w, "</div>"));

0 commit comments

Comments
 (0)