refactor formatter to provide format() method and strip comments when format=compressed