Warning: sort() expects parameter 1 to be array, boolean given in /home/mgobbi/public_html/YourDigitalMentor.com/resources/include/PageWrapper-mike.php on line 164
Footnoter

Footnoter

Gadgets > FootnoterNo download for gad:fnView Licence

Footnoter is a script that helps you maintain footnotes within a document (as I do in my Project Organization Basics article). You can create footnotes while editing your HTML by using a special [[footnote:]] notation, and if you ever rearrange your paragraphs the script will automatically renumber your footnotes.

Installing the script on Mac OS X1 is very easy — simply copy the footnoter.command script file into the top-level folder of your website. When you double-click the script it will process all html & php files2 in that folder and its subfolders.

As you are writing your web page, define your footnote references using two square brackets3, like this:

In my home directory[[footnote:I use a Macintosh. Windows does not have a 'home directory' in the same sense, so you should use either your desktop or the My Documents folder]] I have a Projects folder.

At the bottom of your document create a header block (you can use any one of <h1>, <h2>, <h3>, through <h9>) with the content "Notes":

Notes

When you have finished editing your web page, run the footnoter script. Your html file will be modified to create hyperlinks between the reference and its corresponding footnote:

In my home directory1 I have a Projects folder.

...

Notes

  1. I use a Macintosh. Windows does not have a 'home directory' in the same sense, so you should use either your desktop or the My Documents folder. Return to text.

You'll notice that in the preceding example the footnote link is shown as green text (which turns gray after you follow the link) in a dotted-border box and the back link uses a slightly smaller font. Footnoter automatically assigned classes to the link tags:

In my home directory<a href="#note1" id="ref1" class="ref">1</a> I have a Projects folder.

...

<ol> <li id="note1" class="footnote">I use a Macintosh. Windows does not have a 'home directory' in the same sense, so you should use either your desktop or the My Documents folder. <a href="#ref1" class="backref">Return to text.</a></li> </ol>

and the tags were styled using the following CSS:

a.ref {
     font-size: smaller;
     color: #228822;
     text-decoration: none;
     border: thin dotted #444444;
     padding: 0pt 2pt;
     margin-left: 2pt;
}
a.ref:visited {
     border: thin dotted #666666;
     color: #666666;
}
a.ref:hover {
     border: thin solid #228822;
}
a.backref {
     font-size: smaller;
     text-decoration: none;
     white-space: nowrap;
     }
a.backref:hover {
     color: #228822;
}
a.backref:before {
     content: "[";
     text-decoration: none; 
     color: #000000;
}
a.backref:after {
     content: "]";
     text-decoration: none;
     color: #000000;
}

If you ever rearrange your paragraphs so that the footnotes are in the wrong order, just re-run the footnoter script to update your pages.

Error Recovery

The script edits files "in place" — the original file is replaced with the new content. If the results are not what you wanted, you might want to revert to the original file. On Unix and Mac OS X, the original html/php files may be found in the Sites/backups/footnoter folder in your home folder. I haven't tested the script on Windows, so I can't guarantee where the backups will be placed — I don't know what "home folder" means on that platform.

Disabling the Script

As I said before, the script automatically processes every html and php file in the directory that you place it in. It does this very quickly, so performance is not an issue. But perhaps you have some files (or parts of files) that you don't want to be processed by the script4. Not a problem: just use the special footnotes off and footnotes on comments to enable and disable footnote processing:

<!-- footnotes off -->
<h3>Notes</h3>
This is <em>not</em> the footnotes section.
<!-- footnotes on -->

Using a Different Notes Header

If you want to use a different header than "Notes" you will have to edit the script. Look for the variable named $notesHeaderField near the top of the file and change it to whatever you want your header to be. If you stick to letters and numbers you should be okay, but if you want to use punctuation marks you should be familiar with perl regular expressions before you modify the file.

Running the script from the Command Line

You can run this script from a Terminal window of Mac OS X, any terminal program on a Linux system, and the DOS prompt of a Windows machine (if Perl is installed). You might want to rename the file to get rid of the .command extension, and can run footnoter -h to learn about the command-line options.

Note that renaming the script will change its behavior slightly. I did this because the standard conventions for a command-line program are different than for a double-clicked application.

Behavior Changes When Script is Renamed
footnoter.command When double-clicked, processes all html & php files in the current folder. Displays the names of the files that were changed.
footnoter Prints instructions and exits if run with -h or no arguments.
Processed named files & folders if run with arguments.
Produces no output unless -v or -vv is passed.

Running the script from BBEdit

The script has been designed so that you can also call it from BBEdit. Just do the following:

  1. Turn on Unix Scripting Tools in the Tools pane of the BBEdit Preferences window.
  2. Quit and restart BBEdit (the scripts menu does not appear until after you restart).
  3. Look for the #! menu5 and choose #! > Unix Filters > Open Filters Folder.
  4. Finder should have come to the foreground with a folder selected. Copy the footnoter.command script into that folder.
  5. Quit and restart BBEdit again.

And now you can open up an HTML file in BBEdit, add some footnotes, and choose #! > Unix Filters > footnoter.command to process the file.

Notes

  1. I haven't tested the script on Unix or Windows, and if you do please email me the correct steps and I'll include them in this page. Return to text.
  2. Specifically, the script processes files whose extensions match the pattern s?html? and php[0-9]? (in plain English that's htm, html, shtm, shtml, php, php3, php4, and php5). Return to text.
  3. You cannot place any square brackets within the initial footnote declaration because they will confuse the script. Once you have run footnoter once and the note has moved to the bottom of your HTML file you can go ahead and add the square brackets Return to text.
  4. This page is an example of something that needs special processing by footnoter. I want this footnote to be handled correctly, but want the example HTML in the earlier sections to be ignored. Return to text.
  5. All Unix scripts begin with #! followed by the location of the script interpreter. The footnoter script is written in perl, and so begins with #!/usr/bin/perl Return to text.