Skip to content

Don't use \ as directory separator, not even on Windows #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Evrey opened this issue Mar 13, 2016 · 8 comments
Closed

Don't use \ as directory separator, not even on Windows #119

Evrey opened this issue Mar 13, 2016 · 8 comments

Comments

@Evrey
Copy link

Evrey commented Mar 13, 2016

Yeah. mdBook generates all links with .\chapter.html instead of ./chapter.html on Windows. This way, I have to edit all links by hand if I plan to load my on-Windows-generated HTML book up on some website.

@azerupi
Copy link
Contributor

azerupi commented Mar 13, 2016

I don't have a windows machine, so I can't really test this.

My first guess would be that Rusts Paths are represented that way on windows. I don't know if there is an option to change that. Else I will have make my own path to string method that behaves the same on all platforms.

@Evrey
Copy link
Author

Evrey commented Mar 14, 2016

I guess that Path-to-String solution would be the easiest way to go. Its just a matter of a simple extra String::replace("\\", "/") then. You might use std::path::MAIN_SEPARATOR if "\\" feels too dirty.

In fact, '/' is almost always the easiest cross-platform way to go. All Unixoids like Mac OS and Linux use it and Windows accepts it in the Win32API (although cmd.exe, the Windows shell, does not know about '/'). Thus, the whole standard library works just fine using '/' as directory separator.

@azerupi
Copy link
Contributor

azerupi commented Apr 25, 2016

@Evrey, could you tell me exactly where this happens?

Is this only for links in the sidebar, navigation, all links?

@Evrey
Copy link
Author

Evrey commented Apr 25, 2016

Right now it looks like only sidebar-/navigation-links are affected, i.e. those links that will be converted from anything.md to anything.html. All other links seem to be left untouched.

@azerupi
Copy link
Contributor

azerupi commented Apr 25, 2016

Yes, it's what I thought. So I use path.to_str() and it seems that it uses the \ separator in windows. I am not sure how I can change that behavior though.

You might use std::path::MAIN_SEPARATOR if "" feels too dirty.

Do you know how I could set the MAIN_SEPARATOR ?

@azerupi azerupi reopened this Apr 25, 2016
@azerupi
Copy link
Contributor

azerupi commented Apr 25, 2016

I have used the string::replace hack, but it would need some testing. Could you try it out on windows an let me know if it works? (or broke the world 😋)

@Evrey
Copy link
Author

Evrey commented Apr 25, 2016

Slashes everywhere, finally! Many thanks.

@azerupi
Copy link
Contributor

azerupi commented Apr 25, 2016

Good! I will make a release to crates.io in the following days :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants