MAJOR: enable the use of custom metadata and page sorting

This version is based on the current master, all commits squashed. It enables the use of metadata to set a custom pagenumber and (menu)title. metadata can optionally be surrounded by a comment tag to make them invisible on the page.