Skip to content

Conversation

@EricTendian
Copy link
Contributor

Right now the book cannot be viewed in GitHub from README files due to the filenames having spaces and not being URL-encoded, causing GitHub Markdown to render it as something like this:

image

This PR addresses the problem by properly URL-encoding the links in each of the various README files, including for each translation. In the process of doing the encoding I noticed the Chinese version had level-specific READMEs with different wording than the overall README, so particular headings may have been overwritten with the wording used at zh/README.md.

@EricTendian EricTendian changed the title URL-encoding Markdown links with spaces for GitHub Markdown URL-encoding Markdown links with spaces for GitHub Markdown compatibility Mar 21, 2017
@braydie
Copy link
Owner

braydie commented Mar 21, 2017

@EricTendian you are a champion! I just spotted this today and was going to start going through and fixing the links but you beat me to it!! 😃 Thank you so much!

@braydie braydie merged commit fe28ced into braydie:master Mar 21, 2017
@braydie
Copy link
Owner

braydie commented Mar 21, 2017

Oh snap looks like each pages link to the next page is bust too - I'll try pick that up tomorrow 👍

@EricTendian
Copy link
Contributor Author

EricTendian commented Mar 21, 2017

Thanks! And yeah, good catch. What I did for converting the README links is to convert the markdown file to HTML using pandoc which automatically URL-encodes spaces, then converted it back to markdown as a separate document. That was done with the following two commands:

pandoc README.md -o README.html pandoc README.html -o README2.md --wrap=none # so that it closely matches original markdown

From there I just copy-pasted the section of links from the pandoc-generated markdown file to the original one, to preserve any special formatting used by gitbook or something else. Perhaps this method can be followed to make those individual pages easier to fix (such as writing a script to do it).

Originally I was going to do this all with regex but found it a lot more complicated/difficult. In case you're curious as to which markdown implementations support spaces in the links: https://johnmacfarlane.net/babelmark2/

@braydie
Copy link
Owner

braydie commented Mar 22, 2017

I ended up using regex to get all the others with some manual intervention - using this expression - \ (?=[^(]*\)) - which will match on spaces in brackets

@braydie
Copy link
Owner

braydie commented Mar 22, 2017

Thanks again for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants