Refactored heading handling and added parameterized support for labels in PDF bookmarks

Refactored away some of the duplicate code for heading processing (in "process-headings" mode template). Also added parameterized support for adding labels to the `data-pdf-bookmark` attribute, via `$autogenerate.pdf.bookmark.labels`