Skip to content

Commit 0f0c48b

Browse files
committed
rustbook: Fix relative links on the Introduction page
The Introduction page generated by rustbook used weird relative links like "./getting-started.html" instead of just "getting-started.html" like on the other pages. This adversely affected Windows builds the worst, since it generated links like ".\getting-started.html" (note the backslash). If you then try to upload the generated book to a webserver, you end up with 404's. See this example of what is going on with the Introduction page links and why this PR should fix it: http://is.gd/fRUTXk Compare the links on these two pages, for instance: https://doc.rust-lang.org/nightly/book/ https://doc.rust-lang.org/nightly/book/getting-started.html Also, fix a few whitespace issues in build.rs.
1 parent 94ddfc7 commit 0f0c48b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/rustbook/book.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn parse_summary(input: &mut Read, src: &Path) -> Result<Book, Vec<String>>
102102
top_items.push(BookItem {
103103
title: "Introduction".to_string(),
104104
path: PathBuf::from("README.md"),
105-
path_to_root: PathBuf::from("."),
105+
path_to_root: PathBuf::from(""),
106106
children: vec!(),
107107
});
108108

src/rustbook/build.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ fn write_toc(book: &Book, current_page: &BookItem, out: &mut Write) -> io::Resul
5252
current_page: &BookItem,
5353
out: &mut Write) -> io::Result<()> {
5454
let class_string = if item.path == current_page.path {
55-
"class='active'"
55+
"class='active'"
5656
} else {
57-
""
57+
""
5858
};
5959

6060
try!(writeln!(out, "<li><a {} href='{}'><b>{}</b> {}</a>",
61-
class_string,
62-
current_page.path_to_root.join(&item.path).with_extension("html").display(),
63-
section,
64-
item.title));
61+
class_string,
62+
current_page.path_to_root.join(&item.path).with_extension("html").display(),
63+
section,
64+
item.title));
6565
if !item.children.is_empty() {
6666
try!(writeln!(out, "<ul class='section'>"));
6767
let _ = walk_items(&item.children[..], section, current_page, out);

0 commit comments

Comments
 (0)