Add handling for bibliographic lists at the end of a document

This processes the last element in the document and, if it finds that it is a list, it treats it as a bibliography.