Custom compilation

an
anderswt
Posts: 15
Joined: Thu Oct 06, 2016 9:25 am
Platform: Mac

Mon Mar 13, 2017 1:14 pm Post

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?

cheers
Anders

User avatar
kewms
Posts: 6404
Joined: Fri Feb 02, 2007 5:22 pm
Platform: Mac

Mon Mar 13, 2017 4:15 pm Post

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

Katherine
Scrivener Support Team

User avatar
AmberV
Posts: 24306
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Mon Mar 13, 2017 7:52 pm Post

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

an
anderswt
Posts: 15
Joined: Thu Oct 06, 2016 9:25 am
Platform: Mac

Tue Mar 14, 2017 9:33 am Post

Thanks, Ill have a look.

How stable is the file format?

For the upcoming v3, has the file format changed?

/anders

User avatar
AmberV
Posts: 24306
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Tue Mar 14, 2017 5:39 pm Post

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

an
anderswt
Posts: 15
Joined: Thu Oct 06, 2016 9:25 am
Platform: Mac

Tue Mar 14, 2017 6:07 pm Post

oki, thanks.

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

/anders

User avatar
AmberV
Posts: 24306
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Wed Mar 15, 2017 1:56 am Post

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

an
anderswt
Posts: 15
Joined: Thu Oct 06, 2016 9:25 am
Platform: Mac

Wed Mar 15, 2017 1:59 pm Post

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.

/anders

User avatar
AmberV
Posts: 24306
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Wed Mar 15, 2017 4:25 pm Post

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles