Archive for category MarsEdit
Clean Up Text in Mars Edit
Posted by clark in Applescript, Automation, MarsEdit, Python on 2009/07/26
One thing I really miss with Mars Edit are things like smart quotes and the like. I think they make your blog posts look vastly superior to using regular ASCII quotes. (Of course they don’t show up too terribly well in Helvetica – so I’m actually thinking of changing my body text for this blog to Garamond)
You might think replacing text with smart text filtered text would be easy. However most of the time in Mars Edit you are using a lot of HTML tags. Fortunately in Python there is a standard module called htmlparser which does a lot of the dirty work for you.
This tip is a tad longer than most of the ones I’ve posted in the past. However it illustrates two really, really useful techniques. The first is parsing HTML. The second is using regular expressions. First the code and then I’ll follow it with an explanation.
Converting Formats
Posted by clark in Automation, MarsEdit, System on 2009/07/19
I actually spent several hours the other day (on and off) looking for a good rtf -> HTML converter. Then I realized that Apple had one built in: textutil. It’s quite powerful. And looking at it’s HTML output, it’s very robust as well. Why is textutil useful? Well rtf is used quite a bit in OSX in such places as the clipboard. This utility lets you do things like convert the clipboard to HTML. (The supported formats are: txt, html, rtf, rtfd, doc, wordml, or webarchive)
I’m looking at it for a little script to let me edit in TextEdit or Pages and then autopaste the text as HTML in MarsEdit. (Hopefully I’ll have the post finished sometime this week) Effectively it lets you more easily handle formatted texts in your scripts. Handling rtf is a pain. Handling HTML is trivial.
Footnotes and MarsEdit
Posted by clark in Applescript, Automation, MarsEdit, Python on 2009/07/09
One thing I wish MarsEdit did was handle footnotes gracefully. There are a few Applescripts out that help, but I didn’t care for them too much. Inspired by one script by Shimone Samuel, I wrote up my own. It doesn’t do a whole lot. It’s a Python – Appscript program that simply puts anchor and link tags around the selected text (assumed to be a number representing the footnote number) and makes it a superscript. It then puts on the clipboard boilerplate for the footnote with the proper links and anchors setup.
NetNewsWire and MarsEdit
Posted by clark in Applescript, Automation, MarsEdit, NetNewsWire, Python on 2009/07/09
You probably noticed that I’ve put up a sideblog. I had one on my philosophy blog and I wanted one here. The basic idea (common to many blogs) is to have a list of posts you think are worth reading but don’t really want to dedicate a post to discussing. Typically I do a quick browse of many websites using my favorite rss reader NewNewWire. The nice thing about NetNewsWire is that it is scriptable. Since I use Mars Edit for all my blogging it immediately occurred to me to write a nice little script that simply generates a sideblog post from the currently selected NetNewsWire post.
.jpg)
Recent Comments