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