Hi, firstly thanks for previous help. Learning as I go but stuck on this newbie question - I've searched but can't find any reference.
I have codes in my XML for italic ("^I^" & "^/I^") surrounding text to make italic. I need to change it to italic regardless as to whether the XML gets mapped to a para style which has bold or roman.
I can find the text and map it to a character style (when I wrongly assumed it would only occur in XML which ended up as bold, so it applied "BoldItalic" character style)
JS so far:
//Find text with ^I^ and ^/I^ around it.
app.findGrepPreferences.findWhat = "(\\^I\\^)(.+)(\\^/I\\^)";
app.changeGrepPreferences.changeTo = "$2";
app.changeGrepPreferences.appliedCharacterStyle = "BoldItalic";
I need to replicated the functionality when selecting text in InDesign when you press ctrl-alt-I (make italic, regardless if it's roman or bold), and not selecting 'Italic' from the character panel (which would remove the boldness of the text).
is it a case of querying the found results to see if they're bold, and if so applying "BoldItalic" else applying "Italic"? If so, an indication of the syntax would really help me, and as always thanks heaps for any assistance.
It'll take two changeGreps, but this still beats checking each occurrence one at a time.
Copy your stuff twice, and add
app.findGrepPreferences.fontStyle = 'Bold";
to the first query, and make that change to Bold Italics. In the second set, change the remains to Italics.
Wow! Thanks for that. Works absolutely perfectly (Note for future reference: had to add a couple of lines to clear the search prefs in between the Greps).
It's part of an automatic document creation project, so doing it manually was not an option.
As an aside, I've been in the graphics industry for 25 years (anyone remember PageMaker 2?) and never realised (couldn't be bothered to learn) the power of scripting and automation. Now I love it - and I thought I was a 'power user' before...