web analytics


July 9, 2012 / Blog

Designing with XMPie uCreate — Tips & Tricks with GREP

By Administrator

When I first began designing with XMPie, or for highly variable data driven documents in general, I noticed that some simple design-related elements were a bit more complicated than static one-off documents. Dynamically executing things such as super scripting, emphasizing, and inline formatting (interpreting XML or HTML tags, perhaps) that are coming through your data can be challenging.

Regardless of what kind of data is thrown your way, you just need to deal with it and find a way to work with it. The data will never adapt to fit your exact needs, as it is often used across many different applications. In this article, I’ll show you how to use XMPie’s uCreate and Adobe InDesign’s out-of-the-box functionality to manipulate your data without having to change it upstream.

The following requires Adobe InDesign CS4 or higher

Recently I was faced with a challenge where the data coming upstream contained inline HTML tags ( <em>, <strong>, <sup>, etc. ). InDesign does not interpret HTML tags naturally so they are populated as plain text and without having my client change their data, I had to find a way to handle the tags – all while keeping the document dynamic.

Here are the requirements:

  1. Format text between tags appropriately.
  2. Use GREPs on all paragraph styles to limit duplicate edits while future proofing.
  3. Remove tags.

Untouched Data

Notice the HTML tags within the inbound data. This will not work in XMPie.

GREP to the Rescue

GREP is a command line text search utility; it stands for Global Regular Expression Parsing.  Essentially, GREP in InDesign allows you to use codes to find, edit or style text through the Find/Change dialog box, or in this case Paragraph Styles.

In the next few paragraphs, I’ll show you how beautiful it really is.

GREP Styles

Using InDesign’s character and paragraph styles, you can save yourself a lot of time by predefining your text parameters.  Setting the base font, size, and color alone will save you from endless visits to the character palette every time you create a new text box.  Here I have my Basic Paragraph style set with my default font, as well as three other Character Styles ‘Bold’, ‘Italic’ and ‘Red Text’, which we will use in a moment.

Paragraph Character Styles

Now let’s get into the GREP.  For illustrative purposes, we’ll target and highlight our tags in a red color, a GREP style in its most basic form.

This is extremely important: in order to make these GREP rules applicable to each and every piece of data coming in, you will need to make sure each new Paragraph Style you create is based on your ‘Basic Paragraph Style’.  InDesign lets you do this with the click of a mouse when you create a new Paragraph Style.

What this also means is that there is only one place (your Basic Paragraph Style) where you will edit all of your GREP styles and expressions.  This is a key part which will take care of our second requirement.

Now, go to your Paragraph Styles and select ‘Basic Paragraph Style’.  In the Paragraph Style options dialog on the left hand column, you will notice ‘GREP Style’ a bit more than half way down.  Select ‘New GREP Style’.  This will enter a new GREP style to the dialog, where you can choose existing Character Styles or create a new style to apply to the text (the default GREP code d+ means “one or more digits in a row”).

In this example, we are going to highlight our tags in a red color with a character style I’ve predefined for the text: <em> and <strong>.

GREP Highlight tags

The result is that the tags are highlighted in red text. Also note the ‘bar’ or ‘pipe’ symbol (|) is used.  It means ‘AND’ and can be very useful when targeting several text elements together.

GREP Result 1

GREP Expressions

We clearly have more to do here.

We still need to style the text between the tags, but keep in mind it needs to be done in a dynamic way.  Targeting particular strings of sentences could be an absolute nightmare.  GREP styles here won’t exactly fit the bill, so let me introduce you to GREP Expressions.  In this case, here’s a spinoff on the ‘Find Between’ GREP expression string using our target <STRONG> tag, compliments of Anne-Marie Concepcion.


This might look a little scary, but it’s not all that bad.  Basically the expression finds the text between the two pieces of target text and applies a style to them. You can learn about the Find Between expression in more detail here.

Here it is in our GREP Styles dialog:
GREP Dialog

And here is the result on our data:
GREP Result

Removing the tags

Looking a little better, but we still need to get rid of those obtrusive tags.  At first, I had my doubts about this next trick, but after some extensive testing – it works like a charm.

To remove characters, you’ll need to create a new ‘Character Style’ and name it ‘Remove Tags’.  Now the Character Style settings here are very important.  First you will need to go to ‘Basic Character Formats’ and apply the following setting: Font Size: 0.1pt. (Font family and style are optional).

Remove tags Step 1

Next, choose ‘Advanced Character Formats’ and set the Horizontal Scale to 1%.

Remove Tags Step 2

Lastly for our Remove Tags character Style, choose Character Color and set it to None.

Remove Tags Step 3

Now that we have our Remove Tags Character Style set, we’ll need to apply a GREP using our new style. To do so, you’ll need to edit the Basic Paragraph Style, where all of our GREPS are located.

Now we already have our target text in one of our GREP styles that we used to highlight our tags in red. We don’t need to highlight our tags, so the best way to go about it is to replace the ‘Red Text’ style to our new ‘Remove Tags’ character style.

Apply Remove GREP

End Result

Once you select the style and click ‘OK’, you will now see your end result. Voila! I told you it was a beautiful thing!

End Result


As you can see from our end result, inline formatting can in fact be handled using InDesign’s core functionality with a little help from GREP. We started with tag-filled unformatted data and what began as a major issue resulted in a dynamic, easy to manage, and lightweight solution. When it comes to GREP for dynamic documents, we have only scratched the surface. So if ever you feel stuck working with data on your next InDesign/XMPie project, don’t overlook the power of GREP. It just might save the day.