Cleanup templates, reoptimize macro subs, fixes & tests

Particularly important in this pull request is a fix to prevent Asciidoctor from crashing on bad table markup. The additional tests help with peace of mind :)

- use function for inserting title div in html5 templates
- use string interpolation instead of concat in template functions
- clean up macro substitution optimizations
- fix link macro embedded in footnote
- allow entities to be escaped
- fix invalid attribute parsing if value is quoted value is empty
- don't override caption if set to empty string
- fix invalid reference to regex constant
- add idseparator to customize separator used to generate section ids
- recover if separator is missing from first cell of psv table
- add support for 'd' cell style (for default, or normal)
- add tests for forward and backward xref references