I want to make a script, but I am unsure of how to write it.
I want the script to choose the first sentence in a text-box, changes the swatch, duplicates the page, select the next sentence, change the swatch, repeat. I have attached an example of the result I want to acheive.
Any tips or resources would be greatly appreciated!
Hi @printperson22, this was an intriguing exercise! I've written a script that I think does what you are asking for, but it is designed to be used in a particular set up:
1. a single page document with text contained in the first text frame on the page.
2. document should have character styles for "foreground" and "background" text colors.
3. document should have paragraph style with two Grep styles (see screenshot below) that set those character styles.
The script finds all sentences and, after duplicating the first page, drops a marker character at the start and end of the current page's sentence. The paragraph style handles the formatting—all the script needs to do is drop those markers. If the script gets the sentence positions wrong—which will happen sometimes (see caveat in script)— you can just move them manually by cutting and pasting the zero width spaces (show invisibles to see them). See screenshot.
IMPORTANT: Please also download this sample indesign file (attached to this post) to see my set up.
Wow, this is amazing! Thanks!
I will try it out with your file and then see if I can make it work with my text.
It works perfectly, thank you so much!