Friday, February 18, 2011

Book indexing script

I had to index my modality book, so I wrote a little perl script to help me (it also needs the Roman module from CPAN) and it generated this index.  The idea is that one inserts special plain-text codes in my Microsoft Word file for the book which mark the ranges to index for each term and that mark where the page breaks in the galleys are (actually, Logan Gage, my TA, marked the page breaks), and then one runs the perl script which generates an html file with the index (which one can then import into Word if one so sees fit).

The main special codes are these:
  • {{entry name:}} This is put at the beginning of a passage that will be indexed under "entry name"
  • {{:entry name}} This is put at the end of the passage
  • {{nickname>official name}}  This specifies that any entries flagged with the nickname get re-indexed under the official name.  For instance, to save myself typing, in the body of the text I would use codes like {{EMR:}}...{{:EMR}}, and then I'd put an entry that says {{EMR>Extreme Modal Realism}}
  • {{synonym~entry name}}  This generates a "see entry name" entry in the index, under synonym.
  • @@n@@  This marks the beginning of page n.
There are no special facilities for generating an "n" after a page number for a footnote--one just surrounds the footnote superscript marker with {{entry name:}}...{{:entry name}} and gets a reference to the page it's on.  This won't be good for endnotes that need to be indexed.  There is no facility for "see also".

I also used a Word macro so that I could highlight some text, and it would surround it with the {{entry name:}}...{{:entry name}} codes (getting the name of the entry from the clipboard).

If you want to use the script for something and need help, email me.

1 comment:

  1. Ooops. Found a serious bug in the previous version which generated incorrect numbers. Fixed now. If you downloaded the old script, re-download the new one.

    ReplyDelete