Copy link to clipboard
Copied
Hi everyone, im trying to format a line of text that has a bullet separator. see example below.
before: Word • Word Word Word
convert to: Word • Word Word Word
However, it only formats the first word after the bullet. I want to convert all the succeding words to condensed like the example above.
heres the code im currently using;
Hi Joseph,
Have a look at this script:
var doc = app.activeDocument,
// the regex to find anything before first bullet
// uses a 'positive lookahead' ?=
myFindWhat = '^.*?(?=•)',
// this is example change to make
changeStyle = doc.characterStyles.itemByName("Bolder");
if (!changeStyle.isValid) {
alert('There is no character style named "Bolder".');
return;
}
// set up the find/changes
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.
...
Copy link to clipboard
Copied
Hi Joseph,
Have a look at this script:
var doc = app.activeDocument,
// the regex to find anything before first bullet
// uses a 'positive lookahead' ?=
myFindWhat = '^.*?(?=•)',
// this is example change to make
changeStyle = doc.characterStyles.itemByName("Bolder");
if (!changeStyle.isValid) {
alert('There is no character style named "Bolder".');
return;
}
// set up the find/changes
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = myFindWhat;
app.changeGrepPreferences.appliedCharacterStyle = changeStyle;
// do the changes
doc.stories.everyItem().paragraphs.everyItem().changeGrep();
But do you know you can do this exact thing using a Grep Style?
Copy link to clipboard
Copied
Hi @m1b thank you for the code you've provided. How about for lines that have multiple bullets?
example: Word • Word • Word • Word • Word
convert to: Word • Word • Word • Word • Word
Thank you!
We are also using the Grep Style, however I need to include some scripting that is not availble on Greps.
Copy link to clipboard
Copied
@m1b please disregard my second inquiry, I've figured it out base on the code you gave! Thank you so much!
Copy link to clipboard
Copied
Great! Glad you figured it out! And you're right, my regex finds characters before every bullet, not just the first. Oops, didn't test. I've edited my original.
- Mark