Refactor rewriting URL's for non-markdown files

Fixes #292
Merge pull request #293 from d0ugal/relative-urls

Refactor rewriting URL's for non-markdown files