A typesetting goldmine: Peter Kahrel’s online repository of free scripts

Website header showing code. Photo by Markus Spiske on Unsplash

At first glance, it may not look like much—but Peter Kahrel’s extensive online repository of free scripts is an essential resource for anyone who works on long documents in InDesign.

After hosting the script repository on his own website for many years, its future was in doubt late last year when Peter made the decision to relocate from the UK to Spain. His UK ISP refused to let him keep the site, or even set up redirection links.

Fortunately, David Blatner at CreativePro Network came to the rescue, and the repository now has a new home at CreativePro.com.

In this interview, Peter shares insights into the repository’s history, and some of the ways that InDesign typesetters can use his free scripts to make their lives easier.

Peter, how did you first get into scripting?

I worked as a typesetter, copy-editor, and indexer for more than thirty years. Much of typesetting and copy-editing is tedious, and to beat the tedium to some extent, I scripted as much as I could.

I’ve been interested in programming and AI since the 1980s, and I started scripting InDesign with JavaScript in 2003.

Why did you develop your online script repository?

I thought that some people might be interested in some of my scripts, so I posted them online. When that appeared to go down well, I made a habit of posting scripts I did for myself that I thought would be generally useful. And I wrote up how to use them.

The repository doesn’t look very exciting; in fact, some years ago it was described by Gerald Singelmann as visually an Langeweile kaum zu übertreffen—‘unsurpassed boredom’. Though, he did say he liked the scripts!

What do the scripts do?

In a way, the scripts reflect the features that InDesign lacks or lacked and which I needed. I have clusters of scripts in three areas where a lot of functionality is or was missing: footnotes/endnotes, indexes, and GREP.

Footnotes/endnotes

Before CC2018, InDesign did just one type of note: footnotes. Thus, the Notes section includes scripts that convert footnotes to endnotes and margin notes (and vice versa), and to manage footnotes in more flexible ways.

Indexes

InDesign’s index is not very flexible and lacks several basic features. However, with scripting, it becomes a powerful tool.

With the Indexes and concordances scripts, it’s possible to use more than one index in a document, and implement different sort types (word-by-word and letter-by-letter). A much-requested feature, the possibility to create an index from a word list, is not difficult to script, and the repository contains some versions of such a concordancer.

Other useful index features include various index statistics and audits. For example, there’s a script in the repository that shows the distribution of index references graphically, so that in a glance you see whether an index is lopsided or evenly spread.

GREP

GREP (Global Regular Expression Print) is a sophisticated search and replace tool that enables you to manipulate text automatically. InDesign’s GREP is very powerful as it is, but various things can be improved.

For example, InDesign’s interface in the ‘Find/Change’ dialogue is a tiny entry field, which is fine for simple and short expressions. However, the GREP Editor script creates a window in which you can write long expressions (making life a lot easier), and which highlights everything that is matched by the expression (useful for debugging).

The GREP Editor doesn’t stop there. When GREP was first implemented (in InDesign CS3), the GREP wildcards and features that were exposed by the interface covered only part of what is available, and I exposed all GREP features in the GREP Editor’s interface.

The GREP section of the repository also includes several other useful GREP utilities.

Are there other scripts available in the repository?

Yes, there are nearly 40 individual scripts in addition to the three clusters. Some are very complex and perform many functions, while others are relatively simple. Some of my favourites are:

What advice do you have for anyone who wants to get started with InDesign scripting?

Get as much practice as possible. You can do that by writing as many scripts as possible for yourself.

Get involved in some scripting forums, such as Adobe’s InDesign scripting forum,  the InDesign Secrets scripting forum, and the German-language HilfDirSelbst forum. There are people there who can answer your questions and, after you’ve made a start, trying to solve other people’s problems is a good way to get familiar with InDesign’s object model.

My script repository has a section with links to books and other useful resources, which will help you learn the basics.

Most of all, you need determination: don’t be discouraged if you can’t get a script to work straight away. Try your best to get the script to work before you look for help.

About Peter

Peter Kahrel

Peter Kahrel was born in Amsterdam, the Netherlands. He trained as a linguist at the University of Amsterdam and has an MA and a PhD, specialising in syntax, semantics, and typology. He became interested in programming and early AI in the 1980s, and has been automating arduous typesetting tasks in InDesign with JavaScript since 2003.

Peter is the author of JavaScript for InDesign and GREP in InDesign (both available from indesignsecrets.com) and is highly regarded in the global InDesign scripting community. He has worked as a Scripting Engineer at Typefi since 2010.

Related Articles

Sign up to our Newsletter

Subscribe

* indicates required

BookMachine Ltd. will use the information you provide on this form to be in touch with you and to provide updates and marketing. Please let us know all the ways you would like to hear from us:

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at [email protected]. We will treat your information with respect. For more information about our privacy practices please visit our website. By clicking below, you agree that we may process your information in accordance with these terms.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.