Joho the Blogutilities Archives - Joho the Blog

December 27, 2015

Embedded endnote extractor

I’ve updated a 2009 utility that lets you embed your end notes in the text you’re typing. The utility, Footnoter, extracts the endnotes, leaves a footnote number, and compiles a list of the endnotes with numbers and links. It now works with Markdown as well as with HTML; I use Markdown for most of what I write these days.

In other words, let’s say you type this in a document you’re creating with Markdown:

I write using Markdown. ((See John Gruber’s Daring Fireball for more.)) Markdown lets you embed formatting codes into plain text that are then rendered into formatted HTML, Word, etc.((The Marked app adds a viewer with export capabilities. It’s on sale for $9.99 right now.)), enabling me to focus purely on what I’m saying. It also lets me keep my fingers on the keyboard.

If you paste this text into Footnoter and tell it you want Markdown output, it will treat the comments between the double parentheses as endnotes. It will remove those comments from the body of the text, leaving the Markdown code for an endnote number, and will compile a list of endnotes with the proper references back to their endnote numbers. That is, it does what you would expect. At least with my limited testing.

For Markdown, that means the above text gets turned into this:

I write using Markdown.[^fn2] Markdown lets you embed formatting codes into plain text that are then rendered into formatted HTML, Word, etc.[^fn3], enabling me to focus purely on what I’m saying. It also lets me keep my fingers on the keyboard.

[^fn2]:See John Gruber’s Daring Fireball for more.
[^fn3]:The Marked app adds a viewer with export capabilities. It’s on sale for $9.99 right now.

Don’t be freaked out. That’s what endnotes look like in Markdown. When you run them through a parser, they’ll have appropriately numbered superscripts. (Footnoter generates arbitrary unique Markdown labels for endnotes; they start with “fn” and then have numbers appended sequentially. Those numbers have nothing to do with the number the parser will assign to the endnote itself. Also, yes, it’s a little bug that Footnoter starts with fn2 instead of fn1. Non-critical. I’m working on it. [Minutes later]: Fixed it. I think.)

The same thing happens if you are writing HTML except the markup that’s generated is more like this:

I write using Markdown.<span class=’fn_in_text’><a name=’fn2′><a href=#fnend2>2</a><</span> Markdown lets you embed formatting codes into plain text that are then rendered into formatted HTML, Word, etc.<span class=’fn_in_text’><a name=’fn3′><a href=#fnend3>3</a></span>, enabling me to focus purely on what I’m saying. It also lets me keep my fingers on the keyboard.

And that gets rendered in a browser as this:

I write using Markdown.2 Markdown lets you embed formatting codes into plain text that are then rendered into formatted HTML, Word, etc.3, enabling me to focus purely on what I’m saying. It also lets me keep my fingers on the keyboard.

There are a number of options, including setting the delimiters for endnotes and, for HTML, which endnote number to begin with. By default it removes the space before an endnote, so you can put a space between the word where the superscript should be and your delimiters, making your text easier to read when you’re working on it.

Also, if you work on a text, run it through Footnoter, work on it some more and add more endnotes, Footnoter should detect that and begin its arbitrary numbering of Markdown endnotes above where you left off. That means you can run it through more than once and it should still work.

Should.

Note: This code is from 2009. I’ve learned some stuff since then, including that jQuery makes life easier. When I added the Markdown option yesterday, I didn’t bother cleaning up the old code. It is particularly hideous. You can gape at its uglinesss at github.

PS: Yes, I really should have named it “Endnoter.”

Be the first to comment »

December 3, 2012

Tab Rocker – a Chrome utility to return to previous tab

I get lost in my browser tabs all the time. The place I most often want to go is back to the tab I was just in. On Firefox, there are a few utilities that let me do that. My nephew Joel Weinberger has written one that does that and nothing but that for Chrome. You can grab it (free, of course) here. (The source code is on github.)

Joel wrote this, as the result of my whining, during our annual post-Thanksgiving-dinner viewing of Jurassic Park, although he did some clean up of the code afterwards. I should add that, among other things, Joel is a certified computer genius working in deep areas of computer security.

Be the first to comment »

May 15, 2009

Footnoter

I frequently write in HTML, but find footnotes (endnotes, actually) a pain. I don’t like having to interrupt my flow to jump to the end of the document to plunk in a footnote, and I hate having to decide on a number not knowing if I might decide to insert a footnote ahead of the one I just inserted. So, primarily because I enjoy writing utilities for myself, I spent far more hours writing a tool that will make it easier for me than the tool itself will save.

Footnoter lets you embed footnotes in the middle of an HTM document. [[For example, this might be a footnote]] It looks for the designated delimiters, pulls the footnote out, puts it at the end, and leaves a hyperlinked number in its stead. It defaults to the quick-and-dirty HTML that uses <sup> to superscript the number, but the Advanced section lets you instead insert CSS classes for the marker in the text, the marker that precedes the footnote, and for the footnote itself.

Some warnings if you decide to try it out. First, It’s fragile. I’ve barely tested it. I’m sure there will be lots of ways it can be broken. (Nested footnotes won’t work.) Second, you would be a damned fool to paste its results over your only copy of the document you’ve been working on. Third, I am a baboonish, flatfooted writer of programs. What I write is the oppoosite of elegant: I prefer the long way of doing it and of writing it, since I can barely follow what I’m doing. Besides, the programs I write are so small and confined that efficiency doesn’t really matter.

If you care to try Footnoter out, with fear in your limbs and forgiveness in your heart, it’s here.

[Tags: ]

Be the first to comment »