Leanpub (again)

The book I was working on earlier, when I was asking about Leanpub, went to Pragmatic Programmers instead, so I had to move over to their system. The good news is that it got done and looks good.

Now I’m working on another and again targeting Leanpub. Salient points are that Leanpub has two “manifest” files, Sample.txt and Book.txt, which list the file names (chapters, whatever) to be included in the sample book and the full book. It expects to find those files in some standard folder.

The files themselves are expected to be in Markdown form.

The question is how to use Scrivener with this as the target.

One Big File

One way is simply to compile the whole book (or the sample, using selection) and let Leanpub generate from that. I think that will work. However, it kind of breaks the Leanpub model, which is built around multiple chapter files. Maybe this is OK.

I’ve got compile working well enough to convince myself that I can write in Scrivener, probably using some Markdown syntax like italic and such, and then generate a book that Leanpub might recognize. I’d have to test that: I could imagine that they have some magic going on between files that wouldn’t be there for one big file, but from my reading I think it’ll work. But it’s one big file, and that’s a bit naff.

Lots of Little Files

Ideally, there’d be a way to tell Compile to be like Export, and produce a file structure containing each chapter, all markdownified like the compiler does. I guess there is no such thing, though I’d like to be wrong.

And Export will export raw text, but then I’d have to write in pure Markdown, not using Scrivener to insert any titles and such, which it now does but I could live without. However, Scrivener also assembles all my sub-documents (sections, whatever) into a single document, and I think I’d lose that with export, instead getting lots and lots of tiny files.

Advise Me

So … am I missing some facility that might serve this need? Or have you some advice on which way you’d go, and how you might go? If so, I’d love to hear.

Meanwhile, I’m searching the web for Leanpub-Scrivener users, and keeping a separate section in the book about how I did it …

Thanks!

Since you are using a Markdown based output it would be easy to split the file into multiple pieces using a script that looks for “# ” at the start of a line, or at whatever Markdown header depth you need to split by (or even more basic than that, define a file separator string in Separators and use your script to hunt for that). “One big file” isn’t really a problem when it is plain-text, it’s just a matter of whether Leanpub can handle it gracefully. Plain-text is an extremely efficient format to pack the data of a book into. This is really more of a problem with hugely complicated and over-engineered formats like .docx being “rendered” in real-time by a desktop publishing style program like Word.

But yes, there is no such compile option from within Scrivener. We might have a file splitter option in the future, but I believe that’s off the board for the next major update anyway. Oh and if you don’t know any scripting languages, you can always just use Scrivener to split a file up by separators, using the File/Import/Import and Split command using your custom separator, into a blank project, then just select everything and then use the Export command. A bit of a chore, but presumably you’re only going to need a Leanpub-ready output a few times.

Hi Amber …

Thanks for confirming what I thought. Yes, I can split the file if it comes to that, or just go the one big file route.

I think that for this book, Scrivener’s other features will outweigh this one inconvenience.

It does seem that the existence of Leanpub would call for some kind of splitter in Compile, but it seems to me that Scrivener isn’t exactly what you’d call market-driven. I admire that. :slight_smile:

Thanks,

R

The thing about dividing your book into into different markdown files for each chapter is that Leanpub automatically generates different headers and start-of-chapter typography based on these files. It’s the same if you have a preface: the pagination is in lower case Roman numerals. You don’t have to mess with any of that. And the TOC is generated from those files.

If you had one big file for the book, it would be laid out as one big chapter. Even if you have twenty chapters, it seems worth it to split the files up manually, name each file and then put the order of the chapters in the book.txt file. Leanpub will do the rest. I think they run the markdown through LaTeX somewhere along the line.

Thanks, good tip. I’ll experiment, for sure, and sort something out.

Thanks again,

R