]> git.lizzy.rs Git - rust.git/commitdiff
address review comments: reuse Escape etc.
authorLiigo Zhuang <com.liigo@gmail.com>
Fri, 16 Jan 2015 12:56:26 +0000 (20:56 +0800)
committerLiigo Zhuang <com.liigo@gmail.com>
Wed, 21 Jan 2015 13:31:09 +0000 (21:31 +0800)
src/librustdoc/html/markdown.rs
src/librustdoc/html/render.rs

index 45b77ea2dddc4fc351285807fcb7b68e0df7d930..31c01e7777a226b240fb7cbaa78e8f9016399c41 100644 (file)
@@ -471,7 +471,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 }
 
 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 @@ extern "C" fn link(_ob: *mut hoedown_buffer,
     {
         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 @@ extern "C" fn link(_ob: *mut hoedown_buffer,
         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)
     {
index 86c945125f624ef39ef9d7a085a4bffafac0860b..480c61534e6bff2be7f2d6ff643c2d4949137e8e 100644 (file)
@@ -64,6 +64,7 @@
 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 @@ fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
                        } 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>"));