6 Replies Latest reply on Nov 29, 2013 10:58 AM by Peter Spier

    Grep Styles

    PepiPepi

      Hello,

       

      I've not used grep style in the past, so I'm aware I'll need to do a few tutorials etc - a point in the right direction for some really good ones would be appreciated.

       

      In particular, however, I am laying out a book. Throughout the book there is editorial markup to include icons within the text fro accomodation, telephone numbers, etc. They appear as follows for example;

      [tel]

      [accom]

       

      I'd like to know how I can use Grep Styles to automatically convert this sort of text to the icons in layout, so I don't have to style each one individually, or do a find and replace.

       

      Many thanks in advance,

      P

        • 1. Re: Grep Styles
          [Jongware] Most Valuable Participant

          You need to change the text of "[tel]" to your icon, and GREP Styles do not change text, they can only apply character styles.

           

          So here is option #1: forget GREP styles and use find-and-change.

           

          Option #2 is way, way more work (but then you can use GREP styles, and everything will happen automatically and all will be flowers and sunshine from then on):

           

          1. Create a One-Character Font of your "[tel]" icon -- you can use the demo from IndyFont for this (http://www.indiscripts.com/post/2013/05/indyfont-1-1-public-pro-release-and-users-guide)

           

          2. Assign the character code for "[" to this icon.

           

          3. Add a GREP style that assigns your custom font to the character "[" when followed by 'tel':

           

          \[(?=tel\])

           

          4. Add a GREP style that assigns a blanking style to the part that should be invisible:

           

          (?<=\[)tel\]

           

          This character style should set a horizontal width of 1% and a fill color of "[None]".

           

          5. Repeat for "[accom]"

          • 2. Re: Grep Styles
            Peter Spier Most Valuable Participant (Moderator)

            Hi Jongware,

             

            Do you remember helping me with this same sort of problem a few weeks ago when I needed a custom square bullet?

             

            I ended up making ligatures from the tags like <B> and <b> and even the word bullet and adjusting the side bearings, which would eliminate the need for look-behind and a second style to set a 1% width and [None] fill. Does the demo do ligatures? I've forgotten.

             

            If not, it might be worth the price for the full version.

            • 3. Re: Grep Styles
              [Jongware] Most Valuable Participant

              Peter, yes you can create a single ligature from the entire construction "[tel]" -- but, alas, not with the demo. To create a ligature, you *also* need the original characters in the same font -- and so you can't do that using the demo.

               

              PeipiPepi does not mention what sort of icons this is about -- if they are simple monochromatic vector icons, you could experiment with the demo and see if you can get it to work. But since this uses a *font*, exactly like using a Wingdings or Dingbats font, you are automatically restricted to one color.

               

              (That said: with the *full* version, you could create a separate "border" character with a width of zero, and design the next character so that it falls exactly into the center of this border. Then it's two characters, which you can color separately.)

               

              (Also: the free demo is restricted to One Character Per One Font. For two icons, you need two fonts, which the demo happily allows; it's just a bit more cumbersome since you have to have separate character styles and GREP styles as well.)

              • 4. Re: Grep Styles
                PepiPepi Level 1

                Hi Jongware and Peter,

                 

                I should have been more specific (learning the Grep Ropes here) - I'd like to apply Grep Styles to text like [tel] and [accom] and use characters from Dingbat fonts as the icons. So assuming I can apply characters styles using Greps, this should be possible, shouldn't it?

                 

                Many thanks,

                Pepi

                • 5. Re: Grep Styles
                  Salah Fadlabi Level 5

                  apply Grep Styles to text like [tel] and [accom] and use characters from Dingbat fonts

                  On Find and Change dailgo box (grep)

                   

                  For [tel]

                  Find: tel(?=])

                  Change to: ~c

                   

                  For [accom]

                  Find: accom(?=])

                  Change to: ~c

                   

                  Important note:copy the Dingbat character before click on change.

                  • 6. Re: Grep Styles
                    Peter Spier Most Valuable Participant (Moderator)

                    Grep STYLES can only change formatting, which is why switching to a different font with the correct glyph at that position will work, but they cannot change the glyph to some other character, i.e. a grep style cannot change the word cat to dog. For that you need Find/Change.

                     

                    If you go with Find/Change, one option for the change field is to use formatted or unformatted contes from the clipboard, so it would be possible to simply copy the correct dingbat to the clipboard and then run the query, but this is not an automatic process that will happen as you type, the way a GREP style is.