Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Converting Nested Styles into Local Character Styles

This blog post is half-tip and half-plea. It has to do with a particular problem some people have with nested styles: You can’t easily convert them to real, localy-formatted character styles — you know, styles that show up as applied to the text in the Character Style panel.

For example, let’s say you need to export a story in RTF format for someone to read in MS Word. The story has run-in headings created with nested styles. You export the story but all the runin heads disappear! Word doesn’t have nested styles, after all. So how can you convert the nested styles into actual character styles?

I am almost sure that I saw a script to do this somewhere in the past year. But I cannot find any evidence of it. So I queried a few likely suspects, but no one has found it yet. If you know of a script (or feel like writing one) email me or post a comment below.

In the meantime, I did learn one awesome trick to achieve this result from author and trainer Jim Maivald. I suggest saving your document before trying this, so that you can revert back to the proper nested styles at the end.

First, open the Tags panel, click the New Tag button and give the tag a name, such as “nestedstyle”

Next, choose Map Styles to Tags from the Tags panel menu. Choose the name of your new tag in the right column, next to the character style name.

After you click OK, choose Map Tags to Styles and choose your character style name from the right column, next to the tag name.

When you click OK, the text that had been styled via nested styles will now be tagged with real character styles. And if you export the story as RTF, you’ll see the styles!

Obviously, that script (wherever it is) is going to be more efficient. But isn’t it cool that you can co-opt the XML tagging features for this workaround?

Tags
Related Articles
Comments

11 Comments on “Converting Nested Styles into Local Character Styles

  1. Another, and perhaps more straightforward, workaround is to simply use the Find/Change dialog. Choose Edit > Find Change and then use the Find Format section to locate the text to which the nested character style is applied. Use the Change Format section to apply the “real” character style to the text. Then just click Find then Change All. I use this method before exporting a publication to the EPUB format by the way.

  2. This is something which has bugged me for a long time.

    There’s no direct way to “see” which text has nested styles applied even with scripting.

    In CS4, you can search for nested styles, but InDesign only finds them if they are the first word of the paragraph. I’m not sure if this is a bug or a halfway implemented feature…

    It’s relatively easy to write a script which would find text which apparently has a nested style applied, but there’s two problems:

    1) The script would have to set a relatively rarely used property to find the text with the style applied. It would always be possible that the said property would be otherwise used, so the script can’t be foolproof.

    2) The bigger problem is that nested styles a “nestable” meaning that you can have text which has both a nested style and a character style applied directly. As long as InDesign doesn’t have the ability to apply more than one character style to text, applying the nested style directly will remove any previously applied character styles. This can easily change formatting in undesirable ways… :(

    Are you still sure you want this script? ;)

  3. Hi David,

    I think you must have been remembering the script I posted in a comment to Downsaving Snippets post . It was an applescript but Adi Ravid kindly created a javascript version (however, I’ve not tested this version).

    The original applescript does not rely on setting a rarely used property as Harps suggested would be required in his point 1. However, I think it would overwrite any manually applied styles (Harps’s point 2). In my experience this does not usually matter too much, but, as with any script, caution should be applied before pressing the button!

    Anyway, I hope people find of use…

    Nye

  4. Whoops! I should read more carefully before commenting, my script works with Grep styles, rather than nested styles. I suspect that the limitations of scripting that Harbs describes would make this difficult to script. N.

  5. This should have been a very easy script.

    You would not believe the number of bugs I had to work around to make this script work! :( But, here it is… Enjoy! (and use with care…)

    I used the underline gap color to identify the character styles. I think it’s sufficiently rarely used to be a relatively safe identifier… ;)

  6. Thank you, Harbs! In my quick tests, it does appear to work well. As you said, it does wipe out any local character styles applied on top of the nested styles, but until Adobe gives us multiple character styles (please?!) that’s as good as we can expect.

  7. This is very cool. I didn’t need it yesterday, but I needed it today, and there it was. Thank you! I hadn’t realized until just now that exporting to epub (in CS3 since it’s broken in CS4) stripped out nested style formatting.

  8. Before I read this, I ignorantly assumed that mapping styles to tags would not respect non-local styles (i.e. formatting applied via a nested style). It simply never occurred to me that it would.

    Knowing it does has really saved me time and a lot of tedious work. Thanks to everyone at InDesign Secrets! (And Harbs as well, because I’ll probably have to use that script sooner or later.)

  9. The need change nested styles to local character styles just came up for me today. I knew I had seen this post before, so I searched nested styles and found it right away. David, the tagging solution is awesome, but Harbs’ script just saved me hours of work.

    I love this site.

    Thanks, guys!

  10. I’ve just tried Harbs’s script in CS5 as I had a need for it. Sadly it seems to crash InDesign every time, even on a very simple test document.
    Oh well, at least the tagging solution is still available.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>