Creating an index in JavaScript

Can JavaScript be used to automatically generate an index, like those found at the back of books? The answer is yes, to a point. In this example, some terms in the document have been tagged for inclusion in the index. The script attached to the page looks for these tags (span elements, actually), and creates an alphabetized list of pointers to them. Thereafter, Prince adds page numbers by way of CSS. The resulting PDF file has an index at the end. Some things are missing, though: commas between page numbers and the collapsing of equal page numbers into one link. The latter is tricky to achieve as the script runs before page numbers are generated.

Posted by howcome November 27, 2013 — Filed under UncategorizedComments (0)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment