Copy link to clipboard
Copied
Hello everyone...
Is there a way to grep all non-italics characters followed by an italics punctuatiob, e.g., serach for "Review of Religions," in this word, the punctuation "," is not italics, I would like to serach of all types of punctuation that are not italics, and change them to italics, same would be the case for bold, and bold-italics.
Another way looking at it would be a grep that could search for any italics character followed by a regular punctuation, and a bold character follwed by a non-bold punctuation, and a bold-italics character followed by a non-bold-italics character.
Thanks in advance!
Copy link to clipboard
Copied
I would run this 3 times:
Find What: (\,|\;|\:)
Find Format: Regular
Change To: leave blank
Change Format: Character Style Italic
The second time you run it I would reset to Bold Character Style.
The third time I would run it I would reset to Bold Italic Character Style.
Automatic? No. But it would allow you to inspect each occurrence, and it would only take 5 minutes.
Copy link to clipboard
Copied
Look for grep manager script or the multi find and change from automatication. The first is free. Once you have the query you can load them in a set and ececute them all in one click.
Copy link to clipboard
Copied
Hi,
Just this:
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = ".[.,;:!?…]";
myFound = app.activeDocument.findGrep();
var F = myFound.length;
for (var f = 0; f < F; f++) {
var myCharStyle = myFound
.characters[0].appliedCharacterStyle; if (myFound
.characters[-1].appliedCharacterStyle !== myCharStyle) myFound .characters[-1].appliedCharacterStyle = myCharStyle; }
app.findGrepPreferences = null;
Of course, if you only want to catch "Italic", "Bold" and "Bold Italic" and avoid to catch, say, URL, you could play this:
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = ".[.,;:!?…]";
myFound = app.activeDocument.findGrep();
var F = myFound.length;
for (var f = 0; f < F; f++) {
var myCharStyle = myFound
.characters[0].appliedCharacterStyle; if ((myCharStyle.name == "Italic" || myCharStyle.name == "Bold" || myCharStyle.name == "Bold Italic") && myFound
.characters[-1].appliedCharacterStyle !== myCharStyle) myFound .characters[-1].appliedCharacterStyle = myCharStyle; }
app.findGrepPreferences = null;
(^/)
Copy link to clipboard
Copied
This is not something you can just like that with InDesign's Grep. The Grep manager that Gert mentioned can't do that, don't know about Automatication's solution. If Michael's solution doesn't work for you, you can change italic formatting to text tags, so that this:
Review of Religions,
(where the comma is not italic) is rendered like this:
<i>Review of Religions</i>,
You can then search for (</i>)([[:punct:]]) and replace with $2$1 to move the punctuation inside the italics. Then you change the italic tags back to italic formatting. This method is described in detail in https://indesignsecrets.com/issues/issue-76-publish-anywhere. You'd do that again for bold and bold-italic. You can store the queries and rerun them. It's a method I've been using a lot, and it works well.
Peter
Copy link to clipboard
Copied
Peter, you're right. It cannot be done by either. I thought it could be chained, but no. The Grep manager and the MFC are useful solutions when grep queries can be executed one after the other. We use it a lot during layout of texts coming from Word.
Copy link to clipboard
Copied
I found a way,
Find: (?<!.)[:,;")!?%]|["(](?!.)
Find format: font style regular (or if you work with characterstyles, like I do chacacter style: [none])
Change format: italic (or character-style: italic)
Explanation: It looks for every character in the list [:,;")!?%] that is preceded by any character that is not regular/has no character style OR every character in the second list ["(] that is followed by a character that is not regular/has no character style.
It's not perfect. I would like to optimize it so that it won't find brackets in which the text is not fully italic (e.g this text). But I couldn't find out how. It does work well enough though.