Refactor the markdown parsing stuff.