Web Development - Written by Shimone Samuel on Monday, July 14, 2008 17:28 - 7 Comments
Generating HTML footnotes with AppleScript and MarsEdit

As noted in the intro to Accessible footnotes with HTML and CSS, I’m using WordPress to manage the contents of this web site. Searching for an offline content manager, I found MarsEdit was consistently praised as both powerful and effective.
Among other features, MarsEdit offers support for AppleScript and intelligent macros using what it calls Text Markup. Combining these two features offers users advanced tools for speeding up their workflow.
In the case of footnotes, I’m using a combination of AppleScript and Text Markup to reduce the process to two simple steps.
- AppleScript creates a unique link and identifier from a selection of text.
<sup><a href="#63911" id="fn1" title="see footnote 1">1</a></sup>
AppleScript then creates the unique identifier and return link. This reference is stored in the clipboard.
<li id="63911">FOOTNOTE <a href="#fn1" title="return to article">↑</a></li>
- Text Markup creates the footnote code block and includes the stored text from the clipboard.
<div id="footnote"> <ol> <li id="63911">FOOTNOTE <a href="#fn1" title="return to article">↑</a></li> </ol> </div>
What the “Create Footnote” AppleScript does
- Check if MarsEdit has a post window open
- If no post window is open, return an error message
- Check if post window contains a text selection
- If no text is selected, return an error
- Store the selection as a variable
- Store the date and time as a unique identifier
- Replace the selected text with unique link and identifier
- Update clipboard with unique identifier and return link
Download: Create Footnote Applescript
What the “Footnote Block” Text Markup does
- Generate a block of html code
- Add the contents of the clipboard to the code block
- Paste the complete code into the post window
Text Markup can’t be exported but the process to create a new macro is simple:
- Open a post in MarsEdit
- Select Edit in the Text Markup menu
- Click the “+” symbol in the window that opens
- Name your new macro “Footnote Block”
- Enter the following Text Markup into the Opening field and click “Ok”
Footnote Block macro
<div id="footnote"> <ol> #pastetext# </ol> </div>
Generating footnotes with AppleScript and MarsEdit
Part 1: Setup
- Download the Create Footnote Applescript.
- Copy the file to your MarsEdit/Scripts folder (to find the folder, click the AppleScript icon in MarsEdit and select “Open Scripts Folder”).
- Create the Foonote Block macro in MarsEdit using the instructions above.
Part 2: Usage
- Open a post in MarsEdit and make a text selection.
- Choose “Create Footnote” from the AppleScript menu.
- Move the cursor to a new location and select “Footnote Block” from the Text Markup menu.
- To create additional footnotes, skip the Text Markup step and paste the stored clipboard item in the ordered list.
Demo
This demo video shows how AppleScript and MarsEdit is used with the methods above to create HTML footnotes.
Watch: Create Footnote demo video
7 Comments
Red Sweater Blog - Generating Footnotes With MarsEdit
I like this a lot. Would it be possible to get a version that generates Markdown footnotes?
That’s bloody brilliant! It reminds me I need to sit down and figure out how to use AppleScript more.
This is a novel approach, and might be particularly useful for WordPress.com Mac users. I use the WP-Footnotes WordPresst plugin on my own blog.
[...] – bookmarked by 5 members originally found by bopt1 on 2008-10-25 Generating HTML footnotes with AppleScript and MarsEdit http://www.likewowonline.net/web/dev/footnotes-applescript-marsedit.html – bookmarked by 2 members [...]
Create Footnotes in MarsEdit with AppleScript - Shawn Blanc
[...] Generating HTML footnotes with AppleScript and MarsEdit – [...]
Blogo uses this same technique in the rich text editor to insert footnotes into posts (Format > Insert > Footnote). It will also check your post for footnotes above the “more…” link and change those after posting to point to the full article so that the links will work from your blog’s homepage. Blogo
Leave a Reply
- Install a wireless router for your family then email them instructions how to fix it themselves
- Recommended reading from the 2009 Interaction and IA Summit conferences
- Constructive Criticism: Radar for the iPhone
- Shimone.info – A crowdSPRING Success Story
- Generating HTML footnotes with AppleScript and MarsEdit
- Choosing a theme and topics for your blog
- siFR and the user experience
- Accessible footnotes with HTML and CSS
- Creating a blog for fun and profit
- Announcing Like Wow Online!
- Crowdspring Rides Again!
Keep America Beautiful logo crOUTsourced to Indonesi...
- Thanks for the feedback Matt. I did encounter that question when I created this ...
- I think having all of your "return to article" links saying the same thing might...
- interesting post, will come back here, bookmarked your site...
- Thanks for the useful info. It's so interesting...
- Very handy summary. So excited to see content included, too!...
- Hah, to think that I didn't even attend the Summit and still my T-Model made it ...
- That's a great list. Thanks so much for putting it together. And for the shout o...
[...] One of the aspects of MarsEdit which appeals to me is the way it hides much of its power and versatility beneath a relatively simple interface. Shimone Samuel recognized the power of MarsEdit’s scriptability and powerful markup macros, and came up with a pretty cool solution for automating footnote generation. [...]