Separate source tokens and document creation.
Refactor to infer format from file extension.
Merge branch 'feature/output' into develop