BooneJS tweeted me a script yesterday that takes my original “scrivwatch” script and makes it handle full Scrivener documents. It scrapes the XML file to get the order of RTF files in the document, then used the original method to convert and concatenate all of it into a plain text file. If you write in Scrivener using Markdown, you get a file that Marked can preview as a rendered document with any theme. It uses the original datestamp polling to watch for any change in any of the files in the project and update Marked within a second or two.
I took the script and ran with it this morning, switching it over to REXML parsing and adding in titles for sections and pages. The original script broke on a couple of my projects, but the recursive XML handler I set up fixes the issue.
To run it, you just need to save the script on your drive and make it executable (
chmod a+x /path/to/scrivwatcher.rb). Then you can run
/path/to/scrivwatcher.rb /path/to/YourProject.scriv. Marked will open automatically and changes will be reflected every time you save. To stop the script, you need to type Control-c in the terminal window you ran it from.
I’m going to try to wrap this into a droplet that you can just drop a Scrivener project on and launch both Scrivener and Marked with scrivwatcher syncing the two. Once I’ve determined whether that’s win or fail, I’ll update the Marked Bonus Pack with it. Yes, I will eventually find time to build this functionality into Marked, along with the rest of the Bonus Pack scripts.
The script is currently a gist on GitHub if you want to play with it. I’ll be updating the gist as I have time to clean it up and make a few things (much) more elegant. If you want to fork and help me out, it’s always appreciated!