Skip to content

Commit

Permalink
Attempt to fix #119 replace \ with / in paths, so that Windows al…
Browse files Browse the repository at this point in the history
…so uses `/` as separator (ugly hack)
  • Loading branch information
azerupi committed Apr 25, 2016
1 parent 1b8af2b commit 15d6227
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/renderer/html_handlebars/helpers/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext

match previous.get("path") {
Some(p) => {
// Hack for windows who tends to use `\` as separator instead of `/`
let path = Path::new(p).with_extension("html");
debug!("[*]: Inserting link: {:?}", path);

match path.to_str() {
Some(p) => {
previous_chapter.insert("link".to_owned(), p.to_json());
previous_chapter.insert("link".to_owned(), p.replace("\\", "/").to_json());
},
None => {
return Err(RenderError {
Expand Down Expand Up @@ -170,7 +171,8 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->

match link.to_str() {
Some(l) => {
next_chapter.insert("link".to_owned(), l.to_json());
// Hack for windows who tends to use `\` as separator instead of `/`
next_chapter.insert("link".to_owned(), l.replace("\\", "/").to_json());
},
None => return Err(RenderError { desc: "Link could not converted to str".to_owned() }),
}
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/html_handlebars/helpers/toc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl HelperDef for RenderToc {
.with_extension("html")
.to_str()
.unwrap()
// Hack for windows who tends to use `\` as separator instead of `/`
.replace("\\", "/")
.as_bytes()));

try!(rc.writer.write("\"".as_bytes()));
Expand Down Expand Up @@ -98,7 +100,8 @@ impl HelperDef for RenderToc {
// filter all events that are not inline code blocks
let parser = Parser::new(&name).filter(|event| {
match event {
&Event::Start(Tag::Code) | &Event::End(Tag::Code) => true,
&Event::Start(Tag::Code) |
&Event::End(Tag::Code) => true,
&Event::InlineHtml(_) => true,
&Event::Text(_) => true,
_ => false,
Expand Down

0 comments on commit 15d6227

Please sign in to comment.