I know that L&L is a small software outfit and doesn’t have nearly the resources necessary to support every user request. However, I wonder if it would be possible to create a simple export plugin SDK that would allow us with the ability to write exporters to our favorite programs.
For instance, I write lots of technical documentation in Scrivener, and I would like to export it to a specific format. What I would like to do is take the content of my Scrivenings and apply them to a Word template so that my output matches my company’s specification format. This would be a fairly simple thing, and I could do it outside of Scrivener, but it would be so much nicer to have it within Scrivener itself.
I can only hope that Scrivener’s internal workings are modular enough to allow for something like this.
The only trouble with this - and it’s a good idea - is that I’m not sure how I would do it. The issues involved are as follows, in case you have any ideas about how they might be resolved:
Scrivener being a Cocoa app, its text is natively stored as an NSAttributedString object. If you wanted the text in its rawest form, there would need to be some way of me passing you this object, and I’m not quite sure how that can be done.
Scrivener 2.0’s Compile Draft interface is contextual, meaning it shows only the controls you need for a specific format. It wouldn’t be possible to provide a contextual interface for formats it knows nothing about, though.
On the other hand, if you wanted to receive the text in one of the given formats, that would be easier than trying to hand you the NSAttributedString directly.
Another possibility might be for Scrivener to be able to export to a custom, documented XML format, that included all elements of the document, something like:
<ScrivenerDocument>
<!-- Font and format information go at the top →
<Text ParagraphStyle=“3” PageBreakBefore="YES">Blah blah</Text>
...
</ScrivenerDocument>
You could then take the XML and do anything you wanted with it. Although the trouble is that it would be difficult to include lists and tables.
Hmm, getting the NSAttributedString would definitely be the best option. I’ll have to look into how SDKs work and how developers can provide them.
It’s probably a lot of work so would probably have to wait for after 2.0 given the amount of work left to do there, but it’s definitely a good idea that I would be interested in looking into more.
This is a fantastic idea. Even just being able to make small manipulations to the NSAttributedString, like running a regex/grep command on the text, would go a long way.
The XML output idea would be great! I was thinking of something in process, such as a shared library that would be loaded by Scrivener, but having an easy to parse format would be great.
Truth be told, I thought I might be able to use the MultiMarkdown for this, but I balk at having to integrate with Perl
An easy to use output format for post-processing would be ideal. I could simply write scripts to integrate it. Considering that docx is already an XML format, it wouldn’t be too hard. (I did something like this already integrating reStructuredText into docx and it worked smartly).
Another easy thing would be to document the existing file formats, if they aren’t too arcane. It should (and I say should with trepidation) be easy enough to parse those files and do the processing ourselves. I’ll see what I can see in the files just looking at them.
The existing file formats are all third-party formats - RTF, DOC etc - if you mean the export formats. If you mean the formats within .scriv itself, I’m in the middle of converting everything to XML for 2.0. The 2.0 .scriv file will use XML with RTF (instead of RTFD) for the text files. So it would be possible to parse a 2.0 .scriv file, so long as you have a good RTF reader, and do what you like with it too (I’m documenting the file format as I go and will publish it sometime after 2.0 is released).