This article originally appeared in TidBITS on 2013-04-26 at 1:47 p.m.
The permanent URL for this article is: http://tidbits.com/article/13720
Include images: Off

Push-button Book Publishing with Leanpub

by Adam C. Engst

Book publishing used to be a labor-intensive occupation, full of tedium and repetition, but such drudgery could be a thing of the past, thanks to a new system called Leanpub [1], with which we’ve just published our latest title: “Take Control of Dropbox [2].” Leanpub relies on a number of key tools — the Markdown language, Dropbox, LaTeX, CSS, and a Web-based interface — to enable a quick and efficient book publishing workflow.

For my earliest books, I had to FedEx final Word files and screenshots to my publisher on CD-R, along with printouts. Those files were laid out in PageMaker, and we pored over the galleys to eliminate errors introduced in layout. At least it was mostly digital — a friend was just telling us about how his first book was retyped (badly) in Ireland, to be entered into some early publishing system.

But you know what? For a single book, that’s not terrible. Publishers got away with such inefficiencies because labor was cheap and the alternatives didn’t scale well. In fact, despite its whizzy features, Apple’s iBooks Author software comes from such a tradition, lacking, as it does, the change tracking and commenting capabilities that are necessary for any professional author-editor workflow.

When we started the Take Control book series nearly ten years ago, we knew we couldn’t afford to play such labor-intensive games, so our authors have always written directly into their final layouts, using detailed style sheets in programs like Microsoft Word and Pages that provide change tracking and commenting for the editing process. We adopted Dropbox quickly when it came out, since it makes swapping versions of a book between author, editor, and publisher trivially easy. When possible, we even take advantage of time zones so we can eliminate some dead time while different people work on the same manuscript.

However, our Achilles heel has always been production, where we create the final book in the most common ebook formats. A lot of that effort goes into making PDF bookmarks and links. Back when we used Word, we cobbled together a system that relied on a squirrelly detour to Word for Windows to generate links and bookmarks. Although Pages makes PDF links, it does so in a long-broken fashion (doubling the PDF link boxes for each link), and it can’t create bookmarks at all, requiring us to use the Debenu PDF Aerialist [3] plug-in for Adobe Acrobat Pro.

Pages can put out an EPUB that looks decent, but it’s so horribly constructed with regard to CSS styles that fixing its EPUB requires a complex production step and a brittle BBEdit text factory. Worst were Mobipocket versions for the Kindle — until our last book, we had our publishing partner O’Reilly Media create them because they’re so hard to make properly. Happily, thanks to a tip from our friend Serenity Caldwell at Macworld, I figured out how to make our own high-quality Mobipocket for last week’s minor update to “Take Control of Using Mountain Lion [4],” but the process is fussy and complex.

In essence, then, there are two distinct phases of book creation: writing/editing and production. In the first, powerful authoring environments with change tracking and commenting are essential, and drafts need to be moved between author and editor quickly and seamlessly. In the second, the Holy Grail is a push-button system that takes a manuscript and kicks out nicely formatted ebooks in PDF, EPUB, and Mobipocket, complete with clickable links in all formats and bookmarks in the PDF.

I periodically scour the Internet for such systems, and have found several that seemed promising, including Booktype [5], PressBooks [6], and Atavist [7]. But when I looked deeper, I’d run into problems. Phase 1 issues revolved around the use of online editing environments that can’t compete with a real word processor, the replacement of change tracking with after-the-fact comparison, and the lack of commenting on selections of text. Phase 2 troubles were related to the inability or difficulty of styling the output as we wanted in each format — the defaults weren’t terrible, but they weren’t necessarily up to our standards.

Leanpub popped up in one of my searches, and I was intrigued by how they used a variety of existing tools at the surface, rather than building a platform from scratch. The writing and editing in Phase 1 of the publishing process in Leanpub happens in straight text files coded in the Markdown language, with which we’re totally familiar because it’s what we use for TidBITS. (To be precise, Leanpub uses the kramdown [8] superset of Markdown, because the latter isn’t sufficiently rich on its own to represent all the elements necessary in books.) Those files live in Dropbox folders, which we would use anyway, and when you click a button on the Leanpub Web site, it transforms copies of those Markdown files into PDF, EPUB, and Mobipocket ebooks.

Markdown may be easy to write, but with TidBITS, we simulate change tracking using the Subversion version control system and BBEdit’s comparison feature. And we put comments in HTML comment style within the text. Neither of these approaches is ideal for book-length manuscripts. Although there’s a messy way to compare versions of Dropbox-managed text files using the DropboxDiff [9] Chrome extension, comparing files is far clumsier and more confusing than change tracking, and intra-textual comments clutter a manuscript (and deleting them messes up comparisons even more).

That was when I had a brainstorm — we could write Markdown in any word processor, complete with change tracking and commenting, and then export to text for the Leanpub process! And better yet, since we were planning to test this system with Joe Kissell’s “Take Control of Dropbox [10],” Joe and I could use Nisus Writer Pro [11], our favorite writing tool of yesteryear, now back in force. Nisus Writer Pro has full change tracking and commenting capabilities, plus powerful grep-based searching and macros that helped in creating the Markdown. We used character and paragraph styles in Nisus Writer to differentiate various elements of the book visually as well, which made editing easier.

Even with Nisus Writer Pro, writing and editing Markdown in Phase 1 with Leanpub is still clumsier than working in Pages, because links must be constructed manually each time, graphics must be referenced as external files in a special folder, and things like nested lists with internal screenshots require extremely careful attention to Markdown rules. But it all worked, and it was huge fun to run a Nisus Writer macro that exported the text and then click a Preview button on the Leanpub Web site to generate in-progress versions of the book in each format.

When I found them, Leanpub had just moved from serving only self-published authors to working with small publishers like us as well. They call the concept behind the company “Lean Publishing [12],” and the idea is to provide free, lightweight tools that make it sufficiently quick and easy to generate ebooks that authors will make in-progress versions available for readers while they write. (We chose not to do that with “Take Control of Dropbox [13]” because we were feeling our way into the system.) To pay the rent, Leanpub acts as a non-exclusive bookstore for the books their users create, charging an entirely reasonable 50¢ plus 10-percent of the selling price per copy. And yes, you can buy “Take Control of Dropbox” through Leanpub [14] for the same price as on our site, though we’re still learning what the overall user experience will be like. (For instance, we just realized that customers on Leanpub can pay more than the cover price of $10 if they wish; a nice touch!)

Thanks to their new focus on small publishers like Take Control, the Leanpub folks are constantly refining and improving their system, particularly with regard to the Phase 2 production step, and it has been a pleasure to work with them. For instance, we were planning to open their EPUB and insert our own CSS into it for custom formatting, but while we were discussing that with them a few weeks ago, they made our lives easier by enabling us to put our own custom.css file in the manuscript folder and have built into our EPUB automatically. Of course, this benefits everyone who uses Leanpub, but it was still nice to feel acknowledged.

However, although custom CSS improves EPUB and Mobipocket, their system relies on LaTeX for PDF generation, and while the PDF they’re putting out isn’t bad, when push came to shove, we decided it wasn’t something we felt comfortable giving to Take Control readers. In particular, the LinLibertine font was ugly in some versions of Adobe Reader (and Leanpub offers no font family control at all), the font size was too small, and the line length was too long. We also preferred our style of colored boxes behind notes, tips, and sidebars. Alas, Leanpub couldn’t fix all this just for us.

Leanpub does have a solution to the desire for a custom PDF, but it’s not yet ready for prime time, nor are we ready for it. Along with kicking out PDF, EPUB, and Mobipocket (plus HTML, either as a single file or one file per chapter), Leanpub can create InCopy Markup Language files for the book. InCopy Markup Language is a story-specific subset of InDesign Markup Language, an XML-based format that represents an entire InDesign document. The idea is that we could place these InCopy Markup Language files in a laid-out InDesign template, where they’d pick up our pre-defined styles. Changes to the source files could be automatically reflowed in InDesign. We would essentially be using InDesign as an engine for PDF creation. InDesign could also theoretically export EPUB and Mobipocket, though Leanpub’s versions of those — with our custom CSS — is good enough already. Unfortunately, Leanpub’s export isn’t creating usable files right now, and even if it were, we haven’t yet designed an InDesign template file into which we can flow them.

So for “Take Control of Dropbox [15],” we decided to fall back on our traditional process for PDF. A quickly generated Nisus Writer macro stripped the Markdown formatting from our manuscript and made sure that everything was assigned style names. Then we opened Nisus Writer’s native RTF file in Microsoft Word, saved in Word format, and imported it into Pages, where our Take Control styles took over. (Other approaches, such as opening the RTF directly in Pages and exporting .docx format from Nisus Writer, didn’t work properly.) Tonya put the internal and external links back in manually, and placed and resized the graphics, adding several tedious hours to our normal production process. Extra work this time but it worked fine in the end.

We took the opportunity to play with the interior design a bit too, since the other new part of “Take Control of Dropbox [16]” is its use of our new cover design, created by Sam Schick of Neversink [17], using a logo designed by Geoff Allen of FUN is OK [18]. (The cover colors will vary from title to title.) The new logo and cover are the first steps in a major visual redesign for Take Control. We made some small changes in the book interiors to match the cover color and address some things that we’d been wanting to try for a while — notably, we’ve hidden most external URLs, since they’re long and ugly in running text, differentiating them in the PDF from internal navigation links by a light underline. Once we’re certain of the tools we’ll be using — Pages or InDesign or something else — we’ll look harder at the interior design. (The final part of the process is a new Web site design, and while the look is done, a lot of ExpressionEngine code needs to be updated and modified, and that’s taking a while.)

We are planning to work our way into Leanpub slowly, since authors and editors have varying amounts of experience with Markdown and Nisus Writer Pro, so we won’t be using them for every forthcoming book. But Leanpub is the most interesting development we’ve found in the book publishing world in a long time, and we’re looking forward to the time when the production phase of the publishing process truly does come down to the click of a button.

[1]: https://leanpub.com/
[2]: http://www.takecontrolbooks.com/dropbox?pt=TB1172
[3]: http://www.debenu.com/products/desktop/debenu-pdf-aerialist/
[4]: http://www.takecontrolbooks.com/mountain-lion-using?pt=TB1172
[5]: http://www.sourcefabric.org/en/booktype/
[6]: http://pressbooks.com/
[7]: https://www.atavist.com/howitworks/
[8]: http://kramdown.rubyforge.org/
[9]: https://chrome.google.com/webstore/detail/dropboxdiff/aefdkgcdokdiaoppobphjogcilaaakka?hl=en-US
[10]: http://www.takecontrolbooks.com/dropbox?pt=TB1172
[11]: http://nisus.com/pro/
[12]: https://leanpub.com/lean
[13]: http://www.takecontrolbooks.com/dropbox?pt=TB1172
[14]: https://leanpub.com/tco-dropbox
[15]: http://www.takecontrolbooks.com/dropbox?pt=TB1172
[16]: http://www.takecontrolbooks.com/dropbox?pt=TB1172
[17]: http://neversinkcreative.com/
[18]: http://www.funisok.com/