Pre-compute chapter/page information.

We need to know cross-chapter information for proper page
navigation, so run through the directories first to build
a map of chapters and pages, then generate the output. This
allows us to always know the "next" page, even at the end of
a chapter.