Create a GREP-Style with script? [AS] [CS4]

Hi
I'm trying to ad a grep-style to a paragraph style.
It's easy to read/write properties from one that already exists but how can I create a new one?
This is in applescript, CS4
rgds /Mattias

Yep, know about Nested Grep Style.
In AS it:s http://www.indesignscriptingreference.com/CS4/AppleScript/nested-grep-style.htm
If I have a P-style in a document, with a nested grep style applied. I can read and write to that grep style by calling it:
nested grep style 1 of paragraph style "myParaStyle"
read: grep expression of ... -- -- -- -- -- -- -- Where ... is the above line
write: set grep expression of ... to "xyz"
However, if the P-style doesn't have a nested grep style applied, I can't find a way to create/insert one into the P-style.

Similar Messages

  • A GREP style not holding in CS4

    Hi,
    OK...I have been playing with a bunch of these GREP searches in CS4 where I can put them in as a stylesheet.
    I have a character style that is called superscript, that automatically makes a ® superscript when it is typed, and that is working fine.
    Then I added my lookahead for any TM or ® to add a 100 tracking in between the letter and the tm or ®. It does it if I have the type in the box and apply my style to the whole box. But, if I go in and make changes to the text, the ®-superscript automatically happens when I type a new one, but the tracking doesn't automatically happen. What's worse is, if I select the text and try to apply the style manually, it still doesn't not apply the 100 tracking. I have to make it a basic or none style and then re-apply the good one.
    If it is in the GREP style of the paragraph style, shouldn't it do it dynamically?
    Here is my image.
    thanks!!
    babs

    The only object I know of you can create an InDesign and specify whether it prints or not in the PDF is a button. That would definitely NOT work with character styles.

  • Can somebody please help me creating a GREP style to reformat all the website adresses in my layout?

    i've got this text from a client full with webadresses, some end with .com or .nl and i would like to highlight these adressess in bold and blue... i created a textstyle for it but the only thing i manage to get as a result is only the beginning of the website 'www.' i know it's possible but my skills are lacking in this departement...
    can anyone help me getting started...?

    Got it.
    parentheses group #1 (the first | separated OR group): DOS path name, because a link can also refer to a file.
    parentheses groups #2-5 (2nd OR group): e-mail address. Note: a "mailto://" prefix does not get matched here.
    parentheses groups #6-13 (3rd OR group): URL, with a mandatory prefix "http://", "https://", "ftp://", and some more ("smb://", for example, is a Samba server file prefix). This also includes "ftps://", which was unknown to me but it appears it's perfectly valid.
    It does not match the "mailto://" prefix for an e-mail address, but that's a moot point because the URL may not contain a @ character anyway.
    This group correctly recognizes URLs that contain one or more hyphens in the base name (it also correctly rejects hyphens in the domain extension).
    parentheses groups #14-15: (4th and last OR group): any non-prefixed URL, recognized solely on the basis of "any sequence of word characters, including the hyphen, followed by a period, optionally followed by some more characters (including both period and forward slash but excluding the hyphen), followed by at least two uppercase or lowercase letters.
    This last one is responsible for (a) recognizing both "deadline.com" and "keefe-studios.com" as URLs, but (b) also rejecting "www.test-test.com" -- a hyphen in the 'center', fully optional, part.
    Interestingly, there are more differences between the more exact 'match only with prefix' and the catch-all 'match about anything'. The former includes among the allowed characters: ':' (which, if I recall correctly, is only valid if a port number follows!), '#', '$', '%', '&', '?' and '+', so it matches a server query as well:
    http://www.google.com/search?hl=enl&tbo=d&site=&source=hp&q=allowed+characters+in+url&oq=a llowed+characters+in+url
    The latter does not include all of these characters, just letters, numbers, the hyphen (but not in all positions), and a period. It's probably because this is an unreliable way to match URLs after all -- hence the number of 'false hits'. These would only increase with even more allowed characters.
    Lesson learned: to be assured "Create Hyperlinks Automatically" works as expected, make sure URLs are prefixed with "http://", and mail addresses are not prefixed with "mailto://". I didn't test if the function actually creates a correct e-mail link, but even if it does the prefix is not included in the clickable linked text.
    (Also interestingly, it appears a GREP style, fed with this same query, doesn't stumble over the hyphen whereas a GREP find does. I don't think I'm capable of figuring that one out.)

  • Create a list style with unique space after the last list item?

    I should start by saying that I'm a web designer and therefore extremely used to using CSS for type setting to the point that I now become frustrated when going back to the print world
    So here's what I'm trying to achieve:
    - I want to create a list style for bullet lists
    - I want there to be 3pt space after and space before paragraph breaks
    - I want there to be 9pt space after the entire list (or last list item)
    I can't for the life of me figure out how to do this short of overriding the space after amount on the last item each time I use my style.

    Hi supportneeder
    Welcome to the forum.
    Try this link:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=179&mforum=iworktips ntrick
    Pay attention to how +"styles work by example"+. Form up the list levels the way you want them and then select them to make the list style.
    Personally I can't help remarking on the obtuse behavior of programmers that they manufactured all the problems on the internet and only now, more than a decade later, patch together "solutions" they struggle to implement due to the legacy of all the awful standards we never needed to have in the first place.
    Peter
    btw The last list item is always a problem in typesetting. Usually you deal with it by having a particular style for that or the paragraph afte,r all of which can take multiple forms.

  • How to create an object style with repeating formatting?

    I am trying to create an object style that will create my subhead formatting after each body of text; in other words, I'll have 5 or 6 subheads, all in need of the same formatting, but they will be separated by bodies of text with multiple paragraphs. How do I go about specifying this repeating formatting in an object style?

    Unless the number of paragraphs between headings is always the same, and always needs the same formatting, you can't.

  • Attempting to create a GREP Style

    I'm trying to make a GREP style for one of my paragraph styles, that will take the text from the beginning of a line until a colon and set a character style to it to bold that part.
    Example:
    Step 1: Take bread
    Step 2: Take peanut butter
    Step 3: Spread peanut butter on bread
    I don't think I've been getting the syntax right.  I've put ^\:~h and ^:~h into the 'to text' box, thinking this meant "Beginning of line until the character ':' and end" but neither of those have given me the results I want.  Thanks in advance for the help!

    Prismatus wrote:
    Your response worked for me.  I had tried using a wildcard before the ones I posted, but only put the . in, assuming it would cover more than just one character.  I assume the +? covers all characters until the colon shows up, yes?
    No, it's slightly more complicated than that (sorry!). By default, GREP is Greedy -- that means, if you use this
    ^.+:
    GREP will think that the Any Character wildcard may be repeated as much as possible (that's the '+') before it needs to match the colon. What this means is that it will work just as you expected for
    Step 1: This is a single line.
    but will go out of its mind with this
    Step 2: what will happen now? Well, contrary to what you were expecting, the entire line will be marked bold, all because everything up to the very last : will be matched!
    The bold bits accurately shows what happens! Another example would be this:
    \d+
    which for a string of "123" will not match just the first digit, then the second, then the third, but all of them in a single long go. By default, GREP will grab as much as it possibly can.
    Adding a question mark behind the "Repeat Me" character reverts this behavior to Non-Greedy behavior, and as such GREP will match as little as humanly possible:
    \d+?
    will then match just the "1" in "123".
    Prismatus wrote:
    I also like the be literal part, but I was wondering what you would have instead of \d if you had more than nine steps, or if you had substeps (1a, 1b, etc.).
    That's just a case of adding more specifiers. To match one or more digits, you need this:
    ^Step \d+:
    The '+', again, will allow a repetition of the "digit" code. In this case you don't have to add a question mark, because there is no way this could run out of control; first, it will only match digits, and second, these digits must be followed by a colon.
    And if you may or may not have a single lowercase character following the digit (but still before the colon), you'd use the Any Lowercase Character code and the Zero or Once repetition specifier:
    ^Step \d+\l?:
    (that's a lowercase ell.) You see the question mark meaning Something Entirely Different here? It's only a Non-Greedy marker when immediately following another repetition code, one of these
    * (zero or more)
    + (once or more)
    ? (zero or once)
    {4,8} (or any other set of numbers -- this is at least 4 and at most 8 times)
    Uh, by the way, that makes this
    abc??
    a valid GREP. It will match "ab" or "abc", and then always select the shortest possible match of these two, which is then the "ab" one. ... Uh. I'm pretty sure this may be useful, some time in the future.

  • Creating a GREP style Help Needed

    I would like to set-up a style using GREP expression(s) that would do the following:
    Everything preceding an em dash (including the em dash and two spaces after the em dash) would be set to bold-italic, AND everything in the paragraph that begins with the word "NOTE:" until the end of the paragraph would be regular-italic.
    Here is a sample of the kind of text I want to format with one style:
    OPERATOR PANEL - The operator panel is located on the right-hand electrical enclosure. NOTE: Not all equipment will have the same operator panel. Refer to schematics for additional information.
    "OPERATOR PANEL - " would be all bold (or bold italic). The body text is regular. the "NOTE: Not all .... " to the end would be regular-italic.
    Any help or direction to a web-site with examples would be appreciated.
    Thanks in advance.
    RPP

    It's easier than you think.
    Peter's suggestion of a regular nesting style might work, except that it's
    i always
    applied to each paragraph you apply it to. That's just what the Grep styles are for:
    i conditional
    stuff.
    The 1st half: Apply Style: Bolded To Text: ^.*? ~=
    (there should be another space after the '=')
    The 2nd half: Apply Style: Italicized To Text: NOTE:.*$
    These are both pretty much basic GREP expressions -- except for the "~=", that's Adobe's --, so just about any google to a GREP repository can explain them. I already knew the basics, but
    this page taught me some new tricks.

  • Why doesn't Grep Styles with pos lookbehind work?

    Hi,
    I've posted another thread but I suppose I expected too much. I'll try to siplify this.
    I have text where I want to catch underlined text:
    Ponny, - Cob…….499,-
    125, - 135, - 145, - 155…….399,-
    140, - 150, - 160, - 170……..99,-
    140, - 150………99,-
    This paragraph grep style works for the above:      ^\w+,\s-\s
    However, when I want to use positive look-behind to just catch the " - " it stops working.
    I have tried the following (none of them catches anything at all):
    ^(?<=\w+,)\s-\s
    (?<=^\w+,)\s-\s
    (?<=\w+,)\s-\s
    Is there a limitation as to what syntax I can use in the lookbehind?
    Pointers anyone?
    /K

    Hi Eugene,
    Lookaheads and Lookbehinds don't work when using the repeat codes, like "+" or "*" or "?" etc.
    I guessed there might be a limitation as to what works.
    Eugene Tyson wrote:
    Can you search for
    \s-\s
    And only search for underlined text in the
    Find Format
    area
    No, sorry. The underline was olnly to indicate what I was trying to grep...
    I don't want to use find-replace. I want to use the paragraph grep style.
    /K

  • Created a footnote style with language set to english but upon spell check language goes to German

    my spell check switches to german when I spell check the footnotes. The footnotes have a paragraph style that is set to English USA (under the advanced characters tab)
    Any ideas?

    Well I had another thought this morning, and you CAN use find change.
    The following GREP expression will find all characters: .+
    Set that in the find what field and leave the change to field blank. In the find format otions choose your footnote style under style options, then switch to advanced character options and set German as the language (you are looking for characters assigned the German languag in your footnotes). In the change options go to the advanced character options and change the language to English, then set the scope of the search and change all (preuming there really are no words that should be in German that you don't want to pick up as misspelled).
    The only thing this won't pick up, as far as I can tell, is the end of paragraph marker if that happens also to be set to German. You can search for that explicitly by changing the find expression to \r and rerunning the find/change.
    Peter

  • Create 'Object Style' by script

    Hi,
    My 'Library.indl' file has the 'Box1', 'Box2'. I need to create the object style(with dummy properties) based on the Library file names.
    If the library has BOX1, BOX2, I need to check my Indesign file has Object Style with the same name(BOX1, BOX2).
    If object style not presented in that particular name(BOX1, BOX2) in Indesign, I have to create the dummy Object style. (The 'object style name' should match with BOX1, BOX2.)
    Is this possible by Indesign script?
    by
    hasvi

    Hi Chinna,
    When I click 'hyphenation setting' on, I have the problems on line 54 and 55.
    If I select line 55(line 54 is deselect). script working fine.
    If I select line 54(line 55 is deselect) script is not working, but I want to select library file from the folder path, so I need line 54 action.
    Correct my script here:
    var w = new Window ("dialog", "Template Checklist", undefined, {closeButton: false});
    w.alignChildren = "left";
    var check1  = w.add ("checkbox", undefined, "Hyphenation Settings");
    var check2  = w.add ("checkbox", undefined, "Object Style creation based on Library");
    var buttons = w.add ("group");
    buttons.add ("button", undefined, "Ok");
    var Exit = 0;
    var cancel = buttons.add ("button", undefined, "Cancel")
            cancel.onClick = function()
                    w.close();
                    Exit = 1;
    w.show ();
    if(Exit ==1)
            this.exit();
    var myDocument = app.activeDocument;
    if (check1.value == true)
        var myPara=app.activeDocument.paragraphStyles;
        for(var i=1;i<myPara.length;i++)
                if(myPara[i].hyphenation)
                //myPara[i].hyphenation=true;
                myPara[i].hyphenateWordsLongerThan=6;
                myPara[i].hyphenateAfterFirst=3;
                myPara[i].hyphenateBeforeLast=3;
                myPara[i].hyphenateLadderLimit=2;
                myPara[i].hyphenationZone="1p";
                myPara[i].hyphenateCapitalizedWords=true;
                myPara[i].hyphenateLastWord=false;
                myPara[i].hyphenateAcrossColumns=false;
        var myStyle=new Array("BK_TTL","BK_HTTL")
        for(var i=0;i<myStyle.length;i++)
                if(myDocument.paragraphStyles.item(myStyle[i]).isValid)
                 myDocument.paragraphStyles.item(myStyle[i]).hyphenation = false;
    if (check2.value == true)
    alert("Library File is must for this process.");
    //~ var library = File.openDialog ("Select the Library File", "*.indl");  ////Your library file path.
    var library=new File("C:\\Users\\Jayanthi\\Desktop\\Library.indl");//Your library file path.
    app.open(library);
    asset = app.libraries[0].assets;
    for(var i=0;i<asset.length;i++)
        try{
            myDocument.objectStyles.add({name:asset[i].name});
        catch(e){}
    var ProgressBar = function(/*str*/title)
         var w = new Window('palette', ' '+title, {x:0, y:0, width:340, height:60}),
              pb = w.add('progressbar', {x:20, y:12, width:300, height:12}, 0, 100),
              st = w.add('statictext', {x:10, y:36, width:320, height:20}, '');
         st.justify = 'center';
         w.center();
         this.reset = function(msg,maxValue)
              st.text = msg;
              pb.value = 0;
              pb.maxvalue = maxValue||0;
              pb.visible = !!maxValue;
              w.show();
         this.hit = function() {++pb.value;};
         this.hide = function() {w.hide();};
         this.close = function() {w.close();};
    //      SAMPLE CODE
    function main()
         var pBar = new ProgressBar("Running");
         var i;
         // Routine #1
         pBar.reset("Please wait Processing ...", 100);
         for( i=0 ; i < 100; ++i, pBar.hit() )
              $.sleep(10);
         // Routine #2
         pBar.close();
    main();
    exit();
    by
    hasvi

  • IDCS5/MAC - GREP Style to uppercase a letter after a dash between words

    G'day there.
    I'm trying to create a GREP style to uppercase a letter after a dash between words, more specifically where one word starts with a capital and the one after a dash does not e.g. Lorem-ipsum = Lorem-Ipsum
    The full story is that there is a standing indesign file used over and over again which data-merges surnames which are in a massive database. The data arrives in uppercase and our mail barcoding software allows us to Title Case certain fields, but the Title Case behaviour has the following results:
    * McLeod = Mcleod
    * D'Agostino = D'agostino
    * Smith-Bunting = Smith-bunting
    i've been able to solve the McLeod = Mcleod problem with the following GREP style:
    (?<=Mc)\l
    and then apply a character style which is nothing more than All Caps.
    similarly, i've been able to solve the D'Agostino = D'agostino problem:
    (?<=\u')\l
    and once again apply the All Caps style to the affected letter. This also solves the O'leary problem to O'Leary.
    However, when I try these GREPs to grab the Smith-bunting style issues:
    (?<=\u\l+?-)\l     or   (?<=\u\l{2,}-)\l
    the search won't work, nor will it work with regular Find/Change GREP replace... yet the expression \u\l+?-\l will find the block that i'm after.
    I could use the search
    (?<=\l-)\l
    and this will find Smith-bunting = Smith-Bunting... but will also find co-operate = co-Operate (will find two words joined with a dash but  starts with a lower case letter).
    This is fine if the para style is applied to the  line in the address block containing the client's name, but if the name is referred to in a block of text, then that block of text has to have the para style with the GREP style applied, and any dashes between words in that para behave the same way as the name.
    yes, it is possible to go into excel and use the =PROPER(affected cell) and fix the Smith-Bunting fields, but i'm trying to create a solution which will work solely in InDesign so that other operators in the office (who aren't familiar with excel) can simply open the standing file and dump in the txt database generated by the mail barcoding software.
    there are other names that the mail barcoding's title-case fouls up i.e.
    * MacLeod = Macleod
    * van der Graaf = Van Der Graaf
    * van Diemen = Van Diemen
    but a GREP to make Macleod become MacLeod may foul up Mack, Mackie or Macy to become MacK, MacKie or MacY.
    I also know that a GREP for the van der or van won't work as the style will only force letters to become All Caps, not uppercase to lower...
    Ultimately...
    does anyone know a way to GREP style (not a find/change GREP) a fix for Xxxxx-xxxxx = Xxxxx-Xxxxx?
    Colly
    Colecandoo.

    I agree with Haakenlid on his Dirty-Workaround view -- I feel data should be entered the way it oguht to, not altered by some magic GREP styling -- but then again I can also sympathize with your POV re: a fire-and-forget solution even your dumbest operator can't miss.
    Oh the rigors of life.
    If you are totally, absolutely certain you want to do this by GREP, use this:
    (a) Set a To Capitals character style to the string
    \b\u\l+\-\l
    -- this will magically transform "Hon. Lt. Sir John Forsythe Blunt-object" into "BLUNT-Object".
    (b) Then override ( ! ) the first half again with another character style that removes the To Capitals attribute ( ! ):
    \b\u\l+-(?=\l)
    Notice how this expression is exactly the same as the above one, except for the very last code -- the next lowercase must also be caught, but now using a lookahead so its formatting won't be affected.
    This removes the All Caps override from the first halve, changing it from "BLUNT-Object" back to "Blunt-Object".
    Lots of side effects, I'm sure. Perhaps it is safer to teach your operators to run a single script.

  • How can I apply a GREP style to a text variable?

    Hello everybody,
    I have a question concerning GREP styles inside Paragraph styles.
    1. I've created a text variable to generate a recurring title on the upper side of the page based on the main title paragraph style;
    2. The recurring title is in Adobe Garamond Small Caps, all letters in lower case, and it is formatted with a paragraph style sheet in the master page;
    3. I want to create a GREP style for the recurring title, according to which every time that in the recurring title appear an apostrophe or the double quotes, they are automatically lowered 2pt on the baseline
    (I already created the character style sheet that lowers letters of 2pt).
    What I need is the correct GREP formula to automatically apply the character style sheet to apostrophes and double quotes, in the line of text generated by the text variable...
    Thanks for your  help
    p.

    Hi,
    As I said, using Power Headers is the best way to do it.
    As Power Headers treats the header as "live text", you can use a simple grep style inserted in the header para style:
    … to obtain:
    For the sample, I use a char style named "-2pts" with Shift -5 pts and Green color to show you the place of ' and ".
    Don't forget that, even Power Headers treats the header as "live text", you only have to update Power Headers to make an update of the headers! 
    Even I use in another cases Tomaxxi's [JS] and it's a good way to treat the question, Jean-Claude Tremblay's solution is less interesting because the variable used is converted in text. If the variable text content changes, it's more complicated to manage the update!

  • GREP style as part of paragraph style

    I'm wanting to create a GREP style that uses a character style. Whenever certain words (No class) appear followed by dates. Sometimes it is a single date and sometimes more than one date. For example:
    No class 7/11.
    No class 7/11-8/11.
    What I have so far is:
    No class \d+.
    This works okay through the words "No class" and the first digit, but not for the whole sentence. I've tried different combinations but nothing that works correctly.
    Can anyone help?

    Peter,
    I so much appreciate your help with this. Your explanation makes it understandable. But there is still a mystery.
    The GREP for Instructor: Instructor Name works fine. The GREP for the date sentence is not working. Instead of the date sentence becoming italic, it  matches the first part of the paragraph. This is what the GREP looks like:
    This is what the paragraph looks like with the GREP applied:
    It should look like this:
    In a separate issue in another paragraph, which is a heading paragraph, I have a similar situation. The headings are bold, some headings list ages, and some list ages AND whether parental participation is required. I thought I could extrapolate from the information you've given me to fix this paragraph as well. I've tried different combinations, but so far haven't gotten it to work. The paragraph looks like this:
    But it needs to look like this (bold paragraph with ages in regular,and parent requirement in italic):
    The heading doesn't always have an age requirement, and doesn't always require parental participation.
    The catalog is quite long, so if there is a way to fix these two types of paragraphs, it would save a ton of time.

  • Having trouble with textwrap in CS4

    I'm having a hard time getting the text wrap to work how I want it to in CS4 (running the Windows version). I have several images that I'd like to wrap text around, and in CS3 I always used the "wrap around object shape" feature, which would leave a nice little buffer around the object. When I try to do it in CS4, the text runs right up to the image, making it look pretty bad and unreadable. I'm sure this is a simple fix but I haven't been able to figure it out.
    I've attached a small image showing the problem. The example is using the "wrap text around object shape" feature.
    Thanks for any help on this

    I think there has been a change in the default settings for wrap around object shape.
    Once you have set the text wrap, open the Text Wrap panel.
    In the past there was a default setting of about 1 pica (or less).
    Now, the default setting is 0p.
    This would create what you're seeing.
    You need to change the text wrap setting.
    If youy need to do this a lot, create an object style with Text Wrap as it's attribute and set the amount to what you would like.

  • Grep style positive look behind

    I am trying to create a grep style in InDesign CC 2014 to make anything after an em space a certain character style. I have come up with
    (?<=~m[[:punct:]]\l\u\s)*?
    but it doesn't work. Must contain punctuation, spaces and words.
    Any suggestions would be appreciated.

    The correct look-behind for the em space would be (?<=~m) and what you want to find goes outside of that. (?<=~m).+ will find everything after an em space up to the end of the paragraph. (?<=~m)\S+ will find up to the next white space (so the first word following the em space). (?<=~m)[^~m]+ will find everything following an em space up to the next em space.
    It's not really clear to me what you are trying to do here. It's also not clear why you think you need a GREP style rather than a simple nested style.

Maybe you are looking for