A whole novel in English

Most examples on this site are one page long, which says nothing about what happens at page sixty. Here the whole of Lewis Carroll's Alice's Adventures in Wonderland, published in 1865, goes in exactly as the plain text file holds it and comes out as one PDF: a title page, a contents, twelve chapters, sixty-two numbered pages. The program is told one thing and one thing only about that text — that a line reading CHAPTER I opens a chapter — and every heading, every running head and every page number follows from it.

Nobody counted a page or measured a line to make this. Where each line ends, where each page ends, how a justified line is spaced: all of it is worked out while the book is being written out, which is the only way sixty-two pages can be produced without somebody reading all sixty-two. The contents is the tricky part, because it has to be in place before the chapters can start after it, and can only be filled in once they have landed — and every line of it is a link straight to its chapter. The novel is in the public domain: its copyright has expired and it has no condition on its use.

What this example shows

  • A whole book handed over as plain text, with no layout instructions.
  • Twelve chapters found in the text itself, each opening its own page.
  • Sixty-two numbered pages behind a contents that clicks through.

The source code, complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The document itself

Open the document

Examples near this one

Breaking an overlong word

A word longer than the column that holds it: the library leaves it whole, or cuts it at the column's edge.

Break points after a slash or a hyphen

A justified column set twice: file paths and compounds running past the edge with no break points, then wrapping where a break after a slash or a hyphen is allowed.

A font behind the font

One line of statuses set twice: in a company font alone, where the characters it has no glyph for come out as empty boxes, then with a second font behind it that draws them.

Every example, by subject