8 Replies Latest reply on Apr 26, 2014 7:08 AM by Obi-wan Kenobi

    GREP Style Question (2)

    Obi-wan Kenobi Adobe Community Professional

      Hi,

       

      Imagine the following line and how I want to treat it:

       

      "There is on the left side a beautiful blue house with pink windows and yellow doors. On the right side, we find a beautiful green house with black stairs and a purple roof!"

       

      What I mean: some words where the vowels are in bold, some where the consonants are in bold, but you can not systematize it.

       

      In this case, a way to accelerate the process to treat each word? Thanks in advance! 

        • 1. Re: GREP Style Question (2)
          pixxxel schubser Level 5

          Hello Obi-wan,

          you yourself have much experience with GREP. Therefore, you know that we need a lot of much more information:

           

          Did you tested a FindCangeByList script before?

           

          The language is English?

          Your sentence is the starting point?

          Only the words shown should be treated? Or are there more words to reformat?

          Is there a screenshot of the final result?

           

          Or can you post a sample IDML with all words?

           

          I think otherwise it's impossible to help you.

          • 2. Re: GREP Style Question (2)
            Obi-wan Kenobi Adobe Community Professional

            Hi pixxxel schubser,

             

            In fact, you don't need more.

             

            There is no systematization in the choice of the words.

             

            My author indicates me what word he wants to be treated. 2 cases: All vowels or all consonants are highlighted!

             

            So the idea: I only mark the word and, automatically (with grep styles), all the vowels (case 1) or all the consonants (case 2) are highlighted!

             

            Obviously, There are 2 problems:

             

            1/ How "mark" each word to be treated (will be fixed with a little [JS] + 2 keyboard shortcuts: all vowels or all consonants). Done manually, but quickly!

             

            2/ How create the grep styles.

             

            Good luck... if you want to play! 

            • 3. Re: GREP Style Question (2)
              pixxxel schubser Level 5

              Again, the best way is IMHO  a FindChangeByList script.

              If not, you can try something like this:

               

              app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
              app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
              
              app.findTextPreferences.findWhat = "word_no_1";
              app.changeTextPreferences.changeTo = '';
              // use here the exact name of your character style you want to apply now
              // must already exist
              app.changeTextPreferences.appliedCharacterStyle = 'underlined_red';
              app.activeDocument.changeText();
              
              app.findTextPreferences.findWhat = "word_no_2";
              app.changeTextPreferences.changeTo = '';
              app.changeTextPreferences.appliedCharacterStyle = 'underlined_red';
              app.activeDocument.changeText();
              
              // now remove the formatting of all consonants
              app.findGrepPreferences.findWhat = "[^aeiou]";
              // finds the character style, that you applied previously
              app.findGrepPreferences.appliedCharacterStyle = 'underlined_red';
              app.changeGrepPreferences.changeTo = '';
              // this is depending on the language used - character style [None]
              app.changeGrepPreferences.appliedCharacterStyle = app.documents[0].characterStyles.item('[Ohne]');
              app.activeDocument.changeGrep();
              
              app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
              app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
              

               

               

              Works this for you?

              • 4. Re: GREP Style Question (2)
                [Jongware] Most Valuable Participant

                Piece of cake. It needs 2 character styles (well, one if you want everything to be the same: Bold) and 2 GREP styles, plus two invisible characters that you easily can insert without disrupting regular text flow. I used "End Nested Style" (~h) and "Invisible Non-Joiner" (~j) here; both have no hotkey by default but those are easily added if you need to do a lot of these.

                 

                GREP Style 1: [aeiou](?=\w*~h)

                GREP Style 2: [bcdfghj-np-twxyz](?=\w*~j)

                 

                ... I wonder how correct it is to insert "y" in either the consonant or vowel list. It is not a vowel in "yellow" is it? If there is a simple trick, such as "It is a consonant if followed or preceded by a vowel", you can add a Not-Bold style (or in my example, Not-Highlight, by switching Underline off) to

                 

                (?<=[aeiou])y|y(?=[aeiou])

                 

                (Only thought of this after creating the picture below. It works for switching *off* for Vowels but not for *on* for Consonants. Perhaps that needs a 4th GREP.)

                 

                grepstyle.png

                • 5. Re: GREP Style Question (2)
                  pixxxel schubser Level 5

                  Hello [Jongware],

                  nice to see you.

                   

                  But unfortunately I disagree with your proposal.

                  How is your long way ( find&replace additional also??) in which you add the invisible characters in the many different words before you can use the grep style? What is the advantage of this method?

                   

                  • 6. Re: GREP Style Question (2)
                    [Jongware] Most Valuable Participant

                    Hi pixxel,

                     

                    This does not need find&replace! That's the beauty of it. Obi-wan asked

                     

                    Obviously, There are 2 problems:

                     

                    1/ How "mark" each word to be treated (will be fixed with a little [JS] + 2 keyboard shortcuts: all vowels or all consonants). Done manually, but quickly!

                     

                    2/ How create the grep styles.

                     

                    The marking is done through inserting either an End Nested Style Here or a Non-Joiner code at the end of any word ("in the middle" also works, but then characters after it are ignored). The GREP style then automatically takes care of the highlighting.

                     

                    So all Obi-wan has to do is go over the words marked by his author and insert either of the codes. I think, based on O-w's wording, he will be receiving a document where some words in sentences are marked for highlighting. A Find&Change script will change *every* occurrence of these words.

                     

                    (Even if this is required, all that's needed is to find the words and immediately insert the correct code behind it. That's in itself a short script, well within O-w's capabilities.)

                    • 7. Re: GREP Style Question (2)
                      pixxxel schubser Level 5

                      Hi @[Jongware],

                      you need find and replace. You have to insert the hidden characters End nested Style and the Non-Joiner. My opinion is: I don't like additional hidden characters in the text.

                       

                      But sure, with this characters you can use grep styles.

                       

                       

                       

                      @Obi-wan Kenobi,

                      I wondering - is non of the given answers worth to get a feedback?

                      Works one of the solutions for you - or not?  Or did you found a different solution?

                      • 8. Re: GREP Style Question (2)
                        Obi-wan Kenobi Adobe Community Professional

                        Hi pixxxel schubser and Jongware,

                         

                        Sorry for the delay in responding.

                         

                        The way in which I was gone is what Jongware thought. I reached the same approach but mine is more complex.

                        Jongware has quite right (at least in my case). His grep code approach is very pure (using only a positive lookahead is very subtil!) and add invisible characters does not bother me at all, quite the contrary as I've already said in other posts.

                         

                        Thanks to all 2. Let me recall that, for me, this is not the outcome that is most important but the foregoing discussion