Tags

, , ,

I have been writing my thesis using the Pandoc markup format which is a flavour of Markdown. Recently I also switched to using the Sublime Text plain text editor for this purpose. As Sublime Text is fantastically extensible with easy-to-write Python 3.3. plugins, thus on week nights I’ve also been building some tools that help me with some of the basic Pandoc/Markdown mark up text. In particular that bane of all those who write theses of any sort: footnotes and references.

I wrote the plugin PandocReferencr. It’s available in the Package Control system for Sublime Text (to install, type CMD-SHIFT-P (CTRL-SHIFT-P on Windows and Linux), type “Package” select “Package Control: Install” from the drop down menu, wait until it fetches the package list, then type “Pandoc Ref” and select the package to install).

There are two main commands: one (check_footnotes) scans the current file and makes sure every footnote that has been inserted has a corresponding entry somewhere else in the file. It also checks if every footnote text entry also has a footnote insert to match.

This block of footnoted Pandoc/Markdown has two errors and one successful footnote. 
This text has a successful footnote.[^footnote1] This bit of text has a footnote 
that's broken because it doesn't have the matching text entry.[^notexist0]

[^footnote1]: this is the text of the successful footnote number 1.

[^missing1]: there is nowhere that inserts the 'missing1' footnote.

The other useful command (insert_footnote) asks for a footnote id (if you have selected any text, it uses the selection as the default), and then inserts it at the end of the selection (if nothing is selected it acts as expected – inserts at the current cursor position). Then it asks for the footnote text data, and when that’s completed (i.e. you press enter) it puts the footnote text at the end of the current buffer (i.e. at the end of the file).

I’ve got some other ideas for functionality to add in the near future, like:

  • default key bindings installed with the package

  • stop the crazy big warning dialogue for files with many (>15 or so) footnote referencing errors 😳

  • manual-fix and auto-fix broken footnote refs found

  • ability to put footnote text after each paragraph the footnote insert appears in rather than the end of the entire file, by configuration.

  • footnote clean up, i.e. move footnotes to paragraphs or all to end of file according to user preference of footnote placement (above).

  • footnote auto-renumbering, with automatic prefixing.

  • restrict to working with only relevant markdown and pandoc contexts (currently doesn’t care what sort of file it’s invoked in).