Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

I have a poster which I have made, it is basically lots of java code and looks like a wall of text.

I want to add syntax highlighting to this so that the code is more readable. I know that I can create styles and then apply them by selecting the text and adding the desired style, however there is so much code in the poster that I want t automate/batch this process.

Is there either a plugin I can use that will add the syntax highlighting or is there a way to add styles globally so that it adds the style to every instance of a certain character?

If anyone can think of a different way to achieve this using a different piece of software then please share :)

share|improve this question
1  
Some code editors allow you to export the code as HTML, with highlighting preserved in the result. I think Notepad++ can do this via plugin, and I think jEdit can do this as well. Also, sometimes copy/pasting into Word created RTF text which also maintains the highlighting, but that depends on the source of the copy - I think it is possible with Eclipse. I don't know if Indesign can accept RTF as an input so I'm not sure if this kludgey process would work... –  FrustratedWithFormsDesigner Apr 13 '12 at 18:06
add comment

1 Answer 1

This the kind of task where GREP Styles shine. Since you're setting javascript, I assume you're not unfamiliar with grep, but the GREP (for some reason, Adobe uses all caps) Styles dialog has plenty of help if you're rusty.

The first step is to create a set of colors you'll want to use to highlight different code elements, so they're ready in the Swatches panel.

The next step is to assign a Paragraph Style to all the code, if you haven't already. Once that's done, edit the Paragraph Style and go to the "GREP Style" section, where the magic starts.

enter image description here

  • Click on New GREP Style and in the Apply Style: dropdown select "New Character Style".

  • Give the style a name (I'm using "String" in this example), and assign a Character Color or font style such as bold, italic, etc. I'm using the stock green for the example.

New Character Style dialog

  • In the To Text: section, enter the grep expression that will identify the text you want to target. In this case, it's pretty simple: ".+" finds any text between any pair of double quote marks.

GREP Style applied

That's the basic technique. From here you simply "rinse and repeat" until you've covered all the bases. Save the expressions for the next time you have one of these projects, because some of them will be quite lengthy.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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