Skip navigation
oldcompositor
Currently Being Moderated

Way to search italic spaces not flanked by italic?

Dec 4, 2012 2:17 AM

Tags: #book #grep #searches #character_style

Hi all!

 

I'm trying to eliminate (un-italicize) spurious italicized word spaces -- those that are not preceded and followed by italic characters. (The book contains more than 12,000 italic word spaces in all, so going through them manually is not reasonable.) Is there a way to search these?

 

-oldcompositor

 
Replies
  • Currently Being Moderated
    Dec 4, 2012 3:01 AM   in reply to oldcompositor

    Do you really need to unitalicise these? What difference does it make to the flow of the text?

     

    I'm not following the logic you want to search by - can you give an example?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 4, 2012 3:42 AM   in reply to oldcompositor

    While I agree with Eugene, I've been thinking about this and I believe it is doable (sort of) in several steps.

     

    The first step is to identify the ones you want to keep italic and mark them:

     

    Find (?<=[\u\l\d[:punct:]]) (?=[\u\l\d[:punct:]])  (that's a space between the look-behind and look-ahead expressions, which are checking for uppercase, lowercase, digit or punctuation) and set the find formatting to italic. Set the change formatting to make the character color some color you aren't using for text. I used red in my test.

     

    Now you need to find all spaces that are italic, but not red, and change them to the regular font, so you want to change the find to just the space character, and add Black as the character color to the find format (which will ignore the spaces you just marked red). Set the change formatting to on the font to Regular (or Roman, or whatever the correct name is).

     

    Finally, you need to go back and find red spaces and change the color back to black or whatever color they should be.

     

    I hope you can see that this is pretty limited. It will destroy your bold or bold italic spaces in strings that are bold or bold italic, it can only handle one color of type at a time and it won't work with multiple fonts that have different names for the normal font style, nor does it (as the query is set up) find anything but spacebar spaces. You can do similar searches for bold, bold italic, condensed, extendeded... (and you get the idea) font styles before converting, and you can substitute \s for the space bar in the query if you want to pick up other spaces and tabs, but it also picks up paragraph breaks and forced line breaks, which might not be desirable. By the time you finish with this, it might be just as easy to find italic spaces one at a time and decide if they need to be changed.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 4, 2012 3:59 AM   in reply to oldcompositor

    Only that . reperesents any character, including the various white space and break characters and I'm not sure you want to find those. Also, should one of those be a paragraph break I believe you run the risk of changing the style (that came up earlier this week with removing multiple returns) so the look-ahead and look-behind are somewhat safer. The advantage to using a color change instead of a symbol is that if for some reason you don't change the symbol back into a space you don't risk chaning the text flow and it will still output as a space. Colored spaces don't generate ink on a plate (though they might add a plat you could ignore in some cases).

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 4, 2012 4:11 AM   in reply to oldcompositor

    I'm curious to hear what some of the other real GREP experts have to say....

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 4, 2012 5:14 AM   in reply to oldcompositor

    oldcompositor wrote:

     

    I'm trying to eliminate (un-italicize) spurious italicized word spaces -- those that are not preceded and followed by italic characters.

     

    Now that is what separates the men from the .. what, old compositors? Yup, like you I also thoroughly dislike spurious formatting, such as bolded or italicized or even superscripted space. It messes up the overall spacing, and if you happen to type something "before" an italicized word your new text will also be cursive.

     

    With this GREP you can search for "nothing" (i.e., "no italic text") followed by a space:

     

    (?s)(?<!.)\s

     

    and this one for the right hand side, for an italic space followed by "nothing" (again, meaning "no italic text"):

     

    (?s)\s(?!.)

     

    In both cases you must make sure to have "Italic" in the Find Format field.

     

    It's possible to put both queries into a single operation:

     

     

    (?s)(?<!.)\s|\s(?!.)

    

    but be advised, at times InDesign seems to prefer the easy road with slightly more complicated expressions like these, and skip over occurrences which it really should have found. I think Peter happened across this once with one of my chained OR expressions.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points