Copy link to clipboard
Copied
Hi,
I have a manuscript layout in InDesign. It has unfortunately words with starting letter as italic. Is there any way to find out such words using the GREP styles or any other method. There are lot of words. So, it seems impossible to manually look for each of them.
Example:
Test
Thanks and Regards,
Eswari
Okay, I'm going to assume that you want to keep the italics if the whole word is italic. So here's a revised script that should work with your test. And screen shots of my test results.
- Mark
/**
* Removes italics fontStyle in an any word that is not completely italicized.
* @author m1b
* discussion https://community.adobe.com/t5/indesign-discussions/indesign-italic-words-issue/m-p/13601388
*/
function main() {
var findFontStyle = 'Italic',
changeToFontStyle = 'Regular';
...
Copy link to clipboard
Copied
Hi @Eshu153, I've written a script that might help in your case. It will find italicized first letters (of words longer than one letter) and apply the 2nd character's fontStyle to it. See if that covers your situation.
- Mark
/**
* Removes italics fontStyle in the first character
* of a word, where the word is longer than one letter
* and the first character is italicized.
* discussion https://community.adobe.com/t5/indesign-discussions/indesign-italic-words-issue/m-p/13601388
*/
function main() {
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = '\\b[\\l\\u]';
app.findGrepPreferences.fontStyle = 'Italic';
app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = true;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = true;
var doc = app.activeDocument,
found = doc.findGrep(),
counter = 0;
for (var i = 0; i < found.length; i++) {
var word = found[i].words.item(0),
nextChar = word.characters.item(1);
if (
nextChar.isValid
&& nextChar.fontStyle != 'Italic'
&& word.length > 1
) {
found[i].fontStyle = nextChar.fontStyle;
counter++;
}
}
alert('Changed ' + counter + ' italicized characters.');
} // end main
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Un-italicize First Letters');
Copy link to clipboard
Copied
Thanks, Mark.
The script throwing error. I saved it as .vbs.
\\b[\\l\\u]
this I tried in GREP find box and could not find any italics.
Copy link to clipboard
Copied
Hi @Eshu153, please save my script as .jsx (it is ExtendScript, which is a flavour of Javascript).
If you are using Grep in Indesign via the UI, you also need to set the font style:
But please try script first—it will be much easier. 🙂
P.S. here is instructions to install a script:
1. Select the text from my post - just the "code" styled part.
2. Make a new text file in Notepad or TextEdit (IMPORTANT: must be plain text—not rich text).
3. Paste the code from step 1.
4. Save as "Script name here.jsx" (note: file extension is ".jsx") to your desktop.
5. In Indesign, open the Script panel, right-click on on User folder and choose "Reveal".
6. Move the file you saved in step 4 to the User folder that should now be visible.
7. Back in Indesign, the script should appear in the User folder of Scripts Panel (see Window menu > Utility).
8. Double click script name to run the script.
Copy link to clipboard
Copied
I did use the italic style while searching. Could not find any.
I ran the script with your instructions. It says changed 12 italics. But, I see the italics followed by regular characters still not changed. 😞
Copy link to clipboard
Copied
Now, When I search, it shows the first character italic words. But, what I need is show only those words which first character is italic and next characters followed are not italic. It shows every italic word.
Copy link to clipboard
Copied
Okay, can you please post a sample .indd file showing some examples that the script didn't change. Then I'll be able to see why and adjust the script.
Copy link to clipboard
Copied
Okay. Sorry. I didn't being specific. Its changing the first character to normal. But, the occurrences sometimes, more than one letter in the word.
For example,
Test
"Test
"Test
These scenario texts are not getting affected. Maybe the code needs some updation.
Thanks and Regards,
Eswari
Copy link to clipboard
Copied
Okay, I'm going to assume that you want to keep the italics if the whole word is italic. So here's a revised script that should work with your test. And screen shots of my test results.
- Mark
/**
* Removes italics fontStyle in an any word that is not completely italicized.
* @author m1b
* discussion https://community.adobe.com/t5/indesign-discussions/indesign-italic-words-issue/m-p/13601388
*/
function main() {
var findFontStyle = 'Italic',
changeToFontStyle = 'Regular';
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = '[[:punct:]]?\\b[\\l\\u]+';
app.findGrepPreferences.fontStyle = findFontStyle;
app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = true;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = true;
var doc = app.activeDocument,
found = doc.findGrep(),
lettersOfWord = /[A-Za-z]+/,
counter = 0;
for (var i = 0; i < found.length; i++) {
var word = found[i].words.item(0);
if (!word.isValid)
continue;
var wordLettersMatch = word.contents.match(lettersOfWord);
if (wordLettersMatch && wordLettersMatch[0].length > found[i].contents.length) {
found[i].fontStyle = changeToFontStyle;
counter++;
}
}
alert('Changed ' + counter + ' partially italicized words.');
} // end main
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Un-italicize Partial Words');
Copy link to clipboard
Copied
Just For Comments!
[thinking personally a global treatment could be a wrong approach…]
(^/) The Jedi
Copy link to clipboard
Copied
Yeah @FRIdNGE that looks great for the ability to step forwards and backwards. Nice!
- Mark
Copy link to clipboard
Copied
Thanks Mark. It works. But, its always better to search and change would be more better as sometimes we don't know what authors want to convey with the letters. But, this still resolves my issue.