first crack - seems to work correctly
NOTE: uses kluge to output indentation with tabs