Further formatter refactoring

This is some further changes I had in mind based on my work on the fivemat formatter.

/cc @JonRowe