I have an InDesign document with text styled as one of the following custom character styles throughout the document:

  • character-bold
  • character-italic
  • character-bolditalic
  • [none]

I am trying to write a script to scan the entire document and wrap each text of a particular character style with the appropriate HTML tag, except of course the text without any assigned character style. Thus, the following text:

The quick brown fox jumps right over the lazy dog.

...should look like:

The quick <b>brown</b> fox <b>jumps ri</b>ght <i>ov</i>er <b><i>the</i></b> lazy dog.

Is this doable? I am sure it is. I don't mind using some kind of GREP/Find-Change method if possible. I don't want to use "Export to HTML" because there are some custom tags that won't show that way.

2 Answers 2


This is definitely doable, and can quite easily be done with the use of a GREP-style script.

For each of your attributes, search for it using the GREP tab and replace with <b>$0</b> (so in a script, that would be changeGrep). The codes themselves will probably get some of the formatting but that would not matter if you discard them anyway. (Make sure to change the HTML codes as well, matching the attribute you are changing.)

Before you do this to add attributes, make sure to replace the characters < and > with &lt; and &gt;, and - since this introduces yet another special character - before you do that, replace & with &amp;.

  • Worked like a charm! Would you please also be kind enough to help me bring these steps together in a jsx script? If you could just point me to some resource that explains or lists out the available IndDesign library functions and their syntax pertaining to this task, that would be awesome.
    – TheLearner
    Commented Nov 24, 2015 at 1:33

This is definitely doable, and could quite easily be done without the use of a GREP-style script.

InDesign has a built-in "Export to HTML" feature which can be found under File > Export.

You can choose how the HTML will render on it's way out in the export dialogue, including which tags to include (like bold, italic, etc.)

Here is a tutorial detailing the entire process: http://www.dummies.com/how-to/content/how-to-export-adobe-indesign-cs6-documents-to-html.html

  • 1
    Did you read the last paragraph in the question? Is there a way to factor in that? Commented Nov 23, 2015 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.