J'essaye d'écrire un script qui convertira tous les caractères en minuscules si un style imbriqué particulier est appliqué. Je n'arrive pas à trouver la syntaxe correcte pour obtenir le texte.Comment obtenir le texte auquel un style imbriqué est appliqué? InDesign
Je l'origine essayé ce qui suit, qui a travaillé à une extension, mais en minuscules tout le paragraphe plutôt que seul le texte qui a le style de caractère appliqué:
function lowerCaseNest(myPStyle, myCStyle){
var myDocument = app.documents.item(0);
//Clear the find/change preferences.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.includeFootnotes = false;
app.findChangeTextOptions.includeHiddenLayers = false;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = false;
app.findChangeTextOptions.wholeWord = false;
app.findTextPreferences.appliedParagraphStyle = myPStyle;
var missingFind = app.activeDocument.findText();
var myDoc = app.documents[0];
for (var listIndex = 0 ; listIndex < missingFind.length; listIndex++) {
for (i = missingFind[listIndex].nestedStyles.length-1;i>=0; i--) {
for (j = missingFind[listIndex].nestedStyles[i].parent.characters.length-1;j>=0; j--) {
if (missingFind[listIndex].nestedStyles[i].parent.characters[j].contents.appliedCharacterStyle(myCStyle)) {
var myString = missingFind[listIndex].nestedStyles[i].parent.characters[j].contents;
if (typeof(myString) == "string"){
var myNewString = myString.toLowerCase();
missingFind[listIndex].nestedStyles[i].parent.characters[j].contents = myNewString;
}
}
}
}
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
}
J'ai alors essayé de jouer autour avec appliedNestedStyles
, mais n'arrive pas à comprendre comment récupérer le texte auquel le style imbriqué est appliqué.
Quelqu'un peut-il m'aider?
Merci! John