IA Writer to WordPress

0. Wha?

With the coming of the new doggie into the house, perhaps I will again add more content to the bloggy thing that I have kinda sorta not really been keeping over the last little while.

Probably this has been done by someone else on the Intertubz, but ach, why not. I have some time on my hands, so here are running notes in IA Writer that will make its way to a WordPress post by some means or other. There’s nothing special about IA writer, by the way. Well, there is, but not for the purposes of the WordPress posting. The same code should work with any plain-ish text file coming from any editor.

Why bother? Well, I think that the primary reason a lot of my notes have not made it to the blog is that it is just such a PITA to go out of my way to make a blog posting. If it all just sorta “works” from my usual workflows than that would perhaps be a very different situation. Not that I think I have anything particularly interesting or unique to say

So the process for this exercise seems clear:
1. “~~shell out” to markdown and produce an html file~~
2. process that html with nokogiri
3. post to WordPress

No need to shell out, apparently. tillsc has already built a Ruby extension library around MultiMarkdown, Ruby MultiMarkdown 4, so
I guess the awkward bit would be how best to execute the ruby script that pulls all this together… from a services menu item, maybe? And then how to deal with edits… something in the metadata at the head of the file? A call to getPost call to XML RPC to see if an existing post “matching” (on what criterion?) that about to be posted exists? But what to check on? Is the old post deleted? I suppose when one starts thinking about these things then one might just as well produce an actual interface to WordPress, but why bother when there are so many such things anyway?

Maybe I will look into that… but I am reasonably happy with the fact that this post came from iA Writer, and without too much trouble either. Next up? A horror-show of a MultiMarkdown file in iA Writer to to see how much gets translated into a decent-ish looking post.

3. Code

Posting to WordPress is pretty straightforward. All the heavy lifting is done by the rubypress gem, which makes this sort of thing doggone simple (see what I did there!). Here a block of code from that thing I wrote a while ago that scraped a Koine Greek “Word of the Day” from Ἡ Καινὴ Διαθήκη. Last post here

I never really did manage to get into the swing of things with Sublime Text everyone’s favourite general-purpose editor since, well TextMate fell out of favour ca. 2009-ish, and generally stuck to TextMate. Sure there’s VIM (and it is awesome), but really? Life _is_ better with a pretty and functional editor.

And then along came Atom… as well as a few others: Brackets and Light Table to name the other two newbies, all better described at SitePoint. Suffice to say that Atom won for me. Despite it being very Sublime-like, I felt comfortable with it. So here, culled from .zsh_history, those Themes and Packages that I have installed and not uninstalled over the last eight months or so:

For whatever reason, I’ve bumped into a number of in-browser [latex]\LaTeX[/latex] editing tools recently. I guess these are mostly useful for collaborative efforts, and I can see a reason why one would not want to use Subversion or Git. I mean Eldest is just coming of an age where he’s seeing computers as tools for his own use rather than just vectors of games/educational materials/movies. Because I am a benevolent father-dictator, he’s already familiar with [latex]\LaTeX[/latex] (and actually loves Computer Modern), and has decided to set all his writings in [latex]\LaTeX[/latex] prior to submission. Good for him. I love the fact that he was complaining about fonts on the MacBook Airs at school, and the pain of writing in MS Word. Good boy!

So, rather than having him use my tool chain, which is very much tied to my laptop and TeXstudio, we could use one of these. I might even be able to persuade his Grade IV teacher that [latex]\LaTeX[/latex] is something worth introducing to the kids in its own right. She was, after all, blown away by 74111101’s Christmas writing piece that we set in [latex]\LaTeX[/latex]. I guess I’ll make notes as I evaluate each below and add them here.

[latex]\LaTeX[/latex] can, apparently, be embedded in WP using shortcodes <http://en.support.wordpress.com/latex/>, but neither of the below “codes”, for example appear to work out-of-the-box on self-hosted WP sites: