Custom compilation

Hi, Im looking for the possibility to develop a custom compile appl/application/plugin that generates a website. So I need to traverse the binder and look at each document to generate web oriented material.
I need access to documents status, keywords, formatting, etc.

Is there a standard way to do this? Or maybe even better a code library?


The standard way to do this is through the Scrivener Compile command. Scrivener does not support plugins.


If you’re a developer, you might also take a peek at the Scrivener format itself. It’s a package format using standard formats and human-friendly XML for almost everything. Once you right-click on the project file and navigate into it, you’ll find everything you need. The .scrivx file is the master outline, and a roadmap for finding all of the data throughout the rest of the project.

A practical example is TeXDown, posted to these very forums, and I think it is even open source so you might find some inspiration on where to go from it. Another example is Marked, a Markdown previewing tool which is capable of loading .scriv projects and running a simple “compile” to produce a single preview for Markdown authors.

Thanks, Ill have a look.

How stable is the file format?

For the upcoming v3, has the file format changed?


The format will change a bit, mainly in the the internal addressing. Files will be UUIDs instead of serial numbers (you’ll note UUIDs are already there for iOS sync, but they aren’t used internally yet), so you’ll need to update an attribute look-up or two, and slightly adjust the actual file access itself. The core structure of the .scrivx will be very similar however, and you shouldn’t find too many changes necessary for things like keyword cross-referencing.

oki, thanks.

What about the new stylesheets support? Does it intervene with the RTF format for each document (file)?


I don’t know what is meant by intervention in this sense, but it will be an additive change to the RTF, not fundamental, and degradable in the sense that a lack of style parsing will not cause formatting loss.

Just few more technical questions.

Which RTF version is used?

So stylesheets are stored outside the RTF file? And the the styling of the text too? Or is that embedded in the RTF?

The reason I ask is that I wonder about the need created a custom made RTF reader.


Scrivener uses the macOS RTF engine, so most of the specifics of how it works will be available through their documentation, and you’d be able to use their libraries for working with them. The command-line utility textutil may also be of some service here.

I can’t really go too deep into the specifics of the stylesheet implementation as that hasn’t been released yet. What I meant by my comment though is that in RTF it is traditional for stylesheets to be on top of the formatting the stylesheet implements, as a layer of redundancy for parsers that don’t support styles. So you wouldn’t need to implement style parsing to read formatted text using the stock engine.

Overall for maximum support, depending upon how many special non-RTF features you use in Scrivener (like linked images instead of embedded), you should be able to get away with a stock parser. The additions Scrivener adds are not to the RTF spec itself, but rather conventions in the text—for example an inline annotation is a text token, fully visible in the parsed output—it’s up to the parser if it wishes to do anything fancy with it other than display it as raw code.