310b8974a739e593a2cb8562c052e9dedce81113
Pagination / README.md
Pagination with raw CSS and Functional Javascript
=================================================

This script produces a pdf-like paged document from basic HTML. For the prototype I decided to use the last draft of my ill-fated Masters thesis on the history of self-esteem. Some readers may find this content as or more interesting than the code itself. Special thanks to Timothy Verhoeven and Michael Hau for the feedback that helped shape this draft. To read it and/or see my code in action, download it from the "example" directory and open it with an up-to-date version of Firefox, Chromium or Chrome.

Note: it is not written to work on Internet Explorer due to the browser's prehistoric Javascript support. It may however work with other browsers. Although the script was specifically written to work with Firefox, slightly older versions of Firefox have a display problem: you cannot zoom in or out without modifying and sometimes hiding the text. If you wish to zoom, hit F5 afterwards to re-render the pages. Also, for anyone wishing to cite the content, the page numbers cannot be relied on for consistency. Finally, it was not designed for proper smartphone display, but relies on smartphone browsers behaving like desktop ones.

The CSS standard has long covered the display of HTML on discrete pages like a book, but implementation of this feature has been lacking. The [PagedJS](https://www.pagedjs.org/) project has created a Javascript library to fill this gap. I studied this project in order to understand how the implementation works. I then developed a very different implementation from the perspective of functional programming. In doing so I adhered very closely to the wisdom of Luis Atencio's [Functional Programming in Javascript](https://www.manning.com/books/functional-programming-in-javascript), the book that sold me on the functional paradigm. This book and the PagedJS project are thus the two influences reflected in this code and warmly acknowledged.

The code mainly focuses on dividing the content across pages intelligently. I have taken great pains to prevent single lines, including headings, appearing in isolation at the tops and bottoms of pages. To my judgment, I have succeeded in making my history writing look almost as nice as the concise and declarative compositions and recursion-based machinery behind it.
1
2
3
4
5
6
7
8
9
10
11