Thanks for this, it’s a good hook for starting. I’ll try to keep a link to this.
The output I need is all specialized XML that the Pragmatic Programmers use to generate all their books. Once one’s book is marked up, they run it though various tools that apply the styles they want to get the various forms, paper, ePub and so on.
I’ll compare this to Leanpub format at some points as I go along.
Both Leanpub and Prag want a top level control file, called Book or something, that lists the files to be included. These are supposed to be chapters. Leanpub just lists the file names, and Prag has some kind of XMLish “include” statement, but same idea.
In each, there are markers for parts, chapters, sectiions. Nominally one writes a bunch of chapter files, each wrapped in suitable XML and the system assembles them and voila! you have a book. Prag also supports some Markdown syntax that you can invoke by a suitable XML thingie that says “Markdown inside here”.
Leanpub basically understands Markdown directly. It is much less capable than Prag.
So I hacked Leanpub by putting just one file name in the Book file, and compiling the whole book, with all its headers and such, into that one file. So the one file has all my chapters, all my images, all in one go. Leanpub’s accepting markdown and the book file index lets me pretty much do everything with compile.
I am not sure whether I can coerce Prag into accepting one big file. One issue is that one’s development editor would like to look at and edit the files one at a time. So I really need to split out the chapters, and ideally, I’d like to generate the Book file from Scrivener’s structure. One possibility is to get close enough and then just cut over to a text editor. There is some OK support for Prag’s language and I won’t need much anyway as the book is mostly words.
So one possibility is to embed enough info in the compiled file to split it up with Ruby. That would be nearly good for output and I could manually import edits back. I really don’t want to do a bunch of programming – it would be a distraction from what I’m supposed to be doing, namely writing.
The other thing I had been thinking was to use export to break out all the files. Each of these would have enough XML in it to do the job. But … one of the things I sometimes do with Scrivener is work below the chapter level, with a card for each paragraph or couple of paragraphs. So …
the Book file would have to say, not just
chapter1.txt
chapter2.txt
chapter3.txt
but …
chapter1.txt
chapter2.txt
subchapter21.txt
subchapter22.txt
chapter3.txt
in order to pick up all the little bits. That would be a pain. So what would be neat would be if you could tell the Export to export level 1 and 2, but to include all level3 files inside the owning level 2. But this is not to be.
So the one way you have to break the big compiled file apart on some markers. Doable, but a digression. The other way you have to roll it back up, or deal with way too much manual creation of book file. Also doable, also a digression.
I suppose I could recruit a tame Ruby programmer so that I could keep my head down on the work.
Anyway, your hook info for post processing this will be useful should I go that way, and makes me think that postprocessing compile is better than preprocessing an export.
Thanks, you’re a star!