Refactor URL rewriting

Use a Markdown extension to hook into the build process and modify the
HTML document tree rather than using regular expressions to process
the HTML.

Fixes #240
Move the markdown extension
Add a test case specific to #240
Add a docstring to explain the relative path Markdown extension
Correct a variable name in the tests
Merge pull request #250 from d0ugal/script

Refactor URL rewriting