On this page:
Pollen:   the book is a program
6.0.1.11

Pollen: the book is a program

Matthew Butterick <mb@mbtype.com>

 #lang pollen package: pollen

Pollen is a publishing system that helps authors create beautiful and functional web-based books. Pollen includes tools for writing, designing, programming, testing, and publishing.

I used Pollen to create my book Butterick’s Practical Typography. Sure, go take a look. Is it better than the last digital book you encountered? Yes it is. Would you like your book to look like that? If so, keep reading.

At the core of Pollen is an argument:
  • First, that digital books should be the best books we’ve ever had. So far, they’re not even close.

  • Second, that because digital books are software, an author shouldn’t think of a book as merely data. The book is a program.

  • Third, that the way we make digital books better than their predecessors is by exploiting this programmability.

That’s what Pollen is for.

Not that you need to be a programmer to use Pollen. On the contrary, the Pollen language is markup-based, so you can write & edit text naturally. But when you want to automate repetitive tasks, add cross-references, or pull in data from other sources, you can access a full programming language from within the text.

That language is Racket. I chose Racket because while the idea for Pollen had been with me for several years, it simply wasn’t possible to build it with other languages. So if it’s unfamiliar to you, don’t panic. It was unfamiliar to me. Once you see what you can do with Pollen & Racket, you may be persuaded. I was.

Or, if you can find a better digital-publishing tool, use that. But I’m never going back to the way I used to work.

    1 Installation

    2 Quick tour

      2.1 Creating a source file

      2.2 Running a source file

      2.3 Naming, saving, and rendering a source file

      2.4 The project server

      2.5 Intermission

      2.6 Pollen as a preprocessor

      2.7 Markdown mode

      2.8 Markup mode

      2.9 Templates

      2.10 PS for Scribble users

      2.11 The end of the beginning

    3 Backstory

      3.1 Web development and its discontents

      3.2 The better idea: a programming model

      3.3 “Now you have two problems”

      3.4 Rethinking the solution for digital books

      3.5 Enter Racket

      3.6 What is Pollen?

    4 The big picture

      4.1 The book is a program

      4.2 One language, multiple dialects

      4.3 Development environment

      4.4 A special data structure for HTML

      4.5 Pollen command syntax

      4.6 The preprocessor

      4.7 Templated source files

      4.8 Pagetrees

    5 First tutorial

      5.1 Prerequisites

      5.2 The relationship of Racket & Pollen

      5.3 Starting a new file in DrRacket

        5.3.1 Setting the #lang line

        5.3.2 Putting in the text of the poem

        5.3.3 Saving & naming your source file

      5.4 Using the project server

        5.4.1 Starting the project server with raco pollen

        5.4.2 Using the dashboard

        5.4.3 Source files in the dashboard

      5.5 Working with the preprocessor

        5.5.1 Setting up a preprocessor source file

        5.5.2 Creating valid HTML output

        5.5.3 Adding commands

        5.5.4 Racket basics (if you’re not familiar)

        5.5.5 Defining variables with commands

        5.5.6 Inserting values from variables

        5.5.7 Inserting variables within CSS

      5.6 First tutorial complete

    6 Using raco pollen

      6.1 Making sure raco pollen works

      6.2 raco pollen

      6.3 raco pollen help

      6.4 raco pollen start

      6.5 raco pollen render

      6.6 raco pollen clone

    7 File formats

      7.1 Source formats

        7.1.1 Command syntax using ◊

        7.1.2 Any command is valid

        7.1.3 Standard exports

        7.1.4 Custom exports

        7.1.5 The project-require.rkt file

        7.1.6 Preprocessor (.pp extension)

        7.1.7 Markdown (.pmd extension)

        7.1.8 Markup (.pm extension)

        7.1.9 Pagetree (.ptree extension)

      7.2 Utility formats

        7.2.1 Scribble (.scrbl extension)

        7.2.2 Null (.p extension)

    8 ◊ command overview

      8.1 The golden rule

      8.2 The lozenge glyph (◊)

      8.3 The two command modes: text mode & Racket mode

        8.3.1 The command name

          8.3.1.1 Invoking tag functions

          8.3.1.2 Invoking other functions

          8.3.1.3 Inserting the value of a variable

          8.3.1.4 Inserting a comment

        8.3.2 The Racket arguments

        8.3.3 The text argument

      8.4 Further reading

    9 Module reference

      9.1 Cache

      9.2 Decode

        9.2.1 Block

        9.2.2 Typography

      9.3 File

      9.4 Pagetree

        9.4.1 Navigation

        9.4.2 Utilities

      9.5 Render

      9.6 Template

      9.7 Tag

      9.8 Top

      9.9 World

    10 Acknowledgments

    11 License & source code

    Index