Created
July 2, 2014 11:49
-
-
Save milligramme/0c6b93b785bbeaff8c9f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function () { | |
| var doc = app.documents.add(); | |
| var c_style = doc.characterStyles.item("cyan").isValid ? | |
| doc.characterStyles.item("cyan") : | |
| doc.characterStyles.add({name:"cyan"}); | |
| c_style.fillColor = doc.colors.item('Cyan'); | |
| var p_style = doc.paragraphStyles.item("test").isValid ? | |
| doc.paragraphStyles.item("test") : | |
| doc.paragraphStyles.add({name:"test"}); | |
| var nsg_style = p_style.nestedGrepStyles.add(); | |
| nsg_style.grepExpression = "\\\d{3}"; | |
| nsg_style.appliedCharacterStyle = c_style; | |
| var tf = doc.textFrames.add({geometricBounds: [10,10,90,120], contents:"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 333 incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 333. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}); | |
| tf.parentStory.appliedParagraphStyle = p_style; | |
| var para = tf.parentStory.paragraphs; | |
| var tsr = tf.parentStory.textStyleRanges; | |
| // alert([para.length, tsr.length]); // => 1 | |
| var reg = new RegExp(para[0].appliedParagraphStyle.nestedGrepStyles[0].grepExpression); | |
| x = para[0].contents.split(reg) | |
| alert(x.join("☗☗☗")); | |
| })(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment