Support macros

This adds three directives:

- `@macro (name)`: Starts recording a macro identified by 'name'
- `@endmacro`: Stops recording a macro
- `@do (name, kwargs)`: "Execute" the macro identified by 'name' by replacing the
  directive by the recorded macro contents, using kwargs to format the lines
Feels haphazard having to store a constant for `ENDMACRO` and treat it specially. Is that because `@endmacro` needs to be evaluated before all the code below? It would be better to merge this with the `if line.startswith(DIRECTIVE_PREFIX)` block or move parts of that directive check up if possible so the code doesn't diverge too much.