
Pollen: the book is a program - Tomte
http://mbutterick.github.io/pollen/doc/
======
mbutterick
Hi, this is Matthew Butterick. If you have specific questions about Pollen's
capabilities (e.g., "how hard would it be to ...") I encourage you to post
them to the GitHub repo at
[http://github.com/mbutterick/pollen](http://github.com/mbutterick/pollen).
I'd love to make it more useful for other authors, especially those in
technical fields, so I welcome all suggestions.

TeX has been mentioned several times — I don't mind that comparison at all,
since my thinly-veiled ambition is to create a contemporary successor to TeX.
Contemporary = optimized for web publishing + better "macro" language (Racket)
+ shallower learning curve.

That said, TeX got a lot of things right. Especially the basic notion that a
book (or other publication) should be represented as a program, and that
authors should be able to freely intermix text and code. With digital books, I
think it's essential.

(PS on Racket: HN was built with Arc, which was also built with Racket.)

~~~
HNJohnC
The bit in the book / manual about typing a "lozenge" character that shows how
with an Apple then has two blank lines for windows and linux is a little
disconcerting.

~~~
dragonwriter
As with any unusual character in Windows, you seem to be pretty much stuck
with "build and install a new keyboard layout" as the general solution, though
there may be editor-specific alternatives.

------
capnrefsmmat
I've been looking at this recently. It looks like an extension of what made
TeX so successful: your typesetter is programmable -- and macros can live in
your documents, defined at any time -- so any common tedious task can be
automated.

Sure, Markdown and the rest have a simple syntax for everything, but what if
you're writing a book and want cross-references? Or you commonly use side-by-
side examples (good grammar vs. bad grammar, say) and want a macro that
generates the appropriate table layout. Or you want some macros which typeset
entries in your CV. And instead of crufty TeX macros you can use Racket.

If I weren't already writing a book in LaTeX I'd try writing one in Pollen.

~~~
jostylr
I've been contemplating using my literate programming project
[https://github.com/jostylr/literate-
programming](https://github.com/jostylr/literate-programming) to write a book.
It would allow one to do all sorts of things in terms of reordering text,
doing macros, calling out to stuff, etc. as well as having multiple compile-to
targets.

It would also allow one to write why one is writing what one is writing
without actually putting it in the book. Kind of like writing a "behind-the-
scenes" while writing the book.

------
Blahah
Beautiful, and I'll use it for my first book.

But I have to call out the claim:

 _> I think Pollen just won the Hello World Tournament._

That tournament was won permanently by the M4 language in 1977.
[http://en.wikipedia.org/wiki/List_of_Hello_world_program_exa...](http://en.wikipedia.org/wiki/List_of_Hello_world_program_examples#M)

~~~
ColinDabritz
I was considering an esoteric (joke) language that would compile a blank file
to print "Hello, world!", q to a quine, g to guess, and similar. I never got
around to creating it though.

~~~
breadbox
HQ9+ already fills that niche well enough.

~~~
ColinDabritz
Ah, yep, nailed it.

------
Vaskivo
Awesome!

I love Butterick’s Practical Typography. It taught me a lot about typography,
and started my love for typefaces.

The fact that Matthew Butterick is, a lawyer, a typographer and a programmer
just increase my respect for him.

Thank you for your work!

------
habosa
"The ◊ character is called a lozenge. In Pollen, the lozenge is a special
character that marks anything Pollen should interpret as a command (rather
than plain text).

How to type a lozenge: Mac: option + shift + V Windows: holding down alt, type
9674 on the num pad Ubuntu: ctrl + shift + U, then 25CA"

That's an unfortunate choice, imo. Pollen looks great but I wouldn't want to
have to type that character all the time.

Sorry to nitpick, I think everything else I've seen (so far) is very
encouraging. Looks like something halfway between Markdown and LaTeX.

~~~
evincarofautumn
If our languages never stray outside of ASCII, then our input methods will
never improve. The Emacs version is not much better:

C-x 8 RET loz[enge]

or

C-x 8 RET 25CA

Which suck, but can at least be rebound to a useful key. Unfortunately, the
\lozenge command in TeX mode produces U+2727 “white four pointed star”. Sigh.

------
ivan_ah
This looks very interesting. Books really are code: I now have 10+ conditional
flags in my book: ifPG13, ifPRINT, ifEBOOK, ifEREADER, etc. I'm looking to add
more, but the basic \ifthenelse macro in LaTeX won't be enough...

How hard would it be to implement things like \ref and \pageref and support
more of the LaTeX environments supported by MathJax?

I think a triple output format HTML + ePub + LaTeX|PDF|print would be awesome
--- I'd switch right away!

Thanks for releasing this as LGPL.

~~~
grayclhn
>I now have 10+ conditional flags in my book: ifPG13, ifPRINT, ifEBOOK,
ifEREADER, etc. I'm looking to add more, but the basic \ifthenelse macro in
LaTeX won't be enough...

Makefiles can be your friend... in the file `Makefile` put

    
    
        .PHONY: all pg13 print ebook ereader
        all: pg13 print ebook ereader
        pg13: book-pg13.pdf
        book-pg13.pdf: mainfile.tex
    	pdflatex "\setstuffforethisversion\input{mainfile}"
        print: book-print.pdf
        [etc...]
    

Then type `make print` or `make ebook` etc at the command line. (This version
is almost certainly too simplistic, but I hope the point is clear.)

~~~
ivan_ah
Hm... reading-in the src from the command looks a little brittle, but it's a
must try. The makefile will also help with the need to compile 3 times with
latex.

~~~
grayclhn
It's definitely brittle, but it's brittle along a dimension that usually
doesn't change much over the course of the project (paper, book, etc). If you
have automatically generated images or tables the benefits can be huge.

`latexmk` solves the "compile many times" problem, and can monitor for changes
to the source file in the background.

------
a-nikolaev
Interesting software. Actually, I wish there was a way to use some other
character (or string) instead of the lozenge character (◊) for commands.

I mean, I see the reason for using a weird symbol, but I'm not even sure how
to enter it from the keyboard other than by copy-pasting it. Is it some sort
of standard symbol in DrRacket environment?

Maybe, a directive for changing this symbol can be added: #commands_start_with
my-char

~~~
auxbuss
Apparently you can do this via setting Pollen’s 'world:command-marker' value;
though I don't know how to do that myself :-/

Ref for others, on OSX, its: option + shift + V

See
[http://mbutterick.github.io/pollen/doc/reader.html](http://mbutterick.github.io/pollen/doc/reader.html)

edit: key commands now fixed for other platforms

------
arnarbi
This looks great! I like the documentation itself even more, is that generated
with pollen as well?

Edit: I answered my own question, the documentation is generated using
Scribble: [http://docs.racket-lang.org/scribble/](http://docs.racket-
lang.org/scribble/)

------
spot
[http://www.cs.cmu.edu/~spot/markup/markup.html](http://www.cs.cmu.edu/~spot/markup/markup.html)

also used scheme for writing books, provided for embedding code execution, tex
for math, targeting html and paper, etc. i made it in 1996 to write my phd
dissertation, based on markup by jar@mit.

------
dfc
I have been looking forward to trying this out ever since I heard about pollen
in one of MB's talks on typography. Unfortunately it requires racket 6.0 and
Debian only has 5.3.6 in unstable and nothing in experimental.

According to the "package 6.0" bugreport it looks like things are not going to
change very soon:

    
    
      As far as I understand, the build system and general organization of
      racket has been changed quite a lot for 6.0. I'm not sure how soon I'll
      find time and motivation to work on this, especially since I'm committed
      to using 5.3.6 at $WORK through the end of April.
    

I cant remember the last time I saw a self extracting shell archive
installation and/or a shar without a gpg signature.

~~~
soegaard
You can install Racket 6 directly from the Racket web-page:
[http://download.racket-lang.org/](http://download.racket-lang.org/)

You can see the SHA1 hashes of the distribution here:
[http://www.cs.utah.edu/plt/snapshots/](http://www.cs.utah.edu/plt/snapshots/)

------
dangoor
This looks cool and I'll take some time to read the docs in depth.

I wonder when Atwood's Law will kick in and we'll see more ambitious
JavaScript-based tools like this (maybe with sweet.js macros to provide higher
level constructs). JS already turns a document format into a program, but
plain HTML+JS is not the best authoring format.

------
jestinjoy1
Can I export it to PDF like in TeX?

------
grayclhn
Just saw this too:
[https://github.com/mbutterick/hyphenate](https://github.com/mbutterick/hyphenate)
"Racket implementation of the Knuth–Liang hyphenation algorithm."

------
jostylr
I am a bit flummoxed about the lozenge character being used to signify markup.
Is it convenient to input by keyboard? Seems like that would be necessary.

------
mjf2
Does it have mathematical typesetting like Tex?

~~~
mbutterick
You can use MathJax inside Pollen today. As far as building more integrated
support for math typesetting, I'd like to do that, but what I'm not sure about
yet are the ergonomics. Ideally, you'd just be able to drop TeX-style math
expressions into the markup, indicating whether they're inline or block, and
Pollen would do the right thing in terms of handling the rendering (based on
whether the output is a web page vs. something else).

~~~
Tomte
How do you think about MathJax vs. pre-rendering formulae to images and using
those, with the TeX input as the alt attribute? Oh, and using STIX or whatever
as web font.

~~~
soegaard
There is already a couple of packages for Racket that prerenders formulas in
TeX into various graphic formats (they call LaTeX to the rendering). It is
straightforward to use these from Pollen.

~~~
Tomte
I know that it's straightforward, I'd like to hear about pros and cons I
haven't found myself.

~~~
soegaard
If you want an html-page that works offline, then MathJax is rather large. In
that case it makes sense to generate pdfs or svgs containing the formulas.
Otherwise using MathJax from a CDN is quite convenient. On mobile rendering a
page with many formulas via MathJax is somewhat slow though.

------
thrush
[How] Can we add keyboard navigation?

------
ctdavies
Wonderful!

------
toolslive
there's also literate haskell.
[http://www.haskell.org/haskellwiki/Literate_programming#Hask...](http://www.haskell.org/haskellwiki/Literate_programming#Haskell_and_literate_programming)

