summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu David <mathieudavid@mathieudavid.org>2016-04-25 17:02:47 +0200
committerMathieu David <mathieudavid@mathieudavid.org>2016-04-25 17:02:47 +0200
commit15d6227a11dd930beadaa75885da7c62d94c38d4 (patch)
tree9ba111cb663462284386b9dc2bc3729092d1f93f
parent1b8af2bf57acfb180ea460f59a0c2f553757841b (diff)
Attempt to fix #119 replace `\` with `/` in paths, so that Windows also uses `/` as separator (ugly hack)v0.0.12
-rw-r--r--src/renderer/html_handlebars/helpers/navigation.rs6
-rw-r--r--src/renderer/html_handlebars/helpers/toc.rs5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs
index 8b300a94..82026dfd 100644
--- a/src/renderer/html_handlebars/helpers/navigation.rs
+++ b/src/renderer/html_handlebars/helpers/navigation.rs
@@ -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 {
@@ -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() }),
}
diff --git a/src/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs
index 9f4e142d..7ecb4da6 100644
--- a/src/renderer/html_handlebars/helpers/toc.rs
+++ b/src/renderer/html_handlebars/helpers/toc.rs
@@ -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()));
@@ -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,