jbt / docker

Documentation generator
http://jbt.github.com/docker
MIT License
233 stars 56 forks source link

Support links to other files #59

Closed alinex closed 8 years ago

alinex commented 10 years ago

Links in markdown can go to other files. To make it work in docker i have to link to other file.md.html but for GitHub I have to use otherfile.md

It would be nice if we may link to the file (works in GitHub) and docker will add the .html automatically while saving the document.

alinex commented 10 years ago

To solve this you may add the .html extension to all local links before any anchor. I don't know the best place to put this, one may be:

showdown.js: insert at line 554:
url = url.replace(/^((?![#\/]|\w+:\/\/)[^?#]*?)(.*)/, "$1.html$2");

Or is it better to not touch showdown.js and make the replacement after each call with:

html = html.replace(/(href="(?![#\/]|\w+:\/\/)[^?#]*?)(.*?")/g, "$1.html$2");
jbt commented 10 years ago

Sorry for not getting back to this: I do like the idea of auto-linking like this. I'm tempted to avoid touching showdown if possible because I'd ideally like to switch to using marked at some point in the future. (This should really help with #65 too I think as marked has its own built-in callback for code blocks).