Web Development - Written by Shimone Samuel on Monday, July 14, 2008 17:28 - 5 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
5 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.
Footnotes : Mormon Metaphysics
[...] MarsEdit for Blogging? Here’s how to automate footnotes. I suspect I’ll be using this in the days to [...]
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.
Leave a Reply
- 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!
- Hi Judy. Which website are you referring to? Who made the food depends on which ...
- This is a novel approach, and might be particularly useful for WordPress.com Mac...
- That's bloody brilliant! It reminds me I need to sit down and figure out how to ...
- I like this a lot. Would it be possible to get a version that generates Markdown...
- Hi Shimone,
I was looking at your website tonight (which I always enjoy) and w...
- Thank you for the feedback.
I came up with the name after several weeks of re...
- Great concept, and great name for this website. How did you come up with the na...
- Fair enough. Thanks for clarifying your points. I'd say that extended character ...
[...] 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. [...]