
As the previous entry attests, I finally got the Final Draft -> blog entry conversion worked out. Parsing the RTF file turned out to be much easier than anticipated thanks to a tip about a command-line utility called "textutil" from Michael Henley. The whole exercise may be kind of silly, but it did give me a chance to dig a little deeper into Applescript and the Unix Filters built into BBEdit. Allow me to geek out for a moment and describe how text in Final Draft gets onto the weblog.
First, I write whatever script snippet it is I want to put on the blog. I do this in Final Draft, because it lets me focus on the text without having to worry about formatting, and the auto-complete functions are especially nice for dialog. Once the script says what I want, I save it as an RTF file into a special directory I have set up with a folder action that executes any time a new file is saved into it.
The folder action fires up textutil to parse the file and sends the output to BBEdit. At this point I have a workable HTML file with proper stylesheet information, but it's not exactly the way I want it, so I need to translate the css styles from the generic 'p1,' 'p2,' etc. stylenames into the custom styles I've written for the blog. To do this, I run a perl script on the html output, which looks at the layout for each style and assigns each p# style to one that I've specified. This same script also strips out everything that's not within the <body> tag and slaps a div around the contents to identify it as a script in the blog.
Once the text transformations have been done, the Applescript copies the contents of the BBEdit window into a new MarsEdit post so that I can add any other comments and post the entry.
And now that I've posted way more about this than most people will care about, and too little information to be useful to a geek, I think it's time to watch a real movie.
Posted by Jason at December 28, 2005 08:08 PM