]> git.lizzy.rs Git - rust.git/commitdiff
fix rustdoc metadata parsing
authorAlexis Beingessner <a.beingessner@gmail.com>
Thu, 30 Jul 2015 22:29:34 +0000 (15:29 -0700)
committerAlexis Beingessner <a.beingessner@gmail.com>
Thu, 30 Jul 2015 22:51:50 +0000 (15:51 -0700)
src/librustdoc/markdown.rs

index bc6c797e5c5da3d55fb809cf38d93b20e93db876..a311b938e9609de758e1756e3de20828a0077b03 100644 (file)
 /// Separate any lines at the start of the file that begin with `%`.
 fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
     let mut metadata = Vec::new();
+    let mut count = 0;
     for line in s.lines() {
         if line.starts_with("%") {
             // remove %<whitespace>
-            metadata.push(line[1..].trim_left())
+            metadata.push(line[1..].trim_left());
+            count += line.len() + 1;
         } else {
-            let line_start_byte = s.find(line).unwrap();
-            return (metadata, &s[line_start_byte..]);
+            return (metadata, &s[count..]);
         }
     }
     // if we're here, then all lines were metadata % lines.