zacharyvoase / markdoc

A lightweight Markdown-based wiki system. Current status: abandoned.
http://markdoc.org/
The Unlicense
347 stars 74 forks source link

Error when accessing rendered files with file://... #12

Closed ghost closed 12 years ago

ghost commented 12 years ago

I would like to be able to build a set of linked html files locally readable without a server. I can individually open the pages as

file://~/html/index.html  

but any links do not work as they are missing the .html extension. I know servers will add the extension as required (and the index.html if address ends in "/"). Would it be possible to add an option to include the extension on build?

ghost commented 12 years ago

Hmmm, on further reflection this is probably more of a markdown issue than a markdoc issue, right?

ghost commented 12 years ago

Well, after much trial and error I now have a script to do postprocessing to get what I want. So I guess I'll close this.

janbaer commented 12 years ago

Hello NevarMaor! I have the same problem with the generated links on my webserver. Could you post your solution in this issue please? Thanks!

ghost commented 12 years ago

On 05/05/2012 12:51 PM, Jan Baer wrote:

Hello NevarMaor! I have the same problem with the generated links on my webserver. Could you post your solution in this issue please? Thanks!


Reply to this email directly or view it on GitHub: https://github.com/zacharyvoase/markdoc/issues/12#issuecomment-5528552 Hi Jan, the issue I had was with using the rendered files without a webserver. If you are running a webserver it shouldn't be an issue.

Anyway, I am certainly no bash whiz but here is the script I use. It uses sed to add ".html" to all local links (and also adds "index.html" if the link ends in a "/", which is how I distinguish subdirectory home pages). You would likely have to modify this for your application.

Also, I use a separate directory ".file" for the modified version to keep it separate from the ".html" directory. And this setup is entirely for my own personal use, no public access.

 #!/bin/bash

 rm - r .file
 cp -r .html .file
 cd .file

 find . -type f | xargs sed -i \
 -e 's/\(<a href="[^(http:\/\/)].*\/\)\(">\)/\1index.html\2/g' \
 -e 's/\(<a href="[^(http:\/\/)].*[^(\.html)]\)\(">\)/\1.html\2/g'