Editing topics

Back in 2009 I wrote a set of scripts for Guy Burns. Guy provided the manual as a PDF, but after all these years (writing in 2023) the text of the manual needed some updates and additions. The text that follows is Guy's text with some additions and clarifications.

InDesign has a limitation that does not allow full editing of index topics. For example, if certain topics appear in the index as:

Burns, Joy 3, 5, 11
Burns, Max 2, 9, 17, 23, 45

they cannot be edited, as topics, to become:

Burns
  Joy 3, 5, 11
  Max 2, 9, 17, 23, 45

The Topic Options window shows why: the window does not allow entries into Levels 2, 3, and 4:

Index edit: Topic dialog

However, full editing is possible in the Page Reference Options window:

Index edit: Page references dialog

The problem is, of course, that each individual page reference has to be altered – a time-consuming process if there are more than a few entries.

Three scripts overcome this limitation. These scripts are called:

index-list.jsx

The script exports all the index topics in an InDesign document (the one that is open) to a new InDesign document called index_update.indd. In index_update the topics can be fully edited to four levels. When editing is complete, the topics can be exported back to the original document.

duplicate_line.jsx

This script performs a certain function that makes it easier to edit the topics within index_update (see below).

index-list-update.jsx

This one takes the edited topics from index_update.indd and exports them back to the original InDesign document. All properties of the original topic are preserved as much as possible (applied page-number style override, page-reference type, etc.)

How to use the scripts

1. Open the document whose index topics you want to edit. Let’s assume the document is called TEST.

2. Run index-list.jsx. It creates a new document called index_update.indd in the same folder as TEST. If a document with the same name already exists (because you have run index-list.jsx previously), you will be asked to rename or delete the existing document. You must delete or rename it, else index-list.jsx will not run.

3. When index-list.jsx has generated a list of topics in the new document, you can begin to edit the topics. The process requires some explanation. The topics appear one per line. For example, the first two topics in the index might be:

Burns, Joy
Burns, Max

If the topics already have several levels, a # symbol is used to indicate the level breaks. For example, if the topic in TEST had two levels:

Burns
  Max

that same topic appears in index_update as:

Burns#Max

The # indicates that Burns is at Level 1, and Max is at Level 2.

4. To edit the topic, you insert a tab after the topic and add the new version of the topic. The script index-list-update.jsx, when it is run, looks for tabs and updates the index in TEST with what appears to the right of the tab. An example should make this clear. Assume you want to change Burns, Max into a two-level topic. In index_update the topic would first appear as:

Burns, Max

After adding the edited version of the topic, the line would appear as (where [TAB] stands for the tab character):

Burns, Max[TAB]Burns#Max

The tab character after the first Max triggers the update script (index-list-update.jsx) to alter the topic in TEST to a two-level topic.

The two examples which follow show how to turn a single-level topic into a three-level and a four-level topic:

Burns, Max[TAB]Burns#Max#early childhood
Burns, Joy[TAB]Burns#Joy#early childhood#first school

5. It should now be clear why the script duplicate_line.jsx comes in handy. Instead of having to insert a tab and retype the topic (before editing it), duplicate_line.jsx does that for you. By simply clicking in the line that is to be edited and running duplicate_line.jsx, you get the tab and a repeat of the original topic. The big advantage of using duplicate_line.jsx is that it can process multiple lines at once. If you have several topics that have to be edited, simply select them, run duplicate_line.jsx, and the selected topics will be duplicated ready for editing. Finally, to duplicate all the topic names, select one of the text frames and run the script. (It is convenient to assign a keyboard shortcut to this script.)

6. When you have finished editing, make TEST active and run index-list-update.jsx. The script will search through index_update looking for tabs. After it has found all lines that contain a tab, it notes the changes that are to be made, and then enters TEST and makes those changes.

Note: Apostrophies in the original topic, such as in annon’s Hotel, may cause the topic to be skipped and not edited. You may have to rename the topic in the original document before attempting to edit it.


Change log

25 Aug. 2023: Updated Guy Burns's original text in the (previously attached) PDF and placed it as text here. Added some improvements to the scripts.

16 Dec. 2012: In some cases, topics were duplicated. Fixed.

Aug. 2009: First posted.


Download scripts

Back to the main page on indexing

Back to the main script page

Installing and running scripts

Editing a script

Questions, comments? Get in touch