Last active
July 14, 2019 11:26
-
-
Save joonaspaakko/619f3c4d4e2acfb0f2518906c107ffb4 to your computer and use it in GitHub Desktop.
Indesign script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set true to "normalize" the character styled text = no extra leading & trailing spaces | |
var removeSpace = false; | |
app.findTextPreferences = null; | |
app.changeTextPreferences = null; | |
var findPref = app.findTextPreferences; | |
var changePref = app.changeTextPreferences; | |
findPref.appliedCharacterStyle = 'yellow-background'; | |
var doc = app.activeDocument; | |
var search = doc.findText(); | |
for (var i = 0; i < search.length; i++) { | |
var text = search[i]; | |
var string = text.contents; | |
var space = removeSpace ? '' : ' '; // Just a regular space | |
changePref.changeTo = space + text.contents.replace(/^\s+/,'').replace(/\s+$/,'') + space; | |
text.changeText(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example gif: