Refactor HTML processing of Markdown to model, rather than view