CoreFiling/reviki — pull request #25 by Barrucadu (2014-07-29 12:03:09+00:00)
Title: Renderer directives

(this depends on pull request #21)

This pull request adds markup solely for the internal use of the renderer, to control what the output looks like. Directives themselves are not rendered. Macro syntax was extended, with `<<+directive name:directive args>>` to enable a directive and `<<-directive name>>` to disable a directive. Directives may have multiple arguments, separated by commas.

Example, two tables with a short cell, and a vertically much bigger cell. In the first, the short cell is aligned to the top, and in the second, it has the default (middle) alignment:

<<+table-alignment: top>>

|short table cell|Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur elementum enim turpis, non posuere nulla porttitor eu. Curabitur eu ornare orci, a aliquam lacus. Curabitur suscipit arcu quis lobortis lacinia. Ut sed felis vel tellus auctor sodales. Aenean magna massa, venenatis non pretium ut, condimentum vitae dolor. Sed et magna non est gravida fringilla at non justo. Mauris vel nunc leo. Integer euismod ultricies felis non interdum. Nulla tempor a enim eu fringilla.|

<<-table-alignment>>

|short table cell|Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur elementum enim turpis, non posuere nulla porttitor eu. Curabitur eu ornare orci, a aliquam lacus. Curabitur suscipit arcu quis lobortis lacinia. Ut sed felis vel tellus auctor sodales. Aenean magna massa, venenatis non pretium ut, condimentum vitae dolor. Sed et magna non est gravida fringilla at non justo. Mauris vel nunc leo. Integer euismod ultricies felis non interdum. Nulla tempor a enim eu fringilla.|

Directives can only appear in block positions, as I didn't want to have to implement scoping, and I thought it probably unnecessary. Directives do not have to immediately precede the thing they effect, the enable/disable tokens act as toggles. If a directive is enabled multiple times (without being disabled in between) with differing arguments, the most recent arguments take effect.

Caveats: passing around a mutable map of currently enabled directives is very messy and horrible. If starting from scratch, this would not be how I would implement it. However, I decided to keep to the current API, with the intent of refactoring things when I move on to adding support for multiple output formats.

This goes part way towards fixing REVIKI-341.