Carl Johnson left a comment on my “Lazy Markdown Links” post to mention that he’s long used a similar “lazy” method for footnotes. It struck me as a great idea. I whipped up another preprocessor1 for Marked 2 to make it work. It works as a standalone script, too.
While I thought the lazy Markdown links were a neat trick, they didn’t really affect my personal writing style. I generally work in one of three ways: gather all of my reference links at once and put them together at the bottom, write inline links for speed and use the Markdown Service Tools to “Flip Link Style” and clean them up as reference links, or I’m using SearchLink with a combination of the above. None of those lend themselves to the lazy style. My footnote format, however, is perfect for it.
Let me first say that Fletcher Penney has recently made this irrelevant in MultiMarkdown 4 (downloads here). In MMD 4, you can now use [^ this is my footnote]
and it will become a standard footnote. Even more recently, he added a –random option to randomize generated footnote ids and avoid duplication in scenarios such as blogs which render multiple documents and generate repeated footnote labels. That’s as lazy as you can get (and exactly what I had in mind with the inline footnotes Service).
That being said, I still like being able to separate my footnotes below the text so that my Markdown can be read the same way I want my output formatted. I rewrote the Lazy Markdown Links script to do footnotes instead. It accepts two formats: [^]
and `` (Option-T). You can use either or both freely, as long as the marker in the text matches the first following footnote you want to connect. Example text would look like…
Lorem ipsum dolor sit amet[^], consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation[^] ullamco laboris
nisi ut aliquip ex ea commodo consequat.
[^]: This footnote will replace the first caret marker found in
the text.
: This one will replace the first "cross." The syntaxes are
auto-detected and interchangeable.
[^]: This one replaces the second caret instance.
Inspired by tidbits[^] and Carl Johnson
[^]: <http://tidbits.com>
: <http://blog.carlsensei.com/>
From which the script will generate (with random id prefixes)…
Lorem ipsum dolor sit amet[^fn184555-1], consectetur adipisicing
elit, sed do eiusmod tempor[^fn184555-2] incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation[^fn184555-3] ullamco laboris nisi ut aliquip ex ea
commodo consequat.
[^fn184555-1]: This footnote will replace the first caret marker
found in the text.
[^fn184555-2]: This one will replace the first "cross." The
syntaxes are auto-detected and interchangeable.
[^fn184555-3]: This one replaces the second caret instance.
Inspired by tidbits[^fn184555-4] and Carl Johnson[^fn184555-5]
[^fn184555-4]: <http://tidbits.com>
[^fn184555-5]: <http://blog.carlsensei.com/>
You can find the script on GitHub. It can be set up in Marked 2 as follows.
- Save it to a folder as
lazyfootnotes.rb
- Run
chmod a+x lazyfootnotes.rb
on it in Terminal to make it executable - In Marked 2, go to the Behavior preferences and select the Custom Preprocessor tab
- Enter the path to the script, such as
~/scripts/lazyfootnotes.rb
- Check the box to make it “Enabled by default”
- Copy the text of the first example above and hit “Command-Shift-V” in Marked 2 to test
As always, hope somebody else finds this useful, too.