about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLiigo Zhuang <com.liigo@gmail.com>2015-01-16 20:56:26 +0800
committerLiigo Zhuang <com.liigo@gmail.com>2015-01-21 21:31:09 +0800
commit2b11a80a60dbae980418b229ab89d2a28dbbc15f (patch)
treef250a2c384d0ca7b873ee008f47ea53d19b78fe1 /src
parent17ebb6053edd7b7d6e8ab5f59dd093f53db7ae44 (diff)
downloadrust-2b11a80a60dbae980418b229ab89d2a28dbbc15f.tar.gz
rust-2b11a80a60dbae980418b229ab89d2a28dbbc15f.zip
address review comments: reuse Escape etc.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/markdown.rs7
-rw-r--r--src/librustdoc/html/render.rs18
2 files changed, 4 insertions, 21 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 45b77ea2ddd..31c01e7777a 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -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)
     {
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 86c945125f6..480c61534e6 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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>"));