Don't replace links with the a tags - these break [img] tags.
Write out the JSON as well. Useful for debugging, someone might like it.