Minor refactor to allow for JSON export task.
Support for JSON export.

TODO: move this to the html export plugin.