Add counters and figure, table and example captions

- add a counter facility
- use counter to create synthetic captions for block images, tables and example blocks
- support creating, incrementing and reading counters from attributes
- tests and TomDoc
- optimize the checks for block title in the HTML5 templates