Generating HTML footnotes with AppleScript and MarsEdit

Beach sandal on a tile floor

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.

  1. 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>
  2. Text Markup creates the footnote code block and includes the stored text from the clipboard.
    <div id="footnote">
    		<li id="63911">FOOTNOTE <a href="#fn1" title="return to article">↑</a></li>

What the “Create Footnote” AppleScript does

  1. Check if MarsEdit has a post window open
    • If no post window is open, return an error message
  2. Check if post window contains a text selection
    • If no text is selected, return an error
  3. Store the selection as a variable
  4. Store the date and time as a unique identifier
  5. Replace the selected text with unique link and identifier
  6. Update clipboard with unique identifier and return link

Download: Create Footnote Applescript

What the “Footnote Block” Text Markup does

  1. Generate a block of html code
  2. Add the contents of the clipboard to the code block
  3. Paste the complete code into the post window

Text Markup can’t be exported but the process to create a new macro is simple:

  1. Open a post in MarsEdit
  2. Select Edit in the Text Markup menu
  3. Click the “+” symbol in the window that opens
  4. Name your new macro “Footnote Block”
  5. Enter the following Text Markup into the Opening field and click “Ok”

Footnote Block macro

<div id="footnote">

Generating footnotes with AppleScript and MarsEdit

Part 1: Setup

  1. Download the Create Footnote Applescript.
  2. Copy the file to your MarsEdit/Scripts folder (to find the folder, click the AppleScript icon in MarsEdit and select “Open Scripts Folder”).
  3. Create the Foonote Block macro in MarsEdit using the instructions above.

Part 2: Usage

  1. Open a post in MarsEdit and make a text selection.
  2. Choose “Create Footnote” from the AppleScript menu.
  3. Move the cursor to a new location and select “Footnote Block” from the Text Markup menu.
  4. To create additional footnotes, skip the Text Markup step and paste the stored clipboard item in the ordered list.


This demo video shows how AppleScript and MarsEdit is used with the methods above to create HTML footnotes.

Watch: Create Footnote demo video

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>