Substantial rewrite

Now outputs markdown document, then generates html from this.
Html output much cleaner.
Significant work still required.